1 line
2.0 KiB
JavaScript
1 line
2.0 KiB
JavaScript
!function(){"use strict";if("querySelector"in document&&"addEventListener"in window){var e=document.body;if(e.addEventListener("mousedown",function(){e.classList.add("using-mouse")}),e.addEventListener("keydown",function(){e.classList.remove("using-mouse")}),e.classList.contains("dropdown-hover")){for(var t=document.querySelectorAll("nav .main-nav ul a"),s=document.querySelectorAll(".menu-bar-items .menu-bar-item > a"),n=function(){if(!this.closest("nav").classList.contains("toggled")&&!this.closest("nav").classList.contains("slideout-navigation"))for(var e=this;-1===e.className.indexOf("main-nav");)"li"===e.tagName.toLowerCase()&&e.classList.toggle("sfHover"),e=e.parentElement},o=function(){if(!this.closest("nav").classList.contains("toggled")&&!this.closest("nav").classList.contains("slideout-navigation"))for(var e=this;-1===e.className.indexOf("menu-bar-items");)e.classList.contains("menu-bar-item")&&e.classList.toggle("sfHover"),e=e.parentElement},i=0;i<t.length;i++)t[i].addEventListener("focus",n),t[i].addEventListener("blur",n);for(i=0;i<s.length;i++)s[i].addEventListener("focus",o),s[i].addEventListener("blur",o)}}if("ontouchend"in document.documentElement&&document.body.classList.contains("dropdown-hover"))for(var a=document.querySelectorAll(".sf-menu .menu-item-has-children"),i=0;i<a.length;i++)a[i].addEventListener("touchend",function(e){var t;if(!this.closest("nav").classList.contains("toggled")&&((1===e.touches.length||0===e.touches.length)&&(e.stopPropagation(),!this.classList.contains("sfHover")))){e.target!==this&&e.target.parentNode!==this&&!e.target.parentNode.parentNode||e.preventDefault();for(var s=this.closest("li"),n=(t=s,Array.prototype.filter.call(t.parentNode.children,function(e){return e!==t})),o=0;o<n.length;o++)n[o].classList.contains("sfHover")&&n[o].classList.remove("sfHover");this.classList.add("sfHover");var i,a=this;document.addEventListener("touchend",i=function(e){e.stopPropagation(),a.classList.remove("sfHover"),document.removeEventListener("touchend",i)})}})}(); |