33 lines
891 B
Plaintext
33 lines
891 B
Plaintext
<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) {
|
|
const els = document.getElementsByClassName('ds-memos');
|
|
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) => {
|
|
return slide.triggerEl.alt || slide.triggerEl.dataset.caption || null
|
|
}
|
|
});
|
|
})
|
|
}
|
|
</script>
|