2 lines
4.1 KiB
JavaScript
2 lines
4.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"),o=document.querySelectorAll("nav ul a"),n=document.body,r=document.documentElement,s=function(e,t){if(!t)t=this;if(t.getAttribute("data-nav"))var o=document.getElementById(t.getAttribute("data-nav"));else o=document.getElementById(t.closest("nav").getAttribute("id"));var s=o.getElementsByTagName("ul")[0];if(o.classList.contains("toggled")){if(o.classList.remove("toggled"),r.classList.remove("mobile-menu-open"),s.setAttribute("aria-hidden","true"),t.setAttribute("aria-expanded","false"),n.classList.contains("dropdown-hover"))for(var l=s.querySelectorAll("li.menu-item-has-children"),i=0;i<l.length;i++)l[i].querySelector(".dropdown-menu-toggle").removeAttribute("tabindex"),l[i].querySelector(".dropdown-menu-toggle").setAttribute("role","presentation"),l[i].querySelector(".dropdown-menu-toggle").removeAttribute("aria-expanded")}else if(o.classList.add("toggled"),r.classList.add("mobile-menu-open"),s.setAttribute("aria-hidden","false"),t.setAttribute("aria-expanded","true"),n.classList.contains("dropdown-hover"))for(l=s.querySelectorAll("li.menu-item-has-children"),i=0;i<l.length;i++)l[i].querySelector(".dropdown-menu-toggle").setAttribute("tabindex","0"),l[i].querySelector(".dropdown-menu-toggle").setAttribute("role","button"),l[i].querySelector(".dropdown-menu-toggle").setAttribute("aria-expanded","false")},l=0;l<e.length;l++)e[l].addEventListener("click",s,!1);var i=function(e,t){if(!t)t=this;if((t.closest("nav").classList.contains("toggled")||r.classList.contains("slide-opened"))&&!n.classList.contains("dropdown-click")){e.preventDefault();var o=t.closest("li"),s=o.querySelector(".dropdown-menu-toggle");if("false"==s.getAttribute("aria-expanded")?s.setAttribute("aria-expanded","true"):s.setAttribute("aria-expanded","false"),o.querySelector(".sub-menu"))var l=o.querySelector(".sub-menu");else l=o.querySelector(".children");o.classList.toggle("sfHover"),l.classList.toggle("toggled-on")}e.stopPropagation()};for(l=0;l<t.length;l++)t[l].addEventListener("click",i,!1),t[l].addEventListener("keypress",function(e){13===(e.which||e.keyCode)&&i(e,this)},!1);var a=function(){for(var t=0;t<e.length;t++)if(null===e[t].offsetParent){var o=e[t].closest("nav");if(o&&o.classList.contains("toggled")){var s=o.getElementsByTagName("ul")[0],l=s.getElementsByTagName("li"),i=s.getElementsByTagName("ul");document.activeElement.blur(),o.classList.remove("toggled"),r.classList.remove("mobile-menu-open"),e[t].setAttribute("aria-expanded","false");for(var a=0;a<l.length;a++)l[a].classList.remove("sfHover");for(var d=0;d<i.length;d++)i[d].classList.remove("toggled-on");if(s&&s.removeAttribute("aria-hidden"),n.classList.contains("dropdown-hover"))for(var c=o.querySelectorAll("li.menu-item-has-children"),u=0;u<c.length;u++)c[u].querySelector(".dropdown-menu-toggle").removeAttribute("tabindex"),c[u].querySelector(".dropdown-menu-toggle").setAttribute("role","presentation"),c[u].querySelector(".dropdown-menu-toggle").removeAttribute("aria-expanded")}}};if(window.addEventListener("resize",a,!1),window.addEventListener("orientationchange",a,!1),n.classList.contains("dropdown-hover"))for(l=0;l<o.length;l++)o[l].addEventListener("click",function(e){this.hostname!==window.location.hostname&&document.activeElement.blur();var t=this.closest("nav");if(t.classList.contains("toggled")||r.classList.contains("slide-opened")){var o=this.getAttribute("href");if("#"==o||""==o){e.preventDefault();var n=this.closest("li");n.classList.toggle("sfHover");var s=n.querySelector(".sub-menu");s&&s.classList.toggle("toggled-on")}"#"===o||""===o||navigator.userAgent.match(/iemobile/i)||setTimeout(function(){t.classList.remove("toggled"),r.classList.remove("mobile-menu-open")},200)}},!1)}}();
|