From d82f69e83b99ea48e6d91a22aa250191e77fff8f Mon Sep 17 00:00:00 2001 From: Jerry Date: Sun, 13 Dec 2020 17:00:34 +0800 Subject: [PATCH] =?UTF-8?q?label:=203.4.0=20=E7=99=BC=E4=BD=88=20improveme?= =?UTF-8?q?nt:=20js=E5=84=AA=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- source/img/icp.png | Bin 1146 -> 0 bytes source/js/main.js | 8 +++----- source/js/utils.js | 32 ++++++-------------------------- 4 files changed, 10 insertions(+), 32 deletions(-) delete mode 100644 source/img/icp.png diff --git a/package.json b/package.json index 0a26ee2..417a7c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "3.4.0-b6", + "version": "3.4.0", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": { diff --git a/source/img/icp.png b/source/img/icp.png deleted file mode 100644 index 3b5539dfc148e947ef77a5def3eec17005e0ab29..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1146 zcmV-=1cm#FP)xN#0007lP)t-s0002| z_1XUX;PdFJ+^lNes8`soeeu_>`t;4{#(bJ-T;a25pJ-LvtYYN6S?S1L@7aIk!fo8A zS>do}>ce{HwOr$@Q|;b>5}BZkHddH+q#GC&4%jOgX_|m?A@~O=%dlDcFKfX|M}3_uY&R4$N%}k|M!>p z+JgK4-t5_p{`&0GlW+h5cme@t=DJ$lnMKwe7Xbop?#*WD!eZ>kUF5Z0>bzS2(pcue zQRJ{r-=j*}N+{PoAl3p1&j12zc88RYfdBx2k%@No<8$)MZt&D>{?BFY%3=T8Uh2tQ zyN+9vcv|bgSK_i${>4&JHc{!gQ0cHr)sRN=uteI9L+OG((}g|alsngTI5`wJ-Gw#n zaWK|pFuP19?p`C)I3meCAJZ-z$tM&2EDy8?56~73gpZjVK9_QZl&Q3l00@z3evSYe zju$YA#l45qyoaNigmQX(WMB*cU8jv%_{3P) zo>;V*SmLQy^2t`_wpQ1XQ{}u;&8$+ReNyheP+%TV?72@)4o?5rO*R@$RcshYtI`^bGOaM9CZ8!FUHso(M zlVCP!0ygQFG{kE&*IzT9Uogx*E&Prw$yqAZNGkJuDAjZ*(?BN0QY7VIBjQFL(jgkr z3=zKo5y1=##25<600L`sARPbz06KJ1PE!CH2twe-tZ7^O`}z0v^ziKL>*wa=_Wlri&k6?mpm5+@)<(=#4v!Ogz87gYVy?V;= z3wHUQ#g}LJZW1vE3z`J@&(87Ax4W2oHK)-&z!a=m&d+Mgd2c%}FFPNv&i)n!3!tFh z?mGW@`+QDpb6a1W*<DY{Zn;Cbv|b9-;JCQwi& zX?{qFm9_QC<+H4<>cgDZ$N~j9=PpVOYK!!pyriSAVcJ$(cLAUv$6}9!({sXB#U#2; zaLq`F4rgWniSoOp>~L^#w{ZxzwVfyk7Gp3H4tH7@<>VOZ;$ai)C+=6BCE8?S^+(N~5VF7BXug)qdCd#U)Z3yNA0JGS0XlP49c>n+a M07*qoM6N<$f>C-=TmS$7 diff --git a/source/js/main.js b/source/js/main.js index ccac18a..565749c 100644 --- a/source/js/main.js +++ b/source/js/main.js @@ -383,9 +383,7 @@ document.addEventListener('DOMContentLoaded', function () { const contentMath = (docHeight > winHeight) ? (docHeight - winHeight) : (document.documentElement.scrollHeight - winHeight) const scrollPercent = (currentTop - headerHeight) / (contentMath) const scrollPercentRounded = Math.round(scrollPercent * 100) - const percentage = (scrollPercentRounded > 100) ? 100 - : (scrollPercentRounded <= 0) ? 0 - : scrollPercentRounded + const percentage = (scrollPercentRounded > 100) ? 100 : (scrollPercentRounded <= 0) ? 0 : scrollPercentRounded $cardToc.setAttribute('progress-percentage', percentage) } @@ -687,7 +685,7 @@ document.addEventListener('DOMContentLoaded', function () { if (!$tabItem.classList.contains('active')) { const $tabContent = $tabItem.parentNode.nextElementSibling - btf.siblings($tabItem, 'active')[0].classList.remove('active') + btf.siblings($tabItem, '.active')[0].classList.remove('active') $tabItem.classList.add('active') const tabId = $this.getAttribute('data-href').replace('#', '') const childList = [...$tabContent.children] @@ -753,7 +751,7 @@ document.addEventListener('DOMContentLoaded', function () { const addPostOutdateNotice = function () { const data = GLOBAL_CONFIG.noticeOutdate - var diffDay = btf.diffDate(GLOBAL_CONFIG_SITE.postUpdate) + const diffDay = btf.diffDate(GLOBAL_CONFIG_SITE.postUpdate) if (diffDay >= data.limitDay) { const ele = document.createElement('div') ele.className = 'post-outdate-notice' diff --git a/source/js/utils.js b/source/js/utils.js index a1cdf4c..b53e48a 100644 --- a/source/js/utils.js +++ b/source/js/utils.js @@ -1,4 +1,4 @@ -var btf = { +const btf = { debounce: function (func, wait, immediate) { let timeout return function () { @@ -140,7 +140,7 @@ var btf = { return } - var currentPos = window.scrollY || window.screenTop + const currentPos = window.scrollY || window.screenTop if (currentPos > pos) pos = pos - 70 if ('CSS' in window && CSS.supports('scroll-behavior', 'smooth')) { @@ -151,7 +151,7 @@ var btf = { return } - var start = null + let start = null time = time || 500 window.requestAnimationFrame(function step (currentTime) { start = !start ? currentTime : start @@ -188,38 +188,18 @@ var btf = { }, getParents: (elem, selector) => { - // polyfill - if (!Element.prototype.matches) { - Element.prototype.matches = - Element.prototype.matchesSelector || - Element.prototype.mozMatchesSelector || - Element.prototype.msMatchesSelector || - Element.prototype.oMatchesSelector || - Element.prototype.webkitMatchesSelector || - function (s) { - const matches = (this.document || this.ownerDocument).querySelectorAll(s) - let i = matches.length - while (--i >= 0 && matches.item(i) !== this) {} - return i > -1 - } - } - for (; elem && elem !== document; elem = elem.parentNode) { if (elem.matches(selector)) return elem } return null }, - /** - * - * @param {*} ele - * @param {*} selector class name - */ siblings: (ele, selector) => { return [...ele.parentNode.children].filter((child) => { if (selector) { - return child !== ele && child.classList.contains(selector) + return child !== ele && child.matches(selector) } + return child !== ele }) }, @@ -230,7 +210,7 @@ var btf = { * @param {*} id id * @param {*} cn class name */ - wrap: function (selector, eleType, id = null, cn = null) { + wrap: function (selector, eleType, id = '', cn = '') { const creatEle = document.createElement(eleType) if (id) creatEle.id = id if (cn) creatEle.className = cn