1 line
6.8 KiB
JavaScript
1 line
6.8 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}while(null!==(t=t.parentElement));return null});var o=function(t){return Array.prototype.filter.call(t.parentNode.children,function(e){return e!==t})},e=document.querySelectorAll(".menu-toggle"),t=document.querySelectorAll("nav .dropdown-menu-toggle"),n=document.querySelectorAll("nav .main-nav ul a"),l=document.querySelector(".mobile-menu-control-wrapper"),r=document.body,c=document.documentElement,u=function(e){if(e&&r.classList.contains("dropdown-hover")){var t=e.querySelectorAll("li.menu-item-has-children");for(p=0;p<t.length;p++)t[p].querySelector(".dropdown-menu-toggle").removeAttribute("tabindex"),t[p].querySelector(".dropdown-menu-toggle").setAttribute("role","presentation"),t[p].querySelector(".dropdown-menu-toggle").removeAttribute("aria-expanded"),t[p].querySelector(".dropdown-menu-toggle").removeAttribute("aria-label")}},a=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"),c.classList.remove("mobile-menu-open"),s&&s.setAttribute("aria-hidden","true"),t.setAttribute("aria-expanded","false"),(n||l&&o.classList.contains("main-navigation"))&&l.classList.remove("toggled"),u(s)):(o.classList.add("toggled"),c.classList.add("mobile-menu-open"),s&&s.setAttribute("aria-hidden","false"),t.setAttribute("aria-expanded","true"),n?(l.classList.add("toggled"),l.querySelector(".search-item")&&l.querySelector(".search-item").classList.contains("active")&&l.querySelector(".search-item").click()):l&&o.classList.contains("main-navigation")&&l.classList.add("toggled"),function(e){if(e&&r.classList.contains("dropdown-hover")){var t=e.querySelectorAll("li.menu-item-has-children");for(p=0;p<t.length;p++)t[p].querySelector(".dropdown-menu-toggle").setAttribute("tabindex","0"),t[p].querySelector(".dropdown-menu-toggle").setAttribute("role","button"),t[p].querySelector(".dropdown-menu-toggle").setAttribute("aria-expanded","false"),t[p].querySelector(".dropdown-menu-toggle").setAttribute("aria-label",generatepressMenu.openSubMenuLabel)}}(s)))};for(p=0;p<e.length;p++)e[p].addEventListener("click",s,!1);var i=function(e,t){if(((t=t||this).closest("nav").classList.contains("toggled")||c.classList.contains("slide-opened"))&&!r.classList.contains("dropdown-click")){e.preventDefault();var n=t.closest("li");if(a(n.querySelector(".dropdown-menu-toggle")),t=n.querySelector(".sub-menu")?n.querySelector(".sub-menu"):n.querySelector(".children"),generatepressMenu.toggleOpenedSubMenus){var s=o(n);for(p=0;p<s.length;p++)s[p].classList.contains("sfHover")&&(s[p].classList.remove("sfHover"),s[p].querySelector(".toggled-on").classList.remove("toggled-on"),a(s[p].querySelector(".dropdown-menu-toggle")))}n.classList.toggle("sfHover"),t.classList.toggle("toggled-on")}e.stopPropagation()};for(p=0;p<t.length;p++)t[p].addEventListener("click",i,!1),t[p].addEventListener("keypress",function(e){"Enter"!==e.key&&" "!==e.key||i(e,this)},!1);var d=function(){var e=document.querySelectorAll(".toggled, .has-active-search");for(p=0;p<e.length;p++){var t=e[p].querySelector(".menu-toggle");if((t=l&&!t.closest("nav").classList.contains("mobile-menu-control-wrapper")?l.querySelector(".menu-toggle"):t)&&null===t.offsetParent){i
|