1 line
7.1 KiB
JavaScript
1 line
7.1 KiB
JavaScript
|
!function(){"use strict";if("querySelector"in document&&"addEventListener"in window){Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){var t=this;if(!document.documentElement.contains(this))return null;do{if(t.matches(e))return t;t=t.parentElement}while(null!==t);return null});for(var e=document.querySelectorAll(".menu-toggle"),t=document.querySelectorAll("nav .dropdown-menu-toggle"),n=document.querySelectorAll("nav ul a"),c=document.querySelector(".mobile-menu-control-wrapper"),i=document.body,u=document.documentElement,d=function(e){if(i.classList.contains("dropdown-hover"))for(var t=e.querySelectorAll("li.menu-item-has-children"),n=0;n<t.length;n++)t[n].querySelector(".dropdown-menu-toggle").removeAttribute("tabindex"),t[n].querySelector(".dropdown-menu-toggle").setAttribute("role","presentation"),t[n].querySelector(".dropdown-menu-toggle").removeAttribute("aria-expanded"),t[n].querySelector(".dropdown-menu-toggle").removeAttribute("aria-label")},l=function(e){"false"!==e.getAttribute("aria-expanded")&&e.getAttribute("aria-expanded")?(e.setAttribute("aria-expanded","false"),e.setAttribute("aria-label",generatepressMenu.openSubMenuLabel)):(e.setAttribute("aria-expanded","true"),e.setAttribute("aria-label",generatepressMenu.closeSubMenuLabel))},s=function(e,t){var n,s,o="";(o=(t=t||this).getAttribute("data-nav")?document.getElementById(t.getAttribute("data-nav")):document.getElementById(t.closest("nav").getAttribute("id")))&&(n=!1,t.closest(".mobile-menu-control-wrapper")&&(n=!0),s=o.getElementsByTagName("ul")[0],o.classList.contains("toggled")?(o.classList.remove("toggled"),u.classList.remove("mobile-menu-open"),s.setAttribute("aria-hidden","true"),t.setAttribute("aria-expanded","false"),(n||c&&o.classList.contains("main-navigation"))&&c.classList.remove("toggled"),d(s)):(o.classList.add("toggled"),u.classList.add("mobile-menu-open"),s.setAttribute("aria-hidden","false"),t.setAttribute("aria-expanded","true"),n?(c.classList.add("toggled"),c.querySelector(".search-item")&&c.querySelector(".search-item").classList.contains("active")&&c.querySelector(".search-item").click()):c&&o.classList.contains("main-navigation")&&c.classList.add("toggled"),function(e){if(i.classList.contains("dropdown-hover"))for(var t=e.querySelectorAll("li.menu-item-has-children"),n=0;n<t.length;n++)t[n].querySelector(".dropdown-menu-toggle").setAttribute("tabindex","0"),t[n].querySelector(".dropdown-menu-toggle").setAttribute("role","button"),t[n].querySelector(".dropdown-menu-toggle").setAttribute("aria-expanded","false"),t[n].querySelector(".dropdown-menu-toggle").setAttribute("aria-label",generatepressMenu.openSubMenuLabel)}(s)))},o=0;o<e.length;o++)e[o].addEventListener("click",s,!1);for(var r=function(e,t){var n;if(((t=t||this).closest("nav").classList.contains("toggled")||u.classList.contains("slide-opened"))&&!i.classList.contains("dropdown-click")){e.preventDefault();var s,o=t.closest("li");if(l(o.querySelector(".dropdown-menu-toggle")),s=o.querySelector(".sub-menu")?o.querySelector(".sub-menu"):o.querySelector(".children"),generatepressMenu.toggleOpenedSubMenus)for(var r=(n=o,Array.prototype.filter.call(n.parentNode.children,function(e){return e!==n})),a=0;a<r.length;a++)r[a].classList.contains("sfHover")&&(r[a].classList.remove("sfHover"),r[a].querySelector(".toggled-on").classList.remove("toggled-on"),l(r[a].querySelector(".dropdown-menu-toggle")));o.classList.toggle("sfHover"),s.classList.toggle("toggled-on")}e.stopPropagation()},o=0;o<t.length;o++)t[o].addEventListener("click",r,!1),t[o].addEventListener("keypress",function(e){13===(e.which||e.keyCode)&&r(e,this)},!1);var a=function(){for(var e=document.querySelectorAll(".toggled, .has-active-search"),t=0;t<e.length;t++){var n=e[t].querySelector(".menu-toggle");if(c&&!n.closest("nav").classList.contains("mobile-menu-control-wrapper")&&(n=c.querySelector(".menu-toggle")),n&&null===n.offsetParent){if(e[t].classList.contains("toggled")){var
|