{"version":3,"sources":["js/jquery.ucMenu.js"],"names":["$","Drupal","behaviors","ucalgaryMenu","isInitialized","attach","context","this","$menu","$hamburger","on","event","attr","preventDefault","closest","hasClass","is","toggleMenu","lowerLevel","tabbed","activeTab","active","isMenuOpen","parentsUntil","removeClass","not","addClass","parents","target","currentTarget","resetMenus","off","height","document","container","has","length","trigger","window","updateDropdownHeight","each","appendTo","parent","last","$dropdown","dropdownHeight","$subMenu","index","curTabsHeight","outerHeight","position","top","$links","curLinksHeight","parseInt","css","openClickedMenu","$clickedMenu","children","siblings","closeClickedMenu","jQuery"],"mappings":"CAAA,SAAWA,EAAGC,GACZ,aAEAA,EAAOC,UAAUC,aAAe,CAC9BC,eAAe,EACfC,OAAQ,SAAUC,GAChB,IAAIC,KAAKH,cAAT,CAGAG,KAAKH,eAAgB,EAGrB,IAAII,EAAQR,EAAE,YACVS,EAAaT,EAAE,aAAcQ,GA0HjCR,EAAE,0BAA2BQ,GAAOE,GAAG,SAAS,SAAUC,GAC3B,MAAzBX,EAAEO,MAAMK,KAAK,SACfD,EAAME,oBAOVb,EAAE,0BAA2BQ,GAAOE,GAAG,mBAAmB,SAAUC,GAClE,GAA6B,MAAzBX,EAAEO,MAAMK,KAAK,QACXZ,EAAEO,MAAMO,QAAQ,MAAMC,SAAS,kBAE5Bf,EAAEO,MAAMO,QAAQ,MAAME,GAAG,mBAC5BC,EAAWjB,EAAEO,MAAMO,QAAQ,gBAKrBd,EAAEO,MAAMO,QAAQ,MAAMC,SAAS,YACvCE,EAAWjB,EAAEO,MAAMO,QAAQ,oBAG1B,CAEH,IAAII,EAAalB,EAAEO,MAAMO,QAAQ,MAAMC,SAAS,WAAaf,EAAEO,MAAMO,QAAQ,MAAMC,SAAS,UACxFI,EAASnB,EAAEO,MAAMO,QAAQ,aAAaC,SAAS,UAC/CK,EAAYpB,EAAEO,MAAMO,QAAQ,wCAAwCC,SAAS,kBAC7EM,EAASrB,EAAEO,MAAMO,QAAQ,qBAAqBC,SAAS,kB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ClBnC,KACHb,EAAW4B,QAAQ,SAIrBP,IAGA2B,EAAa/B,SAAS,kBACnBgC,SAAS,MAAMhC,SAAS,0BAC3B+B,EAAa9B,QAAQ,mBAAmBD,SAAS,kBAIjDa,EADgBvC,EAAE,uBAAwByD,IAO5C,SAASxC,EAAWwC,GACdA,EAAa3C,QAAQ,MAAMC,SAAS,2BACtC0C,EAAaE,WAAWlC,IAAI,iBAAiBV,SAAS,kBAEtDyC,EAAgBC,GAETzD,EAAE,sCAAuCQ,GAAO4B,OAEnDqB,EAAa1C,SAAS,kBACvB0C,EAAa1C,SAAS,mBAAqB0C,EAAa1C,SAAS,mBAC9DO,KACFb,EAAW4B,QAAQ,UAKrBrC,EAAE,uBAAwBQ,GACvBE,GAAG,oDAAoD,SAAUC,GAC5DA,EAAMiB,SAAWjB,EAAMkB,gBAEzB2B,EAAgBC,GAEhBzD,EAAE,uBAAwBQ,GAAOuB,IAAI,wDAhDjD,SAA0B0B,GACxBA,EAAajC,YAAY,kBAAkBG,QAAQ,UAAUH,YAAY,kBACzExB,EAAE,qBAAsBQ,GAAOwB,OAAO,GAiDlC4B,CAAiB5D,EAAE,sCAAuCQ,IAC1DgD,EAAgBC,IAIlBD,EAAgBC,GAElBzD,EAAE,oBAAqBQ,GAAOkB,SAAS,0BAlI/C,CA6RGmC,OAAQ5D","file":"jquery.ucMenu.js","sourcesContent":["(function ($, Drupal) {\n 'use strict';\n\n Drupal.behaviors.ucalgaryMenu = {\n isInitialized: false,\n attach: function (context) {\n if (this.isInitialized) {\n return;\n }\n this.isInitialized = true;\n\n // Store our key menu objects.\n var $menu = $('#uc-menu');\n var $hamburger = $('#hamburger', $menu);\n\n function updateDropdownHeight($dropdown) {\n if ($dropdown.length) {\n var dropdownHeight = 0;\n if ($dropdown.hasClass('tabbed')) {\n var $subMenu = $('> li:not(.menu-block-item)', $dropdown);\n // Find the tallest section of the tabbed dropdown.\n $subMenu.each(function (index) {\n // Left-hand tabs section.\n if (index === $subMenu.length - 1) {\n // Find height and top position of last tab for tabs height.\n var curTabsHeight = $(this).outerHeight(true) + $(this).position().top;\n if (curTabsHeight > dropdownHeight) {\n dropdownHeight = curTabsHeight;\n }\n }\n // Right-hand links section.\n var $links = $('ul.level3.uc-submenu', this);\n var curLinksHeight = $links.outerHeight(true);\n // Need to factor in VISIBLE menu's top position for links height.\n if ($links.position()) {\n // The top value of this element accounts for the space that is\n // used by the overview link.\n curLinksHeight += parseInt($links.css('top'), 10);\n }\n if (curLinksHeight > dropdownHeight) {\n dropdownHeight = curLinksHeight;\n }\n });\n }\n else {\n dropdownHeight = $('div.uc-sublinks', $dropdown).outerHeight(true);\n }\n\n $dropdown.height(dropdownHeight);\n }\n }\n\n function isMenuOpen() {\n return $hamburger.hasClass('uc-menu-open');\n }\n\n function resetMenus() {\n // Reset any existing 'active' menus...\n $('.uc-active-path', $menu).removeClass('uc-active-path');\n $('.uc-active-link', $menu).removeClass('uc-active-link');\n $('.uc-active-link-submenu', $menu).removeClass('uc-active-link-submenu');\n }\n\n function resetMenuState() {\n // Reset any existing menus...\n resetMenus();\n // Reset user's current position.\n $('ul.level1.uc-menu', $menu).removeClass('uc-off-current-path');\n // Reset hamburger/menu state.\n $hamburger.removeClass('uc-menu-open uc-mobile-menu-open uc-desktop-menu-open');\n }\n\n function closeClickedMenu($clickedMenu) {\n $clickedMenu.removeClass('uc-active-link').parents('ul, li').removeClass('uc-active-path');\n $('.level2.uc-submenu', $menu).height(0); // Reset menu height.\n }\n\n function openClickedMenu($clickedMenu) {\n if (!isMenuOpen()) {\n $hamburger.trigger('click'); // Initiate open animation.\n }\n\n // Reset any existing menus...\n resetMenus();\n\n // ...and rebuild the display logic.\n $clickedMenu.addClass('uc-active-link')\n .children('ul').addClass('uc-active-link-submenu');\n $clickedMenu.parents('ul, li.children').addClass('uc-active-path');\n\n // Grab the dropdown height and trigger desktop dropdown menu animation.\n var $openMenu = $('ul.level2.uc-submenu', $clickedMenu);\n updateDropdownHeight($openMenu);\n }\n\n //\n // Menu state logic.\n //\n function toggleMenu($clickedMenu) {\n if ($clickedMenu.closest('ul').hasClass('uc-active-link-submenu') ||\n $clickedMenu.siblings().not('.uc-main-menu').hasClass('uc-active-link')) {\n // Digging deeper on mobile menu, or clicking tabs on desktop menu.\n openClickedMenu($clickedMenu);\n }\n else if ($('li[class*=\"uc-active\"].uc-main-menu', $menu).length) {\n // Clicked main menu already open, so close it (impossible on mobile)!\n if ($clickedMenu.hasClass('uc-main-menu') &&\n ($clickedMenu.hasClass('uc-active-path') || $clickedMenu.hasClass('uc-active-link'))) {\n if (isMenuOpen()) {\n $hamburger.trigger('click'); // Initiate close animation.\n }\n }\n // Main menu other than clicked menu is open, so close it first...\n else {\n $('ul.level2.uc-submenu', $menu)\n .on('transitionend webkitTransitionEnd oTransitionEnd', function (event) {\n if (event.target === event.currentTarget) {\n // ...and open the clicked menu.\n openClickedMenu($clickedMenu);\n // Remove event handler.\n $('ul.level2.uc-submenu', $menu).off('transitionend webkitTransitionEnd oTransitionEnd');\n }\n });\n closeClickedMenu($('li[class*=\"uc-active\"].uc-main-menu', $menu));\n openClickedMenu($clickedMenu);\n }\n }\n else {\n openClickedMenu($clickedMenu);\n }\n $('ul.level1.uc-menu', $menu).addClass('uc-off-current-path');\n }\n\n // We capture the focus and mousedown events below, but we need to\n // preventDefault on the click event to prevent a # being added to the url\n $('.uc-menu-wrapper li > a', $menu).on('click', function (event) {\n if ($(this).attr('href') === '#') {\n event.preventDefault();\n }\n });\n\n //\n // Main menu event handler.\n //\n $('.uc-menu-wrapper li > a', $menu).on('focus mousedown', function (event) {\n if ($(this).attr('href') === '#') {\n if ($(this).closest('li').hasClass('uc-active-link')) {\n // Tabbing backwards and hitting a new level 1 menu item.\n if (!$(this).closest('ul').is('.tabbed.level2')) {\n toggleMenu($(this).closest('li.children'));\n }\n }\n // Tabbing or clicking forward and hitting a level 1 or 2 item.\n // Skip for level 1/2 back items.\n else if (!$(this).closest('li').hasClass('uc-back')) {\n toggleMenu($(this).closest('li.children'));\n }\n }\n else {\n\n let lowerLevel = $(this).closest('ul').hasClass('level3') || $(this).closest('ul').hasClass('level4');\n let tabbed = $(this).closest('ul.level2').hasClass('tabbed');\n let activeTab = $(this).closest('li.uc-active-link:not(.uc-main-menu)').hasClass('uc-active-link');\n let active = $(this).closest('li.uc-active-link').hasClass('uc-active-link');\n\n if (!isMenuOpen()) {\n // If menu is closed and focus is happening on a lower level menu item,\n // then we know its being tabbed to backwards and needs multiple parents\n // to be clicked open in order.\n if (lowerLevel) {\n toggleMenu( $(this).parentsUntil('.level1.uc-submenu', 'li.children'));\n toggleMenu( $(this).parentsUntil('.level2.uc-submenu', 'li.children'));\n }\n // Otherwise we can just call the toggle as normal.\n else {\n toggleMenu($(this).closest('li.children'));\n }\n }\n else {\n // If we are tabbing backwards and hit a level 3 or level 4 menu item\n // that is on a different tab that is closed.\n if (tabbed && !activeTab && lowerLevel) {\n toggleMenu( $(this).parentsUntil('.level2.uc-submenu', 'li.children'));\n }\n // If we are tabbing backwards and hit an inactive level 2 non-tabbed\n // menu item.\n else if (!tabbed && !active) {\n toggleMenu($(this).closest('li.children'));\n }\n }\n }\n return false; // Prevent # in address bar\n });\n\n //\n // 'Back' links (for mobile).\n //\n $('li.uc-back > a').on('click', function () {\n // Use 'closest()' to support link in non-tabbed '.uc-sublinks' wrapper.\n $(this).closest('ul').removeClass('uc-active-link-submenu')\n .closest('li.children').removeClass('uc-active-link')\n .closest('ul').removeClass('uc-active-path').not('.level1').addClass('uc-active-link-submenu')\n .closest('li.children').removeClass('uc-active-path').addClass('uc-active-link')\n .parents('ul, li').addClass('uc-active-path');\n $('ul.level1.uc-menu', $menu).addClass('uc-off-current-path');\n return false; // Prevent # in address bar\n });\n\n //\n // Hamburger menu visibility/animation toggle.\n //\n $hamburger.on('click', function () {\n if (isMenuOpen()) {\n $('.uc-menu-wrapper', $menu).addClass('uc-menu-toggle');\n $('.uc-menu-wrapper, ul.level2.uc-submenu', $menu)\n .on('transitionend webkitTransitionEnd oTransitionEnd', function (event) {\n if (event.target === event.currentTarget) {\n $('.uc-menu-wrapper', $menu).removeClass('uc-menu-toggle');\n // Reset all menu settings after animation is complete\n // to prevent any weird flashes of default menu states.\n resetMenuState();\n $('.uc-menu-wrapper, ul.level2.uc-submenu', $menu)\n .off('transitionend webkitTransitionEnd oTransitionEnd');\n }\n });\n // Reset menu to trigger the close animations.\n $hamburger.removeClass('uc-mobile-menu-open');\n $('ul.level2.uc-submenu', $menu).height(0);\n }\n else {\n $('.uc-menu-wrapper', $menu).addClass('uc-menu-toggle');\n $('.uc-menu-wrapper, ul.level2.uc-submenu', $menu)\n .on('transitionend webkitTransitionEnd oTransitionEnd', function (event) {\n if (event.target === event.currentTarget) {\n $('.uc-menu-wrapper', $menu).removeClass('uc-menu-toggle');\n $('.uc-menu-wrapper, ul.level2.uc-submenu', $menu)\n .off('transitionend webkitTransitionEnd oTransitionEnd');\n }\n });\n // Initialize open animations.\n $hamburger.addClass('uc-menu-open uc-mobile-menu-open uc-desktop-menu-open');\n }\n });\n\n //\n // Auto-close menu.\n //\n $(document).on('mousedown focusin', function (event) {\n if (isMenuOpen()) {\n // Clicking somewhere outside of this object makes the menu close...\n var container = $menu;\n // ...If the target of the event isn't the container itself\n // ...Nor a descendant of the container\n if (!container.is(event.target) && container.has(event.target).length === 0) {\n $hamburger.trigger('click'); // Initiate close animation.\n }\n }\n });\n\n $(window).on('resize', function (event) {\n // Grab the dropdown height and trigger desktop dropdown menu animation.\n var $openMenu = $('ul.level2.uc-submenu[class*=\"uc-active-\"]', $menu);\n updateDropdownHeight($openMenu);\n });\n\n //\n // If an advertising menu block is specified, we expect it\n // to be the last child in the list... Otherwise, move it.\n //\n $('li.menu-block-item', $menu).not(':last-child').each(function () {\n $(this).appendTo($(this).parent());\n });\n\n //\n // Mark the path up from the user's current page location. This is\n // useful for adjusting the mobile menu display when first opened.\n // (The 'current' class is a little too generic for this use-case)\n // (The 'is-active' class gets set later so dig down to last link)\n //\n $('li.current > a', $menu).last().closest('ul').addClass('uc-current-link-submenu')\n .parent('li').addClass('uc-current-link')\n .parents('ul, li').addClass('uc-current-path');\n }\n };\n\n})(jQuery, Drupal);\n"]}