{"version":3,"file":"hamburger-menu.js","sources":["hamburger-menu.js"],"sourcesContent":["/**\n * @file\n * A JavaScript file for the hamburger menu.\n *\n */\n\n(function ($) {\n\n var event = (navigator.userAgent.match(/iPhone/i)) ? \"touchstart\" : \"click\";\n\n Drupal.behaviors.hamburgerMenu = {\n attach: function (context) {\n\n // Attach click function for hamburger toggle.\n var toggleButton = document.getElementById( 'hamburger' );\n // Clicking the button\n // NOTE: need to update this for touchstart?\n toggleButton.onclick = function() {\n $('#navigation-panel').slideToggle(); // open dropdown\n // $('#search-box-wrapper').removeClass('open'); // close search box if open\n // 1. Toggle class \"is-active\"\n // 2. Set aria-expanded to true or false.\n if ( -1 !== toggleButton.className.indexOf( 'is-active' ) ) {\n toggleButton.className = toggleButton.className.replace( ' is-active', '' );\n toggleButton.setAttribute( 'aria-expanded', 'false' );\n } else {\n toggleButton.className += ' is-active';\n toggleButton.setAttribute( 'aria-expanded', 'true' );\n }\n // close search box if is open\n $('#search-box-wrapper').removeClass('open');\n };\n\n $('#navigation-panel .wrapper__menu--main > ul.menu').prepend('
  • Home
  • ');\n\n /**\n * Set the main menu submenu accordions for hamburger navigation\n *\n */\n $('#hamburger-navigation .wrapper__menu--main ul.menu li > button').each(function() {\n var buttonText = \"\" + $(this).text() + \"\";\n var linkIdentifier = $(this).text().replace(/\\s+/g, '-').toLowerCase();\n\n $(this)\n .html(buttonText)\n .addClass('mobile-submenu__trigger')\n .attr('aria-expanded', 'false')\n .attr('aria-controls', linkIdentifier + '-submenu')\n .attr('id', linkIdentifier + '-submenu-controls')\n .next('ul').attr('aria-hidden', 'true')\n .attr('id', linkIdentifier + '-submenu')\n .addClass('submenu');\n });\n\n function mainMenuAccordions() {\n // Attach click function for submenu accordion toggle\n $('#hamburger-navigation .mobile-submenu__trigger').each(function() {\n\n $(this)\n .off(event)\n .on(event, function(e) {\n // Add accordion functionality\n $(this).toggleClass('open').next('.submenu').slideToggle('500');\n // Amend aria values as needed\n if ($(this).hasClass('open')) {\n $(this).attr('aria-expanded', 'true')\n .next().attr('aria-hidden', 'false');\n } else {\n $(this).attr('aria-expanded', 'false')\n .next().attr('aria-hidden', 'true');\n }\n });\n });\n\n // Everything should be closed on page load\n $('#hamburger-navigation .submenu').hide();\n\n }\n\n // Call function\n mainMenuAccordions();\n\n // close the menu if the user clicks outside of it or clicks the esc key\n $( document ).on(event, function(e) {\n var container = $(\"header\");\n\n if ( $('#hamburger-navigation').css('display') === 'block' ) {\n // if the target of the click isn't the container nor a descendant of the container\n if (!container.is(e.target) && container.has(e.target).length === 0) {\n // hide the hamburger menu and reset the classes and aria code\n $('#navigation-panel').slideUp();\n toggleButton.className = toggleButton.className.replace( ' is-active', '' );\n toggleButton.setAttribute( 'aria-expanded', 'false' );\n }\n }\n });\n\n $( document ).on('keydown', function(e) {\n $areaexpandedtrue = $('#hamburger[aria-expanded=true]');\n\n if ( $('#hamburger-navigation').css('display') === 'block' ) {\n if($areaexpandedtrue.length){\n if ( e.keyCode === 27 ) { // ESC\n // hide the hamburger menu and reset the classes and aria code\n $('#navigation-panel').slideUp();\n toggleButton.className = toggleButton.className.replace( ' is-active', '' );\n toggleButton.setAttribute( 'aria-expanded', 'false' );\n toggleButton.focus();\n }\n }\n }\n });\n\n }\n };\n\n})(jQuery);\n"],"names":["$","event","navigator","userAgent","match","Drupal","behaviors","hamburgerMenu","attach","context","toggleButton","document","getElementById","onclick","slideToggle","className","indexOf","replace","setAttribute","removeClass","prepend","each","buttonText","this","text","linkIdentifier","toLowerCase","html","addClass","attr","next","off","on","e","toggleClass","hasClass","hide","container","css","is","target","has","length","slideUp","$areaexpandedtrue","keyCode","focus","jQuery"],"mappings":"CAMA,SAAWA,GAET,IAAIC,EAASC,UAAUC,UAAUC,MAAM,WAAc,aAAe,QAEpEC,OAAOC,UAAUC,cAAgB,CAC/BC,OAAQ,SAAUC,GAGhB,IAAIC,EAAeC,SAASC,eAAgB,aAG5CF,EAAaG,QAAU,WACrBb,EAAE,qBAAqBc,eAIjB,IAAMJ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