hexo-theme-linen 1.0.18 → 1.0.20
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/layout/post.ejs +1 -0
- package/package.json +1 -1
- package/scripts/footnote.js +99 -0
- package/scripts/index.js +1 -0
- package/source/linen-theme/css/linen.scss +16 -0
- package/source/linen-theme/img/icons/backref.svg +1 -0
- package/source/linen-theme/js/gitalk/gitalk.min.js +6 -6
- package/source/linen-theme/js/linen.js +52 -8
- package/source/linen-theme/js/photoswipe/photoswipe.esm.min.js +234 -509
|
@@ -161,14 +161,30 @@ function copyToClipboard(text) {
|
|
|
161
161
|
copyToClipboard(text);
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
function highlightAnchor(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
164
|
+
function highlightAnchor(
|
|
165
|
+
hash,
|
|
166
|
+
highlightClass = "anchor-highlight",
|
|
167
|
+
element = null,
|
|
168
|
+
) {
|
|
169
|
+
if (element) {
|
|
170
|
+
element.classList.remove(highlightClass);
|
|
171
|
+
void element.offsetWidth;
|
|
172
|
+
element.classList.add(highlightClass);
|
|
173
|
+
setTimeout(() => {
|
|
174
|
+
element.classList.remove(highlightClass);
|
|
175
|
+
}, 4000);
|
|
176
|
+
} else {
|
|
177
|
+
if (!hash) return;
|
|
178
|
+
const id = hash.replace(/^#/, "");
|
|
179
|
+
const el = document.getElementById(id);
|
|
180
|
+
if (el) {
|
|
181
|
+
el.classList.remove(highlightClass);
|
|
182
|
+
void el.offsetWidth;
|
|
183
|
+
el.classList.add(highlightClass);
|
|
184
|
+
setTimeout(() => {
|
|
185
|
+
el.classList.remove(highlightClass);
|
|
186
|
+
}, 4000);
|
|
187
|
+
}
|
|
172
188
|
}
|
|
173
189
|
}
|
|
174
190
|
|
|
@@ -272,6 +288,34 @@ function handleClick(e) {
|
|
|
272
288
|
var maskElement = document.getElementById("mask");
|
|
273
289
|
var bodyElement = document.body;
|
|
274
290
|
var donateModal = document.getElementById("donate-modal");
|
|
291
|
+
if(target?.className === 'footnote-href') {
|
|
292
|
+
const footNoteDefinitionId = target.getAttribute("href").substring(1);
|
|
293
|
+
const footNoteDefinitionElement = document.getElementById(footNoteDefinitionId);
|
|
294
|
+
if (footNoteDefinitionElement) {
|
|
295
|
+
footNoteDefinitionElement.scrollIntoView({
|
|
296
|
+
behavior: "smooth",
|
|
297
|
+
block: "start",
|
|
298
|
+
});
|
|
299
|
+
e.preventDefault();
|
|
300
|
+
highlightAnchor(undefined, undefined, footNoteDefinitionElement);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (target?.className === "footnote-backref") {
|
|
305
|
+
const footNoteId = target.getAttribute("href").substring(1);
|
|
306
|
+
const footNoteTextElements = document.querySelectorAll('.footnote-anchor-wrap');
|
|
307
|
+
if (footNoteTextElements.length) {
|
|
308
|
+
footNoteTextElements[0].scrollIntoView({
|
|
309
|
+
behavior: "smooth",
|
|
310
|
+
block: "start",
|
|
311
|
+
});
|
|
312
|
+
e.preventDefault();
|
|
313
|
+
Array.prototype.forEach.call(footNoteTextElements, (el) => {
|
|
314
|
+
highlightAnchor(undefined, undefined, el);
|
|
315
|
+
})
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
275
319
|
if (/content-switch/.test(target.id)) {
|
|
276
320
|
if (document.body.classList.contains("render-raw")) {
|
|
277
321
|
target.innerText = target.dataset.rawcontentlabel;
|