hexo-theme-redefine-x 2.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug-chinese.yml +115 -0
- package/.github/ISSUE_TEMPLATE/bug-english.yml +106 -0
- package/.github/ISSUE_TEMPLATE/enhancement-chinese.yml +55 -0
- package/.github/ISSUE_TEMPLATE/enhancement-english.yml +55 -0
- package/.github/workflows/build-and-commit.yml +49 -0
- package/.github/workflows/npm-publish.yml +34 -0
- package/.github/workflows/stale-issues.yml +20 -0
- package/CHANGELOG_REDEFINE_X.md +236 -0
- package/CODE_OF_CONDUCT.md +128 -0
- package/CONTRIBUTING.md +51 -0
- package/DONATION.md +82 -0
- package/LICENSE +674 -0
- package/README.md +135 -0
- package/README_zh-CN.md +138 -0
- package/README_zh-TW.md +137 -0
- package/TODO.md +215 -0
- package/_config.yml +489 -0
- package/languages/en.yml +93 -0
- package/languages/es.yml +92 -0
- package/languages/fr.yml +92 -0
- package/languages/ja.yml +92 -0
- package/languages/zh-CN.yml +95 -0
- package/languages/zh-TW.yml +94 -0
- package/layout/404.ejs +1 -0
- package/layout/archive.ejs +1 -0
- package/layout/category.ejs +1 -0
- package/layout/components/comments/comment.ejs +22 -0
- package/layout/components/comments/giscus.ejs +42 -0
- package/layout/components/comments/gitalk.ejs +47 -0
- package/layout/components/comments/twikoo.ejs +50 -0
- package/layout/components/comments/waline.ejs +34 -0
- package/layout/components/footer/footer.ejs +99 -0
- package/layout/components/header/head.ejs +222 -0
- package/layout/components/header/navbar.ejs +163 -0
- package/layout/components/header/preloader.ejs +148 -0
- package/layout/components/header/progress-bar.ejs +12 -0
- package/layout/components/plugins/aplayer.ejs +3 -0
- package/layout/components/scripts.ejs +90 -0
- package/layout/components/sidebar/author.ejs +6 -0
- package/layout/components/sidebar/avatar.ejs +3 -0
- package/layout/components/sidebar/statistics.ejs +14 -0
- package/layout/components/swup.ejs +27 -0
- package/layout/index.ejs +1 -0
- package/layout/layout.ejs +13 -0
- package/layout/page.ejs +57 -0
- package/layout/pages/archive/archive.ejs +3 -0
- package/layout/pages/bookmarks/bookmarks.ejs +68 -0
- package/layout/pages/category/categories.ejs +11 -0
- package/layout/pages/category/category-detail.ejs +6 -0
- package/layout/pages/friends/friends-link.ejs +59 -0
- package/layout/pages/home/home-article.ejs +52 -0
- package/layout/pages/home/home-background.ejs +33 -0
- package/layout/pages/home/home-banner.ejs +234 -0
- package/layout/pages/home/home-content.ejs +62 -0
- package/layout/pages/home/home-sidebar.ejs +78 -0
- package/layout/pages/masonry/masonry.ejs +28 -0
- package/layout/pages/notfound/notfound.ejs +8 -0
- package/layout/pages/page-template.ejs +23 -0
- package/layout/pages/post/article-content.ejs +153 -0
- package/layout/pages/post/article-copyright.ejs +69 -0
- package/layout/pages/post/article-info.ejs +78 -0
- package/layout/pages/post/post-tools.ejs +17 -0
- package/layout/pages/post/toc.ejs +15 -0
- package/layout/pages/shuoshuo/essays.ejs +23 -0
- package/layout/pages/tag/tag-detail.ejs +6 -0
- package/layout/pages/tag/tags.ejs +24 -0
- package/layout/post.ejs +1 -0
- package/layout/tag.ejs +1 -0
- package/layout/tags.ejs +1 -0
- package/layout/utils/image-viewer.ejs +3 -0
- package/layout/utils/local-search.ejs +20 -0
- package/layout/utils/paginator.ejs +8 -0
- package/layout/utils/posts-list.ejs +28 -0
- package/layout/utils/side-tools.ejs +51 -0
- package/package.json +45 -0
- package/scripts/config-export.js +66 -0
- package/scripts/data-handle.js +37 -0
- package/scripts/events/404.js +16 -0
- package/scripts/events/welcome.js +141 -0
- package/scripts/filters/delete-mask-handle.js +27 -0
- package/scripts/filters/encrypt.js +202 -0
- package/scripts/filters/img-handle.js +9 -0
- package/scripts/filters/lazyload-handle.js +350 -0
- package/scripts/filters/lib/hbe.default.js +15 -0
- package/scripts/filters/link-handle.js +42 -0
- package/scripts/filters/stylus-handle.js +9 -0
- package/scripts/filters/table-handle.js +11 -0
- package/scripts/helpers/meta-helpers.js +38 -0
- package/scripts/helpers/page-helpers.js +153 -0
- package/scripts/helpers/recommendation-helpers.js +367 -0
- package/scripts/helpers/theme-helpers.js +251 -0
- package/scripts/helpers/waline-helpers.js +33 -0
- package/scripts/modules/btn.js +85 -0
- package/scripts/modules/btns.js +71 -0
- package/scripts/modules/folding.js +34 -0
- package/scripts/modules/note-large.js +72 -0
- package/scripts/modules/note.js +64 -0
- package/scripts/modules/tabs.js +99 -0
- package/source/assets/hbe.style.css +220 -0
- package/source/assets/odometer-theme-minimal.css +81 -0
- package/source/css/build/tailwind.css +2 -0
- package/source/css/common/animated.styl +71 -0
- package/source/css/common/basic.styl +239 -0
- package/source/css/common/codeblock/code-block.styl +158 -0
- package/source/css/common/codeblock/code-theme.styl +82 -0
- package/source/css/common/codeblock/highlight.styl +189 -0
- package/source/css/common/codeblock/hljs-themes/dark/a11y-dark.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/dark/agate.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/dark/atom-one-dark.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/dark/github-dark.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/dark/monokai-sublime.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/dark/night-owl.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/dark/nord.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/dark/tokyo-night-dark.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/dark/vs2015.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/light/atom-one-light.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/light/default.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/light/github.styl +18 -0
- package/source/css/common/colors.styl +112 -0
- package/source/css/common/markdown.styl +337 -0
- package/source/css/common/redefine-theme.styl +65 -0
- package/source/css/common/theme.styl +72 -0
- package/source/css/common/variables.styl +145 -0
- package/source/css/layout/_modules/aplayer.styl +799 -0
- package/source/css/layout/_modules/buttons.styl +42 -0
- package/source/css/layout/_modules/folding.styl +180 -0
- package/source/css/layout/_modules/notes.styl +181 -0
- package/source/css/layout/_modules/tabs.styl +105 -0
- package/source/css/layout/_partials/404.styl +14 -0
- package/source/css/layout/_partials/archive-list.styl +49 -0
- package/source/css/layout/_partials/article-copyright-info.styl +27 -0
- package/source/css/layout/_partials/article-meta-info.styl +62 -0
- package/source/css/layout/_partials/comments/comment.styl +11 -0
- package/source/css/layout/_partials/comments/gitalk.styl +529 -0
- package/source/css/layout/_partials/comments/twikoo.styl +62 -0
- package/source/css/layout/_partials/comments/waline.styl +1151 -0
- package/source/css/layout/_partials/footer.styl +59 -0
- package/source/css/layout/_partials/home-banner.styl +48 -0
- package/source/css/layout/_partials/image-viewer.styl +37 -0
- package/source/css/layout/_partials/local-search.styl +137 -0
- package/source/css/layout/_partials/navbar.styl +309 -0
- package/source/css/layout/_partials/page-template.styl +147 -0
- package/source/css/layout/_partials/paginator.styl +65 -0
- package/source/css/layout/_partials/post-tools.styl +43 -0
- package/source/css/layout/_partials/progress-bar.styl +33 -0
- package/source/css/layout/_partials/side-tools.styl +87 -0
- package/source/css/layout/_partials/tagcloud.styl +136 -0
- package/source/css/layout/_partials/toc.styl +105 -0
- package/source/css/layout/animations.styl +42 -0
- package/source/css/layout/archive-content.styl +8 -0
- package/source/css/layout/article-content.styl +257 -0
- package/source/css/layout/bookmarks.styl +8 -0
- package/source/css/layout/category-content.styl +21 -0
- package/source/css/layout/category-list.styl +119 -0
- package/source/css/layout/home-content.styl +114 -0
- package/source/css/layout/home-sidebar.styl +126 -0
- package/source/css/layout/page.styl +144 -0
- package/source/css/layout/tag-content.styl +30 -0
- package/source/css/style.styl +26 -0
- package/source/css/tailwind.source.css +236 -0
- package/source/fontawesome/all.min.css +6 -0
- package/source/fontawesome/brands.min.css +6 -0
- package/source/fontawesome/duotone.min.css +6 -0
- package/source/fontawesome/fontawesome.min.css +6 -0
- package/source/fontawesome/light.min.css +6 -0
- package/source/fontawesome/regular.min.css +6 -0
- package/source/fontawesome/sharp-solid.min.css +6 -0
- package/source/fontawesome/solid.min.css +6 -0
- package/source/fontawesome/svg-with-js.min.css +6 -0
- package/source/fontawesome/thin.min.css +6 -0
- package/source/fontawesome/v4-font-face.min.css +6 -0
- package/source/fontawesome/v4-shims.min.css +6 -0
- package/source/fontawesome/v5-font-face.min.css +6 -0
- package/source/fonts/Chillax/Chillax-Variable.eot +0 -0
- package/source/fonts/Chillax/Chillax-Variable.ttf +0 -0
- package/source/fonts/Chillax/Chillax-Variable.woff +0 -0
- package/source/fonts/Chillax/Chillax-Variable.woff2 +0 -0
- package/source/fonts/Chillax/chillax.css +39 -0
- package/source/fonts/Geist/GeistVF.ttf +0 -0
- package/source/fonts/Geist/GeistVF.woff +0 -0
- package/source/fonts/Geist/GeistVF.woff2 +0 -0
- package/source/fonts/Geist/geist.css +16 -0
- package/source/fonts/GeistMono/GeistMonoVF.ttf +0 -0
- package/source/fonts/GeistMono/GeistMonoVF.woff +0 -0
- package/source/fonts/GeistMono/GeistMonoVF.woff2 +0 -0
- package/source/fonts/GeistMono/geist-mono.css +16 -0
- package/source/images/bookmark-placeholder.svg +9 -0
- package/source/images/loading.svg +5 -0
- package/source/images/redefine-avatar.svg +1 -0
- package/source/images/redefine-favicon.svg +1 -0
- package/source/images/redefine-logo.svg +1 -0
- package/source/images/redefine-logo.webp +0 -0
- package/source/images/redefine-og.webp +0 -0
- package/source/images/wallhaven-wqery6-dark.webp +0 -0
- package/source/images/wallhaven-wqery6-light.webp +0 -0
- package/source/js/build/layouts/bookmarkNav.js +2 -0
- package/source/js/build/layouts/bookmarkNav.js.map +1 -0
- package/source/js/build/layouts/categoryList.js +2 -0
- package/source/js/build/layouts/categoryList.js.map +1 -0
- package/source/js/build/layouts/essays.js +2 -0
- package/source/js/build/layouts/essays.js.map +1 -0
- package/source/js/build/layouts/lazyload.js +2 -0
- package/source/js/build/layouts/lazyload.js.map +1 -0
- package/source/js/build/layouts/navbarShrink.js +2 -0
- package/source/js/build/layouts/navbarShrink.js.map +1 -0
- package/source/js/build/layouts/toc.js +2 -0
- package/source/js/build/layouts/toc.js.map +1 -0
- package/source/js/build/libs/APlayer.min.js +2 -0
- package/source/js/build/libs/Swup.min.js +2 -0
- package/source/js/build/libs/SwupPreloadPlugin.min.js +1 -0
- package/source/js/build/libs/SwupProgressPlugin.min.js +1 -0
- package/source/js/build/libs/SwupScriptsPlugin.min.js +1 -0
- package/source/js/build/libs/SwupScrollPlugin.min.js +1 -0
- package/source/js/build/libs/SwupSlideTheme.min.js +1 -0
- package/source/js/build/libs/Typed.min.js +10 -0
- package/source/js/build/libs/anime.min.js +8 -0
- package/source/js/build/libs/mermaid.min.js +2314 -0
- package/source/js/build/libs/minimasonry.min.js +1 -0
- package/source/js/build/libs/moment-with-locales.min.js +2 -0
- package/source/js/build/libs/moment.min.js +2 -0
- package/source/js/build/libs/odometer.min.js +2 -0
- package/source/js/build/libs/pangu.min.js +9 -0
- package/source/js/build/libs/pjax.min.js +1 -0
- package/source/js/build/libs/waline.js +84 -0
- package/source/js/build/main.js +2 -0
- package/source/js/build/main.js.map +1 -0
- package/source/js/build/plugins/aplayer.js +2 -0
- package/source/js/build/plugins/aplayer.js.map +1 -0
- package/source/js/build/plugins/hbe.js +2 -0
- package/source/js/build/plugins/hbe.js.map +1 -0
- package/source/js/build/plugins/masonry.js +2 -0
- package/source/js/build/plugins/masonry.js.map +1 -0
- package/source/js/build/plugins/mermaid.js +2 -0
- package/source/js/build/plugins/mermaid.js.map +1 -0
- package/source/js/build/plugins/pangu.js +2 -0
- package/source/js/build/plugins/pangu.js.map +1 -0
- package/source/js/build/plugins/tabs.js +2 -0
- package/source/js/build/plugins/tabs.js.map +1 -0
- package/source/js/build/plugins/typed.js +2 -0
- package/source/js/build/plugins/typed.js.map +1 -0
- package/source/js/build/tools/codeBlock.js +2 -0
- package/source/js/build/tools/codeBlock.js.map +1 -0
- package/source/js/build/tools/imageViewer.js +2 -0
- package/source/js/build/tools/imageViewer.js.map +1 -0
- package/source/js/build/tools/lightDarkSwitch.js +2 -0
- package/source/js/build/tools/lightDarkSwitch.js.map +1 -0
- package/source/js/build/tools/localSearch.js +2 -0
- package/source/js/build/tools/localSearch.js.map +1 -0
- package/source/js/build/tools/runtime.js +2 -0
- package/source/js/build/tools/runtime.js.map +1 -0
- package/source/js/build/tools/scrollTopBottom.js +2 -0
- package/source/js/build/tools/scrollTopBottom.js.map +1 -0
- package/source/js/build/tools/tocToggle.js +2 -0
- package/source/js/build/tools/tocToggle.js.map +1 -0
- package/source/js/build/utils.js +2 -0
- package/source/js/build/utils.js.map +1 -0
- package/source/js/build.js +148 -0
- package/source/js/layouts/bookmarkNav.js +65 -0
- package/source/js/layouts/categoryList.js +53 -0
- package/source/js/layouts/essays.js +25 -0
- package/source/js/layouts/lazyload.js +199 -0
- package/source/js/layouts/navbarShrink.js +135 -0
- package/source/js/layouts/toc.js +115 -0
- package/source/js/libs/APlayer.min.js +2 -0
- package/source/js/libs/APlayer.min.js.map +1 -0
- package/source/js/libs/Swup.min.js +2 -0
- package/source/js/libs/Swup.min.js.map +1 -0
- package/source/js/libs/SwupPreloadPlugin.min.js +1 -0
- package/source/js/libs/SwupPreloadPlugin.min.js.map +1 -0
- package/source/js/libs/SwupProgressPlugin.min.js +1 -0
- package/source/js/libs/SwupScriptsPlugin.min.js +1 -0
- package/source/js/libs/SwupScrollPlugin.min.js +1 -0
- package/source/js/libs/SwupScrollPlugin.min.js.map +1 -0
- package/source/js/libs/SwupSlideTheme.min.js +1 -0
- package/source/js/libs/Typed.min.js +10 -0
- package/source/js/libs/anime.min.js +8 -0
- package/source/js/libs/mermaid.min.js +2314 -0
- package/source/js/libs/mermaid.min.js.map +7 -0
- package/source/js/libs/minimasonry.min.js +1 -0
- package/source/js/libs/moment-with-locales.min.js +2 -0
- package/source/js/libs/moment.min.js +2 -0
- package/source/js/libs/odometer.min.js +2 -0
- package/source/js/libs/pangu.min.js +9 -0
- package/source/js/libs/pjax.min.js +1 -0
- package/source/js/libs/waline.js +84 -0
- package/source/js/libs/waline.js.map +1 -0
- package/source/js/main.js +95 -0
- package/source/js/plugins/aplayer.js +33 -0
- package/source/js/plugins/hbe.js +350 -0
- package/source/js/plugins/masonry.js +115 -0
- package/source/js/plugins/mermaid.js +7 -0
- package/source/js/plugins/pangu.js +12 -0
- package/source/js/plugins/tabs.js +29 -0
- package/source/js/plugins/typed.js +62 -0
- package/source/js/tools/codeBlock.js +48 -0
- package/source/js/tools/imageViewer.js +194 -0
- package/source/js/tools/lightDarkSwitch.js +165 -0
- package/source/js/tools/localSearch.js +327 -0
- package/source/js/tools/runtime.js +28 -0
- package/source/js/tools/scrollTopBottom.js +34 -0
- package/source/js/tools/tocToggle.js +58 -0
- package/source/js/utils.js +383 -0
- package/source/webfonts/fa-brands-400.ttf +0 -0
- package/source/webfonts/fa-brands-400.woff2 +0 -0
- package/source/webfonts/fa-duotone-900.ttf +0 -0
- package/source/webfonts/fa-duotone-900.woff2 +0 -0
- package/source/webfonts/fa-light-300.ttf +0 -0
- package/source/webfonts/fa-light-300.woff2 +0 -0
- package/source/webfonts/fa-regular-400.ttf +0 -0
- package/source/webfonts/fa-regular-400.woff2 +0 -0
- package/source/webfonts/fa-sharp-solid-900.ttf +0 -0
- package/source/webfonts/fa-sharp-solid-900.woff2 +0 -0
- package/source/webfonts/fa-solid-900.ttf +0 -0
- package/source/webfonts/fa-solid-900.woff2 +0 -0
- package/source/webfonts/fa-thin-100.ttf +0 -0
- package/source/webfonts/fa-thin-100.woff2 +0 -0
- package/source/webfonts/fa-v4compatibility.ttf +0 -0
- package/source/webfonts/fa-v4compatibility.woff2 +0 -0
- package/vercel.json +7 -0
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
/* utils function */
|
|
2
|
+
import { navbarShrink } from "./layouts/navbarShrink.js";
|
|
3
|
+
import { initTOC } from "./layouts/toc.js";
|
|
4
|
+
import { main } from "./main.js";
|
|
5
|
+
import imageViewer from "./tools/imageViewer.js";
|
|
6
|
+
|
|
7
|
+
export const navigationState = {
|
|
8
|
+
isNavigating: false,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default function initUtils() {
|
|
12
|
+
const utils = {
|
|
13
|
+
html_root_dom: document.querySelector("html"),
|
|
14
|
+
pageContainer_dom: document.querySelector(".page-container"),
|
|
15
|
+
pageTop_dom: document.querySelector(".main-content-header"),
|
|
16
|
+
homeBanner_dom: document.querySelector(".home-banner-container"),
|
|
17
|
+
homeBannerBackground_dom: document.querySelector(".home-banner-background"),
|
|
18
|
+
scrollProgressBar_dom: document.querySelector(".scroll-progress-bar"),
|
|
19
|
+
pjaxProgressBar_dom: document.querySelector(".pjax-progress-bar"),
|
|
20
|
+
backToTopButton_dom: document.querySelector(".tool-scroll-to-top"),
|
|
21
|
+
toolsList: document.querySelector(".hidden-tools-list"),
|
|
22
|
+
toggleButton: document.querySelector(".toggle-tools-list"),
|
|
23
|
+
|
|
24
|
+
innerHeight: window.innerHeight,
|
|
25
|
+
pjaxProgressBarTimer: null,
|
|
26
|
+
prevScrollValue: 0,
|
|
27
|
+
fontSizeLevel: 0,
|
|
28
|
+
triggerViewHeight: 0.5 * window.innerHeight,
|
|
29
|
+
|
|
30
|
+
isHasScrollProgressBar: theme.global.scroll_progress.bar === true,
|
|
31
|
+
isHasScrollPercent: theme.global.scroll_progress.percentage === true,
|
|
32
|
+
|
|
33
|
+
// Scroll Style
|
|
34
|
+
updateScrollStyle() {
|
|
35
|
+
const scrollTop =
|
|
36
|
+
window.pageYOffset || document.documentElement.scrollTop;
|
|
37
|
+
const scrollHeight = document.documentElement.scrollHeight;
|
|
38
|
+
const clientHeight =
|
|
39
|
+
window.innerHeight || document.documentElement.clientHeight;
|
|
40
|
+
const percent = this.calculatePercentage(
|
|
41
|
+
scrollTop,
|
|
42
|
+
scrollHeight,
|
|
43
|
+
clientHeight,
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
this.updateScrollProgressBar(percent);
|
|
47
|
+
this.updateScrollPercent(percent);
|
|
48
|
+
this.updatePageTopVisibility(scrollTop, clientHeight);
|
|
49
|
+
|
|
50
|
+
this.prevScrollValue = scrollTop;
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
updateScrollProgressBar(percent) {
|
|
54
|
+
if (this.isHasScrollProgressBar) {
|
|
55
|
+
const progressPercent = percent.toFixed(3);
|
|
56
|
+
const visibility = percent === 0 ? "hidden" : "visible";
|
|
57
|
+
|
|
58
|
+
this.scrollProgressBar_dom.style.visibility = visibility;
|
|
59
|
+
this.scrollProgressBar_dom.style.width = `${progressPercent}%`;
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
updateScrollPercent(percent) {
|
|
64
|
+
if (this.isHasScrollPercent) {
|
|
65
|
+
const percentDom = this.backToTopButton_dom.querySelector(".percent");
|
|
66
|
+
const showButton = percent !== 0 && percent !== undefined;
|
|
67
|
+
|
|
68
|
+
this.backToTopButton_dom.classList.toggle("show", showButton);
|
|
69
|
+
percentDom.innerHTML = percent.toFixed(0);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
updatePageTopVisibility(scrollTop, clientHeight) {
|
|
74
|
+
if (theme.navbar.auto_hide) {
|
|
75
|
+
const prevScrollValue = this.prevScrollValue;
|
|
76
|
+
const hidePageTop =
|
|
77
|
+
prevScrollValue > clientHeight && scrollTop > prevScrollValue;
|
|
78
|
+
|
|
79
|
+
this.pageTop_dom.classList.toggle("hide", hidePageTop);
|
|
80
|
+
} else {
|
|
81
|
+
this.pageTop_dom.classList.remove("hide");
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
calculatePercentage(scrollTop, scrollHeight, clientHeight) {
|
|
86
|
+
let percentageValue = Math.round(
|
|
87
|
+
(scrollTop / (scrollHeight - clientHeight)) * 100,
|
|
88
|
+
);
|
|
89
|
+
if (
|
|
90
|
+
isNaN(percentageValue) ||
|
|
91
|
+
percentageValue < 0 ||
|
|
92
|
+
!isFinite(percentageValue)
|
|
93
|
+
) {
|
|
94
|
+
percentageValue = 0;
|
|
95
|
+
} else if (percentageValue > 100) {
|
|
96
|
+
percentageValue = 100;
|
|
97
|
+
}
|
|
98
|
+
return percentageValue;
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
// register window scroll event
|
|
102
|
+
registerWindowScroll() {
|
|
103
|
+
window.addEventListener("scroll", () => {
|
|
104
|
+
this.updateScrollStyle();
|
|
105
|
+
this.updateTOCScroll();
|
|
106
|
+
this.updateNavbarShrink();
|
|
107
|
+
// this.updateHomeBannerBlur();
|
|
108
|
+
this.updateAutoHideTools();
|
|
109
|
+
});
|
|
110
|
+
window.addEventListener(
|
|
111
|
+
"scroll",
|
|
112
|
+
this.debounce(() => this.updateHomeBannerBlur(), 20),
|
|
113
|
+
);
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
updateTOCScroll() {
|
|
117
|
+
if (
|
|
118
|
+
theme.articles.toc.enable &&
|
|
119
|
+
initTOC().hasOwnProperty("updateActiveTOCLink")
|
|
120
|
+
) {
|
|
121
|
+
initTOC().updateActiveTOCLink();
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
updateNavbarShrink() {
|
|
126
|
+
if (!navigationState.isNavigating) {
|
|
127
|
+
navbarShrink.init();
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
debounce(func, delay) {
|
|
132
|
+
let timer;
|
|
133
|
+
return function () {
|
|
134
|
+
clearTimeout(timer);
|
|
135
|
+
timer = setTimeout(() => func.apply(this, arguments), delay);
|
|
136
|
+
};
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
updateHomeBannerBlur() {
|
|
140
|
+
if (!this.homeBannerBackground_dom) return;
|
|
141
|
+
|
|
142
|
+
if (
|
|
143
|
+
theme.home_banner.style === "fixed" &&
|
|
144
|
+
location.pathname === config.root
|
|
145
|
+
) {
|
|
146
|
+
const scrollY = window.scrollY || window.pageYOffset;
|
|
147
|
+
const blurValue = scrollY >= this.triggerViewHeight ? 15 : 0;
|
|
148
|
+
|
|
149
|
+
try {
|
|
150
|
+
requestAnimationFrame(() => {
|
|
151
|
+
this.homeBannerBackground_dom.style.filter = `blur(${blurValue}px)`;
|
|
152
|
+
this.homeBannerBackground_dom.style.webkitFilter = `blur(${blurValue}px)`;
|
|
153
|
+
});
|
|
154
|
+
} catch (e) {
|
|
155
|
+
// Handle or log the error properly
|
|
156
|
+
console.error("Error updating banner blur:", e);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
updateAutoHideTools() {
|
|
162
|
+
const y = window.scrollY;
|
|
163
|
+
const height = document.body.scrollHeight;
|
|
164
|
+
const windowHeight = window.innerHeight;
|
|
165
|
+
const toolList = document.getElementsByClassName(
|
|
166
|
+
"right-side-tools-container",
|
|
167
|
+
);
|
|
168
|
+
const aplayer = document.getElementById("aplayer");
|
|
169
|
+
|
|
170
|
+
for (let i = 0; i < toolList.length; i++) {
|
|
171
|
+
const tools = toolList[i];
|
|
172
|
+
if (y <= 100) {
|
|
173
|
+
if (location.pathname === config.root) {
|
|
174
|
+
tools.classList.add("hide");
|
|
175
|
+
if (aplayer !== null) {
|
|
176
|
+
aplayer.classList.add("hide");
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
} else if (y + windowHeight >= height - 20) {
|
|
180
|
+
tools.classList.add("hide");
|
|
181
|
+
if (aplayer !== null) {
|
|
182
|
+
aplayer.classList.add("hide");
|
|
183
|
+
}
|
|
184
|
+
} else {
|
|
185
|
+
tools.classList.remove("hide");
|
|
186
|
+
if (aplayer !== null) {
|
|
187
|
+
aplayer.classList.remove("hide");
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
toggleToolsList() {
|
|
194
|
+
// Auto expand tools list if configured
|
|
195
|
+
if (theme.global.side_tools && theme.global.side_tools.auto_expand) {
|
|
196
|
+
this.toolsList.classList.add("show");
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
this.toggleButton.addEventListener("click", () => {
|
|
200
|
+
this.toolsList.classList.toggle("show");
|
|
201
|
+
});
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
fontAdjPlus_dom: document.querySelector(".tool-font-adjust-plus"),
|
|
205
|
+
fontAdMinus_dom: document.querySelector(".tool-font-adjust-minus"),
|
|
206
|
+
globalFontSizeAdjust() {
|
|
207
|
+
const htmlRoot = this.html_root_dom;
|
|
208
|
+
const fontAdjustPlus = this.fontAdjPlus_dom;
|
|
209
|
+
const fontAdjustMinus = this.fontAdMinus_dom;
|
|
210
|
+
|
|
211
|
+
const fontSize = document.defaultView.getComputedStyle(
|
|
212
|
+
document.body,
|
|
213
|
+
).fontSize;
|
|
214
|
+
const baseFontSize = parseFloat(fontSize);
|
|
215
|
+
|
|
216
|
+
let fontSizeLevel = 0;
|
|
217
|
+
const styleStatus = main.getStyleStatus();
|
|
218
|
+
if (styleStatus) {
|
|
219
|
+
fontSizeLevel = styleStatus.fontSizeLevel;
|
|
220
|
+
setFontSize(fontSizeLevel);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function setFontSize(level) {
|
|
224
|
+
const fontSize = baseFontSize * (1 + level * 0.05);
|
|
225
|
+
htmlRoot.style.fontSize = `${fontSize}px`;
|
|
226
|
+
main.styleStatus.fontSizeLevel = level;
|
|
227
|
+
main.setStyleStatus();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function increaseFontSize() {
|
|
231
|
+
fontSizeLevel = Math.min(fontSizeLevel + 1, 5);
|
|
232
|
+
setFontSize(fontSizeLevel);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function decreaseFontSize() {
|
|
236
|
+
fontSizeLevel = Math.max(fontSizeLevel - 1, 0);
|
|
237
|
+
setFontSize(fontSizeLevel);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
fontAdjustPlus.addEventListener("click", increaseFontSize);
|
|
241
|
+
fontAdjustMinus.addEventListener("click", decreaseFontSize);
|
|
242
|
+
},
|
|
243
|
+
// go comment anchor
|
|
244
|
+
goComment() {
|
|
245
|
+
this.goComment_dom = document.querySelector(".go-comment");
|
|
246
|
+
if (this.goComment_dom) {
|
|
247
|
+
this.goComment_dom.addEventListener("click", () => {
|
|
248
|
+
const target = document.querySelector("#comment-anchor");
|
|
249
|
+
if (target) {
|
|
250
|
+
const offset = target.getBoundingClientRect().top + window.scrollY;
|
|
251
|
+
window.scrollTo({
|
|
252
|
+
top: offset,
|
|
253
|
+
behavior: "smooth",
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
// get dom element height
|
|
261
|
+
getElementHeight(selectors) {
|
|
262
|
+
const dom = document.querySelector(selectors);
|
|
263
|
+
return dom ? dom.getBoundingClientRect().height : 0;
|
|
264
|
+
},
|
|
265
|
+
|
|
266
|
+
// init first screen height
|
|
267
|
+
inithomeBannerHeight() {
|
|
268
|
+
this.homeBanner_dom &&
|
|
269
|
+
(this.homeBanner_dom.style.height = this.innerHeight + "px");
|
|
270
|
+
},
|
|
271
|
+
|
|
272
|
+
// init page height handle
|
|
273
|
+
initPageHeightHandle() {
|
|
274
|
+
if (this.homeBanner_dom) return;
|
|
275
|
+
const temp_h1 = this.getElementHeight(".main-content-header");
|
|
276
|
+
const temp_h2 = this.getElementHeight(".main-content-body");
|
|
277
|
+
const temp_h3 = this.getElementHeight(".main-content-footer");
|
|
278
|
+
const allDomHeight = temp_h1 + temp_h2 + temp_h3;
|
|
279
|
+
const innerHeight = window.innerHeight;
|
|
280
|
+
const pb_dom = document.querySelector(".main-content-footer");
|
|
281
|
+
if (allDomHeight < innerHeight) {
|
|
282
|
+
const marginTopValue = Math.floor(innerHeight - allDomHeight);
|
|
283
|
+
if (marginTopValue > 0) {
|
|
284
|
+
pb_dom.style.marginTop = `${marginTopValue - 2}px`;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
|
|
289
|
+
// set how long ago language
|
|
290
|
+
setHowLongAgoLanguage(p1, p2) {
|
|
291
|
+
return p2.replace(/%s/g, p1);
|
|
292
|
+
},
|
|
293
|
+
|
|
294
|
+
getHowLongAgo(timestamp) {
|
|
295
|
+
const l = lang_ago;
|
|
296
|
+
|
|
297
|
+
const __Y = Math.floor(timestamp / (60 * 60 * 24 * 30) / 12);
|
|
298
|
+
const __M = Math.floor(timestamp / (60 * 60 * 24 * 30));
|
|
299
|
+
const __W = Math.floor(timestamp / (60 * 60 * 24) / 7);
|
|
300
|
+
const __d = Math.floor(timestamp / (60 * 60 * 24));
|
|
301
|
+
const __h = Math.floor((timestamp / (60 * 60)) % 24);
|
|
302
|
+
const __m = Math.floor((timestamp / 60) % 60);
|
|
303
|
+
const __s = Math.floor(timestamp % 60);
|
|
304
|
+
|
|
305
|
+
if (__Y > 0) {
|
|
306
|
+
return this.setHowLongAgoLanguage(__Y, l.year);
|
|
307
|
+
} else if (__M > 0) {
|
|
308
|
+
return this.setHowLongAgoLanguage(__M, l.month);
|
|
309
|
+
} else if (__W > 0) {
|
|
310
|
+
return this.setHowLongAgoLanguage(__W, l.week);
|
|
311
|
+
} else if (__d > 0) {
|
|
312
|
+
return this.setHowLongAgoLanguage(__d, l.day);
|
|
313
|
+
} else if (__h > 0) {
|
|
314
|
+
return this.setHowLongAgoLanguage(__h, l.hour);
|
|
315
|
+
} else if (__m > 0) {
|
|
316
|
+
return this.setHowLongAgoLanguage(__m, l.minute);
|
|
317
|
+
} else if (__s > 0) {
|
|
318
|
+
return this.setHowLongAgoLanguage(__s, l.second);
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
relativeTimeInHome() {
|
|
323
|
+
const post = document.querySelectorAll(
|
|
324
|
+
".home-article-meta-info .home-article-date",
|
|
325
|
+
);
|
|
326
|
+
const df = theme.home.article_date_format;
|
|
327
|
+
if (df === "relative") {
|
|
328
|
+
post &&
|
|
329
|
+
post.forEach((v) => {
|
|
330
|
+
const nowDate = Date.now();
|
|
331
|
+
const postDate = new Date(
|
|
332
|
+
v.dataset.date.split(" GMT")[0],
|
|
333
|
+
).getTime();
|
|
334
|
+
v.innerHTML = this.getHowLongAgo(
|
|
335
|
+
Math.floor((nowDate - postDate) / 1000),
|
|
336
|
+
);
|
|
337
|
+
});
|
|
338
|
+
} else if (df === "auto") {
|
|
339
|
+
post &&
|
|
340
|
+
post.forEach((v) => {
|
|
341
|
+
const nowDate = Date.now();
|
|
342
|
+
const postDate = new Date(
|
|
343
|
+
v.dataset.date.split(" GMT")[0],
|
|
344
|
+
).getTime();
|
|
345
|
+
const finalDays = Math.floor(
|
|
346
|
+
(nowDate - postDate) / (60 * 60 * 24 * 1000),
|
|
347
|
+
);
|
|
348
|
+
if (finalDays < 7) {
|
|
349
|
+
v.innerHTML = this.getHowLongAgo(
|
|
350
|
+
Math.floor((nowDate - postDate) / 1000),
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
utils.updateAutoHideTools();
|
|
359
|
+
|
|
360
|
+
// init scroll
|
|
361
|
+
utils.registerWindowScroll();
|
|
362
|
+
|
|
363
|
+
// toggle show tools list
|
|
364
|
+
utils.toggleToolsList();
|
|
365
|
+
|
|
366
|
+
// main font adjust
|
|
367
|
+
utils.globalFontSizeAdjust();
|
|
368
|
+
|
|
369
|
+
// go comment
|
|
370
|
+
utils.goComment();
|
|
371
|
+
|
|
372
|
+
// init page height handle
|
|
373
|
+
utils.initPageHeightHandle();
|
|
374
|
+
|
|
375
|
+
// init first screen height
|
|
376
|
+
utils.inithomeBannerHeight();
|
|
377
|
+
|
|
378
|
+
// set how long ago in home article block
|
|
379
|
+
utils.relativeTimeInHome();
|
|
380
|
+
|
|
381
|
+
// image viewer handle
|
|
382
|
+
imageViewer();
|
|
383
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|