hexo-theme-shokax 0.2.8 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattribute +1 -0
- package/README.md +4 -4
- package/README_en.MD +4 -4
- package/_config.yml +5 -5
- package/_images.yml +1 -1
- package/layout/_mixin/comment.pug +2 -1
- package/layout/_partials/footer.pug +1 -1
- package/layout/_partials/layout.pug +9 -8
- package/layout/_partials/post/nav.pug +1 -1
- package/layout/_partials/third-party/google-analytics.pug +10 -0
- package/layout/post.pug +2 -1
- package/package.json +10 -12
- package/scripts/helpers/asset.js +1 -1
- package/scripts/plugin/lib/injects.js +4 -0
- package/source/css/_common/components/tags/tabs.styl +0 -1
- package/source/css/_common/scaffolding/base.styl +4 -3
- package/source/css/comment.styl +0 -2
- package/source/js/_app/components.js +26 -27
- package/source/js/_app/fireworks.js +28 -42
- package/source/js/_app/global.js +23 -23
- package/source/js/_app/library.js +38 -43
- package/source/js/_app/page.js +76 -77
- package/source/js/_app/player.js +87 -91
- package/source/js/_app/vue.js +6 -6
package/source/js/_app/global.js
CHANGED
@@ -24,7 +24,7 @@ let oWinWidth = window.innerWidth;
|
|
24
24
|
let LOCAL_HASH = 0;
|
25
25
|
let LOCAL_URL = window.location.href;
|
26
26
|
let pjax;
|
27
|
-
const changeTheme =
|
27
|
+
const changeTheme = (type) => {
|
28
28
|
const btn = $dom('.theme .ic');
|
29
29
|
if (type === 'dark') {
|
30
30
|
HTML.attr('data-theme', type);
|
@@ -37,7 +37,7 @@ const changeTheme = function (type) {
|
|
37
37
|
btn.addClass('i-sun');
|
38
38
|
}
|
39
39
|
};
|
40
|
-
const autoDarkmode =
|
40
|
+
const autoDarkmode = () => {
|
41
41
|
if (CONFIG.auto_dark.enable) {
|
42
42
|
if (new Date().getHours() >= CONFIG.auto_dark.start || new Date().getHours() <= CONFIG.auto_dark.end) {
|
43
43
|
changeTheme('dark');
|
@@ -48,26 +48,26 @@ const autoDarkmode = function () {
|
|
48
48
|
}
|
49
49
|
};
|
50
50
|
const lazyload = lozad('img, [data-background-image]', {
|
51
|
-
loaded
|
51
|
+
loaded(el) {
|
52
52
|
el.addClass('lozaded');
|
53
53
|
}
|
54
54
|
});
|
55
55
|
const Loader = {
|
56
56
|
timer: undefined,
|
57
57
|
lock: false,
|
58
|
-
show
|
58
|
+
show() {
|
59
59
|
clearTimeout(this.timer);
|
60
60
|
document.body.removeClass('loaded');
|
61
61
|
loadCat.attr('style', 'display:block');
|
62
62
|
Loader.lock = false;
|
63
63
|
},
|
64
|
-
hide
|
64
|
+
hide(sec) {
|
65
65
|
if (!CONFIG.loader.start) {
|
66
66
|
sec = -1;
|
67
67
|
}
|
68
68
|
this.timer = setTimeout(this.vanish, sec || 3000);
|
69
69
|
},
|
70
|
-
vanish
|
70
|
+
vanish() {
|
71
71
|
if (Loader.lock) {
|
72
72
|
return;
|
73
73
|
}
|
@@ -78,14 +78,14 @@ const Loader = {
|
|
78
78
|
Loader.lock = true;
|
79
79
|
}
|
80
80
|
};
|
81
|
-
const changeMetaTheme =
|
81
|
+
const changeMetaTheme = (color) => {
|
82
82
|
if (HTML.attr('data-theme') === 'dark') {
|
83
83
|
color = '#222';
|
84
84
|
}
|
85
85
|
$dom('meta[name="theme-color"]').attr('content', color);
|
86
86
|
};
|
87
|
-
const themeColorListener =
|
88
|
-
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change',
|
87
|
+
const themeColorListener = () => {
|
88
|
+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (mediaQueryList) => {
|
89
89
|
if (mediaQueryList.matches) {
|
90
90
|
changeTheme('dark');
|
91
91
|
}
|
@@ -103,9 +103,9 @@ const themeColorListener = function () {
|
|
103
103
|
}
|
104
104
|
}
|
105
105
|
};
|
106
|
-
const visibilityListener =
|
106
|
+
const visibilityListener = () => {
|
107
107
|
const iconNode = $dom('[rel="icon"]');
|
108
|
-
document.addEventListener('visibilitychange',
|
108
|
+
document.addEventListener('visibilitychange', () => {
|
109
109
|
switch (document.visibilityState) {
|
110
110
|
case 'hidden':
|
111
111
|
iconNode.attr('href', statics + CONFIG.favicon.hidden);
|
@@ -121,14 +121,14 @@ const visibilityListener = function () {
|
|
121
121
|
if (CONFIG.loader.switch) {
|
122
122
|
Loader.hide(1000);
|
123
123
|
}
|
124
|
-
titleTime = setTimeout(
|
124
|
+
titleTime = setTimeout(() => {
|
125
125
|
document.title = originTitle;
|
126
126
|
}, 2000);
|
127
127
|
break;
|
128
128
|
}
|
129
129
|
});
|
130
130
|
};
|
131
|
-
const showtip =
|
131
|
+
const showtip = (msg) => {
|
132
132
|
if (!msg) {
|
133
133
|
return;
|
134
134
|
}
|
@@ -136,14 +136,14 @@ const showtip = function (msg) {
|
|
136
136
|
innerHTML: msg,
|
137
137
|
className: 'tip'
|
138
138
|
});
|
139
|
-
setTimeout(
|
139
|
+
setTimeout(() => {
|
140
140
|
tipbox.addClass('hide');
|
141
|
-
setTimeout(
|
141
|
+
setTimeout(() => {
|
142
142
|
BODY.removeChild(tipbox);
|
143
143
|
}, 300);
|
144
144
|
}, 3000);
|
145
145
|
};
|
146
|
-
const resizeHandle =
|
146
|
+
const resizeHandle = (event) => {
|
147
147
|
siteNavHeight = siteNav.changeOrGetHeight();
|
148
148
|
headerHightInner = siteHeader.changeOrGetHeight();
|
149
149
|
headerHight = headerHightInner + $dom('#waves').changeOrGetHeight();
|
@@ -153,7 +153,7 @@ const resizeHandle = function (event) {
|
|
153
153
|
oWinHeight = window.innerHeight;
|
154
154
|
oWinWidth = window.innerWidth;
|
155
155
|
};
|
156
|
-
const scrollHandle =
|
156
|
+
const scrollHandle = (event) => {
|
157
157
|
const winHeight = window.innerHeight;
|
158
158
|
const docHeight = getDocHeight();
|
159
159
|
const contentVisibilityHeight = docHeight > winHeight ? docHeight - winHeight : document.body.scrollHeight - winHeight;
|
@@ -191,12 +191,12 @@ const scrollHandle = function (event) {
|
|
191
191
|
$dom('.percent').changeOrGetWidth(scrollPercent);
|
192
192
|
}
|
193
193
|
};
|
194
|
-
const pagePosition =
|
194
|
+
const pagePosition = () => {
|
195
195
|
if (CONFIG.auto_scroll) {
|
196
196
|
$storage.set(LOCAL_URL, String(scrollAction.y));
|
197
197
|
}
|
198
198
|
};
|
199
|
-
const positionInit =
|
199
|
+
const positionInit = (comment) => {
|
200
200
|
const anchor = window.location.hash;
|
201
201
|
let target = null;
|
202
202
|
if (LOCAL_HASH) {
|
@@ -218,7 +218,7 @@ const positionInit = function (comment) {
|
|
218
218
|
LOCAL_HASH = 1;
|
219
219
|
}
|
220
220
|
};
|
221
|
-
const clipBoard =
|
221
|
+
const clipBoard = (str, callback) => {
|
222
222
|
if (navigator.clipboard && window.isSecureContext) {
|
223
223
|
navigator.clipboard.writeText(str).then(() => {
|
224
224
|
callback && callback(true);
|
@@ -251,7 +251,7 @@ const clipBoard = function (str, callback) {
|
|
251
251
|
BODY.removeChild(ta);
|
252
252
|
}
|
253
253
|
};
|
254
|
-
const isOutime =
|
254
|
+
const isOutime = () => {
|
255
255
|
let updateTime;
|
256
256
|
if (CONFIG.outime.enable && LOCAL.outime) {
|
257
257
|
const times = document.getElementsByTagName('time');
|
@@ -280,7 +280,7 @@ const isOutime = function () {
|
|
280
280
|
}
|
281
281
|
}
|
282
282
|
};
|
283
|
-
const clickMenu =
|
283
|
+
const clickMenu = () => {
|
284
284
|
const menuElement = $dom('#clickMenu');
|
285
285
|
window.oncontextmenu = function (event) {
|
286
286
|
if (event.ctrlKey) {
|
@@ -308,7 +308,7 @@ const clickMenu = function () {
|
|
308
308
|
}
|
309
309
|
});
|
310
310
|
};
|
311
|
-
window.addEventListener('click',
|
311
|
+
window.addEventListener('click', () => {
|
312
312
|
menuElement.classList.remove('active');
|
313
313
|
});
|
314
314
|
};
|
@@ -9,24 +9,19 @@ $dom.all = (selector, element = document) => {
|
|
9
9
|
return element.querySelectorAll(selector);
|
10
10
|
};
|
11
11
|
$dom.each = (selector, callback, element) => {
|
12
|
-
|
12
|
+
$dom.all(selector, element).forEach(callback);
|
13
13
|
};
|
14
14
|
$dom.asyncify = async (selector, element = document) => {
|
15
|
-
if (selector
|
16
|
-
return element.getElementById(selector.
|
15
|
+
if (selector[0] === '#') {
|
16
|
+
return element.getElementById(selector.substring(1));
|
17
17
|
}
|
18
18
|
return element.querySelector(selector);
|
19
19
|
};
|
20
|
-
$dom.asyncifyAll = async (selector, element = document) => {
|
21
|
-
return element.querySelectorAll(selector);
|
22
|
-
};
|
23
20
|
$dom.asyncifyEach = (selector, callback, element) => {
|
24
|
-
$dom.
|
25
|
-
tmp.forEach(callback);
|
26
|
-
});
|
21
|
+
$dom.all(selector, element).forEach(callback);
|
27
22
|
};
|
28
23
|
Object.assign(HTMLElement.prototype, {
|
29
|
-
createChild
|
24
|
+
createChild(tag, obj, positon) {
|
30
25
|
const child = document.createElement(tag);
|
31
26
|
Object.assign(child, obj);
|
32
27
|
switch (positon) {
|
@@ -42,32 +37,32 @@ Object.assign(HTMLElement.prototype, {
|
|
42
37
|
}
|
43
38
|
return child;
|
44
39
|
},
|
45
|
-
wrapObject
|
40
|
+
wrapObject(obj) {
|
46
41
|
const box = document.createElement('div');
|
47
42
|
Object.assign(box, obj);
|
48
43
|
this.parentNode.insertBefore(box, this);
|
49
44
|
this.parentNode.removeChild(this);
|
50
45
|
box.appendChild(this);
|
51
46
|
},
|
52
|
-
changeOrGetHeight
|
47
|
+
changeOrGetHeight(h) {
|
53
48
|
if (h) {
|
54
49
|
this.style.height = typeof h === 'number' ? h + 'rem' : h;
|
55
50
|
}
|
56
51
|
return this.getBoundingClientRect().height;
|
57
52
|
},
|
58
|
-
changeOrGetWidth
|
53
|
+
changeOrGetWidth(w) {
|
59
54
|
if (w) {
|
60
55
|
this.style.width = typeof w === 'number' ? w + 'rem' : w;
|
61
56
|
}
|
62
57
|
return this.getBoundingClientRect().width;
|
63
58
|
},
|
64
|
-
getTop
|
59
|
+
getTop() {
|
65
60
|
return this.getBoundingClientRect().top;
|
66
61
|
},
|
67
|
-
left
|
62
|
+
left() {
|
68
63
|
return this.getBoundingClientRect().left;
|
69
64
|
},
|
70
|
-
attr
|
65
|
+
attr(type, value) {
|
71
66
|
if (value === null) {
|
72
67
|
return this.removeAttribute(type);
|
73
68
|
}
|
@@ -79,7 +74,7 @@ Object.assign(HTMLElement.prototype, {
|
|
79
74
|
return this.getAttribute(type);
|
80
75
|
}
|
81
76
|
},
|
82
|
-
insertAfter
|
77
|
+
insertAfter(element) {
|
83
78
|
const parent = this.parentNode;
|
84
79
|
if (parent.lastChild === this) {
|
85
80
|
parent.appendChild(element);
|
@@ -88,7 +83,7 @@ Object.assign(HTMLElement.prototype, {
|
|
88
83
|
parent.insertBefore(element, this.nextSibling);
|
89
84
|
}
|
90
85
|
},
|
91
|
-
display
|
86
|
+
display(d) {
|
92
87
|
if (d == null) {
|
93
88
|
return this.style.display;
|
94
89
|
}
|
@@ -97,13 +92,13 @@ Object.assign(HTMLElement.prototype, {
|
|
97
92
|
return this;
|
98
93
|
}
|
99
94
|
},
|
100
|
-
child
|
95
|
+
child(selector) {
|
101
96
|
return $dom(selector, this);
|
102
97
|
},
|
103
|
-
find
|
98
|
+
find(selector) {
|
104
99
|
return $dom.all(selector, this);
|
105
100
|
},
|
106
|
-
_class
|
101
|
+
_class(type, className, display) {
|
107
102
|
const classNames = className.indexOf(' ') ? className.split(' ') : [className];
|
108
103
|
classNames.forEach((name) => {
|
109
104
|
if (type === 'toggle') {
|
@@ -114,34 +109,34 @@ Object.assign(HTMLElement.prototype, {
|
|
114
109
|
}
|
115
110
|
});
|
116
111
|
},
|
117
|
-
addClass
|
112
|
+
addClass(className) {
|
118
113
|
this._class('add', className);
|
119
114
|
return this;
|
120
115
|
},
|
121
|
-
removeClass
|
116
|
+
removeClass(className) {
|
122
117
|
this._class('remove', className);
|
123
118
|
return this;
|
124
119
|
},
|
125
|
-
toggleClass
|
120
|
+
toggleClass(className, display) {
|
126
121
|
this._class('toggle', className, display);
|
127
122
|
return this;
|
128
123
|
},
|
129
|
-
hasClass
|
124
|
+
hasClass(className) {
|
130
125
|
return this.classList.contains(className);
|
131
126
|
}
|
132
127
|
});
|
133
128
|
const $storage = {
|
134
|
-
set
|
129
|
+
set(key, value) {
|
135
130
|
localStorage.setItem(key, value);
|
136
131
|
},
|
137
|
-
get
|
132
|
+
get(key) {
|
138
133
|
return localStorage.getItem(key);
|
139
134
|
},
|
140
|
-
del
|
135
|
+
del(key) {
|
141
136
|
localStorage.removeItem(key);
|
142
137
|
}
|
143
138
|
};
|
144
|
-
const getScript =
|
139
|
+
const getScript = (url, callback, condition) => {
|
145
140
|
if (condition) {
|
146
141
|
callback();
|
147
142
|
}
|
@@ -160,27 +155,27 @@ const getScript = function (url, callback, condition) {
|
|
160
155
|
document.head.appendChild(script);
|
161
156
|
}
|
162
157
|
};
|
163
|
-
const assetUrl =
|
158
|
+
const assetUrl = (asset, type) => {
|
164
159
|
const str = CONFIG[asset][type];
|
165
|
-
if (str.
|
160
|
+
if (str.includes('gh') || str.includes('combine')) {
|
166
161
|
return `https://cdn.jsdelivr.net/${str}`;
|
167
162
|
}
|
168
|
-
if (str.
|
163
|
+
if (str.includes('npm')) {
|
169
164
|
return `https://cdn.jsdelivr.net/${str}`;
|
170
165
|
}
|
171
|
-
if (str.
|
166
|
+
if (str.includes('http')) {
|
172
167
|
return str;
|
173
168
|
}
|
174
169
|
return `/${str}`;
|
175
170
|
};
|
176
|
-
const vendorJs =
|
171
|
+
const vendorJs = (type, callback, condition) => {
|
177
172
|
if (LOCAL[type]) {
|
178
173
|
getScript(assetUrl('js', type), callback || function () {
|
179
174
|
window[type] = true;
|
180
175
|
}, condition || window[type]);
|
181
176
|
}
|
182
177
|
};
|
183
|
-
const vendorCss =
|
178
|
+
const vendorCss = (type, condition) => {
|
184
179
|
if (window['css' + type]) {
|
185
180
|
return;
|
186
181
|
}
|
@@ -205,7 +200,7 @@ const transition = (target, type, complete, begin) => {
|
|
205
200
|
break;
|
206
201
|
case 'bounceUpIn':
|
207
202
|
animation = {
|
208
|
-
begin
|
203
|
+
begin(anim) {
|
209
204
|
target.display('block');
|
210
205
|
},
|
211
206
|
translateY: [
|
@@ -220,7 +215,7 @@ const transition = (target, type, complete, begin) => {
|
|
220
215
|
break;
|
221
216
|
case 'shrinkIn':
|
222
217
|
animation = {
|
223
|
-
begin
|
218
|
+
begin(anim) {
|
224
219
|
target.display('block');
|
225
220
|
},
|
226
221
|
scale: [
|
@@ -233,7 +228,7 @@ const transition = (target, type, complete, begin) => {
|
|
233
228
|
break;
|
234
229
|
case 'slideRightIn':
|
235
230
|
animation = {
|
236
|
-
begin
|
231
|
+
begin(anim) {
|
237
232
|
target.display('block');
|
238
233
|
},
|
239
234
|
translateX: ['100%', '0%'],
|
@@ -256,16 +251,16 @@ const transition = (target, type, complete, begin) => {
|
|
256
251
|
targets: target,
|
257
252
|
duration: 200,
|
258
253
|
easing: 'linear',
|
259
|
-
begin
|
254
|
+
begin() {
|
260
255
|
begin && begin();
|
261
256
|
},
|
262
|
-
complete
|
257
|
+
complete() {
|
263
258
|
target.display(display);
|
264
259
|
complete && complete();
|
265
260
|
}
|
266
261
|
}, animation)).play();
|
267
262
|
};
|
268
|
-
const pjaxScript =
|
263
|
+
const pjaxScript = (element) => {
|
269
264
|
const { text, parentNode, id, className, type, src, dataset } = element;
|
270
265
|
const code = text || element.textContent || element.innerHTML || '';
|
271
266
|
parentNode.removeChild(element);
|
@@ -291,13 +286,13 @@ const pjaxScript = function (element) {
|
|
291
286
|
}
|
292
287
|
parentNode.appendChild(script);
|
293
288
|
};
|
294
|
-
const pageScroll =
|
289
|
+
const pageScroll = (target, offset, complete) => {
|
295
290
|
const opt = {
|
296
291
|
targets: typeof offset === 'number' ? target.parentNode : document.scrollingElement,
|
297
292
|
duration: 500,
|
298
293
|
easing: 'easeInOutQuad',
|
299
294
|
scrollTop: offset || (typeof target === 'number' ? target : (target ? target.getTop() + document.documentElement.scrollTop - siteNavHeight : 0)),
|
300
|
-
complete
|
295
|
+
complete() {
|
301
296
|
complete && complete();
|
302
297
|
}
|
303
298
|
};
|