Skip to content

Commit

Permalink
Some minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Jun 1, 2020
1 parent 036d2d3 commit 5f6271d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 24 deletions.
5 changes: 1 addition & 4 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,7 @@ valine:
appKey: # Your leancloud application appkey
placeholder: Just go go # Comment box placeholder
avatar: mm # Gravatar style
meta: # Custom comment header
- nick
- mail
- link
meta: [nick, mail, link] # Custom comment header
pageSize: 10 # Pagination size
language: # Language, available values: en, zh-cn
visitor: false # Article reading statistic
Expand Down
6 changes: 2 additions & 4 deletions layout/_partials/comments.njk
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
commentButton.forEach(element => {
let commentClass = element.classList[2];
element.addEventListener('click', () => {
commentButton.forEach(rmActive => rmActive.classList.remove('active'));
element.classList.add('active');
document.querySelectorAll('.comment-position').forEach(rmActive => rmActive.classList.remove('active'));
document.querySelector(`.comment-position.${commentClass}`).classList.add('active');
commentButton.forEach(active => active.classList.toggle('active', active === element));
document.querySelectorAll('.comment-position').forEach(active => active.classList.toggle('active', active.classList.contains(commentClass)));
if (CONFIG.comments.storage) {
localStorage.setItem('comments_active', commentClass);
}
Expand Down
4 changes: 1 addition & 3 deletions scripts/tags/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ function postButton(args) {
icon = icon.startsWith('fa') ? icon : 'fa fa-' + icon;
title = title.trim();

return `<a class="btn" href="${url}"${title.length > 0 ? ` title="${title}"` : ''}>
${icon.length > 0 ? `<i class="${icon}"></i>` : ''}${text}
</a>`;
return `<a class="btn" href="${url}"${title.length > 0 ? ` title="${title}"` : ''}>${icon.length > 0 ? `<i class="${icon}"></i>` : ''}${text}</a>`;
}

hexo.extend.tag.register('button', postButton, {ends: false});
Expand Down
5 changes: 2 additions & 3 deletions source/js/next-boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ NexT.boot.registerEvents = function() {
NexT.utils.registerCanIUseTag();

// Mobile top menu bar.
document.querySelector('.site-nav-toggle .toggle').addEventListener('click', () => {
document.querySelector('.site-nav-toggle .toggle').addEventListener('click', event => {
event.currentTarget.classList.toggle('toggle-close');
const siteNav = document.querySelector('.site-nav');
if (!siteNav) return;
Expand Down Expand Up @@ -57,9 +57,8 @@ NexT.boot.registerEvents = function() {
});

[...item.parentNode.children].forEach(element => {
element.classList.remove(activeTabClassName);
element.classList.toggle(activeTabClassName, element === item);
});
item.classList.add(activeTabClassName);
});
});

Expand Down
18 changes: 8 additions & 10 deletions source/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ NexT.utils = {
}
document.body.removeChild(ta);
});
button.addEventListener('mouseleave', event => {
element.addEventListener('mouseleave', () => {
setTimeout(() => {
event.target.querySelector('i').className = 'fa fa-clipboard fa-fw';
button.querySelector('i').className = 'fa fa-clipboard fa-fw';
}, 300);
});
});
Expand Down Expand Up @@ -131,7 +131,7 @@ NexT.utils = {
let width = Number(element.width);
let height = Number(element.height);
if (width && height) {
element.parentNode.style.paddingTop = (height / width * 100) + '%';
box.style.paddingTop = (height / width * 100) + '%';
}
}
});
Expand Down Expand Up @@ -181,14 +181,12 @@ NexT.utils = {
if (!target.classList.contains('active')) {
// Add & Remove active class on `nav-tabs` & `tab-content`.
[...target.parentNode.children].forEach(element => {
element.classList.remove('active');
element.classList.toggle('active', element === target);
});
target.classList.add('active');
const tActive = document.getElementById(target.querySelector('a').getAttribute('href').replace('#', ''));
const tActive = document.querySelector(target.querySelector('a').getAttribute('href'));
[...tActive.parentNode.children].forEach(element => {
element.classList.remove('active');
element.classList.toggle('active', element === tActive);
});
tActive.classList.add('active');
// Trigger event
tActive.dispatchEvent(new Event('tabs:click', {
bubbles: true
Expand All @@ -203,7 +201,7 @@ NexT.utils = {
registerCanIUseTag: function() {
// Get responsive height passed from iframe.
window.addEventListener('message', ({ data }) => {
if ((typeof data === 'string') && data.includes('ciu_embed')) {
if (typeof data === 'string' && data.includes('ciu_embed')) {
const featureID = data.split(':')[1];
const height = data.split(':')[2];
document.querySelector(`iframe[data-feature=${featureID}]`).style.height = parseInt(height, 10) + 5 + 'px';
Expand Down Expand Up @@ -237,7 +235,7 @@ NexT.utils = {
const navItems = document.querySelectorAll('.post-toc li');
const sections = [...navItems].map(element => {
const link = element.querySelector('a.nav-link');
const target = document.getElementById(decodeURI(link.getAttribute('href')).replace('#', ''));
const target = document.querySelector(decodeURI(link.getAttribute('href')));
// TOC item animation navigate.
link.addEventListener('click', event => {
event.preventDefault();
Expand Down

0 comments on commit 5f6271d

Please sign in to comment.