UNPKG

butterfly-halo-theme

Version:
1 lines 3.98 kB
(()=>{"use strict";function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function d(t){var e=document.querySelector("link[data-code-theme=light]"),a=document.querySelector("link[data-code-theme=dark]");if(a||e){if("light"===t)return a.disabled=!0,e.disabled=!1;e.disabled=!0,a.disabled=!1}}function c(t,e){var a,i,e=1<arguments.length&&void 0!==e?e:0;null!=(a=window)&&a.drawEchartsDom&&(i=window.echarts.init(window.drawEchartsDom,t),1===e&&(i.dispose(),i=window.echarts.init(window.drawEchartsDom,t)),i.setOption(window.drawEchartsOption),window.addEventListener("resize",function(){return i.resize()}))}var t=function(){function t(){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function");this.init(),this.sidebar(),this.scroll(),this.runDay()}for(var e,a=t,i=[{key:"init",value:function(){var t=this,e=$("html");$(".menu-item.toggle").on("click",function(){e.addClass("active-mask"),t.switchSidebar(1)}),window.lazyLoadInstance=new LazyLoad({elements_selector:"img",threshold:0,data_src:"lazy-src"}),$(".adsorption .switch-model").on("click",function(){"light"===(localStorage.getItem("Butterfly-data-theme")||"light")?(d("dark"),c("dark",1),$("html").attr("data-theme","dark"),localStorage.setItem("Butterfly-data-theme","dark"),window.dataTheme="dark"):(d("light"),c("light",1),$("html").attr("data-theme","light"),localStorage.setItem("Butterfly-data-theme","light"),window.dataTheme="light")}),$(".adsorption .back-top").on("click",function(){$("html").animate({scrollTop:0},300)}),$(".global-mask").on("click",function(){e.removeClass("active-mask"),t.switchSidebar(0)})}},{key:"switchSidebar",value:function(t){var e=$(".sidebar");1===t?e.css({transform:"translate3d(-100%, 0, 0)"}):e.css({transform:"translate3d(0, 0, 0)"})}},{key:"sidebar",value:function(){var t=$(".sidebar-menus .menu-item");t.length&&t.each(function(){$(this).hasClass("relative")&&$(this).on("click",function(){$(this).toggleClass("active").children(".menu-child").stop().toggle("fast")})})}},{key:"scroll",value:function(){var a=$(".header .nav"),i=$(".adsorption"),n=$(".post .aside .post-sticky"),o=0;window.addEventListener("scroll",function(a,i){function n(){s=!1===i.leading?0:(new Date).getTime(),o=null,a.apply(r,l),r=l=null}var o,r,l,s=0;i=i||{};return function(){var t=(new Date).getTime(),e=150-(t-(s=s||!1!==i.leading?s:t));r=this,l=arguments,e<=0||150<e?(o&&(clearTimeout(o),o=null),s=t,a.apply(r,l),o||(r=l=null)):o||!1===i.leading||(o=setTimeout(n,e))}}(function(t){var e=window.scrollY||document.documentElement.scrollTop;56<e?(o<=e?(a.hasClass("visible")&&a.addClass("hidden").removeClass("visible"),n&&n.css("top",""),i.hasClass("active")||i.addClass("active")):(a.hasClass("visible")||a.addClass("visible").removeClass("hidden"),n&&n.css("top","70px")),a.hasClass("style")||a.addClass("style")):0===e&&(a.removeClass("style visible hidden"),i.hasClass("active"))&&i.removeClass("active"),o=e}))}},{key:"runDay",value:function(){var t,e,a=$(".aside-web-info .run-day");a&&(e=a.attr("data-runday"))&&("Invalid Date"!==(t=new Date).toString()?(t=t.getTime()-new Date(e).getTime(),e=parseInt((t/864e5).toString()),a.html(e+" 天")):a.html('<span style="color:#fd0000">建站时间配置错误</span>'))}}],n=a.prototype,o=i,r=0;r<o.length;r++){var l=o[r];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(n,(e=function(t){if("object"!==s(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return String(t);e=e.call(t,"string");if("object"!==s(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(l.key),"symbol"===s(e)?e:String(e)),l)}return Object.defineProperty(a,"prototype",{writable:!1}),t}();document.addEventListener("DOMContentLoaded",function(){return window.GlobalClass=new t})})();