hexo-theme-lnote 1.2.3 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +122 -122
- package/_config.yml +19 -19
- package/config/links.yml +63 -62
- package/config/svg.yml +33 -33
- package/index.d.ts +4 -0
- package/languages/de.yml +69 -69
- package/languages/en.yml +69 -69
- package/languages/eo.yml +69 -69
- package/languages/es.yml +69 -69
- package/languages/ja.yml +69 -69
- package/languages/ru.yml +69 -69
- package/languages/zh-CN.yml +69 -69
- package/languages/zh-HK.yml +69 -69
- package/languages/zh-TW.yml +69 -69
- package/layout/404.ejs +8 -8
- package/layout/_partials/archive-list.ejs +17 -17
- package/layout/_partials/category-chains.ejs +19 -19
- package/layout/_partials/category-list.ejs +62 -62
- package/layout/_partials/comments/changyan.ejs +11 -11
- package/layout/_partials/comments/cusdis.ejs +25 -25
- package/layout/_partials/comments/discuss.ejs +17 -17
- package/layout/_partials/comments/disqus.ejs +32 -32
- package/layout/_partials/comments/giscus.ejs +36 -36
- package/layout/_partials/comments/gitalk.ejs +19 -19
- package/layout/_partials/comments/livere.ejs +10 -10
- package/layout/_partials/comments/remark42.ejs +29 -29
- package/layout/_partials/comments/twikoo.ejs +25 -25
- package/layout/_partials/comments/utterances.ejs +27 -27
- package/layout/_partials/comments/valine.ejs +23 -23
- package/layout/_partials/comments/waline.ejs +24 -24
- package/layout/_partials/comments.ejs +8 -8
- package/layout/_partials/css.ejs +9 -9
- package/layout/_partials/footer/beian.ejs +33 -33
- package/layout/_partials/footer/statistics.ejs +39 -39
- package/layout/_partials/footer.ejs +7 -7
- package/layout/_partials/head.ejs +46 -46
- package/layout/_partials/header/banner.ejs +24 -24
- package/layout/_partials/header/navigation.ejs +56 -56
- package/layout/_partials/header.ejs +4 -4
- package/layout/_partials/markdown-plugins.ejs +24 -24
- package/layout/_partials/paginator.ejs +14 -14
- package/layout/_partials/plugins/CSR.ejs +4 -0
- package/layout/_partials/plugins/analytics.ejs +75 -75
- package/layout/_partials/plugins/anchorjs.ejs +39 -39
- package/layout/_partials/plugins/code-widget.ejs +7 -7
- package/layout/_partials/plugins/encrypt.ejs +18 -18
- package/layout/_partials/plugins/fancybox.ejs +11 -11
- package/layout/_partials/plugins/highlight.ejs +13 -13
- package/layout/_partials/plugins/math.ejs +51 -51
- package/layout/_partials/plugins/mermaid.ejs +4 -4
- package/layout/_partials/plugins/nprogress.ejs +7 -7
- package/layout/_partials/plugins/typed.ejs +20 -20
- package/layout/_partials/post/category-bar.ejs +18 -18
- package/layout/_partials/post/copyright.ejs +50 -50
- package/layout/_partials/post/css.ejs +3 -3
- package/layout/_partials/post/meta-bottom.ejs +16 -16
- package/layout/_partials/post/meta-top.ejs +27 -27
- package/layout/_partials/post/scripts.ejs +8 -7
- package/layout/_partials/post/sidebar-left.ejs +1 -1
- package/layout/_partials/post/sidebar-right.ejs +2 -2
- package/layout/_partials/post/toc.ejs +6 -6
- package/layout/_partials/scripts.ejs +10 -10
- package/layout/_partials/search.ejs +19 -19
- package/layout/about.ejs +22 -22
- package/layout/archive.ejs +10 -10
- package/layout/categories.ejs +20 -20
- package/layout/category.ejs +12 -12
- package/layout/index.ejs +61 -61
- package/layout/layout.ejs +60 -60
- package/layout/links.ejs +31 -31
- package/layout/page.ejs +15 -15
- package/layout/post.ejs +77 -77
- package/layout/tag.ejs +12 -12
- package/layout/tags.ejs +26 -26
- package/package.json +73 -70
- package/source/css/_functions/base.styl +8 -8
- package/source/css/_mixins/base.styl +23 -23
- package/source/css/_pages/_about/about.styl +32 -32
- package/source/css/_pages/_archive/archive.styl +32 -32
- package/source/css/_pages/_base/_widget/anchorjs.styl +8 -8
- package/source/css/_pages/_base/_widget/banner.styl +29 -29
- package/source/css/_pages/_base/_widget/board.styl +11 -11
- package/source/css/_pages/_base/_widget/code-widget.styl +37 -36
- package/source/css/_pages/_base/_widget/copyright.styl +91 -90
- package/source/css/_pages/_base/_widget/footer.styl +65 -65
- package/source/css/_pages/_base/_widget/footnote.styl +26 -25
- package/source/css/_pages/_base/_widget/header.styl +173 -173
- package/source/css/_pages/_base/_widget/modal.styl +100 -100
- package/source/css/_pages/_base/_widget/navlink.styl +15 -15
- package/source/css/_pages/_base/_widget/ngrogress.styl +12 -12
- package/source/css/_pages/_base/_widget/noscript.styl +13 -12
- package/source/css/_pages/_base/_widget/pagination.styl +23 -23
- package/source/css/_pages/_base/_widget/qrcode.styl +17 -17
- package/source/css/_pages/_base/_widget/scroll-btn.styl +48 -48
- package/source/css/_pages/_base/_widget/text.styl +20 -19
- package/source/css/_pages/_base/_widget/toc.styl +75 -75
- package/source/css/_pages/_base/base.styl +68 -68
- package/source/css/_pages/_base/color-schema.styl +75 -75
- package/source/css/_pages/_base/inline.styl +51 -51
- package/source/css/_pages/_base/keyframes.styl +31 -31
- package/source/css/_pages/_base/print.styl +39 -38
- package/source/css/_pages/_category/category-bar.styl +58 -58
- package/source/css/_pages/_category/category-chain.styl +6 -6
- package/source/css/_pages/_category/category-list.styl +62 -62
- package/source/css/_pages/_index/index.styl +75 -75
- package/source/css/_pages/_links/links.styl +80 -79
- package/source/css/_pages/_post/comment.styl +28 -27
- package/source/css/_pages/_post/highlight.styl +75 -75
- package/source/css/_pages/_post/markdown.styl +96 -96
- package/source/css/_pages/_post/post-page.styl +179 -179
- package/source/css/_pages/_post/post-plugin.styl +10 -0
- package/source/css/_pages/_post/post-tag.styl +43 -29
- package/source/css/_pages/_tag/tags.styl +9 -9
- package/source/css/_pages/pages.styl +8 -8
- package/source/css/_variables/base.styl +72 -72
- package/source/css/gitalk.css +546 -546
- package/source/css/main.styl +19 -19
- package/source/js/color-schema.js +279 -279
- package/source/js/events.js +72 -72
- package/source/js/img-lazyload.js +10 -10
- package/source/js/local-search.js +70 -70
- package/source/js/post/copying-code.js +34 -34
- package/source/js/post/enable.js +6 -8
- package/source/js/post/img-swipe-bf.js +47 -47
- package/source/js/post/img-swipe.js +81 -35
- package/source/js/post/mermaiding.js +9 -13
- package/source/js/post/play-imgs.js +58 -58
- package/source/js/post/toc.js +24 -24
- package/source/js/post/view-imgs.js +27 -27
- package/source/js/utils.js +245 -245
- package/source/xml/local-search.xml +45 -45
- package/templates/footer.ejs +12 -12
- package/templates/noun.vue +14 -17
- package/templates/utils/uri.ts +12 -0
- package/scripts/index.js +0 -1
- package/source/css/_pages/_tag/tag.styl +0 -9
package/source/js/events.js
CHANGED
@@ -1,72 +1,72 @@
|
|
1
|
-
LNote.events = {
|
2
|
-
registerNavbarEvent() {
|
3
|
-
const $navbar = document.getElementById('navbar')
|
4
|
-
if (!$navbar) {
|
5
|
-
return
|
6
|
-
}
|
7
|
-
|
8
|
-
function $navUd() {
|
9
|
-
const top = window.scrollY || document.documentElement.scrollTop
|
10
|
-
if (top > 0) {
|
11
|
-
$navbar.classList.remove('navbar-dark')
|
12
|
-
if (top > 50) {
|
13
|
-
$navbar.classList.add('top-nav-collapse')
|
14
|
-
} else {
|
15
|
-
$navbar.classList.remove('top-nav-collapse')
|
16
|
-
}
|
17
|
-
} else {
|
18
|
-
$navbar.classList.add('navbar-dark')
|
19
|
-
}
|
20
|
-
}
|
21
|
-
$navUd()
|
22
|
-
LNote.utils.listenScroll($navUd)
|
23
|
-
|
24
|
-
document
|
25
|
-
.getElementById('navbar-toggler-btn')
|
26
|
-
.addEventListener('click', (e) => {
|
27
|
-
document
|
28
|
-
.querySelector('.animated-icon')
|
29
|
-
.classList.toggle('open')
|
30
|
-
$navbar.classList.toggle('navbar-col-show')
|
31
|
-
})
|
32
|
-
},
|
33
|
-
|
34
|
-
/* registerImageLoadedEvent: function () {
|
35
|
-
if (!('NProgress' in window)) {
|
36
|
-
return
|
37
|
-
}
|
38
|
-
|
39
|
-
var bg = document.getElementById('banner')
|
40
|
-
if (bg) {
|
41
|
-
var src = bg.style.backgroundImage
|
42
|
-
var url = src.match(/\((.*?)\)/)[1].replace(/(['"])/g, '')
|
43
|
-
var img = new Image()
|
44
|
-
img.onload = function () {
|
45
|
-
window.NProgress && window.NProgress.inc(0.2)
|
46
|
-
}
|
47
|
-
img.src = url
|
48
|
-
if (img.complete) {
|
49
|
-
img.onload()
|
50
|
-
}
|
51
|
-
}
|
52
|
-
|
53
|
-
var notLazyImages = jQuery('main img:not([lazyload])')
|
54
|
-
var total = notLazyImages.length
|
55
|
-
for (const img of notLazyImages) {
|
56
|
-
const old = img.onload
|
57
|
-
img.onload = function () {
|
58
|
-
old && old()
|
59
|
-
window.NProgress && window.NProgress.inc(0.5 / total)
|
60
|
-
img.onload = null
|
61
|
-
}
|
62
|
-
if (img.complete) {
|
63
|
-
img.onload()
|
64
|
-
}
|
65
|
-
}
|
66
|
-
}, */
|
67
|
-
}
|
68
|
-
|
69
|
-
document.addEventListener('DOMContentLoaded', function () {
|
70
|
-
LNote.events.registerNavbarEvent()
|
71
|
-
// LNote.events.registerImageLoadedEvent()
|
72
|
-
})
|
1
|
+
LNote.events = {
|
2
|
+
registerNavbarEvent() {
|
3
|
+
const $navbar = document.getElementById('navbar')
|
4
|
+
if (!$navbar) {
|
5
|
+
return
|
6
|
+
}
|
7
|
+
|
8
|
+
function $navUd() {
|
9
|
+
const top = window.scrollY || document.documentElement.scrollTop
|
10
|
+
if (top > 0) {
|
11
|
+
$navbar.classList.remove('navbar-dark')
|
12
|
+
if (top > 50) {
|
13
|
+
$navbar.classList.add('top-nav-collapse')
|
14
|
+
} else {
|
15
|
+
$navbar.classList.remove('top-nav-collapse')
|
16
|
+
}
|
17
|
+
} else {
|
18
|
+
$navbar.classList.add('navbar-dark')
|
19
|
+
}
|
20
|
+
}
|
21
|
+
$navUd()
|
22
|
+
LNote.utils.listenScroll($navUd)
|
23
|
+
|
24
|
+
document
|
25
|
+
.getElementById('navbar-toggler-btn')
|
26
|
+
.addEventListener('click', (e) => {
|
27
|
+
document
|
28
|
+
.querySelector('.animated-icon')
|
29
|
+
.classList.toggle('open')
|
30
|
+
$navbar.classList.toggle('navbar-col-show')
|
31
|
+
})
|
32
|
+
},
|
33
|
+
|
34
|
+
/* registerImageLoadedEvent: function () {
|
35
|
+
if (!('NProgress' in window)) {
|
36
|
+
return
|
37
|
+
}
|
38
|
+
|
39
|
+
var bg = document.getElementById('banner')
|
40
|
+
if (bg) {
|
41
|
+
var src = bg.style.backgroundImage
|
42
|
+
var url = src.match(/\((.*?)\)/)[1].replace(/(['"])/g, '')
|
43
|
+
var img = new Image()
|
44
|
+
img.onload = function () {
|
45
|
+
window.NProgress && window.NProgress.inc(0.2)
|
46
|
+
}
|
47
|
+
img.src = url
|
48
|
+
if (img.complete) {
|
49
|
+
img.onload()
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
var notLazyImages = jQuery('main img:not([lazyload])')
|
54
|
+
var total = notLazyImages.length
|
55
|
+
for (const img of notLazyImages) {
|
56
|
+
const old = img.onload
|
57
|
+
img.onload = function () {
|
58
|
+
old && old()
|
59
|
+
window.NProgress && window.NProgress.inc(0.5 / total)
|
60
|
+
img.onload = null
|
61
|
+
}
|
62
|
+
if (img.complete) {
|
63
|
+
img.onload()
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}, */
|
67
|
+
}
|
68
|
+
|
69
|
+
document.addEventListener('DOMContentLoaded', function () {
|
70
|
+
LNote.events.registerNavbarEvent()
|
71
|
+
// LNote.events.registerImageLoadedEvent()
|
72
|
+
})
|
@@ -1,10 +1,10 @@
|
|
1
|
-
/* global LNote, CONFIG */
|
2
|
-
|
3
|
-
(function(window, document) {
|
4
|
-
for (const each of document.querySelectorAll('img[lazyload]')) {
|
5
|
-
LNote.utils.waitElementVisible(each, function() {
|
6
|
-
each.removeAttribute('srcset');
|
7
|
-
each.removeAttribute('lazyload');
|
8
|
-
}, 2);
|
9
|
-
}
|
10
|
-
})(window, document);
|
1
|
+
/* global LNote, CONFIG */
|
2
|
+
|
3
|
+
(function(window, document) {
|
4
|
+
for (const each of document.querySelectorAll('img[lazyload]')) {
|
5
|
+
LNote.utils.waitElementVisible(each, function() {
|
6
|
+
each.removeAttribute('srcset');
|
7
|
+
each.removeAttribute('lazyload');
|
8
|
+
}, 2);
|
9
|
+
}
|
10
|
+
})(window, document);
|
@@ -1,70 +1,70 @@
|
|
1
|
-
;(() => {
|
2
|
-
const $modal = document.getElementById('modalSearch')
|
3
|
-
const $input = document.getElementById('modalSearchInput')
|
4
|
-
const $result = document.getElementById('modalSearchResult')
|
5
|
-
let inputThol
|
6
|
-
|
7
|
-
let dataSource
|
8
|
-
function fetchData() {
|
9
|
-
if (dataSource != null) {
|
10
|
-
return
|
11
|
-
}
|
12
|
-
$result.innerHTML =
|
13
|
-
'<div class="m-auto text-center"><div class="spinner-grow text-primary" role="status"><span class="visually-hidden">Loading...</span></div></div>'
|
14
|
-
fetch(LNote.root + 'content.json')
|
15
|
-
.then((rep) => rep.json())
|
16
|
-
.then((res) => (dataSource = res))
|
17
|
-
.finally(() => ($result.innerHTML = ''))
|
18
|
-
}
|
19
|
-
|
20
|
-
$modal.addEventListener('show.bs.modal', () => {
|
21
|
-
fetchData()
|
22
|
-
$input.focus()
|
23
|
-
})
|
24
|
-
|
25
|
-
$modal.addEventListener('hidden.bs.modal', () => {
|
26
|
-
console.log('hide')
|
27
|
-
})
|
28
|
-
|
29
|
-
$input.addEventListener('input', (e) => {
|
30
|
-
if (dataSource == null) {
|
31
|
-
return
|
32
|
-
}
|
33
|
-
clearTimeout(inputThol)
|
34
|
-
inputThol = setTimeout(() => {
|
35
|
-
const kw = e.target.value.trim()
|
36
|
-
if (kw === '') {
|
37
|
-
return
|
38
|
-
}
|
39
|
-
const matchedList = dataSource.filter((item) => {
|
40
|
-
return item.excerpt.includes(kw) || item.title.includes(kw)
|
41
|
-
})
|
42
|
-
if (matchedList.length > 0) {
|
43
|
-
e.target.classList.remove('invalid')
|
44
|
-
e.target.classList.add('valid')
|
45
|
-
const { root } = LNote
|
46
|
-
$result.innerHTML = matchedList
|
47
|
-
.map((item) => {
|
48
|
-
let { excerpt, title } = item
|
49
|
-
if (excerpt.includes(kw)) {
|
50
|
-
excerpt = excerpt.replace(
|
51
|
-
kw,
|
52
|
-
`<span class="text-success-emphasis">${kw}</span>`
|
53
|
-
)
|
54
|
-
} else if (title.includes(kw)) {
|
55
|
-
title = title.replace(
|
56
|
-
kw,
|
57
|
-
`<span class="text-success-emphasis">${kw}</span>`
|
58
|
-
)
|
59
|
-
}
|
60
|
-
|
61
|
-
return `<div><a href="${root}${item.path}" class="fs-5 link-warning">${title}</a><p>${excerpt}</p></div>`
|
62
|
-
})
|
63
|
-
.join('')
|
64
|
-
} else {
|
65
|
-
e.target.classList.remove('valid')
|
66
|
-
e.target.classList.add('invalid')
|
67
|
-
}
|
68
|
-
}, 500)
|
69
|
-
})
|
70
|
-
})()
|
1
|
+
;(() => {
|
2
|
+
const $modal = document.getElementById('modalSearch')
|
3
|
+
const $input = document.getElementById('modalSearchInput')
|
4
|
+
const $result = document.getElementById('modalSearchResult')
|
5
|
+
let inputThol
|
6
|
+
|
7
|
+
let dataSource
|
8
|
+
function fetchData() {
|
9
|
+
if (dataSource != null) {
|
10
|
+
return
|
11
|
+
}
|
12
|
+
$result.innerHTML =
|
13
|
+
'<div class="m-auto text-center"><div class="spinner-grow text-primary" role="status"><span class="visually-hidden">Loading...</span></div></div>'
|
14
|
+
fetch(LNote.root + 'content.json')
|
15
|
+
.then((rep) => rep.json())
|
16
|
+
.then((res) => (dataSource = res))
|
17
|
+
.finally(() => ($result.innerHTML = ''))
|
18
|
+
}
|
19
|
+
|
20
|
+
$modal.addEventListener('show.bs.modal', () => {
|
21
|
+
fetchData()
|
22
|
+
$input.focus()
|
23
|
+
})
|
24
|
+
|
25
|
+
$modal.addEventListener('hidden.bs.modal', () => {
|
26
|
+
console.log('hide')
|
27
|
+
})
|
28
|
+
|
29
|
+
$input.addEventListener('input', (e) => {
|
30
|
+
if (dataSource == null) {
|
31
|
+
return
|
32
|
+
}
|
33
|
+
clearTimeout(inputThol)
|
34
|
+
inputThol = setTimeout(() => {
|
35
|
+
const kw = e.target.value.trim()
|
36
|
+
if (kw === '') {
|
37
|
+
return
|
38
|
+
}
|
39
|
+
const matchedList = dataSource.filter((item) => {
|
40
|
+
return item.excerpt.includes(kw) || item.title.includes(kw)
|
41
|
+
})
|
42
|
+
if (matchedList.length > 0) {
|
43
|
+
e.target.classList.remove('invalid')
|
44
|
+
e.target.classList.add('valid')
|
45
|
+
const { root } = LNote
|
46
|
+
$result.innerHTML = matchedList
|
47
|
+
.map((item) => {
|
48
|
+
let { excerpt, title } = item
|
49
|
+
if (excerpt.includes(kw)) {
|
50
|
+
excerpt = excerpt.replace(
|
51
|
+
kw,
|
52
|
+
`<span class="text-success-emphasis">${kw}</span>`
|
53
|
+
)
|
54
|
+
} else if (title.includes(kw)) {
|
55
|
+
title = title.replace(
|
56
|
+
kw,
|
57
|
+
`<span class="text-success-emphasis">${kw}</span>`
|
58
|
+
)
|
59
|
+
}
|
60
|
+
|
61
|
+
return `<div><a href="${root}${item.path}" class="fs-5 link-warning">${title}</a><p>${excerpt}</p></div>`
|
62
|
+
})
|
63
|
+
.join('')
|
64
|
+
} else {
|
65
|
+
e.target.classList.remove('valid')
|
66
|
+
e.target.classList.add('invalid')
|
67
|
+
}
|
68
|
+
}, 500)
|
69
|
+
})
|
70
|
+
})()
|
@@ -1,34 +1,34 @@
|
|
1
|
-
;(() => {
|
2
|
-
if (!'ClipboardJS' in window) {
|
3
|
-
return
|
4
|
-
}
|
5
|
-
|
6
|
-
function genSVG(id) {
|
7
|
-
return `<svg width="1em" height="1em"><use xlink:href="#${id}"/></svg>`
|
8
|
-
}
|
9
|
-
|
10
|
-
const codes = document.querySelectorAll('.markdown-body .highlight')
|
11
|
-
codes.forEach((item) => {
|
12
|
-
const btn = document.createElement('button')
|
13
|
-
btn.type = 'button'
|
14
|
-
btn.classList.add('btn-clipboard')
|
15
|
-
btn.title = 'Copy to clipboard'
|
16
|
-
btn.innerHTML = genSVG('clipboard')
|
17
|
-
item.insertAdjacentElement('afterbegin', btn)
|
18
|
-
})
|
19
|
-
|
20
|
-
const clipboard = new ClipboardJS('.btn-clipboard', {
|
21
|
-
target: function (trigger) {
|
22
|
-
return trigger.parentNode.getElementsByTagName('code')[0]
|
23
|
-
},
|
24
|
-
})
|
25
|
-
clipboard.on('success', function (e) {
|
26
|
-
e.clearSelection()
|
27
|
-
e.trigger.innerHTML = genSVG('check')
|
28
|
-
e.trigger.title = 'Copied!'
|
29
|
-
setTimeout(function () {
|
30
|
-
e.trigger.innerHTML = genSVG('clipboard')
|
31
|
-
e.trigger.title = 'Copy to clipboard'
|
32
|
-
}, 2000)
|
33
|
-
})
|
34
|
-
})()
|
1
|
+
;(() => {
|
2
|
+
if (!'ClipboardJS' in window) {
|
3
|
+
return
|
4
|
+
}
|
5
|
+
|
6
|
+
function genSVG(id) {
|
7
|
+
return `<svg width="1em" height="1em"><use xlink:href="#${id}"/></svg>`
|
8
|
+
}
|
9
|
+
|
10
|
+
const codes = document.querySelectorAll('.markdown-body .highlight')
|
11
|
+
codes.forEach((item) => {
|
12
|
+
const btn = document.createElement('button')
|
13
|
+
btn.type = 'button'
|
14
|
+
btn.classList.add('btn-clipboard')
|
15
|
+
btn.title = 'Copy to clipboard'
|
16
|
+
btn.innerHTML = genSVG('clipboard')
|
17
|
+
item.insertAdjacentElement('afterbegin', btn)
|
18
|
+
})
|
19
|
+
|
20
|
+
const clipboard = new ClipboardJS('.btn-clipboard', {
|
21
|
+
target: function (trigger) {
|
22
|
+
return trigger.parentNode.getElementsByTagName('code')[0]
|
23
|
+
},
|
24
|
+
})
|
25
|
+
clipboard.on('success', function (e) {
|
26
|
+
e.clearSelection()
|
27
|
+
e.trigger.innerHTML = genSVG('check')
|
28
|
+
e.trigger.title = 'Copied!'
|
29
|
+
setTimeout(function () {
|
30
|
+
e.trigger.innerHTML = genSVG('clipboard')
|
31
|
+
e.trigger.title = 'Copy to clipboard'
|
32
|
+
}, 2000)
|
33
|
+
})
|
34
|
+
})()
|
package/source/js/post/enable.js
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
)
|
8
|
-
})()
|
1
|
+
const popoverTriggerList = document.querySelectorAll(
|
2
|
+
'[data-bs-toggle="popover"]'
|
3
|
+
)
|
4
|
+
const popoverList = [...popoverTriggerList].map(
|
5
|
+
(popoverTriggerEl) => new bootstrap.Popover(popoverTriggerEl)
|
6
|
+
)
|
@@ -1,47 +1,47 @@
|
|
1
|
-
;(() => {
|
2
|
-
const imgs = document.querySelectorAll('.markdown-body img')
|
3
|
-
const promiseds = Array.prototype.map.call(imgs, (item) => {
|
4
|
-
return new Promise((resolve, reject) => {
|
5
|
-
const src = item.getAttribute('src')
|
6
|
-
const __img = new Image()
|
7
|
-
__img.onload = function () {
|
8
|
-
const a = document.createElement('a')
|
9
|
-
a.href = src
|
10
|
-
a.target = '_blank'
|
11
|
-
a.setAttribute('data-pswp-src', src)
|
12
|
-
a.setAttribute('data-pswp-width', __img.width)
|
13
|
-
a.setAttribute('data-pswp-height', __img.height)
|
14
|
-
const parentNode = item.parentNode
|
15
|
-
parentNode.removeChild(item)
|
16
|
-
a.appendChild(item)
|
17
|
-
parentNode.appendChild(a)
|
18
|
-
resolve()
|
19
|
-
}
|
20
|
-
__img.onerror = function () {
|
21
|
-
reject()
|
22
|
-
}
|
23
|
-
__img.src = src
|
24
|
-
})
|
25
|
-
})
|
26
|
-
|
27
|
-
Promise.allSettled(promiseds).then(() => {
|
28
|
-
const lightbox = new PhotoSwipeLightbox({
|
29
|
-
gallery: '#board',
|
30
|
-
children: 'a[data-pswp-src]',
|
31
|
-
pswpModule: () => PhotoSwipe,
|
32
|
-
wheelToZoom: true,
|
33
|
-
})
|
34
|
-
lightbox.init()
|
35
|
-
/* lightbox.on('initialLayout', () => {
|
36
|
-
$('.pswp').on('contextmenu.fb', function (e) {
|
37
|
-
if (e.button == 2) {
|
38
|
-
e.preventDefault()
|
39
|
-
}
|
40
|
-
return true
|
41
|
-
})
|
42
|
-
}) */
|
43
|
-
/* lightbox.on('destroy', () => {
|
44
|
-
console.log('destroy');
|
45
|
-
}); */
|
46
|
-
})
|
47
|
-
})()
|
1
|
+
;(() => {
|
2
|
+
const imgs = document.querySelectorAll('.markdown-body img')
|
3
|
+
const promiseds = Array.prototype.map.call(imgs, (item) => {
|
4
|
+
return new Promise((resolve, reject) => {
|
5
|
+
const src = item.getAttribute('src')
|
6
|
+
const __img = new Image()
|
7
|
+
__img.onload = function () {
|
8
|
+
const a = document.createElement('a')
|
9
|
+
a.href = src
|
10
|
+
a.target = '_blank'
|
11
|
+
a.setAttribute('data-pswp-src', src)
|
12
|
+
a.setAttribute('data-pswp-width', __img.width)
|
13
|
+
a.setAttribute('data-pswp-height', __img.height)
|
14
|
+
const parentNode = item.parentNode
|
15
|
+
parentNode.removeChild(item)
|
16
|
+
a.appendChild(item)
|
17
|
+
parentNode.appendChild(a)
|
18
|
+
resolve()
|
19
|
+
}
|
20
|
+
__img.onerror = function () {
|
21
|
+
reject()
|
22
|
+
}
|
23
|
+
__img.src = src
|
24
|
+
})
|
25
|
+
})
|
26
|
+
|
27
|
+
Promise.allSettled(promiseds).then(() => {
|
28
|
+
const lightbox = new PhotoSwipeLightbox({
|
29
|
+
gallery: '#board',
|
30
|
+
children: 'a[data-pswp-src]',
|
31
|
+
pswpModule: () => PhotoSwipe,
|
32
|
+
wheelToZoom: true,
|
33
|
+
})
|
34
|
+
lightbox.init()
|
35
|
+
/* lightbox.on('initialLayout', () => {
|
36
|
+
$('.pswp').on('contextmenu.fb', function (e) {
|
37
|
+
if (e.button == 2) {
|
38
|
+
e.preventDefault()
|
39
|
+
}
|
40
|
+
return true
|
41
|
+
})
|
42
|
+
}) */
|
43
|
+
/* lightbox.on('destroy', () => {
|
44
|
+
console.log('destroy');
|
45
|
+
}); */
|
46
|
+
})
|
47
|
+
})()
|
@@ -1,35 +1,81 @@
|
|
1
|
-
import PhotoSwipeLightbox from '
|
2
|
-
|
3
|
-
const
|
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
|
-
}
|
1
|
+
import PhotoSwipeLightbox from '//lib.baomitu.com/photoswipe/5.4.2/photoswipe-lightbox.esm.min.js'
|
2
|
+
|
3
|
+
const lightbox = new PhotoSwipeLightbox({
|
4
|
+
pswpModule: () => import('//lib.baomitu.com/photoswipe/5.4.2/photoswipe.esm.min.js'),
|
5
|
+
wheelToZoom: true,
|
6
|
+
})
|
7
|
+
const groups = []
|
8
|
+
|
9
|
+
const imgClick = (event) => {
|
10
|
+
const dataSwipeI = Number.parseInt(event.target.getAttribute('data-swipe-i'))
|
11
|
+
const dataSwipeGi = event.target.getAttribute('data-swipe-gi')
|
12
|
+
lightbox.loadAndOpen(dataSwipeI, groups[dataSwipeGi])
|
13
|
+
}
|
14
|
+
|
15
|
+
function imgToData($img, groupIndex, index) {
|
16
|
+
return new Promise((resolve, reject) => {
|
17
|
+
$img.setAttribute('data-swipe-gi', groupIndex)
|
18
|
+
$img.setAttribute('data-swipe-i', index)
|
19
|
+
const src = $img.getAttribute('src')
|
20
|
+
const alt = $img.getAttribute('alt')
|
21
|
+
const data = { src, alt }
|
22
|
+
const loadDone = () => {
|
23
|
+
groups[groupIndex][index] = {
|
24
|
+
...data,
|
25
|
+
width: $img.naturalWidth,
|
26
|
+
height: $img.naturalHeight,
|
27
|
+
}
|
28
|
+
resolve()
|
29
|
+
$img.onclick = imgClick
|
30
|
+
}
|
31
|
+
if ($img.complete) {
|
32
|
+
loadDone()
|
33
|
+
} else {
|
34
|
+
$img.onload = loadDone
|
35
|
+
}
|
36
|
+
|
37
|
+
$img.onerror = () => {
|
38
|
+
reject()
|
39
|
+
}
|
40
|
+
})
|
41
|
+
}
|
42
|
+
|
43
|
+
const promiseds = []
|
44
|
+
|
45
|
+
document.querySelectorAll('.img-swipe-single').forEach($img => {
|
46
|
+
const groupIndex = groups.length
|
47
|
+
groups.push([{}])
|
48
|
+
promiseds.push(imgToData($img, groupIndex, 0))
|
49
|
+
})
|
50
|
+
|
51
|
+
document.querySelectorAll('.img-swipe-group').forEach($group => {
|
52
|
+
const groupIndex = groups.length
|
53
|
+
groups.push([])
|
54
|
+
$group.querySelectorAll('img').forEach(($img, index) => {
|
55
|
+
groups[groupIndex].push({})
|
56
|
+
promiseds.push(imgToData($img, groupIndex, index))
|
57
|
+
})
|
58
|
+
})
|
59
|
+
|
60
|
+
if (promiseds.length === 0) {
|
61
|
+
throw new Error('empty img')
|
62
|
+
}
|
63
|
+
|
64
|
+
Promise.allSettled(promiseds).then(() => {
|
65
|
+
lightbox.on('uiRegister', () => {
|
66
|
+
lightbox.pswp.ui.registerElement({
|
67
|
+
name: 'custom-caption',
|
68
|
+
className: 'lnote-lightbox-caption',
|
69
|
+
order: 9,
|
70
|
+
isButton: false,
|
71
|
+
appendTo: 'root',
|
72
|
+
html: 'Caption text',
|
73
|
+
onInit(el, pswp) {
|
74
|
+
pswp.on('change', () => {
|
75
|
+
el.innerHTML = `<div>${pswp.currSlide.data.alt}</div>`
|
76
|
+
})
|
77
|
+
},
|
78
|
+
})
|
79
|
+
})
|
80
|
+
lightbox.init()
|
81
|
+
})
|
@@ -1,13 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
theme,
|
11
|
-
})
|
12
|
-
mermaid.init()
|
13
|
-
})()
|
1
|
+
let theme = document.documentElement.getAttribute('data-bs-theme')
|
2
|
+
if (theme !== 'dark') {
|
3
|
+
theme = 'forest'
|
4
|
+
}
|
5
|
+
mermaid.initialize({
|
6
|
+
theme,
|
7
|
+
startOnLoad: true
|
8
|
+
})
|
9
|
+
mermaid.init()
|