2 lines
2.5 KiB
JavaScript
2 lines
2.5 KiB
JavaScript
!function(){"use strict";if("querySelector"in document&&"addEventListener"in window){var c=document.body,t=function(e,t){if(e.preventDefault(),e.stopPropagation(),!t)t=this;var n=t.closest("li"),o=t.closest("nav").querySelectorAll("ul.toggled-on");if(o&&!t.closest("ul").classList.contains("toggled-on")&&!t.closest("li").classList.contains("sfHover"))for(var l=0;l<o.length;l++)o[l].classList.remove("toggled-on"),o[l].closest("li").classList.remove("sfHover");n.classList.toggle("sfHover");var r=n.querySelector(".dropdown-menu-toggle");if("false"!==r.getAttribute("aria-expanded")&&r.getAttribute("aria-expanded")?r.setAttribute("aria-expanded","false"):r.setAttribute("aria-expanded","true"),n.querySelector(".sub-menu"))var i=".sub-menu";else i=".children";c.classList.contains("dropdown-click-menu-item")?t.parentNode.querySelector(i).classList.toggle("toggled-on"):c.classList.contains("dropdown-click-arrow")&&n.querySelector(i).classList.toggle("toggled-on")},e=document.querySelectorAll(".main-nav .menu-item-has-children > a");if(c.classList.contains("dropdown-click-menu-item"))for(var n=0;n<e.length;n++)e[n].addEventListener("click",t,!0);if(c.classList.contains("dropdown-click-arrow")){for(n=0;n<document.querySelectorAll(".main-nav .menu-item-has-children > a").length;n++)"#"==document.querySelectorAll(".main-nav .menu-item-has-children > a")[n].getAttribute("href")&&document.querySelectorAll(".main-nav .menu-item-has-children > a")[n].classList.add("menu-item-dropdown-click");var o=document.querySelectorAll(".main-nav .menu-item-has-children > a .dropdown-menu-toggle");for(n=0;n<o.length;n++)o[n].addEventListener("click",t,!1),o[n].addEventListener("keydown",function(e){13===(e.which||e.keyCode)&&t(e,this)},!1);for(n=0;n<document.querySelectorAll(".main-nav .menu-item-has-children > a.menu-item-dropdown-click").length;n++)document.querySelectorAll(".main-nav .menu-item-has-children > a.menu-item-dropdown-click")[n].addEventListener("click",t,!1)}var l=function(){if(document.querySelector("nav ul .toggled-on")){for(var e=document.querySelectorAll("nav ul .toggled-on"),t=document.querySelectorAll("nav .dropdown-menu-toggle"),n=0;n<e.length;n++)e[n].classList.remove("toggled-on"),e[n].closest(".sfHover").classList.remove("sfHover");for(n=0;n<t.length;n++)t[n].setAttribute("aria-expanded","false")}};document.addEventListener("click",function(e){e.target.closest(".sfHover")||l()},!1),document.addEventListener("keydown",function(e){27===(e.which||e.keyCode)&&l()},!1)}}();
|