summaryrefslogtreecommitdiff
path: root/public/javascripts/public.js
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-21 14:24:59 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-21 14:24:59 +0200
commitc14683fe37fabe06082f43e8bf67debc4cca7297 (patch)
tree10054588f053cf071a55df067180091d3388e05a /public/javascripts/public.js
parent1912b8fbf0e1e1ea84a89c033e20e34235d19cce (diff)
Render asset credit inside the gallery lightbox correctly
GLightbox's own selector-based description feature never actually resolved a selector in three different attempts -- literal text, then a resolved-but-empty div, then apparently not firing at all against the installed (unversioned) build. Replaced with a small afterSlideLoad handler that reads a plain data-credit-selector attribute and copies the real element's HTML into the slide's description area directly, depending only on GLightbox handing back a real DOM node per slide -- a much smaller contract than trusting its own caption-resolution feature. Renamed the credit div's class from glightbox-desc, since that name is reserved by the library's own bundled CSS (display: none !important) and can't be reliably overridden from here. Also: distinguishes the credit line and the "N Bilder" caption from ordinary body text (italic, muted, matching .author_and_date's existing convention), and makes the lightbox's caption card follow the site's light/dark toggle via Canvas/CanvasText, since the library's bundled theme never adapts to it on its own.
Diffstat (limited to 'public/javascripts/public.js')
-rw-r--r--public/javascripts/public.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/public/javascripts/public.js b/public/javascripts/public.js
index a9250ca..7f38f66 100644
--- a/public/javascripts/public.js
+++ b/public/javascripts/public.js
@@ -1,6 +1,25 @@
1document.addEventListener('DOMContentLoaded', function(){ 1document.addEventListener('DOMContentLoaded', function(){
2 2
3 GLightbox({ selector: '.glightbox' }); 3 GLightbox({
4 selector: '.glightbox',
5 afterSlideLoad: function(slideData) {
6 var trigger = document.querySelectorAll('.glightbox')[slideData.index];
7 var selector = trigger && trigger.dataset.creditSelector;
8 if (!selector) return;
9
10 var source = document.querySelector(selector);
11 var container = slideData.slide.querySelector('.gdesc-inner');
12 if (!source || !container) return;
13
14 var target = container.querySelector('.gslide-desc');
15 if (!target) {
16 target = document.createElement('div');
17 target.className = 'gslide-desc';
18 container.appendChild(target);
19 }
20 target.innerHTML = source.innerHTML;
21 }
22 });
4 23
5 document.getElementById("light-mode").addEventListener("change", () => { 24 document.getElementById("light-mode").addEventListener("change", () => {
6 if (document.getElementById("light-mode").checked) 25 if (document.getElementById("light-mode").checked)