hexo-theme-shokax 0.4.6-dev2 → 0.4.6-dev3
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/toolbox/lib.mjs +38 -24
- package/scripts/filters/locals.js +0 -52
- package/scripts/filters/post.js +0 -5
- package/scripts/generaters/archive.js +0 -133
- package/scripts/generaters/config.js +0 -51
- package/scripts/generaters/images.js +0 -23
- package/scripts/generaters/index.js +0 -107
- package/scripts/generaters/pages.js +0 -15
- package/scripts/generaters/script.js +0 -156
- package/scripts/helpers/asset.js +0 -73
- package/scripts/helpers/engine.js +0 -177
- package/scripts/helpers/list_categories.js +0 -80
- package/scripts/helpers/summary_ai.js +0 -107
- package/scripts/helpers/symbols_count_time.js +0 -69
- package/scripts/plugin/check.js +0 -32
- package/scripts/plugin/index.js +0 -81
- package/scripts/plugin/lib/injects-point.js +0 -20
- package/scripts/plugin/lib/injects.js +0 -89
- package/scripts/tags/links.js +0 -44
- package/scripts/tags/media.js +0 -19
- package/scripts/utils.js +0 -13
- package/source/js/_app/components/comments.js +0 -59
- package/source/js/_app/components/sidebar.js +0 -244
- package/source/js/_app/components/tcomments.js +0 -47
- package/source/js/_app/globals/handles.js +0 -105
- package/source/js/_app/library/loadFile.js +0 -43
- package/source/js/_app/library/vue.js +0 -52
- package/source/js/_app/page/common.js +0 -45
- package/source/js/_app/page/fancybox.js +0 -70
- package/source/js/_app/page/post.js +0 -253
- package/source/js/_app/page/search.js +0 -111
- package/source/js/_app/pjax/domInit.js +0 -80
- package/source/js/_app/pjax/refresh.js +0 -137
- package/source/js/_app/pjax/siteInit.js +0 -115
- package/source/js/_app/player.js +0 -777
@@ -1,52 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.initVue = void 0;
|
4
|
-
const storage_1 = require("./storage");
|
5
|
-
const anime_1 = require("./anime");
|
6
|
-
const dom_1 = require("./dom");
|
7
|
-
const globalVars_1 = require("../globals/globalVars");
|
8
|
-
const themeColor_1 = require("../globals/themeColor");
|
9
|
-
const proto_1 = require("./proto");
|
10
|
-
function initVue() {
|
11
|
-
function changeThemeByBtn() {
|
12
|
-
let c;
|
13
|
-
const btn = (0, proto_1.child)((0, dom_1.$dom)('.theme'), '.ic');
|
14
|
-
const neko = (0, proto_1.createChild)(globalVars_1.BODY, 'div', {
|
15
|
-
id: 'neko',
|
16
|
-
innerHTML: '<div class="planet"><div class="sun"></div><div class="moon"></div></div><div class="body"><div class="face"><section class="eyes left"><span class="pupil"></span></section><section class="eyes right"><span class="pupil"></span></section><span class="nose"></span></div></div>'
|
17
|
-
});
|
18
|
-
const hideNeko = () => {
|
19
|
-
(0, anime_1.transition)(neko, {
|
20
|
-
// @ts-ignore
|
21
|
-
delay: 2500,
|
22
|
-
opacity: 0
|
23
|
-
}, () => {
|
24
|
-
globalVars_1.BODY.removeChild(neko);
|
25
|
-
});
|
26
|
-
};
|
27
|
-
if (btn.hasClass('i-sun')) {
|
28
|
-
c = () => {
|
29
|
-
neko.addClass('dark');
|
30
|
-
(0, themeColor_1.changeTheme)('dark');
|
31
|
-
storage_1.$storage.set('theme', 'dark');
|
32
|
-
hideNeko();
|
33
|
-
};
|
34
|
-
}
|
35
|
-
else {
|
36
|
-
neko.addClass('dark');
|
37
|
-
c = () => {
|
38
|
-
neko.removeClass('dark');
|
39
|
-
(0, themeColor_1.changeTheme)();
|
40
|
-
storage_1.$storage.set('theme', 'light');
|
41
|
-
hideNeko();
|
42
|
-
};
|
43
|
-
}
|
44
|
-
(0, anime_1.transition)(neko, 1, () => {
|
45
|
-
setTimeout(c, 210);
|
46
|
-
}, () => {
|
47
|
-
(0, proto_1.setDisplay)(neko, 'block');
|
48
|
-
});
|
49
|
-
}
|
50
|
-
(0, proto_1.child)((0, dom_1.$dom)('#rightNav'), '.theme .ic').addEventListener('click', changeThemeByBtn);
|
51
|
-
}
|
52
|
-
exports.initVue = initVue;
|
@@ -1,45 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.cardActive = void 0;
|
4
|
-
const dom_1 = require("../library/dom");
|
5
|
-
const cardActive = () => {
|
6
|
-
if (!(0, dom_1.$dom)('.index.wrap')) {
|
7
|
-
return;
|
8
|
-
}
|
9
|
-
const io = new IntersectionObserver((entries) => {
|
10
|
-
entries.forEach((article) => {
|
11
|
-
if (article.target.hasClass('show')) {
|
12
|
-
io.unobserve(article.target);
|
13
|
-
}
|
14
|
-
else {
|
15
|
-
if (article.isIntersecting || article.intersectionRatio > 0) {
|
16
|
-
article.target.addClass('show');
|
17
|
-
io.unobserve(article.target);
|
18
|
-
}
|
19
|
-
}
|
20
|
-
});
|
21
|
-
}, {
|
22
|
-
root: null,
|
23
|
-
threshold: [0.3]
|
24
|
-
});
|
25
|
-
dom_1.$dom.each('.index.wrap article.item, .index.wrap section.item', (article) => {
|
26
|
-
io.observe(article);
|
27
|
-
});
|
28
|
-
(0, dom_1.$dom)('.index.wrap .item:first-child').addClass('show');
|
29
|
-
dom_1.$dom.each('.cards .item', (element) => {
|
30
|
-
['mouseenter', 'touchstart'].forEach((item) => {
|
31
|
-
element.addEventListener(item, () => {
|
32
|
-
if ((0, dom_1.$dom)('.cards .item.active')) {
|
33
|
-
(0, dom_1.$dom)('.cards .item.active').removeClass('active');
|
34
|
-
}
|
35
|
-
element.addClass('active');
|
36
|
-
}, { passive: true });
|
37
|
-
});
|
38
|
-
['mouseleave'].forEach((item) => {
|
39
|
-
element.addEventListener(item, () => {
|
40
|
-
element.removeClass('active');
|
41
|
-
}, { passive: true });
|
42
|
-
});
|
43
|
-
});
|
44
|
-
};
|
45
|
-
exports.cardActive = cardActive;
|
@@ -1,70 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.postFancybox = void 0;
|
4
|
-
const dom_1 = require("../library/dom");
|
5
|
-
const loadFile_1 = require("../library/loadFile");
|
6
|
-
const proto_1 = require("../library/proto");
|
7
|
-
const postFancybox = (p) => {
|
8
|
-
if ((0, dom_1.$dom)(p + ' .md img')) {
|
9
|
-
(0, loadFile_1.vendorCss)('fancybox');
|
10
|
-
(0, loadFile_1.vendorCss)('justifiedGallery');
|
11
|
-
(0, loadFile_1.vendorJs)('fancybox', () => {
|
12
|
-
const q = jQuery.noConflict();
|
13
|
-
dom_1.$dom.each(p + ' p.gallery', (element) => {
|
14
|
-
const box = document.createElement('div');
|
15
|
-
box.className = 'gallery';
|
16
|
-
box.setAttribute('data-height', String(element.getAttribute('data-height') || 220));
|
17
|
-
box.innerHTML = element.innerHTML.replace(/<br>/g, '');
|
18
|
-
element.parentNode.insertBefore(box, element);
|
19
|
-
element.remove();
|
20
|
-
});
|
21
|
-
dom_1.$dom.each(p + ' .md img:not(.emoji):not(.vemoji)', (element) => {
|
22
|
-
const $image = q(element);
|
23
|
-
const imageLink = $image.attr('data-src') || $image.attr('src'); // 替换
|
24
|
-
const $imageWrapLink = $image.wrap('<a class="fancybox" href="' + imageLink + '" itemscope itemtype="https://schema.org/ImageObject" itemprop="url"></a>').parent('a');
|
25
|
-
let info;
|
26
|
-
let captionClass = 'image-info';
|
27
|
-
if (!$image.is('a img')) {
|
28
|
-
$image.data('safe-src', imageLink);
|
29
|
-
if (!$image.is('.gallery img')) {
|
30
|
-
$imageWrapLink.attr('data-fancybox', 'default').attr('rel', 'default');
|
31
|
-
}
|
32
|
-
else {
|
33
|
-
captionClass = 'jg-caption';
|
34
|
-
}
|
35
|
-
}
|
36
|
-
if ((info = element.getAttribute('title'))) {
|
37
|
-
$imageWrapLink.attr('data-caption', info);
|
38
|
-
const para = document.createElement('span');
|
39
|
-
const txt = document.createTextNode(info);
|
40
|
-
para.appendChild(txt);
|
41
|
-
para.addClass(captionClass);
|
42
|
-
(0, proto_1.insertAfter)(element, para);
|
43
|
-
}
|
44
|
-
});
|
45
|
-
dom_1.$dom.each(p + ' div.gallery', (el, i) => {
|
46
|
-
// @ts-ignore
|
47
|
-
q(el).justifiedGallery({
|
48
|
-
rowHeight: q(el).data('height') || 120,
|
49
|
-
rel: 'gallery-' + i
|
50
|
-
}).on('jg.complete', function () {
|
51
|
-
q(this).find('a').each((k, ele) => {
|
52
|
-
ele.setAttribute('data-fancybox', 'gallery-' + i);
|
53
|
-
});
|
54
|
-
});
|
55
|
-
});
|
56
|
-
q.fancybox.defaults.hash = false;
|
57
|
-
q(p + ' .fancybox').fancybox({
|
58
|
-
loop: true,
|
59
|
-
// @ts-ignore
|
60
|
-
helpers: {
|
61
|
-
overlay: {
|
62
|
-
locked: false
|
63
|
-
}
|
64
|
-
}
|
65
|
-
});
|
66
|
-
// @ts-ignore
|
67
|
-
}, window.jQuery);
|
68
|
-
}
|
69
|
-
};
|
70
|
-
exports.postFancybox = postFancybox;
|
@@ -1,253 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.postBeauty = void 0;
|
4
|
-
const dom_1 = require("../library/dom");
|
5
|
-
const fancybox_1 = require("./fancybox");
|
6
|
-
const tools_1 = require("../globals/tools");
|
7
|
-
const globalVars_1 = require("../globals/globalVars");
|
8
|
-
const anime_1 = require("../library/anime");
|
9
|
-
const player_1 = require("../player");
|
10
|
-
const proto_1 = require("../library/proto");
|
11
|
-
const postBeauty = () => {
|
12
|
-
if (!(0, dom_1.$dom)('.md')) {
|
13
|
-
return;
|
14
|
-
}
|
15
|
-
if (__shokax_fancybox__) {
|
16
|
-
(0, fancybox_1.postFancybox)('.post.block');
|
17
|
-
}
|
18
|
-
(0, dom_1.$dom)('.post.block').oncopy = (event) => {
|
19
|
-
(0, tools_1.showtip)(LOCAL.copyright);
|
20
|
-
if (LOCAL.nocopy) {
|
21
|
-
event.preventDefault();
|
22
|
-
return;
|
23
|
-
}
|
24
|
-
const copyright = (0, dom_1.$dom)('#copyright');
|
25
|
-
if (window.getSelection().toString().length > 30 && copyright) {
|
26
|
-
event.preventDefault();
|
27
|
-
const author = '# ' + copyright.child('.author').innerText;
|
28
|
-
const link = '# ' + copyright.child('.link').innerText;
|
29
|
-
const license = '# ' + copyright.child('.license').innerText;
|
30
|
-
const htmlData = author + '<br>' + link + '<br>' + license + '<br><br>' + window.getSelection().toString().replace(/\r\n/g, '<br>');
|
31
|
-
const textData = author + '\n' + link + '\n' + license + '\n\n' + window.getSelection().toString().replace(/\r\n/g, '\n');
|
32
|
-
if (event.clipboardData) {
|
33
|
-
event.clipboardData.setData('text/html', htmlData);
|
34
|
-
event.clipboardData.setData('text/plain', textData);
|
35
|
-
}
|
36
|
-
else {
|
37
|
-
// @ts-ignore
|
38
|
-
if (window.clipboardData) {
|
39
|
-
// @ts-ignore
|
40
|
-
return window.clipboardData.setData('text', textData);
|
41
|
-
}
|
42
|
-
}
|
43
|
-
}
|
44
|
-
};
|
45
|
-
dom_1.$dom.each('li ruby', (element) => {
|
46
|
-
let parent = element.parentNode;
|
47
|
-
// @ts-ignore
|
48
|
-
if (element.parentNode.tagName !== 'LI') {
|
49
|
-
parent = element.parentNode.parentNode;
|
50
|
-
}
|
51
|
-
parent.addClass('ruby');
|
52
|
-
});
|
53
|
-
dom_1.$dom.each('ol[start]', (element) => {
|
54
|
-
// @ts-ignore
|
55
|
-
element.style.counterReset = 'counter ' + parseInt(element.getAttribute('start') - 1);
|
56
|
-
});
|
57
|
-
dom_1.$dom.each('.md table', (element) => {
|
58
|
-
(0, proto_1.wrapObject)(element, {
|
59
|
-
className: 'table-container'
|
60
|
-
});
|
61
|
-
});
|
62
|
-
dom_1.$dom.each('.highlight > .table-container', (element) => {
|
63
|
-
element.className = 'code-container';
|
64
|
-
});
|
65
|
-
dom_1.$dom.each('figure.highlight', (element) => {
|
66
|
-
const code_container = element.child('.code-container');
|
67
|
-
const caption = element.child('figcaption');
|
68
|
-
element.insertAdjacentHTML('beforeend', '<div class="operation"><span class="breakline-btn"><i class="ic i-align-left"></i></span><span class="copy-btn"><i class="ic i-clipboard"></i></span><span class="fullscreen-btn"><i class="ic i-expand"></i></span></div>');
|
69
|
-
const copyBtn = element.child('.copy-btn');
|
70
|
-
if (LOCAL.nocopy) {
|
71
|
-
copyBtn.remove();
|
72
|
-
}
|
73
|
-
else {
|
74
|
-
copyBtn.addEventListener('click', (event) => {
|
75
|
-
const target = event.currentTarget;
|
76
|
-
let comma = '';
|
77
|
-
let code = '';
|
78
|
-
code_container.find('pre').forEach((line) => {
|
79
|
-
code += comma + line.innerText;
|
80
|
-
comma = '\n';
|
81
|
-
});
|
82
|
-
(0, tools_1.clipBoard)(code, (result) => {
|
83
|
-
target.child('.ic').className = result ? 'ic i-check' : 'ic i-times';
|
84
|
-
target.blur();
|
85
|
-
(0, tools_1.showtip)(LOCAL.copyright);
|
86
|
-
});
|
87
|
-
}, { passive: true });
|
88
|
-
copyBtn.addEventListener('mouseleave', (event) => {
|
89
|
-
setTimeout(() => {
|
90
|
-
event.target.child('.ic').className = 'ic i-clipboard';
|
91
|
-
}, 1000);
|
92
|
-
});
|
93
|
-
}
|
94
|
-
const breakBtn = element.child('.breakline-btn');
|
95
|
-
breakBtn.addEventListener('click', (event) => {
|
96
|
-
const target = event.currentTarget;
|
97
|
-
if (element.hasClass('breakline')) {
|
98
|
-
element.removeClass('breakline');
|
99
|
-
target.child('.ic').className = 'ic i-align-left';
|
100
|
-
}
|
101
|
-
else {
|
102
|
-
element.addClass('breakline');
|
103
|
-
target.child('.ic').className = 'ic i-align-justify';
|
104
|
-
}
|
105
|
-
});
|
106
|
-
const fullscreenBtn = element.child('.fullscreen-btn');
|
107
|
-
const removeFullscreen = () => {
|
108
|
-
element.removeClass('fullscreen');
|
109
|
-
element.scrollTop = 0;
|
110
|
-
globalVars_1.BODY.removeClass('fullscreen');
|
111
|
-
fullscreenBtn.child('.ic').className = 'ic i-expand';
|
112
|
-
};
|
113
|
-
const fullscreenHandle = () => {
|
114
|
-
if (element.hasClass('fullscreen')) {
|
115
|
-
removeFullscreen();
|
116
|
-
if (code_container && code_container.find('tr').length > 15) {
|
117
|
-
const showBtn = code_container.child('.show-btn');
|
118
|
-
code_container.style.maxHeight = '300px';
|
119
|
-
showBtn.removeClass('open');
|
120
|
-
}
|
121
|
-
(0, anime_1.pageScroll)(element);
|
122
|
-
}
|
123
|
-
else {
|
124
|
-
element.addClass('fullscreen');
|
125
|
-
globalVars_1.BODY.addClass('fullscreen');
|
126
|
-
fullscreenBtn.child('.ic').className = 'ic i-compress';
|
127
|
-
if (code_container && code_container.find('tr').length > 15) {
|
128
|
-
const showBtn = code_container.child('.show-btn');
|
129
|
-
code_container.style.maxHeight = '';
|
130
|
-
showBtn.addClass('open');
|
131
|
-
}
|
132
|
-
}
|
133
|
-
};
|
134
|
-
fullscreenBtn.addEventListener('click', fullscreenHandle);
|
135
|
-
caption && caption.addEventListener('click', fullscreenHandle);
|
136
|
-
if (code_container && code_container.find('tr').length > 15) {
|
137
|
-
code_container.style.maxHeight = '300px';
|
138
|
-
code_container.insertAdjacentHTML('beforeend', '<div class="show-btn"><i class="ic i-angle-down"></i></div>');
|
139
|
-
const showBtn = code_container.child('.show-btn');
|
140
|
-
const hideCode = () => {
|
141
|
-
code_container.style.maxHeight = '300px';
|
142
|
-
showBtn.removeClass('open');
|
143
|
-
};
|
144
|
-
const showCode = () => {
|
145
|
-
code_container.style.maxHeight = '';
|
146
|
-
showBtn.addClass('open');
|
147
|
-
};
|
148
|
-
showBtn.addEventListener('click', () => {
|
149
|
-
if (showBtn.hasClass('open')) {
|
150
|
-
removeFullscreen();
|
151
|
-
hideCode();
|
152
|
-
(0, anime_1.pageScroll)(code_container);
|
153
|
-
}
|
154
|
-
else {
|
155
|
-
showCode();
|
156
|
-
}
|
157
|
-
});
|
158
|
-
}
|
159
|
-
});
|
160
|
-
dom_1.$dom.each('pre.mermaid > svg', (element) => {
|
161
|
-
const temp = element;
|
162
|
-
temp.style.maxWidth = '';
|
163
|
-
});
|
164
|
-
dom_1.$dom.each('.reward button', (element) => {
|
165
|
-
element.addEventListener('click', (event) => {
|
166
|
-
event.preventDefault();
|
167
|
-
const qr = (0, dom_1.$dom)('#qr');
|
168
|
-
if ((0, proto_1.getDisplay)(qr) === 'inline-flex') {
|
169
|
-
(0, anime_1.transition)(qr, 0);
|
170
|
-
}
|
171
|
-
else {
|
172
|
-
(0, anime_1.transition)(qr, 1, () => {
|
173
|
-
(0, proto_1.setDisplay)(qr, 'inline-flex');
|
174
|
-
}); // slideUpBigIn
|
175
|
-
}
|
176
|
-
});
|
177
|
-
});
|
178
|
-
// quiz
|
179
|
-
if (__shokax_quiz__) {
|
180
|
-
dom_1.$dom.each('.quiz > ul.options li', (element) => {
|
181
|
-
element.addEventListener('click', () => {
|
182
|
-
if (element.hasClass('correct')) {
|
183
|
-
element.toggleClass('right');
|
184
|
-
element.parentNode.parentNode.addClass('show');
|
185
|
-
}
|
186
|
-
else {
|
187
|
-
element.toggleClass('wrong');
|
188
|
-
}
|
189
|
-
});
|
190
|
-
});
|
191
|
-
dom_1.$dom.each('.quiz > p', (element) => {
|
192
|
-
element.addEventListener('click', () => {
|
193
|
-
element.parentNode.toggleClass('show');
|
194
|
-
});
|
195
|
-
});
|
196
|
-
dom_1.$dom.each('.quiz > p:first-child', (element) => {
|
197
|
-
const quiz = element.parentNode;
|
198
|
-
let type = 'choice';
|
199
|
-
if (quiz.hasClass('true') || quiz.hasClass('false')) {
|
200
|
-
type = 'true_false';
|
201
|
-
}
|
202
|
-
if (quiz.hasClass('multi')) {
|
203
|
-
type = 'multiple';
|
204
|
-
}
|
205
|
-
if (quiz.hasClass('fill')) {
|
206
|
-
type = 'gap_fill';
|
207
|
-
}
|
208
|
-
if (quiz.hasClass('essay')) {
|
209
|
-
type = 'essay';
|
210
|
-
}
|
211
|
-
element.setAttribute('data-type', LOCAL.quiz[type]);
|
212
|
-
});
|
213
|
-
dom_1.$dom.each('.quiz .mistake', (element) => {
|
214
|
-
element.setAttribute('data-type', LOCAL.quiz.mistake);
|
215
|
-
});
|
216
|
-
}
|
217
|
-
dom_1.$dom.each('div.tags a', (element) => {
|
218
|
-
element.className = ['primary', 'success', 'info', 'warning', 'danger'][Math.floor(Math.random() * 5)];
|
219
|
-
});
|
220
|
-
if (__shokax_player__) {
|
221
|
-
dom_1.$dom.each('.md div.player', (element) => {
|
222
|
-
(0, player_1.mediaPlayer)(element, {
|
223
|
-
type: element.getAttribute('data-type'),
|
224
|
-
mode: 'order',
|
225
|
-
btns: []
|
226
|
-
}).player.load(JSON.parse(element.getAttribute('data-src'))).fetch();
|
227
|
-
});
|
228
|
-
}
|
229
|
-
const angleDown = document.querySelectorAll('.show-btn .i-angle-down');
|
230
|
-
if (angleDown.length) {
|
231
|
-
const io = new IntersectionObserver((entries) => {
|
232
|
-
entries.forEach(entry => {
|
233
|
-
if (entry.isIntersecting) {
|
234
|
-
angleDown.forEach(i => {
|
235
|
-
i.classList.remove('stop-animation');
|
236
|
-
});
|
237
|
-
}
|
238
|
-
else {
|
239
|
-
angleDown.forEach(i => {
|
240
|
-
i.classList.add('stop-animation');
|
241
|
-
});
|
242
|
-
}
|
243
|
-
});
|
244
|
-
}, {
|
245
|
-
root: null,
|
246
|
-
threshold: 0.5
|
247
|
-
});
|
248
|
-
angleDown.forEach(i => {
|
249
|
-
io.observe(i);
|
250
|
-
});
|
251
|
-
}
|
252
|
-
};
|
253
|
-
exports.postBeauty = postBeauty;
|
@@ -1,111 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.algoliaSearch = void 0;
|
7
|
-
const globalVars_1 = require("../globals/globalVars");
|
8
|
-
const anime_1 = require("../library/anime");
|
9
|
-
const dom_1 = require("../library/dom");
|
10
|
-
const widgets_1 = require("instantsearch.js/es/widgets");
|
11
|
-
const instantsearch_js_1 = __importDefault(require("instantsearch.js"));
|
12
|
-
const lite_1 = __importDefault(require("algoliasearch/lite"));
|
13
|
-
function algoliaSearch(pjax) {
|
14
|
-
const search = (0, instantsearch_js_1.default)({
|
15
|
-
indexName: globalVars_1.CONFIG.search.indexName,
|
16
|
-
searchClient: (0, lite_1.default)(globalVars_1.CONFIG.search.appID, globalVars_1.CONFIG.search.apiKey),
|
17
|
-
// TODO 移除弃用函数
|
18
|
-
searchFunction(helper) {
|
19
|
-
const searchInput = (0, dom_1.$dom)('.search-input');
|
20
|
-
if (searchInput.value) {
|
21
|
-
helper.search();
|
22
|
-
}
|
23
|
-
}
|
24
|
-
});
|
25
|
-
search.on('render', () => {
|
26
|
-
pjax.refresh((0, dom_1.$dom)('#search-hits'));
|
27
|
-
});
|
28
|
-
// Registering Widgets
|
29
|
-
search.addWidgets([
|
30
|
-
(0, widgets_1.configure)({
|
31
|
-
hitsPerPage: globalVars_1.CONFIG.search.hits.per_page || 10
|
32
|
-
}),
|
33
|
-
(0, widgets_1.searchBox)({
|
34
|
-
container: '.search-input-container',
|
35
|
-
placeholder: LOCAL.search.placeholder,
|
36
|
-
// Hide default icons of algolia search
|
37
|
-
showReset: false,
|
38
|
-
showSubmit: false,
|
39
|
-
showLoadingIndicator: false,
|
40
|
-
cssClasses: {
|
41
|
-
input: 'search-input'
|
42
|
-
}
|
43
|
-
}),
|
44
|
-
(0, widgets_1.stats)({
|
45
|
-
container: '#search-stats',
|
46
|
-
templates: {
|
47
|
-
text(data) {
|
48
|
-
const stats = LOCAL.search.stats
|
49
|
-
.replace(/\$\{hits}/, data.nbHits.toString())
|
50
|
-
.replace(/\$\{time}/, data.processingTimeMS.toString());
|
51
|
-
return stats + '<span class="algolia-powered"></span><hr>';
|
52
|
-
}
|
53
|
-
}
|
54
|
-
}),
|
55
|
-
(0, widgets_1.hits)({
|
56
|
-
container: '#search-hits',
|
57
|
-
templates: {
|
58
|
-
item(data) {
|
59
|
-
const cats = data.categories ? '<span>' + data.categories.join('<i class="ic i-angle-right"></i>') + '</span>' : '';
|
60
|
-
return '<a href="' + globalVars_1.CONFIG.root + data.path + '">' + cats + data._highlightResult.title.value + '</a>';
|
61
|
-
},
|
62
|
-
empty(data) {
|
63
|
-
return '<div id="hits-empty">' +
|
64
|
-
LOCAL.search.empty.replace(/\$\{query}/, data.query) +
|
65
|
-
'</div>';
|
66
|
-
}
|
67
|
-
},
|
68
|
-
cssClasses: {
|
69
|
-
item: 'item'
|
70
|
-
}
|
71
|
-
}),
|
72
|
-
(0, widgets_1.pagination)({
|
73
|
-
container: '#search-pagination',
|
74
|
-
scrollTo: false,
|
75
|
-
showFirst: false,
|
76
|
-
showLast: false,
|
77
|
-
templates: {
|
78
|
-
first: '<i class="ic i-angle-double-left"></i>',
|
79
|
-
last: '<i class="ic i-angle-double-right"></i>',
|
80
|
-
previous: '<i class="ic i-angle-left"></i>',
|
81
|
-
next: '<i class="ic i-angle-right"></i>'
|
82
|
-
},
|
83
|
-
cssClasses: {
|
84
|
-
root: 'pagination',
|
85
|
-
item: 'pagination-item',
|
86
|
-
link: 'page-number',
|
87
|
-
selectedItem: 'current',
|
88
|
-
disabledItem: 'disabled-item'
|
89
|
-
}
|
90
|
-
})
|
91
|
-
]);
|
92
|
-
search.start();
|
93
|
-
// Monitor main search box
|
94
|
-
const onPopupClose = () => {
|
95
|
-
document.body.style.overflow = '';
|
96
|
-
(0, anime_1.transition)(globalVars_1.siteSearch, 0); // "transition.shrinkOut"
|
97
|
-
};
|
98
|
-
globalVars_1.siteSearch.addEventListener('click', (event) => {
|
99
|
-
if (event.target === globalVars_1.siteSearch) {
|
100
|
-
onPopupClose();
|
101
|
-
}
|
102
|
-
});
|
103
|
-
(0, dom_1.$dom)('.close-btn').addEventListener('click', onPopupClose);
|
104
|
-
window.addEventListener('pjax:success', onPopupClose);
|
105
|
-
window.addEventListener('keyup', (event) => {
|
106
|
-
if (event.key === 'Escape') {
|
107
|
-
onPopupClose();
|
108
|
-
}
|
109
|
-
});
|
110
|
-
}
|
111
|
-
exports.algoliaSearch = algoliaSearch;
|
@@ -1,80 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const sidebar_1 = require("../components/sidebar");
|
4
|
-
const globalVars_1 = require("../globals/globalVars");
|
5
|
-
const thirdparty_1 = require("../globals/thirdparty");
|
6
|
-
const dom_1 = require("../library/dom");
|
7
|
-
const player_1 = require("../player");
|
8
|
-
const proto_1 = require("../library/proto");
|
9
|
-
function domInit() {
|
10
|
-
dom_1.$dom.each('.overview .menu > .item', (el) => {
|
11
|
-
(0, proto_1.child)(globalVars_1.siteNav, '.menu').appendChild(el.cloneNode(true));
|
12
|
-
});
|
13
|
-
globalVars_1.loadCat.addEventListener('click', thirdparty_1.Loader.vanish);
|
14
|
-
globalVars_1.menuToggle.addEventListener('click', sidebar_1.sideBarToggleHandle);
|
15
|
-
(0, dom_1.$dom)('.dimmer').addEventListener('click', sidebar_1.sideBarToggleHandle);
|
16
|
-
(0, proto_1.child)(globalVars_1.quickBtn, '.down').addEventListener('click', sidebar_1.goToBottomHandle);
|
17
|
-
(0, proto_1.child)(globalVars_1.quickBtn, '.up').addEventListener('click', sidebar_1.backToTopHandle);
|
18
|
-
if (!globalVars_1.toolBtn) {
|
19
|
-
(0, globalVars_1.setToolBtn)((0, proto_1.createChild)(globalVars_1.siteHeader, 'div', {
|
20
|
-
id: 'tool',
|
21
|
-
innerHTML: '<div class="item player"></div><div class="item contents"><i class="ic i-list-ol"></i></div><div class="item chat"><i class="ic i-comments"></i></div><div class="item back-to-top"><i class="ic i-arrow-up"></i><span>0%</span></div>'
|
22
|
-
}));
|
23
|
-
}
|
24
|
-
(0, globalVars_1.setToolPlayer)(globalVars_1.toolBtn.child('.player'));
|
25
|
-
(0, globalVars_1.setBackToTop)(globalVars_1.toolBtn.child('.back-to-top'));
|
26
|
-
(0, globalVars_1.setGoToComment)(globalVars_1.toolBtn.child('.chat'));
|
27
|
-
(0, globalVars_1.setShowContents)(globalVars_1.toolBtn.child('.contents'));
|
28
|
-
globalVars_1.backToTop.addEventListener('click', sidebar_1.backToTopHandle);
|
29
|
-
globalVars_1.goToComment.addEventListener('click', sidebar_1.goToCommentHandle);
|
30
|
-
globalVars_1.showContents.addEventListener('click', sidebar_1.sideBarToggleHandle);
|
31
|
-
if (__shokax_player__) {
|
32
|
-
(0, player_1.mediaPlayer)(globalVars_1.toolPlayer);
|
33
|
-
(0, dom_1.$dom)('main').addEventListener('click', () => {
|
34
|
-
globalVars_1.toolPlayer.player.mini();
|
35
|
-
});
|
36
|
-
}
|
37
|
-
const createIntersectionObserver = () => {
|
38
|
-
// waves在视口外时停止动画
|
39
|
-
new IntersectionObserver(([entry]) => {
|
40
|
-
if (entry.isIntersecting) {
|
41
|
-
document.querySelectorAll('.parallax>use').forEach(i => {
|
42
|
-
i.classList.remove('stop-animation');
|
43
|
-
});
|
44
|
-
document.querySelectorAll('#imgs .item').forEach(i => {
|
45
|
-
i.classList.remove('stop-animation');
|
46
|
-
});
|
47
|
-
}
|
48
|
-
else {
|
49
|
-
document.querySelectorAll('.parallax>use').forEach(i => {
|
50
|
-
i.classList.add('stop-animation');
|
51
|
-
});
|
52
|
-
// waves不可见时imgs也应该不可见了
|
53
|
-
document.querySelectorAll('#imgs .item').forEach(i => {
|
54
|
-
i.classList.add('stop-animation');
|
55
|
-
});
|
56
|
-
}
|
57
|
-
}, {
|
58
|
-
root: null,
|
59
|
-
threshold: 0.2
|
60
|
-
}).observe(document.getElementById('waves'));
|
61
|
-
// sakura在视口外时停止动画
|
62
|
-
new IntersectionObserver(([entry]) => {
|
63
|
-
if (entry.isIntersecting) {
|
64
|
-
document.querySelectorAll('.with-love>i').forEach(i => {
|
65
|
-
i.classList.remove('stop-animation');
|
66
|
-
});
|
67
|
-
}
|
68
|
-
else {
|
69
|
-
document.querySelectorAll('.with-love>i').forEach(i => {
|
70
|
-
i.classList.add('stop-animation');
|
71
|
-
});
|
72
|
-
}
|
73
|
-
}, {
|
74
|
-
root: null,
|
75
|
-
threshold: 0.2
|
76
|
-
}).observe(document.querySelector('.with-love'));
|
77
|
-
};
|
78
|
-
createIntersectionObserver();
|
79
|
-
}
|
80
|
-
exports.default = domInit;
|