hexo-theme-shokax 0.2.9 → 0.2.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,9 @@
1
- const cardActive = function () {
1
+ const cardActive = () => {
2
2
  if (!$dom('.index.wrap')) {
3
3
  return;
4
4
  }
5
- const io = new IntersectionObserver(function (entries) {
6
- entries.forEach(function (article) {
5
+ const io = new IntersectionObserver((entries) => {
6
+ entries.forEach((article) => {
7
7
  if (article.target.hasClass('show')) {
8
8
  io.unobserve(article.target);
9
9
  }
@@ -18,30 +18,30 @@ const cardActive = function () {
18
18
  root: null,
19
19
  threshold: [0.3]
20
20
  });
21
- $dom.each('.index.wrap article.item, .index.wrap section.item', function (article) {
21
+ $dom.each('.index.wrap article.item, .index.wrap section.item', (article) => {
22
22
  io.observe(article);
23
23
  });
24
24
  $dom('.index.wrap .item:first-child').addClass('show');
25
- $dom.each('.cards .item', function (element, index) {
26
- ['mouseenter', 'touchstart'].forEach(function (item) {
27
- element.addEventListener(item, function (event) {
25
+ $dom.each('.cards .item', (element) => {
26
+ ['mouseenter', 'touchstart'].forEach((item) => {
27
+ element.addEventListener(item, () => {
28
28
  if ($dom('.cards .item.active')) {
29
29
  $dom('.cards .item.active').removeClass('active');
30
30
  }
31
31
  element.addClass('active');
32
32
  }, { passive: true });
33
33
  });
34
- ['mouseleave'].forEach(function (item) {
35
- element.addEventListener(item, function (event) {
34
+ ['mouseleave'].forEach((item) => {
35
+ element.addEventListener(item, () => {
36
36
  element.removeClass('active');
37
37
  }, { passive: true });
38
38
  });
39
39
  });
40
40
  };
41
- const registerExtURL = function () {
42
- $dom.each('span.exturl', function (element) {
41
+ const registerExtURL = () => {
42
+ $dom.each('span.exturl', (element) => {
43
43
  const link = document.createElement('a');
44
- link.href = decodeURIComponent(window.atob(element.dataset.url).split('').map(function (c) {
44
+ link.href = decodeURIComponent(window.atob(element.dataset.url).split('').map((c) => {
45
45
  return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
46
46
  }).join(''));
47
47
  link.rel = 'noopener external nofollow noreferrer';
@@ -55,12 +55,12 @@ const registerExtURL = function () {
55
55
  element.parentNode.replaceChild(link, element);
56
56
  });
57
57
  };
58
- const postFancybox = function (p) {
58
+ const postFancybox = (p) => {
59
59
  if ($dom(p + ' .md img')) {
60
60
  vendorCss('fancybox');
61
- vendorJs('fancybox', function () {
61
+ vendorJs('fancybox', () => {
62
62
  const q = jQuery.noConflict();
63
- $dom.each(p + ' p.gallery', function (element) {
63
+ $dom.each(p + ' p.gallery', (element) => {
64
64
  const box = document.createElement('div');
65
65
  box.className = 'gallery';
66
66
  box.attr('data-height', String(element.attr('data-height') || 220));
@@ -68,7 +68,7 @@ const postFancybox = function (p) {
68
68
  element.parentNode.insertBefore(box, element);
69
69
  element.remove();
70
70
  });
71
- $dom.each(p + ' .md img:not(.emoji):not(.vemoji)', function (element) {
71
+ $dom.each(p + ' .md img:not(.emoji):not(.vemoji)', (element) => {
72
72
  const $image = q(element);
73
73
  const imageLink = $image.attr('data-src') || $image.attr('src');
74
74
  const $imageWrapLink = $image.wrap('<a class="fancybox" href="' + imageLink + '" itemscope itemtype="https://schema.org/ImageObject" itemprop="url"></a>').parent('a');
@@ -92,7 +92,7 @@ const postFancybox = function (p) {
92
92
  element.insertAfter(para);
93
93
  }
94
94
  });
95
- $dom.each(p + ' div.gallery', function (el, i) {
95
+ $dom.each(p + ' div.gallery', (el, i) => {
96
96
  q(el).justifiedGallery({
97
97
  rowHeight: q(el).data('height') || 120,
98
98
  rel: 'gallery-' + i
@@ -114,13 +114,13 @@ const postFancybox = function (p) {
114
114
  }, window.jQuery);
115
115
  }
116
116
  };
117
- const postBeauty = function () {
117
+ const postBeauty = () => {
118
118
  loadComments();
119
119
  if (!$dom('.md')) {
120
120
  return;
121
121
  }
122
122
  postFancybox('.post.block');
123
- $dom('.post.block').oncopy = async function (event) {
123
+ $dom('.post.block').oncopy = async (event) => {
124
124
  showtip(LOCAL.copyright);
125
125
  if (LOCAL.nocopy) {
126
126
  event.preventDefault();
@@ -145,25 +145,25 @@ const postBeauty = function () {
145
145
  }
146
146
  }
147
147
  };
148
- $dom.each('li ruby', function (element) {
148
+ $dom.each('li ruby', (element) => {
149
149
  let parent = element.parentNode;
150
150
  if (element.parentNode.tagName !== 'LI') {
151
151
  parent = element.parentNode.parentNode;
152
152
  }
153
153
  parent.addClass('ruby');
154
154
  });
155
- $dom.each('ol[start]', function (element) {
155
+ $dom.each('ol[start]', (element) => {
156
156
  element.style.counterReset = 'counter ' + parseInt(element.attr('start') - 1);
157
157
  });
158
- $dom.each('.md table', function (element) {
158
+ $dom.each('.md table', (element) => {
159
159
  element.wrapObject({
160
160
  className: 'table-container'
161
161
  });
162
162
  });
163
- $dom.each('.highlight > .table-container', function (element) {
163
+ $dom.each('.highlight > .table-container', (element) => {
164
164
  element.className = 'code-container';
165
165
  });
166
- $dom.each('figure.highlight', function (element) {
166
+ $dom.each('figure.highlight', (element) => {
167
167
  const code_container = element.child('.code-container');
168
168
  const caption = element.child('figcaption');
169
169
  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>');
@@ -172,28 +172,28 @@ const postBeauty = function () {
172
172
  copyBtn.remove();
173
173
  }
174
174
  else {
175
- copyBtn.addEventListener('click', function (event) {
175
+ copyBtn.addEventListener('click', (event) => {
176
176
  const target = event.currentTarget;
177
177
  let comma = '';
178
178
  let code = '';
179
- code_container.find('pre').forEach(function (line) {
179
+ code_container.find('pre').forEach((line) => {
180
180
  code += comma + line.innerText;
181
181
  comma = '\n';
182
182
  });
183
- clipBoard(code, function (result) {
183
+ clipBoard(code, (result) => {
184
184
  target.child('.ic').className = result ? 'ic i-check' : 'ic i-times';
185
185
  target.blur();
186
186
  showtip(LOCAL.copyright);
187
187
  });
188
188
  }, { passive: true });
189
- copyBtn.addEventListener('mouseleave', function (event) {
190
- setTimeout(function () {
189
+ copyBtn.addEventListener('mouseleave', (event) => {
190
+ setTimeout(() => {
191
191
  event.target.child('.ic').className = 'ic i-clipboard';
192
192
  }, 1000);
193
193
  });
194
194
  }
195
195
  const breakBtn = element.child('.breakline-btn');
196
- breakBtn.addEventListener('click', function (event) {
196
+ breakBtn.addEventListener('click', (event) => {
197
197
  const target = event.currentTarget;
198
198
  if (element.hasClass('breakline')) {
199
199
  element.removeClass('breakline');
@@ -205,14 +205,13 @@ const postBeauty = function () {
205
205
  }
206
206
  });
207
207
  const fullscreenBtn = element.child('.fullscreen-btn');
208
- const removeFullscreen = function () {
208
+ const removeFullscreen = () => {
209
209
  element.removeClass('fullscreen');
210
210
  element.scrollTop = 0;
211
211
  BODY.removeClass('fullscreen');
212
212
  fullscreenBtn.child('.ic').className = 'ic i-expand';
213
213
  };
214
- const fullscreenHandle = function (event) {
215
- const target = event.currentTarget;
214
+ const fullscreenHandle = () => {
216
215
  if (element.hasClass('fullscreen')) {
217
216
  removeFullscreen();
218
217
  if (code_container && code_container.find('tr').length > 15) {
@@ -239,15 +238,15 @@ const postBeauty = function () {
239
238
  code_container.style.maxHeight = '300px';
240
239
  code_container.insertAdjacentHTML('beforeend', '<div class="show-btn"><i class="ic i-angle-down"></i></div>');
241
240
  const showBtn = code_container.child('.show-btn');
242
- const hideCode = function () {
241
+ const hideCode = () => {
243
242
  code_container.style.maxHeight = '300px';
244
243
  showBtn.removeClass('open');
245
244
  };
246
- const showCode = function () {
245
+ const showCode = () => {
247
246
  code_container.style.maxHeight = '';
248
247
  showBtn.addClass('open');
249
248
  };
250
- showBtn.addEventListener('click', function (event) {
249
+ showBtn.addEventListener('click', () => {
251
250
  if (showBtn.hasClass('open')) {
252
251
  removeFullscreen();
253
252
  hideCode();
@@ -259,26 +258,26 @@ const postBeauty = function () {
259
258
  });
260
259
  }
261
260
  });
262
- $dom.asyncifyEach('pre.mermaid > svg', function (element) {
261
+ $dom.asyncifyEach('pre.mermaid > svg', (element) => {
263
262
  const temp = element;
264
263
  temp.style.maxWidth = '';
265
264
  });
266
- $dom.each('.reward button', function (element) {
267
- element.addEventListener('click', function (event) {
265
+ $dom.each('.reward button', (element) => {
266
+ element.addEventListener('click', (event) => {
268
267
  event.preventDefault();
269
268
  const qr = $dom('#qr');
270
269
  if (qr.display() === 'inline-flex') {
271
270
  transition(qr, 0);
272
271
  }
273
272
  else {
274
- transition(qr, 1, function () {
273
+ transition(qr, 1, () => {
275
274
  qr.display('inline-flex');
276
275
  });
277
276
  }
278
277
  });
279
278
  });
280
- $dom.asyncifyEach('.quiz > ul.options li', function (element) {
281
- element.addEventListener('click', function (event) {
279
+ $dom.asyncifyEach('.quiz > ul.options li', (element) => {
280
+ element.addEventListener('click', () => {
282
281
  if (element.hasClass('correct')) {
283
282
  element.toggleClass('right');
284
283
  element.parentNode.parentNode.addClass('show');
@@ -288,12 +287,12 @@ const postBeauty = function () {
288
287
  }
289
288
  });
290
289
  });
291
- $dom.asyncifyEach('.quiz > p', function (element) {
292
- element.addEventListener('click', function (event) {
290
+ $dom.asyncifyEach('.quiz > p', (element) => {
291
+ element.addEventListener('click', () => {
293
292
  element.parentNode.toggleClass('show');
294
293
  });
295
294
  });
296
- $dom.asyncifyEach('.quiz > p:first-child', function (element) {
295
+ $dom.asyncifyEach('.quiz > p:first-child', (element) => {
297
296
  const quiz = element.parentNode;
298
297
  let type = 'choice';
299
298
  if (quiz.hasClass('true') || quiz.hasClass('false')) {
@@ -310,13 +309,13 @@ const postBeauty = function () {
310
309
  }
311
310
  element.attr('data-type', LOCAL.quiz[type]);
312
311
  });
313
- $dom.asyncifyEach('.quiz .mistake', function (element) {
312
+ $dom.asyncifyEach('.quiz .mistake', (element) => {
314
313
  element.attr('data-type', LOCAL.quiz.mistake);
315
314
  });
316
- $dom.each('div.tags a', function (element) {
315
+ $dom.each('div.tags a', (element) => {
317
316
  element.className = ['primary', 'success', 'info', 'warning', 'danger'][Math.floor(Math.random() * 5)];
318
317
  });
319
- $dom.asyncifyEach('.md div.player', function (element) {
318
+ $dom.asyncifyEach('.md div.player', (element) => {
320
319
  mediaPlayer(element, {
321
320
  type: element.attr('data-type'),
322
321
  mode: 'order',
@@ -347,9 +346,9 @@ const postBeauty = function () {
347
346
  });
348
347
  }
349
348
  };
350
- const tabFormat = function () {
349
+ const tabFormat = () => {
351
350
  let first_tab;
352
- $dom.each('div.tab', function (element, index) {
351
+ $dom.each('div.tab', (element) => {
353
352
  if (element.attr('data-ready')) {
354
353
  return;
355
354
  }
@@ -362,7 +361,7 @@ const tabFormat = function () {
362
361
  box.id = id;
363
362
  box.innerHTML = '<div class="show-btn"></div>';
364
363
  const showBtn = box.child('.show-btn');
365
- showBtn.addEventListener('click', function (event) {
364
+ showBtn.addEventListener('click', () => {
366
365
  pageScroll(box);
367
366
  });
368
367
  element.parentNode.insertBefore(box, element);
@@ -385,9 +384,9 @@ const tabFormat = function () {
385
384
  li.addClass('active');
386
385
  element.addClass('active');
387
386
  }
388
- li.addEventListener('click', function (event) {
387
+ li.addEventListener('click', (event) => {
389
388
  const target = event.currentTarget;
390
- box.find('.active').forEach(function (el) {
389
+ box.find('.active').forEach((el) => {
391
390
  el.removeClass('active');
392
391
  });
393
392
  element.addClass('active');
@@ -397,7 +396,7 @@ const tabFormat = function () {
397
396
  element.attr('data-ready', String(true));
398
397
  });
399
398
  };
400
- const loadComments = function () {
399
+ const loadComments = () => {
401
400
  const element = $dom('#comments');
402
401
  if (!element) {
403
402
  goToComment.display('none');
@@ -406,7 +405,7 @@ const loadComments = function () {
406
405
  else {
407
406
  goToComment.display('');
408
407
  }
409
- const io = new IntersectionObserver(function (entries, observer) {
408
+ const io = new IntersectionObserver((entries, observer) => {
410
409
  const entry = entries[0];
411
410
  vendorCss('valine');
412
411
  if (entry.isIntersecting || entry.intersectionRatio > 0) {
@@ -416,7 +415,7 @@ const loadComments = function () {
416
415
  });
417
416
  io.observe(element);
418
417
  };
419
- const algoliaSearch = function (pjax) {
418
+ const algoliaSearch = (pjax) => {
420
419
  if (CONFIG.search === null) {
421
420
  return;
422
421
  }
@@ -429,14 +428,14 @@ const algoliaSearch = function (pjax) {
429
428
  const search = instantsearch({
430
429
  indexName: CONFIG.search.indexName,
431
430
  searchClient: algoliasearch(CONFIG.search.appID, CONFIG.search.apiKey),
432
- searchFunction: function (helper) {
431
+ searchFunction(helper) {
433
432
  const searchInput = $dom('.search-input');
434
433
  if (searchInput.value) {
435
434
  helper.search();
436
435
  }
437
436
  }
438
437
  });
439
- search.on('render', function () {
438
+ search.on('render', () => {
440
439
  pjax.refresh($dom('#search-hits'));
441
440
  });
442
441
  search.addWidgets([
@@ -456,7 +455,7 @@ const algoliaSearch = function (pjax) {
456
455
  instantsearch.widgets.stats({
457
456
  container: '#search-stats',
458
457
  templates: {
459
- text: function (data) {
458
+ text(data) {
460
459
  const stats = LOCAL.search.stats
461
460
  .replace(/\$\{hits}/, data.nbHits)
462
461
  .replace(/\$\{time}/, data.processingTimeMS);
@@ -467,11 +466,11 @@ const algoliaSearch = function (pjax) {
467
466
  instantsearch.widgets.hits({
468
467
  container: '#search-hits',
469
468
  templates: {
470
- item: function (data) {
469
+ item(data) {
471
470
  const cats = data.categories ? '<span>' + data.categories.join('<i class="ic i-angle-right"></i>') + '</span>' : '';
472
471
  return '<a href="' + CONFIG.root + data.path + '">' + cats + data._highlightResult.title.value + '</a>';
473
472
  },
474
- empty: function (data) {
473
+ empty(data) {
475
474
  return '<div id="hits-empty">' +
476
475
  LOCAL.search.empty.replace(/\$\{query}/, data.query) +
477
476
  '</div>';
@@ -502,33 +501,33 @@ const algoliaSearch = function (pjax) {
502
501
  })
503
502
  ]);
504
503
  search.start();
505
- $dom.each('.search', function (element) {
506
- element.addEventListener('click', function () {
504
+ $dom.each('.search', (element) => {
505
+ element.addEventListener('click', () => {
507
506
  document.body.style.overflow = 'hidden';
508
- transition(siteSearch, 'shrinkIn', function () {
507
+ transition(siteSearch, 'shrinkIn', () => {
509
508
  $dom('.search-input').focus();
510
509
  });
511
510
  });
512
511
  });
513
- const onPopupClose = function () {
512
+ const onPopupClose = () => {
514
513
  document.body.style.overflow = '';
515
514
  transition(siteSearch, 0);
516
515
  };
517
- siteSearch.addEventListener('click', function (event) {
516
+ siteSearch.addEventListener('click', (event) => {
518
517
  if (event.target === siteSearch) {
519
518
  onPopupClose();
520
519
  }
521
520
  });
522
521
  $dom('.close-btn').addEventListener('click', onPopupClose);
523
522
  window.addEventListener('pjax:success', onPopupClose);
524
- window.addEventListener('keyup', function (event) {
523
+ window.addEventListener('keyup', (event) => {
525
524
  if (event.key === 'Escape') {
526
525
  onPopupClose();
527
526
  }
528
527
  });
529
528
  };
530
- const domInit = function () {
531
- $dom.each('.overview .menu > .item', function (el) {
529
+ const domInit = () => {
530
+ $dom.each('.overview .menu > .item', (el) => {
532
531
  siteNav.child('.menu').appendChild(el.cloneNode(true));
533
532
  });
534
533
  loadCat.addEventListener('click', Loader.vanish);
@@ -551,11 +550,11 @@ const domInit = function () {
551
550
  showContents.addEventListener('click', sideBarToggleHandle);
552
551
  if (typeof mediaPlayer !== 'undefined') {
553
552
  mediaPlayer(toolPlayer);
554
- $dom('main').addEventListener('click', function () {
553
+ $dom('main').addEventListener('click', () => {
555
554
  toolPlayer.player.mini();
556
555
  });
557
556
  }
558
- const createIntersectionObserver = function () {
557
+ const createIntersectionObserver = () => {
559
558
  new IntersectionObserver(([entry]) => {
560
559
  if (entry.isIntersecting) {
561
560
  document.querySelectorAll('.parallax>use').forEach(i => {
@@ -595,10 +594,10 @@ const domInit = function () {
595
594
  };
596
595
  createIntersectionObserver();
597
596
  };
598
- const pjaxReload = function () {
597
+ const pjaxReload = () => {
599
598
  pagePosition();
600
599
  if (sideBar.hasClass('on')) {
601
- transition(sideBar, 0, function () {
600
+ transition(sideBar, 0, () => {
602
601
  sideBar.removeClass('on');
603
602
  menuToggle.removeClass('close');
604
603
  });
@@ -608,7 +607,7 @@ const pjaxReload = function () {
608
607
  mainNode.appendChild(loadCat.lastChild.cloneNode(true));
609
608
  pageScroll(0);
610
609
  };
611
- const siteRefresh = function (reload) {
610
+ const siteRefresh = (reload) => {
612
611
  LOCAL_HASH = 0;
613
612
  LOCAL_URL = window.location.href;
614
613
  vendorCss('katex');
@@ -630,14 +629,14 @@ const siteRefresh = function (reload) {
630
629
  toolPlayer.player.load(LOCAL.audio || CONFIG.audio || {});
631
630
  }
632
631
  Loader.hide();
633
- setTimeout(function () {
632
+ setTimeout(() => {
634
633
  positionInit();
635
634
  }, 500);
636
635
  cardActive();
637
636
  lazyload.observe();
638
637
  isOutime();
639
638
  };
640
- const siteInit = function () {
639
+ const siteInit = () => {
641
640
  domInit();
642
641
  pjax = new Pjax({
643
642
  selectors: [
@@ -662,7 +661,7 @@ const siteInit = function () {
662
661
  window.addEventListener('resize', resizeHandle);
663
662
  window.addEventListener('pjax:send', pjaxReload);
664
663
  window.addEventListener('pjax:success', siteRefresh);
665
- window.addEventListener('beforeunload', function () {
664
+ window.addEventListener('beforeunload', () => {
666
665
  pagePosition();
667
666
  });
668
667
  siteRefresh(1);