Skip to content

Commit

Permalink
Run lebab
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed May 28, 2020
1 parent 17502da commit 74fa9ec
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 114 deletions.
4 changes: 2 additions & 2 deletions scripts/tags/caniuse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down
26 changes: 13 additions & 13 deletions scripts/tags/group-pictures.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

'use strict';

var LAYOUTS = {
const LAYOUTS = {
2: {
1: [1, 1],
2: [2]
Expand Down Expand Up @@ -72,18 +72,18 @@ 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);
}
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);
},

Expand All @@ -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));
}

Expand All @@ -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('');
Expand All @@ -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>`;
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/tags/label.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!');

Expand Down
32 changes: 16 additions & 16 deletions scripts/tags/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!');

Expand All @@ -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();

Expand All @@ -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>`;
}
Expand Down
10 changes: 5 additions & 5 deletions source/js/bookmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 === '') {
Expand All @@ -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
Expand Down
40 changes: 20 additions & 20 deletions source/js/motion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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() {
Expand All @@ -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, {
Expand Down
22 changes: 11 additions & 11 deletions source/js/next-boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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,
Expand Down Expand Up @@ -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();
}
});
Expand Down
22 changes: 11 additions & 11 deletions source/js/schemes/muse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -22,7 +22,7 @@ document.addEventListener('DOMContentLoaded', () => {
}
};

var sidebarToggleMotion = {
const sidebarToggleMotion = {
sidebarEl : document.querySelector('.sidebar'),
isSidebarVisible: false,
init : function() {
Expand All @@ -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();
}
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion source/js/schemes/pisces.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global NexT, CONFIG */

var Affix = {
const Affix = {
init: function(element, options) {
this.element = element;
this.offset = options || 0;
Expand Down
Loading

0 comments on commit 74fa9ec

Please sign in to comment.