hexo-theme-shokax 0.4.4 → 0.4.6-beta1
Sign up to get free protection for your applications and to get access to all the features.
- package/CODE_OF_CONDUCT.md +128 -128
- package/CONTRIBUTING.md +58 -58
- package/LICENSE +660 -660
- package/LICENSE-shoka +21 -21
- package/README.md +99 -98
- package/README_en.MD +91 -90
- package/UsageRestrictions.md +25 -25
- package/_config.yml +381 -388
- package/_images.yml +9 -9
- package/eslint.config.mjs +55 -55
- package/index.html +231 -0
- package/languages/README.md +19 -19
- package/languages/default.yml +1 -1
- package/languages/en.yml +153 -153
- package/languages/ja.yml +153 -153
- package/languages/zh-CN.yml +153 -153
- package/languages/zh-HK.yml +153 -153
- package/languages/zh-TW.yml +153 -153
- package/layout/_alternate/atom.ejs +30 -30
- package/layout/_alternate/json.ejs +16 -16
- package/layout/_alternate/rss.ejs +34 -34
- package/layout/_mixin/breadcrumb.pug +33 -33
- package/layout/_mixin/card.pug +38 -38
- package/layout/_mixin/comment.pug +6 -6
- package/layout/_mixin/postmeta.pug +29 -29
- package/layout/_mixin/segment.pug +35 -35
- package/layout/_mixin/sidebar.pug +40 -40
- package/layout/_mixin/widgets.pug +28 -28
- package/layout/_partials/footer.pug +43 -43
- package/layout/_partials/head/head.pug +55 -56
- package/layout/_partials/head/head_com.pug +24 -24
- package/layout/_partials/head/pwa.pug +18 -18
- package/layout/_partials/header.pug +18 -18
- package/layout/_partials/layout.pug +140 -140
- package/layout/_partials/loading.pug +13 -13
- package/layout/_partials/pagination.pug +4 -4
- package/layout/_partials/post/copyright.pug +20 -20
- package/layout/_partials/post/footer.pug +17 -17
- package/layout/_partials/post/nav.pug +13 -13
- package/layout/_partials/post/post.pug +41 -41
- package/layout/_partials/post/reward.pug +18 -18
- package/layout/_partials/sidebar/menu.pug +37 -37
- package/layout/_partials/sidebar/overview.pug +42 -42
- package/layout/_partials/third-party/baidu-analytics.pug +11 -11
- package/layout/_partials/third-party/clarity.pug +8 -8
- package/layout/_partials/third-party/google-analytics.pug +9 -9
- package/layout/archive.pug +118 -118
- package/layout/category.pug +59 -59
- package/layout/index.pug +33 -33
- package/layout/page.pug +55 -55
- package/layout/post.pug +36 -36
- package/layout/tag.pug +43 -43
- package/meta.json +6431 -0
- package/package.json +72 -70
- package/scripts/helpers/engine.js +10 -0
- package/scripts/plugin/check.js +2 -2
- package/scripts/tags/links.js +4 -4
- package/source/assets/algolia_logo.svg +9 -9
- package/source/assets/logo.svg +16 -16
- package/source/css/_colors.styl +207 -207
- package/source/css/_common/components/components.styl +6 -6
- package/source/css/_common/components/highlight/highlight.styl +357 -357
- package/source/css/_common/components/highlight/operation.styl +21 -21
- package/source/css/_common/components/pages/collapse.styl +119 -119
- package/source/css/_common/components/pages/home.styl +391 -391
- package/source/css/_common/components/pages/pages.styl +56 -56
- package/source/css/_common/components/pages/tag-cloud.styl +12 -12
- package/source/css/_common/components/post/breadcrumb.styl +39 -39
- package/source/css/_common/components/post/copyright.styl +41 -41
- package/source/css/_common/components/post/expand.styl +263 -263
- package/source/css/_common/components/post/footer.styl +11 -11
- package/source/css/_common/components/post/header.styl +79 -79
- package/source/css/_common/components/post/nav.styl +64 -64
- package/source/css/_common/components/post/post.styl +29 -29
- package/source/css/_common/components/post/reward.styl +50 -50
- package/source/css/_common/components/post/rtl.styl +12 -12
- package/source/css/_common/components/post/tags.styl +39 -39
- package/source/css/_common/components/tags/collapse.styl +72 -72
- package/source/css/_common/components/tags/container.styl +49 -49
- package/source/css/_common/components/tags/label.styl +12 -12
- package/source/css/_common/components/tags/links.styl +77 -77
- package/source/css/_common/components/tags/list.styl +131 -131
- package/source/css/_common/components/tags/note.styl +70 -70
- package/source/css/_common/components/tags/player.styl +361 -361
- package/source/css/_common/components/tags/quiz.styl +200 -200
- package/source/css/_common/components/tags/tabs.styl +89 -89
- package/source/css/_common/components/tags/tags.styl +9 -9
- package/source/css/_common/components/third-party/loading.styl +222 -222
- package/source/css/_common/components/third-party/mermaid/class.styl +90 -90
- package/source/css/_common/components/third-party/mermaid/flowchart.styl +72 -72
- package/source/css/_common/components/third-party/mermaid/gantt.styl +251 -251
- package/source/css/_common/components/third-party/mermaid/git.styl +7 -7
- package/source/css/_common/components/third-party/mermaid/mermaid.styl +37 -37
- package/source/css/_common/components/third-party/mermaid/pie.styl +9 -9
- package/source/css/_common/components/third-party/mermaid/sequence.styl +95 -95
- package/source/css/_common/components/third-party/mermaid/state.styl +130 -130
- package/source/css/_common/components/third-party/pace.styl +18 -18
- package/source/css/_common/components/third-party/search.styl +167 -167
- package/source/css/_common/components/third-party/theme.styl +151 -151
- package/source/css/_common/components/third-party/third-party.styl +22 -22
- package/source/css/_common/components/third-party/widgets.styl +57 -57
- package/source/css/_common/outline/footer/footer.styl +67 -67
- package/source/css/_common/outline/header/brand.styl +77 -77
- package/source/css/_common/outline/header/header.styl +20 -20
- package/source/css/_common/outline/header/image.styl +85 -85
- package/source/css/_common/outline/header/menu.styl +117 -117
- package/source/css/_common/outline/header/nav.styl +81 -81
- package/source/css/_common/outline/header/right.styl +15 -15
- package/source/css/_common/outline/header/tool.styl +207 -207
- package/source/css/_common/outline/header/waves.styl +57 -57
- package/source/css/_common/outline/mobile.styl +46 -46
- package/source/css/_common/outline/outline.styl +78 -78
- package/source/css/_common/outline/sidebar/author.styl +59 -59
- package/source/css/_common/outline/sidebar/dimmer.styl +23 -23
- package/source/css/_common/outline/sidebar/menu.styl +63 -63
- package/source/css/_common/outline/sidebar/quick.styl +43 -43
- package/source/css/_common/outline/sidebar/related.styl +56 -56
- package/source/css/_common/outline/sidebar/sidebar.styl +80 -80
- package/source/css/_common/outline/sidebar/social.styl +69 -69
- package/source/css/_common/outline/sidebar/state.styl +37 -37
- package/source/css/_common/outline/sidebar/tab.styl +71 -71
- package/source/css/_common/outline/sidebar/toc.styl +47 -47
- package/source/css/_common/scaffolding/animate.styl +322 -322
- package/source/css/_common/scaffolding/base.styl +190 -190
- package/source/css/_common/scaffolding/buttons.styl +48 -48
- package/source/css/_common/scaffolding/divider.styl +36 -36
- package/source/css/_common/scaffolding/iconfont.styl +443 -443
- package/source/css/_common/scaffolding/normalize.styl +273 -273
- package/source/css/_common/scaffolding/pagination.styl +81 -81
- package/source/css/_common/scaffolding/ribbon.styl +38 -38
- package/source/css/_common/scaffolding/scaffolding.styl +14 -14
- package/source/css/_common/scaffolding/scrollbar.styl +37 -37
- package/source/css/_common/scaffolding/tables.styl +50 -50
- package/source/css/_common/scaffolding/tip.styl +19 -19
- package/source/css/_common/scaffolding/toggles.styl +59 -59
- package/source/css/_iconfont.styl +455 -455
- package/source/css/_mixins.styl +148 -148
- package/source/css/_variables.styl +89 -89
- package/source/css/app.styl +41 -41
- package/source/css/mermaid.styl +5 -5
- package/source/css/optimize.styl +5 -5
- package/source/js/_app/components/comments.js +59 -0
- package/source/js/_app/components/comments.ts +88 -89
- package/source/js/_app/components/sidebar.js +244 -0
- package/source/js/_app/components/sidebar.ts +239 -239
- package/source/js/_app/components/tcomments.js +47 -0
- package/source/js/_app/components/tcomments.ts +54 -55
- package/source/js/_app/globals/globalVars.ts +99 -99
- package/source/js/_app/globals/handles.js +105 -0
- package/source/js/_app/globals/handles.ts +124 -123
- package/source/js/_app/globals/themeColor.ts +63 -64
- package/source/js/_app/globals/thirdparty.ts +63 -63
- package/source/js/_app/globals/tools.ts +75 -75
- package/source/js/_app/library/anime.ts +110 -110
- package/source/js/_app/library/declare.d.ts +128 -133
- package/source/js/_app/library/dom.ts +28 -26
- package/source/js/_app/library/loadFile.js +43 -0
- package/source/js/_app/library/loadFile.ts +47 -43
- package/source/js/_app/library/proto.ts +137 -141
- package/source/js/_app/library/scriptPjax.ts +72 -72
- package/source/js/_app/library/storage.ts +12 -12
- package/source/js/_app/library/vue.js +52 -0
- package/source/js/_app/library/vue.ts +49 -50
- package/source/js/_app/page/common.js +45 -0
- package/source/js/_app/page/common.ts +43 -42
- package/source/js/_app/page/fancybox.js +70 -0
- package/source/js/_app/page/fancybox.ts +72 -71
- package/source/js/_app/page/post.js +253 -0
- package/source/js/_app/page/post.ts +266 -266
- package/source/js/_app/page/search.js +111 -0
- package/source/js/_app/page/search.ts +115 -115
- package/source/js/_app/page/tab.ts +60 -60
- package/source/js/_app/pjax/domInit.js +80 -0
- package/source/js/_app/pjax/domInit.ts +97 -97
- package/source/js/_app/pjax/refresh.js +137 -0
- package/source/js/_app/pjax/refresh.ts +140 -138
- package/source/js/_app/pjax/siteInit.js +115 -0
- package/source/js/_app/pjax/siteInit.ts +106 -104
- package/source/js/_app/player.js +777 -0
- package/source/js/_app/player.ts +798 -799
- package/toolbox/compiler.mjs +73 -0
- package/toolbox/hoistdep.mjs +6 -0
- package/toolbox/lib.mjs +40 -0
@@ -1,89 +1,88 @@
|
|
1
|
-
import { CONFIG } from '../globals/globalVars'
|
2
|
-
import { init, RecentComments } from '@waline/client'
|
3
|
-
import { pageviewCount } from '@waline/client/pageview'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
//
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
const
|
47
|
-
const
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
const
|
70
|
-
const
|
71
|
-
const
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
commentTime.
|
76
|
-
|
77
|
-
commentLink
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
commentLink.appendChild(
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
}
|
1
|
+
import { CONFIG } from '../globals/globalVars'
|
2
|
+
import { init, RecentComments } from '@waline/client'
|
3
|
+
import { pageviewCount } from '@waline/client/pageview'
|
4
|
+
await import('@waline/client/style')
|
5
|
+
|
6
|
+
export const walineComment = function () {
|
7
|
+
init({
|
8
|
+
el: '#comments',
|
9
|
+
serverURL: CONFIG.waline.serverURL,
|
10
|
+
lang: CONFIG.waline.lang,
|
11
|
+
locale: CONFIG.waline.locale,
|
12
|
+
emoji: CONFIG.waline.emoji,
|
13
|
+
meta: CONFIG.waline.meta,
|
14
|
+
requiredMeta: CONFIG.waline.requiredMeta,
|
15
|
+
wordLimit: CONFIG.waline.wordLimit,
|
16
|
+
pageSize: CONFIG.waline.pageSize,
|
17
|
+
pageview: CONFIG.waline.pageview,
|
18
|
+
path: window.location.pathname,
|
19
|
+
dark: 'html[data-theme="dark"]'
|
20
|
+
})
|
21
|
+
}
|
22
|
+
|
23
|
+
export const walinePageview = function () {
|
24
|
+
// TODO waline 上游此模块存在问题
|
25
|
+
pageviewCount({
|
26
|
+
serverURL: CONFIG.waline.serverURL,
|
27
|
+
path: window.location.pathname
|
28
|
+
})
|
29
|
+
}
|
30
|
+
|
31
|
+
export const walineRecentComments = async function () {
|
32
|
+
const root = shokax_siteURL.replace(/^(https?:\/\/)?[^/]*/, '')
|
33
|
+
let items = []
|
34
|
+
const { comments } = await RecentComments({
|
35
|
+
serverURL: CONFIG.waline.serverURL.replace(/\/+$/, ''),
|
36
|
+
count: 10
|
37
|
+
})
|
38
|
+
// TODO 疑似 waline API 返回格式与文档不一致,需要确认是否为上游问题
|
39
|
+
// @ts-ignore
|
40
|
+
comments.data.forEach(function (item) {
|
41
|
+
let cText = (item.orig.length > 50) ? item.orig.substring(0, 50) + '...' : item.orig
|
42
|
+
item.url = item.url.startsWith('/') ? item.url : '/' + item.url
|
43
|
+
const siteLink = item.url + '#' + item.objectId
|
44
|
+
|
45
|
+
const time = new Date(item.time)
|
46
|
+
const now = new Date()
|
47
|
+
const diff = now.valueOf() - time.valueOf()
|
48
|
+
let dateStr:string
|
49
|
+
if (diff < 3600000) {
|
50
|
+
dateStr = `${Math.floor(diff / 60000)} 分钟前`
|
51
|
+
} else if (diff < 86400000) {
|
52
|
+
dateStr = `${Math.floor(diff / 3600000)} 小时前`
|
53
|
+
} else if (diff < 2592000000) {
|
54
|
+
dateStr = `${Math.floor(diff / 86400000)} 天前`
|
55
|
+
} else {
|
56
|
+
dateStr = `${time.getFullYear()}-${time.getMonth() + 1}-${time.getDate()}`
|
57
|
+
}
|
58
|
+
|
59
|
+
items.push({
|
60
|
+
href: siteLink,
|
61
|
+
nick: item.nick,
|
62
|
+
time: dateStr,
|
63
|
+
text: cText
|
64
|
+
})
|
65
|
+
})
|
66
|
+
const newComments = new DocumentFragment()
|
67
|
+
items.forEach(function (item) {
|
68
|
+
const commentEl = document.createElement('li')
|
69
|
+
const commentLink = document.createElement('a')
|
70
|
+
const commentTime = document.createElement('span')
|
71
|
+
const commentText = document.createElement('span')
|
72
|
+
|
73
|
+
commentText.innerText = item.text
|
74
|
+
commentTime.className = 'breadcrumb'
|
75
|
+
commentTime.innerText = `${item.nick} @ ${item.time}`
|
76
|
+
commentLink.href = root + item.href
|
77
|
+
commentLink['data-pjax-state'] = 'data-pjax-state'
|
78
|
+
commentEl.className = 'item'
|
79
|
+
|
80
|
+
commentText.appendChild(document.createElement('br'))
|
81
|
+
commentLink.appendChild(commentTime)
|
82
|
+
commentLink.appendChild(commentText)
|
83
|
+
commentEl.appendChild(commentLink)
|
84
|
+
newComments.appendChild(commentEl)
|
85
|
+
})
|
86
|
+
|
87
|
+
document.getElementById("new-comment").appendChild(newComments)
|
88
|
+
}
|
@@ -0,0 +1,244 @@
|
|
1
|
+
"use strict";
|
2
|
+
/* 边栏分区 */
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
4
|
+
if (k2 === undefined) k2 = k;
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
8
|
+
}
|
9
|
+
Object.defineProperty(o, k2, desc);
|
10
|
+
}) : (function(o, m, k, k2) {
|
11
|
+
if (k2 === undefined) k2 = k;
|
12
|
+
o[k2] = m[k];
|
13
|
+
}));
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
16
|
+
}) : function(o, v) {
|
17
|
+
o["default"] = v;
|
18
|
+
});
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
20
|
+
if (mod && mod.__esModule) return mod;
|
21
|
+
var result = {};
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
23
|
+
__setModuleDefault(result, mod);
|
24
|
+
return result;
|
25
|
+
};
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
27
|
+
exports.menuActive = exports.goToCommentHandle = exports.goToBottomHandle = exports.backToTopHandle = exports.sidebarTOC = exports.sideBarTab = exports.sideBarToggleHandle = void 0;
|
28
|
+
const globalVars_1 = require("../globals/globalVars");
|
29
|
+
const tools_1 = require("../globals/tools");
|
30
|
+
const anime_1 = require("../library/anime");
|
31
|
+
const dom_1 = require("../library/dom");
|
32
|
+
const proto_1 = __importStar(require("../library/proto"));
|
33
|
+
(0, proto_1.default)();
|
34
|
+
const sideBarToggleHandle = (event, force) => {
|
35
|
+
if (globalVars_1.sideBar.hasClass('on')) {
|
36
|
+
globalVars_1.sideBar.removeClass('on');
|
37
|
+
globalVars_1.menuToggle.removeClass('close');
|
38
|
+
if (force) {
|
39
|
+
// @ts-ignore
|
40
|
+
// noinspection JSConstantReassignment
|
41
|
+
globalVars_1.sideBar.style = '';
|
42
|
+
}
|
43
|
+
else {
|
44
|
+
(0, anime_1.transition)(globalVars_1.sideBar, 'slideRightOut');
|
45
|
+
}
|
46
|
+
}
|
47
|
+
else {
|
48
|
+
if (force) {
|
49
|
+
// @ts-ignore
|
50
|
+
// noinspection JSConstantReassignment
|
51
|
+
globalVars_1.sideBar.style = '';
|
52
|
+
}
|
53
|
+
else {
|
54
|
+
(0, anime_1.transition)(globalVars_1.sideBar, 'slideRightIn', () => {
|
55
|
+
globalVars_1.sideBar.addClass('on');
|
56
|
+
globalVars_1.menuToggle.addClass('close');
|
57
|
+
});
|
58
|
+
}
|
59
|
+
}
|
60
|
+
};
|
61
|
+
exports.sideBarToggleHandle = sideBarToggleHandle;
|
62
|
+
const sideBarTab = () => {
|
63
|
+
const sideBarInner = (0, proto_1.child)(globalVars_1.sideBar, '.inner');
|
64
|
+
if (globalVars_1.sideBar.child('.tab')) {
|
65
|
+
sideBarInner.removeChild(globalVars_1.sideBar.child('.tab'));
|
66
|
+
}
|
67
|
+
const list = document.createElement('ul');
|
68
|
+
let active = 'active';
|
69
|
+
list.className = 'tab';
|
70
|
+
['contents', 'related', 'overview'].forEach((item) => {
|
71
|
+
const element = globalVars_1.sideBar.child('.panel.' + item);
|
72
|
+
if (element.innerHTML.trim().length < 1) {
|
73
|
+
if (item === 'contents') {
|
74
|
+
(0, proto_1.setDisplay)(globalVars_1.showContents, 'none');
|
75
|
+
}
|
76
|
+
return;
|
77
|
+
}
|
78
|
+
if (item === 'contents') {
|
79
|
+
(0, proto_1.setDisplay)(globalVars_1.showContents, '');
|
80
|
+
}
|
81
|
+
const tab = document.createElement('li');
|
82
|
+
const span = document.createElement('span');
|
83
|
+
const text = document.createTextNode(element.getAttribute('data-title'));
|
84
|
+
span.appendChild(text);
|
85
|
+
tab.appendChild(span);
|
86
|
+
tab.addClass(item + ' item');
|
87
|
+
if (active) {
|
88
|
+
element.addClass(active);
|
89
|
+
tab.addClass(active);
|
90
|
+
}
|
91
|
+
else {
|
92
|
+
element.removeClass('active');
|
93
|
+
}
|
94
|
+
tab.addEventListener('click', (event) => {
|
95
|
+
const target = event.currentTarget;
|
96
|
+
if (target.hasClass('active'))
|
97
|
+
return;
|
98
|
+
globalVars_1.sideBar.find('.tab .item').forEach((element) => {
|
99
|
+
element.removeClass('active');
|
100
|
+
});
|
101
|
+
globalVars_1.sideBar.find('.panel').forEach((element) => {
|
102
|
+
element.removeClass('active');
|
103
|
+
});
|
104
|
+
globalVars_1.sideBar.child('.panel.' + target.className.replace(' item', '')).addClass('active');
|
105
|
+
target.addClass('active');
|
106
|
+
});
|
107
|
+
list.appendChild(tab);
|
108
|
+
active = '';
|
109
|
+
});
|
110
|
+
if (list.childNodes.length > 1) {
|
111
|
+
sideBarInner.insertBefore(list, sideBarInner.childNodes[0]);
|
112
|
+
globalVars_1.sideBar.child('.panels').style.paddingTop = '';
|
113
|
+
}
|
114
|
+
else {
|
115
|
+
globalVars_1.sideBar.child('.panels').style.paddingTop = '.625rem';
|
116
|
+
}
|
117
|
+
};
|
118
|
+
exports.sideBarTab = sideBarTab;
|
119
|
+
const sidebarTOC = () => {
|
120
|
+
const activateNavByIndex = (index) => {
|
121
|
+
const target = navItems[index];
|
122
|
+
if (!target)
|
123
|
+
return;
|
124
|
+
if (target.hasClass('current')) {
|
125
|
+
return;
|
126
|
+
}
|
127
|
+
dom_1.$dom.each('.toc .active', (element) => {
|
128
|
+
element && element.removeClass('active current');
|
129
|
+
});
|
130
|
+
sections.forEach((element) => {
|
131
|
+
element && element.removeClass('active');
|
132
|
+
});
|
133
|
+
target.addClass('active current');
|
134
|
+
sections[index] && sections[index].addClass('active');
|
135
|
+
let parent = target.parentNode;
|
136
|
+
while (!parent.matches('.contents')) {
|
137
|
+
if (parent.matches('li')) {
|
138
|
+
parent.addClass('active');
|
139
|
+
const t = (0, dom_1.$dom)(parent.child('a.toc-link').getAttribute('href'));
|
140
|
+
if (t) {
|
141
|
+
t.addClass('active');
|
142
|
+
}
|
143
|
+
}
|
144
|
+
parent = parent.parentNode;
|
145
|
+
}
|
146
|
+
// Scrolling to center active TOC element if TOC content is taller than viewport.
|
147
|
+
if (getComputedStyle(globalVars_1.sideBar).display !== 'none' && tocElement.hasClass('active')) {
|
148
|
+
(0, anime_1.pageScroll)(tocElement, target.offsetTop - (tocElement.offsetHeight / 4));
|
149
|
+
}
|
150
|
+
};
|
151
|
+
const navItems = dom_1.$dom.all('.contents li');
|
152
|
+
if (navItems.length < 1) {
|
153
|
+
return;
|
154
|
+
}
|
155
|
+
let sections = [...navItems];
|
156
|
+
let activeLock = null;
|
157
|
+
sections = sections.map((element, index) => {
|
158
|
+
const link = element.child('a.toc-link');
|
159
|
+
const anchor = (0, dom_1.$dom)(decodeURI(link.getAttribute('href')));
|
160
|
+
if (!anchor)
|
161
|
+
return null;
|
162
|
+
const alink = anchor.child('a.anchor');
|
163
|
+
const anchorScroll = (event) => {
|
164
|
+
event.preventDefault();
|
165
|
+
const target = (0, dom_1.$dom)(decodeURI(event.currentTarget.getAttribute('href')));
|
166
|
+
activeLock = index;
|
167
|
+
(0, anime_1.pageScroll)(target, null, () => {
|
168
|
+
activateNavByIndex(index);
|
169
|
+
activeLock = null;
|
170
|
+
});
|
171
|
+
};
|
172
|
+
// TOC item animation navigate.
|
173
|
+
link.addEventListener('click', anchorScroll);
|
174
|
+
alink && alink.addEventListener('click', (event) => {
|
175
|
+
anchorScroll(event);
|
176
|
+
(0, tools_1.clipBoard)(globalVars_1.CONFIG.hostname + '/' + LOCAL.path + event.currentTarget.getAttribute('href'));
|
177
|
+
});
|
178
|
+
return anchor;
|
179
|
+
});
|
180
|
+
const tocElement = globalVars_1.sideBar.child('.contents.panel');
|
181
|
+
const findIndex = (entries) => {
|
182
|
+
let index = 0;
|
183
|
+
let entry = entries[index];
|
184
|
+
if (entry.boundingClientRect.top > 0) {
|
185
|
+
index = sections.indexOf(entry.target);
|
186
|
+
return index === 0 ? 0 : index - 1;
|
187
|
+
}
|
188
|
+
for (; index < entries.length; index++) {
|
189
|
+
if (entries[index].boundingClientRect.top <= 0) {
|
190
|
+
entry = entries[index];
|
191
|
+
}
|
192
|
+
else {
|
193
|
+
return sections.indexOf(entry.target);
|
194
|
+
}
|
195
|
+
}
|
196
|
+
return sections.indexOf(entry.target);
|
197
|
+
};
|
198
|
+
const createIntersectionObserver = () => {
|
199
|
+
const observer = new IntersectionObserver((entries) => {
|
200
|
+
const index = findIndex(entries) + (globalVars_1.diffY < 0 ? 1 : 0);
|
201
|
+
if (activeLock === null) {
|
202
|
+
activateNavByIndex(index);
|
203
|
+
}
|
204
|
+
}, {
|
205
|
+
rootMargin: '0px 0px -100% 0px', threshold: 0
|
206
|
+
});
|
207
|
+
sections.forEach((element) => {
|
208
|
+
element && observer.observe(element);
|
209
|
+
});
|
210
|
+
};
|
211
|
+
createIntersectionObserver();
|
212
|
+
};
|
213
|
+
exports.sidebarTOC = sidebarTOC;
|
214
|
+
const backToTopHandle = () => {
|
215
|
+
(0, anime_1.pageScroll)(0);
|
216
|
+
};
|
217
|
+
exports.backToTopHandle = backToTopHandle;
|
218
|
+
const goToBottomHandle = () => {
|
219
|
+
(0, anime_1.pageScroll)(parseInt(String((0, proto_1.getHeight)(globalVars_1.Container))));
|
220
|
+
};
|
221
|
+
exports.goToBottomHandle = goToBottomHandle;
|
222
|
+
const goToCommentHandle = () => {
|
223
|
+
(0, anime_1.pageScroll)((0, dom_1.$dom)('#comments'));
|
224
|
+
};
|
225
|
+
exports.goToCommentHandle = goToCommentHandle;
|
226
|
+
const menuActive = () => {
|
227
|
+
dom_1.$dom.each('.menu .item:not(.title)', (element) => {
|
228
|
+
const target = element.child('a[href]');
|
229
|
+
const parentItem = element.parentNode.parentNode;
|
230
|
+
if (!target)
|
231
|
+
return;
|
232
|
+
const isSamePath = target.pathname === location.pathname || target.pathname === location.pathname.replace('index.html', '');
|
233
|
+
const isSubPath = !globalVars_1.CONFIG.root.startsWith(target.pathname) && location.pathname.startsWith(target.pathname);
|
234
|
+
const active = target.hostname === location.hostname && (isSamePath || isSubPath);
|
235
|
+
element.toggleClass('active', active);
|
236
|
+
if (element.parentNode.child('.active') && parentItem.hasClass('dropdown')) {
|
237
|
+
parentItem.removeClass('active').addClass('expand');
|
238
|
+
}
|
239
|
+
else {
|
240
|
+
parentItem.removeClass('expand');
|
241
|
+
}
|
242
|
+
});
|
243
|
+
};
|
244
|
+
exports.menuActive = menuActive;
|