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] 来选择) -->
- [ ] 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
<!-- 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
<!-- 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
name: 'Lock threads'
name: Lock Threads
on:
schedule:

View File

@ -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'];

View File

@ -74,9 +74,8 @@ NexT.utils = {
if (!CONFIG.copycode) return;
element.insertAdjacentHTML('beforeend', '<div class="copy-btn"><i class="fa fa-clipboard fa-fw"></i></div>');
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')) {
if (element.classList.contains('active')) return;
// Add & Remove active class on `nav-tabs` & `tab-content`.
[...target.parentNode.children].forEach(element => {
element.classList.toggle('active', element === target);
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(target.querySelector('a').getAttribute('href').replace('#', ''));
[...tActive.parentNode.children].forEach(element => {
element.classList.toggle('active', element === tActive);
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
}));
}
});
});