[feature] Photoswipe gallery (#740)

* implement photoswipe galleries

* dependency wrangling

* photoswipe-dynamic-caption plugin
This commit is contained in:
f0x52
2022-08-07 17:58:01 +02:00
committed by GitHub
parent 745f54970d
commit f2a6ae3ef8
6 changed files with 51 additions and 10 deletions

View File

@ -23,9 +23,24 @@
// our frontend templates don't load the common bundle.js since it contains React etc
// so we can't use any dependencies that would deduplicate with the other files
const Photoswipe = require("photoswipe/dist/umd/photoswipe.umd.min.js");
const PhotoswipeLightbox = require("photoswipe/dist/umd/photoswipe-lightbox.umd.min.js");
const PhotoswipeCaptionPlugin = require("photoswipe-dynamic-caption-plugin").default;
const lightbox = new PhotoswipeLightbox({
gallery: '.photoswipe-gallery',
children: 'a',
pswpModule: Photoswipe,
});
new PhotoswipeCaptionPlugin(lightbox, {
type: 'auto',
});
lightbox.init();
Array.from(document.getElementsByClassName("spoiler-label")).forEach((label) => {
let checkbox = document.getElementById(label.htmlFor);
console.log(label, checkbox);
if (checkbox != undefined) {
function update() {
if(checkbox.checked) {