chore(deps): remove jQuery

This commit is contained in:
Dillon 2020-02-16 03:03:18 +08:00
parent 730ce7a1ca
commit 2f8123bfa6
16 changed files with 299 additions and 394 deletions

View file

@ -68,22 +68,25 @@
h5,
h6 {
font-weight: bold;
margin: 1.2rem 0;
.dark-theme & {
font-weight: bolder;
}
}
h2,
h3,
h4,
h5,
h6 {
padding-top: .8rem;
padding-bottom: .3rem;
h2::before,
h3::before,
h4::before,
h5::before,
h6::before {
display: block;
content: "";
height: 1.2 * $header-height;
margin: -1.2 * $header-height 0 0;
}
h2::before {
h2 > a:first-child::before {
content: "#";
margin-right: .3125rem;
color: $single-link-color;
@ -93,16 +96,18 @@
}
}
h3::before,
h4::before,
h5::before,
h6::before {
content: "|";
margin-right: .3125rem;
color: $single-link-color;
h3,
h4,
h5,
h6 {
& > a:first-child::before {
content: "|";
margin-right: .3125rem;
color: $single-link-color;
.dark-theme & {
color: $single-link-color-dark;
.dark-theme & {
color: $single-link-color-dark;
}
}
}

View file

@ -1,15 +1,18 @@
header.desktop {
display: block;
header {
position: fixed;
width: 100%;
z-index: 100;
height: 4rem;
line-height: 4rem;
height: $header-height;
line-height: $header-height;
background-color: $header-background-color;
.dark-theme & {
background-color: $header-background-color-dark;
}
}
header.desktop {
display: block;
z-index: 100;
.header-wrapper {
width: auto;
@ -44,17 +47,12 @@ header.desktop {
header.mobile {
display: none;
position: fixed;
width: 100%;
z-index: 100;
transition: all 0.3s ease 0s;
.header-wrapper {
padding: 0;
margin: 0;
height: 4rem;
line-height: 4rem;
background: $global-background-color;
.header-container {
display: flex;
@ -82,9 +80,9 @@ header.mobile {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
-webkit-transition: .2s margin .2s, .2s transform;
-moz-transition: .2s margin .2s, .2s transform;
transition: .2s margin .2s, .2s transform;
-webkit-transition: .1s margin .1s, .1s transform;
-moz-transition: .1s margin .1s, .1s transform;
transition: .1s margin .1s, .1s transform;
.dark-theme & {
background: $global-font-color-dark;
@ -101,9 +99,9 @@ header.mobile {
&.active {
span {
-webkit-transition: .2s margin, .2s transform .2s;
-moz-transition: .2s margin, .2s transform .2s;
transition: .2s margin, .2s transform .2s;
-webkit-transition: .1s margin, .1s transform .1s;
-moz-transition: .1s margin, .1s transform .1s;
transition: .1s margin, .1s transform .1s;
}
span:nth-child(1) {
@ -148,9 +146,5 @@ header.mobile {
border-top: 2px solid $global-font-color-dark;
}
}
.dark-theme & {
background: $global-background-color-dark;
}
}
}

View file

@ -46,6 +46,9 @@ $selection-color-dark: rgba(38, 139, 211, 0.3) !default;
// ========== Selection ========== //
// ========== Header ========== //
// Height of the header
$header-height: 4rem !default;
// Color of the header background
$header-background-color: #fafafa !default;
$header-background-color-dark: #252627 !default;

View file

@ -1,12 +1,10 @@
gitalk@1.5.0
valine@1.3.10
jquery@3.4.1
lazysizes@5.1.2
katex@0.11.1
mermaid@8.4.2
echarts@4.5.0
typeit@6.0.3
jquery-countdown@2.2.0
aplayer@1.10.1
meting@2.0.1
smooth-scroll@16.1.0

View file

@ -1,22 +0,0 @@
/*!
* The Final Countdown for jQuery v2.2.0 (http://hilios.github.io/jQuery.countdown/)
* Copyright (c) 2016 Edson Hilios
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
!function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){"use strict";function b(a){if(a instanceof Date)return a;if(String(a).match(g))return String(a).match(/^[0-9]*$/)&&(a=Number(a)),String(a).match(/\-/)&&(a=String(a).replace(/\-/g,"/")),new Date(a);throw new Error("Couldn't cast `"+a+"` to a date object.")}function c(a){var b=a.toString().replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1");return new RegExp(b)}function d(a){return function(b){var d=b.match(/%(-|!)?[A-Z]{1}(:[^;]+;)?/gi);if(d)for(var f=0,g=d.length;f<g;++f){var h=d[f].match(/%(-|!)?([a-zA-Z]{1})(:[^;]+;)?/),j=c(h[0]),k=h[1]||"",l=h[3]||"",m=null;h=h[2],i.hasOwnProperty(h)&&(m=i[h],m=Number(a[m])),null!==m&&("!"===k&&(m=e(l,m)),""===k&&m<10&&(m="0"+m.toString()),b=b.replace(j,m.toString()))}return b=b.replace(/%%/,"%")}}function e(a,b){var c="s",d="";return a&&(a=a.replace(/(:|;|\s)/gi,"").split(/\,/),1===a.length?c=a[0]:(d=a[0],c=a[1])),Math.abs(b)>1?c:d}var f=[],g=[],h={precision:100,elapse:!1,defer:!1};g.push(/^[0-9]*$/.source),g.push(/([0-9]{1,2}\/){2}[0-9]{4}( [0-9]{1,2}(:[0-9]{2}){2})?/.source),g.push(/[0-9]{4}([\/\-][0-9]{1,2}){2}( [0-9]{1,2}(:[0-9]{2}){2})?/.source),g=new RegExp(g.join("|"));var i={Y:"years",m:"months",n:"daysToMonth",d:"daysToWeek",w:"weeks",W:"weeksToMonth",H:"hours",M:"minutes",S:"seconds",D:"totalDays",I:"totalHours",N:"totalMinutes",T:"totalSeconds"},j=function(b,c,d){this.el=b,this.$el=a(b),this.interval=null,this.offset={},this.options=a.extend({},h),this.instanceNumber=f.length,f.push(this),this.$el.data("countdown-instance",this.instanceNumber),d&&("function"==typeof d?(this.$el.on("update.countdown",d),this.$el.on("stoped.countdown",d),this.$el.on("finish.countdown",d)):this.options=a.extend({},h,d)),this.setFinalDate(c),this.options.defer===!1&&this.start()};a.extend(j.prototype,{start:function(){null!==this.interval&&clearInterval(this.interval);var a=this;this.update(),this.interval=setInterval(function(){a.update.call(a)},this.options.precision)},stop:function(){clearInterval(this.interval),this.interval=null,this.dispatchEvent("stoped")},toggle:function(){this.interval?this.stop():this.start()},pause:function(){this.stop()},resume:function(){this.start()},remove:function(){this.stop.call(this),f[this.instanceNumber]=null,delete this.$el.data().countdownInstance},setFinalDate:function(a){this.finalDate=b(a)},update:function(){if(0===this.$el.closest("html").length)return void this.remove();var b,c=void 0!==a._data(this.el,"events"),d=new Date;b=this.finalDate.getTime()-d.getTime(),b=Math.ceil(b/1e3),b=!this.options.elapse&&b<0?0:Math.abs(b),this.totalSecsLeft!==b&&c&&(this.totalSecsLeft=b,this.elapsed=d>=this.finalDate,this.offset={seconds:this.totalSecsLeft%60,minutes:Math.floor(this.totalSecsLeft/60)%60,hours:Math.floor(this.totalSecsLeft/60/60)%24,days:Math.floor(this.totalSecsLeft/60/60/24)%7,daysToWeek:Math.floor(this.totalSecsLeft/60/60/24)%7,daysToMonth:Math.floor(this.totalSecsLeft/60/60/24%30.4368),weeks:Math.floor(this.totalSecsLeft/60/60/24/7),weeksToMonth:Math.floor(this.totalSecsLeft/60/60/24/7)%4,months:Math.floor(this.totalSecsLeft/60/60/24/30.4368),years:Math.abs(this.finalDate.getFullYear()-d.getFullYear()),totalDays:Math.floor(this.totalSecsLeft/60/60/24),totalHours:Math.floor(this.totalSecsLeft/60/60),totalMinutes:Math.floor(this.totalSecsLeft/60),totalSeconds:this.totalSecsLeft},this.options.elapse||0!==this.totalSecsLeft?this.dispatchEvent("update"):(this.stop(),this.dispatchEvent("finish")))},dispatchEvent:function(b){var c=a.Event(b+".countdown");c.finalDate=this.finalDate,c.elapsed=this.elapsed,c.offset=a.extend({},this.offset),c.strftime=d(this.offset),this.$el.trigger(c)}}),a.fn.countdown=function(){var b=Array.prototype.slice.call(arguments,0);return this.each(function(){var c=a(this).data("countdown-instance");if(void 0!==c){var d=f[c],e=b[0];j.prototype.hasOwnProperty(e)?d[e].apply(d,b.slice(1)):null===String(e).match(/^[$A-Z_][0-9A-Z_$]*$/i)?(d.setFinalDate.call(d,e),d.start()):a.error("Method %s does not exist on jQuery.countdown".replace(/\%s/gi,e))}else new j(this,b[0],b[1])})}});

File diff suppressed because one or more lines are too long

View file

@ -1,313 +1,288 @@
jQuery(function($) {
(() => {
'use strict';
var _Theme = window._Theme || {};
_Theme.scroll = function () {
window.scroll = new SmoothScroll('[data-scroll]', {speed: 300, speedAsDuration: true});
}
_Theme.toggleMobileMenu = function () {
$('#menu-toggle').on('click', () => {
$('#menu-toggle').toggleClass('active');
$('#menu-mobile').toggleClass('active');
});
};
_Theme.toggleTheme = function () {
$('.theme-switch').on('click', () => {
$('body').toggleClass('dark-theme');
window.isDark = !window.isDark;
window.localStorage && window.localStorage.setItem('theme', window.isDark ? 'dark' : 'light');
this.echarts();
});
};
_Theme.dynamicToTop = function () {
const min = 300;
var $toTop = $('#dynamic-to-top');
$(window).scroll(() => {
var scrollTop = $(window).scrollTop();
if (typeof document.body.style.maxHeight === 'undefined') {
$toTop.css({
'position': 'absolute',
'top': scrollTop + $(window).height() - 20,
});
}
if (scrollTop > min) {
(function fadeIn(el, display){
display = display || "block";
if (el.style.display !== display) {
el.style.opacity = 0;
el.style.display = display;
(function fade() {
var val = parseFloat(el.style.opacity);
if (!((val += .1) > 1)) {
el.style.opacity = val;
requestAnimationFrame(fade);
}
})();
}
})(document.getElementById('dynamic-to-top'));
} else {
(function fadeOut(el){
if (el.style.display !== "none") {
el.style.opacity = 1;
(function fade() {
if ((el.style.opacity -= .1) < 0) {
el.style.display = "none";
} else {
requestAnimationFrame(fade);
}
})();
}
})(document.getElementById('dynamic-to-top'));
}
});
};
_Theme.chroma = function () {
const blocks = document.querySelectorAll('.highlight > .chroma');
for (let i = 0; i < blocks.length; i++) {
const block = blocks[i];
const codes = block.querySelectorAll('pre.chroma > code');
const code = codes[codes.length - 1];
const lang = code ? code.className.toLowerCase() : '';
block.className += ' ' + lang;
}
const nolinenosBlocks = document.querySelectorAll('.highlight > pre.chroma');
for (let i = 0; i < nolinenosBlocks.length; i++) {
const block = nolinenosBlocks[i];
const chroma = document.createElement('div');
chroma.className = block.className;
const table = document.createElement('table');
chroma.appendChild(table);
const tbody = document.createElement('tbody');
table.appendChild(tbody);
const tr = document.createElement('tr');
tbody.appendChild(tr);
const td = document.createElement('td');
tr.appendChild(td);
block.parentElement.replaceChild(chroma, block);
td.appendChild(block);
const forEachElement = (elements, handler) => {
elements = elements || [];
for (let i = 0; i < elements.length; i++) {
handler(elements[i]);
}
};
_Theme.responsiveTable = function () {
const tables = document.querySelectorAll('.content table');
for (let i = 0; i < tables.length; i++) {
const table = tables[i];
const wrapper = document.createElement('div');
wrapper.className = 'table-wrapper';
table.parentElement.replaceChild(wrapper, table);
wrapper.appendChild(table);
class Theme {
initSmoothScroll() {
new SmoothScroll('[smooth-scroll]', {speed: 300, speedAsDuration: true});
}
};
_Theme._refactorToc = function(toc) {
// when headings do not start with `h1`
const oldTocList = toc.children[0];
let newTocList = oldTocList;
let temp;
while (newTocList.children.length === 1
&& (temp = newTocList.children[0].children[0]).tagName === 'UL') {
newTocList = temp;
initMobileMenu() {
document.getElementById('menu-toggle').onclick = () => {
document.getElementById('menu-toggle').classList.toggle('active');
document.getElementById('menu-mobile').classList.toggle('active');
};
}
if (newTocList !== oldTocList) toc.replaceChild(newTocList, oldTocList);
};
_Theme._linkToc = function () {
const links = document.querySelectorAll('#TableOfContents a:first-child');
for (let i = 0; i < links.length; i++) links[i].className += ' toc-link';
for (let num = 1; num <= 6; num++) {
const headers = document.querySelectorAll('.content>h' + num);
for (let i = 0; i < headers.length; i++) {
const header = headers[i];
header.innerHTML = `<a href="#${header.id}" class="headerlink"></a>${header.innerHTML}`;
}
}
};
_Theme._initToc = function () {
const $toc = $('#post-toc');
if ($toc.length && $toc.css('display') !== 'none') {
const SPACING = 80;
const $footer = $('#post-footer');
const minTop = $toc.position().top;;
const mainTop = $('main').position().top;
const minScrollTop = minTop + mainTop - SPACING;
const changeTocState = function () {
const scrollTop = $(window).scrollTop();
const maxTop = $footer.position().top - $toc.height();
const maxScrollTop = maxTop + mainTop - SPACING;
const tocState = {
start: {
'position': 'absolute',
'top': minTop,
},
process: {
'position': 'fixed',
'top': SPACING,
},
end: {
'position': 'absolute',
'top': maxTop,
}
initSwitchTheme() {
forEachElement(document.getElementsByClassName('theme-switch'), (button) => {
button.onclick = () => {
document.body.classList.toggle('dark-theme');
window.isDark = !window.isDark;
window.localStorage && window.localStorage.setItem('theme', window.isDark ? 'dark' : 'light');
this.initEcharts();
};
});
}
if (scrollTop < minScrollTop) {
$toc.css(tocState.start);
} else if (scrollTop > maxScrollTop) {
$toc.css(tocState.end);
initDynamicToTop() {
const min = 300;
const toTopButton = document.getElementById('dynamic-to-top');
window.onscroll = () => {
const scrollTop = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
if (typeof document.body.style.maxHeight === 'undefined') {
toTopButton.style.position = 'absolute';
toTopButton.style.top = scrollTop + window.document.documentElement.clientHeight - 20;
}
if (scrollTop > min) {
(function fadeIn(el, display){
display = display || 'block';
if (el.style.display !== display) {
el.style.opacity = 0;
el.style.display = display;
(function fade() {
let val = parseFloat(el.style.opacity);
if ((val += .1) <= 1) {
el.style.opacity = val;
requestAnimationFrame(fade);
}
})();
}
})(document.getElementById('dynamic-to-top'));
} else {
$toc.css(tocState.process);
(function fadeOut(el){
if (el.style.display !== 'none') {
el.style.opacity = 1;
(function fade() {
if ((el.style.opacity -= .1) < 0) {
el.style.display = 'none';
} else {
requestAnimationFrame(fade);
}
})();
}
})(document.getElementById('dynamic-to-top'));
}
};
changeTocState();
}
const $toclink = $('.toc-link');
const $headerDummyLink = $('.post-dummy-target');
const $tocLinkLis = $('.post-toc-content li');
const activeIndex = function () {
const scrollTop = $(window).scrollTop();
const headerlinkTop = $.map($headerDummyLink, function(link) {
return $(link).offset().top;
initHighlight() {
forEachElement(document.querySelectorAll('.highlight > .chroma'), (block) => {
const codes = block.querySelectorAll('pre.chroma > code');
const code = codes[codes.length - 1];
const lang = code ? code.className.toLowerCase() : '';
block.className += ' ' + lang;
});
forEachElement(document.querySelectorAll('.highlight > pre.chroma'), (block) => {
const chroma = document.createElement('div');
chroma.className = block.className;
const table = document.createElement('table');
chroma.appendChild(table);
const tbody = document.createElement('tbody');
table.appendChild(tbody);
const tr = document.createElement('tr');
tbody.appendChild(tr);
const td = document.createElement('td');
tr.appendChild(td);
block.parentElement.replaceChild(chroma, block);
td.appendChild(block);
});
}
initTable() {
forEachElement(document.querySelectorAll('.content table'), (table) => {
const wrapper = document.createElement('div');
wrapper.className = 'table-wrapper';
table.parentElement.replaceChild(wrapper, table);
wrapper.appendChild(table);
});
}
_refactorToc(toc) {
// when headings do not start with `h1`
const oldTocList = toc.children[0];
let newTocList = oldTocList;
let temp;
while (newTocList.children.length === 1
&& (temp = newTocList.children[0].children[0]).tagName === 'UL') {
newTocList = temp;
}
if (newTocList !== oldTocList) toc.replaceChild(newTocList, oldTocList);
}
_linkToc() {
forEachElement(document.querySelectorAll('#TableOfContents a:first-child'), (link) => {
link.classList.add('toc-link');
});
for (let num = 1; num <= 6; num++) {
forEachElement(document.querySelectorAll('.content > h' + num), (header) => {
header.classList.add('headerLink');
header.innerHTML = `<a href="#${header.id}"></a>${header.innerHTML}`;
});
const searchActiveTocIndex = function(array, target) {
for (let i = 0; i < array.length - 1; i++) {
if ( target < array[i + 1]) return i;
}
return array.length - 1;
};
const activeTocIndex = searchActiveTocIndex(headerlinkTop, scrollTop);
$($toclink).removeClass('active');
$($tocLinkLis).removeClass('has-active');
if (activeTocIndex !== -1) {
$($toclink[activeTocIndex]).addClass('active');
let ancestor = $toclink[activeTocIndex].parentNode;
while (ancestor.tagName !== 'NAV') {
$(ancestor).addClass('has-active');
ancestor = ancestor.parentNode.parentNode;
}
}
};
activeIndex();
if (!this._initTocOnce) {
$(window).scroll(changeTocState);
$(window).scroll(activeIndex);
this._initTocOnce = true;
}
}
};
_Theme.toc = function () {
const tocContainer = document.getElementById('post-toc');
if (tocContainer !== null) {
const toc = document.getElementById('TableOfContents');
if (toc === null) {
// toc = true, but there are no headings
tocContainer.parentNode.removeChild(tocContainer);
} else {
this._refactorToc(toc);
this._linkToc();
this._initToc();
// Listen for orientation changes
_initTocState() {
const toc = document.getElementById('post-toc');
if (toc && window.getComputedStyle(toc, null).display !== 'none') {
const HEADER_SPACING = 80;
const minTop = toc.offsetTop;
const minScrollTop = minTop - HEADER_SPACING;
const footerTop = document.getElementById('post-footer').offsetTop;
const toclinks = toc.getElementsByClassName('toc-link');
const headerLinks = document.getElementsByClassName('headerLink') || [];
const tocLinkLis = toc.querySelectorAll('.post-toc-content li');
const INDEX_SPACING = 10;
const changeTocState = () => {
const scrollTop = document.documentElement.scrollTop;
const maxTop = footerTop - toc.getBoundingClientRect().height;
const maxScrollTop = maxTop - HEADER_SPACING;
if (scrollTop < minScrollTop) {
toc.style.position = 'absolute';
toc.style.top = `${minTop}px`;
} else if (scrollTop > maxScrollTop) {
toc.style.position = 'absolute';
toc.style.top = `${maxTop}px`;
} else {
toc.style.position = 'fixed';
toc.style.top = `${HEADER_SPACING}px`;
}
forEachElement(toclinks, (link) => { link.classList.remove('active'); });
forEachElement(tocLinkLis, (link) => { link.classList.remove('has-active'); });
let activeTocIndex = headerLinks.length - 1;
for (let i = 0; i < headerLinks.length - 1; i++) {
const thisTop = headerLinks[i].getBoundingClientRect().top;
const nextTop = headerLinks[i + 1].getBoundingClientRect().top;
if ((i == 0 && thisTop > INDEX_SPACING)
|| (thisTop <= INDEX_SPACING && nextTop > INDEX_SPACING)) {
activeTocIndex = i;
break;
}
}
if (activeTocIndex !== -1) {
toclinks[activeTocIndex].classList.add('active');
let parent = toclinks[activeTocIndex].parentElement;
while (parent.tagName !== 'NAV') {
parent.classList.add('has-active');
parent = parent.parentElement.parentElement;
}
}
};
changeTocState();
if (!this._initTocOnce) {
window.onscroll = changeTocState;
this._initTocOnce = true;
}
}
}
initToc() {
const tocContainer = document.getElementById('post-toc');
if (tocContainer !== null) {
const toc = document.getElementById('TableOfContents');
if (toc === null) {
tocContainer.parentElement.removeChild(tocContainer);
} else {
this._refactorToc(toc);
this._linkToc();
this._initTocState();
window.addEventListener("resize", () => {
window.setTimeout(this._initTocState, 0);
}, false);
}
}
}
initMermaid() {
if (window.mermaidMap) {
mermaid.initialize({startOnLoad: false, theme: null});
Object.keys(mermaidMap).forEach((id) => {
const element = document.getElementById(id);
mermaid.mermaidAPI.render("d" + id, mermaidMap[id], (svgCode) => {
element.innerHTML = svgCode;
const svg = element.firstChild;
svg.style.width = "100%"
}, element);
});
}
}
initEcharts() {
if (window.echartsMap) {
for (let i = 0; i < echartsArr.length; i++) {
echartsArr[i].dispose();
}
echartsArr = [];
Object.keys(echartsMap).forEach((id) => {
let myChart = echarts.init(document.getElementById(id), window.isDark ? 'dark' : 'macarons', {renderer: 'svg'});
myChart.setOption(echartsMap[id]);
echartsArr.push(myChart);
});
window.addEventListener("resize", function () {
this.setTimeout(_Theme._initToc, 0);
this.setTimeout(() => {
for (let i = 0; i < echartsArr.length; i++) {
echartsArr[i].resize();
}
}, 0);
}, false);
}
}
};
_Theme.mermaid = function () {
if (window.mermaidMap) {
mermaid.initialize({startOnLoad: false, theme: null});
const mermaidAPI = mermaid.mermaidAPI
Object.keys(mermaidMap).forEach((id) => {
const element = document.getElementById(id);
mermaidAPI.render("d" + id, mermaidMap[id], (svgCode) => {
element.innerHTML = svgCode;
const svg = element.firstChild;
svg.style.width = "100%"
}, element);
});
}
}
_Theme.echarts = function () {
if (window.echartsMap) {
for (let i = 0; i < echartsArr.length; i++) {
echartsArr[i].dispose();
}
echartsArr = [];
Object.keys(echartsMap).forEach((id) => {
let myChart = echarts.init(document.getElementById(id), window.isDark ? 'dark' : 'macarons', {renderer: 'svg'});
myChart.setOption(echartsMap[id]);
echartsArr.push(myChart);
});
window.addEventListener("resize", function () {
this.setTimeout(() => {
for (let i = 0; i < echartsArr.length; i++) {
echartsArr[i].resize();
}
}, 0);
}, false);
}
}
_Theme.countdown = function () {
if (window.countdownMap) {
Object.keys(countdownMap).forEach(function(id) {
$(`#${id}`).countdown(countdownMap[id]['date'], {elapse: true})
.on('update.countdown', function(event) {
$(this).html(event.strftime(countdownMap[id]['pattern']));
});
});
}
};
_Theme.typeit = function () {
if (window.typeitArr) {
for (let i = 0; i < typeitArr.length; i++) {
const group = typeitArr[i];
(function typeone(i) {
const content = document.getElementById(`r${group[i]}`).innerHTML;
if (i === group.length - 1) {
new TypeIt(`#${group[i]}`, {
initTypeit() {
if (window.typeitArr) {
for (let i = 0; i < typeitArr.length; i++) {
const group = typeitArr[i];
(function typeone(i) {
const content = document.getElementById(`r${group[i]}`).innerHTML;
if (i === group.length - 1) {
new TypeIt(`#${group[i]}`, {
strings: content,
}).go();
return;
}
let instance = new TypeIt(`#${group[i]}`, {
strings: content,
afterComplete: () => {
instance.destroy();
typeone(i + 1);
},
}).go();
return;
}
let instance = new TypeIt(`#${group[i]}`, {
strings: content,
afterComplete: () => {
instance.destroy();
typeone(i + 1);
},
}).go();
})(0);
})(0);
}
}
}
init() {
this.initSmoothScroll();
this.initMobileMenu();
this.initSwitchTheme();
this.initDynamicToTop();
this.initHighlight();
this.initTable();
this.initMermaid();
this.initEcharts();
this.initTypeit();
this.initToc();
}
}
const themeInit = () => {
const theme = new Theme();
theme.init();
};
$(document).ready(() => {
_Theme.scroll();
_Theme.toggleMobileMenu();
_Theme.toggleTheme();
_Theme.dynamicToTop();
_Theme.chroma();
_Theme.responsiveTable();
_Theme.mermaid();
_Theme.echarts();
_Theme.countdown();
_Theme.typeit();
_Theme.toc();
});
});
if (document.readyState !== 'loading') {
themeInit();
} else {
document.addEventListener('DOMContentLoaded', themeInit);
}
})();

View file

@ -167,7 +167,6 @@ dateFormatToUse = "2006-01-02"
gitalk_css = ''
gitalk_js = ''
valine_js = ''
jquery_js = ''
lazysizes_js = ''
smooth_scroll_js = ''
katex_css = ''
@ -180,7 +179,6 @@ dateFormatToUse = "2006-01-02"
echarts_js = ''
echarts_macarons_js = ''
typeit_js = ''
jquery_countdown_js = ''
aplayer_css = ''
aplayer_js = ''
meting_js = ''

View file

@ -52,7 +52,6 @@ It is based on the original [LeaveIt Theme](https://github.com/liuzc/LeaveIt/) a
* :(far fa-bell): Kinds of admonitions shortcode support
* :(fas fa-align-left): Custom align and float style shortcodes support
* :(fas fa-i-cursor): Animated typing support by [TypeIt](https://typeitjs.com/)
* :(far fa-clock): Animated coutdown support by [jQuery.countdown](https://github.com/hilios/jQuery.countdown)
* :(fas fa-arrow-up): Dynamic to top support by [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
* ...
@ -69,8 +68,6 @@ Thanks to the authors of following resources included in the theme:
* [lazysizes](https://github.com/aFarkas/lazysizes)
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
* [TypeIt](https://typeitjs.com/)
* [jQuery](https://github.com/jquery/jquery)
* [jQuery.countdown](https://github.com/hilios/jQuery.countdown)
* [Katex](https://katex.org/)
* [mermaid](https://github.com/knsv/mermaid)
* [APlayer](https://github.com/MoePlayer/APlayer)

View file

@ -167,7 +167,6 @@ dateFormatToUse = "2006-01-02"
gitalk_css = ''
gitalk_js = ''
valine_js = ''
jquery_js = ''
lazysizes_js = ''
smooth_scroll_js = ''
katex_css = ''
@ -180,7 +179,6 @@ dateFormatToUse = "2006-01-02"
echarts_js = ''
echarts_macarons_js = ''
typeit_js = ''
jquery_countdown_js = ''
aplayer_css = ''
aplayer_js = ''
meting_js = ''

View file

@ -52,7 +52,6 @@ draft: false
* :(far fa-bell): 支持多种提醒样式的 shortcode
* :(fas fa-align-left): 支持自定义对齐和浮动方式的 shortcode
* :(fas fa-i-cursor): 支持基于 [TypeIt](https://typeitjs.com/) 的打字动画
* :(far fa-clock): 支持基于 [jQuery.countdown](https://github.com/hilios/jQuery.countdown) 的倒计时动画
* :(fas fa-arrow-up): 支持基于 [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll) 的回到顶部动画
* ...
@ -69,8 +68,6 @@ LoveIt 根据 MIT 许可协议授权。
* [lazysizes](https://github.com/aFarkas/lazysizes)
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
* [TypeIt](https://typeitjs.com/)
* [jQuery](https://github.com/jquery/jquery)
* [jQuery.countdown](https://github.com/hilios/jQuery.countdown)
* [Katex](https://katex.org/)
* [mermaid](https://github.com/knsv/mermaid)
* [APlayer](https://github.com/MoePlayer/APlayer)

View file

@ -52,7 +52,7 @@
</div>
{{- /* Dynamic to top button */ -}}
<a href="#" class="dynamic-to-top" id="dynamic-to-top" data-scroll>
<a href="#" class="dynamic-to-top" id="dynamic-to-top" smooth-scroll>
<span>&nbsp;</span>
</a>

View file

@ -25,11 +25,6 @@
{{- $REout = `↩︎` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- /* Dummy target */ -}}
{{- $REin = `<(h[23456]) (id=".+?")>` -}}
{{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- /* Dummy target */ -}}
{{- $REin = `<(.+) (id="fnref:.+?")>` -}}
{{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}}

View file

@ -5,13 +5,6 @@
{{- template "_internal/google_analytics_async.html" . -}}
{{- end -}}
{{- /* jQuery https://github.com/jquery/jquery */ -}}
{{- with $CDN.jquery_js -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/jquery/jquery.slim.min.js" | .Scratch.Add "scriptLocal" -}}
{{- end -}}
{{- /* lazysizes https://github.com/aFarkas/lazysizes */ -}}
{{- with $CDN.lazysizes_js -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
@ -133,18 +126,6 @@
{{- end -}}
{{- end -}}
{{- /* jQuery.countdown https://github.com/hilios/jQuery.countdown */ -}}
{{- with .Scratch.Get "countdownMap" -}}
{{- with $CDN.jquery_countdown_js -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/jquery-countdown/jquery.countdown.min.js" | $.Scratch.Add "scriptLocal" -}}
{{- end -}}
<script>
window.countdownMap = {{ jsonify . | safeJS }};
</script>
{{- end -}}
{{- /* dev feature */ -}}
{{- if .Params.dev -}}
{{- /* ECharts https://github.com/apache/incubator-echarts */ -}}

View file

@ -1,12 +0,0 @@
{{- if .Get "date" -}}
{{- $date := .Get "date" -}}
{{- $id := delimit (split (md5 $date) "" | shuffle) "" | printf "countdown-%s" -}}
{{- $defaultPattern := printf "%%D %s %%H %s %%M %s %%S %s" (T "day") (T "hour") (T "minute") (T "second") -}}
{{- $new := dict $id (dict "date" $date "pattern" (.Get "pattern" | default $defaultPattern)) -}}
{{- with .Page.Scratch.Get "countdownMap" -}}
{{- .Page.Scratch.Set "countdownMap" (merge . $new) -}}
{{- else -}}
{{- .Page.Scratch.Set "countdownMap" $new -}}
{{- end -}}
<div id="{{ $id }}" style={{ .Get "style" | safeCSS }}></div>
{{- end -}}