{"version":3,"file":"accessible-menus.js","sources":["accessible-menus.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.accessibleMenus = {\n attach: function (context) {\n\n $('#desktop-navigation').addClass('dropdown-menu');\n\n $('#desktop-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('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 // Dropdown menus need to accommodate keyboard navigation\n function dropDownMenus() {\n // Attach click function to submenu trigger\n $('.submenu__trigger').each(function() {\n\n // start with submenus closed (useful for resizing)\n $(this).attr('aria-expanded', 'false').next('.submenu').attr('aria-hidden', 'true').parent().removeClass('expanded-dropdown');\n\n $(this)\n .off(event)\n .on(event, function(e) {\n // Add accordion functionality\n $(this).parent().toggleClass('expanded-dropdown');\n // Amend aria values as needed\n if ($(this).parent().hasClass('expanded-dropdown')) {\n $(this).parent().removeClass('not-expanded');\n $(this).attr('aria-expanded', 'true')\n .next().attr('aria-hidden', 'false');\n } else {\n $(this).parent().addClass('not-expanded');\n $(this).attr('aria-expanded', 'false')\n .next().attr('aria-hidden', 'true');\n }\n\n $('.submenu__trigger').not(this).parent().removeClass('expanded-dropdown');\n $('.submenu__trigger').not(this).attr('aria-expanded', 'true').next().attr('aria-hidden', 'false');\n\n });\n });\n\n // submenus should have any inline styles removed that might be there from resizing from hamburger menu\n $('#desktop-navigation .submenu').removeAttr('style');\n }\n\n // close the submenus if the user clicks outside of them\n $( document ).on(event, function(e) {\n var container = $(\"#desktop-navigation\");\n\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 menus by resetting the classes and aria code\n $('.submenu__trigger').each(function() {\n $(this).parent().removeClass('expanded-dropdown');\n $(this).parent().removeClass('not-expanded');\n });\n }\n });\n\n // Call function\n dropDownMenus();\n\n $( window ).on( \"load resize orientationchange\", function( event ) {\n setTimeout(function( event ) {\n dropDownMenus();\n }, 100);\n });\n\n }\n };\n\n})(jQuery);\n"],"names":["$","event","navigator","userAgent","match","Drupal","behaviors","accessibleMenus","attach","context","dropDownMenus","each","this","attr","next","parent","removeClass","off","on","e","toggleClass","hasClass","addClass","not","removeAttr","buttonText","text","linkIdentifier","replace","toLowerCase","html","document","container","is","target","has","length","window","setTimeout","jQuery"],"mappings":"CAMA,SAAWA,GAET,IAAIC,EAASC,UAAUC,UAAUC,MAAM,WAAc,aAAe,QAEpEC,OAAOC,UAAUC,gBAAkB,CACjCC,OAAQ,SAAUC,GAoBhB,SAASC,IAEPV,EAAE,qBAAqBW,KAAK,WAG1BX,EAAEY,MAAMC,KAAK,gBAAiB,SAASC,KAAK,YAAYD,KAAK,cAAe,QAAQE,SAASC,YAAY,qBAEzGhB,EAAEY,MACCK,IAAIhB,GACJiB,GAAGjB,EAAO,SAASkB,GAElBnB,EAAEY,MAAMG,SAASK,YAAY,qBAEzBpB,EAAEY,MAAMG,SAASM,SAAS,sBAC5BrB,EAAEY,MAAMG,SAASC,YAAY,gBAC7BhB,EAAEY,MAAMC,KAAK,gBAAiB,QAC3BC,OAAOD,KAAK,cAAe,WAE9Bb,EAAEY,MAAMG,SAASO,SAAS,gBAC1BtB,EAAEY,MAAMC,KAAK,gBAAiB,SAC3BC,OAAOD,KAAK,cAAe,SAGhCb,EAAE,qBAAqBuB,IAAIX,MAAMG,SAASC,YAAY,qBACtDhB,EAAE,qBAAqBuB,IAAIX,MAAMC,KAAK,gBAAiB,QAAQC,OAAOD,KAAK,cAAe,aAMhGb,EAAE,gCAAgCw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