-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext-boot.js
1 lines (1 loc) · 2.19 KB
/
next-boot.js
1
NexT.boot={},NexT.boot.registerEvents=function(){NexT.utils.registerScrollPercent(),NexT.utils.registerCanIUseTag(),document.querySelector(".site-nav-toggle .toggle").addEventListener("click",()=>{event.currentTarget.classList.toggle("toggle-close");var e=document.querySelector(".site-nav"),t=e.classList.contains("site-nav-on")?"slideUp":"slideDown";"function"==typeof Velocity?Velocity(e,t,{duration:200,complete:function(){e.classList.toggle("site-nav-on")}}):e.classList.toggle("site-nav-on")});document.querySelectorAll(".sidebar-nav li").forEach((e,t)=>{e.addEventListener("click",e=>{var i=e.currentTarget;if(!i.classList.contains("sidebar-nav-active")){var o=document.querySelectorAll(".sidebar-panel"),a=o[t],s=o[1-t];window.anime({targets:s,duration:200,easing:"linear",opacity:0,complete:()=>{s.classList.remove("sidebar-panel-active"),a.style.opacity=0,a.classList.add("sidebar-panel-active"),window.anime({targets:a,duration:200,easing:"linear",opacity:1})}}),[...i.parentNode.children].forEach(e=>{e.classList.remove("sidebar-nav-active")}),i.classList.add("sidebar-nav-active")}})}),window.addEventListener("resize",NexT.utils.initSidebarDimension),window.addEventListener("hashchange",()=>{var e=location.hash;if(""!==e&&!e.match(/%\S{2}/)){var t=document.querySelector(`.tabs ul.nav-tabs li a[href="${e}"]`);t&&t.click()}})},NexT.boot.refresh=function(){CONFIG.fancybox&&NexT.utils.wrapImageWithFancyBox(),CONFIG.mediumzoom&&window.mediumZoom(".post-body :not(a) > img, .post-body > img"),CONFIG.lazyload&&window.lozad(".post-body img").observe(),CONFIG.pangu&&window.pangu.spacingPage(),CONFIG.exturl&&NexT.utils.registerExtURL(),CONFIG.copycode.enable&&NexT.utils.registerCopyCode(),NexT.utils.registerTabsTag(),NexT.utils.registerActiveMenuItem(),NexT.utils.registerSidebarTOC(),NexT.utils.wrapTableWithBox(),NexT.utils.registerVideoIframe()},NexT.boot.motion=function(){CONFIG.motion.enable?NexT.motion.integrator.add(NexT.motion.middleWares.logo).add(NexT.motion.middleWares.menu).add(NexT.motion.middleWares.postList).add(NexT.motion.middleWares.sidebar).bootstrap():NexT.utils.updateSidebarPosition()},window.addEventListener("DOMContentLoaded",()=>{NexT.boot.registerEvents(),NexT.boot.refresh(),NexT.boot.motion()});