hexo-theme-shokax 0.5.1 → 0.5.2-hotfix.2

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.
Files changed (165) hide show
  1. package/.vscode/settings.json +6 -0
  2. package/CODE_OF_CONDUCT.md +128 -128
  3. package/LICENSE +660 -660
  4. package/LICENSE-shoka +21 -21
  5. package/README.md +74 -68
  6. package/UsageRestrictions.md +25 -25
  7. package/_config.yml +352 -350
  8. package/languages/README.md +19 -19
  9. package/languages/default.yml +1 -1
  10. package/languages/en.yml +155 -155
  11. package/languages/ja.yml +155 -155
  12. package/languages/zh-CN.yml +155 -155
  13. package/languages/zh-HK.yml +155 -155
  14. package/languages/zh-TW.yml +155 -155
  15. package/layout/_alternate/atom.ejs +30 -30
  16. package/layout/_alternate/json.ejs +16 -16
  17. package/layout/_alternate/rss.ejs +34 -34
  18. package/layout/_mixin/breadcrumb.pug +33 -33
  19. package/layout/_mixin/card.pug +37 -37
  20. package/layout/_mixin/comment.pug +6 -6
  21. package/layout/_mixin/postmeta.pug +29 -29
  22. package/layout/_mixin/segment.pug +35 -35
  23. package/layout/_mixin/sidebar.pug +40 -40
  24. package/layout/_mixin/widgets.pug +28 -28
  25. package/layout/_partials/footer.pug +43 -43
  26. package/layout/_partials/head/head.pug +50 -50
  27. package/layout/_partials/head/head_com.pug +24 -24
  28. package/layout/_partials/head/pwa.pug +18 -18
  29. package/layout/_partials/header.pug +18 -18
  30. package/layout/_partials/layout.pug +137 -137
  31. package/layout/_partials/loading.pug +13 -13
  32. package/layout/_partials/pagination.pug +4 -4
  33. package/layout/_partials/post/copyright.pug +20 -20
  34. package/layout/_partials/post/footer.pug +20 -20
  35. package/layout/_partials/post/nav.pug +17 -17
  36. package/layout/_partials/post/post.pug +42 -42
  37. package/layout/_partials/post/reward.pug +18 -18
  38. package/layout/_partials/sidebar/menu.pug +37 -37
  39. package/layout/_partials/sidebar/overview.pug +42 -42
  40. package/layout/_partials/third-party/baidu-analytics.pug +11 -11
  41. package/layout/_partials/third-party/clarity.pug +8 -8
  42. package/layout/_partials/third-party/google-analytics.pug +9 -9
  43. package/layout/archive.pug +121 -121
  44. package/layout/category.pug +62 -62
  45. package/layout/index.pug +36 -36
  46. package/layout/page.pug +60 -60
  47. package/layout/post.pug +42 -42
  48. package/layout/tag.pug +46 -46
  49. package/package.json +13 -12
  50. package/scripts/generaters/images.js +11 -13
  51. package/scripts/generaters/script.js +3 -1
  52. package/scripts/plugin/check.js +48 -10
  53. package/scripts/plugin/index.js +2 -2
  54. package/source/assets/algolia_logo.svg +9 -9
  55. package/source/assets/logo.svg +16 -16
  56. package/source/css/_colors.styl +207 -207
  57. package/source/css/_common/components/components.styl +5 -6
  58. package/source/css/_common/components/pages/collapse.styl +119 -119
  59. package/source/css/_common/components/pages/home.styl +391 -391
  60. package/source/css/_common/components/pages/pages.styl +56 -56
  61. package/source/css/_common/components/pages/tag-cloud.styl +12 -12
  62. package/source/css/_common/components/post/breadcrumb.styl +39 -39
  63. package/source/css/_common/components/post/copyright.styl +41 -41
  64. package/source/css/_common/components/post/expand.styl +263 -263
  65. package/source/css/_common/components/post/footer.styl +11 -11
  66. package/source/css/_common/components/post/header.styl +79 -79
  67. package/source/css/_common/components/post/nav.styl +64 -64
  68. package/source/css/_common/components/post/post.styl +29 -29
  69. package/source/css/_common/components/post/reward.styl +50 -50
  70. package/source/css/_common/components/post/rtl.styl +12 -12
  71. package/source/css/_common/components/post/tags.styl +39 -39
  72. package/source/css/_common/components/tags/collapse.styl +72 -72
  73. package/source/css/_common/components/tags/container.styl +49 -49
  74. package/source/css/_common/components/tags/label.styl +12 -12
  75. package/source/css/_common/components/tags/links.styl +77 -77
  76. package/source/css/_common/components/tags/list.styl +131 -131
  77. package/source/css/_common/components/tags/note.styl +70 -70
  78. package/source/css/_common/components/tags/player.styl +361 -361
  79. package/source/css/_common/components/tags/quiz.styl +200 -200
  80. package/source/css/_common/components/tags/tabs.styl +89 -89
  81. package/source/css/_common/components/tags/tags.styl +9 -9
  82. package/source/css/_common/components/third-party/loading.styl +222 -222
  83. package/source/css/_common/components/third-party/mermaid/class.styl +90 -90
  84. package/source/css/_common/components/third-party/mermaid/flowchart.styl +72 -72
  85. package/source/css/_common/components/third-party/mermaid/gantt.styl +251 -251
  86. package/source/css/_common/components/third-party/mermaid/git.styl +7 -7
  87. package/source/css/_common/components/third-party/mermaid/mermaid.styl +37 -37
  88. package/source/css/_common/components/third-party/mermaid/pie.styl +9 -9
  89. package/source/css/_common/components/third-party/mermaid/sequence.styl +95 -95
  90. package/source/css/_common/components/third-party/mermaid/state.styl +130 -130
  91. package/source/css/_common/components/third-party/pace.styl +18 -18
  92. package/source/css/_common/components/third-party/search.styl +167 -167
  93. package/source/css/_common/components/third-party/theme.styl +151 -151
  94. package/source/css/_common/components/third-party/third-party.styl +22 -22
  95. package/source/css/_common/components/third-party/widgets.styl +57 -57
  96. package/source/css/_common/outline/footer/footer.styl +67 -67
  97. package/source/css/_common/outline/header/brand.styl +77 -77
  98. package/source/css/_common/outline/header/header.styl +20 -20
  99. package/source/css/_common/outline/header/image.styl +85 -85
  100. package/source/css/_common/outline/header/menu.styl +117 -117
  101. package/source/css/_common/outline/header/nav.styl +81 -81
  102. package/source/css/_common/outline/header/right.styl +15 -15
  103. package/source/css/_common/outline/header/tool.styl +207 -207
  104. package/source/css/_common/outline/header/waves.styl +57 -57
  105. package/source/css/_common/outline/mobile.styl +46 -46
  106. package/source/css/_common/outline/outline.styl +78 -78
  107. package/source/css/_common/outline/sidebar/author.styl +59 -59
  108. package/source/css/_common/outline/sidebar/dimmer.styl +23 -23
  109. package/source/css/_common/outline/sidebar/menu.styl +63 -63
  110. package/source/css/_common/outline/sidebar/quick.styl +43 -43
  111. package/source/css/_common/outline/sidebar/related.styl +56 -56
  112. package/source/css/_common/outline/sidebar/sidebar.styl +82 -82
  113. package/source/css/_common/outline/sidebar/social.styl +69 -69
  114. package/source/css/_common/outline/sidebar/state.styl +37 -37
  115. package/source/css/_common/outline/sidebar/tab.styl +71 -71
  116. package/source/css/_common/outline/sidebar/toc.styl +47 -47
  117. package/source/css/_common/scaffolding/animate.styl +322 -322
  118. package/source/css/_common/scaffolding/base.styl +192 -190
  119. package/source/css/_common/scaffolding/buttons.styl +48 -48
  120. package/source/css/_common/scaffolding/divider.styl +36 -36
  121. package/source/css/_common/scaffolding/iconfont.styl +443 -443
  122. package/source/css/_common/scaffolding/normalize.styl +273 -273
  123. package/source/css/_common/scaffolding/pagination.styl +81 -81
  124. package/source/css/_common/scaffolding/ribbon.styl +38 -38
  125. package/source/css/_common/scaffolding/scaffolding.styl +14 -14
  126. package/source/css/_common/scaffolding/scrollbar.styl +37 -37
  127. package/source/css/_common/scaffolding/tables.styl +50 -50
  128. package/source/css/_common/scaffolding/tip.styl +19 -19
  129. package/source/css/_common/scaffolding/toggles.styl +59 -59
  130. package/source/css/_iconfont.styl +455 -455
  131. package/source/css/_mixins.styl +148 -148
  132. package/source/css/_variables.styl +89 -89
  133. package/source/css/app.styl +25 -25
  134. package/source/css/mermaid.styl +5 -5
  135. package/source/css/page.styl +2 -2
  136. package/source/css/post.styl +5 -5
  137. package/source/css/scaffolding.styl +4 -4
  138. package/source/js/_app/components/cloudflare.ts +18 -18
  139. package/source/js/_app/components/comments.ts +88 -86
  140. package/source/js/_app/components/sidebar.ts +243 -243
  141. package/source/js/_app/components/tcomments.ts +53 -53
  142. package/source/js/_app/globals/globalVars.ts +84 -84
  143. package/source/js/_app/globals/handles.ts +124 -124
  144. package/source/js/_app/globals/themeColor.ts +62 -62
  145. package/source/js/_app/globals/thirdparty.ts +63 -63
  146. package/source/js/_app/globals/tools.ts +73 -73
  147. package/source/js/_app/library/anime.ts +121 -121
  148. package/source/js/_app/library/declare.d.ts +128 -126
  149. package/source/js/_app/library/proto.ts +70 -70
  150. package/source/js/_app/library/vue.ts +49 -49
  151. package/source/js/_app/page/common.ts +41 -41
  152. package/source/js/_app/page/imageviewer.ts +15 -15
  153. package/source/js/_app/page/post.ts +251 -248
  154. package/source/js/_app/page/search.ts +109 -109
  155. package/source/js/_app/page/tab.ts +59 -59
  156. package/source/js/_app/pjax/domInit.ts +102 -102
  157. package/source/js/_app/pjax/refresh.ts +117 -117
  158. package/source/js/_app/pjax/siteInit.ts +90 -90
  159. package/source/js/_app/player.ts +13 -13
  160. package/toolbox/compiler.mjs +49 -53
  161. package/toolbox/dev-version.mjs +14 -14
  162. package/toolbox/hoistdep.mjs +5 -5
  163. package/toolbox/lib.mjs +63 -63
  164. package/source/css/_common/components/highlight/highlight.styl +0 -357
  165. package/source/css/_common/components/highlight/operation.styl +0 -21
@@ -1,109 +1,109 @@
1
- import { CONFIG, siteSearch } from '../globals/globalVars'
2
- import { transition } from '../library/anime'
3
- import { searchBox, configure, stats, hits, pagination } from 'instantsearch.js/es/widgets'
4
- import type { HitHighlightResult } from 'instantsearch.js/es/types/results'
5
- import instantsearch from 'instantsearch.js'
6
- import { liteClient as algoliasearch } from 'algoliasearch/lite'
7
-
8
- export function algoliaSearch () {
9
- const search = instantsearch({
10
- indexName: CONFIG.search.indexName,
11
- searchClient: algoliasearch(CONFIG.search.appID, CONFIG.search.apiKey),
12
- // TODO 移除弃用函数
13
- searchFunction (helper) {
14
- const searchInput = document.querySelector('.search-input') as HTMLInputElement
15
- if (searchInput.value) {
16
- helper.search()
17
- }
18
- }
19
- })
20
-
21
- // Registering Widgets
22
- search.addWidgets([
23
- configure({
24
- hitsPerPage: CONFIG.search.hits.per_page || 10
25
- }),
26
-
27
- searchBox({
28
- container: '.search-input-container',
29
- placeholder: LOCAL.search.placeholder,
30
- // Hide default icons of algolia search
31
- showReset: false,
32
- showSubmit: false,
33
- showLoadingIndicator: false,
34
- cssClasses: {
35
- input: 'search-input'
36
- }
37
- }),
38
-
39
- stats({
40
- container: '#search-stats',
41
- templates: {
42
- text (data) {
43
- const stats = LOCAL.search.stats
44
- .replace(/\$\{hits}/, data.nbHits.toString())
45
- .replace(/\$\{time}/, data.processingTimeMS.toString())
46
- return stats + '<span class="algolia-powered"></span><hr>'
47
- }
48
- }
49
- }),
50
-
51
- hits({
52
- container: '#search-hits',
53
- templates: {
54
- item (data) {
55
- const cats = data.categories ? '<span>' + data.categories.join('<i class="ic i-angle-right"></i>') + '</span>' : ''
56
- return '<a href="' + CONFIG.root + data.path + '">' + cats + (data._highlightResult.title as HitHighlightResult).value + '</a>'
57
- },
58
- empty (data) {
59
- return '<div id="hits-empty">' +
60
- LOCAL.search.empty.replace(/\$\{query}/, data.query) +
61
- '</div>'
62
- }
63
- },
64
- cssClasses: {
65
- item: 'item'
66
- }
67
- }),
68
-
69
- pagination({
70
- container: '#search-pagination',
71
- scrollTo: false,
72
- showFirst: false,
73
- showLast: false,
74
- templates: {
75
- first: '<i class="ic i-angle-double-left"></i>',
76
- last: '<i class="ic i-angle-double-right"></i>',
77
- previous: '<i class="ic i-angle-left"></i>',
78
- next: '<i class="ic i-angle-right"></i>'
79
- },
80
- cssClasses: {
81
- root: 'pagination',
82
- item: 'pagination-item',
83
- link: 'page-number',
84
- selectedItem: 'current',
85
- disabledItem: 'disabled-item'
86
- }
87
- })
88
- ])
89
-
90
- search.start()
91
-
92
- // Monitor main search box
93
- const onPopupClose = () => {
94
- document.body.style.overflow = ''
95
- transition(siteSearch, 0) // "transition.shrinkOut"
96
- }
97
-
98
- siteSearch.addEventListener('click', (event) => {
99
- if (event.target === siteSearch) {
100
- onPopupClose()
101
- }
102
- })
103
- document.querySelector('.close-btn').addEventListener('click', onPopupClose)
104
- window.addEventListener('keyup', (event) => {
105
- if (event.key === 'Escape') {
106
- onPopupClose()
107
- }
108
- })
109
- }
1
+ import { CONFIG, siteSearch } from '../globals/globalVars'
2
+ import { transition } from '../library/anime'
3
+ import { searchBox, configure, stats, hits, pagination } from 'instantsearch.js/es/widgets'
4
+ import type { HitHighlightResult } from 'instantsearch.js/es/types/results'
5
+ import instantsearch from 'instantsearch.js'
6
+ import { liteClient as algoliasearch } from 'algoliasearch/lite'
7
+
8
+ export function algoliaSearch () {
9
+ const search = instantsearch({
10
+ indexName: CONFIG.search.indexName,
11
+ searchClient: algoliasearch(CONFIG.search.appID, CONFIG.search.apiKey),
12
+ // TODO 移除弃用函数
13
+ searchFunction (helper) {
14
+ const searchInput = document.querySelector('.search-input') as HTMLInputElement
15
+ if (searchInput.value) {
16
+ helper.search()
17
+ }
18
+ }
19
+ })
20
+
21
+ // Registering Widgets
22
+ search.addWidgets([
23
+ configure({
24
+ hitsPerPage: CONFIG.search.hits.per_page || 10
25
+ }),
26
+
27
+ searchBox({
28
+ container: '.search-input-container',
29
+ placeholder: LOCAL.search.placeholder,
30
+ // Hide default icons of algolia search
31
+ showReset: false,
32
+ showSubmit: false,
33
+ showLoadingIndicator: false,
34
+ cssClasses: {
35
+ input: 'search-input'
36
+ }
37
+ }),
38
+
39
+ stats({
40
+ container: '#search-stats',
41
+ templates: {
42
+ text (data) {
43
+ const stats = LOCAL.search.stats
44
+ .replace(/\$\{hits}/, data.nbHits.toString())
45
+ .replace(/\$\{time}/, data.processingTimeMS.toString())
46
+ return stats + '<span class="algolia-powered"></span><hr>'
47
+ }
48
+ }
49
+ }),
50
+
51
+ hits({
52
+ container: '#search-hits',
53
+ templates: {
54
+ item (data) {
55
+ const cats = data.categories ? '<span>' + data.categories.join('<i class="ic i-angle-right"></i>') + '</span>' : ''
56
+ return '<a href="' + CONFIG.root + data.path + '">' + cats + (data._highlightResult.title as HitHighlightResult).value + '</a>'
57
+ },
58
+ empty (data) {
59
+ return '<div id="hits-empty">' +
60
+ LOCAL.search.empty.replace(/\$\{query}/, data.query) +
61
+ '</div>'
62
+ }
63
+ },
64
+ cssClasses: {
65
+ item: 'item'
66
+ }
67
+ }),
68
+
69
+ pagination({
70
+ container: '#search-pagination',
71
+ scrollTo: false,
72
+ showFirst: false,
73
+ showLast: false,
74
+ templates: {
75
+ first: '<i class="ic i-angle-double-left"></i>',
76
+ last: '<i class="ic i-angle-double-right"></i>',
77
+ previous: '<i class="ic i-angle-left"></i>',
78
+ next: '<i class="ic i-angle-right"></i>'
79
+ },
80
+ cssClasses: {
81
+ root: 'pagination',
82
+ item: 'pagination-item',
83
+ link: 'page-number',
84
+ selectedItem: 'current',
85
+ disabledItem: 'disabled-item'
86
+ }
87
+ })
88
+ ])
89
+
90
+ search.start()
91
+
92
+ // Monitor main search box
93
+ const onPopupClose = () => {
94
+ document.body.style.overflow = ''
95
+ transition(siteSearch, 0) // "transition.shrinkOut"
96
+ }
97
+
98
+ siteSearch.addEventListener('click', (event) => {
99
+ if (event.target === siteSearch) {
100
+ onPopupClose()
101
+ }
102
+ })
103
+ document.querySelector('.close-btn').addEventListener('click', onPopupClose)
104
+ window.addEventListener('keyup', (event) => {
105
+ if (event.key === 'Escape') {
106
+ onPopupClose()
107
+ }
108
+ })
109
+ }
@@ -1,59 +1,59 @@
1
- import { pageScroll } from '../library/anime'
2
- import { createChild } from '../library/proto'
3
-
4
- export const tabFormat = () => {
5
- // tab
6
- let first_tab:boolean
7
- document.querySelectorAll('div.tab').forEach((element) => {
8
- if (element.getAttribute('data-ready')) { return }
9
-
10
- const id = element.getAttribute('data-id')
11
- const title = element.getAttribute('data-title')
12
- let box = document.getElementById(id)
13
- if (!box) {
14
- box = document.createElement('div')
15
- box.className = 'tabs'
16
- box.id = id
17
- box.innerHTML = '<div class="show-btn"></div>'
18
-
19
- const showBtn = box.querySelector('.show-btn')
20
- showBtn.addEventListener('click', () => {
21
- pageScroll(box)
22
- })
23
-
24
- element.parentNode.insertBefore(box, element)
25
- first_tab = true
26
- } else {
27
- first_tab = false
28
- }
29
-
30
- let ul = box.querySelector('.nav ul')
31
- if (!ul) {
32
- ul = createChild(box, 'div', {
33
- className: 'nav',
34
- innerHTML: '<ul></ul>'
35
- }).querySelector('ul')
36
- }
37
-
38
- const li = createChild(ul, 'li', {
39
- innerHTML: title
40
- })
41
-
42
- if (first_tab) {
43
- li.classList.add('active')
44
- element.classList.add('active')
45
- }
46
-
47
- li.addEventListener('click', (event) => {
48
- const target = event.currentTarget as HTMLElement
49
- box.querySelectorAll('.active').forEach((el) => {
50
- el.classList.remove('active')
51
- })
52
- element.classList.add('active')
53
- target.classList.add('active')
54
- })
55
-
56
- box.appendChild(element)
57
- element.setAttribute('data-ready', String(true))
58
- })
59
- }
1
+ import { pageScroll } from '../library/anime'
2
+ import { createChild } from '../library/proto'
3
+
4
+ export const tabFormat = () => {
5
+ // tab
6
+ let first_tab:boolean
7
+ document.querySelectorAll('div.tab').forEach((element) => {
8
+ if (element.getAttribute('data-ready')) { return }
9
+
10
+ const id = element.getAttribute('data-id')
11
+ const title = element.getAttribute('data-title')
12
+ let box = document.getElementById(id)
13
+ if (!box) {
14
+ box = document.createElement('div')
15
+ box.className = 'tabs'
16
+ box.id = id
17
+ box.innerHTML = '<div class="show-btn"></div>'
18
+
19
+ const showBtn = box.querySelector('.show-btn')
20
+ showBtn.addEventListener('click', () => {
21
+ pageScroll(box)
22
+ })
23
+
24
+ element.parentNode.insertBefore(box, element)
25
+ first_tab = true
26
+ } else {
27
+ first_tab = false
28
+ }
29
+
30
+ let ul = box.querySelector('.nav ul')
31
+ if (!ul) {
32
+ ul = createChild(box, 'div', {
33
+ className: 'nav',
34
+ innerHTML: '<ul></ul>'
35
+ }).querySelector('ul')
36
+ }
37
+
38
+ const li = createChild(ul, 'li', {
39
+ innerHTML: title
40
+ })
41
+
42
+ if (first_tab) {
43
+ li.classList.add('active')
44
+ element.classList.add('active')
45
+ }
46
+
47
+ li.addEventListener('click', (event) => {
48
+ const target = event.currentTarget as HTMLElement
49
+ box.querySelectorAll('.active').forEach((el) => {
50
+ el.classList.remove('active')
51
+ })
52
+ element.classList.add('active')
53
+ target.classList.add('active')
54
+ })
55
+
56
+ box.appendChild(element)
57
+ element.setAttribute('data-ready', String(true))
58
+ })
59
+ }
@@ -1,102 +1,102 @@
1
- import { backToTopHandle, goToBottomHandle, goToCommentHandle, sideBarToggleHandle } from '../components/sidebar'
2
- import {
3
- backToTop,
4
- goToComment,
5
- loadCat,
6
- menuToggle,
7
- quickBtn, setBackToTop, setGoToComment, setShowContents, setToolBtn,
8
- showContents,
9
- siteHeader,
10
- siteNav,
11
- toolBtn
12
- } from '../globals/globalVars'
13
- import { Loader } from '../globals/thirdparty'
14
- import { createChild } from '../library/proto'
15
- import { initAudioPlayer } from '../player'
16
-
17
- export default async function domInit () {
18
- document.querySelectorAll('.overview .menu > .item').forEach((el) => {
19
- siteNav.querySelector('.menu').appendChild(el.cloneNode(true))
20
- })
21
-
22
- loadCat.addEventListener('click', Loader.vanish)
23
- menuToggle.addEventListener('click', sideBarToggleHandle)
24
- document.querySelector('.dimmer').addEventListener('click', sideBarToggleHandle)
25
-
26
- quickBtn.querySelector('.down').addEventListener('click', goToBottomHandle)
27
- quickBtn.querySelector('.up').addEventListener('click', backToTopHandle)
28
-
29
- if (!toolBtn) {
30
- setToolBtn(createChild(siteHeader, 'div', {
31
- id: 'tool',
32
- innerHTML: `<div class="item player">
33
- ${__shokax_player__ ? '<div class="play-pause btn" id="playBtn"></div><div class="music btn btn" id="showBtn"></div>' : ''}
34
- </div>
35
- <div class="item contents">
36
- <i class="ic i-list-ol"></i>
37
- </div>
38
- <div class="item chat">
39
- <i class="ic i-comments"></i>
40
- </div>
41
- <div class="item back-to-top">
42
- <i class="ic i-arrow-up"></i>
43
- <span>0%</span>
44
- </div>`
45
- }))
46
- }
47
-
48
- setBackToTop(toolBtn.querySelector('.back-to-top'))
49
- setGoToComment(toolBtn.querySelector('.chat'))
50
- setShowContents(toolBtn.querySelector('.contents'))
51
-
52
- backToTop.addEventListener('click', backToTopHandle)
53
- goToComment.addEventListener('click', goToCommentHandle)
54
- showContents.addEventListener('click', sideBarToggleHandle)
55
-
56
- if (__shokax_player__) {
57
- await initAudioPlayer()
58
- }
59
-
60
-
61
- const createIntersectionObserver = () => {
62
- // waves在视口外时停止动画
63
- new IntersectionObserver(([entry]) => {
64
- if (entry.isIntersecting) {
65
- document.querySelectorAll('.parallax>use').forEach(i => {
66
- i.classList.remove('stop-animation')
67
- })
68
- document.querySelectorAll('#imgs .item').forEach(i => {
69
- i.classList.remove('stop-animation')
70
- })
71
- } else {
72
- document.querySelectorAll('.parallax>use').forEach(i => {
73
- i.classList.add('stop-animation')
74
- })
75
- // waves不可见时imgs也应该不可见了
76
- document.querySelectorAll('#imgs .item').forEach(i => {
77
- i.classList.add('stop-animation')
78
- })
79
- }
80
- }, {
81
- root: null,
82
- threshold: 0.2
83
- }).observe(document.getElementById('waves'))
84
-
85
- // sakura在视口外时停止动画
86
- new IntersectionObserver(([entry]) => {
87
- if (entry.isIntersecting) {
88
- document.querySelectorAll('.with-love>i').forEach(i => {
89
- i.classList.remove('stop-animation')
90
- })
91
- } else {
92
- document.querySelectorAll('.with-love>i').forEach(i => {
93
- i.classList.add('stop-animation')
94
- })
95
- }
96
- }, {
97
- root: null,
98
- threshold: 0.2
99
- }).observe(document.querySelector('.with-love'))
100
- }
101
- createIntersectionObserver()
102
- }
1
+ import { backToTopHandle, goToBottomHandle, goToCommentHandle, sideBarToggleHandle } from '../components/sidebar'
2
+ import {
3
+ backToTop,
4
+ goToComment,
5
+ loadCat,
6
+ menuToggle,
7
+ quickBtn, setBackToTop, setGoToComment, setShowContents, setToolBtn,
8
+ showContents,
9
+ siteHeader,
10
+ siteNav,
11
+ toolBtn
12
+ } from '../globals/globalVars'
13
+ import { Loader } from '../globals/thirdparty'
14
+ import { createChild } from '../library/proto'
15
+ import { initAudioPlayer } from '../player'
16
+
17
+ export default async function domInit () {
18
+ document.querySelectorAll('.overview .menu > .item').forEach((el) => {
19
+ siteNav.querySelector('.menu').appendChild(el.cloneNode(true))
20
+ })
21
+
22
+ loadCat.addEventListener('click', Loader.vanish)
23
+ menuToggle.addEventListener('click', sideBarToggleHandle)
24
+ document.querySelector('.dimmer').addEventListener('click', sideBarToggleHandle)
25
+
26
+ quickBtn.querySelector('.down').addEventListener('click', goToBottomHandle)
27
+ quickBtn.querySelector('.up').addEventListener('click', backToTopHandle)
28
+
29
+ if (!toolBtn) {
30
+ setToolBtn(createChild(siteHeader, 'div', {
31
+ id: 'tool',
32
+ innerHTML: `<div class="item player">
33
+ ${__shokax_player__ ? '<div class="play-pause btn" id="playBtn"></div><div class="music btn btn" id="showBtn"></div>' : ''}
34
+ </div>
35
+ <div class="item contents">
36
+ <i class="ic i-list-ol"></i>
37
+ </div>
38
+ <div class="item chat">
39
+ <i class="ic i-comments"></i>
40
+ </div>
41
+ <div class="item back-to-top">
42
+ <i class="ic i-arrow-up"></i>
43
+ <span>0%</span>
44
+ </div>`
45
+ }))
46
+ }
47
+
48
+ setBackToTop(toolBtn.querySelector('.back-to-top'))
49
+ setGoToComment(toolBtn.querySelector('.chat'))
50
+ setShowContents(toolBtn.querySelector('.contents'))
51
+
52
+ backToTop.addEventListener('click', backToTopHandle)
53
+ goToComment.addEventListener('click', goToCommentHandle)
54
+ showContents.addEventListener('click', sideBarToggleHandle)
55
+
56
+ if (__shokax_player__) {
57
+ await initAudioPlayer()
58
+ }
59
+
60
+
61
+ const createIntersectionObserver = () => {
62
+ // waves在视口外时停止动画
63
+ new IntersectionObserver(([entry]) => {
64
+ if (entry.isIntersecting) {
65
+ document.querySelectorAll('.parallax>use').forEach(i => {
66
+ i.classList.remove('stop-animation')
67
+ })
68
+ document.querySelectorAll('#imgs .item').forEach(i => {
69
+ i.classList.remove('stop-animation')
70
+ })
71
+ } else {
72
+ document.querySelectorAll('.parallax>use').forEach(i => {
73
+ i.classList.add('stop-animation')
74
+ })
75
+ // waves不可见时imgs也应该不可见了
76
+ document.querySelectorAll('#imgs .item').forEach(i => {
77
+ i.classList.add('stop-animation')
78
+ })
79
+ }
80
+ }, {
81
+ root: null,
82
+ threshold: 0.2
83
+ }).observe(document.getElementById('waves'))
84
+
85
+ // sakura在视口外时停止动画
86
+ new IntersectionObserver(([entry]) => {
87
+ if (entry.isIntersecting) {
88
+ document.querySelectorAll('.with-love>i').forEach(i => {
89
+ i.classList.remove('stop-animation')
90
+ })
91
+ } else {
92
+ document.querySelectorAll('.with-love>i').forEach(i => {
93
+ i.classList.add('stop-animation')
94
+ })
95
+ }
96
+ }, {
97
+ root: null,
98
+ threshold: 0.2
99
+ }).observe(document.querySelector('.with-love'))
100
+ }
101
+ createIntersectionObserver()
102
+ }