2 lines
2.0 KiB
JavaScript
2 lines
2.0 KiB
JavaScript
|
!function(){"use strict";if("querySelector"in document&&"addEventListener"in window){var e=function(e,t){if(e.preventDefault(),!t)t=this;var a=t.closest("nav");t.getAttribute("data-nav")&&(a=document.querySelector(this.getAttribute("data-nav")));var s=a.querySelector(".navigation-search"),c=document.querySelectorAll('a[href], area[href], input:not([disabled]):not(.navigation-search), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]');if(s.classList.contains("nav-search-active")){t.classList.remove("close-search"),t.classList.remove("active"),document.activeElement.blur(),t.classList.remove("sfHover"),s.classList.remove("nav-search-active"),t.style.float="";for(var i=0;i<c.length;i++)c[i].closest(".navigation-search")||c[i].closest(".search-item")||c[i].removeAttribute("tabindex")}else{t.classList.add("active"),s.classList.add("nav-search-active"),s.querySelector(".search-field").focus();for(i=0;i<c.length;i++)c[i].closest(".navigation-search")||c[i].closest(".search-item")||c[i].setAttribute("tabindex","-1");setTimeout(function(){t.classList.add("sfHover")},50),document.body.classList.contains("nav-aligned-center")?(t.style.opacity=0,setTimeout(function(){t.classList.add("close-search"),t.style.opacity=1,document.body.classList.contains("rtl")?t.style.float="left":t.style.float="right"},250)):t.classList.add("close-search")}};if(document.body.classList.contains("nav-search-enabled")){for(var t=document.querySelectorAll(".search-item"),a=0;a<t.length;a++)t[a].addEventListener("click",e,!1);document.addEventListener("click",function(t){if(document.querySelector(".navigation-search.nav-search-active")&&!t.target.closest(".navigation-search")&&!t.target.closest(".search-item"))for(var a=document.querySelectorAll(".search-item.active"),s=0;s<a.length;s++)e(t,a[s])},!1),document.addEventListener("keydown",function(t){if(document.querySelector(".navigation-search.nav-search-active")&&27===(t.which||t.keyCode))for(var a=document.querySelectorAll(".search-item.active"),s=0;s<a.length;s++)e(t,a[s])},!1)}}}();
|