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 3b5539d..0000000 Binary files a/source/img/icp.png and /dev/null differ 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