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,5 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ // @ts-ignore
3
4
  const hexo_util_1 = require("hexo-util");
4
5
  const randomServer = parseInt(String(Math.random() * 4), 10) + 1;
5
6
  const randomBG = function (count = 1, image_server = null, image_list = []) {
@@ -18,7 +19,7 @@ const randomBG = function (count = 1, image_server = null, image_list = []) {
18
19
  if (img.startsWith('//') || img.startsWith('http')) {
19
20
  return img;
20
21
  }
21
- else if (hexo.theme.config.experiments?.usingRelative) {
22
+ else if (hexo.theme.config.experiments?.usingRelative) { // support relative url
22
23
  return img;
23
24
  }
24
25
  else {
@@ -47,7 +48,9 @@ const randomBG = function (count = 1, image_server = null, image_list = []) {
47
48
  }
48
49
  return parseImage(image_list[Math.floor(Math.random() * image_list.length)], 'mw690');
49
50
  };
51
+ // 注册hexo主题中的URL帮助方法
50
52
  hexo.extend.helper.register('_url', function (path, text, options = {}) {
53
+ // 如果未提供URL路径,则返回
51
54
  if (!path) {
52
55
  return;
53
56
  }
@@ -59,6 +62,7 @@ hexo.extend.helper.register('_url', function (path, text, options = {}) {
59
62
  if (attrs.class && Array.isArray(attrs.class)) {
60
63
  attrs.class = attrs.class.join(' ');
61
64
  }
65
+ // 返回HTML标记字符串
62
66
  return (0, hexo_util_1.htmlTag)(tag, attrs, decodeURI(text), false);
63
67
  });
64
68
  hexo.extend.helper.register('_image_url', function (img, path = '') {
@@ -95,24 +99,43 @@ hexo.extend.helper.register('_cover_index', function (item) {
95
99
  return randomBG(1, image_server, index_images.length === 0 ? image_list : index_images);
96
100
  }
97
101
  });
102
+ // 注册hexo主题的永久链接帮助方法
98
103
  hexo.extend.helper.register('_permapath', function (str) {
104
+ // 获取hexo的永久链接配置
99
105
  const { permalink } = hexo.config;
106
+ // 将输入字符串中的'index.html'替换为空字符串
100
107
  let url = str.replace(/index\.html$/, '');
108
+ // 如果永久链接不以'.html'结尾,将输入字符串中的'.html'替换为空字符串
101
109
  if (!permalink.endsWith('.html')) {
102
110
  url = url.replace(/\.html$/, '');
103
111
  }
112
+ // 返回处理后的URL字符串
104
113
  return url;
105
114
  });
106
115
  hexo.extend.helper.register('canonical', function () {
107
116
  return `<link rel="canonical" href="${this._permapath(this.url)}">`;
108
117
  });
118
+ /**
119
+ * Get page path given a certain language tag
120
+ */
121
+ // 注册hexo主题的国际化路径帮助方法
109
122
  hexo.extend.helper.register('i18n_path', function (language) {
123
+ // 获取当前页面的path和lang
110
124
  const { path, lang } = this.page;
125
+ // 如果path以lang开头,则截取掉lang部分,作为基础路径
111
126
  const base = path.startsWith(lang) ? path.slice(lang.length + 1) : path;
127
+ // 通过调用url_for方法,生成国际化路径
112
128
  return hexo_util_1.url_for.call(this, `${this.languages.indexOf(language) === 0 ? '' : '/' + language}/${base}`);
113
129
  });
130
+ /**
131
+ * Get the language name
132
+ */
133
+ // 注册hexo主题的语言名称帮助方法
114
134
  hexo.extend.helper.register('language_name', function (language) {
135
+ // 从主题配置中获取指定语言的名称
136
+ // @ts-ignore
115
137
  const name = hexo.theme.i18n.__(language)('name');
138
+ // 如果名称为默认值'name',则返回语言代码,否则返回语言名称
116
139
  return name === 'name' ? language : name;
117
140
  });
118
141
  hexo.extend.helper.register('random_color', function () {
@@ -1,4 +1,5 @@
1
1
  'use strict';
2
+ /* global hexo */
2
3
  const prepareQuery = (categories, parent) => {
3
4
  const query = {
4
5
  parent: undefined
@@ -12,6 +13,7 @@ const prepareQuery = (categories, parent) => {
12
13
  return categories.find(query).sort('name', 1).filter(cat => cat.length);
13
14
  };
14
15
  hexo.extend.helper.register('_list_categories', function (depth = 0) {
16
+ // let hexo = this
15
17
  const categories = this.site.categories;
16
18
  if (!categories || !categories.length)
17
19
  return '';
@@ -46,6 +48,7 @@ hexo.extend.helper.register('_list_categories', function (depth = 0) {
46
48
  return hierarchicalList(0);
47
49
  });
48
50
  hexo.extend.helper.register('_category_prev', function (name) {
51
+ // let hexo = this
49
52
  const categories = this.site.categories;
50
53
  if (!categories || !categories.length)
51
54
  return '';
@@ -60,6 +63,7 @@ hexo.extend.helper.register('_category_prev', function (name) {
60
63
  return result;
61
64
  });
62
65
  hexo.extend.helper.register('_category_posts', function (page) {
66
+ // let hexo = this
63
67
  const categories = this.site.categories;
64
68
  if (!categories || !categories.length || !page.categories || !page.categories.length)
65
69
  return '';
@@ -10,6 +10,7 @@ function getContent(post) {
10
10
  let db;
11
11
  function postMessage(path, content, dbPath, startMessage) {
12
12
  if (node_fs_1.default.existsSync('summary.json')) {
13
+ // @ts-ignore
13
14
  db = JSON.parse(node_fs_1.default.readFileSync('summary.json'));
14
15
  }
15
16
  else {
@@ -39,6 +40,7 @@ function postMessage(path, content, dbPath, startMessage) {
39
40
  throw Error('ERROR: Failed to get summary from Openai API');
40
41
  }
41
42
  response.json().then((data) => {
43
+ // @ts-ignore
42
44
  const summary = data.choices[0].message.content;
43
45
  try {
44
46
  db[path][dbPath] = summary;
@@ -63,6 +65,7 @@ function postMessage(path, content, dbPath, startMessage) {
63
65
  setTimeout(checkTime, 1000 * waitTime);
64
66
  return;
65
67
  }
68
+ // Openai API 针对个人用户免费试用限制 3 RPM,这里是25s后发送请求
66
69
  node_fs_1.default.writeFileSync('requested.lock', '');
67
70
  setTimeout(request, 1000 * 2.5 * waitTime);
68
71
  node_fs_1.default.unlinkSync('request.lock');
@@ -92,6 +95,7 @@ function postMessage(path, content, dbPath, startMessage) {
92
95
  }
93
96
  }
94
97
  else {
98
+ // custom尚未支持
95
99
  }
96
100
  }
97
101
  }
@@ -1,5 +1,11 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* global hexo */
4
+ /*!
5
+ hexo-symbols-count-time by theme-next
6
+ under GNU Lesser General Public License v3.0 or later
7
+ https://github.com/theme-next/hexo-symbols-count-time/blob/master/LICENSE
8
+ */
3
9
  const hexo_util_1 = require("hexo-util");
4
10
  const config = hexo.config.symbols_count_time = Object.assign({
5
11
  symbols: true,
@@ -25,20 +31,20 @@ function getFormatTime(minutes, suffix) {
25
31
  const fHours = Math.floor(minutes / 60);
26
32
  let fMinutes = Math.floor(minutes - (fHours * 60));
27
33
  if (fMinutes < 1) {
28
- fMinutes = 1;
34
+ fMinutes = 1; // 0 => 1
29
35
  }
30
36
  return fHours < 1
31
- ? fMinutes + ' ' + suffix
32
- : fHours + ':' + ('00' + fMinutes).slice(-2);
37
+ ? fMinutes + ' ' + suffix // < 59 => 59 mins.
38
+ : fHours + ':' + ('00' + fMinutes).slice(-2); // = 61 => 1:01
33
39
  }
34
40
  hexo.extend.helper.register('symbolsCount', function (post) {
35
41
  let symbolsResult = getSymbols(post);
36
42
  if (symbolsResult > 9999) {
37
- symbolsResult = Math.round(symbolsResult / 1000) + 'k';
43
+ symbolsResult = Math.round(symbolsResult / 1000) + 'k'; // > 9999 => 11k
38
44
  }
39
45
  else if (symbolsResult > 999) {
40
- symbolsResult = Math.round(symbolsResult / 100) / 10 + 'k';
41
- }
46
+ symbolsResult = Math.round(symbolsResult / 100) / 10 + 'k'; // > 999 => 1.1k
47
+ } // < 999 => 111
42
48
  return symbolsResult;
43
49
  });
44
50
  hexo.extend.helper.register('symbolsTime', function (post, awl = config.awl, wpm = config.wpm, suffix = config.suffix) {
@@ -48,8 +54,8 @@ hexo.extend.helper.register('symbolsTime', function (post, awl = config.awl, wpm
48
54
  hexo.extend.helper.register('symbolsCountTotal', function (site) {
49
55
  const symbolsResultTotal = getSymbolsTotal(site);
50
56
  return symbolsResultTotal < 1000000
51
- ? Math.round(symbolsResultTotal / 1000) + 'k'
52
- : Math.round(symbolsResultTotal / 100000) / 10 + 'm';
57
+ ? Math.round(symbolsResultTotal / 1000) + 'k' // < 999k => 111k
58
+ : Math.round(symbolsResultTotal / 100000) / 10 + 'm'; // > 999k => 1.1m
53
59
  });
54
60
  hexo.extend.helper.register('symbolsTimeTotal', function (site, awl = config.awl, wpm = config.wpm, suffix = config.suffix) {
55
61
  const minutes = Math.round(getSymbolsTotal(site) / (awl * wpm));
@@ -1,10 +1,11 @@
1
+ /* global hexo */
1
2
  let findProblem = false;
2
3
  hexo.on('generateBefore', function () {
3
4
  if (hexo.config.syntax_highlighter) {
4
5
  findProblem = true;
5
6
  hexo.log.error('[SXEC 101] Highlight.js or Prismjs enabled. The code block will render incomplete');
6
7
  }
7
- if (!hexo.config.autoprefixer || !hexo.config.markdown) {
8
+ if (!hexo.config.markdown) {
8
9
  findProblem = true;
9
10
  hexo.log.error(`[SXEC 102] Critical rendering plugins are missing or incorrectly configured.
10
11
  Some features will be disabled or render incorrectly`);
@@ -17,8 +18,9 @@ Some features will be disabled or render incorrectly`);
17
18
  findProblem = true;
18
19
  hexo.log.warn('[SXEC 201] Essential information(title, desc, lang, etc) config incorrectly, Page will render incorrectly');
19
20
  }
20
- if (hexo.theme.config.gitalk.clientID || hexo.theme.config.giscus.repo) {
21
- hexo.log.warn('You are using an deprecated feature and it was removed in the v0.3.10');
21
+ if (hexo.theme.config.gitalk?.clientID || hexo.theme.config.giscus?.repo) {
22
+ findProblem = true;
23
+ hexo.log.warn('[SXEC 202] You are using an deprecated feature and it was removed in the v0.3.10');
22
24
  }
23
25
  });
24
26
  hexo.on('generateAfter', function () {
@@ -4,36 +4,52 @@
4
4
  under GNU AFFERO GENERAL PUBLIC LICENSE v3.0 OR LATER
5
5
  https://github.com/next-theme/hexo-theme-next/blob/master/LICENSE.md
6
6
  */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || function (mod) {
24
+ if (mod && mod.__esModule) return mod;
25
+ var result = {};
26
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
27
+ __setModuleDefault(result, mod);
28
+ return result;
29
+ };
7
30
  var __importDefault = (this && this.__importDefault) || function (mod) {
8
31
  return (mod && mod.__esModule) ? mod : { "default": mod };
9
32
  };
10
33
  Object.defineProperty(exports, "__esModule", { value: true });
11
34
  const injects_1 = __importDefault(require("./lib/injects"));
12
- const node_https_1 = __importDefault(require("node:https"));
13
35
  const package_json_1 = require("../../package.json");
14
- const node_fs_1 = __importDefault(require("node:fs"));
36
+ const fs = __importStar(require("node:fs"));
15
37
  hexo.on('generateBefore', () => {
38
+ // 加载`theme_injects`过滤器
16
39
  (0, injects_1.default)(hexo);
17
- if (node_fs_1.default.existsSync('request.lock')) {
18
- node_fs_1.default.unlinkSync('request.lock');
40
+ if (fs.existsSync('request.lock')) {
41
+ fs.unlinkSync('request.lock');
19
42
  }
20
- if (node_fs_1.default.existsSync('requested.lock')) {
21
- node_fs_1.default.unlinkSync('requested.lock');
43
+ if (fs.existsSync('requested.lock')) {
44
+ fs.unlinkSync('requested.lock');
22
45
  }
23
46
  });
24
47
  hexo.on('generateAfter', () => {
25
- node_https_1.default.get('https://api.github.com/repos/theme-shoka-x/hexo-theme-shokaX/releases/latest', {
26
- headers: {
27
- 'User-Agent': 'Theme ShokaX Client'
28
- }
29
- }, (res) => {
30
- let result = '';
31
- res.on('data', (data) => {
32
- result += data;
33
- });
34
- res.on('end', () => {
48
+ // 检查版本更新
49
+ fetch('https://api.github.com/repos/theme-shoka-x/hexo-theme-shokaX/releases/latest').then((res) => {
50
+ res.json().then((resp) => {
35
51
  try {
36
- const latest = JSON.parse(result).tag_name.replace('v', '').split('.');
52
+ const latest = resp.tag_name.replace('v', '').split('.');
37
53
  const current = package_json_1.version.split('.');
38
54
  let isOutdated = false;
39
55
  for (let i = 0; i < Math.max(latest.length, current.length); i++) {
@@ -50,13 +66,13 @@ hexo.on('generateAfter', () => {
50
66
  hexo.log.warn('Visit https://github.com/theme-shoka-x/hexo-theme-shokaX/releases for more information.');
51
67
  }
52
68
  }
53
- catch (err) {
54
- hexo.log.error('Failed to detect version info. Error message:');
55
- hexo.log.error(err);
69
+ catch (e) {
70
+ hexo.log.warn('Failed to detect version info. Error message:');
71
+ hexo.log.warn(e);
56
72
  }
73
+ }).catch((e) => {
74
+ hexo.log.warn('Failed to detect version info. Error message:');
75
+ hexo.log.warn(e);
57
76
  });
58
- }).on('error', err => {
59
- hexo.log.error('Failed to detect version info. Error message:');
60
- hexo.log.error(err);
61
77
  });
62
78
  });
@@ -3,6 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ /*!
7
+ inject.js in next-theme/hexo-theme-next by next-theme
8
+ under GNU AFFERO GENERAL PUBLIC LICENSE v3.0 OR LATER
9
+ https://github.com/next-theme/hexo-theme-next/blob/master/LICENSE.md
10
+ */
6
11
  const node_fs_1 = __importDefault(require("node:fs"));
7
12
  const node_path_1 = __importDefault(require("node:path"));
8
13
  const injects_point_1 = __importDefault(require("./injects-point"));
@@ -18,6 +23,7 @@ class StylusInject {
18
23
  this.files.push(node_path_1.default.resolve(this.base_dir, file));
19
24
  }
20
25
  }
26
+ // Defining view types
21
27
  class ViewInject {
22
28
  base_dir;
23
29
  raws;
@@ -26,18 +32,22 @@ class ViewInject {
26
32
  this.raws = [];
27
33
  }
28
34
  raw(name, raw, ...args) {
35
+ // Set default extname
29
36
  if (node_path_1.default.extname(name) === '') {
30
37
  name += defaultExtname;
31
38
  }
32
39
  this.raws.push({ name, raw, args });
33
40
  }
34
41
  file(name, file, ...args) {
42
+ // Set default extname from file's extname
35
43
  if (node_path_1.default.extname(name) === '') {
36
44
  name += node_path_1.default.extname(file);
37
45
  }
46
+ // Get absolute path base on hexo dir
38
47
  this.raw(name, node_fs_1.default.readFileSync(node_path_1.default.resolve(this.base_dir, file), 'utf8'), ...args);
39
48
  }
40
49
  }
50
+ // Init injects
41
51
  function initInject(base_dir) {
42
52
  const injects = {};
43
53
  injects_point_1.default.styles.forEach(item => {
@@ -49,15 +59,19 @@ function initInject(base_dir) {
49
59
  return injects;
50
60
  }
51
61
  exports.default = (hexo) => {
62
+ // Exec theme_inject filter
52
63
  const injects = initInject(hexo.base_dir);
53
64
  hexo.execFilterSync('theme_inject', injects);
54
65
  hexo.theme.config.injects = {};
66
+ // Inject stylus
55
67
  injects_point_1.default.styles.forEach(type => {
56
68
  hexo.theme.config.injects[type] = injects[type].files;
57
69
  });
70
+ // Inject views
58
71
  injects_point_1.default.views.forEach(type => {
59
72
  const configs = Object.create(null);
60
73
  hexo.theme.config.injects[type] = [];
74
+ // Add or override view.
61
75
  injects[type].raws.forEach((injectObj, index) => {
62
76
  const name = `inject/${type}/${injectObj.name}`;
63
77
  hexo.theme.setView(name, injectObj.raw);
@@ -68,6 +82,7 @@ exports.default = (hexo) => {
68
82
  order: injectObj.args[2] || index
69
83
  };
70
84
  });
85
+ // Views sort.
71
86
  hexo.theme.config.injects[type] = Object.values(configs)
72
87
  .sort((x, y) => x.order - y.order);
73
88
  });
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ /* global hexo */
6
7
  const js_yaml_1 = __importDefault(require("js-yaml"));
7
8
  function postMedia(args, content) {
8
9
  if (!args[0] || !content) {
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getVendorLink = void 0;
4
+ function getVendorLink(hexo, source) {
5
+ const VendorsCfg = hexo.theme.config.vendors;
6
+ const tagIdx = source.indexOf('|');
7
+ if (tagIdx !== -1) {
8
+ return `${VendorsCfg.cdns[source.substring(0, tagIdx)]}/${source.substring(tagIdx + 1)}`;
9
+ }
10
+ else {
11
+ return source;
12
+ }
13
+ }
14
+ exports.getVendorLink = getVendorLink;
@@ -1,52 +1,53 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.menuActive = exports.goToCommentHandle = exports.goToBottomHandle = exports.backToTopHandle = exports.sidebarTOC = exports.sideBarTab = exports.sideBarToggleHandle = void 0;
4
- const globalVars_1 = require("../globals/globalVars");
5
- const tools_1 = require("../globals/tools");
6
- const anime_1 = require("../library/anime");
7
- const dom_1 = require("../library/dom");
8
- const sideBarToggleHandle = (event, force) => {
9
- if (globalVars_1.sideBar.hasClass('on')) {
10
- globalVars_1.sideBar.removeClass('on');
11
- globalVars_1.menuToggle.removeClass('close');
1
+ /* 边栏分区 */
2
+ import { Container, diffY, menuToggle, showContents, sideBar } from '../globals/globalVars';
3
+ import { clipBoard } from '../globals/tools';
4
+ import { pageScroll, transition } from '../library/anime';
5
+ import { $dom } from '../library/dom';
6
+ export const sideBarToggleHandle = (event, force) => {
7
+ if (sideBar.hasClass('on')) {
8
+ sideBar.removeClass('on');
9
+ menuToggle.removeClass('close');
12
10
  if (force) {
13
- globalVars_1.sideBar.style = '';
11
+ // @ts-ignore
12
+ // noinspection JSConstantReassignment
13
+ sideBar.style = '';
14
14
  }
15
15
  else {
16
- (0, anime_1.transition)(globalVars_1.sideBar, 'slideRightOut');
16
+ transition(sideBar, 'slideRightOut');
17
17
  }
18
18
  }
19
19
  else {
20
20
  if (force) {
21
- globalVars_1.sideBar.style = '';
21
+ // @ts-ignore
22
+ // noinspection JSConstantReassignment
23
+ sideBar.style = '';
22
24
  }
23
25
  else {
24
- (0, anime_1.transition)(globalVars_1.sideBar, 'slideRightIn', () => {
25
- globalVars_1.sideBar.addClass('on');
26
- globalVars_1.menuToggle.addClass('close');
26
+ transition(sideBar, 'slideRightIn', () => {
27
+ sideBar.addClass('on');
28
+ menuToggle.addClass('close');
27
29
  });
28
30
  }
29
31
  }
30
32
  };
31
- exports.sideBarToggleHandle = sideBarToggleHandle;
32
- const sideBarTab = () => {
33
- const sideBarInner = globalVars_1.sideBar.child('.inner');
34
- if (globalVars_1.sideBar.child('.tab')) {
35
- sideBarInner.removeChild(globalVars_1.sideBar.child('.tab'));
33
+ export const sideBarTab = () => {
34
+ const sideBarInner = sideBar.child('.inner');
35
+ if (sideBar.child('.tab')) {
36
+ sideBarInner.removeChild(sideBar.child('.tab'));
36
37
  }
37
38
  const list = document.createElement('ul');
38
39
  let active = 'active';
39
40
  list.className = 'tab';
40
41
  ['contents', 'related', 'overview'].forEach((item) => {
41
- const element = globalVars_1.sideBar.child('.panel.' + item);
42
+ const element = sideBar.child('.panel.' + item);
42
43
  if (element.innerHTML.trim().length < 1) {
43
44
  if (item === 'contents') {
44
- globalVars_1.showContents.display('none');
45
+ showContents.display('none');
45
46
  }
46
47
  return;
47
48
  }
48
49
  if (item === 'contents') {
49
- globalVars_1.showContents.display('');
50
+ showContents.display('');
50
51
  }
51
52
  const tab = document.createElement('li');
52
53
  const span = document.createElement('span');
@@ -65,13 +66,13 @@ const sideBarTab = () => {
65
66
  const target = event.currentTarget;
66
67
  if (target.hasClass('active'))
67
68
  return;
68
- globalVars_1.sideBar.find('.tab .item').forEach((element) => {
69
+ sideBar.find('.tab .item').forEach((element) => {
69
70
  element.removeClass('active');
70
71
  });
71
- globalVars_1.sideBar.find('.panel').forEach((element) => {
72
+ sideBar.find('.panel').forEach((element) => {
72
73
  element.removeClass('active');
73
74
  });
74
- globalVars_1.sideBar.child('.panel.' + target.className.replace(' item', '')).addClass('active');
75
+ sideBar.child('.panel.' + target.className.replace(' item', '')).addClass('active');
75
76
  target.addClass('active');
76
77
  });
77
78
  list.appendChild(tab);
@@ -79,14 +80,13 @@ const sideBarTab = () => {
79
80
  });
80
81
  if (list.childNodes.length > 1) {
81
82
  sideBarInner.insertBefore(list, sideBarInner.childNodes[0]);
82
- globalVars_1.sideBar.child('.panels').style.paddingTop = '';
83
+ sideBar.child('.panels').style.paddingTop = '';
83
84
  }
84
85
  else {
85
- globalVars_1.sideBar.child('.panels').style.paddingTop = '.625rem';
86
+ sideBar.child('.panels').style.paddingTop = '.625rem';
86
87
  }
87
88
  };
88
- exports.sideBarTab = sideBarTab;
89
- const sidebarTOC = () => {
89
+ export const sidebarTOC = () => {
90
90
  const activateNavByIndex = (index) => {
91
91
  const target = navItems[index];
92
92
  if (!target)
@@ -94,7 +94,7 @@ const sidebarTOC = () => {
94
94
  if (target.hasClass('current')) {
95
95
  return;
96
96
  }
97
- dom_1.$dom.each('.toc .active', (element) => {
97
+ $dom.each('.toc .active', (element) => {
98
98
  element && element.removeClass('active current');
99
99
  });
100
100
  sections.forEach((element) => {
@@ -106,46 +106,49 @@ const sidebarTOC = () => {
106
106
  while (!parent.matches('.contents')) {
107
107
  if (parent.matches('li')) {
108
108
  parent.addClass('active');
109
- const t = (0, dom_1.$dom)(parent.child('a.toc-link').attr('href'));
109
+ const t = $dom(parent.child('a.toc-link').attr('href'));
110
110
  if (t) {
111
111
  t.addClass('active');
112
112
  }
113
113
  }
114
114
  parent = parent.parentNode;
115
115
  }
116
- if (getComputedStyle(globalVars_1.sideBar).display !== 'none' && tocElement.hasClass('active')) {
117
- (0, anime_1.pageScroll)(tocElement, target.offsetTop - (tocElement.offsetHeight / 4));
116
+ // Scrolling to center active TOC element if TOC content is taller than viewport.
117
+ if (getComputedStyle(sideBar).display !== 'none' && tocElement.hasClass('active')) {
118
+ pageScroll(tocElement, target.offsetTop - (tocElement.offsetHeight / 4));
118
119
  }
119
120
  };
120
- const navItems = dom_1.$dom.all('.contents li');
121
+ const navItems = $dom.all('.contents li');
121
122
  if (navItems.length < 1) {
122
123
  return;
123
124
  }
125
+ // @ts-ignore
124
126
  let sections = [...navItems];
125
127
  let activeLock = null;
126
128
  sections = sections.map((element, index) => {
127
129
  const link = element.child('a.toc-link');
128
- const anchor = (0, dom_1.$dom)(decodeURI(link.attr('href')));
130
+ const anchor = $dom(decodeURI(link.attr('href')));
129
131
  if (!anchor)
130
132
  return null;
131
133
  const alink = anchor.child('a.anchor');
132
134
  const anchorScroll = (event) => {
133
135
  event.preventDefault();
134
- const target = (0, dom_1.$dom)(decodeURI(event.currentTarget.attr('href')));
136
+ const target = $dom(decodeURI(event.currentTarget.attr('href')));
135
137
  activeLock = index;
136
- (0, anime_1.pageScroll)(target, null, () => {
138
+ pageScroll(target, null, () => {
137
139
  activateNavByIndex(index);
138
140
  activeLock = null;
139
141
  });
140
142
  };
143
+ // TOC item animation navigate.
141
144
  link.addEventListener('click', anchorScroll);
142
145
  alink && alink.addEventListener('click', (event) => {
143
146
  anchorScroll(event);
144
- (0, tools_1.clipBoard)(CONFIG.hostname + '/' + LOCAL.path + event.currentTarget.attr('href'));
147
+ clipBoard(CONFIG.hostname + '/' + LOCAL.path + event.currentTarget.attr('href'));
145
148
  });
146
149
  return anchor;
147
150
  });
148
- const tocElement = globalVars_1.sideBar.child('.contents.panel');
151
+ const tocElement = sideBar.child('.contents.panel');
149
152
  const findIndex = (entries) => {
150
153
  let index = 0;
151
154
  let entry = entries[index];
@@ -165,7 +168,7 @@ const sidebarTOC = () => {
165
168
  };
166
169
  const createIntersectionObserver = () => {
167
170
  const observer = new IntersectionObserver((entries) => {
168
- const index = findIndex(entries) + (globalVars_1.diffY < 0 ? 1 : 0);
171
+ const index = findIndex(entries) + (diffY < 0 ? 1 : 0);
169
172
  if (activeLock === null) {
170
173
  activateNavByIndex(index);
171
174
  }
@@ -178,21 +181,17 @@ const sidebarTOC = () => {
178
181
  };
179
182
  createIntersectionObserver();
180
183
  };
181
- exports.sidebarTOC = sidebarTOC;
182
- const backToTopHandle = () => {
183
- (0, anime_1.pageScroll)(0);
184
+ export const backToTopHandle = () => {
185
+ pageScroll(0);
184
186
  };
185
- exports.backToTopHandle = backToTopHandle;
186
- const goToBottomHandle = () => {
187
- (0, anime_1.pageScroll)(parseInt(String(globalVars_1.Container.changeOrGetHeight())));
187
+ export const goToBottomHandle = () => {
188
+ pageScroll(parseInt(String(Container.changeOrGetHeight())));
188
189
  };
189
- exports.goToBottomHandle = goToBottomHandle;
190
- const goToCommentHandle = () => {
191
- (0, anime_1.pageScroll)((0, dom_1.$dom)('#comments'));
190
+ export const goToCommentHandle = () => {
191
+ pageScroll($dom('#comments'));
192
192
  };
193
- exports.goToCommentHandle = goToCommentHandle;
194
- const menuActive = () => {
195
- dom_1.$dom.each('.menu .item:not(.title)', (element) => {
193
+ export const menuActive = () => {
194
+ $dom.each('.menu .item:not(.title)', (element) => {
196
195
  const target = element.child('a[href]');
197
196
  const parentItem = element.parentNode.parentNode;
198
197
  if (!target)
@@ -209,4 +208,3 @@ const menuActive = () => {
209
208
  }
210
209
  });
211
210
  };
212
- exports.menuActive = menuActive;