UNPKG

butterfly-halo-theme

Version:
1 lines 4.05 kB
(()=>{"use strict";function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var e=function(){function o(){var e;if(!(this instanceof o))throw new TypeError("Cannot call a class as a function");$(".render-html").css({visibility:"visible"}),function(e){var t=document.querySelector("link[data-code-theme=light]"),o=document.querySelector("link[data-code-theme=dark]");if(o||t){if("light"===e)return o.disabled=!0,t.disabled=!1;t.disabled=!0,o.disabled=!1}}(dataTheme),ThemeConfig.code.enable&&(t=$(".render-html pre")).length&&t.each(function(){var e,n=$(this),t=n.next(".toolbar");t&&(t.append('<div class="custom-item absolute top-0"></div>'),e=t.find(".custom-item"),ThemeConfig.code.enable_title&&t.addClass("c-title"),ThemeConfig.code.enable_hr&&t.addClass("c-hr"),ThemeConfig.code.enable_copy&&(e.append('<i class="fas fa-paste copy-button code-copy cursor-pointer"></i>'),e.find(".code-copy").on("click",function(e){var t=n.children("code[class*='language-']").text(),o=new ClipboardJS(this,{text:function(){return t}});o.on("success",function(){Qmsg.success("已复制"),o.destroy()}),o.on("error",function(){o.destroy()}),o.onClick(e)})),ThemeConfig.code.enable_expander)&&(e.append('<i class="fa-sharp fa-solid fa-caret-down code-expander cursor-pointer"></i>'),e.find(".code-expander").on("click",function(){n.children("code").toggle(),t.toggleClass("c-expander")}))});var t=".post-tocbot > .toc";window.tocbot.init({tocSelector:t,contentSelector:".render-html",headingSelector:"h1, h2, h3, h4, h5, h6",hasInnerContainers:!0,scrollSmooth:!0,includeTitleTags:!0,scrollSmoothDuration:280,throttleTimeout:30,headingsOffset:80,scrollSmoothOffset:-80,fixedSidebarOffset:"auto",disableTocScrollSync:!1,onClick:function(e){e.preventDefault()},scrollEndCallback:function(e){}}),(t=$(t)).html()||t.html("暂无目录~"),0<ThemeConfig.post.out_date&&this.outDate(),(e=$(".render-html img")).length&&e.each(function(){var e=$(this);e.attr("width",""),e.attr("height",""),e.wrap($('<span class="block text-center w-100" data-fancybox="post" href="'.concat(e.attr("src"),'" ></span>')))}),this.copyPermalink(),this.copyRightPermalinkDecode(),this.showTocbot()}for(var e,t=o,n=t.prototype,i=[{key:"outDate",value:function(){var e,t,o,n=$(".post-outDate");n.length&&(o=Number(n.attr("data-outDate")),e=n.attr("data-publishTime"),e=new Date(e),t=new Date,o<(o=Math.floor((t-e)/864e5)))&&(n.html("距离上次更新已经过了 ".concat(o," 天,文中部分内容可能已经过时,如有疑问,请在下方留言。")),n.removeClass("none"))}},{key:"copyRightPermalinkDecode",value:function(){var e=$(".post-copyRight .permalink");e.length&&e.html(decodeURIComponent(e.html()))}},{key:"copyPermalink",value:function(){var e=$(".post-support .share .copy-permalink");e.length&&e.on("click",function(e){var t=new ClipboardJS(this,{text:function(){return location.href}});t.on("success",function(){Qmsg.success("已复制"),t.destroy()}),t.on("error",function(){t.destroy()}),t.onClick(e)})}},{key:"showTocbot",value:function(){var e=$(".adsorption .show-tocbot");e.length&&e.on("click",function(){var e=$(".aside .post-tocbot");e.attr("style")?(e.css({animation:"toc-close .2s"}),setTimeout(function(){e.attr("style","")},100)):($(".main").css({animation:"none"}),e.css({display:"block",animation:"toc-open .3s"}))})}}],r=0;r<i.length;r++){var a=i[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(n,(e=function(e){if("object"!==c(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!==c(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(a.key),"symbol"===c(e)?e:String(e)),a)}return Object.defineProperty(t,"prototype",{writable:!1}),o}();document.addEventListener("DOMContentLoaded",function(){return window.PostClass=new e})})();