2 lines
8.2 KiB
JavaScript
2 lines
8.2 KiB
JavaScript
function generateStickyDebounce(s,n,a){var o;return function(){var t=this,e=arguments,i=a&&!o;clearTimeout(o),o=setTimeout(function(){o=null,a||s.apply(t,e)},n),i&&s.apply(t,e)}}!function(T,M,E){var e=function(t,e){var s=0,n=0,a="",o=0,r=!1,l=!1,c=!1,p=!1,d=0,m=0,h=0,f=0,u=0,g=T(),i=T("body"),b=0,v=0,k=0,y=T(t).clone().css({visibility:"hidden",display:"none"}).attr({id:"sticky-placeholder",itemtype:null,itemscope:null}),w=T(),C={top:0,bottom:0,custom:[]},I={scrollHide:!1,lazyHeight:0,topMargin:"auto",keepInWrapper:!1,wrapperSelector:"",zIndex:100,namespaceClass:"stuckElement",fixedClass:"isStuck",disableOn:function(){return!0},transition:"none"},H=function(){var t=0<jQuery("#wpadminbar").length&&"fixed"==jQuery("#wpadminbar").css("position")?jQuery("#wpadminbar").outerHeight():0;return"auto"===I.topMargin?parseInt(t+g.css("marginTop")):isNaN(I.topMargin)&&0<I.topMargin.search("px")?parseInt(t+I.topMargin.replace("px","")):isNaN(parseInt(I.topMargin))?0:parseInt(t+I.topMargin)},x=function(){y.hide().removeClass(I.fixedClass).removeClass("sticky-navigation-transition"),g.removeClass(I.fixedClass).css({"max-width":"","margin-top":"","margin-left":"","margin-right":"",position:"",top:"",left:"",right:"",bottom:"",width:"",opacity:"",height:"",overflow:"","-webkit-transform":"","-ms-transform":"",transform:"","-webkit-transition":"","-ms-transition":"",transition:"",visibility:""}).removeClass("sticky-navigation-transition").removeClass("navigation-transition"),"sticky-navigation"===g.attr("id")&&g.attr("id","site-navigation"),c=l=r=!1,g.trigger("stickUp:unStick")},S=function(t){y.show().addClass(I.fixedClass);var e=y.offsetParent();if(t){g.css({position:"absolute"});var i=w.offset().top+w.outerHeight()-e.offset().top-m-parseInt(w.css("paddingBottom"))}g.css({position:"absolute",marginTop:v,bottom:"",left:y.position().left,top:t?i:g.offset().top-e.offset().top-v}),g.trigger("stickUp:holdIt")},U=function(t){if(I.disableOn()){if(p&&(p=!1),!I.keepInWrapper||w.is(":visible")){if(n=T(t.target).scrollTop(),a=s<=n?"down":"up",o=Math.abs(s-n),h=T(M).outerHeight(),n+h,s=n,f=g.offset().top,d=parseInt(g.outerHeight()+v)+parseInt(g.css("marginBottom")),r||c||l||(parseInt(g.outerHeight(!0)),l||c?(C.top=parseInt(y.offset().top),parseInt(g.offset().left)+5):C.top=parseInt(g.offset().top)),m=parseInt(g.outerHeight())+parseInt(g.css("margin-bottom"))+v,I.keepInWrapper?C.bottom=w.offset().top+w.outerHeight()-parseInt(w.css("paddingBottom")):C.bottom=T(E).outerHeight(),u=g.offset().top+m,k=I.scrollHide?d+I.lazyHeight:I.lazyHeight,"none"!==I.transition&&(b=2*g.outerHeight()),v=null!==I.topMargin?H():0,r&&v!==g.css("margin-top")&&g.css("margin-top",v),(!r&&!l&&n>=C.top-v+k+b||l&&c&&n<=f-v+k)&&(!function(){r=!0,"fade"==I.transition&&g.hide(),("slide"==I.transition||I.scrollHide)&&g.css({height:"0",overflow:"hidden",visibility:"hidden"}),y.show().addClass(I.fixedClass),"left"!=g.css("float")&&"right"!=g.css("float")||(y.css("float",g.css("float")),y.attr("style",y.attr("style")+"width:auto !important")),"slide"==I.transition&&"block"==y.css("display")&&g.css({"-webkit-transform":"translateY(-100%)","-ms-transform":"translateY(-100%)",transform:"translateY(-100%)","-webkit-transition":"transform 300ms ease-in-out","-ms-transition":"transform 300ms ease-in-out",transition:"transform 300ms ease-in-out"}),g.addClass(I.fixedClass),"site-navigation"===g.attr("id")&&g.attr("id","sticky-navigation");var t=-k;g.css({"margin-top":v,position:"fixed",top:t+"px",left:"",right:"",bottom:""}),g.trigger("stickUp:stickIt"),"fade"==I.transition&&g.fadeIn(300),"slide"==I.transition&&g.one("webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend",function(t){g.css({visibility:"",height:"",overflow:""}),setTimeout(function(){g.css({"-webkit-transform":"translateY(0)","-ms-transform":"translateY(0)",transform:"translateY(0)"})},10)}),I.scrollHide&&g.css({height:"",overflow:"",visibility:""})}(),c=l=!(r=!0)),r&&!l&&n>=C.top-v+k+g.outerHeight()/2&&(y.addClass("sticky-navigation-transition"),g.addClass("sticky-navigation-transition")),I.keepInWrapper&&parseInt(u-v)!==parseInt(C.bottom)&&n>=C.bottom-m+k&&(S(!0),c=l=!(r=!1)),r){var e=parseInt(g.css("top"));if("up"===a&&0!==e){var i=-e<o?0:e+o;g.css("top",i+"px")}else if("down"===a&&-k<e){i=k+e<o?-k:e-o;g.css("top",i+"px")}}(r||c||l)&&n<=C.top-v&&x(),(r||c||l)&&y.width()!==g.outerWidth()&&g.outerWidth(y.outerWidth())}}else p||(x(),p=!0)},z=function(t){c&&(S(),l=!1),U(t)};(function(t,e){g=T(t),y.remove(),g.after(y),T(".gen-sidebar-nav").length&&y.css("height",g.outerHeight()),g.addClass(I.namespaceClass),e&&T.extend(!0,I,e),v=null!==I.topMargin?H():0,I.lazyHeight&&(v+=I.lazyHeight),I.keepInWrapper?(""!==I.wrapperSelector&&(w=g.closest(I.wrapperSelector)),w.length||(w=g.parent())):w=i,I.zIndex&&g.css("z-index",I.zIndex),T(M).on("scroll.stickUp",U),T(M).on("resize.stickUp",z),U({target:E})}).call(this,t,e),T(t).on("stickUp:detach",function(t){(g=T(this)).removeClass(I.namespaceClass),y.remove(),g.removeClass(I.fixedClass).css({maxWidth:"",marginTop:"",marginLeft:"",marginRight:"",position:"",top:"",left:"",right:"",bottom:"",width:""}),p=!(c=l=r=!1),T(M).off("scroll.stickUp",U),T(M).off("resize.stickUp",z)})};T.fn.stickUp=function(t){return this.each(function(){new e(this,t)})}}(jQuery,window,document),function(a){a.fn.GenerateSimpleSticky=function(t){var e=a.extend({menu:a(this),parent:!1,scrollHide:!1,offsetElement:"#wpadminbar",disableOn:function(){return!0},transition:"none"},t),i=a("body"),s=null;s=e.parent?e.parent:e.menu.parent(),(0<e.menu.parents(".site-header").length||0<e.menu.parents(".generate-page-header").length||0<e.menu.parents(".header-wrap").length||0<e.menu.parents(".site-wrapper").length)&&(s=i),!i.hasClass("nav-right-sidebar")&&!i.hasClass("nav-left-sidebar")||a(".menu-toggle").is(":visible")||(e.menu=a(".gen-sidebar-nav"),s=a(".site-content"),e.menu.children().hasClass("auto-hide-sticky")),0<jQuery(e.offsetElement).length&&"fixed"==jQuery(e.offsetElement).css("position")&&jQuery(e.offsetElement).outerHeight();var n={scrollHide:e.scrollHide,keepInWrapper:!0,wrapperSelector:s,fixedClass:"is_stuck navigation-stick navigation-clone",topMargin:0,disableOn:e.disableOn,transition:e.transition};e.menu.stickUp(n)}}(jQuery),jQuery(document).ready(function(s){window;var t=s("body"),e="none";if(t.hasClass("sticky-enabled")){var i=s("#site-navigation");t.hasClass("sticky-menu-fade")&&(e="fade"),t.hasClass("sticky-menu-slide")&&(e="slide");var n={transition:e,scrollHide:!!i.hasClass("auto-hide-sticky"),disableOn:function(){var t=s("body"),e=s("#mobile-header"),i=s(".menu-toggle");return!(t.hasClass("desktop-sticky-menu")&&i.is(":visible")||t.hasClass("mobile-sticky-menu")&&!i.is(":visible")||t.hasClass("mobile-header")&&e.is(":visible"))}};s(i).GenerateSimpleSticky(n),t.on("generate_navigation_location_updated",function(){i.trigger("stickUp:detach"),setTimeout(function(){s(i).GenerateSimpleSticky(n)},250)})}if(t.hasClass("mobile-header")&&t.hasClass("mobile-header-sticky")){var a=s("#mobile-header");a.GenerateSimpleSticky({scrollHide:!!a.data("auto-hide-sticky"),disableOn:function(){return!!a.is(":visible")}})}var o=s(".sidebar-nav-mobile"),r=s(".gen-sidebar-nav"),l=s(window).width(),c=generateStickyDebounce(function(){l!==s(window).width()&&(o.is(":visible")&&(r.trigger("stickUp:detach"),o.trigger("stickUp:detach"),o.GenerateSimpleSticky(n)),r.is(":visible")&&(o.trigger("stickUp:detach"),r.trigger("stickUp:detach"),r.GenerateSimpleSticky(n)))},250);o.length&&(window.addEventListener("resize",c),window.addEventListener("orientationchange",c)),navigator.userAgent.match(/(iPod|iPhone|iPad)/)&&(t.hasClass("sticky-enabled")||t.hasClass("mobile-header")&&t.hasClass("mobile-header-sticky"))&&s(document).on("focus",".navigation-stick .search-field",function(){s("html, body").animate({scrollTop:0},"fast")});var p=function(t){var e=t,i=e.getAttribute("href");e.pathname===window.location.pathname&&"#"!==i&&e.closest("nav").classList.contains("toggled")&&(e.closest("nav").classList.remove("toggled"),s("html").hasClass("mobile-menu-open")&&s("html").removeClass("mobile-menu-open"))};(t.hasClass("both-sticky-menu")||t.hasClass("mobile-sticky-menu"))&&s(".main-navigation:not(#mobile-header) ul a[href*=\\#]").on("click",function(t){p(this)}),t.hasClass("mobile-header-sticky")&&s("#mobile-header ul a[href*=\\#]").on("click",function(t){p(this)})});
|