// Start with your project-level client-side javascript here.
// JQuery and lodash (_) are both included with Apostrophe, so no need to
// worry about including them on your own.
//
// This is the Javascript to handle displaying and hiding the mega menus.
// We are using this instead of CSS and the hover selector because we want to allow for touch screen users to be able to open it and have it stay open when they tap.
// Clicking also makes for a less confusing UI for users that have a hard time figuring out what is going on.
// //When clicking the same link (to close the menu) there is a race condition where the focusLost event might happen before the click event, in which case the menu flashes.
// //To fix this we will detect the special case of the user clicking the same link that is open, and ignoring the focus out in that event.
// Handle the menu losing focus. This should remove visibility of the menu normally, but not when the click will result in one of the menus from displaying or hiding (clicking the same menu button).
// Handle one of the top level menu items being clicked. This normally shows the mega menu div and chevron by applying a "display" class to the li element for the menu.
// If the menu already is open then the menu should close. If another menu was already open then close it here so that there is a nice smooth transition.