web/assets/js/dist/page.min.js

4 lines
4.2 KiB
JavaScript

/*!
* Chirpy v6.5.5 | © 2019 Cotes Chung | MIT Licensed | https://github.com/cotes2020/jekyll-theme-chirpy/
*/
!function(){"use strict";const t=$(".mode-toggle");function e(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var s=o.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function o(t,o,s){return(o=e(o))in t?Object.defineProperty(t,o,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[o]=s,t}const s=$("body"),a="sidebar-display";class n{static toggle(){!1===n.isExpanded?s.attr(a,""):s.removeAttr(a),n.isExpanded=!n.isExpanded}}o(n,"isExpanded",!1);const r=$("#sidebar-trigger"),i=$("#search-trigger"),l=$("#search-cancel"),c=$("#main-wrapper>.container>.row"),u=$("#topbar-title"),d=$("search"),f=$("#search-result-wrapper"),p=$("#search-results"),m=$("#search-input"),g=$("#search-hints"),h=$("html,body"),b="loaded",v="unloaded",C="input-focus",w="d-flex";class y{static on(){y.offset=window.scrollY,h.scrollTop(0)}static off(){h.scrollTop(y.offset)}}o(y,"offset",0),o(y,"resultVisible",!1);class k{static on(){r.addClass(v),u.addClass(v),i.addClass(v),d.addClass(w),l.addClass(b)}static off(){l.removeClass(b),d.removeClass(w),r.removeClass(v),u.removeClass(v),i.removeClass(v)}}class S{static on(){y.resultVisible||(y.on(),f.removeClass(v),c.addClass(v),y.resultVisible=!0)}static off(){y.resultVisible&&(p.empty(),g.hasClass(v)&&g.removeClass(v),f.addClass(v),c.removeClass(v),y.off(),m.val(""),y.resultVisible=!1)}}function T(){return l.hasClass(b)}$(".collapse");const E=".code-header>button",A="fas fa-check",x="timeout",M="data-title-succeed",R="data-bs-original-title",I=2e3;function V(t){if($(t)[0].hasAttribute(x)){let e=$(t).attr(x);if(Number(e)>Date.now())return!0}return!1}function q(t){$(t).attr(x,Date.now()+I)}function N(t){$(t).removeAttr(x)}const P=$(E).children().attr("class");const U="data-src",j="data-lqip",B={SHIMMER:"shimmer",BLUR:"blur"};function H(t){$(this).parent().removeClass(t)}function O(){this.complete&&(this.hasAttribute(j)?H.call(this,B.BLUR):H.call(this,B.SHIMMER))}function z(){const t=$(this),e=t.attr(U);t.attr("src",encodeURI(e)),t.removeAttr(U)}!function(){const t=$(window),e=$("#back-to-top");t.on("scroll",(()=>{t.scrollTop()>50?e.fadeIn():e.fadeOut()})),e.on("click",(()=>{t.scrollTop(0)}))}(),[...document.querySelectorAll('[data-bs-toggle="tooltip"]')].map((t=>new bootstrap.Tooltip(t))),0!==t.length&&t.off().on("click",(t=>{const e=$(t.target);let o=e.prop("tagName")==="button".toUpperCase()?e:e.parent();modeToggle.flipMode(),o.trigger("blur")})),$("#sidebar-trigger").on("click",n.toggle),$("#mask").on("click",n.toggle),i.on("click",(function(){k.on(),S.on(),m.trigger("focus")})),l.on("click",(function(){k.off(),S.off()})),m.on("focus",(function(){d.addClass(C)})),m.on("focusout",(function(){d.removeClass(C)})),m.on("input",(()=>{""===m.val()?T()?g.removeClass(v):S.off():(S.on(),T()&&g.addClass(v))})),function(){const t=$("article img");t.length&&t.on("load",O),$('article img[loading="lazy"]').each((function(){this.complete&&H.call(this,B.SHIMMER)}));const e=$("article img[".concat(j,'="true"]'));e.length&&e.each(z)}(),$(".popup")<=0||$(".popup").magnificPopup({type:"image",closeOnContentClick:!0,showCloseBtn:!1,zoom:{enabled:!0,duration:300,easing:"ease-in-out"}}),function(){if($(E).length){const t=new ClipboardJS(E,{target:t=>t.parentNode.nextElementSibling.querySelector("code .rouge-code")});[...document.querySelectorAll(E)].map((t=>new bootstrap.Tooltip(t,{placement:"left"}))),t.on("success",(t=>{t.clearSelection();const e=t.trigger;V(e)||(!function(t){$(t).children().attr("class",A)}(e),function(t){const e=$(t).attr(M);$(t).attr(R,e).tooltip("show")}(e),q(e),setTimeout((()=>{!function(t){$(t).tooltip("hide").removeAttr(R)}(e),function(t){$(t).children().attr("class",P)}(e),N(e)}),I))}))}const t=$("#copy-link");t.on("click",(t=>{let e=$(t.target);V(e)||navigator.clipboard.writeText(window.location.href).then((()=>{const t=e.attr(R),o=e.attr(M);e.attr(R,o).tooltip("show"),q(e),setTimeout((()=>{e.attr(R,t),N(e)}),I)}))})),t.on("mouseleave",(function(t){$(t.target).tooltip("hide")}))}()}();