diff --git a/_includes/topbar.html b/_includes/topbar.html index 039434d..d0734b5 100644 --- a/_includes/topbar.html +++ b/_includes/topbar.html @@ -2,7 +2,7 @@ The Top Bar --> -
+
@@ -50,7 +50,7 @@
{% if page.layout == 'home' %} {{- site.data.locales[lang].title | default: site.title -}} - {% elsif page.collection == 'tabs' or page.dynamic_title %} + {% elsif page.collection == 'tabs' or page.layout == 'page' %} {%- capture tab_key -%}{{ page.url | split: '/' }}{%- endcapture -%} {{- site.data.locales[lang].tabs[tab_key] | default: page.title -}} {% else %} diff --git a/_javascript/commons/scroll-helper.js b/_javascript/commons/scroll-helper.js new file mode 100644 index 0000000..5dc6bd5 --- /dev/null +++ b/_javascript/commons/scroll-helper.js @@ -0,0 +1,36 @@ +/** + * A tool for smooth scrolling and topbar switcher + */ +const ScrollHelper = (function () { + const $body = $("body"); + const ATTR_TOPBAR_VISIBLE = "topbar-visible"; + const topbarHeight = $("#topbar-wrapper").outerHeight(); + + let scrollUpCount = 0; // the number of times the scroll up was triggered by ToC or anchor + let topbarLocked = false; + let orientationLocked = false; + + return { + hideTopbar: () => $body.attr(ATTR_TOPBAR_VISIBLE, false), + showTopbar: () => $body.attr(ATTR_TOPBAR_VISIBLE, true), + + // scroll up + + addScrollUpTask: () => { + scrollUpCount += 1; + if (!topbarLocked) { topbarLocked = true; } + }, + popScrollUpTask: () => scrollUpCount -= 1, + hasScrollUpTask: () => scrollUpCount > 0, + topbarLocked: () => topbarLocked === true, + unlockTopbar: () => topbarLocked = false, + getTopbarHeight: () => topbarHeight, + + // orientation change + + orientationLocked: () => orientationLocked === true, + lockOrientation: () => orientationLocked = true, + unLockOrientation: () => orientationLocked = false + }; + +}()); diff --git a/_javascript/commons/topbar-switch.js b/_javascript/commons/topbar-switch.js deleted file mode 100644 index b8942dd..0000000 --- a/_javascript/commons/topbar-switch.js +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Hide Header on scroll down - */ - -$(function() { - const $topbarWrapper = $("#topbar-wrapper"); - const $topbarTitle = $("#topbar-title"); - const $panel = $("#panel-wrapper"); - const $searchInput = $("#search-input"); - - const CLASS_TOPBAR_UP = "topbar-up"; - const CLASS_TOPBAR_DOWN = "topbar-down"; - const ATTR_TOC_SCROLLING_UP = "toc-scrolling-up"; // topbar locked - - let didScroll; - let lastScrollTop = 0; - - const delta = $topbarWrapper.outerHeight(); - const topbarHeight = $topbarWrapper.outerHeight(); - - function hasScrolled() { - let st = $(this).scrollTop(); - - /* Make sure they scroll more than delta */ - if (Math.abs(lastScrollTop - st) <= delta) { - return; - } - - if (st > lastScrollTop ) { // Scroll Down - if (st > topbarHeight) { - $topbarWrapper.removeClass(CLASS_TOPBAR_DOWN).addClass(CLASS_TOPBAR_UP); - $panel.removeClass(CLASS_TOPBAR_DOWN); - - if ($searchInput.is(":focus")) { - $searchInput.blur(); /* remove focus */ - } - } - } else {// Scroll up - // did not reach the bottom of the document, i.e., still have space to scroll up - if (st + $(window).height() < $(document).height()) { - let tocScrollingUp = $topbarWrapper.attr(ATTR_TOC_SCROLLING_UP); - if (typeof tocScrollingUp !== "undefined") { - if (tocScrollingUp === "false") { - $topbarWrapper.removeAttr(ATTR_TOC_SCROLLING_UP); - } - - } else { - $topbarWrapper.removeClass(CLASS_TOPBAR_UP).addClass(CLASS_TOPBAR_DOWN); - $panel.addClass(CLASS_TOPBAR_DOWN); - } - } - } - - lastScrollTop = st; - } - - $(window).scroll(function(event) { - if ($topbarTitle.is(":hidden")) { - didScroll = true; - } - }); - - setInterval(function() { - if (didScroll) { - hasScrolled(); - didScroll = false; - } - }, 250); - -}); diff --git a/_javascript/commons/topbar-switcher.js b/_javascript/commons/topbar-switcher.js new file mode 100644 index 0000000..f1c42bf --- /dev/null +++ b/_javascript/commons/topbar-switcher.js @@ -0,0 +1,90 @@ +/* + * Hide Header on scroll down + */ + +$(function() { + const $searchInput = $("#search-input"); + const delta = ScrollHelper.getTopbarHeight(); + + let didScroll; + let lastScrollTop = 0; + + function hasScrolled() { + let st = $(this).scrollTop(); + + /* Make sure they scroll more than delta */ + if (Math.abs(lastScrollTop - st) <= delta) { + return; + } + + if (st > lastScrollTop ) { // Scroll Down + ScrollHelper.hideTopbar(); + + if ($searchInput.is(":focus")) { + $searchInput.blur(); /* remove focus */ + } + + } else { // Scroll up + // has not yet scrolled to the bottom of the screen, that is, there is still space for scrolling + if (st + $(window).height() < $(document).height()) { + + if (ScrollHelper.hasScrollUpTask()) { + return; + } + + if (ScrollHelper.topbarLocked()) { // avoid redundant scroll up event from smooth scrolling + ScrollHelper.unlockTopbar(); + } else { + if (ScrollHelper.orientationLocked()) { // avoid device auto scroll up on orientation change + ScrollHelper.unLockOrientation(); + } else { + ScrollHelper.showTopbar(); + } + } + } + } + + lastScrollTop = st; + + } // hasScrolled() + + function handleLandscape() { + if ($(window).scrollTop() === 0) { + return; + } + ScrollHelper.lockOrientation(); + ScrollHelper.hideTopbar(); + } + + if (screen.orientation) { + screen.orientation.onchange = () => { + const type = screen.orientation.type; + if (type === "landscape-primary" || type === "landscape-secondary") { + handleLandscape(); + } + }; + + } else { + // for the browsers that not support `window.screen.orientation` API + $(window).on("orientationchange",() => { + if ($(window).width() < $(window).height()) { // before rotating, it is still in portrait mode. + handleLandscape(); + } + }); + } + + $(window).scroll(() => { + if (didScroll) { + return; + } + didScroll = true; + }); + + setInterval(() => { + if (didScroll) { + hasScrolled(); + didScroll = false; + } + }, 250); + +}); diff --git a/_javascript/commons/topbar-title.js b/_javascript/commons/topbar-title.js index 2208afa..ff82151 100644 --- a/_javascript/commons/topbar-title.js +++ b/_javascript/commons/topbar-title.js @@ -14,17 +14,22 @@ $(function() { } const defaultTitleText = $topbarTitle.text().trim(); - let titleText = $pageTitle.text().trim(); + let pageTitleText = $pageTitle.text().trim(); let hasScrolled = false; let lastScrollTop = 0; if ($("#page-category").length || $("#page-tag").length) { /* The title in Category or Tag page will be " <count_of_posts>" */ - if (/\s/.test(titleText)) { - titleText = titleText.replace(/[0-9]/g, "").trim(); + if (/\s/.test(pageTitleText)) { + pageTitleText = pageTitleText.replace(/[0-9]/g, "").trim(); } } + // When the page is scrolled down and then refreshed, the topbar title needs to be initialized + if ($pageTitle.offset().top < $(window).scrollTop()) { + $topbarTitle.text(pageTitleText); + } + let options = { rootMargin: '-48px 0px 0px 0px', // 48px equals to the topbar height (3rem) threshold: [0, 1] @@ -43,7 +48,7 @@ $(function() { if (isScrollDown) { if (heading.intersectionRatio === 0) { - $topbarTitle.text(titleText); + $topbarTitle.text(pageTitleText); } } else { if (heading.intersectionRatio === 1) { diff --git a/_javascript/utils/smooth-scroll.js b/_javascript/utils/smooth-scroll.js index a8ad44c..200cb65 100644 --- a/_javascript/utils/smooth-scroll.js +++ b/_javascript/utils/smooth-scroll.js @@ -8,21 +8,16 @@ */ $(function() { - const $topbarWrapper = $("#topbar-wrapper"); - const topbarHeight = $topbarWrapper.outerHeight(); const $topbarTitle = $("#topbar-title"); - - const ATTR_TOC_SCROLLING = "toc-scrolling-up"; - const SCROLL_MARK = "scroll-focus"; const REM = 16; // in pixels - let tocScrollUpCount = 0; + const ATTR_SCROLL_FOCUS = "scroll-focus"; $("a[href*='#']") .not("[href='#']") .not("[href='#0']") .click(function(event) { - - if (this.pathname.replace(/^\//, "") !== location.pathname.replace(/^\//, "")) { + if (this.pathname.replace(/^\//, "") !== + location.pathname.replace(/^\//, "")) { return; } @@ -36,9 +31,8 @@ $(function() { 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"); + let isMobileViews = $topbarTitle.is(":visible"); + let isPortrait = $(window).width() < $(window).height(); if (typeof $target === "undefined") { return; @@ -50,26 +44,20 @@ $(function() { history.pushState(null, null, hash); } - let curOffset = isAnchor ? $(this).offset().top : $(window).scrollTop(); + let curOffset = $(window).scrollTop(); let destOffset = $target.offset().top -= REM / 2; 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; - } + ScrollHelper.hideTopbar(); + ScrollHelper.addScrollUpTask(); + + if (isMobileViews && isPortrait) { + destOffset -= ScrollHelper.getTopbarHeight(); } - if ((isAnchor || toFootnoteRef) && isMobileViews) { - destOffset -= topbarHeight; - } - - } else { - if (isMobileViews) { - destOffset -= topbarHeight; + } else { // scroll down + if (isMobileViews && isPortrait) { + destOffset -= ScrollHelper.getTopbarHeight(); } } @@ -79,18 +67,18 @@ $(function() { $target.focus(); /* clean up old scroll mark */ - if ($(`[${SCROLL_MARK}=true]`).length) { - $(`[${SCROLL_MARK}=true]`).attr(SCROLL_MARK, false); + if ($(`[${ATTR_SCROLL_FOCUS}=true]`).length) { + $(`[${ATTR_SCROLL_FOCUS}=true]`).attr(ATTR_SCROLL_FOCUS, false); } /* Clean :target links */ if ($(":target").length) { /* element that visited by the URL with hash */ - $(":target").attr(SCROLL_MARK, false); + $(":target").attr(ATTR_SCROLL_FOCUS, false); } /* set scroll mark to footnotes */ if (toFootnote || toFootnoteRef) { - $target.attr(SCROLL_MARK, true); + $target.attr(ATTR_SCROLL_FOCUS, true); } if ($target.is(":focus")) { /* Checking if the target was focused */ @@ -100,12 +88,8 @@ $(function() { $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 (ScrollHelper.hasScrollUpTask()) { + ScrollHelper.popScrollUpTask(); } }); }); /* click() */ diff --git a/_layouts/default.html b/_layouts/default.html index 4bcede5..99c4d8a 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -21,7 +21,7 @@ layout: compress {% include mode-toggle.html %} {% endunless %} - <body data-spy="scroll" data-target="#toc"> + <body data-spy="scroll" data-target="#toc" topbar-visible="true"> {% include sidebar.html %} diff --git a/_layouts/page.html b/_layouts/page.html index cf998f0..5eafb93 100644 --- a/_layouts/page.html +++ b/_layouts/page.html @@ -34,7 +34,7 @@ layout: default </div> <!-- #core-wrapper --> <!-- pannel --> - <div id="panel-wrapper" class="col-xl-3 pl-2 text-muted topbar-down"> + <div id="panel-wrapper" class="col-xl-3 pl-2 text-muted"> <div class="access"> {% include update-list.html %} diff --git a/_sass/addon/commons.scss b/_sass/addon/commons.scss index 13a11e9..ce8f6be 100644 --- a/_sass/addon/commons.scss +++ b/_sass/addon/commons.scss @@ -247,7 +247,7 @@ img[data-src] { } } - &.topbar-down > div { + [topbar-visible=true] & > div { top: 6rem; } } @@ -570,10 +570,6 @@ img[data-src] { box-shadow: 0 0 8px 0 var(--btn-box-shadow) !important; } -.topbar-up { - top: -3rem !important; /* same as topbar height. */ -} - .no-text-decoration { @include no-text-decoration; } @@ -876,6 +872,10 @@ $sidebar-display: "sidebar-display"; z-index: 50; border-bottom: 1px solid rgba(0, 0, 0, 0.07); background-color: var(--topbar-wrapper-bg); + + [topbar-visible=false] & { + top: -$topbar-height; /* same as topbar height. */ + } } #topbar { @@ -1193,9 +1193,15 @@ $sidebar-display: "sidebar-display"; /* hide sidebar and panel */ @media all and (max-width: 849px) { - %slide { - -webkit-transition: transform 0.4s ease; - transition: transform 0.4s ease; + @mixin slide($append: null) { + $basic: transform 0.4s ease; + @if $append { + -webkit-transition: $basic, $append; + transition: $basic, $append; + } @else { + -webkit-transition: $basic; + transition: $basic; + } } html, @@ -1203,15 +1209,6 @@ $sidebar-display: "sidebar-display"; overflow-x: hidden; } - .footnotes ol > li { - padding-top: 3.5rem; - margin-top: -3.2rem; - - &:first-child { - margin-top: -3.5rem; - } - } - [#{$sidebar-display}] { #sidebar { transform: translateX(0); @@ -1221,11 +1218,10 @@ $sidebar-display: "sidebar-display"; #main-wrapper { transform: translateX(#{$sidebar-width}); } - } #sidebar { - @extend %slide; + @include slide; transform: translateX(-#{$sidebar-width}); // hide -webkit-transform: translateX(-#{$sidebar-width}); @@ -1238,7 +1234,7 @@ $sidebar-display: "sidebar-display"; } #main-wrapper { - @extend %slide; + @include slide; padding-top: $topbar-height; } @@ -1253,15 +1249,11 @@ $sidebar-display: "sidebar-display"; } #topbar-wrapper { - @extend %slide; + @include slide(top 0.2s ease); left: 0; } - .topbar-up { - top: 0 !important; - } - #main > div.row:first-child > div:nth-child(1), #main > div.row:first-child > div:nth-child(2) { margin-top: 0; @@ -1308,6 +1300,12 @@ $sidebar-display: "sidebar-display"; } // max-width: 849px +@media all and (max-width: 849px) and (orientation: portrait) { + [topbar-visible=false] #topbar-wrapper { + top: 0; + } +} + /* Phone & Pad */ @media all and (min-width: 577px) and (max-width: 1199px) { footer > .d-flex > div { @@ -1353,10 +1351,6 @@ $sidebar-display: "sidebar-display"; right: 1.2rem; } - .topbar-up { - box-shadow: none !important; - } - #topbar-title { text-align: left; } diff --git a/assets/404.html b/assets/404.html index dde158a..1608517 100644 --- a/assets/404.html +++ b/assets/404.html @@ -7,8 +7,6 @@ redirect_from: - /norobots/ - /assets/ - /posts/ - -dynamic_title: true --- {% include lang.html %} diff --git a/assets/js/dist/categories.min.js b/assets/js/dist/categories.min.js index 5aa4341..72ce62c 100644 --- a/assets/js/dist/categories.min.js +++ b/assets/js/dist/categories.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(e=>{const o=$(e.target);let t=o.prop("tagName")==="button".toUpperCase()?o:o.parent();t.blur(),flipMode()})}),$(function(){const e=$("#sidebar-trigger"),o=$("#search-trigger"),t=$("#search-cancel"),s=$("#search-cleaner"),a=$("#main"),l=$("#topbar-title"),r=$("#search-wrapper"),n=$("#search-result-wrapper"),d=$("#search-results"),i=$("#search-input"),c=$("#search-hints"),u=function(){let e=0;return{block(){e=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(e)},getOffset(){return e}}}(),f={on(){e.addClass("unloaded"),l.addClass("unloaded"),o.addClass("unloaded"),r.addClass("d-flex"),t.addClass("loaded")},off(){t.removeClass("loaded"),r.removeClass("d-flex"),e.removeClass("unloaded"),l.removeClass("unloaded"),o.removeClass("unloaded")}},p=function(){let e=!1;return{on(){e||(u.block(),n.removeClass("unloaded"),a.addClass("unloaded"),e=!0)},off(){e&&(d.empty(),c.hasClass("unloaded")&&c.removeClass("unloaded"),n.addClass("unloaded"),s.removeClass("visible"),a.removeClass("unloaded"),u.release(),i.val(""),e=!1)},isVisible(){return e}}}();function h(){return t.hasClass("loaded")}o.click(function(){f.on(),p.on(),i.focus()}),t.click(function(){f.off(),p.off()}),i.focus(function(){r.addClass("input-focus")}),i.focusout(function(){r.removeClass("input-focus")}),i.on("keyup",function(e){8===e.keyCode&&""===i.val()?h()?c.removeClass("unloaded"):p.off():""!==i.val()&&(p.on(),s.hasClass("visible")||s.addClass("visible"),h()&&c.addClass("unloaded"))}),s.on("click",function(){i.val(""),h()?(c.removeClass("unloaded"),d.empty()):p.off(),i.focus(),s.removeClass("visible")})}),$(function(){var e=function(){const e="sidebar-display";let o=!1;const t=$("body");return{toggle(){!1===o?t.attr(e,""):t.removeAttr(e),o=!o}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const t=$("#topbar-wrapper"),o=$("#topbar-title"),s=$("#panel-wrapper"),a=$("#search-input"),l="topbar-up",r="topbar-down",n="toc-scrolling-up";let d,i=0;const c=t.outerHeight(),u=t.outerHeight();$(window).scroll(function(e){o.is(":hidden")&&(d=!0)}),setInterval(function(){d&&(function(){var e,o=$(this).scrollTop();Math.abs(i-o)<=c||(o>i?o>u&&(t.removeClass(r).addClass(l),s.removeClass(r),a.is(":focus")&&a.blur()):o+$(window).height()<$(document).height()&&(void 0!==(e=t.attr(n))?"false"===e&&t.removeAttr(n):(t.removeClass(l).addClass(r),s.addClass(r))),i=o)}(),d=!1)},250)}),$(function(){var o="div.post>h1:first-of-type";const t=$(o),r=$("#topbar-title");if(0!==t.length&&!t.hasClass("dynamic-title")&&!r.is(":hidden")){const n=r.text().trim();let s=t.text().trim(),a=!1,l=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(s)&&(s=s.replace(/[0-9]/g,"").trim());let e=new IntersectionObserver(e=>{var o,t;a?(o=$(window).scrollTop(),t=l<o,l=o,e=e[0],t?0===e.intersectionRatio&&r.text(s):1===e.intersectionRatio&&r.text(n)):a=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]});e.observe(document.querySelector(o)),r.click(function(){$("body,html").animate({scrollTop:0},800)})}}),$(function(){const e=$(".collapse");e.on("hide.bs.collapse",function(){var e="h_"+$(this).attr("id").substring("l_".length);e&&($(`#${e} .far.fa-folder-open`).attr("class","far fa-folder fa-fw"),$(`#${e} i.fas`).addClass("rotate"),$("#"+e).removeClass("hide-border-bottom"))}),e.on("show.bs.collapse",function(){var e="h_"+$(this).attr("id").substring("l_".length);e&&($(`#${e} .far.fa-folder`).attr("class","far fa-folder-open fa-fw"),$(`#${e} i.fas`).removeClass("rotate"),$("#"+e).addClass("hide-border-bottom"))})}); \ 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(o=>{const e=$(o.target);let t=e.prop("tagName")==="button".toUpperCase()?e:e.parent();t.blur(),flipMode()})});const ScrollHelper=function(){const o=$("body"),e="topbar-visible",t=$("#topbar-wrapper").outerHeight();let l=0,a=!1,r=!1;return{hideTopbar:()=>o.attr(e,!1),showTopbar:()=>o.attr(e,!0),addScrollUpTask:()=>{l+=1,a=a||!0},popScrollUpTask:()=>--l,hasScrollUpTask:()=>0<l,topbarLocked:()=>!0===a,unlockTopbar:()=>a=!1,getTopbarHeight:()=>t,orientationLocked:()=>!0===r,lockOrientation:()=>r=!0,unLockOrientation:()=>r=!1}}();$(function(){const o=$("#sidebar-trigger"),e=$("#search-trigger"),t=$("#search-cancel"),l=$("#search-cleaner"),a=$("#main"),r=$("#topbar-title"),s=$("#search-wrapper"),n=$("#search-result-wrapper"),i=$("#search-results"),c=$("#search-input"),d=$("#search-hints"),p=function(){let o=0;return{block(){o=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(o)},getOffset(){return o}}}(),f={on(){o.addClass("unloaded"),r.addClass("unloaded"),e.addClass("unloaded"),s.addClass("d-flex"),t.addClass("loaded")},off(){t.removeClass("loaded"),s.removeClass("d-flex"),o.removeClass("unloaded"),r.removeClass("unloaded"),e.removeClass("unloaded")}},u=function(){let o=!1;return{on(){o||(p.block(),n.removeClass("unloaded"),a.addClass("unloaded"),o=!0)},off(){o&&(i.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),n.addClass("unloaded"),l.removeClass("visible"),a.removeClass("unloaded"),p.release(),c.val(""),o=!1)},isVisible(){return o}}}();function h(){return t.hasClass("loaded")}e.click(function(){f.on(),u.on(),c.focus()}),t.click(function(){f.off(),u.off()}),c.focus(function(){s.addClass("input-focus")}),c.focusout(function(){s.removeClass("input-focus")}),c.on("keyup",function(o){8===o.keyCode&&""===c.val()?h()?d.removeClass("unloaded"):u.off():""!==c.val()&&(u.on(),l.hasClass("visible")||l.addClass("visible"),h()&&d.addClass("unloaded"))}),l.on("click",function(){c.val(""),h()?(d.removeClass("unloaded"),i.empty()):u.off(),c.focus(),l.removeClass("visible")})}),$(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 a(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var o=screen.orientation.type;"landscape-primary"!==o&&"landscape-secondary"!==o||a()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&a()}),$(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 e="div.post>h1:first-of-type";const t=$(e),s=$("#topbar-title");if(0!==t.length&&!t.hasClass("dynamic-title")&&!s.is(":hidden")){const n=s.text().trim();let l=t.text().trim(),a=!1,r=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(l)&&(l=l.replace(/[0-9]/g,"").trim()),t.offset().top<$(window).scrollTop()&&s.text(l);let o=new IntersectionObserver(o=>{var e,t;a?(e=$(window).scrollTop(),t=r<e,r=e,o=o[0],t?0===o.intersectionRatio&&s.text(l):1===o.intersectionRatio&&s.text(n)):a=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]});o.observe(document.querySelector(e)),s.click(function(){$("body,html").animate({scrollTop:0},800)})}}),$(function(){const o=$(".collapse");o.on("hide.bs.collapse",function(){var o="h_"+$(this).attr("id").substring("l_".length);o&&($(`#${o} .far.fa-folder-open`).attr("class","far fa-folder fa-fw"),$(`#${o} i.fas`).addClass("rotate"),$("#"+o).removeClass("hide-border-bottom"))}),o.on("show.bs.collapse",function(){var o="h_"+$(this).attr("id").substring("l_".length);o&&($(`#${o} .far.fa-folder`).attr("class","far fa-folder-open fa-fw"),$(`#${o} i.fas`).removeClass("rotate"),$("#"+o).addClass("hide-border-bottom"))})}); \ No newline at end of file diff --git a/assets/js/dist/commons.min.js b/assets/js/dist/commons.min.js index b686a1f..4f29516 100644 --- a/assets/js/dist/commons.min.js +++ b/assets/js/dist/commons.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(e=>{const o=$(e.target);let t=o.prop("tagName")==="button".toUpperCase()?o:o.parent();t.blur(),flipMode()})}),$(function(){const e=$("#sidebar-trigger"),o=$("#search-trigger"),t=$("#search-cancel"),s=$("#search-cleaner"),a=$("#main"),l=$("#topbar-title"),n=$("#search-wrapper"),r=$("#search-result-wrapper"),i=$("#search-results"),d=$("#search-input"),c=$("#search-hints"),u=function(){let e=0;return{block(){e=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(e)},getOffset(){return e}}}(),p={on(){e.addClass("unloaded"),l.addClass("unloaded"),o.addClass("unloaded"),n.addClass("d-flex"),t.addClass("loaded")},off(){t.removeClass("loaded"),n.removeClass("d-flex"),e.removeClass("unloaded"),l.removeClass("unloaded"),o.removeClass("unloaded")}},f=function(){let e=!1;return{on(){e||(u.block(),r.removeClass("unloaded"),a.addClass("unloaded"),e=!0)},off(){e&&(i.empty(),c.hasClass("unloaded")&&c.removeClass("unloaded"),r.addClass("unloaded"),s.removeClass("visible"),a.removeClass("unloaded"),u.release(),d.val(""),e=!1)},isVisible(){return e}}}();function m(){return t.hasClass("loaded")}o.click(function(){p.on(),f.on(),d.focus()}),t.click(function(){p.off(),f.off()}),d.focus(function(){n.addClass("input-focus")}),d.focusout(function(){n.removeClass("input-focus")}),d.on("keyup",function(e){8===e.keyCode&&""===d.val()?m()?c.removeClass("unloaded"):f.off():""!==d.val()&&(f.on(),s.hasClass("visible")||s.addClass("visible"),m()&&c.addClass("unloaded"))}),s.on("click",function(){d.val(""),m()?(c.removeClass("unloaded"),i.empty()):f.off(),d.focus(),s.removeClass("visible")})}),$(function(){var e=function(){const e="sidebar-display";let o=!1;const t=$("body");return{toggle(){!1===o?t.attr(e,""):t.removeAttr(e),o=!o}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const t=$("#topbar-wrapper"),o=$("#topbar-title"),s=$("#panel-wrapper"),a=$("#search-input"),l="topbar-up",n="topbar-down",r="toc-scrolling-up";let i,d=0;const c=t.outerHeight(),u=t.outerHeight();$(window).scroll(function(e){o.is(":hidden")&&(i=!0)}),setInterval(function(){i&&(function(){var e,o=$(this).scrollTop();Math.abs(d-o)<=c||(o>d?o>u&&(t.removeClass(n).addClass(l),s.removeClass(n),a.is(":focus")&&a.blur()):o+$(window).height()<$(document).height()&&(void 0!==(e=t.attr(r))?"false"===e&&t.removeAttr(r):(t.removeClass(l).addClass(n),s.addClass(n))),d=o)}(),i=!1)},250)}),$(function(){var o="div.post>h1:first-of-type";const t=$(o),n=$("#topbar-title");if(0!==t.length&&!t.hasClass("dynamic-title")&&!n.is(":hidden")){const r=n.text().trim();let s=t.text().trim(),a=!1,l=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(s)&&(s=s.replace(/[0-9]/g,"").trim());let e=new IntersectionObserver(e=>{var o,t;a?(o=$(window).scrollTop(),t=l<o,l=o,e=e[0],t?0===e.intersectionRatio&&n.text(s):1===e.intersectionRatio&&n.text(r)):a=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]});e.observe(document.querySelector(o)),n.click(function(){$("body,html").animate({scrollTop:0},800)})}}); \ 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(e=>{const o=$(e.target);let t=o.prop("tagName")==="button".toUpperCase()?o:o.parent();t.blur(),flipMode()})});const ScrollHelper=function(){const e=$("body"),o="topbar-visible",t=$("#topbar-wrapper").outerHeight();let l=0,r=!1,a=!1;return{hideTopbar:()=>e.attr(o,!1),showTopbar:()=>e.attr(o,!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 e=$("#sidebar-trigger"),o=$("#search-trigger"),t=$("#search-cancel"),l=$("#search-cleaner"),r=$("#main"),a=$("#topbar-title"),n=$("#search-wrapper"),s=$("#search-result-wrapper"),i=$("#search-results"),c=$("#search-input"),d=$("#search-hints"),p=function(){let e=0;return{block(){e=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(e)},getOffset(){return e}}}(),u={on(){e.addClass("unloaded"),a.addClass("unloaded"),o.addClass("unloaded"),n.addClass("d-flex"),t.addClass("loaded")},off(){t.removeClass("loaded"),n.removeClass("d-flex"),e.removeClass("unloaded"),a.removeClass("unloaded"),o.removeClass("unloaded")}},f=function(){let e=!1;return{on(){e||(p.block(),s.removeClass("unloaded"),r.addClass("unloaded"),e=!0)},off(){e&&(i.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),s.addClass("unloaded"),l.removeClass("visible"),r.removeClass("unloaded"),p.release(),c.val(""),e=!1)},isVisible(){return e}}}();function h(){return t.hasClass("loaded")}o.click(function(){u.on(),f.on(),c.focus()}),t.click(function(){u.off(),f.off()}),c.focus(function(){n.addClass("input-focus")}),c.focusout(function(){n.removeClass("input-focus")}),c.on("keyup",function(e){8===e.keyCode&&""===c.val()?h()?d.removeClass("unloaded"):f.off():""!==c.val()&&(f.on(),l.hasClass("visible")||l.addClass("visible"),h()&&d.addClass("unloaded"))}),l.on("click",function(){c.val(""),h()?(d.removeClass("unloaded"),i.empty()):f.off(),c.focus(),l.removeClass("visible")})}),$(function(){var e=function(){const e="sidebar-display";let o=!1;const t=$("body");return{toggle(){!1===o?t.attr(e,""):t.removeAttr(e),o=!o}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const o=$("#search-input"),t=ScrollHelper.getTopbarHeight();let e,l=0;function r(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var e=screen.orientation.type;"landscape-primary"!==e&&"landscape-secondary"!==e||r()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&r()}),$(window).scroll(()=>{e=e||!0}),setInterval(()=>{e&&(function(){var e=$(this).scrollTop();if(!(Math.abs(l-e)<=t)){if(e>l)ScrollHelper.hideTopbar(),o.is(":focus")&&o.blur();else if(e+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}l=e}}(),e=!1)},250)}),$(function(){var o="div.post>h1:first-of-type";const t=$(o),n=$("#topbar-title");if(0!==t.length&&!t.hasClass("dynamic-title")&&!n.is(":hidden")){const s=n.text().trim();let l=t.text().trim(),r=!1,a=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(l)&&(l=l.replace(/[0-9]/g,"").trim()),t.offset().top<$(window).scrollTop()&&n.text(l);let e=new IntersectionObserver(e=>{var o,t;r?(o=$(window).scrollTop(),t=a<o,a=o,e=e[0],t?0===e.intersectionRatio&&n.text(l):1===e.intersectionRatio&&n.text(s)):r=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]});e.observe(document.querySelector(o)),n.click(function(){$("body,html").animate({scrollTop:0},800)})}}); \ No newline at end of file diff --git a/assets/js/dist/home.min.js b/assets/js/dist/home.min.js index 23bf90c..7ee08f4 100644 --- a/assets/js/dist/home.min.js +++ b/assets/js/dist/home.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"),s=$("#main"),l=$("#topbar-title"),n=$("#search-wrapper"),r=$("#search-result-wrapper"),i=$("#search-results"),d=$("#search-input"),c=$("#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"),l.addClass("unloaded"),e.addClass("unloaded"),n.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),n.removeClass("d-flex"),t.removeClass("unloaded"),l.removeClass("unloaded"),e.removeClass("unloaded")}},f=function(){let t=!1;return{on(){t||(u.block(),r.removeClass("unloaded"),s.addClass("unloaded"),t=!0)},off(){t&&(i.empty(),c.hasClass("unloaded")&&c.removeClass("unloaded"),r.addClass("unloaded"),a.removeClass("visible"),s.removeClass("unloaded"),u.release(),d.val(""),t=!1)},isVisible(){return t}}}();function m(){return o.hasClass("loaded")}e.click(function(){p.on(),f.on(),d.focus()}),o.click(function(){p.off(),f.off()}),d.focus(function(){n.addClass("input-focus")}),d.focusout(function(){n.removeClass("input-focus")}),d.on("keyup",function(t){8===t.keyCode&&""===d.val()?m()?c.removeClass("unloaded"):f.off():""!==d.val()&&(f.on(),a.hasClass("visible")||a.addClass("visible"),m()&&c.addClass("unloaded"))}),a.on("click",function(){d.val(""),m()?(c.removeClass("unloaded"),i.empty()):f.off(),d.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"),e=$("#topbar-title"),a=$("#panel-wrapper"),s=$("#search-input"),l="topbar-up",n="topbar-down",r="toc-scrolling-up";let i,d=0;const c=o.outerHeight(),u=o.outerHeight();$(window).scroll(function(t){e.is(":hidden")&&(i=!0)}),setInterval(function(){i&&(function(){var t,e=$(this).scrollTop();Math.abs(d-e)<=c||(e>d?e>u&&(o.removeClass(n).addClass(l),a.removeClass(n),s.is(":focus")&&s.blur()):e+$(window).height()<$(document).height()&&(void 0!==(t=o.attr(r))?"false"===t&&o.removeAttr(r):(o.removeClass(l).addClass(n),a.addClass(n))),d=e)}(),i=!1)},250)}),$(function(){var e="div.post>h1:first-of-type";const o=$(e),n=$("#topbar-title");if(0!==o.length&&!o.hasClass("dynamic-title")&&!n.is(":hidden")){const r=n.text().trim();let a=o.text().trim(),s=!1,l=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim());let t=new IntersectionObserver(t=>{var e,o;s?(e=$(window).scrollTop(),o=l<e,l=e,t=t[0],o?0===t.intersectionRatio&&n.text(a):1===t.intersectionRatio&&n.text(r)):s=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]});t.observe(document.querySelector(e)),n.click(function(){$("body,html").animate({scrollTop:0},800)})}}),$(function(){let o=$(".timeago").length,t=void 0;const s=$("meta[name=day-prompt]").attr("content"),l=$("meta[name=hour-prompt]").attr("content"),n=$("meta[name=minute-prompt]").attr("content"),r=$("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} `+s:1<=(e=Math.floor(t/3600))?` ${e} `+l:1<=(t=Math.floor(t/60))?` ${t} `+n:r)}($(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<e()&&(t=setInterval(e,6e4))}); \ 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(e=>{const t=$(e.target);let o=t.prop("tagName")==="button".toUpperCase()?t:t.parent();o.blur(),flipMode()})});const ScrollHelper=function(){const e=$("body"),t="topbar-visible",o=$("#topbar-wrapper").outerHeight();let a=0,l=!1,r=!1;return{hideTopbar:()=>e.attr(t,!1),showTopbar:()=>e.attr(t,!0),addScrollUpTask:()=>{a+=1,l=l||!0},popScrollUpTask:()=>--a,hasScrollUpTask:()=>0<a,topbarLocked:()=>!0===l,unlockTopbar:()=>l=!1,getTopbarHeight:()=>o,orientationLocked:()=>!0===r,lockOrientation:()=>r=!0,unLockOrientation:()=>r=!1}}();$(function(){const e=$("#sidebar-trigger"),t=$("#search-trigger"),o=$("#search-cancel"),a=$("#search-cleaner"),l=$("#main"),r=$("#topbar-title"),n=$("#search-wrapper"),s=$("#search-result-wrapper"),i=$("#search-results"),c=$("#search-input"),d=$("#search-hints"),p=function(){let e=0;return{block(){e=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(e)},getOffset(){return e}}}(),u={on(){e.addClass("unloaded"),r.addClass("unloaded"),t.addClass("unloaded"),n.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),n.removeClass("d-flex"),e.removeClass("unloaded"),r.removeClass("unloaded"),t.removeClass("unloaded")}},f=function(){let e=!1;return{on(){e||(p.block(),s.removeClass("unloaded"),l.addClass("unloaded"),e=!0)},off(){e&&(i.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),s.addClass("unloaded"),a.removeClass("visible"),l.removeClass("unloaded"),p.release(),c.val(""),e=!1)},isVisible(){return e}}}();function h(){return o.hasClass("loaded")}t.click(function(){u.on(),f.on(),c.focus()}),o.click(function(){u.off(),f.off()}),c.focus(function(){n.addClass("input-focus")}),c.focusout(function(){n.removeClass("input-focus")}),c.on("keyup",function(e){8===e.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 e=function(){const e="sidebar-display";let t=!1;const o=$("body");return{toggle(){!1===t?o.attr(e,""):o.removeAttr(e),t=!t}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const t=$("#search-input"),o=ScrollHelper.getTopbarHeight();let e,a=0;function l(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var e=screen.orientation.type;"landscape-primary"!==e&&"landscape-secondary"!==e||l()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&l()}),$(window).scroll(()=>{e=e||!0}),setInterval(()=>{e&&(function(){var e=$(this).scrollTop();if(!(Math.abs(a-e)<=o)){if(e>a)ScrollHelper.hideTopbar(),t.is(":focus")&&t.blur();else if(e+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}a=e}}(),e=!1)},250)}),$(function(){var t="div.post>h1:first-of-type";const o=$(t),n=$("#topbar-title");if(0!==o.length&&!o.hasClass("dynamic-title")&&!n.is(":hidden")){const s=n.text().trim();let a=o.text().trim(),l=!1,r=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),o.offset().top<$(window).scrollTop()&&n.text(a);let e=new IntersectionObserver(e=>{var t,o;l?(t=$(window).scrollTop(),o=r<t,r=t,e=e[0],o?0===e.intersectionRatio&&n.text(a):1===e.intersectionRatio&&n.text(s)):l=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]});e.observe(document.querySelector(t)),n.click(function(){$("body,html").animate({scrollTop:0},800)})}}),$(function(){let o=$(".timeago").length,e=void 0;const l=$("meta[name=day-prompt]").attr("content"),r=$("meta[name=hour-prompt]").attr("content"),n=$("meta[name=minute-prompt]").attr("content"),s=$("meta[name=justnow-prompt]").attr("content");function t(){return $(".timeago").each(function(){var e,t;!1!==$(this)[0].hasAttribute("date")?(t=function(e,t){let o=new Date,a=new Date(e);return a.getFullYear()!==o.getFullYear()||a.getMonth()!==o.getMonth()?t:(e=Math.floor((o-a)/1e3),1<=(t=Math.floor(e/86400))?` ${t} `+l:1<=(t=Math.floor(e/3600))?` ${t} `+r:1<=(e=Math.floor(e/60))?` ${e} `+n:s)}($(this).attr("date"),e=$(this).text()))===e?$(this).removeAttr("date"):$(this).text(t):--o}),0===o&&void 0!==e&&clearInterval(e),o}0!==o&&0<t()&&(e=setInterval(t,6e4))}); \ No newline at end of file diff --git a/assets/js/dist/page.min.js b/assets/js/dist/page.min.js index 5f041d0..b012afc 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"),s=$("#main"),l=$("#topbar-title"),r=$("#search-wrapper"),n=$("#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"),l.addClass("unloaded"),e.addClass("unloaded"),r.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),r.removeClass("d-flex"),t.removeClass("unloaded"),l.removeClass("unloaded"),e.removeClass("unloaded")}},f=function(){let t=!1;return{on(){t||(u.block(),n.removeClass("unloaded"),s.addClass("unloaded"),t=!0)},off(){t&&(i.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),n.addClass("unloaded"),a.removeClass("visible"),s.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(){r.addClass("input-focus")}),c.focusout(function(){r.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"),e=$("#topbar-title"),a=$("#panel-wrapper"),s=$("#search-input"),l="topbar-up",r="topbar-down",n="toc-scrolling-up";let i,c=0;const d=o.outerHeight(),u=o.outerHeight();$(window).scroll(function(t){e.is(":hidden")&&(i=!0)}),setInterval(function(){i&&(function(){var t,e=$(this).scrollTop();Math.abs(c-e)<=d||(e>c?e>u&&(o.removeClass(r).addClass(l),a.removeClass(r),s.is(":focus")&&s.blur()):e+$(window).height()<$(document).height()&&(void 0!==(t=o.attr(n))?"false"===t&&o.removeAttr(n):(o.removeClass(l).addClass(r),a.addClass(r))),c=e)}(),i=!1)},250)}),$(function(){var e="div.post>h1:first-of-type";const o=$(e),r=$("#topbar-title");if(0!==o.length&&!o.hasClass("dynamic-title")&&!r.is(":hidden")){const n=r.text().trim();let a=o.text().trim(),s=!1,l=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim());let t=new IntersectionObserver(t=>{var e,o;s?(e=$(window).scrollTop(),o=l<e,l=e,t=t[0],o?0===t.intersectionRatio&&r.text(a):1===t.intersectionRatio&&r.text(n)):s=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]});t.observe(document.querySelector(e)),r.click(function(){$("body,html").animate({scrollTop:0},800)})}}),$(function(){$("input[type=checkbox]").addClass("unloaded"),$("input[type=checkbox][checked]").before('<i class="fas fa-check-circle checked"></i>'),$("input[type=checkbox]:not([checked])").before('<i class="far fa-circle"></i>')}),$(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(`<a href="${o}" title="${e}" class="popup"></a>`)}),$(".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 s(t){if($(t)[0].hasAttribute(e)){t=$(t).attr(e);if(Number(t)>Date.now())return 1}}function l(t){$(t).attr(e,Date.now()+2e3)}function r(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;s(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"),l(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),r(e)},2e3))}),$("#copy-link").click(t=>{let e=$(t.target);if(!s(e)){t=window.location.href;const o=$("<input>");$("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"),l(e),setTimeout(()=>{e.attr("data-original-title",a),r(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(s){if(this.pathname.replace(/^\//,"")===location.pathname.replace(/^\//,"")&&location.hostname===this.hostname){const n=decodeURI(this.hash);let e=RegExp(/^#fnref:/).test(n),o=!e&&RegExp(/^#fn:/).test(n);var l=n.includes(":")?n.replace(/\:/g,"\\:"):n;let a=$(l);var r=$(this).parent().prop("tagName"),l=RegExp(/^H\d/).test(r),r=!t.is(":hidden");if(void 0!==a){s.preventDefault(),history.pushState&&history.pushState(null,null,n);s=l?$(this).offset().top:$(window).scrollTop();let t=a.offset().top-=8;t<s?(l||o||r||(i.removeClass("topbar-down").addClass("topbar-up"),i.attr(d,!0),p+=1),(l||e)&&r&&(t-=c)):r&&(t-=c),$("html").animate({scrollTop:t},500,()=>(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(e=>{const t=$(e.target);let o=t.prop("tagName")==="button".toUpperCase()?t:t.parent();o.blur(),flipMode()})});const ScrollHelper=function(){const e=$("body"),t="topbar-visible",o=$("#topbar-wrapper").outerHeight();let l=0,a=!1,r=!1;return{hideTopbar:()=>e.attr(t,!1),showTopbar:()=>e.attr(t,!0),addScrollUpTask:()=>{l+=1,a=a||!0},popScrollUpTask:()=>--l,hasScrollUpTask:()=>0<l,topbarLocked:()=>!0===a,unlockTopbar:()=>a=!1,getTopbarHeight:()=>o,orientationLocked:()=>!0===r,lockOrientation:()=>r=!0,unLockOrientation:()=>r=!1}}();$(function(){const e=$("#sidebar-trigger"),t=$("#search-trigger"),o=$("#search-cancel"),l=$("#search-cleaner"),a=$("#main"),r=$("#topbar-title"),n=$("#search-wrapper"),i=$("#search-result-wrapper"),s=$("#search-results"),c=$("#search-input"),d=$("#search-hints"),p=function(){let e=0;return{block(){e=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(e)},getOffset(){return e}}}(),u={on(){e.addClass("unloaded"),r.addClass("unloaded"),t.addClass("unloaded"),n.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),n.removeClass("d-flex"),e.removeClass("unloaded"),r.removeClass("unloaded"),t.removeClass("unloaded")}},f=function(){let e=!1;return{on(){e||(p.block(),i.removeClass("unloaded"),a.addClass("unloaded"),e=!0)},off(){e&&(s.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),i.addClass("unloaded"),l.removeClass("visible"),a.removeClass("unloaded"),p.release(),c.val(""),e=!1)},isVisible(){return e}}}();function h(){return o.hasClass("loaded")}t.click(function(){u.on(),f.on(),c.focus()}),o.click(function(){u.off(),f.off()}),c.focus(function(){n.addClass("input-focus")}),c.focusout(function(){n.removeClass("input-focus")}),c.on("keyup",function(e){8===e.keyCode&&""===c.val()?h()?d.removeClass("unloaded"):f.off():""!==c.val()&&(f.on(),l.hasClass("visible")||l.addClass("visible"),h()&&d.addClass("unloaded"))}),l.on("click",function(){c.val(""),h()?(d.removeClass("unloaded"),s.empty()):f.off(),c.focus(),l.removeClass("visible")})}),$(function(){var e=function(){const e="sidebar-display";let t=!1;const o=$("body");return{toggle(){!1===t?o.attr(e,""):o.removeAttr(e),t=!t}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const t=$("#search-input"),o=ScrollHelper.getTopbarHeight();let e,l=0;function a(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var e=screen.orientation.type;"landscape-primary"!==e&&"landscape-secondary"!==e||a()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&a()}),$(window).scroll(()=>{e=e||!0}),setInterval(()=>{e&&(function(){var e=$(this).scrollTop();if(!(Math.abs(l-e)<=o)){if(e>l)ScrollHelper.hideTopbar(),t.is(":focus")&&t.blur();else if(e+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}l=e}}(),e=!1)},250)}),$(function(){var t="div.post>h1:first-of-type";const o=$(t),n=$("#topbar-title");if(0!==o.length&&!o.hasClass("dynamic-title")&&!n.is(":hidden")){const i=n.text().trim();let l=o.text().trim(),a=!1,r=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(l)&&(l=l.replace(/[0-9]/g,"").trim()),o.offset().top<$(window).scrollTop()&&n.text(l);let e=new IntersectionObserver(e=>{var t,o;a?(t=$(window).scrollTop(),o=r<t,r=t,e=e[0],o?0===e.intersectionRatio&&n.text(l):1===e.intersectionRatio&&n.text(i)):a=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]});e.observe(document.querySelector(t)),n.click(function(){$("body,html").animate({scrollTop:0},800)})}}),$(function(){$("input[type=checkbox]").addClass("unloaded"),$("input[type=checkbox][checked]").before('<i class="fas fa-check-circle checked"></i>'),$("input[type=checkbox]:not([checked])").before('<i class="far fa-circle"></i>')}),$(function(){var e="#main > div.row:first-child > div:first-child";if(!($(e+" img").length<=0)){var t=document.querySelectorAll(e+" img[data-src]");const o=lozad(t);o.observe(),$(e+` p > img[data-src],${e} img[data-src].preview-img`).each(function(){let e=$(this).next();var t="EM"===e.prop("tagName")?e.text():"",o=$(this).attr("data-src");$(this).wrap(`<a href="${o}" title="${t}" class="popup"></a>`)}),$(".popup").magnificPopup({type:"image",closeOnContentClick:!0,showCloseBtn:!1,zoom:{enabled:!0,duration:300,easing:"ease-in-out"}}),$(e+" a").has("img").addClass("img-link")}}),$(function(){var e=".code-header>button";const t="timeout";function a(e){if($(e)[0].hasAttribute(t)){e=$(e).attr(t);if(Number(e)>Date.now())return 1}}function r(e){$(e).attr(t,Date.now()+2e3)}function n(e){$(e).removeAttr(t)}const o=new ClipboardJS(e,{target(e){let t=e.parentNode.nextElementSibling;return t.querySelector("code .rouge-code")}});$(e).tooltip({trigger:"hover",placement:"left"});const l=function(e){let t=$(e).children();return t.attr("class")}(e);o.on("success",e=>{e.clearSelection();const t=e.trigger;var o;a(t)||(function(e){let t=$(e),o=t.children();o.attr("class","fas fa-check")}(t),o=t,e=$(o).attr("title-succeed"),$(o).attr("data-original-title",e).tooltip("show"),r(t),setTimeout(()=>{var e;e=t,$(e).tooltip("hide").removeAttr("data-original-title"),function(e){let t=$(e),o=t.children();o.attr("class",l)}(t),n(t)},2e3))}),$("#copy-link").click(e=>{let t=$(e.target);if(!a(t)){e=window.location.href;const o=$("<input>");$("body").append(o),o.val(e).select(),document.execCommand("copy"),o.remove();const l=t.attr("data-original-title");e=t.attr("title-succeed");t.attr("data-original-title",e).tooltip("show"),r(t),setTimeout(()=>{t.attr("data-original-title",l),n(t)},2e3)}})}),$(function(){const e=$("#topbar-title"),s="scroll-focus";$("a[href*='#']").not("[href='#']").not("[href='#0']").click(function(a){if(this.pathname.replace(/^\//,"")===location.pathname.replace(/^\//,"")&&location.hostname===this.hostname){const i=decodeURI(this.hash);let t=RegExp(/^#fnref:/).test(i),o=!t&&RegExp(/^#fn:/).test(i);var r=i.includes(":")?i.replace(/\:/g,"\\:"):i;let l=$(r);var n=e.is(":visible"),r=$(window).width()<$(window).height();if(void 0!==l){a.preventDefault(),history.pushState&&history.pushState(null,null,i);a=$(window).scrollTop();let e=l.offset().top-=8;e<a&&(ScrollHelper.hideTopbar(),ScrollHelper.addScrollUpTask()),n&&r&&(e-=ScrollHelper.getTopbarHeight()),$("html").animate({scrollTop:e},500,()=>(l.focus(),$(`[${s}=true]`).length&&$(`[${s}=true]`).attr(s,!1),$(":target").length&&$(":target").attr(s,!1),(o||t)&&l.attr(s,!0),l.is(":focus")?!1:(l.attr("tabindex","-1"),l.focus(),void(ScrollHelper.hasScrollUpTask()&&ScrollHelper.popScrollUpTask()))))}}})}); \ No newline at end of file diff --git a/assets/js/dist/post.min.js b/assets/js/dist/post.min.js index 7353d90..67e97ec 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"),e=$("#topbar-title"),a=$("#panel-wrapper"),n=$("#search-input"),r="topbar-up",l="topbar-down",s="toc-scrolling-up";let i,c=0;const d=o.outerHeight(),u=o.outerHeight();$(window).scroll(function(t){e.is(":hidden")&&(i=!0)}),setInterval(function(){i&&(function(){var t,e=$(this).scrollTop();Math.abs(c-e)<=d||(e>c?e>u&&(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))),c=e)}(),i=!1)},250)}),$(function(){var e="div.post>h1:first-of-type";const o=$(e),l=$("#topbar-title");if(0!==o.length&&!o.hasClass("dynamic-title")&&!l.is(":hidden")){const s=l.text().trim();let a=o.text().trim(),n=!1,r=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim());let t=new IntersectionObserver(t=>{var e,o;n?(e=$(window).scrollTop(),o=r<e,r=e,t=t[0],o?0===t.intersectionRatio&&l.text(a):1===t.intersectionRatio&&l.text(s)):n=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]});t.observe(document.querySelector(e)),l.click(function(){$("body,html").animate({scrollTop:0},800)})}}),$(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(`<a href="${o}" title="${e}" class="popup"></a>`)}),$(".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<e()&&(t=setInterval(e,6e4))}),$(function(){$("input[type=checkbox]").addClass("unloaded"),$("input[type=checkbox][checked]").before('<i class="fas fa-check-circle checked"></i>'),$("input[type=checkbox]:not([checked])").before('<i class="far fa-circle"></i>')}),$(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=$("<input>");$("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<n?(r||o||l||(i.removeClass("topbar-down").addClass("topbar-up"),i.attr(d,!0),p+=1),(r||e)&&l&&(t-=c)):l&&(t-=c),$("html").animate({scrollTop:t},500,()=>(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()})});const ScrollHelper=function(){const t=$("body"),e="topbar-visible",o=$("#topbar-wrapper").outerHeight();let a=0,r=!1,l=!1;return{hideTopbar:()=>t.attr(e,!1),showTopbar:()=>t.attr(e,!0),addScrollUpTask:()=>{a+=1,r=r||!0},popScrollUpTask:()=>--a,hasScrollUpTask:()=>0<a,topbarLocked:()=>!0===r,unlockTopbar:()=>r=!1,getTopbarHeight:()=>o,orientationLocked:()=>!0===l,lockOrientation:()=>l=!0,unLockOrientation:()=>l=!1}}();$(function(){const t=$("#sidebar-trigger"),e=$("#search-trigger"),o=$("#search-cancel"),a=$("#search-cleaner"),r=$("#main"),l=$("#topbar-title"),n=$("#search-wrapper"),i=$("#search-result-wrapper"),c=$("#search-results"),s=$("#search-input"),d=$("#search-hints"),p=function(){let t=0;return{block(){t=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(t)},getOffset(){return t}}}(),u={on(){t.addClass("unloaded"),l.addClass("unloaded"),e.addClass("unloaded"),n.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),n.removeClass("d-flex"),t.removeClass("unloaded"),l.removeClass("unloaded"),e.removeClass("unloaded")}},h=function(){let t=!1;return{on(){t||(p.block(),i.removeClass("unloaded"),r.addClass("unloaded"),t=!0)},off(){t&&(c.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),i.addClass("unloaded"),a.removeClass("visible"),r.removeClass("unloaded"),p.release(),s.val(""),t=!1)},isVisible(){return t}}}();function f(){return o.hasClass("loaded")}e.click(function(){u.on(),h.on(),s.focus()}),o.click(function(){u.off(),h.off()}),s.focus(function(){n.addClass("input-focus")}),s.focusout(function(){n.removeClass("input-focus")}),s.on("keyup",function(t){8===t.keyCode&&""===s.val()?f()?d.removeClass("unloaded"):h.off():""!==s.val()&&(h.on(),a.hasClass("visible")||a.addClass("visible"),f()&&d.addClass("unloaded"))}),a.on("click",function(){s.val(""),f()?(d.removeClass("unloaded"),c.empty()):h.off(),s.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 e=$("#search-input"),o=ScrollHelper.getTopbarHeight();let t,a=0;function r(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var t=screen.orientation.type;"landscape-primary"!==t&&"landscape-secondary"!==t||r()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&r()}),$(window).scroll(()=>{t=t||!0}),setInterval(()=>{t&&(function(){var t=$(this).scrollTop();if(!(Math.abs(a-t)<=o)){if(t>a)ScrollHelper.hideTopbar(),e.is(":focus")&&e.blur();else if(t+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}a=t}}(),t=!1)},250)}),$(function(){var e="div.post>h1:first-of-type";const o=$(e),n=$("#topbar-title");if(0!==o.length&&!o.hasClass("dynamic-title")&&!n.is(":hidden")){const i=n.text().trim();let a=o.text().trim(),r=!1,l=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),o.offset().top<$(window).scrollTop()&&n.text(a);let t=new IntersectionObserver(t=>{var e,o;r?(e=$(window).scrollTop(),o=l<e,l=e,t=t[0],o?0===t.intersectionRatio&&n.text(a):1===t.intersectionRatio&&n.text(i)):r=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]});t.observe(document.querySelector(e)),n.click(function(){$("body,html").animate({scrollTop:0},800)})}}),$(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(`<a href="${o}" title="${e}" class="popup"></a>`)}),$(".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 r=$("meta[name=day-prompt]").attr("content"),l=$("meta[name=hour-prompt]").attr("content"),n=$("meta[name=minute-prompt]").attr("content"),i=$("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} `+r:1<=(e=Math.floor(t/3600))?` ${e} `+l:1<=(t=Math.floor(t/60))?` ${t} `+n:i)}($(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<e()&&(t=setInterval(e,6e4))}),$(function(){$("input[type=checkbox]").addClass("unloaded"),$("input[type=checkbox][checked]").before('<i class="fas fa-check-circle checked"></i>'),$("input[type=checkbox]:not([checked])").before('<i class="far fa-circle"></i>')}),$(function(){var t=".code-header>button";const e="timeout";function r(t){if($(t)[0].hasAttribute(e)){t=$(t).attr(e);if(Number(t)>Date.now())return 1}}function l(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;r(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"),l(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(!r(e)){t=window.location.href;const o=$("<input>");$("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"),l(e),setTimeout(()=>{e.attr("data-original-title",a),n(e)},2e3)}})}),$(function(){const t=$("#topbar-title"),c="scroll-focus";$("a[href*='#']").not("[href='#']").not("[href='#0']").click(function(r){if(this.pathname.replace(/^\//,"")===location.pathname.replace(/^\//,"")&&location.hostname===this.hostname){const i=decodeURI(this.hash);let e=RegExp(/^#fnref:/).test(i),o=!e&&RegExp(/^#fn:/).test(i);var l=i.includes(":")?i.replace(/\:/g,"\\:"):i;let a=$(l);var n=t.is(":visible"),l=$(window).width()<$(window).height();if(void 0!==a){r.preventDefault(),history.pushState&&history.pushState(null,null,i);r=$(window).scrollTop();let t=a.offset().top-=8;t<r&&(ScrollHelper.hideTopbar(),ScrollHelper.addScrollUpTask()),n&&l&&(t-=ScrollHelper.getTopbarHeight()),$("html").animate({scrollTop:t},500,()=>(a.focus(),$(`[${c}=true]`).length&&$(`[${c}=true]`).attr(c,!1),$(":target").length&&$(":target").attr(c,!1),(o||e)&&a.attr(c,!0),a.is(":focus")?!1:(a.attr("tabindex","-1"),a.focus(),void(ScrollHelper.hasScrollUpTask()&&ScrollHelper.popScrollUpTask()))))}}})}); \ No newline at end of file