hexo-theme-shokax 0.3.10 → 0.3.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. package/_config.yml +47 -57
  2. package/layout/_mixin/comment.pug +1 -1
  3. package/layout/_partials/head/head.pug +2 -7
  4. package/layout/_partials/layout.pug +5 -5
  5. package/package.json +16 -21
  6. package/scripts/filters/locals.js +6 -0
  7. package/scripts/filters/post.js +2 -0
  8. package/scripts/generaters/archive.js +13 -1
  9. package/scripts/generaters/config.js +4 -1
  10. package/scripts/generaters/images.js +2 -0
  11. package/scripts/generaters/index.js +2 -0
  12. package/scripts/generaters/pages.js +0 -2
  13. package/scripts/generaters/script.js +37 -11
  14. package/scripts/helpers/asset.js +17 -71
  15. package/scripts/helpers/engine.js +24 -1
  16. package/scripts/helpers/list_categories.js +4 -0
  17. package/scripts/helpers/summary_ai.js +4 -0
  18. package/scripts/helpers/symbols_count_time.js +14 -8
  19. package/scripts/plugin/check.js +5 -3
  20. package/scripts/plugin/index.js +39 -23
  21. package/scripts/plugin/lib/injects.js +15 -0
  22. package/scripts/tags/media.js +1 -0
  23. package/scripts/utils.js +14 -0
  24. package/source/js/_app/components/sidebar.js +54 -56
  25. package/source/js/_app/fireworks.js +6 -137
  26. package/source/js/_app/globals/globalVars.js +80 -96
  27. package/source/js/_app/globals/handles.js +81 -60
  28. package/source/js/_app/globals/themeColor.js +30 -26
  29. package/source/js/_app/globals/thirdparty.js +25 -24
  30. package/source/js/_app/globals/tools.js +36 -30
  31. package/source/js/_app/library/anime.js +30 -15
  32. package/source/js/_app/library/dom.js +12 -5
  33. package/source/js/_app/library/loadFile.js +10 -12
  34. package/source/js/_app/library/proto.js +59 -7
  35. package/source/js/_app/library/scriptPjax.js +14 -9
  36. package/source/js/_app/library/storage.js +2 -4
  37. package/source/js/_app/library/vue.js +16 -19
  38. package/source/js/_app/page/comment.js +10 -11
  39. package/source/js/_app/page/common.js +8 -12
  40. package/source/js/_app/page/fancybox.js +14 -14
  41. package/source/js/_app/page/post.js +43 -45
  42. package/source/js/_app/page/search.js +20 -20
  43. package/source/js/_app/page/tab.js +7 -10
  44. package/source/js/_app/pjax/domInit.js +29 -29
  45. package/source/js/_app/pjax/refresh.js +44 -50
  46. package/source/js/_app/pjax/siteInit.js +27 -31
  47. package/source/js/_app/player.js +44 -27
  48. package/test/dom.test.js +0 -86
@@ -1,24 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const dom_1 = require("../library/dom");
4
- const anime_1 = require("../library/anime");
5
- const globalVars_1 = require("../globals/globalVars");
6
- function loadComments() {
7
- const element = (0, dom_1.$dom)('#comments');
1
+ import { $dom } from '../library/dom';
2
+ import { transition } from '../library/anime';
3
+ import { goToComment } from '../globals/globalVars';
4
+ // TODO 此函数在twikoo下可能不适用
5
+ export default function loadComments() {
6
+ const element = $dom('#comments');
8
7
  if (!element) {
9
- globalVars_1.goToComment.display('none');
8
+ goToComment.display('none');
10
9
  return;
11
10
  }
12
11
  else {
13
- globalVars_1.goToComment.display('');
12
+ goToComment.display('');
14
13
  }
15
14
  const io = new IntersectionObserver((entries, observer) => {
16
15
  const entry = entries[0];
16
+ // vendorCss('valine')
17
17
  if (entry.isIntersecting || entry.intersectionRatio > 0) {
18
- (0, anime_1.transition)((0, dom_1.$dom)('#comments'), 'bounceUpIn');
18
+ transition($dom('#comments'), 'bounceUpIn');
19
19
  observer.disconnect();
20
20
  }
21
21
  });
22
22
  io.observe(element);
23
23
  }
24
- exports.default = loadComments;
@@ -1,9 +1,6 @@
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')) {
1
+ import { $dom } from '../library/dom';
2
+ export const cardActive = () => {
3
+ if (!$dom('.index.wrap')) {
7
4
  return;
8
5
  }
9
6
  const io = new IntersectionObserver((entries) => {
@@ -22,15 +19,15 @@ const cardActive = () => {
22
19
  root: null,
23
20
  threshold: [0.3]
24
21
  });
25
- dom_1.$dom.each('.index.wrap article.item, .index.wrap section.item', (article) => {
22
+ $dom.each('.index.wrap article.item, .index.wrap section.item', (article) => {
26
23
  io.observe(article);
27
24
  });
28
- (0, dom_1.$dom)('.index.wrap .item:first-child').addClass('show');
29
- dom_1.$dom.each('.cards .item', (element) => {
25
+ $dom('.index.wrap .item:first-child').addClass('show');
26
+ $dom.each('.cards .item', (element) => {
30
27
  ['mouseenter', 'touchstart'].forEach((item) => {
31
28
  element.addEventListener(item, () => {
32
- if ((0, dom_1.$dom)('.cards .item.active')) {
33
- (0, dom_1.$dom)('.cards .item.active').removeClass('active');
29
+ if ($dom('.cards .item.active')) {
30
+ $dom('.cards .item.active').removeClass('active');
34
31
  }
35
32
  element.addClass('active');
36
33
  }, { passive: true });
@@ -42,4 +39,3 @@ const cardActive = () => {
42
39
  });
43
40
  });
44
41
  };
45
- exports.cardActive = cardActive;
@@ -1,14 +1,12 @@
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
+ vendorCss('justifiedGallery');
7
+ vendorJs('fancybox', () => {
10
8
  const q = jQuery.noConflict();
11
- dom_1.$dom.each(p + ' p.gallery', (element) => {
9
+ $dom.each(p + ' p.gallery', (element) => {
12
10
  const box = document.createElement('div');
13
11
  box.className = 'gallery';
14
12
  box.attr('data-height', String(element.attr('data-height') || 220));
@@ -16,9 +14,9 @@ const postFancybox = (p) => {
16
14
  element.parentNode.insertBefore(box, element);
17
15
  element.remove();
18
16
  });
19
- dom_1.$dom.each(p + ' .md img:not(.emoji):not(.vemoji)', (element) => {
17
+ $dom.each(p + ' .md img:not(.emoji):not(.vemoji)', (element) => {
20
18
  const $image = q(element);
21
- const imageLink = $image.attr('data-src') || $image.attr('src');
19
+ const imageLink = $image.attr('data-src') || $image.attr('src'); // 替换
22
20
  const $imageWrapLink = $image.wrap('<a class="fancybox" href="' + imageLink + '" itemscope itemtype="https://schema.org/ImageObject" itemprop="url"></a>').parent('a');
23
21
  let info;
24
22
  let captionClass = 'image-info';
@@ -40,7 +38,8 @@ const postFancybox = (p) => {
40
38
  element.insertAfter(para);
41
39
  }
42
40
  });
43
- dom_1.$dom.each(p + ' div.gallery', (el, i) => {
41
+ $dom.each(p + ' div.gallery', (el, i) => {
42
+ // @ts-ignore
44
43
  q(el).justifiedGallery({
45
44
  rowHeight: q(el).data('height') || 120,
46
45
  rel: 'gallery-' + i
@@ -53,13 +52,14 @@ const postFancybox = (p) => {
53
52
  q.fancybox.defaults.hash = false;
54
53
  q(p + ' .fancybox').fancybox({
55
54
  loop: true,
55
+ // @ts-ignore
56
56
  helpers: {
57
57
  overlay: {
58
58
  locked: false
59
59
  }
60
60
  }
61
61
  });
62
+ // @ts-ignore
62
63
  }, window.jQuery);
63
64
  }
64
65
  };
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;