From f2a6ae3ef8dee5764bf99e051c4a2ff548b1d8ca Mon Sep 17 00:00:00 2001 From: f0x52 Date: Sun, 7 Aug 2022 17:58:01 +0200 Subject: [feature] Photoswipe gallery (#740) * implement photoswipe galleries * dependency wrangling * photoswipe-dynamic-caption plugin --- web/source/frontend/index.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'web/source/frontend/index.js') diff --git a/web/source/frontend/index.js b/web/source/frontend/index.js index e761202bb..5c53a31bf 100644 --- a/web/source/frontend/index.js +++ b/web/source/frontend/index.js @@ -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) { -- cgit v1.2.3