hexo-theme-shokax 0.3.9 → 0.3.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/README.md +4 -1
  2. package/_config.yml +26 -28
  3. package/layout/_mixin/comment.pug +1 -34
  4. package/layout/_mixin/segment.pug +1 -1
  5. package/layout/_partials/head/head.pug +1 -4
  6. package/layout/_partials/layout.pug +2 -2
  7. package/package.json +18 -17
  8. package/scripts/filters/locals.js +6 -0
  9. package/scripts/filters/post.js +2 -0
  10. package/scripts/generaters/archive.js +13 -1
  11. package/scripts/generaters/config.js +4 -1
  12. package/scripts/generaters/images.js +2 -0
  13. package/scripts/generaters/index.js +5 -2
  14. package/scripts/generaters/pages.js +0 -2
  15. package/scripts/generaters/script.js +34 -9
  16. package/scripts/helpers/asset.js +16 -7
  17. package/scripts/helpers/engine.js +24 -1
  18. package/scripts/helpers/list_categories.js +4 -0
  19. package/scripts/helpers/summary_ai.js +4 -0
  20. package/scripts/helpers/symbols_count_time.js +14 -8
  21. package/scripts/plugin/check.js +5 -3
  22. package/scripts/plugin/index.js +36 -9
  23. package/scripts/plugin/lib/injects.js +15 -0
  24. package/scripts/tags/media.js +1 -0
  25. package/source/js/_app/components/sidebar.js +54 -56
  26. package/source/js/_app/fireworks.js +6 -137
  27. package/source/js/_app/globals/globalVars.js +80 -96
  28. package/source/js/_app/globals/handles.js +81 -60
  29. package/source/js/_app/globals/themeColor.js +30 -26
  30. package/source/js/_app/globals/thirdparty.js +25 -24
  31. package/source/js/_app/globals/tools.js +36 -30
  32. package/source/js/_app/library/anime.js +31 -17
  33. package/source/js/_app/library/dom.js +12 -5
  34. package/source/js/_app/library/loadFile.js +7 -9
  35. package/source/js/_app/library/proto.js +59 -7
  36. package/source/js/_app/library/scriptPjax.js +14 -9
  37. package/source/js/_app/library/storage.js +2 -4
  38. package/source/js/_app/library/vue.js +16 -19
  39. package/source/js/_app/page/comment.js +10 -11
  40. package/source/js/_app/page/common.js +8 -12
  41. package/source/js/_app/page/fancybox.js +13 -14
  42. package/source/js/_app/page/post.js +43 -45
  43. package/source/js/_app/page/search.js +20 -20
  44. package/source/js/_app/page/tab.js +7 -10
  45. package/source/js/_app/pjax/domInit.js +29 -29
  46. package/source/js/_app/pjax/refresh.js +45 -50
  47. package/source/js/_app/pjax/siteInit.js +27 -31
  48. package/source/js/_app/player.js +44 -27
  49. package/test/dom.test.js +0 -86
@@ -1,14 +1,11 @@
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 postFancybox = (p) => {
7
- if ((0, dom_1.$dom)(p + ' .md img')) {
8
- (0, loadFile_1.vendorCss)('fancybox');
9
- (0, loadFile_1.vendorJs)('fancybox', () => {
1
+ import { $dom } from '../library/dom';
2
+ import { vendorCss, vendorJs } from '../library/loadFile';
3
+ export const postFancybox = (p) => {
4
+ if ($dom(p + ' .md img')) {
5
+ vendorCss('fancybox');
6
+ vendorJs('fancybox', () => {
10
7
  const q = jQuery.noConflict();
11
- dom_1.$dom.each(p + ' p.gallery', (element) => {
8
+ $dom.each(p + ' p.gallery', (element) => {
12
9
  const box = document.createElement('div');
13
10
  box.className = 'gallery';
14
11
  box.attr('data-height', String(element.attr('data-height') || 220));
@@ -16,9 +13,9 @@ const postFancybox = (p) => {
16
13
  element.parentNode.insertBefore(box, element);
17
14
  element.remove();
18
15
  });
19
- dom_1.$dom.each(p + ' .md img:not(.emoji):not(.vemoji)', (element) => {
16
+ $dom.each(p + ' .md img:not(.emoji):not(.vemoji)', (element) => {
20
17
  const $image = q(element);
21
- const imageLink = $image.attr('data-src') || $image.attr('src');
18
+ const imageLink = $image.attr('data-src') || $image.attr('src'); // 替换
22
19
  const $imageWrapLink = $image.wrap('<a class="fancybox" href="' + imageLink + '" itemscope itemtype="https://schema.org/ImageObject" itemprop="url"></a>').parent('a');
23
20
  let info;
24
21
  let captionClass = 'image-info';
@@ -40,7 +37,8 @@ const postFancybox = (p) => {
40
37
  element.insertAfter(para);
41
38
  }
42
39
  });
43
- dom_1.$dom.each(p + ' div.gallery', (el, i) => {
40
+ $dom.each(p + ' div.gallery', (el, i) => {
41
+ // @ts-ignore
44
42
  q(el).justifiedGallery({
45
43
  rowHeight: q(el).data('height') || 120,
46
44
  rel: 'gallery-' + i
@@ -53,13 +51,14 @@ const postFancybox = (p) => {
53
51
  q.fancybox.defaults.hash = false;
54
52
  q(p + ' .fancybox').fancybox({
55
53
  loop: true,
54
+ // @ts-ignore
56
55
  helpers: {
57
56
  overlay: {
58
57
  locked: false
59
58
  }
60
59
  }
61
60
  });
61
+ // @ts-ignore
62
62
  }, window.jQuery);
63
63
  }
64
64
  };
65
- exports.postFancybox = postFancybox;
@@ -1,29 +1,23 @@
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.postBeauty = void 0;
7
- const comment_1 = __importDefault(require("./comment"));
8
- const dom_1 = require("../library/dom");
9
- const fancybox_1 = require("./fancybox");
10
- const tools_1 = require("../globals/tools");
11
- const globalVars_1 = require("../globals/globalVars");
12
- const anime_1 = require("../library/anime");
13
- const player_1 = require("../player");
14
- const postBeauty = () => {
15
- (0, comment_1.default)();
16
- if (!(0, dom_1.$dom)('.md')) {
1
+ import loadComments from './comment';
2
+ import { $dom } from '../library/dom';
3
+ import { postFancybox } from './fancybox';
4
+ import { clipBoard, showtip } from '../globals/tools';
5
+ import { BODY } from '../globals/globalVars';
6
+ import { pageScroll, transition } from '../library/anime';
7
+ import { mediaPlayer } from '../player';
8
+ export const postBeauty = () => {
9
+ loadComments();
10
+ if (!$dom('.md')) {
17
11
  return;
18
12
  }
19
- (0, fancybox_1.postFancybox)('.post.block');
20
- (0, dom_1.$dom)('.post.block').oncopy = async (event) => {
21
- (0, tools_1.showtip)(LOCAL.copyright);
13
+ postFancybox('.post.block');
14
+ $dom('.post.block').oncopy = async (event) => {
15
+ showtip(LOCAL.copyright);
22
16
  if (LOCAL.nocopy) {
23
17
  event.preventDefault();
24
18
  return;
25
19
  }
26
- const copyright = await dom_1.$dom.asyncify('#copyright');
20
+ const copyright = await $dom.asyncify('#copyright');
27
21
  if (window.getSelection().toString().length > 30 && copyright) {
28
22
  event.preventDefault();
29
23
  const author = '# ' + copyright.child('.author').innerText;
@@ -36,31 +30,35 @@ const postBeauty = () => {
36
30
  event.clipboardData.setData('text/plain', textData);
37
31
  }
38
32
  else {
33
+ // @ts-ignore
39
34
  if (window.clipboardData) {
35
+ // @ts-ignore
40
36
  return window.clipboardData.setData('text', textData);
41
37
  }
42
38
  }
43
39
  }
44
40
  };
45
- dom_1.$dom.each('li ruby', (element) => {
41
+ $dom.each('li ruby', (element) => {
46
42
  let parent = element.parentNode;
43
+ // @ts-ignore
47
44
  if (element.parentNode.tagName !== 'LI') {
48
45
  parent = element.parentNode.parentNode;
49
46
  }
50
47
  parent.addClass('ruby');
51
48
  });
52
- dom_1.$dom.each('ol[start]', (element) => {
49
+ $dom.each('ol[start]', (element) => {
50
+ // @ts-ignore
53
51
  element.style.counterReset = 'counter ' + parseInt(element.attr('start') - 1);
54
52
  });
55
- dom_1.$dom.each('.md table', (element) => {
53
+ $dom.each('.md table', (element) => {
56
54
  element.wrapObject({
57
55
  className: 'table-container'
58
56
  });
59
57
  });
60
- dom_1.$dom.each('.highlight > .table-container', (element) => {
58
+ $dom.each('.highlight > .table-container', (element) => {
61
59
  element.className = 'code-container';
62
60
  });
63
- dom_1.$dom.each('figure.highlight', (element) => {
61
+ $dom.each('figure.highlight', (element) => {
64
62
  const code_container = element.child('.code-container');
65
63
  const caption = element.child('figcaption');
66
64
  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>');
@@ -77,10 +75,10 @@ const postBeauty = () => {
77
75
  code += comma + line.innerText;
78
76
  comma = '\n';
79
77
  });
80
- (0, tools_1.clipBoard)(code, (result) => {
78
+ clipBoard(code, (result) => {
81
79
  target.child('.ic').className = result ? 'ic i-check' : 'ic i-times';
82
80
  target.blur();
83
- (0, tools_1.showtip)(LOCAL.copyright);
81
+ showtip(LOCAL.copyright);
84
82
  });
85
83
  }, { passive: true });
86
84
  copyBtn.addEventListener('mouseleave', (event) => {
@@ -105,7 +103,7 @@ const postBeauty = () => {
105
103
  const removeFullscreen = () => {
106
104
  element.removeClass('fullscreen');
107
105
  element.scrollTop = 0;
108
- globalVars_1.BODY.removeClass('fullscreen');
106
+ BODY.removeClass('fullscreen');
109
107
  fullscreenBtn.child('.ic').className = 'ic i-expand';
110
108
  };
111
109
  const fullscreenHandle = () => {
@@ -116,11 +114,11 @@ const postBeauty = () => {
116
114
  code_container.style.maxHeight = '300px';
117
115
  showBtn.removeClass('open');
118
116
  }
119
- (0, anime_1.pageScroll)(element);
117
+ pageScroll(element);
120
118
  }
121
119
  else {
122
120
  element.addClass('fullscreen');
123
- globalVars_1.BODY.addClass('fullscreen');
121
+ BODY.addClass('fullscreen');
124
122
  fullscreenBtn.child('.ic').className = 'ic i-compress';
125
123
  if (code_container && code_container.find('tr').length > 15) {
126
124
  const showBtn = code_container.child('.show-btn');
@@ -147,7 +145,7 @@ const postBeauty = () => {
147
145
  if (showBtn.hasClass('open')) {
148
146
  removeFullscreen();
149
147
  hideCode();
150
- (0, anime_1.pageScroll)(code_container);
148
+ pageScroll(code_container);
151
149
  }
152
150
  else {
153
151
  showCode();
@@ -155,25 +153,26 @@ const postBeauty = () => {
155
153
  });
156
154
  }
157
155
  });
158
- dom_1.$dom.asyncifyEach('pre.mermaid > svg', (element) => {
156
+ $dom.asyncifyEach('pre.mermaid > svg', (element) => {
159
157
  const temp = element;
160
158
  temp.style.maxWidth = '';
161
159
  });
162
- dom_1.$dom.each('.reward button', (element) => {
160
+ $dom.each('.reward button', (element) => {
163
161
  element.addEventListener('click', (event) => {
164
162
  event.preventDefault();
165
- const qr = (0, dom_1.$dom)('#qr');
163
+ const qr = $dom('#qr');
166
164
  if (qr.display() === 'inline-flex') {
167
- (0, anime_1.transition)(qr, 0);
165
+ transition(qr, 0);
168
166
  }
169
167
  else {
170
- (0, anime_1.transition)(qr, 1, () => {
168
+ transition(qr, 1, () => {
171
169
  qr.display('inline-flex');
172
- });
170
+ }); // slideUpBigIn
173
171
  }
174
172
  });
175
173
  });
176
- dom_1.$dom.asyncifyEach('.quiz > ul.options li', (element) => {
174
+ // quiz
175
+ $dom.asyncifyEach('.quiz > ul.options li', (element) => {
177
176
  element.addEventListener('click', () => {
178
177
  if (element.hasClass('correct')) {
179
178
  element.toggleClass('right');
@@ -184,12 +183,12 @@ const postBeauty = () => {
184
183
  }
185
184
  });
186
185
  });
187
- dom_1.$dom.asyncifyEach('.quiz > p', (element) => {
186
+ $dom.asyncifyEach('.quiz > p', (element) => {
188
187
  element.addEventListener('click', () => {
189
188
  element.parentNode.toggleClass('show');
190
189
  });
191
190
  });
192
- dom_1.$dom.asyncifyEach('.quiz > p:first-child', (element) => {
191
+ $dom.asyncifyEach('.quiz > p:first-child', (element) => {
193
192
  const quiz = element.parentNode;
194
193
  let type = 'choice';
195
194
  if (quiz.hasClass('true') || quiz.hasClass('false')) {
@@ -206,14 +205,14 @@ const postBeauty = () => {
206
205
  }
207
206
  element.attr('data-type', LOCAL.quiz[type]);
208
207
  });
209
- dom_1.$dom.asyncifyEach('.quiz .mistake', (element) => {
208
+ $dom.asyncifyEach('.quiz .mistake', (element) => {
210
209
  element.attr('data-type', LOCAL.quiz.mistake);
211
210
  });
212
- dom_1.$dom.each('div.tags a', (element) => {
211
+ $dom.each('div.tags a', (element) => {
213
212
  element.className = ['primary', 'success', 'info', 'warning', 'danger'][Math.floor(Math.random() * 5)];
214
213
  });
215
- dom_1.$dom.asyncifyEach('.md div.player', (element) => {
216
- (0, player_1.mediaPlayer)(element, {
214
+ $dom.asyncifyEach('.md div.player', (element) => {
215
+ mediaPlayer(element, {
217
216
  type: element.attr('data-type'),
218
217
  mode: 'order',
219
218
  btns: []
@@ -243,4 +242,3 @@ const postBeauty = () => {
243
242
  });
244
243
  }
245
244
  };
246
- exports.postBeauty = postBeauty;
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.algoliaSearch = void 0;
4
- const globalVars_1 = require("../globals/globalVars");
5
- const anime_1 = require("../library/anime");
6
- const dom_1 = require("../library/dom");
7
- function algoliaSearch(pjax) {
1
+ import { BODY, setSiteSearch, siteSearch } from '../globals/globalVars';
2
+ import { transition } from '../library/anime';
3
+ import { $dom } from '../library/dom';
4
+ export function algoliaSearch(pjax) {
8
5
  if (CONFIG.search === null) {
9
6
  return;
10
7
  }
11
- if (!globalVars_1.siteSearch) {
12
- (0, globalVars_1.setSiteSearch)(globalVars_1.BODY.createChild('div', {
8
+ if (!siteSearch) {
9
+ setSiteSearch(BODY.createChild('div', {
13
10
  id: 'search',
14
11
  innerHTML: '<div class="inner"><div class="header"><span class="icon"><i class="ic i-search"></i></span><div class="search-input-container"></div><span class="close-btn"><i class="ic i-times-circle"></i></span></div><div class="results"><div class="inner"><div id="search-stats"></div><div id="search-hits"></div><div id="search-pagination"></div></div></div></div>'
15
12
  }));
@@ -18,15 +15,16 @@ function algoliaSearch(pjax) {
18
15
  indexName: CONFIG.search.indexName,
19
16
  searchClient: algoliasearch(CONFIG.search.appID, CONFIG.search.apiKey),
20
17
  searchFunction(helper) {
21
- const searchInput = (0, dom_1.$dom)('.search-input');
18
+ const searchInput = $dom('.search-input');
22
19
  if (searchInput.value) {
23
20
  helper.search();
24
21
  }
25
22
  }
26
23
  });
27
24
  search.on('render', () => {
28
- pjax.refresh((0, dom_1.$dom)('#search-hits'));
25
+ pjax.refresh($dom('#search-hits'));
29
26
  });
27
+ // Registering Widgets
30
28
  search.addWidgets([
31
29
  instantsearch.widgets.configure({
32
30
  hitsPerPage: CONFIG.search.hits.per_page || 10
@@ -34,6 +32,7 @@ function algoliaSearch(pjax) {
34
32
  instantsearch.widgets.searchBox({
35
33
  container: '.search-input-container',
36
34
  placeholder: LOCAL.search.placeholder,
35
+ // Hide default icons of algolia search
37
36
  showReset: false,
38
37
  showSubmit: false,
39
38
  showLoadingIndicator: false,
@@ -90,24 +89,26 @@ function algoliaSearch(pjax) {
90
89
  })
91
90
  ]);
92
91
  search.start();
93
- dom_1.$dom.each('.search', (element) => {
92
+ // Handle and trigger popup window
93
+ $dom.each('.search', (element) => {
94
94
  element.addEventListener('click', () => {
95
95
  document.body.style.overflow = 'hidden';
96
- (0, anime_1.transition)(globalVars_1.siteSearch, 'shrinkIn', () => {
97
- (0, dom_1.$dom)('.search-input').focus();
98
- });
96
+ transition(siteSearch, 'shrinkIn', () => {
97
+ $dom('.search-input').focus();
98
+ }); // transition.shrinkIn
99
99
  });
100
100
  });
101
+ // Monitor main search box
101
102
  const onPopupClose = () => {
102
103
  document.body.style.overflow = '';
103
- (0, anime_1.transition)(globalVars_1.siteSearch, 0);
104
+ transition(siteSearch, 0); // "transition.shrinkOut"
104
105
  };
105
- globalVars_1.siteSearch.addEventListener('click', (event) => {
106
- if (event.target === globalVars_1.siteSearch) {
106
+ siteSearch.addEventListener('click', (event) => {
107
+ if (event.target === siteSearch) {
107
108
  onPopupClose();
108
109
  }
109
110
  });
110
- (0, dom_1.$dom)('.close-btn').addEventListener('click', onPopupClose);
111
+ $dom('.close-btn').addEventListener('click', onPopupClose);
111
112
  window.addEventListener('pjax:success', onPopupClose);
112
113
  window.addEventListener('keyup', (event) => {
113
114
  if (event.key === 'Escape') {
@@ -115,4 +116,3 @@ function algoliaSearch(pjax) {
115
116
  }
116
117
  });
117
118
  }
118
- exports.algoliaSearch = algoliaSearch;
@@ -1,17 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tabFormat = void 0;
4
- const anime_1 = require("../library/anime");
5
- const dom_1 = require("../library/dom");
6
- const tabFormat = () => {
1
+ import { pageScroll } from '../library/anime';
2
+ import { $dom } from '../library/dom';
3
+ export const tabFormat = () => {
4
+ // tab
7
5
  let first_tab;
8
- dom_1.$dom.each('div.tab', (element) => {
6
+ $dom.each('div.tab', (element) => {
9
7
  if (element.attr('data-ready')) {
10
8
  return;
11
9
  }
12
10
  const id = element.attr('data-id');
13
11
  const title = element.attr('data-title');
14
- let box = (0, dom_1.$dom)('#' + id);
12
+ let box = $dom('#' + id);
15
13
  if (!box) {
16
14
  box = document.createElement('div');
17
15
  box.className = 'tabs';
@@ -19,7 +17,7 @@ const tabFormat = () => {
19
17
  box.innerHTML = '<div class="show-btn"></div>';
20
18
  const showBtn = box.child('.show-btn');
21
19
  showBtn.addEventListener('click', () => {
22
- (0, anime_1.pageScroll)(box);
20
+ pageScroll(box);
23
21
  });
24
22
  element.parentNode.insertBefore(box, element);
25
23
  first_tab = true;
@@ -53,4 +51,3 @@ const tabFormat = () => {
53
51
  element.attr('data-ready', String(true));
54
52
  });
55
53
  };
56
- exports.tabFormat = tabFormat;
@@ -1,39 +1,38 @@
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
- function domInit() {
9
- dom_1.$dom.each('.overview .menu > .item', (el) => {
10
- globalVars_1.siteNav.child('.menu').appendChild(el.cloneNode(true));
1
+ import { backToTopHandle, goToBottomHandle, goToCommentHandle, sideBarToggleHandle } from '../components/sidebar';
2
+ import { backToTop, goToComment, loadCat, menuToggle, quickBtn, setBackToTop, setGoToComment, setShowContents, setToolBtn, setToolPlayer, showContents, siteHeader, siteNav, toolBtn, toolPlayer } from '../globals/globalVars';
3
+ import { Loader } from '../globals/thirdparty';
4
+ import { $dom } from '../library/dom';
5
+ import { mediaPlayer } from '../player';
6
+ export default function domInit() {
7
+ $dom.each('.overview .menu > .item', (el) => {
8
+ siteNav.child('.menu').appendChild(el.cloneNode(true));
11
9
  });
12
- globalVars_1.loadCat.addEventListener('click', thirdparty_1.Loader.vanish);
13
- globalVars_1.menuToggle.addEventListener('click', sidebar_1.sideBarToggleHandle);
14
- (0, dom_1.$dom)('.dimmer').addEventListener('click', sidebar_1.sideBarToggleHandle);
15
- globalVars_1.quickBtn.child('.down').addEventListener('click', sidebar_1.goToBottomHandle);
16
- globalVars_1.quickBtn.child('.up').addEventListener('click', sidebar_1.backToTopHandle);
17
- if (!globalVars_1.toolBtn) {
18
- (0, globalVars_1.setToolBtn)(globalVars_1.siteHeader.createChild('div', {
10
+ loadCat.addEventListener('click', Loader.vanish);
11
+ menuToggle.addEventListener('click', sideBarToggleHandle);
12
+ $dom('.dimmer').addEventListener('click', sideBarToggleHandle);
13
+ quickBtn.child('.down').addEventListener('click', goToBottomHandle);
14
+ quickBtn.child('.up').addEventListener('click', backToTopHandle);
15
+ if (!toolBtn) {
16
+ setToolBtn(siteHeader.createChild('div', {
19
17
  id: 'tool',
20
18
  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>'
21
19
  }));
22
20
  }
23
- (0, globalVars_1.setToolPlayer)(globalVars_1.toolBtn.child('.player'));
24
- (0, globalVars_1.setBackToTop)(globalVars_1.toolBtn.child('.back-to-top'));
25
- (0, globalVars_1.setGoToComment)(globalVars_1.toolBtn.child('.chat'));
26
- (0, globalVars_1.setShowContents)(globalVars_1.toolBtn.child('.contents'));
27
- globalVars_1.backToTop.addEventListener('click', sidebar_1.backToTopHandle);
28
- globalVars_1.goToComment.addEventListener('click', sidebar_1.goToCommentHandle);
29
- globalVars_1.showContents.addEventListener('click', sidebar_1.sideBarToggleHandle);
30
- if (typeof player_1.mediaPlayer !== 'undefined') {
31
- (0, player_1.mediaPlayer)(globalVars_1.toolPlayer);
32
- (0, dom_1.$dom)('main').addEventListener('click', () => {
33
- globalVars_1.toolPlayer.player.mini();
21
+ setToolPlayer(toolBtn.child('.player'));
22
+ setBackToTop(toolBtn.child('.back-to-top'));
23
+ setGoToComment(toolBtn.child('.chat'));
24
+ setShowContents(toolBtn.child('.contents'));
25
+ backToTop.addEventListener('click', backToTopHandle);
26
+ goToComment.addEventListener('click', goToCommentHandle);
27
+ showContents.addEventListener('click', sideBarToggleHandle);
28
+ if (typeof mediaPlayer !== 'undefined') {
29
+ mediaPlayer(toolPlayer);
30
+ $dom('main').addEventListener('click', () => {
31
+ toolPlayer.player.mini();
34
32
  });
35
33
  }
36
34
  const createIntersectionObserver = () => {
35
+ // waves在视口外时停止动画
37
36
  new IntersectionObserver(([entry]) => {
38
37
  if (entry.isIntersecting) {
39
38
  document.querySelectorAll('.parallax>use').forEach(i => {
@@ -47,6 +46,7 @@ function domInit() {
47
46
  document.querySelectorAll('.parallax>use').forEach(i => {
48
47
  i.classList.add('stop-animation');
49
48
  });
49
+ // waves不可见时imgs也应该不可见了
50
50
  document.querySelectorAll('#imgs .item').forEach(i => {
51
51
  i.classList.add('stop-animation');
52
52
  });
@@ -55,6 +55,7 @@ function domInit() {
55
55
  root: null,
56
56
  threshold: 0.2
57
57
  }).observe(document.getElementById('waves'));
58
+ // sakura在视口外时停止动画
58
59
  new IntersectionObserver(([entry]) => {
59
60
  if (entry.isIntersecting) {
60
61
  document.querySelectorAll('.with-love>i').forEach(i => {
@@ -73,4 +74,3 @@ function domInit() {
73
74
  };
74
75
  createIntersectionObserver();
75
76
  }
76
- exports.default = domInit;
@@ -1,59 +1,54 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.siteRefresh = exports.pjaxReload = void 0;
4
- const dom_1 = require("../library/dom");
5
- const common_1 = require("../page/common");
6
- const post_1 = require("../page/post");
7
- const anime_1 = require("../library/anime");
8
- const loadFile_1 = require("../library/loadFile");
9
- const scriptPjax_1 = require("../library/scriptPjax");
10
- const handles_1 = require("../globals/handles");
11
- const globalVars_1 = require("../globals/globalVars");
12
- const player_1 = require("../player");
13
- const tools_1 = require("../globals/tools");
14
- const sidebar_1 = require("../components/sidebar");
15
- const thirdparty_1 = require("../globals/thirdparty");
16
- const tab_1 = require("../page/tab");
17
- const pjaxReload = () => {
18
- (0, tools_1.pagePosition)();
19
- if (globalVars_1.sideBar.hasClass('on')) {
20
- (0, anime_1.transition)(globalVars_1.sideBar, 0, () => {
21
- globalVars_1.sideBar.removeClass('on');
22
- globalVars_1.menuToggle.removeClass('close');
23
- });
1
+ import { $dom } from '../library/dom';
2
+ import { cardActive } from '../page/common';
3
+ import { postBeauty } from '../page/post';
4
+ import { pageScroll, transition } from '../library/anime';
5
+ import { vendorCss, vendorJs } from '../library/loadFile';
6
+ import { pjaxScript } from '../library/scriptPjax';
7
+ import { resizeHandle } from '../globals/handles';
8
+ import { loadCat, menuToggle, setLocalHash, setLocalUrl, setOriginTitle, sideBar, toolPlayer } from '../globals/globalVars';
9
+ import { mediaPlayer } from '../player';
10
+ import { pagePosition, positionInit } from '../globals/tools';
11
+ import { menuActive, sideBarTab, sidebarTOC } from '../components/sidebar';
12
+ import { Loader, isOutime, lazyload } from '../globals/thirdparty';
13
+ import { tabFormat } from '../page/tab';
14
+ export const pjaxReload = () => {
15
+ pagePosition();
16
+ if (sideBar.hasClass('on')) {
17
+ transition(sideBar, 0, () => {
18
+ sideBar.removeClass('on');
19
+ menuToggle.removeClass('close');
20
+ }); // 'transition.slideRightOut'
24
21
  }
25
- const mainNode = (0, dom_1.$dom)('#main');
22
+ const mainNode = $dom('#main');
26
23
  mainNode.innerHTML = '';
27
- mainNode.appendChild(globalVars_1.loadCat.lastChild.cloneNode(true));
28
- (0, anime_1.pageScroll)(0);
24
+ mainNode.appendChild(loadCat.lastChild.cloneNode(true));
25
+ pageScroll(0);
29
26
  };
30
- exports.pjaxReload = pjaxReload;
31
- const siteRefresh = (reload) => {
32
- (0, globalVars_1.setLocalHash)(0);
33
- (0, globalVars_1.setLocalUrl)(window.location.href);
34
- (0, loadFile_1.vendorCss)('katex');
35
- (0, loadFile_1.vendorJs)('copy_tex');
36
- (0, loadFile_1.vendorCss)('mermaid');
37
- (0, loadFile_1.vendorJs)('chart');
27
+ export const siteRefresh = (reload) => {
28
+ setLocalHash(0);
29
+ setLocalUrl(window.location.href);
30
+ vendorCss('katex');
31
+ vendorJs('copy_tex');
32
+ vendorCss('mermaid');
33
+ vendorJs('chart');
38
34
  if (reload !== 1) {
39
- dom_1.$dom.each('script[data-pjax]', scriptPjax_1.pjaxScript);
35
+ $dom.each('script[data-pjax]', pjaxScript);
40
36
  }
41
- (0, globalVars_1.setOriginTitle)(document.title);
42
- (0, handles_1.resizeHandle)();
43
- (0, sidebar_1.menuActive)();
44
- (0, sidebar_1.sideBarTab)();
45
- (0, sidebar_1.sidebarTOC)();
46
- (0, post_1.postBeauty)();
47
- (0, tab_1.tabFormat)();
48
- if (typeof player_1.mediaPlayer !== 'undefined') {
49
- globalVars_1.toolPlayer.player.load(LOCAL.audio || CONFIG.audio || {});
37
+ setOriginTitle(document.title);
38
+ resizeHandle();
39
+ menuActive();
40
+ sideBarTab();
41
+ sidebarTOC();
42
+ postBeauty();
43
+ tabFormat();
44
+ if (typeof mediaPlayer !== 'undefined') {
45
+ toolPlayer.player.load(LOCAL.audio || CONFIG.audio || {});
50
46
  }
51
- thirdparty_1.Loader.hide();
47
+ Loader.hide();
52
48
  setTimeout(() => {
53
- (0, tools_1.positionInit)();
49
+ positionInit();
54
50
  }, 500);
55
- (0, common_1.cardActive)();
56
- thirdparty_1.lazyload.observe();
57
- (0, thirdparty_1.isOutime)();
51
+ cardActive();
52
+ lazyload.observe();
53
+ isOutime();
58
54
  };
59
- exports.siteRefresh = siteRefresh;