style: 4 space indents to the JS files
This commit is contained in:
parent
1fd665bf49
commit
339293d0d7
21 changed files with 913 additions and 912 deletions
|
@ -2,10 +2,13 @@ root = true
|
||||||
|
|
||||||
[*]
|
[*]
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
# 2 space indentation
|
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
# Unix-style newlines with a newline ending every file
|
# Unix-style newlines with a newline ending every file
|
||||||
end_of_line = lf
|
end_of_line = lf
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
|
|
||||||
|
|
||||||
|
[*.js]
|
||||||
|
indent_size = 4
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/**
|
||||||
Reference: https://bootsnipp.com/snippets/featured/link-to-top-page
|
* Reference: https://bootsnipp.com/snippets/featured/link-to-top-page
|
||||||
*/
|
*/
|
||||||
$(function() {
|
$(function() {
|
||||||
$(window).scroll(() => {
|
$(window).scroll(() => {
|
||||||
if ($(this).scrollTop() > 50 &&
|
if ($(this).scrollTop() > 50 &&
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/**
|
||||||
* Listener for theme mode toggle
|
* Listener for theme mode toggle
|
||||||
*/
|
*/
|
||||||
$(function() {
|
$(function () {
|
||||||
$(".mode-toggle").click((e) => {
|
$(".mode-toggle").click((e) => {
|
||||||
const $target = $(e.target);
|
const $target = $(e.target);
|
||||||
let $btn = ($target.prop("tagName") === "button".toUpperCase() ?
|
let $btn = ($target.prop("tagName") === "button".toUpperCase() ?
|
||||||
|
|
|
@ -18,7 +18,9 @@ const ScrollHelper = (function () {
|
||||||
|
|
||||||
addScrollUpTask: () => {
|
addScrollUpTask: () => {
|
||||||
scrollUpCount += 1;
|
scrollUpCount += 1;
|
||||||
if (!topbarLocked) { topbarLocked = true; }
|
if (!topbarLocked) {
|
||||||
|
topbarLocked = true;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
popScrollUpTask: () => scrollUpCount -= 1,
|
popScrollUpTask: () => scrollUpCount -= 1,
|
||||||
hasScrollUpTask: () => scrollUpCount > 0,
|
hasScrollUpTask: () => scrollUpCount > 0,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/**
|
||||||
* This script make #search-result-wrapper switch to unloaded or shown automatically.
|
* This script make #search-result-wrapper switch to unloaded or shown automatically.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$(function() {
|
$(function () {
|
||||||
const btnSbTrigger = $("#sidebar-trigger");
|
const btnSbTrigger = $("#sidebar-trigger");
|
||||||
const btnSearchTrigger = $("#search-trigger");
|
const btnSearchTrigger = $("#search-trigger");
|
||||||
const btnCancel = $("#search-cancel");
|
const btnCancel = $("#search-cancel");
|
||||||
|
@ -91,22 +91,22 @@ $(function() {
|
||||||
return btnCancel.hasClass("loaded");
|
return btnCancel.hasClass("loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
btnSearchTrigger.click(function() {
|
btnSearchTrigger.click(function () {
|
||||||
mobileSearchBar.on();
|
mobileSearchBar.on();
|
||||||
resultSwitch.on();
|
resultSwitch.on();
|
||||||
input.focus();
|
input.focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
btnCancel.click(function() {
|
btnCancel.click(function () {
|
||||||
mobileSearchBar.off();
|
mobileSearchBar.off();
|
||||||
resultSwitch.off();
|
resultSwitch.off();
|
||||||
});
|
});
|
||||||
|
|
||||||
input.focus(function() {
|
input.focus(function () {
|
||||||
searchWrapper.addClass("input-focus");
|
searchWrapper.addClass("input-focus");
|
||||||
});
|
});
|
||||||
|
|
||||||
input.focusout(function() {
|
input.focusout(function () {
|
||||||
searchWrapper.removeClass("input-focus");
|
searchWrapper.removeClass("input-focus");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
* Expand or close the sidebar in mobile screens.
|
* Expand or close the sidebar in mobile screens.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$(function() {
|
$(function () {
|
||||||
|
|
||||||
const sidebarUtil = (function () {
|
const sidebarUtil = (function () {
|
||||||
const ATTR_DISPLAY = "sidebar-display";
|
const ATTR_DISPLAY = "sidebar-display";
|
||||||
let isExpanded = false;
|
let isExpanded = false;
|
||||||
|
@ -26,5 +25,4 @@ $(function() {
|
||||||
$("#sidebar-trigger").click(sidebarUtil.toggle);
|
$("#sidebar-trigger").click(sidebarUtil.toggle);
|
||||||
|
|
||||||
$("#mask").click(sidebarUtil.toggle);
|
$("#mask").click(sidebarUtil.toggle);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Initial Bootstrap Tooltip.
|
* Initial Bootstrap Tooltip.
|
||||||
*/
|
*/
|
||||||
$(function () {
|
$(function () {
|
||||||
$("[data-toggle=\"tooltip\"]").tooltip();
|
$("[data-toggle=\"tooltip\"]").tooltip();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/**
|
||||||
* Hide Header on scroll down
|
* Hide Header on scroll down
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$(function() {
|
$(function () {
|
||||||
const $searchInput = $("#search-input");
|
const $searchInput = $("#search-input");
|
||||||
const delta = ScrollHelper.getTopbarHeight();
|
const delta = ScrollHelper.getTopbarHeight();
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ $(function() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (st > lastScrollTop ) { // Scroll Down
|
if (st > lastScrollTop) { // Scroll Down
|
||||||
ScrollHelper.hideTopbar();
|
ScrollHelper.hideTopbar();
|
||||||
|
|
||||||
if ($searchInput.is(":focus")) {
|
if ($searchInput.is(":focus")) {
|
||||||
|
@ -66,7 +66,7 @@ $(function() {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// for the browsers that not support `window.screen.orientation` API
|
// for the browsers that not support `window.screen.orientation` API
|
||||||
$(window).on("orientationchange",() => {
|
$(window).on("orientationchange", () => {
|
||||||
if ($(window).width() < $(window).height()) { // before rotating, it is still in portrait mode.
|
if ($(window).width() < $(window).height()) { // before rotating, it is still in portrait mode.
|
||||||
handleLandscape();
|
handleLandscape();
|
||||||
}
|
}
|
||||||
|
@ -86,5 +86,4 @@ $(function() {
|
||||||
didScroll = false;
|
didScroll = false;
|
||||||
}
|
}
|
||||||
}, 250);
|
}, 250);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/**
|
||||||
* Top bar title auto change while scrolling up/down in mobile screens.
|
* Top bar title auto change while scrolling up/down in mobile screens.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$(function() {
|
$(function () {
|
||||||
const titleSelector = "div.post>h1:first-of-type";
|
const titleSelector = "div.post>h1:first-of-type";
|
||||||
const $pageTitle = $(titleSelector);
|
const $pageTitle = $(titleSelector);
|
||||||
const $topbarTitle = $("#topbar-title");
|
const $topbarTitle = $("#topbar-title");
|
||||||
|
@ -60,7 +60,7 @@ $(function() {
|
||||||
observer.observe(document.querySelector(titleSelector));
|
observer.observe(document.querySelector(titleSelector));
|
||||||
|
|
||||||
/* Click title will scroll to top */
|
/* Click title will scroll to top */
|
||||||
$topbarTitle.click(function() {
|
$topbarTitle.click(function () {
|
||||||
$("body,html").animate({scrollTop: 0}, 800);
|
$("body,html").animate({scrollTop: 0}, 800);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/**
|
||||||
* Tab 'Categories' expand/close effect.
|
* Tab 'Categories' expand/close effect.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$(function() {
|
$(function () {
|
||||||
const childPrefix = "l_";
|
const childPrefix = "l_";
|
||||||
const parentPrefix = "h_";
|
const parentPrefix = "h_";
|
||||||
const collapse = $(".collapse");
|
const collapse = $(".collapse");
|
||||||
|
@ -18,7 +18,7 @@ $(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
/* expand the top category */
|
/* expand the top category */
|
||||||
collapse.on("show.bs.collapse", function() {
|
collapse.on("show.bs.collapse", function () {
|
||||||
const parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length);
|
const parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length);
|
||||||
if (parentId) {
|
if (parentId) {
|
||||||
$(`#${parentId} .far.fa-folder`).attr("class", "far fa-folder-open fa-fw");
|
$(`#${parentId} .far.fa-folder`).attr("class", "far fa-folder-open fa-fw");
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/**
|
||||||
* Clipboard functions
|
* Clipboard functions
|
||||||
*
|
*
|
||||||
* Dependencies:
|
* Dependencies:
|
||||||
|
@ -6,7 +6,7 @@
|
||||||
* - clipboard.js (https://github.com/zenorocha/clipboard.js)
|
* - clipboard.js (https://github.com/zenorocha/clipboard.js)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$(function() {
|
$(function () {
|
||||||
const btnSelector = '.code-header>button';
|
const btnSelector = '.code-header>button';
|
||||||
const ICON_SUCCESS = 'fas fa-check';
|
const ICON_SUCCESS = 'fas fa-check';
|
||||||
const ATTR_TIMEOUT = 'timeout';
|
const ATTR_TIMEOUT = 'timeout';
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
/**
|
/**
|
||||||
Lazy load images (https://github.com/ApoorvSaxena/lozad.js)
|
Lazy load images (https://github.com/ApoorvSaxena/lozad.js)
|
||||||
and popup when clicked (https://github.com/dimsemenov/Magnific-Popup)
|
and popup when clicked (https://github.com/dimsemenov/Magnific-Popup)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$(function() {
|
|
||||||
|
|
||||||
|
$(function () {
|
||||||
const IMG_SCOPE = '#main > div.row:first-child > div:first-child';
|
const IMG_SCOPE = '#main > div.row:first-child > div:first-child';
|
||||||
|
|
||||||
if ($(`${IMG_SCOPE} img`).length <= 0 ) {
|
if ($(`${IMG_SCOPE} img`).length <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,8 +18,8 @@ $(function() {
|
||||||
|
|
||||||
/* popup */
|
/* popup */
|
||||||
|
|
||||||
$(`${IMG_SCOPE} p > img[data-src],${IMG_SCOPE} img[data-src].preview-img`).each(
|
$(`${IMG_SCOPE} p > img[data-src], ${IMG_SCOPE} img[data-src].preview-img`).each(
|
||||||
function() {
|
function () {
|
||||||
let nextTag = $(this).next();
|
let nextTag = $(this).next();
|
||||||
const title = nextTag.prop('tagName') === 'EM' ? nextTag.text() : '';
|
const title = nextTag.prop('tagName') === 'EM' ? nextTag.text() : '';
|
||||||
const src = $(this).attr('data-src'); // created by lozad.js
|
const src = $(this).attr('data-src'); // created by lozad.js
|
||||||
|
|
|
@ -20,7 +20,7 @@ const LocaleHelper = (function () {
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
||||||
$(function() {
|
$(function () {
|
||||||
dayjs.locale(LocaleHelper.locale());
|
dayjs.locale(LocaleHelper.locale());
|
||||||
dayjs.extend(window.dayjs_plugin_localizedFormat);
|
dayjs.extend(window.dayjs_plugin_localizedFormat);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/**
|
||||||
* Count page views form GA or local cache file.
|
* Count page views form GA or local cache file.
|
||||||
*
|
*
|
||||||
* Dependencies:
|
* Dependencies:
|
||||||
|
@ -106,7 +106,7 @@ const PvStorage = (function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(let i = 0; i < localStorage.length; i++){
|
for (let i = 0; i < localStorage.length; i++) {
|
||||||
const key = localStorage.key(i);
|
const key = localStorage.key(i);
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case Keys.KEY_PV:
|
case Keys.KEY_PV:
|
||||||
|
@ -136,7 +136,7 @@ function countUp(min, max, destId) {
|
||||||
function countPV(path, rows) {
|
function countPV(path, rows) {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
if (typeof rows !== "undefined" ) {
|
if (typeof rows !== "undefined") {
|
||||||
for (let i = 0; i < rows.length; ++i) {
|
for (let i = 0; i < rows.length; ++i) {
|
||||||
const gaPath = rows[parseInt(i, 10)][0];
|
const gaPath = rows[parseInt(i, 10)][0];
|
||||||
if (gaPath === path) { /* path format see: site.permalink */
|
if (gaPath === path) { /* path format see: site.permalink */
|
||||||
|
@ -172,7 +172,7 @@ function displayPageviews(data) {
|
||||||
const rows = data.rows; /* could be undefined */
|
const rows = data.rows; /* could be undefined */
|
||||||
|
|
||||||
if ($("#post-list").length > 0) { /* the Home page */
|
if ($("#post-list").length > 0) { /* the Home page */
|
||||||
$(".post-preview").each(function() {
|
$(".post-preview").each(function () {
|
||||||
const path = $(this).find("a").attr("href");
|
const path = $(this).find("a").attr("href");
|
||||||
tacklePV(rows, path, $(this).find(".pageviews"), hasInit);
|
tacklePV(rows, path, $(this).find(".pageviews"), hasInit);
|
||||||
});
|
});
|
||||||
|
@ -215,7 +215,7 @@ function fetchLocalPageviews(hasCache = false) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function() {
|
$(function () {
|
||||||
if ($(".pageviews").length <= 0) {
|
if ($(".pageviews").length <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
/*
|
/**
|
||||||
Safari doesn't support CSS `scroll-behavior: smooth`,
|
Safari doesn't support CSS `scroll-behavior: smooth`,
|
||||||
so here is a compatible solution for all browser to smooth scrolling
|
so here is a compatible solution for all browser to smooth scrolling
|
||||||
|
|
||||||
See: <https://css-tricks.com/snippets/jquery/smooth-scrolling/>
|
See: <https://css-tricks.com/snippets/jquery/smooth-scrolling/>
|
||||||
|
|
||||||
Warning: It must be called after all `<a>` tags (e.g., the dynamic TOC) are ready.
|
Warning: It must be called after all `<a>` tags (e.g., the dynamic TOC) are ready.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$(function() {
|
$(function () {
|
||||||
const $topbarTitle = $("#topbar-title");
|
const $topbarTitle = $("#topbar-title");
|
||||||
const REM = 16; // in pixels
|
const REM = 16; // in pixels
|
||||||
const ATTR_SCROLL_FOCUS = "scroll-focus";
|
const ATTR_SCROLL_FOCUS = "scroll-focus";
|
||||||
|
@ -15,7 +15,7 @@ $(function() {
|
||||||
$("a[href*='#']")
|
$("a[href*='#']")
|
||||||
.not("[href='#']")
|
.not("[href='#']")
|
||||||
.not("[href='#0']")
|
.not("[href='#0']")
|
||||||
.click(function(event) {
|
.click(function (event) {
|
||||||
if (this.pathname.replace(/^\//, "") !==
|
if (this.pathname.replace(/^\//, "") !==
|
||||||
location.pathname.replace(/^\//, "")) {
|
location.pathname.replace(/^\//, "")) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -5,7 +5,6 @@ layout: compress
|
||||||
---
|
---
|
||||||
|
|
||||||
const resource = [
|
const resource = [
|
||||||
|
|
||||||
/* --- CSS --- */
|
/* --- CSS --- */
|
||||||
'{{ "/assets/css/style.css" | relative_url }}',
|
'{{ "/assets/css/style.css" | relative_url }}',
|
||||||
|
|
||||||
|
@ -16,6 +15,7 @@ const resource = [
|
||||||
/* --- HTML --- */
|
/* --- HTML --- */
|
||||||
'{{ "/index.html" | relative_url }}',
|
'{{ "/index.html" | relative_url }}',
|
||||||
'{{ "/404.html" | relative_url }}',
|
'{{ "/404.html" | relative_url }}',
|
||||||
|
|
||||||
{% for tab in site.tabs %}
|
{% for tab in site.tabs %}
|
||||||
'{{ tab.url | relative_url }}',
|
'{{ tab.url | relative_url }}',
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -25,7 +25,6 @@ const resource = [
|
||||||
{% for file in cache_list %}
|
{% for file in cache_list %}
|
||||||
'{{ file.path | relative_url }}'{%- unless forloop.last -%},{%- endunless -%}
|
'{{ file.path | relative_url }}'{%- unless forloop.last -%},{%- endunless -%}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/* The request url with below domain will be cached */
|
/* The request url with below domain will be cached */
|
||||||
|
|
2
assets/js/dist/page.min.js
vendored
2
assets/js/dist/page.min.js
vendored
File diff suppressed because one or more lines are too long
2
assets/js/dist/post.min.js
vendored
2
assets/js/dist/post.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -32,8 +32,7 @@ if ('serviceWorker' in navigator) {
|
||||||
}
|
}
|
||||||
$notification.toast('hide');
|
$notification.toast('hide');
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
let refreshing = false;
|
let refreshing = false;
|
||||||
|
|
||||||
|
@ -45,3 +44,4 @@ if ('serviceWorker' in navigator) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,3 +87,4 @@ self.addEventListener('fetch', event => {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue