From 4a69c623fc5d205ca483ebb8faeea239e2eb4d57 Mon Sep 17 00:00:00 2001 From: Jerry Date: Sun, 27 Dec 2020 15:51:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=BE=A9=E9=96=8B=E5=95=9Fgita?= =?UTF-8?q?lk=E8=A9=95=E8=AB=96=E6=95=B8=E5=BE=8C=E8=88=87toc=E8=A1=9D?= =?UTF-8?q?=E7=AA=81=E7=9A=84bug=20close=20#462=20fix:=20=E4=BF=AE?= =?UTF-8?q?=E5=BE=A9jquery=E5=9C=A8=E4=B8=80=E4=BA=9B=E4=BB=8B=E9=9D=A2?= =?UTF-8?q?=E4=BB=8D=E7=84=B6=E8=BC=89=E5=85=A5=E5=95=8F=E9=A1=8C=20fix:?= =?UTF-8?q?=20=E4=BF=AE=E5=BE=A9medium=20zoom=20=E5=A0=B1=E9=8C=AF?= =?UTF-8?q?=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/includes/header/post-info.pug | 2 +- package.json | 2 +- source/js/main.js | 62 ++++++++++++++-------------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/layout/includes/header/post-info.pug b/layout/includes/header/post-info.pug index 96f1e9b..316a506 100644 --- a/layout/includes/header/post-info.pug +++ b/layout/includes/header/post-info.pug @@ -77,7 +77,7 @@ else if whichCount === 'Gitalk' +countBlock a(href=url_for(page.path) + '#post-comment') - span.gitalk-#card-toc + span.gitalk-comment-count else if whichCount === 'Twikoo' +countBlock a(href=url_for(page.path) + '#post-comment') diff --git a/package.json b/package.json index 3039164..11aed36 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "3.4.1", + "version": "3.4.2", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": { diff --git a/source/js/main.js b/source/js/main.js index 15a8081..f32b446 100644 --- a/source/js/main.js +++ b/source/js/main.js @@ -247,40 +247,38 @@ document.addEventListener('DOMContentLoaded', function () { * fancybox和 mediumZoom */ const addFancybox = function (ele) { - if (ele.length) { - const runFancybox = (ele) => { - ele.each(function (i, o) { - const $this = $(o) - const lazyloadSrc = $this.attr('data-lazy-src') || $this.attr('src') - const dataCaption = $this.attr('alt') || '' - $this.wrap(``) - }) + const runFancybox = (ele) => { + ele.each(function (i, o) { + const $this = $(o) + const lazyloadSrc = $this.attr('data-lazy-src') || $this.attr('src') + const dataCaption = $this.attr('alt') || '' + $this.wrap(``) + }) - $().fancybox({ - selector: '[data-fancybox]', - loop: true, - transitionEffect: 'slide', - protect: true, - buttons: ['slideShow', 'fullScreen', 'thumbs', 'close'], - hash: false - }) - } + $().fancybox({ + selector: '[data-fancybox]', + loop: true, + transitionEffect: 'slide', + protect: true, + buttons: ['slideShow', 'fullScreen', 'thumbs', 'close'], + hash: false + }) + } - if (typeof $.fancybox === 'undefined') { - $('head').append(``) - $.getScript(`${GLOBAL_CONFIG.source.fancybox.js}`, function () { - runFancybox($(ele)) - }) - } else { + if (typeof $.fancybox === 'undefined') { + $('head').append(``) + $.getScript(`${GLOBAL_CONFIG.source.fancybox.js}`, function () { runFancybox($(ele)) - } + }) + } else { + runFancybox($(ele)) } } const addMediumZoom = () => { const zoom = mediumZoom(document.querySelectorAll('#article-container :not(a)>img')) zoom.on('open', e => { - const photoBg = $(document.documentElement).attr('data-theme') === 'dark' ? '#121212' : '#fff' + const photoBg = document.documentElement.getAttribute('data-theme') === 'dark' ? '#121212' : '#fff' zoom.update({ background: photoBg }) @@ -288,15 +286,17 @@ document.addEventListener('DOMContentLoaded', function () { } const jqLoadAndRun = () => { - const isFancybox = GLOBAL_CONFIG.lightbox === 'fancybox' - const $fancyboxEle = isFancybox ? document.querySelectorAll('#article-container :not(a):not(.gallery-group) > img, #article-container > img') : null + const $fancyboxEle = GLOBAL_CONFIG.lightbox === 'fancybox' + ? document.querySelectorAll('#article-container :not(a):not(.gallery-group) > img, #article-container > img') + : [] + const fbLengthNoZero = $fancyboxEle.length > 0 const $jgEle = document.querySelectorAll('#article-container .justified-gallery') - const jgEleLength = $jgEle.length + const jgLengthNoZero = $jgEle.length > 0 - if (jgEleLength || $fancyboxEle !== null) { + if (jgLengthNoZero || fbLengthNoZero) { btf.isJqueryLoad(() => { - jgEleLength && runJustifiedGallery($jgEle) - isFancybox && addFancybox($fancyboxEle) + jgLengthNoZero && runJustifiedGallery($jgEle) + fbLengthNoZero && addFancybox($fancyboxEle) }) } }