summaryrefslogtreecommitdiff
path: root/web/source/frontend/index.js
diff options
context:
space:
mode:
authorLibravatar f0x52 <f0x@cthu.lu>2022-08-07 17:58:01 +0200
committerLibravatar GitHub <noreply@github.com>2022-08-07 17:58:01 +0200
commitf2a6ae3ef8dee5764bf99e051c4a2ff548b1d8ca (patch)
tree5c853ad758fe0d3702bf870d21392ebc87582813 /web/source/frontend/index.js
parent[frontend] style blockquote nicely within content (#742) (diff)
downloadgotosocial-f2a6ae3ef8dee5764bf99e051c4a2ff548b1d8ca.tar.xz
[feature] Photoswipe gallery (#740)
* implement photoswipe galleries * dependency wrangling * photoswipe-dynamic-caption plugin
Diffstat (limited to 'web/source/frontend/index.js')
-rw-r--r--web/source/frontend/index.js17
1 files changed, 16 insertions, 1 deletions
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) {