hexo-theme-stellar/layout/_plugins/fancybox.ejs

33 lines
891 B
Plaintext
Raw Normal View History

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) => {
return slide.triggerEl.alt || slide.triggerEl.dataset.caption || null
2024-02-12 23:07:56 +08:00
}
});
})
}
</script>