From b7cc22983f6e2ecf27e268314d3a168ac4580af5 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Sun, 31 Oct 2021 22:56:22 +0800 Subject: [PATCH] Prevent multiple reserse-footnote from overlapping (fix #439) --- _javascript/utils/smooth-scroll.js | 4 ++-- _sass/addon/commons.scss | 6 +++--- assets/js/dist/post.min.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/_javascript/utils/smooth-scroll.js b/_javascript/utils/smooth-scroll.js index 57adac2..cb90803 100644 --- a/_javascript/utils/smooth-scroll.js +++ b/_javascript/utils/smooth-scroll.js @@ -20,8 +20,8 @@ $(function() { const hash = decodeURI(this.hash); let isFnRef = RegExp(/^#fnref:/).test(hash); - let isFn = RegExp(/^#fn:/).test(hash); - let selector = hash.includes(":") ? hash.replace(/\:/, "\\:") : hash; + let isFn = isFnRef? false : RegExp(/^#fn:/).test(hash); + let selector = hash.includes(":") ? hash.replace(/\:/g, "\\:") : hash; let target = $(selector); if (target.length) { diff --git a/_sass/addon/commons.scss b/_sass/addon/commons.scss index c75712e..c42eb6d 100644 --- a/_sass/addon/commons.scss +++ b/_sass/addon/commons.scss @@ -319,10 +319,10 @@ footer { .reversefootnote { @at-root a#{&} { font-size: 0.6rem; - position: absolute; line-height: 1; - padding-top: 0.5em; - margin-left: 0.5em; + position: relative; + bottom: 0.25em; + margin-left: 0.25em; border-bottom-style: none !important; } } diff --git a/assets/js/dist/post.min.js b/assets/js/dist/post.min.js index fe883f5..145c454 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(()=>{$(this).scrollTop()>50&&"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(){const t=$("#sidebar-trigger"),e=$("#search-trigger"),o=$("#search-cancel"),a=$("#search-cleaner"),n=$("#main"),l=$("#topbar-title"),s=$("#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:()=>t}}(),f={on(){t.addClass("unloaded"),l.addClass("unloaded"),e.addClass("unloaded"),s.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),s.removeClass("d-flex"),t.removeClass("unloaded"),l.removeClass("unloaded"),e.removeClass("unloaded")}},h=function(){let t=!1;return{on(){t||(u.block(),r.removeClass("unloaded"),n.addClass("unloaded"),t=!0)},off(){t&&(i.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),r.addClass("unloaded"),a.removeClass("visible"),n.removeClass("unloaded"),u.release(),c.val(""),t=!1)},isVisible:()=>t}}();function p(){return o.hasClass("loaded")}e.click(function(){f.on(),h.on(),c.focus()}),o.click(function(){f.off(),h.off()}),c.focus(function(){s.addClass("input-focus")}),c.focusout(function(){s.removeClass("input-focus")}),c.on("keyup",function(t){8===t.keyCode&&""===c.val()?p()?d.removeClass("unloaded"):h.off():""!==c.val()&&(h.on(),a.hasClass("visible")||a.addClass("visible"),p()&&d.addClass("unloaded"))}),a.on("click",function(){c.val(""),p()?(d.removeClass("unloaded"),i.empty()):h.off(),c.focus(),a.removeClass("visible")})}),$(function(){const t=function(){let t=!1;const e=$("body");return{toggle(){!1===t?e.attr("sidebar-display",""):e.removeAttr("sidebar-display"),t=!t}}}();$("#sidebar-trigger").click(t.toggle),$("#mask").click(t.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const t=$("#topbar-wrapper"),e=$("#toc-wrapper"),o=$(".access"),a=$("#search-input");let n,l=0;const s=5,r=t.outerHeight();$(window).scroll(function(t){$("#topbar-title").is(":hidden")&&(n=!0)}),setInterval(function(){n&&(!function(){var n=$(this).scrollTop();Math.abs(l-n)<=s||(n>l&&n>r?(t.removeClass("topbar-down").addClass("topbar-up"),e.length>0&&e.removeClass("topbar-down"),o.length>0&&o.removeClass("topbar-down"),a.is(":focus")&&a.blur()):n+$(window).height()<$(document).height()&&(t.removeClass("topbar-up").addClass("topbar-down"),e.length>0&&e.addClass("topbar-down"),o.length>0&&o.addClass("topbar-down")),l=n)}(),n=!1)},250)}),$(function(){const t=$("#topbar-title"),e=$("div.post>h1"),o=t.text().trim();let a=e.length>0?e.text().trim():$("h1").text().trim();($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),$(window).scroll(function(){if($("#post-list").length||e.is(":hidden")||t.is(":hidden")||$("#sidebar.sidebar-expand").length)return!1;$(this).scrollTop()>=95?t.text()!==a&&t.text(a):t.text()!==o&&t.text(o)}),t.click(function(){$("body,html").animate({scrollTop:0},800)})}),$(function(){const t="#main > div.row:first-child > div:first-child";if($(`${t} img`).length<=0)return;const e=document.querySelectorAll(`${t} img[data-src]`);lozad(e).observe(),$(`${t} p > img[data-src],${t} img[data-src].preview-img`).each(function(){let t=$(this).next();const 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 t=$(".timeago").length,e=void 0;const o=$("meta[name=day-prompt]").attr("content"),a=$("meta[name=hour-prompt]").attr("content"),n=$("meta[name=minute-prompt]").attr("content"),l=$("meta[name=justnow-prompt]").attr("content");function s(){return $(".timeago").each(function(){if($(this).children("i").length>0){let e=$(this).clone().children().remove().end().text(),s=$(this).children("i"),r=s.text();$(this).text(function(e,s){let r=new Date,i=new Date(e);if(i.getFullYear()!==r.getFullYear()||i.getMonth()!==r.getMonth())return s;let c=Math.floor((r-i)/1e3),d=Math.floor(c/86400);if(d>=1)return t-=1,` ${d} ${o}`;let u=Math.floor(c/3600);if(u>=1)return` ${u} ${a}`;let $=Math.floor(c/60);return $>=1?` ${$} ${n}`:l}(r,e)),$(this).append(s)}}),0===t&&void 0!==e&&clearInterval(e),t}0!==t&&s()>0&&(e=setInterval(s,6e4))}),$(function(){$("input[type=checkbox]").addClass("unloaded"),$("input[type=checkbox][checked]").before(''),$("input[type=checkbox]:not([checked])").before('')}),$(function(){const t="fas fa-check",e="timeout",o=2e3;function a(t){if($(t)[0].hasAttribute(e)){let o=$(t).attr(e);if(Number(o)>Date.now())return!0}return!1}function n(t){$(t).attr(e,Date.now()+o)}function l(t){$(t).removeAttr(e)}const s=new ClipboardJS(".code-header>button",{target:t=>t.parentNode.nextElementSibling.querySelector("code .rouge-code")});$(".code-header>button").tooltip({trigger:"hover",placement:"left"});const r=$(".code-header>button").children().attr("class");s.on("success",e=>{e.clearSelection();const s=e.trigger;a(s)||(!function(e){$(e).children().attr("class",t)}(s),function(t){const e=$(t).attr("title-succeed");$(t).attr("data-original-title",e).tooltip("show")}(s),n(s),setTimeout(()=>{!function(t){$(t).tooltip("hide").removeAttr("data-original-title")}(s),function(t){$(t).children().attr("class",r)}(s),l(s)},o))}),$("#copy-link").click(t=>{let e=$(t.target);if(a(e))return;const s=window.location.href,r=$("");$("body").append(r),r.val(s).select(),document.execCommand("copy"),r.remove();const i=e.attr("data-original-title"),c=e.attr("title-succeed");e.attr("data-original-title",c).tooltip("show"),n(e),setTimeout(()=>{e.attr("data-original-title",i),l(e)},o)})}),$(function(){$("a[href*='#']").not("[href='#']").not("[href='#0']").click(function(t){if(this.pathname.replace(/^\//,"")===location.pathname.replace(/^\//,"")&&location.hostname===this.hostname){const e=16,o=decodeURI(this.hash);let a=RegExp(/^#fnref:/).test(o),n=RegExp(/^#fn:/).test(o),l=o.includes(":")?o.replace(/\:/,"\\:"):o,s=$(l);if(s.length){t.preventDefault(),history.pushState&&history.pushState(null,null,o);let l=$(this).offset().top,r=s.offset().top;const i=r{const t=$(s);t.focus();if($("[scroll-focus=true]").length&&$("[scroll-focus=true]").attr("scroll-focus",!1),$(":target").length&&$(":target").attr("scroll-focus",!1),(n||a)&&t.attr("scroll-focus",!0),t.is(":focus"))return!1;t.attr("tabindex","-1"),t.focus()})}}})}); \ No newline at end of file +$(function(){$(window).scroll(()=>{$(this).scrollTop()>50&&"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(){const t=$("#sidebar-trigger"),e=$("#search-trigger"),o=$("#search-cancel"),a=$("#search-cleaner"),n=$("#main"),l=$("#topbar-title"),s=$("#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:()=>t}}(),f={on(){t.addClass("unloaded"),l.addClass("unloaded"),e.addClass("unloaded"),s.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),s.removeClass("d-flex"),t.removeClass("unloaded"),l.removeClass("unloaded"),e.removeClass("unloaded")}},h=function(){let t=!1;return{on(){t||(u.block(),r.removeClass("unloaded"),n.addClass("unloaded"),t=!0)},off(){t&&(i.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),r.addClass("unloaded"),a.removeClass("visible"),n.removeClass("unloaded"),u.release(),c.val(""),t=!1)},isVisible:()=>t}}();function p(){return o.hasClass("loaded")}e.click(function(){f.on(),h.on(),c.focus()}),o.click(function(){f.off(),h.off()}),c.focus(function(){s.addClass("input-focus")}),c.focusout(function(){s.removeClass("input-focus")}),c.on("keyup",function(t){8===t.keyCode&&""===c.val()?p()?d.removeClass("unloaded"):h.off():""!==c.val()&&(h.on(),a.hasClass("visible")||a.addClass("visible"),p()&&d.addClass("unloaded"))}),a.on("click",function(){c.val(""),p()?(d.removeClass("unloaded"),i.empty()):h.off(),c.focus(),a.removeClass("visible")})}),$(function(){const t=function(){let t=!1;const e=$("body");return{toggle(){!1===t?e.attr("sidebar-display",""):e.removeAttr("sidebar-display"),t=!t}}}();$("#sidebar-trigger").click(t.toggle),$("#mask").click(t.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const t=$("#topbar-wrapper"),e=$("#toc-wrapper"),o=$(".access"),a=$("#search-input");let n,l=0;const s=5,r=t.outerHeight();$(window).scroll(function(t){$("#topbar-title").is(":hidden")&&(n=!0)}),setInterval(function(){n&&(!function(){var n=$(this).scrollTop();Math.abs(l-n)<=s||(n>l&&n>r?(t.removeClass("topbar-down").addClass("topbar-up"),e.length>0&&e.removeClass("topbar-down"),o.length>0&&o.removeClass("topbar-down"),a.is(":focus")&&a.blur()):n+$(window).height()<$(document).height()&&(t.removeClass("topbar-up").addClass("topbar-down"),e.length>0&&e.addClass("topbar-down"),o.length>0&&o.addClass("topbar-down")),l=n)}(),n=!1)},250)}),$(function(){const t=$("#topbar-title"),e=$("div.post>h1"),o=t.text().trim();let a=e.length>0?e.text().trim():$("h1").text().trim();($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),$(window).scroll(function(){if($("#post-list").length||e.is(":hidden")||t.is(":hidden")||$("#sidebar.sidebar-expand").length)return!1;$(this).scrollTop()>=95?t.text()!==a&&t.text(a):t.text()!==o&&t.text(o)}),t.click(function(){$("body,html").animate({scrollTop:0},800)})}),$(function(){const t="#main > div.row:first-child > div:first-child";if($(`${t} img`).length<=0)return;const e=document.querySelectorAll(`${t} img[data-src]`);lozad(e).observe(),$(`${t} p > img[data-src],${t} img[data-src].preview-img`).each(function(){let t=$(this).next();const 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 t=$(".timeago").length,e=void 0;const o=$("meta[name=day-prompt]").attr("content"),a=$("meta[name=hour-prompt]").attr("content"),n=$("meta[name=minute-prompt]").attr("content"),l=$("meta[name=justnow-prompt]").attr("content");function s(){return $(".timeago").each(function(){if($(this).children("i").length>0){let e=$(this).clone().children().remove().end().text(),s=$(this).children("i"),r=s.text();$(this).text(function(e,s){let r=new Date,i=new Date(e);if(i.getFullYear()!==r.getFullYear()||i.getMonth()!==r.getMonth())return s;let c=Math.floor((r-i)/1e3),d=Math.floor(c/86400);if(d>=1)return t-=1,` ${d} ${o}`;let u=Math.floor(c/3600);if(u>=1)return` ${u} ${a}`;let $=Math.floor(c/60);return $>=1?` ${$} ${n}`:l}(r,e)),$(this).append(s)}}),0===t&&void 0!==e&&clearInterval(e),t}0!==t&&s()>0&&(e=setInterval(s,6e4))}),$(function(){$("input[type=checkbox]").addClass("unloaded"),$("input[type=checkbox][checked]").before(''),$("input[type=checkbox]:not([checked])").before('')}),$(function(){const t="fas fa-check",e="timeout",o=2e3;function a(t){if($(t)[0].hasAttribute(e)){let o=$(t).attr(e);if(Number(o)>Date.now())return!0}return!1}function n(t){$(t).attr(e,Date.now()+o)}function l(t){$(t).removeAttr(e)}const s=new ClipboardJS(".code-header>button",{target:t=>t.parentNode.nextElementSibling.querySelector("code .rouge-code")});$(".code-header>button").tooltip({trigger:"hover",placement:"left"});const r=$(".code-header>button").children().attr("class");s.on("success",e=>{e.clearSelection();const s=e.trigger;a(s)||(!function(e){$(e).children().attr("class",t)}(s),function(t){const e=$(t).attr("title-succeed");$(t).attr("data-original-title",e).tooltip("show")}(s),n(s),setTimeout(()=>{!function(t){$(t).tooltip("hide").removeAttr("data-original-title")}(s),function(t){$(t).children().attr("class",r)}(s),l(s)},o))}),$("#copy-link").click(t=>{let e=$(t.target);if(a(e))return;const s=window.location.href,r=$("");$("body").append(r),r.val(s).select(),document.execCommand("copy"),r.remove();const i=e.attr("data-original-title"),c=e.attr("title-succeed");e.attr("data-original-title",c).tooltip("show"),n(e),setTimeout(()=>{e.attr("data-original-title",i),l(e)},o)})}),$(function(){$("a[href*='#']").not("[href='#']").not("[href='#0']").click(function(t){if(this.pathname.replace(/^\//,"")===location.pathname.replace(/^\//,"")&&location.hostname===this.hostname){const e=16,o=decodeURI(this.hash);let a=RegExp(/^#fnref:/).test(o),n=!a&&RegExp(/^#fn:/).test(o),l=o.includes(":")?o.replace(/\:/g,"\\:"):o,s=$(l);if(s.length){t.preventDefault(),history.pushState&&history.pushState(null,null,o);let l=$(this).offset().top,r=s.offset().top;const i=r{const t=$(s);t.focus();if($("[scroll-focus=true]").length&&$("[scroll-focus=true]").attr("scroll-focus",!1),$(":target").length&&$(":target").attr("scroll-focus",!1),(n||a)&&t.attr("scroll-focus",!0),t.is(":focus"))return!1;t.attr("tabindex","-1"),t.focus()})}}})}); \ No newline at end of file