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

32 lines
864 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) {
const els = document.getElementsByClassName('stellar-memos-api');
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 || null
}
});
})
}
</script>