diff --git a/_javascript/utils/smooth-scroll.js b/_javascript/utils/smooth-scroll.js index 45e84b0..a8ad44c 100644 --- a/_javascript/utils/smooth-scroll.js +++ b/_javascript/utils/smooth-scroll.js @@ -21,81 +21,92 @@ $(function() { .not("[href='#']") .not("[href='#0']") .click(function(event) { - if (this.pathname.replace(/^\//, "") === location.pathname.replace(/^\//, "")) { - if (location.hostname === this.hostname) { - const hash = decodeURI(this.hash); - let toFootnoteRef = RegExp(/^#fnref:/).test(hash); - let toFootnote = toFootnoteRef? false : RegExp(/^#fn:/).test(hash); - let selector = hash.includes(":") ? hash.replace(/\:/g, "\\:") : hash; - let $target = $(selector); - let parent = $(this).parent().prop("tagName"); - let isAnchor = RegExp(/^H\d/).test(parent); - let isMobileViews = !$topbarTitle.is(":hidden"); + if (this.pathname.replace(/^\//, "") !== location.pathname.replace(/^\//, "")) { + return; + } - if (typeof $target !== "undefined") { - event.preventDefault(); + if (location.hostname !== this.hostname) { + return; + } - if (history.pushState) { /* add hash to URL */ - history.pushState(null, null, hash); - } + const hash = decodeURI(this.hash); + let toFootnoteRef = RegExp(/^#fnref:/).test(hash); + let toFootnote = toFootnoteRef ? false : RegExp(/^#fn:/).test(hash); + let selector = hash.includes(":") ? hash.replace(/\:/g, "\\:") : hash; + let $target = $(selector); - let curOffset = isAnchor? $(this).offset().top : $(window).scrollTop(); - let destOffset = $target.offset().top -= REM / 2; + let parent = $(this).parent().prop("tagName"); + let isAnchor = RegExp(/^H\d/).test(parent); + let isMobileViews = !$topbarTitle.is(":hidden"); - if (destOffset < curOffset) { // scroll up - if (!isAnchor && !toFootnote) { // trigger by ToC item - if (!isMobileViews) { // on desktop/tablet screens - $topbarWrapper.removeClass("topbar-down").addClass("topbar-up"); - // Send message to `${JS_ROOT}/commons/topbar-switch.js` - $topbarWrapper.attr(ATTR_TOC_SCROLLING, true); - tocScrollUpCount += 1; - } - } + if (typeof $target === "undefined") { + return; + } - if ((isAnchor || toFootnoteRef) && isMobileViews) { - destOffset -= topbarHeight; - } - } + event.preventDefault(); - $("html").animate({ - scrollTop: destOffset - }, 500, () => { - $target.focus(); + if (history.pushState) { /* add hash to URL */ + history.pushState(null, null, hash); + } - /* clean up old scroll mark */ - if ($(`[${SCROLL_MARK}=true]`).length) { - $(`[${SCROLL_MARK}=true]`).attr(SCROLL_MARK, false); - } + let curOffset = isAnchor ? $(this).offset().top : $(window).scrollTop(); + let destOffset = $target.offset().top -= REM / 2; - /* Clean :target links */ - if ($(":target").length) { /* element that visited by the URL with hash */ - $(":target").attr(SCROLL_MARK, false); - } - - /* set scroll mark to footnotes */ - if (toFootnote || toFootnoteRef) { - $target.attr(SCROLL_MARK, true); - } - - if ($target.is(":focus")) { /* Checking if the target was focused */ - return false; - } else { - $target.attr("tabindex", "-1"); /* Adding tabindex for elements not focusable */ - $target.focus(); /* Set focus again */ - } - - if (typeof $topbarWrapper.attr(ATTR_TOC_SCROLLING) !== "undefined") { - tocScrollUpCount -= 1; - - if (tocScrollUpCount <= 0) { - $topbarWrapper.attr(ATTR_TOC_SCROLLING, "false"); - } - } - }); + if (destOffset < curOffset) { // scroll up + if (!isAnchor && !toFootnote) { // trigger by ToC item + if (!isMobileViews) { // on desktop/tablet screens + $topbarWrapper.removeClass("topbar-down").addClass("topbar-up"); + // Send message to `${JS_ROOT}/commons/topbar-switch.js` + $topbarWrapper.attr(ATTR_TOC_SCROLLING, true); + tocScrollUpCount += 1; } } + + if ((isAnchor || toFootnoteRef) && isMobileViews) { + destOffset -= topbarHeight; + } + + } else { + if (isMobileViews) { + destOffset -= topbarHeight; + } } + $("html").animate({ + scrollTop: destOffset + }, 500, () => { + $target.focus(); + + /* clean up old scroll mark */ + if ($(`[${SCROLL_MARK}=true]`).length) { + $(`[${SCROLL_MARK}=true]`).attr(SCROLL_MARK, false); + } + + /* Clean :target links */ + if ($(":target").length) { /* element that visited by the URL with hash */ + $(":target").attr(SCROLL_MARK, false); + } + + /* set scroll mark to footnotes */ + if (toFootnote || toFootnoteRef) { + $target.attr(SCROLL_MARK, true); + } + + if ($target.is(":focus")) { /* Checking if the target was focused */ + return false; + } else { + $target.attr("tabindex", "-1"); /* Adding tabindex for elements not focusable */ + $target.focus(); /* Set focus again */ + } + + if (typeof $topbarWrapper.attr(ATTR_TOC_SCROLLING) !== "undefined") { + tocScrollUpCount -= 1; + + if (tocScrollUpCount <= 0) { + $topbarWrapper.attr(ATTR_TOC_SCROLLING, "false"); + } + } + }); }); /* click() */ }); diff --git a/assets/js/dist/page.min.js b/assets/js/dist/page.min.js index adcfe30..a97ed22 100644 --- a/assets/js/dist/page.min.js +++ b/assets/js/dist/page.min.js @@ -3,4 +3,4 @@ * © 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(t=>{const e=$(t.target);let o=e.prop("tagName")==="button".toUpperCase()?e:e.parent();o.blur(),flipMode()})}),$(function(){const t=$("#sidebar-trigger"),e=$("#search-trigger"),o=$("#search-cancel"),a=$("#search-cleaner"),l=$("#main"),s=$("#topbar-title"),n=$("#search-wrapper"),r=$("#search-result-wrapper"),i=$("#search-results"),c=$("#search-input"),d=$("#search-hints"),u=function(){let t=0;return{block(){t=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(t)},getOffset(){return t}}}(),p={on(){t.addClass("unloaded"),s.addClass("unloaded"),e.addClass("unloaded"),n.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),n.removeClass("d-flex"),t.removeClass("unloaded"),s.removeClass("unloaded"),e.removeClass("unloaded")}},f=function(){let t=!1;return{on(){t||(u.block(),r.removeClass("unloaded"),l.addClass("unloaded"),t=!0)},off(){t&&(i.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),r.addClass("unloaded"),a.removeClass("visible"),l.removeClass("unloaded"),u.release(),c.val(""),t=!1)},isVisible(){return t}}}();function h(){return o.hasClass("loaded")}e.click(function(){p.on(),f.on(),c.focus()}),o.click(function(){p.off(),f.off()}),c.focus(function(){n.addClass("input-focus")}),c.focusout(function(){n.removeClass("input-focus")}),c.on("keyup",function(t){8===t.keyCode&&""===c.val()?h()?d.removeClass("unloaded"):f.off():""!==c.val()&&(f.on(),a.hasClass("visible")||a.addClass("visible"),h()&&d.addClass("unloaded"))}),a.on("click",function(){c.val(""),h()?(d.removeClass("unloaded"),i.empty()):f.off(),c.focus(),a.removeClass("visible")})}),$(function(){var t=function(){const t="sidebar-display";let e=!1;const o=$("body");return{toggle(){!1===e?o.attr(t,""):o.removeAttr(t),e=!e}}}();$("#sidebar-trigger").click(t.toggle),$("#mask").click(t.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const o=$("#topbar-wrapper"),a=$("#panel-wrapper"),l=$("#search-input"),s="topbar-up",n="topbar-down",r="toc-scrolling-up";let e,i=0;const c=o.outerHeight(),d=o.outerHeight();$(window).scroll(function(t){$("#topbar-title").is(":hidden")&&(e=!0)}),setInterval(function(){e&&(function(){var t,e=$(this).scrollTop();Math.abs(i-e)<=c||(e>i?e>d&&(o.removeClass(n).addClass(s),a.removeClass(n),l.is(":focus")&&l.blur()):e+$(window).height()<$(document).height()&&(void 0!==(t=o.attr(r))?"false"===t&&o.removeAttr(r):(o.removeClass(s).addClass(n),a.addClass(n))),i=e)}(),e=!1)},250)}),$(function(){const t=$("#topbar-title"),e=$("div.post>h1"),o=t.text().trim();let a=(0'),$("input[type=checkbox]:not([checked])").before('')}),$(function(){var t="#main > div.row:first-child > div:first-child";if(!($(t+" img").length<=0)){var e=document.querySelectorAll(t+" img[data-src]");const o=lozad(e);o.observe(),$(t+` p > img[data-src],${t} img[data-src].preview-img`).each(function(){let t=$(this).next();var e="EM"===t.prop("tagName")?t.text():"",o=$(this).attr("data-src");$(this).wrap(``)}),$(".popup").magnificPopup({type:"image",closeOnContentClick:!0,showCloseBtn:!1,zoom:{enabled:!0,duration:300,easing:"ease-in-out"}}),$(t+" a").has("img").addClass("img-link")}}),$(function(){var t=".code-header>button";const e="timeout";function l(t){if($(t)[0].hasAttribute(e)){t=$(t).attr(e);if(Number(t)>Date.now())return 1}}function s(t){$(t).attr(e,Date.now()+2e3)}function n(t){$(t).removeAttr(e)}const o=new ClipboardJS(t,{target(t){let e=t.parentNode.nextElementSibling;return e.querySelector("code .rouge-code")}});$(t).tooltip({trigger:"hover",placement:"left"});const a=function(t){let e=$(t).children();return e.attr("class")}(t);o.on("success",t=>{t.clearSelection();const e=t.trigger;var o;l(e)||(function(t){let e=$(t),o=e.children();o.attr("class","fas fa-check")}(e),o=e,t=$(o).attr("title-succeed"),$(o).attr("data-original-title",t).tooltip("show"),s(e),setTimeout(()=>{var t;t=e,$(t).tooltip("hide").removeAttr("data-original-title"),function(t){let e=$(t),o=e.children();o.attr("class",a)}(e),n(e)},2e3))}),$("#copy-link").click(t=>{let e=$(t.target);if(!l(e)){t=window.location.href;const o=$("");$("body").append(o),o.val(t).select(),document.execCommand("copy"),o.remove();const a=e.attr("data-original-title");t=e.attr("title-succeed");e.attr("data-original-title",t).tooltip("show"),s(e),setTimeout(()=>{e.attr("data-original-title",a),n(e)},2e3)}})}),$(function(){const i=$("#topbar-wrapper"),c=i.outerHeight(),t=$("#topbar-title"),d="toc-scrolling-up",u="scroll-focus";let p=0;$("a[href*='#']").not("[href='#']").not("[href='#0']").click(function(l){if(this.pathname.replace(/^\//,"")===location.pathname.replace(/^\//,"")&&location.hostname===this.hostname){const r=decodeURI(this.hash);let e=RegExp(/^#fnref:/).test(r),o=!e&&RegExp(/^#fn:/).test(r);var s=r.includes(":")?r.replace(/\:/g,"\\:"):r;let a=$(s);var n=$(this).parent().prop("tagName"),s=RegExp(/^H\d/).test(n),n=!t.is(":hidden");if(void 0!==a){l.preventDefault(),history.pushState&&history.pushState(null,null,r);l=s?$(this).offset().top:$(window).scrollTop();let t=a.offset().top-=8;t(a.focus(),$(`[${u}=true]`).length&&$(`[${u}=true]`).attr(u,!1),$(":target").length&&$(":target").attr(u,!1),(o||e)&&a.attr(u,!0),a.is(":focus")?!1:(a.attr("tabindex","-1"),a.focus(),void(void 0!==i.attr(d)&&(--p,p<=0&&i.attr(d,"false"))))))}}})}); \ No newline at end of file +$(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(t=>{const e=$(t.target);let o=e.prop("tagName")==="button".toUpperCase()?e:e.parent();o.blur(),flipMode()})}),$(function(){const t=$("#sidebar-trigger"),e=$("#search-trigger"),o=$("#search-cancel"),a=$("#search-cleaner"),l=$("#main"),s=$("#topbar-title"),n=$("#search-wrapper"),r=$("#search-result-wrapper"),i=$("#search-results"),c=$("#search-input"),d=$("#search-hints"),u=function(){let t=0;return{block(){t=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(t)},getOffset(){return t}}}(),p={on(){t.addClass("unloaded"),s.addClass("unloaded"),e.addClass("unloaded"),n.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),n.removeClass("d-flex"),t.removeClass("unloaded"),s.removeClass("unloaded"),e.removeClass("unloaded")}},f=function(){let t=!1;return{on(){t||(u.block(),r.removeClass("unloaded"),l.addClass("unloaded"),t=!0)},off(){t&&(i.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),r.addClass("unloaded"),a.removeClass("visible"),l.removeClass("unloaded"),u.release(),c.val(""),t=!1)},isVisible(){return t}}}();function h(){return o.hasClass("loaded")}e.click(function(){p.on(),f.on(),c.focus()}),o.click(function(){p.off(),f.off()}),c.focus(function(){n.addClass("input-focus")}),c.focusout(function(){n.removeClass("input-focus")}),c.on("keyup",function(t){8===t.keyCode&&""===c.val()?h()?d.removeClass("unloaded"):f.off():""!==c.val()&&(f.on(),a.hasClass("visible")||a.addClass("visible"),h()&&d.addClass("unloaded"))}),a.on("click",function(){c.val(""),h()?(d.removeClass("unloaded"),i.empty()):f.off(),c.focus(),a.removeClass("visible")})}),$(function(){var t=function(){const t="sidebar-display";let e=!1;const o=$("body");return{toggle(){!1===e?o.attr(t,""):o.removeAttr(t),e=!e}}}();$("#sidebar-trigger").click(t.toggle),$("#mask").click(t.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const o=$("#topbar-wrapper"),a=$("#panel-wrapper"),l=$("#search-input"),s="topbar-up",n="topbar-down",r="toc-scrolling-up";let e,i=0;const c=o.outerHeight(),d=o.outerHeight();$(window).scroll(function(t){$("#topbar-title").is(":hidden")&&(e=!0)}),setInterval(function(){e&&(function(){var t,e=$(this).scrollTop();Math.abs(i-e)<=c||(e>i?e>d&&(o.removeClass(n).addClass(s),a.removeClass(n),l.is(":focus")&&l.blur()):e+$(window).height()<$(document).height()&&(void 0!==(t=o.attr(r))?"false"===t&&o.removeAttr(r):(o.removeClass(s).addClass(n),a.addClass(n))),i=e)}(),e=!1)},250)}),$(function(){const t=$("#topbar-title"),e=$("div.post>h1"),o=t.text().trim();let a=(0'),$("input[type=checkbox]:not([checked])").before('')}),$(function(){var t="#main > div.row:first-child > div:first-child";if(!($(t+" img").length<=0)){var e=document.querySelectorAll(t+" img[data-src]");const o=lozad(e);o.observe(),$(t+` p > img[data-src],${t} img[data-src].preview-img`).each(function(){let t=$(this).next();var e="EM"===t.prop("tagName")?t.text():"",o=$(this).attr("data-src");$(this).wrap(``)}),$(".popup").magnificPopup({type:"image",closeOnContentClick:!0,showCloseBtn:!1,zoom:{enabled:!0,duration:300,easing:"ease-in-out"}}),$(t+" a").has("img").addClass("img-link")}}),$(function(){var t=".code-header>button";const e="timeout";function l(t){if($(t)[0].hasAttribute(e)){t=$(t).attr(e);if(Number(t)>Date.now())return 1}}function s(t){$(t).attr(e,Date.now()+2e3)}function n(t){$(t).removeAttr(e)}const o=new ClipboardJS(t,{target(t){let e=t.parentNode.nextElementSibling;return e.querySelector("code .rouge-code")}});$(t).tooltip({trigger:"hover",placement:"left"});const a=function(t){let e=$(t).children();return e.attr("class")}(t);o.on("success",t=>{t.clearSelection();const e=t.trigger;var o;l(e)||(function(t){let e=$(t),o=e.children();o.attr("class","fas fa-check")}(e),o=e,t=$(o).attr("title-succeed"),$(o).attr("data-original-title",t).tooltip("show"),s(e),setTimeout(()=>{var t;t=e,$(t).tooltip("hide").removeAttr("data-original-title"),function(t){let e=$(t),o=e.children();o.attr("class",a)}(e),n(e)},2e3))}),$("#copy-link").click(t=>{let e=$(t.target);if(!l(e)){t=window.location.href;const o=$("");$("body").append(o),o.val(t).select(),document.execCommand("copy"),o.remove();const a=e.attr("data-original-title");t=e.attr("title-succeed");e.attr("data-original-title",t).tooltip("show"),s(e),setTimeout(()=>{e.attr("data-original-title",a),n(e)},2e3)}})}),$(function(){const i=$("#topbar-wrapper"),c=i.outerHeight(),t=$("#topbar-title"),d="toc-scrolling-up",u="scroll-focus";let p=0;$("a[href*='#']").not("[href='#']").not("[href='#0']").click(function(l){if(this.pathname.replace(/^\//,"")===location.pathname.replace(/^\//,"")&&location.hostname===this.hostname){const r=decodeURI(this.hash);let e=RegExp(/^#fnref:/).test(r),o=!e&&RegExp(/^#fn:/).test(r);var s=r.includes(":")?r.replace(/\:/g,"\\:"):r;let a=$(s);var n=$(this).parent().prop("tagName"),s=RegExp(/^H\d/).test(n),n=!t.is(":hidden");if(void 0!==a){l.preventDefault(),history.pushState&&history.pushState(null,null,r);l=s?$(this).offset().top:$(window).scrollTop();let t=a.offset().top-=8;t(a.focus(),$(`[${u}=true]`).length&&$(`[${u}=true]`).attr(u,!1),$(":target").length&&$(":target").attr(u,!1),(o||e)&&a.attr(u,!0),a.is(":focus")?!1:(a.attr("tabindex","-1"),a.focus(),void(void 0!==i.attr(d)&&(--p,p<=0&&i.attr(d,"false"))))))}}})}); \ No newline at end of file diff --git a/assets/js/dist/post.min.js b/assets/js/dist/post.min.js index e42751a..fe9beb6 100644 --- a/assets/js/dist/post.min.js +++ b/assets/js/dist/post.min.js @@ -3,4 +3,4 @@ * © 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(t=>{const e=$(t.target);let o=e.prop("tagName")==="button".toUpperCase()?e:e.parent();o.blur(),flipMode()})}),$(function(){const t=$("#sidebar-trigger"),e=$("#search-trigger"),o=$("#search-cancel"),a=$("#search-cleaner"),n=$("#main"),r=$("#topbar-title"),l=$("#search-wrapper"),s=$("#search-result-wrapper"),i=$("#search-results"),c=$("#search-input"),d=$("#search-hints"),u=function(){let t=0;return{block(){t=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(t)},getOffset(){return t}}}(),p={on(){t.addClass("unloaded"),r.addClass("unloaded"),e.addClass("unloaded"),l.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),l.removeClass("d-flex"),t.removeClass("unloaded"),r.removeClass("unloaded"),e.removeClass("unloaded")}},f=function(){let t=!1;return{on(){t||(u.block(),s.removeClass("unloaded"),n.addClass("unloaded"),t=!0)},off(){t&&(i.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),s.addClass("unloaded"),a.removeClass("visible"),n.removeClass("unloaded"),u.release(),c.val(""),t=!1)},isVisible(){return t}}}();function h(){return o.hasClass("loaded")}e.click(function(){p.on(),f.on(),c.focus()}),o.click(function(){p.off(),f.off()}),c.focus(function(){l.addClass("input-focus")}),c.focusout(function(){l.removeClass("input-focus")}),c.on("keyup",function(t){8===t.keyCode&&""===c.val()?h()?d.removeClass("unloaded"):f.off():""!==c.val()&&(f.on(),a.hasClass("visible")||a.addClass("visible"),h()&&d.addClass("unloaded"))}),a.on("click",function(){c.val(""),h()?(d.removeClass("unloaded"),i.empty()):f.off(),c.focus(),a.removeClass("visible")})}),$(function(){var t=function(){const t="sidebar-display";let e=!1;const o=$("body");return{toggle(){!1===e?o.attr(t,""):o.removeAttr(t),e=!e}}}();$("#sidebar-trigger").click(t.toggle),$("#mask").click(t.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const o=$("#topbar-wrapper"),a=$("#panel-wrapper"),n=$("#search-input"),r="topbar-up",l="topbar-down",s="toc-scrolling-up";let e,i=0;const c=o.outerHeight(),d=o.outerHeight();$(window).scroll(function(t){$("#topbar-title").is(":hidden")&&(e=!0)}),setInterval(function(){e&&(function(){var t,e=$(this).scrollTop();Math.abs(i-e)<=c||(e>i?e>d&&(o.removeClass(l).addClass(r),a.removeClass(l),n.is(":focus")&&n.blur()):e+$(window).height()<$(document).height()&&(void 0!==(t=o.attr(s))?"false"===t&&o.removeAttr(s):(o.removeClass(r).addClass(l),a.addClass(l))),i=e)}(),e=!1)},250)}),$(function(){const t=$("#topbar-title"),e=$("div.post>h1"),o=t.text().trim();let a=(0 img[data-src],${t} img[data-src].preview-img`).each(function(){let t=$(this).next();var e="EM"===t.prop("tagName")?t.text():"",o=$(this).attr("data-src");$(this).wrap(``)}),$(".popup").magnificPopup({type:"image",closeOnContentClick:!0,showCloseBtn:!1,zoom:{enabled:!0,duration:300,easing:"ease-in-out"}}),$(t+" a").has("img").addClass("img-link")}}),$(function(){let o=$(".timeago").length,t=void 0;const n=$("meta[name=day-prompt]").attr("content"),r=$("meta[name=hour-prompt]").attr("content"),l=$("meta[name=minute-prompt]").attr("content"),s=$("meta[name=justnow-prompt]").attr("content");function e(){return $(".timeago").each(function(){var t,e;!1!==$(this)[0].hasAttribute("date")?(e=function(t,e){let o=new Date,a=new Date(t);return a.getFullYear()!==o.getFullYear()||a.getMonth()!==o.getMonth()?e:(t=Math.floor((o-a)/1e3),1<=(e=Math.floor(t/86400))?` ${e} `+n:1<=(e=Math.floor(t/3600))?` ${e} `+r:1<=(t=Math.floor(t/60))?` ${t} `+l:s)}($(this).attr("date"),t=$(this).text()))===t?$(this).removeAttr("date"):$(this).text(e):--o}),0===o&&void 0!==t&&clearInterval(t),o}0!==o&&0'),$("input[type=checkbox]:not([checked])").before('')}),$(function(){var t=".code-header>button";const e="timeout";function n(t){if($(t)[0].hasAttribute(e)){t=$(t).attr(e);if(Number(t)>Date.now())return 1}}function r(t){$(t).attr(e,Date.now()+2e3)}function l(t){$(t).removeAttr(e)}const o=new ClipboardJS(t,{target(t){let e=t.parentNode.nextElementSibling;return e.querySelector("code .rouge-code")}});$(t).tooltip({trigger:"hover",placement:"left"});const a=function(t){let e=$(t).children();return e.attr("class")}(t);o.on("success",t=>{t.clearSelection();const e=t.trigger;var o;n(e)||(function(t){let e=$(t),o=e.children();o.attr("class","fas fa-check")}(e),o=e,t=$(o).attr("title-succeed"),$(o).attr("data-original-title",t).tooltip("show"),r(e),setTimeout(()=>{var t;t=e,$(t).tooltip("hide").removeAttr("data-original-title"),function(t){let e=$(t),o=e.children();o.attr("class",a)}(e),l(e)},2e3))}),$("#copy-link").click(t=>{let e=$(t.target);if(!n(e)){t=window.location.href;const o=$("");$("body").append(o),o.val(t).select(),document.execCommand("copy"),o.remove();const a=e.attr("data-original-title");t=e.attr("title-succeed");e.attr("data-original-title",t).tooltip("show"),r(e),setTimeout(()=>{e.attr("data-original-title",a),l(e)},2e3)}})}),$(function(){const i=$("#topbar-wrapper"),c=i.outerHeight(),t=$("#topbar-title"),d="toc-scrolling-up",u="scroll-focus";let p=0;$("a[href*='#']").not("[href='#']").not("[href='#0']").click(function(n){if(this.pathname.replace(/^\//,"")===location.pathname.replace(/^\//,"")&&location.hostname===this.hostname){const s=decodeURI(this.hash);let e=RegExp(/^#fnref:/).test(s),o=!e&&RegExp(/^#fn:/).test(s);var r=s.includes(":")?s.replace(/\:/g,"\\:"):s;let a=$(r);var l=$(this).parent().prop("tagName"),r=RegExp(/^H\d/).test(l),l=!t.is(":hidden");if(void 0!==a){n.preventDefault(),history.pushState&&history.pushState(null,null,s);n=r?$(this).offset().top:$(window).scrollTop();let t=a.offset().top-=8;t(a.focus(),$(`[${u}=true]`).length&&$(`[${u}=true]`).attr(u,!1),$(":target").length&&$(":target").attr(u,!1),(o||e)&&a.attr(u,!0),a.is(":focus")?!1:(a.attr("tabindex","-1"),a.focus(),void(void 0!==i.attr(d)&&(--p,p<=0&&i.attr(d,"false"))))))}}})}); \ No newline at end of file +$(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(t=>{const e=$(t.target);let o=e.prop("tagName")==="button".toUpperCase()?e:e.parent();o.blur(),flipMode()})}),$(function(){const t=$("#sidebar-trigger"),e=$("#search-trigger"),o=$("#search-cancel"),a=$("#search-cleaner"),n=$("#main"),r=$("#topbar-title"),l=$("#search-wrapper"),s=$("#search-result-wrapper"),i=$("#search-results"),c=$("#search-input"),d=$("#search-hints"),u=function(){let t=0;return{block(){t=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(t)},getOffset(){return t}}}(),p={on(){t.addClass("unloaded"),r.addClass("unloaded"),e.addClass("unloaded"),l.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),l.removeClass("d-flex"),t.removeClass("unloaded"),r.removeClass("unloaded"),e.removeClass("unloaded")}},f=function(){let t=!1;return{on(){t||(u.block(),s.removeClass("unloaded"),n.addClass("unloaded"),t=!0)},off(){t&&(i.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),s.addClass("unloaded"),a.removeClass("visible"),n.removeClass("unloaded"),u.release(),c.val(""),t=!1)},isVisible(){return t}}}();function h(){return o.hasClass("loaded")}e.click(function(){p.on(),f.on(),c.focus()}),o.click(function(){p.off(),f.off()}),c.focus(function(){l.addClass("input-focus")}),c.focusout(function(){l.removeClass("input-focus")}),c.on("keyup",function(t){8===t.keyCode&&""===c.val()?h()?d.removeClass("unloaded"):f.off():""!==c.val()&&(f.on(),a.hasClass("visible")||a.addClass("visible"),h()&&d.addClass("unloaded"))}),a.on("click",function(){c.val(""),h()?(d.removeClass("unloaded"),i.empty()):f.off(),c.focus(),a.removeClass("visible")})}),$(function(){var t=function(){const t="sidebar-display";let e=!1;const o=$("body");return{toggle(){!1===e?o.attr(t,""):o.removeAttr(t),e=!e}}}();$("#sidebar-trigger").click(t.toggle),$("#mask").click(t.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const o=$("#topbar-wrapper"),a=$("#panel-wrapper"),n=$("#search-input"),r="topbar-up",l="topbar-down",s="toc-scrolling-up";let e,i=0;const c=o.outerHeight(),d=o.outerHeight();$(window).scroll(function(t){$("#topbar-title").is(":hidden")&&(e=!0)}),setInterval(function(){e&&(function(){var t,e=$(this).scrollTop();Math.abs(i-e)<=c||(e>i?e>d&&(o.removeClass(l).addClass(r),a.removeClass(l),n.is(":focus")&&n.blur()):e+$(window).height()<$(document).height()&&(void 0!==(t=o.attr(s))?"false"===t&&o.removeAttr(s):(o.removeClass(r).addClass(l),a.addClass(l))),i=e)}(),e=!1)},250)}),$(function(){const t=$("#topbar-title"),e=$("div.post>h1"),o=t.text().trim();let a=(0 img[data-src],${t} img[data-src].preview-img`).each(function(){let t=$(this).next();var e="EM"===t.prop("tagName")?t.text():"",o=$(this).attr("data-src");$(this).wrap(``)}),$(".popup").magnificPopup({type:"image",closeOnContentClick:!0,showCloseBtn:!1,zoom:{enabled:!0,duration:300,easing:"ease-in-out"}}),$(t+" a").has("img").addClass("img-link")}}),$(function(){let o=$(".timeago").length,t=void 0;const n=$("meta[name=day-prompt]").attr("content"),r=$("meta[name=hour-prompt]").attr("content"),l=$("meta[name=minute-prompt]").attr("content"),s=$("meta[name=justnow-prompt]").attr("content");function e(){return $(".timeago").each(function(){var t,e;!1!==$(this)[0].hasAttribute("date")?(e=function(t,e){let o=new Date,a=new Date(t);return a.getFullYear()!==o.getFullYear()||a.getMonth()!==o.getMonth()?e:(t=Math.floor((o-a)/1e3),1<=(e=Math.floor(t/86400))?` ${e} `+n:1<=(e=Math.floor(t/3600))?` ${e} `+r:1<=(t=Math.floor(t/60))?` ${t} `+l:s)}($(this).attr("date"),t=$(this).text()))===t?$(this).removeAttr("date"):$(this).text(e):--o}),0===o&&void 0!==t&&clearInterval(t),o}0!==o&&0'),$("input[type=checkbox]:not([checked])").before('')}),$(function(){var t=".code-header>button";const e="timeout";function n(t){if($(t)[0].hasAttribute(e)){t=$(t).attr(e);if(Number(t)>Date.now())return 1}}function r(t){$(t).attr(e,Date.now()+2e3)}function l(t){$(t).removeAttr(e)}const o=new ClipboardJS(t,{target(t){let e=t.parentNode.nextElementSibling;return e.querySelector("code .rouge-code")}});$(t).tooltip({trigger:"hover",placement:"left"});const a=function(t){let e=$(t).children();return e.attr("class")}(t);o.on("success",t=>{t.clearSelection();const e=t.trigger;var o;n(e)||(function(t){let e=$(t),o=e.children();o.attr("class","fas fa-check")}(e),o=e,t=$(o).attr("title-succeed"),$(o).attr("data-original-title",t).tooltip("show"),r(e),setTimeout(()=>{var t;t=e,$(t).tooltip("hide").removeAttr("data-original-title"),function(t){let e=$(t),o=e.children();o.attr("class",a)}(e),l(e)},2e3))}),$("#copy-link").click(t=>{let e=$(t.target);if(!n(e)){t=window.location.href;const o=$("");$("body").append(o),o.val(t).select(),document.execCommand("copy"),o.remove();const a=e.attr("data-original-title");t=e.attr("title-succeed");e.attr("data-original-title",t).tooltip("show"),r(e),setTimeout(()=>{e.attr("data-original-title",a),l(e)},2e3)}})}),$(function(){const i=$("#topbar-wrapper"),c=i.outerHeight(),t=$("#topbar-title"),d="toc-scrolling-up",u="scroll-focus";let p=0;$("a[href*='#']").not("[href='#']").not("[href='#0']").click(function(n){if(this.pathname.replace(/^\//,"")===location.pathname.replace(/^\//,"")&&location.hostname===this.hostname){const s=decodeURI(this.hash);let e=RegExp(/^#fnref:/).test(s),o=!e&&RegExp(/^#fn:/).test(s);var r=s.includes(":")?s.replace(/\:/g,"\\:"):s;let a=$(r);var l=$(this).parent().prop("tagName"),r=RegExp(/^H\d/).test(l),l=!t.is(":hidden");if(void 0!==a){n.preventDefault(),history.pushState&&history.pushState(null,null,s);n=r?$(this).offset().top:$(window).scrollTop();let t=a.offset().top-=8;t(a.focus(),$(`[${u}=true]`).length&&$(`[${u}=true]`).attr(u,!1),$(":target").length&&$(":target").attr(u,!1),(o||e)&&a.attr(u,!0),a.is(":focus")?!1:(a.attr("tabindex","-1"),a.focus(),void(void 0!==i.attr(d)&&(--p,p<=0&&i.attr(d,"false"))))))}}})}); \ No newline at end of file