1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
|
var new_scroll_position=0;var last_scroll_position;var header=document.getElementById("js-header");var stickyMenu=document.getElementById("js-navbar-menu");window.addEventListener("scroll",function(a){last_scroll_position=window.scrollY;if(new_scroll_position<last_scroll_position&&last_scroll_position>40){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(stickyMenu){stickyMenu.classList.add("is-sticky")}}}if(last_scroll_position<1){header.classList.remove("is-visible");if(stickyMenu){stickyMenu.classList.remove("is-sticky")}}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(m){b[m]=d[m]});if(typeof e==="object"){Object.keys(e).forEach(function(m){b[m]=e[m]})}function l(){if(!document.querySelectorAll(b.wrapperSelector).length){return}c();if(b.mobileMenuMode==="overlay"){j()}else{if(b.mobileMenuMode==="sidebar"){i()}}k();if(!b.isHoverMenu){f()}}function c(){var m=document.querySelectorAll(b.wrapperSelector+" ."+b.parentItemClass);for(var o=0;o<m.length;o++){var n=b.isHoverMenu?"mouseenter":"click";m[o].addEventListener(n,function(){var r=this.querySelector(b.submenuSelector);var q=this.getBoundingClientRect().left;var p=2;if(this.parentNode===document.querySelector(b.menuSelector)){p=1}if(b.submenuWidth!=="auto"){var t=q+(b.submenuWidth*p);if(window.innerWidth<t){r.classList.add(b.submenuRightPositionClass)}else{r.classList.add(b.submenuLeftPositionClass)}}else{var t=0;var s=0;if(p===1){t=q+r.clientWidth}else{t=q+this.clientWidth+r.clientWidth}if(window.innerWidth<t){r.classList.add(b.submenuRightPositionClass);s=-1*r.clientWidth;if(p===1){s=0}r.style.left=s+"px";r.style.right=this.clientWidth+"px"}else{r.classList.add(b.submenuLeftPositionClass);s=this.clientWidth;if(p===1){s=0}r.style.left=s+"px"}}r.setAttribute("aria-hidden",false)});if(b.isHoverMenu){m[o].addEventListener("mouseleave",function(){var p=this.querySelector(b.submenuSelector);p.removeAttribute("style");p.setAttribute("aria-hidden",true)})}}}function j(){var o=document.createElement("div");o.classList.add(b.mobileMenuOverlayClass);o.classList.add(b.hiddenElementClass);var m=document.querySelector(b.menuSelector).outerHTML;o.innerHTML=m;document.body.appendChild(o);if(b.mobileMenuExpandableSubmenus){h(o);a(o)}var n=document.querySelector(b.buttonSelector);n.addEventListener("click",function(){var p=document.querySelector(b.relatedContainerForOverlayMenuSelector);o.classList.toggle(b.hiddenElementClass);n.classList.toggle(b.openedMenuClass);n.setAttribute(b.ariaButtonAttribute,n.classList.contains(b.openedMenuClass));if(n.classList.contains(b.openedMenuClass)){document.documentElement.classList.add(b.noScrollClass);if(p){p.classList.add(b.relatedContainerForOverlayMenuClass)}}else{document.documentElement.classList.remove(b.noScrollClass);if(p){p.classList.remove(b.relatedContainerForOverlayMenuClass)}}})}function i(){var o=document.createElement("div");o.classList.add(b.mobileMenuSidebarClass);o.classList.add(b.hiddenElementClass);var m="";if(b.mobileMenuSidebarLogoSelector!=
|