summaryrefslogtreecommitdiff
path: root/public/javascripts/admin_interface.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/admin_interface.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/admin_interface.js')
-rw-r--r--public/javascripts/admin_interface.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/public/javascripts/admin_interface.js b/public/javascripts/admin_interface.js
index 7fb1dc2..f378c46 100644
--- a/public/javascripts/admin_interface.js
+++ b/public/javascripts/admin_interface.js
@@ -282,6 +282,7 @@ cccms = {
282 large: $(this).data('large-url'), 282 large: $(this).data('large-url'),
283 original: $(this).data('original-url'), 283 original: $(this).data('original-url'),
284 name: $(this).data('name'), 284 name: $(this).data('name'),
285 hasCredit: $(this).data('has-credit') === true,
285 headline: $(this).data('headline') === true 286 headline: $(this).data('headline') === true
286 }; 287 };
287 }).get(); 288 }).get();
@@ -320,8 +321,11 @@ cccms = {
320 : 'inline-image inline-image--half inline-image--' + placement; 321 : 'inline-image inline-image--half inline-image--' + placement;
321 322
322 var esc = cccms.inline_images.escape_attr; 323 var esc = cccms.inline_images.escape_attr;
324 var titleForGlightbox = (item.name || '').replace(/;/g, ',');
325 var glightboxOpts = 'title: ' + esc(titleForGlightbox) +
326 (item.hasCredit ? '; description: #credit_for_asset_' + esc(item.id) : '') + ';';
323 var html = '<a href="' + esc(item.original) + '" class="glightbox" data-gallery="page-' + esc(cccms.inline_images.node_id) + '"' + 327 var html = '<a href="' + esc(item.original) + '" class="glightbox" data-gallery="page-' + esc(cccms.inline_images.node_id) + '"' +
324 ' data-title="' + esc(item.name) + '" data-description="#credit_for_asset_' + esc(item.id) + '">' + 328 ' data-glightbox="' + glightboxOpts + '">' +
325 '<img src="' + esc(item.large) + '" class="' + classes + '" alt="' + esc(item.name) + '"></a>'; 329 '<img src="' + esc(item.large) + '" class="' + classes + '" alt="' + esc(item.name) + '"></a>';
326 330
327 cccms.inline_images.editor.insertContent(html); 331 cccms.inline_images.editor.insertContent(html);