2024-02-12 23:07:56 +08:00
|
|
|
<script>
|
|
|
|
ctx.fancybox = {
|
|
|
|
selector: `<%- conf.selector %>`,
|
|
|
|
css: `<%- conf.css %>`,
|
|
|
|
js: `<%- conf.js %>`
|
|
|
|
};
|
|
|
|
var selector = '[data-fancybox]:not(.error)';
|
|
|
|
if (ctx.fancybox.selector) {
|
|
|
|
selector += `, ${ctx.fancybox.selector}`
|
|
|
|
}
|
|
|
|
var needFancybox = document.querySelectorAll(selector).length !== 0;
|
|
|
|
if (!needFancybox) {
|
2024-02-18 12:33:28 +08:00
|
|
|
const els = document.getElementsByClassName('ds-memos');
|
2024-02-12 23:07:56 +08:00
|
|
|
if (els != undefined && els.length > 0) {
|
|
|
|
needFancybox = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (needFancybox) {
|
|
|
|
utils.css(ctx.fancybox.css);
|
|
|
|
utils.js(ctx.fancybox.js, { defer: true }).then(function () {
|
|
|
|
Fancybox.bind(selector, {
|
|
|
|
hideScrollbar: false,
|
|
|
|
Thumbs: {
|
|
|
|
autoStart: false,
|
|
|
|
},
|
|
|
|
caption: (fancybox, slide) => {
|
2024-04-25 00:15:19 +08:00
|
|
|
return slide.triggerEl.alt || slide.triggerEl.dataset.caption || null
|
2024-02-12 23:07:56 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
}
|
2024-04-25 00:15:19 +08:00
|
|
|
</script>
|