mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-17 18:22:33 +00:00
Run lebab
This commit is contained in:
parent
17502dacf4
commit
74fa9ecc05
@ -8,8 +8,8 @@
|
||||
|
||||
function caniUse(args) {
|
||||
args = args.join('').split('@');
|
||||
var feature = args[0];
|
||||
var periods = args[1] || 'current';
|
||||
const feature = args[0];
|
||||
const periods = args[1] || 'current';
|
||||
|
||||
if (!feature) {
|
||||
hexo.log.warn('Caniuse feature can NOT be empty.');
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var LAYOUTS = {
|
||||
const LAYOUTS = {
|
||||
2: {
|
||||
1: [1, 1],
|
||||
2: [2]
|
||||
@ -72,7 +72,7 @@ var LAYOUTS = {
|
||||
};
|
||||
|
||||
function groupBy(group, data) {
|
||||
var r = [];
|
||||
const r = [];
|
||||
for (let count of group) {
|
||||
r.push(data.slice(0, count));
|
||||
data = data.slice(count);
|
||||
@ -80,10 +80,10 @@ function groupBy(group, data) {
|
||||
return r;
|
||||
}
|
||||
|
||||
var templates = {
|
||||
const templates = {
|
||||
|
||||
dispatch: function(pictures, group, layout) {
|
||||
var rule = LAYOUTS[group] ? LAYOUTS[group][layout] : null;
|
||||
const rule = LAYOUTS[group] ? LAYOUTS[group][layout] : null;
|
||||
return rule ? this.getHTML(groupBy(rule, pictures)) : templates.defaults(pictures);
|
||||
},
|
||||
|
||||
@ -97,11 +97,11 @@ var templates = {
|
||||
* @param pictures
|
||||
*/
|
||||
defaults: function(pictures) {
|
||||
var ROW_SIZE = 3;
|
||||
var rows = pictures.length / ROW_SIZE;
|
||||
var pictureArr = [];
|
||||
const ROW_SIZE = 3;
|
||||
const rows = pictures.length / ROW_SIZE;
|
||||
const pictureArr = [];
|
||||
|
||||
for (var i = 0; i < rows; i++) {
|
||||
for (let i = 0; i < rows; i++) {
|
||||
pictureArr.push(pictures.slice(i * ROW_SIZE, (i + 1) * ROW_SIZE));
|
||||
}
|
||||
|
||||
@ -115,8 +115,8 @@ var templates = {
|
||||
},
|
||||
|
||||
getColumnHTML: function(pictures) {
|
||||
var columnWidth = 100 / pictures.length;
|
||||
var columnStyle = `style="width: ${columnWidth}%;"`;
|
||||
const columnWidth = 100 / pictures.length;
|
||||
const columnStyle = `style="width: ${columnWidth}%;"`;
|
||||
return pictures.map(picture => {
|
||||
return `<div class="group-picture-column" ${columnStyle}>${picture}</div>`;
|
||||
}).join('');
|
||||
@ -125,12 +125,12 @@ var templates = {
|
||||
|
||||
function groupPicture(args, content) {
|
||||
args = args[0].split('-');
|
||||
var group = parseInt(args[0], 10);
|
||||
var layout = parseInt(args[1], 10);
|
||||
const group = parseInt(args[0], 10);
|
||||
const layout = parseInt(args[1], 10);
|
||||
|
||||
content = hexo.render.renderSync({text: content, engine: 'markdown'});
|
||||
|
||||
var pictures = content.match(/<img[\s\S]*?>/g);
|
||||
const pictures = content.match(/<img[\s\S]*?>/g);
|
||||
|
||||
return `<div class="group-picture">${templates.dispatch(pictures, group, layout)}</div>`;
|
||||
}
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
|
||||
function postLabel(args) {
|
||||
args = args.join(' ').split('@');
|
||||
var classes = args[0] || 'default';
|
||||
var text = args[1] || '';
|
||||
const classes = args[0] || 'default';
|
||||
const text = args[1] || '';
|
||||
|
||||
!text && hexo.log.warn('Label text must be defined!');
|
||||
|
||||
|
||||
@ -7,17 +7,17 @@
|
||||
'use strict';
|
||||
|
||||
function postTabs(args, content) {
|
||||
var tabBlock = /<!--\s*tab (.*?)\s*-->\n([\w\W\s\S]*?)<!--\s*endtab\s*-->/g;
|
||||
const tabBlock = /<!--\s*tab (.*?)\s*-->\n([\w\W\s\S]*?)<!--\s*endtab\s*-->/g;
|
||||
|
||||
args = args.join(' ').split(',');
|
||||
var tabName = args[0];
|
||||
var tabActive = Number(args[1]) || 0;
|
||||
const tabName = args[0];
|
||||
const tabActive = Number(args[1]) || 0;
|
||||
|
||||
var matches = [];
|
||||
var match;
|
||||
var tabId = 0;
|
||||
var tabNav = '';
|
||||
var tabContent = '';
|
||||
const matches = [];
|
||||
let match;
|
||||
let tabId = 0;
|
||||
let tabNav = '';
|
||||
let tabContent = '';
|
||||
|
||||
!tabName && hexo.log.warn('Tabs block must have unique name!');
|
||||
|
||||
@ -26,12 +26,12 @@ function postTabs(args, content) {
|
||||
matches.push(match[2]);
|
||||
}
|
||||
|
||||
for (var i = 0; i < matches.length; i += 2) {
|
||||
var tabParameters = matches[i].split('@');
|
||||
var postContent = matches[i + 1];
|
||||
var tabCaption = tabParameters[0] || '';
|
||||
var tabIcon = tabParameters[1] || '';
|
||||
var tabHref = '';
|
||||
for (let i = 0; i < matches.length; i += 2) {
|
||||
const tabParameters = matches[i].split('@');
|
||||
let postContent = matches[i + 1];
|
||||
let tabCaption = tabParameters[0] || '';
|
||||
let tabIcon = tabParameters[1] || '';
|
||||
let tabHref = '';
|
||||
|
||||
postContent = hexo.render.renderSync({text: postContent, engine: 'markdown'}).trim();
|
||||
|
||||
@ -40,12 +40,12 @@ function postTabs(args, content) {
|
||||
|
||||
((tabCaption.length === 0) && (tabIcon.length === 0)) && (tabCaption = tabName + ' ' + tabId);
|
||||
|
||||
var isOnlyicon = tabIcon.length > 0 && tabCaption.length === 0 ? ' style="text-align: center;"' : '';
|
||||
const isOnlyicon = tabIcon.length > 0 && tabCaption.length === 0 ? ' style="text-align: center;"' : '';
|
||||
let icon = tabIcon.trim();
|
||||
if (!icon.startsWith('fa')) icon = 'fa fa-' + icon;
|
||||
tabIcon.length > 0 && (tabIcon = `<i class="${icon}"${isOnlyicon}></i>`);
|
||||
|
||||
var isActive = (tabActive > 0 && tabActive === tabId) || (tabActive === 0 && tabId === 1) ? ' active' : '';
|
||||
const isActive = (tabActive > 0 && tabActive === tabId) || (tabActive === 0 && tabId === 1) ? ' active' : '';
|
||||
tabNav += `<li class="tab${isActive}"><a href="#${tabHref}">${tabIcon + tabCaption.trim()}</a></li>`;
|
||||
tabContent += `<div class="tab-pane${isActive}" id="${tabHref}">${postContent}</div>`;
|
||||
}
|
||||
|
||||
@ -3,12 +3,12 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
'use strict';
|
||||
|
||||
var doSaveScroll = () => {
|
||||
const doSaveScroll = () => {
|
||||
localStorage.setItem('bookmark' + location.pathname, window.scrollY);
|
||||
};
|
||||
|
||||
var scrollToMark = () => {
|
||||
var top = localStorage.getItem('bookmark' + location.pathname);
|
||||
const scrollToMark = () => {
|
||||
let top = localStorage.getItem('bookmark' + location.pathname);
|
||||
top = parseInt(top, 10);
|
||||
// If the page opens with a specific hash, just jump out
|
||||
if (!isNaN(top) && location.hash === '') {
|
||||
@ -22,9 +22,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
};
|
||||
// Register everything
|
||||
var init = function(trigger) {
|
||||
const init = function(trigger) {
|
||||
// Create a link element
|
||||
var link = document.querySelector('.book-mark-link');
|
||||
const link = document.querySelector('.book-mark-link');
|
||||
// Scroll event
|
||||
window.addEventListener('scroll', () => link.classList.toggle('book-mark-link-fixed', window.scrollY === 0));
|
||||
// Register beforeunload event when the trigger is auto
|
||||
|
||||
@ -18,7 +18,7 @@ NexT.motion.integrator = {
|
||||
},
|
||||
next: function() {
|
||||
this.cursor++;
|
||||
var fn = this.queue[this.cursor];
|
||||
const fn = this.queue[this.cursor];
|
||||
typeof fn === 'function' && fn(NexT.motion.integrator);
|
||||
},
|
||||
bootstrap: function() {
|
||||
@ -28,13 +28,13 @@ NexT.motion.integrator = {
|
||||
|
||||
NexT.motion.middleWares = {
|
||||
logo: function(integrator) {
|
||||
var sequence = [];
|
||||
var brand = document.querySelector('.brand');
|
||||
var image = document.querySelector('.custom-logo-image');
|
||||
var title = document.querySelector('.site-title');
|
||||
var subtitle = document.querySelector('.site-subtitle');
|
||||
var logoLineTop = document.querySelector('.logo-line-before i');
|
||||
var logoLineBottom = document.querySelector('.logo-line-after i');
|
||||
const sequence = [];
|
||||
const brand = document.querySelector('.brand');
|
||||
const image = document.querySelector('.custom-logo-image');
|
||||
const title = document.querySelector('.site-title');
|
||||
const subtitle = document.querySelector('.site-subtitle');
|
||||
const logoLineTop = document.querySelector('.logo-line-before i');
|
||||
const logoLineBottom = document.querySelector('.logo-line-after i');
|
||||
|
||||
brand && sequence.push({
|
||||
e: brand,
|
||||
@ -112,7 +112,7 @@ NexT.motion.middleWares = {
|
||||
},
|
||||
|
||||
subMenu: function(integrator) {
|
||||
var subMenuItem = document.querySelectorAll('.sub-menu .menu-item');
|
||||
const subMenuItem = document.querySelectorAll('.sub-menu .menu-item');
|
||||
if (subMenuItem.length > 0) {
|
||||
subMenuItem.forEach(element => {
|
||||
element.style.opacity = 1;
|
||||
@ -122,17 +122,17 @@ NexT.motion.middleWares = {
|
||||
},
|
||||
|
||||
postList: function(integrator) {
|
||||
var postBlock = document.querySelectorAll('.post-block, .pagination, .comments');
|
||||
var postBlockTransition = CONFIG.motion.transition.post_block;
|
||||
var postHeader = document.querySelectorAll('.post-header');
|
||||
var postHeaderTransition = CONFIG.motion.transition.post_header;
|
||||
var postBody = document.querySelectorAll('.post-body');
|
||||
var postBodyTransition = CONFIG.motion.transition.post_body;
|
||||
var collHeader = document.querySelectorAll('.collection-header');
|
||||
var collHeaderTransition = CONFIG.motion.transition.coll_header;
|
||||
const postBlock = document.querySelectorAll('.post-block, .pagination, .comments');
|
||||
const postBlockTransition = CONFIG.motion.transition.post_block;
|
||||
const postHeader = document.querySelectorAll('.post-header');
|
||||
const postHeaderTransition = CONFIG.motion.transition.post_header;
|
||||
const postBody = document.querySelectorAll('.post-body');
|
||||
const postBodyTransition = CONFIG.motion.transition.post_body;
|
||||
const collHeader = document.querySelectorAll('.collection-header');
|
||||
const collHeaderTransition = CONFIG.motion.transition.coll_header;
|
||||
|
||||
if (postBlock.length > 0) {
|
||||
var postMotionOptions = window.postMotionOptions || {
|
||||
const postMotionOptions = window.postMotionOptions || {
|
||||
stagger : 100,
|
||||
drag : true,
|
||||
complete: function() {
|
||||
@ -159,8 +159,8 @@ NexT.motion.middleWares = {
|
||||
},
|
||||
|
||||
sidebar: function(integrator) {
|
||||
var sidebarAffix = document.querySelector('.sidebar-inner');
|
||||
var sidebarAffixTransition = CONFIG.motion.transition.sidebar;
|
||||
const sidebarAffix = document.querySelector('.sidebar-inner');
|
||||
const sidebarAffixTransition = CONFIG.motion.transition.sidebar;
|
||||
// Only for Pisces | Gemini.
|
||||
if (sidebarAffixTransition && (CONFIG.scheme === 'Pisces' || CONFIG.scheme === 'Gemini')) {
|
||||
Velocity(sidebarAffix, 'transition.' + sidebarAffixTransition, {
|
||||
|
||||
@ -10,9 +10,9 @@ NexT.boot.registerEvents = function() {
|
||||
// Mobile top menu bar.
|
||||
document.querySelector('.site-nav-toggle .toggle').addEventListener('click', () => {
|
||||
event.currentTarget.classList.toggle('toggle-close');
|
||||
var siteNav = document.querySelector('.site-nav');
|
||||
const siteNav = document.querySelector('.site-nav');
|
||||
if (!siteNav) return;
|
||||
var animateAction = siteNav.classList.contains('site-nav-on') ? 'slideUp' : 'slideDown';
|
||||
const animateAction = siteNav.classList.contains('site-nav-on') ? 'slideUp' : 'slideDown';
|
||||
|
||||
if (typeof Velocity === 'function') {
|
||||
Velocity(siteNav, animateAction, {
|
||||
@ -26,17 +26,17 @@ NexT.boot.registerEvents = function() {
|
||||
}
|
||||
});
|
||||
|
||||
var TAB_ANIMATE_DURATION = 200;
|
||||
const TAB_ANIMATE_DURATION = 200;
|
||||
document.querySelectorAll('.sidebar-nav li').forEach((element, index) => {
|
||||
element.addEventListener('click', event => {
|
||||
var item = event.currentTarget;
|
||||
var activeTabClassName = 'sidebar-nav-active';
|
||||
var activePanelClassName = 'sidebar-panel-active';
|
||||
const item = event.currentTarget;
|
||||
const activeTabClassName = 'sidebar-nav-active';
|
||||
const activePanelClassName = 'sidebar-panel-active';
|
||||
if (item.classList.contains(activeTabClassName)) return;
|
||||
|
||||
var targets = document.querySelectorAll('.sidebar-panel');
|
||||
var target = targets[index];
|
||||
var currentTarget = targets[1 - index];
|
||||
const targets = document.querySelectorAll('.sidebar-panel');
|
||||
const target = targets[index];
|
||||
const currentTarget = targets[1 - index];
|
||||
window.anime({
|
||||
targets : currentTarget,
|
||||
duration: TAB_ANIMATE_DURATION,
|
||||
@ -66,9 +66,9 @@ NexT.boot.registerEvents = function() {
|
||||
window.addEventListener('resize', NexT.utils.initSidebarDimension);
|
||||
|
||||
window.addEventListener('hashchange', () => {
|
||||
var tHash = location.hash;
|
||||
const tHash = location.hash;
|
||||
if (tHash !== '' && !tHash.match(/%\S{2}/)) {
|
||||
var target = document.querySelector(`.tabs ul.nav-tabs li a[href="${tHash}"]`);
|
||||
const target = document.querySelector(`.tabs ul.nav-tabs li a[href="${tHash}"]`);
|
||||
target && target.click();
|
||||
}
|
||||
});
|
||||
|
||||
@ -2,12 +2,12 @@
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
var isRight = CONFIG.sidebar.position === 'right';
|
||||
var SIDEBAR_WIDTH = CONFIG.sidebar.width || 320;
|
||||
var SIDEBAR_DISPLAY_DURATION = 200;
|
||||
var mousePos = {};
|
||||
const isRight = CONFIG.sidebar.position === 'right';
|
||||
const SIDEBAR_WIDTH = CONFIG.sidebar.width || 320;
|
||||
const SIDEBAR_DISPLAY_DURATION = 200;
|
||||
const mousePos = {};
|
||||
|
||||
var sidebarToggleLines = {
|
||||
const sidebarToggleLines = {
|
||||
lines: document.querySelector('.sidebar-toggle'),
|
||||
init : function() {
|
||||
this.lines.classList.remove('toggle-arrow', 'toggle-close');
|
||||
@ -22,7 +22,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
};
|
||||
|
||||
var sidebarToggleMotion = {
|
||||
const sidebarToggleMotion = {
|
||||
sidebarEl : document.querySelector('.sidebar'),
|
||||
isSidebarVisible: false,
|
||||
init : function() {
|
||||
@ -42,9 +42,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
mousePos.Y = event.pageY;
|
||||
},
|
||||
mouseupHandler: function(event) {
|
||||
var deltaX = event.pageX - mousePos.X;
|
||||
var deltaY = event.pageY - mousePos.Y;
|
||||
var clickingBlankPart = Math.sqrt((deltaX * deltaX) + (deltaY * deltaY)) < 20 && event.target.matches('.main');
|
||||
const deltaX = event.pageX - mousePos.X;
|
||||
const deltaY = event.pageY - mousePos.Y;
|
||||
const clickingBlankPart = Math.sqrt((deltaX * deltaX) + (deltaY * deltaY)) < 20 && event.target.matches('.main');
|
||||
if (this.isSidebarVisible && (clickingBlankPart || event.target.matches('img.medium-zoom-image, .fancybox img'))) {
|
||||
this.hideSidebar();
|
||||
}
|
||||
@ -102,8 +102,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
sidebarToggleMotion.init();
|
||||
|
||||
function updateFooterPosition() {
|
||||
var footer = document.querySelector('.footer');
|
||||
var containerHeight = document.querySelector('.header').offsetHeight + document.querySelector('.main').offsetHeight + footer.offsetHeight;
|
||||
const footer = document.querySelector('.footer');
|
||||
const containerHeight = document.querySelector('.header').offsetHeight + document.querySelector('.main').offsetHeight + footer.offsetHeight;
|
||||
footer.classList.toggle('footer-fixed', containerHeight <= window.innerHeight);
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* global NexT, CONFIG */
|
||||
|
||||
var Affix = {
|
||||
const Affix = {
|
||||
init: function(element, options) {
|
||||
this.element = element;
|
||||
this.offset = options || 0;
|
||||
|
||||
@ -13,9 +13,9 @@ NexT.utils = {
|
||||
*/
|
||||
wrapImageWithFancyBox: function() {
|
||||
document.querySelectorAll('.post-body :not(a) > img, .post-body > img').forEach(element => {
|
||||
var $image = $(element);
|
||||
var imageLink = $image.attr('data-src') || $image.attr('src');
|
||||
var $imageWrapLink = $image.wrap(`<a class="fancybox fancybox.image" href="${imageLink}" itemscope itemtype="http://schema.org/ImageObject" itemprop="url"></a>`).parent('a');
|
||||
const $image = $(element);
|
||||
const imageLink = $image.attr('data-src') || $image.attr('src');
|
||||
const $imageWrapLink = $image.wrap(`<a class="fancybox fancybox.image" href="${imageLink}" itemscope itemtype="http://schema.org/ImageObject" itemprop="url"></a>`).parent('a');
|
||||
if ($image.is('.post-gallery img')) {
|
||||
$imageWrapLink.attr('data-fancybox', 'gallery').attr('rel', 'gallery');
|
||||
} else if ($image.is('.group-picture img')) {
|
||||
@ -24,7 +24,7 @@ NexT.utils = {
|
||||
$imageWrapLink.attr('data-fancybox', 'default').attr('rel', 'default');
|
||||
}
|
||||
|
||||
var imageTitle = $image.attr('title') || $image.attr('alt');
|
||||
const imageTitle = $image.attr('title') || $image.attr('alt');
|
||||
if (imageTitle) {
|
||||
$imageWrapLink.append(`<p class="image-caption">${imageTitle}</p>`);
|
||||
// Make sure img title tag will show correctly in fancybox
|
||||
@ -138,16 +138,16 @@ NexT.utils = {
|
||||
},
|
||||
|
||||
registerScrollPercent: function() {
|
||||
var THRESHOLD = 50;
|
||||
var backToTop = document.querySelector('.back-to-top');
|
||||
var readingProgressBar = document.querySelector('.reading-progress-bar');
|
||||
const THRESHOLD = 50;
|
||||
const backToTop = document.querySelector('.back-to-top');
|
||||
const readingProgressBar = document.querySelector('.reading-progress-bar');
|
||||
// For init back to top in sidebar if page was scrolled after page refresh.
|
||||
window.addEventListener('scroll', () => {
|
||||
if (backToTop || readingProgressBar) {
|
||||
var docHeight = document.querySelector('.container').offsetHeight;
|
||||
var winHeight = window.innerHeight;
|
||||
var contentVisibilityHeight = docHeight > winHeight ? docHeight - winHeight : document.body.scrollHeight - winHeight;
|
||||
var scrollPercent = Math.min(100 * window.scrollY / contentVisibilityHeight, 100);
|
||||
const docHeight = document.querySelector('.container').offsetHeight;
|
||||
const winHeight = window.innerHeight;
|
||||
const contentVisibilityHeight = docHeight > winHeight ? docHeight - winHeight : document.body.scrollHeight - winHeight;
|
||||
const scrollPercent = Math.min(100 * window.scrollY / contentVisibilityHeight, 100);
|
||||
if (backToTop) {
|
||||
backToTop.classList.toggle('back-to-top-on', window.scrollY > THRESHOLD);
|
||||
backToTop.querySelector('span').innerText = Math.round(scrollPercent) + '%';
|
||||
@ -176,7 +176,7 @@ NexT.utils = {
|
||||
document.querySelectorAll('.tabs ul.nav-tabs .tab').forEach(element => {
|
||||
element.addEventListener('click', event => {
|
||||
event.preventDefault();
|
||||
var target = event.currentTarget;
|
||||
const target = event.currentTarget;
|
||||
// Prevent selected tab to select again.
|
||||
if (!target.classList.contains('active')) {
|
||||
// Add & Remove active class on `nav-tabs` & `tab-content`.
|
||||
@ -184,7 +184,7 @@ NexT.utils = {
|
||||
element.classList.remove('active');
|
||||
});
|
||||
target.classList.add('active');
|
||||
var tActive = document.getElementById(target.querySelector('a').getAttribute('href').replace('#', ''));
|
||||
const tActive = document.getElementById(target.querySelector('a').getAttribute('href').replace('#', ''));
|
||||
[...tActive.parentNode.children].forEach(element => {
|
||||
element.classList.remove('active');
|
||||
});
|
||||
@ -204,8 +204,8 @@ NexT.utils = {
|
||||
// Get responsive height passed from iframe.
|
||||
window.addEventListener('message', ({ data }) => {
|
||||
if ((typeof data === 'string') && data.includes('ciu_embed')) {
|
||||
var featureID = data.split(':')[1];
|
||||
var height = data.split(':')[2];
|
||||
const featureID = data.split(':')[1];
|
||||
const height = data.split(':')[2];
|
||||
document.querySelector(`iframe[data-feature=${featureID}]`).style.height = parseInt(height, 10) + 5 + 'px';
|
||||
}
|
||||
}, false);
|
||||
@ -213,10 +213,10 @@ NexT.utils = {
|
||||
|
||||
registerActiveMenuItem: function() {
|
||||
document.querySelectorAll('.menu-item').forEach(element => {
|
||||
var target = element.querySelector('a[href]');
|
||||
const target = element.querySelector('a[href]');
|
||||
if (!target) return;
|
||||
var isSamePath = target.pathname === location.pathname || target.pathname === location.pathname.replace('index.html', '');
|
||||
var isSubPath = !CONFIG.root.startsWith(target.pathname) && location.pathname.startsWith(target.pathname);
|
||||
const isSamePath = target.pathname === location.pathname || target.pathname === location.pathname.replace('index.html', '');
|
||||
const isSubPath = !CONFIG.root.startsWith(target.pathname) && location.pathname.startsWith(target.pathname);
|
||||
element.classList.toggle('menu-item-active', target.hostname === location.hostname && (isSamePath || isSubPath));
|
||||
});
|
||||
},
|
||||
@ -236,12 +236,12 @@ NexT.utils = {
|
||||
registerSidebarTOC: function() {
|
||||
const navItems = document.querySelectorAll('.post-toc li');
|
||||
const sections = [...navItems].map(element => {
|
||||
var link = element.querySelector('a.nav-link');
|
||||
const link = element.querySelector('a.nav-link');
|
||||
// TOC item animation navigate.
|
||||
link.addEventListener('click', event => {
|
||||
event.preventDefault();
|
||||
var target = document.getElementById(event.currentTarget.getAttribute('href').replace('#', ''));
|
||||
var offset = target.getBoundingClientRect().top + window.scrollY;
|
||||
const target = document.getElementById(event.currentTarget.getAttribute('href').replace('#', ''));
|
||||
const offset = target.getBoundingClientRect().top + window.scrollY;
|
||||
window.anime({
|
||||
targets : document.scrollingElement,
|
||||
duration : 500,
|
||||
@ -252,7 +252,7 @@ NexT.utils = {
|
||||
return document.getElementById(link.getAttribute('href').replace('#', ''));
|
||||
});
|
||||
|
||||
var tocElement = document.querySelector('.post-toc-wrap');
|
||||
const tocElement = document.querySelector('.post-toc-wrap');
|
||||
function activateNavByIndex(target) {
|
||||
if (target.classList.contains('active-current')) return;
|
||||
|
||||
@ -260,7 +260,7 @@ NexT.utils = {
|
||||
element.classList.remove('active', 'active-current');
|
||||
});
|
||||
target.classList.add('active', 'active-current');
|
||||
var parent = target.parentNode;
|
||||
let parent = target.parentNode;
|
||||
while (!parent.matches('.post-toc')) {
|
||||
if (parent.matches('li')) parent.classList.add('active');
|
||||
parent = parent.parentNode;
|
||||
@ -344,22 +344,22 @@ NexT.utils = {
|
||||
* Need for Sidebar/TOC inner scrolling if content taller then viewport.
|
||||
*/
|
||||
initSidebarDimension: function() {
|
||||
var sidebarNav = document.querySelector('.sidebar-nav');
|
||||
var sidebarNavHeight = sidebarNav.style.display !== 'none' ? sidebarNav.offsetHeight : 0;
|
||||
var sidebarOffset = CONFIG.sidebar.offset || 12;
|
||||
var sidebarb2tHeight = CONFIG.back2top.enable && CONFIG.back2top.sidebar ? document.querySelector('.back-to-top').offsetHeight : 0;
|
||||
var sidebarSchemePadding = (CONFIG.sidebar.padding * 2) + sidebarNavHeight + sidebarb2tHeight;
|
||||
const sidebarNav = document.querySelector('.sidebar-nav');
|
||||
const sidebarNavHeight = sidebarNav.style.display !== 'none' ? sidebarNav.offsetHeight : 0;
|
||||
const sidebarOffset = CONFIG.sidebar.offset || 12;
|
||||
const sidebarb2tHeight = CONFIG.back2top.enable && CONFIG.back2top.sidebar ? document.querySelector('.back-to-top').offsetHeight : 0;
|
||||
let sidebarSchemePadding = (CONFIG.sidebar.padding * 2) + sidebarNavHeight + sidebarb2tHeight;
|
||||
// Margin of sidebar b2t: -4px -10px -18px, brings a different of 22px.
|
||||
if (CONFIG.scheme === 'Pisces' || CONFIG.scheme === 'Gemini') sidebarSchemePadding += (sidebarOffset * 2) - 22;
|
||||
// Initialize Sidebar & TOC Height.
|
||||
var sidebarWrapperHeight = document.body.offsetHeight - sidebarSchemePadding + 'px';
|
||||
const sidebarWrapperHeight = document.body.offsetHeight - sidebarSchemePadding + 'px';
|
||||
document.querySelector('.site-overview-wrap').style.maxHeight = sidebarWrapperHeight;
|
||||
document.querySelector('.post-toc-wrap').style.maxHeight = sidebarWrapperHeight;
|
||||
},
|
||||
|
||||
updateSidebarPosition: function() {
|
||||
var sidebarNav = document.querySelector('.sidebar-nav');
|
||||
var hasTOC = document.querySelector('.post-toc');
|
||||
const sidebarNav = document.querySelector('.sidebar-nav');
|
||||
const hasTOC = document.querySelector('.post-toc');
|
||||
if (hasTOC) {
|
||||
sidebarNav.style.display = '';
|
||||
sidebarNav.classList.add('motion-element');
|
||||
@ -372,7 +372,7 @@ NexT.utils = {
|
||||
NexT.utils.initSidebarDimension();
|
||||
if (!this.isDesktop() || CONFIG.scheme === 'Pisces' || CONFIG.scheme === 'Gemini') return;
|
||||
// Expand sidebar on post detail page by default, when post has a toc.
|
||||
var display = CONFIG.page.sidebar;
|
||||
let display = CONFIG.page.sidebar;
|
||||
if (typeof display !== 'boolean') {
|
||||
// There's no definition sidebar in the page front-matter.
|
||||
display = CONFIG.sidebar.display === 'always' || (CONFIG.sidebar.display === 'post' && hasTOC);
|
||||
@ -386,7 +386,7 @@ NexT.utils = {
|
||||
if (condition) {
|
||||
callback();
|
||||
} else {
|
||||
var script = document.createElement('script');
|
||||
let script = document.createElement('script');
|
||||
script.onload = script.onreadystatechange = function(_, isAbort) {
|
||||
if (isAbort || !script.readyState || /loaded|complete/.test(script.readyState)) {
|
||||
script.onload = script.onreadystatechange = null;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user