Some minor fixes

This commit is contained in:
Mimi 2020-07-19 23:49:40 +08:00
parent 9ae16610c1
commit f45b8c9845
6 changed files with 24 additions and 57 deletions

View File

@ -14,7 +14,7 @@ Please follow this Issue template to provide relevant information, such as sourc
<!-- Change [ ] to [x] to select (将 [ ] 换成 [x] 来选择) --> <!-- Change [ ] to [x] to select (将 [ ] 换成 [x] 来选择) -->
- [ ] I am using [the latest](https://github.com/next-theme/hexo-theme-next/releases/latest) version of NexT. - [ ] 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. - [ ] 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 ### Package dependencies Information
<!-- Paste output from `npm ls --depth 0` (粘贴 `npm ls --depth 0` 输出的信息) --> <!-- Paste output from `npm ls --depth 0` in Hexo root dirctory (粘贴在 Hexo 根目录下 `npm ls --depth 0` 输出的信息) -->
``` ```
``` ```

View File

@ -45,7 +45,7 @@ Please follow this Issue template to provide relevant information, such as sourc
``` ```
### Package dependencies Information ### Package dependencies Information
<!-- Paste output from `npm ls --depth 0` (粘贴 `npm ls --depth 0` 输出的信息) --> <!-- Paste output from `npm ls --depth 0` in Hexo root dirctory (粘贴在 Hexo 根目录下 `npm ls --depth 0` 输出的信息) -->
``` ```
``` ```

29
.github/mergeable.yml vendored
View File

@ -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

View File

@ -1,5 +1,5 @@
# Configuration for Lock Threads - https://github.com/dessant/lock-threads # Configuration for Lock Threads - https://github.com/dessant/lock-threads
name: 'Lock threads' name: Lock Threads
on: on:
schedule: schedule:

View File

@ -45,9 +45,8 @@ NexT.boot.registerEvents = function() {
const duration = 200; const duration = 200;
document.querySelectorAll('.sidebar-nav li').forEach((element, index) => { document.querySelectorAll('.sidebar-nav li').forEach((element, index) => {
element.addEventListener('click', event => { element.addEventListener('click', () => {
const item = event.currentTarget; if (element.matches('.sidebar-toc-active .sidebar-nav-toc, .sidebar-overview-active .sidebar-nav-overview')) return;
if (item.matches('.sidebar-toc-active .sidebar-nav-toc, .sidebar-overview-active .sidebar-nav-overview')) return;
const sidebar = document.querySelector('.sidebar-inner'); const sidebar = document.querySelector('.sidebar-inner');
const panel = document.querySelectorAll('.sidebar-panel'); const panel = document.querySelectorAll('.sidebar-panel');
const activeClassName = ['sidebar-toc-active', 'sidebar-overview-active']; const activeClassName = ['sidebar-toc-active', 'sidebar-overview-active'];

View File

@ -74,9 +74,8 @@ NexT.utils = {
if (!CONFIG.copycode) return; if (!CONFIG.copycode) return;
element.insertAdjacentHTML('beforeend', '<div class="copy-btn"><i class="fa fa-clipboard fa-fw"></i></div>'); element.insertAdjacentHTML('beforeend', '<div class="copy-btn"><i class="fa fa-clipboard fa-fw"></i></div>');
const button = element.querySelector('.copy-btn'); const button = element.querySelector('.copy-btn');
button.addEventListener('click', event => { button.addEventListener('click', () => {
const target = event.currentTarget; const code = [...button.parentNode.querySelectorAll('.code .line')].map(line => line.innerText).join('\n');
const code = [...target.parentNode.querySelectorAll('.code .line')].map(line => line.innerText).join('\n');
const ta = document.createElement('textarea'); const ta = document.createElement('textarea');
ta.style.top = window.scrollY + 'px'; // Prevent page scrolling ta.style.top = window.scrollY + 'px'; // Prevent page scrolling
ta.style.position = 'absolute'; ta.style.position = 'absolute';
@ -88,9 +87,9 @@ NexT.utils = {
ta.setSelectionRange(0, code.length); ta.setSelectionRange(0, code.length);
ta.readOnly = false; ta.readOnly = false;
const result = document.execCommand('copy'); 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 ta.blur(); // For iOS
target.blur(); button.blur();
document.body.removeChild(ta); document.body.removeChild(ta);
}); });
element.addEventListener('mouseleave', () => { element.addEventListener('mouseleave', () => {
@ -179,23 +178,21 @@ NexT.utils = {
document.querySelectorAll('.tabs ul.nav-tabs .tab').forEach(element => { document.querySelectorAll('.tabs ul.nav-tabs .tab').forEach(element => {
element.addEventListener('click', event => { element.addEventListener('click', event => {
event.preventDefault(); event.preventDefault();
const target = event.currentTarget;
// Prevent selected tab to select again. // Prevent selected tab to select again.
if (!target.classList.contains('active')) { if (element.classList.contains('active')) return;
// Add & Remove active class on `nav-tabs` & `tab-content`. // Add & Remove active class on `nav-tabs` & `tab-content`.
[...target.parentNode.children].forEach(element => { element.parentNode.childNodes.forEach(target => {
element.classList.toggle('active', element === target); target.classList.toggle('active', target === element);
}); });
// https://stackoverflow.com/questions/20306204/using-queryselector-with-ids-that-are-numbers // https://stackoverflow.com/questions/20306204/using-queryselector-with-ids-that-are-numbers
const tActive = document.getElementById(target.querySelector('a').getAttribute('href').replace('#', '')); const tActive = document.getElementById(element.querySelector('a').getAttribute('href').replace('#', ''));
[...tActive.parentNode.children].forEach(element => { tActive.parentNode.childNodes.forEach(target => {
element.classList.toggle('active', element === tActive); target.classList.toggle('active', target === tActive);
}); });
// Trigger event // Trigger event
tActive.dispatchEvent(new Event('tabs:click', { tActive.dispatchEvent(new Event('tabs:click', {
bubbles: true bubbles: true
})); }));
}
}); });
}); });