assets/js/dist/commons.min.js in jekyll-theme-chirpy-5.5.2 vs assets/js/dist/commons.min.js in jekyll-theme-chirpy-5.6.0
- old
+ new
@@ -1,6 +1,6 @@
/*!
- * Chirpy v5.5.2 (https://github.com/cotes2020/jekyll-theme-chirpy/)
+ * Chirpy v5.6.0 (https://github.com/cotes2020/jekyll-theme-chirpy/)
* © 2019 Cotes Chung
* MIT Licensed
*/
-$(function(){$(window).scroll(()=>{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))}),$(function(){$(".mode-toggle").click(o=>{o=$(o.target);(o.prop("tagName")==="button".toUpperCase()?o:o.parent()).blur(),flipMode()})});const ScrollHelper=function(){const o=$("body"),e="data-topbar-visible",t=$("#topbar-wrapper").outerHeight();let l=0,r=!1,a=!1;return{hideTopbar:()=>o.attr(e,!1),showTopbar:()=>o.attr(e,!0),addScrollUpTask:()=>{l+=1,r=r||!0},popScrollUpTask:()=>--l,hasScrollUpTask:()=>0<l,topbarLocked:()=>!0===r,unlockTopbar:()=>r=!1,getTopbarHeight:()=>t,orientationLocked:()=>!0===a,lockOrientation:()=>a=!0,unLockOrientation:()=>a=!1}}();$(function(){const o=$("#sidebar-trigger"),e=$("#search-trigger"),t=$("#search-cancel"),l=$("#main"),r=$("#topbar-title"),a=$("#search-wrapper"),n=$("#search-result-wrapper"),s=$("#search-results"),i=$("#search-input"),c=$("#search-hints"),d=function(){let o=0;return{block(){o=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(o)},getOffset(){return o}}}(),p={on(){o.addClass("unloaded"),r.addClass("unloaded"),e.addClass("unloaded"),a.addClass("d-flex"),t.addClass("loaded")},off(){t.removeClass("loaded"),a.removeClass("d-flex"),o.removeClass("unloaded"),r.removeClass("unloaded"),e.removeClass("unloaded")}},u=function(){let o=!1;return{on(){o||(d.block(),n.removeClass("unloaded"),l.addClass("unloaded"),o=!0)},off(){o&&(s.empty(),c.hasClass("unloaded")&&c.removeClass("unloaded"),n.addClass("unloaded"),l.removeClass("unloaded"),d.release(),i.val(""),o=!1)},isVisible(){return o}}}();function f(){return t.hasClass("loaded")}e.click(function(){p.on(),u.on(),i.focus()}),t.click(function(){p.off(),u.off()}),i.focus(function(){a.addClass("input-focus")}),i.focusout(function(){a.removeClass("input-focus")}),i.on("input",()=>{""===i.val()?f()?c.removeClass("unloaded"):u.off():(u.on(),f()&&c.addClass("unloaded"))})}),$(function(){var o=function(){const o="sidebar-display";let e=!1;const t=$("body");return{toggle(){!1===e?t.attr(o,""):t.removeAttr(o),e=!e}}}();$("#sidebar-trigger").click(o.toggle),$("#mask").click(o.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const e=$("#search-input"),t=ScrollHelper.getTopbarHeight();let o,l=0;function r(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var o=screen.orientation.type;"landscape-primary"!==o&&"landscape-secondary"!==o||r()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&r()}),$(window).scroll(()=>{o=o||!0}),setInterval(()=>{o&&(!function(){var o=$(this).scrollTop();if(!(Math.abs(l-o)<=t)){if(o>l)ScrollHelper.hideTopbar(),e.is(":focus")&&e.blur();else if(o+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}l=o}}(),o=!1)},250)}),$(function(){var o="div.post>h1:first-of-type",e=$(o);const n=$("#topbar-title");if(0!==e.length&&!e.hasClass("dynamic-title")&&!n.is(":hidden")){const s=n.text().trim();let l=e.text().trim(),r=!1,a=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(l)&&(l=l.replace(/[0-9]/g,"").trim()),e.offset().top<$(window).scrollTop()&&n.text(l);new IntersectionObserver(o=>{var e,t;r?(t=$(window).scrollTop(),e=a<t,a=t,t=o[0],e?0===t.intersectionRatio&&n.text(l):1===t.intersectionRatio&&n.text(s)):r=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]}).observe(document.querySelector(o)),n.click(function(){$("body,html").animate({scrollTop:0},800)})}});
+!function(){"use strict";var o=$(".mode-toggle");function e(o,e){if(!(o instanceof e))throw new TypeError("Cannot call a class as a function")}function t(o,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(o,i(n.key),n)}}function n(o,e,n){return e&&t(o.prototype,e),n&&t(o,n),Object.defineProperty(o,"prototype",{writable:!1}),o}function r(o,e,t){return(e=i(e))in o?Object.defineProperty(o,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):o[e]=t,o}function i(o){var e=function(o,e){if("object"!=typeof o||null===o)return o;var t=o[Symbol.toPrimitive];if(void 0!==t){var n=t.call(o,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(o)}(o,"string");return"symbol"==typeof e?e:String(e)}var a=$("body"),l="sidebar-display",s=function(){function o(){e(this,o)}return n(o,null,[{key:"toggle",value:function(){!1===o.isExpanded?a.attr(l,""):a.removeAttr(l),o.isExpanded=!o.isExpanded}}]),o}();r(s,"isExpanded",!1);var c="div.post>h1:first-of-type",u=$(c),f=$("#topbar-title"),d=f.text().trim();var p=$("#sidebar-trigger"),v=$("#search-trigger"),b=$("#search-cancel"),g=$("#main"),k=$("#topbar-title"),h=$("#search-wrapper"),y=$("#search-result-wrapper"),m=$("#search-results"),w=$("#search-input"),C=$("#search-hints"),T=$("html,body"),L="loaded",x="unloaded",I="input-focus",O="d-flex",U=function(){function o(){e(this,o)}return n(o,null,[{key:"on",value:function(){o.offset=window.scrollY,T.scrollTop(0)}},{key:"off",value:function(){T.scrollTop(o.offset)}}]),o}();r(U,"offset",0),r(U,"resultVisible",!1);var S=function(){function o(){e(this,o)}return n(o,null,[{key:"on",value:function(){p.addClass(x),k.addClass(x),v.addClass(x),h.addClass(O),b.addClass(L)}},{key:"off",value:function(){b.removeClass(L),h.removeClass(O),p.removeClass(x),k.removeClass(x),v.removeClass(x)}}]),o}(),E=function(){function o(){e(this,o)}return n(o,null,[{key:"on",value:function(){U.resultVisible||(U.on(),y.removeClass(x),g.addClass(x),U.resultVisible=!0)}},{key:"off",value:function(){U.resultVisible&&(m.empty(),C.hasClass(x)&&C.removeClass(x),y.addClass(x),g.removeClass(x),U.off(),w.val(""),U.resultVisible=!1)}}]),o}();function j(){return b.hasClass(L)}var P="data-topbar-visible",V=$("body"),H=$("#topbar-wrapper"),M=function(){function o(){e(this,o)}return n(o,null,[{key:"hideTopbar",value:function(){V.attr(P,"false")}},{key:"showTopbar",value:function(){V.attr(P,"true")}},{key:"addScrollUpTask",value:function(){o.scrollUpCount+=1,o.topbarIsLocked||(o.topbarIsLocked=!0)}},{key:"popScrollUpTask",value:function(){o.scrollUpCount-=1}},{key:"hasScrollUpTask",value:function(){return o.scrollUpCount>0}},{key:"topbarLocked",value:function(){return!0===o.topbarIsLocked}},{key:"unlockTopbar",value:function(){o.topbarIsLocked=!1}},{key:"getTopbarHeight",value:function(){return H.outerHeight()}},{key:"orientationLocked",value:function(){return!0===o.orientationIsLocked}},{key:"lockOrientation",value:function(){o.orientationIsLocked=!0}},{key:"unLockOrientation",value:function(){o.orientationIsLocked=!1}}]),o}();r(M,"scrollUpCount",0),r(M,"topbarIsLocked",!1),r(M,"orientationIsLocked",!1);var N,R=$("#search-input"),q=M.getTopbarHeight(),A=0;function Y(){0!==$(window).scrollTop()&&(M.lockOrientation(),M.hideTopbar())}function z(){var o=screen.orientation;o?o.onchange=function(){var e=o.type;"landscape-primary"!==e&&"landscape-secondary"!==e||Y()}:$(window).on("orientationchange",(function(){$(window).width()<$(window).height()&&Y()})),$(window).on("scroll",(function(){N||(N=!0)})),setInterval((function(){N&&(!function(){var o=$(window).scrollTop();if(!(Math.abs(A-o)<=q)){if(o>A)M.hideTopbar(),R.is(":focus")&&R.trigger("blur");else if(o+$(window).height()<$(document).height()){if(M.hasScrollUpTask())return;M.topbarLocked()?M.unlockTopbar():M.orientationLocked()?M.unLockOrientation():M.showTopbar()}A=o}}(),N=!1)}),250)}$(window).on("scroll",(function(){$(window).scrollTop()>50&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()})),$("#back-to-top").on("click",(function(){return $("body,html").animate({scrollTop:0},800),!1})),$('[data-toggle="tooltip"]').tooltip(),0!==o.length&&o.off().on("click",(function(o){var e=$(o.target),t=e.prop("tagName")==="button".toUpperCase()?e:e.parent();modeToggle.flipMode(),t.trigger("blur")})),$("#sidebar-trigger").on("click",s.toggle),$("#mask").on("click",s.toggle),function(){if(0!==u.length&&!u.hasClass("dynamic-title")&&!f.is(":hidden")){var o=u.text().trim(),e=!1,t=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(o)&&(o=o.replace(/[0-9]/g,"").trim()),u.offset().top<$(window).scrollTop()&&f.text(o),new IntersectionObserver((function(n){if(e){var r=$(window).scrollTop(),i=t<r;t=r;var a=n[0];i?0===a.intersectionRatio&&f.text(o):1===a.intersectionRatio&&f.text(d)}else e=!0}),{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]}).observe(document.querySelector(c)),f.on("click",(function(){$("body,html").animate({scrollTop:0},800)}))}}(),v.on("click",(function(){S.on(),E.on(),w.trigger("focus")})),b.on("click",(function(){S.off(),E.off()})),w.on("focus",(function(){h.addClass(I)})),w.on("focusout",(function(){h.removeClass(I)})),w.on("input",(function(){""===w.val()?j()?C.removeClass(x):E.off():(E.on(),j()&&C.addClass(x))})),z()}();