From f45b8c98455d4d26c3bec34a82649a4e8b4161ba Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Sun, 19 Jul 2020 23:49:40 +0800 Subject: [PATCH] Some minor fixes --- .github/ISSUE_TEMPLATE/bug-report.md | 4 +-- .github/ISSUE_TEMPLATE/question.md | 2 +- .github/mergeable.yml | 29 --------------------- .github/workflows/lock.yml | 2 +- source/js/next-boot.js | 5 ++-- source/js/utils.js | 39 +++++++++++++--------------- 6 files changed, 24 insertions(+), 57 deletions(-) delete mode 100644 .github/mergeable.yml diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index c6574d6..3f71a37 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -14,7 +14,7 @@ Please follow this Issue template to provide relevant information, such as sourc - [ ] I am using [the latest](https://github.com/next-theme/hexo-theme-next/releases/latest) version of NexT. -- [ ] I have already read the [Troubleshooting page of Hexo](https://hexo.io/docs/troubleshooting) & [Troubleshooting page of NexT](https://theme-next.js.org/docs/troubleshooting.html). +- [ ] I have already read the [Troubleshooting page of Hexo](https://hexo.io/docs/troubleshooting) and [Troubleshooting page of NexT](https://theme-next.js.org/docs/troubleshooting.html). - [ ] I have already searched for current [issues](https://github.com/next-theme/hexo-theme-next/issues), which does not help me. *** @@ -45,7 +45,7 @@ Please follow this Issue template to provide relevant information, such as sourc ``` ### Package dependencies Information - + ``` ``` diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md index 45297f2..af6674c 100644 --- a/.github/ISSUE_TEMPLATE/question.md +++ b/.github/ISSUE_TEMPLATE/question.md @@ -45,7 +45,7 @@ Please follow this Issue template to provide relevant information, such as sourc ``` ### Package dependencies Information - + ``` ``` diff --git a/.github/mergeable.yml b/.github/mergeable.yml deleted file mode 100644 index 73e9c42..0000000 --- a/.github/mergeable.yml +++ /dev/null @@ -1,29 +0,0 @@ -# Configuration for Mergeable - https://github.com/jusx/mergeable - -version: 2 -mergeable: - - when: pull_request.* - validate: - - do: description - no_empty: - enabled: false - - - do: title - must_exclude: - regex: ^\[WIP\] - - - do: label - must_include: - regex: 'change|feat|imp|fix|doc|i18n' - must_exclude: - regex: 'wip|work in progress' - - #- do: project - # no_empty: - # enabled: true - # must_include: - # regex: 'change|feat|imp|fix|doc|loc' - - - do: milestone - no_empty: - enabled: true diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index 8d8b463..08e85f1 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -1,5 +1,5 @@ # Configuration for Lock Threads - https://github.com/dessant/lock-threads -name: 'Lock threads' +name: Lock Threads on: schedule: diff --git a/source/js/next-boot.js b/source/js/next-boot.js index 99dd5da..8760529 100644 --- a/source/js/next-boot.js +++ b/source/js/next-boot.js @@ -45,9 +45,8 @@ NexT.boot.registerEvents = function() { const duration = 200; document.querySelectorAll('.sidebar-nav li').forEach((element, index) => { - element.addEventListener('click', event => { - const item = event.currentTarget; - if (item.matches('.sidebar-toc-active .sidebar-nav-toc, .sidebar-overview-active .sidebar-nav-overview')) return; + element.addEventListener('click', () => { + if (element.matches('.sidebar-toc-active .sidebar-nav-toc, .sidebar-overview-active .sidebar-nav-overview')) return; const sidebar = document.querySelector('.sidebar-inner'); const panel = document.querySelectorAll('.sidebar-panel'); const activeClassName = ['sidebar-toc-active', 'sidebar-overview-active']; diff --git a/source/js/utils.js b/source/js/utils.js index 4b6be52..c8cb2f4 100644 --- a/source/js/utils.js +++ b/source/js/utils.js @@ -74,9 +74,8 @@ NexT.utils = { if (!CONFIG.copycode) return; element.insertAdjacentHTML('beforeend', '
'); const button = element.querySelector('.copy-btn'); - button.addEventListener('click', event => { - const target = event.currentTarget; - const code = [...target.parentNode.querySelectorAll('.code .line')].map(line => line.innerText).join('\n'); + button.addEventListener('click', () => { + const code = [...button.parentNode.querySelectorAll('.code .line')].map(line => line.innerText).join('\n'); const ta = document.createElement('textarea'); ta.style.top = window.scrollY + 'px'; // Prevent page scrolling ta.style.position = 'absolute'; @@ -88,9 +87,9 @@ NexT.utils = { ta.setSelectionRange(0, code.length); ta.readOnly = false; const result = document.execCommand('copy'); - target.querySelector('i').className = result ? 'fa fa-check-circle fa-fw' : 'fa fa-times-circle fa-fw'; + button.querySelector('i').className = result ? 'fa fa-check-circle fa-fw' : 'fa fa-times-circle fa-fw'; ta.blur(); // For iOS - target.blur(); + button.blur(); document.body.removeChild(ta); }); element.addEventListener('mouseleave', () => { @@ -179,23 +178,21 @@ NexT.utils = { document.querySelectorAll('.tabs ul.nav-tabs .tab').forEach(element => { element.addEventListener('click', event => { event.preventDefault(); - const target = event.currentTarget; // Prevent selected tab to select again. - if (!target.classList.contains('active')) { - // Add & Remove active class on `nav-tabs` & `tab-content`. - [...target.parentNode.children].forEach(element => { - element.classList.toggle('active', element === target); - }); - // https://stackoverflow.com/questions/20306204/using-queryselector-with-ids-that-are-numbers - const tActive = document.getElementById(target.querySelector('a').getAttribute('href').replace('#', '')); - [...tActive.parentNode.children].forEach(element => { - element.classList.toggle('active', element === tActive); - }); - // Trigger event - tActive.dispatchEvent(new Event('tabs:click', { - bubbles: true - })); - } + if (element.classList.contains('active')) return; + // Add & Remove active class on `nav-tabs` & `tab-content`. + element.parentNode.childNodes.forEach(target => { + target.classList.toggle('active', target === element); + }); + // https://stackoverflow.com/questions/20306204/using-queryselector-with-ids-that-are-numbers + const tActive = document.getElementById(element.querySelector('a').getAttribute('href').replace('#', '')); + tActive.parentNode.childNodes.forEach(target => { + target.classList.toggle('active', target === tActive); + }); + // Trigger event + tActive.dispatchEvent(new Event('tabs:click', { + bubbles: true + })); }); });