1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
|
var new_scroll_position=0;var last_scroll_position;var header=document.getElementById("js-top");window.addEventListener("scroll",function(a){last_scroll_position=window.scrollY;if(new_scroll_position<last_scroll_position&&last_scroll_position>184){header.classList.remove("is-visible");header.classList.add("is-hidden")}else{if(new_scroll_position>last_scroll_position){header.classList.remove("is-hidden");header.classList.add("is-visible")}}if(last_scroll_position<184){header.classList.remove("is-visible")}new_scroll_position=last_scroll_position});(function(e){var d={mobileMenuMode:"overlay",animationSpeed:300,submenuWidth:300,doubleClickTime:500,mobileMenuExpandableSubmenus:false,isHoverMenu:true,wrapperSelector:".navbar",buttonSelector:".navbar__toggle",menuSelector:".navbar__menu",submenuSelector:".navbar__submenu",mobileMenuSidebarLogoSelector:null,mobileMenuSidebarLogoUrl:null,relatedContainerForOverlayMenuSelector:null,ariaButtonAttribute:"aria-haspopup",separatorItemClass:"is-separator",parentItemClass:"has-submenu",submenuLeftPositionClass:"is-left-submenu",submenuRightPositionClass:"is-right-submenu",mobileMenuOverlayClass:"navbar_mobile_overlay",mobileMenuSubmenuWrapperClass:"navbar__submenu_wrapper",mobileMenuSidebarClass:"navbar_mobile_sidebar",mobileMenuSidebarOverlayClass:"navbar_mobile_sidebar__overlay",hiddenElementClass:"is-hidden",openedMenuClass:"is-active",noScrollClass:"no-scroll",relatedContainerForOverlayMenuClass:"is-visible"};var b={};Object.keys(d).forEach(function(p){b[p]=d[p]});if(typeof e==="object"){Object.keys(e).forEach(function(p){b[p]=e[p]})}function o(){if(!document.querySelectorAll(b.wrapperSelector).length){return}c();if(b.mobileMenuMode==="overlay"){m()}else{if(b.mobileMenuMode==="sidebar"){l()}}n();if(!b.isHoverMenu){f()}}function c(){var p=document.querySelectorAll(b.wrapperSelector+" ."+b.parentItemClass);for(var r=0;r<p.length;r++){var q=b.isHoverMenu?"mouseenter":"click";p[r].addEventListener(q,function(){var u=this.querySelector(b.submenuSelector);var t=this.getBoundingClientRect().left;var s=2;if(this.parentNode===document.querySelector(b.menuSelector)){s=1}if(b.submenuWidth!=="auto"){var x=t+(b.submenuWidth*s);if(window.innerWidth<x){u.classList.remove(b.submenuLeftPositionClass);u.classList.add(b.submenuRightPositionClass)}else{u.classList.remove(b.submenuRightPositionClass);u.classList.add(b.submenuLeftPositionClass)}}else{var x=0;var v=0;if(s===1){x=t+u.clientWidth}else{x=t+this.clientWidth+u.clientWidth}if(window.innerWidth<x){u.classList.remove(b.submenuLeftPositionClass);u.classList.add(b.submenuRightPositionClass);v=-1*u.clientWidth;u.removeAttribute("style");if(s===1){v=0;u.style.right=v+"px"}else{u.style.right=this.clientWidth+"px"}}else{u.classList.remove(b.submenuRightPositionClass);u.classList.add(b.submenuLeftPositionClass);v=this.clientWidth;if(s===1){v=0}u.removeAttribute("style");u.style.left=v+"px"}}u.setAttribute("aria-hidden",false)});if(b.isHoverMenu){p[r].addEventListener("mouseleave",function(){var s=this.querySelector(b.submenuSelector);s.removeAttribute("style");s.setAttribute("aria-hidden",true)})}}}function m(){var r=document.createElement("div");r.classList.add(b.mobileMenuOverlayClass);r.classList.add(b.hiddenElementClass);var p=document.querySelector(b.menuSelector).outerHTML;r.innerHTML=p;document.body.appendChild(r);if(b.mobileMenuExpandableSubmenus){j(r);a(r)}else{k(r)}var q=document.querySelector(b.buttonSelector);q.addEventListener("click",function(){var s=document.querySelector(b.relatedContainerForOverlayMenuSelector);r.classList.toggle(b.hiddenElementClass);q.classList.toggle(b.openedMenuClass);q.setAttribute(b.ariaButtonAttribute,q.classList.contains(b.openedMenuClass));if(q.classList.contains(b.openedMenuClass)){document.documentElement.classList.add(b.noScrollClass);if(s){s.classList.add(b.relatedContainerForOverlayMenuClass)}}else{document.documentElement.classList.remove(b.noScrollClass);if(s){s.classList.remove(b.relatedContainerForOverlayMenuClass)}}})}function l(){var r=document.createElement("div");r.classList.add(b.mobileMenuSide
|