From 0816e0e4df55d4fe9133f306886b42b4aee2e679 Mon Sep 17 00:00:00 2001 From: BentiGorlich Date: Fri, 31 Jan 2025 12:38:35 +0100 Subject: [PATCH 1/3] Always put thumb images in a lightbox - this commit puts all thumb images in a lightbox - additionally we now set the `data-gallery` so only the images belonging to one post are in a gallery together (which will currently always be one) --- templates/components/_figure_entry.html.twig | 11 +++-------- templates/components/_figure_image.html.twig | 1 + templates/components/entry_comment.html.twig | 3 ++- templates/components/post.html.twig | 3 ++- templates/components/post_comment.html.twig | 3 ++- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/templates/components/_figure_entry.html.twig b/templates/components/_figure_entry.html.twig index 8bef85441..74ab96822 100644 --- a/templates/components/_figure_entry.html.twig +++ b/templates/components/_figure_entry.html.twig @@ -3,13 +3,7 @@ {% set sensitive_id = 'sensitive-check-%s-%s'|format(entry.id, image.id) %} {% set lightbox_alt_id = 'thumb-alt-%s-%s'|format(entry.id, image.id) %} {% set image_path = image.filePath ? asset(image.filePath)|imagine_filter('entry_thumb') : image.sourceUrl %} - - - {% if type is same as 'image' %} - {% set route = is_single ? uploaded_asset(image) : entry_url(entry) %} - {% elseif type is same as 'link' %} - {% set route = is_single ? entry.url : entry_url(entry) %} - {% endif %} + {% set route = uploaded_asset(image) %} {% set is_single_image = is_single and type is same as 'image' %} @@ -31,8 +25,9 @@ aria-label="{{ 'sensitive_toggle'|trans }}"> {% endif %} Date: Wed, 5 Feb 2025 14:33:02 +0100 Subject: [PATCH 2/3] Fix JS NRE --- assets/controllers/subject_controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/controllers/subject_controller.js b/assets/controllers/subject_controller.js index 9bf8afcbd..d619ea800 100644 --- a/assets/controllers/subject_controller.js +++ b/assets/controllers/subject_controller.js @@ -39,7 +39,7 @@ export default class extends Controller { // if in a list and the click is made via touch, open the post if (!this.element.classList.contains('isSingle')) { - this.element.querySelector('.content').addEventListener('click', (e) => { + this.element.querySelector('.content')?.addEventListener('click', (e) => { if (e.defaultPrevented) { return } From 6ae49b0166b3f861bc9683e6fc8e33208d845a2d Mon Sep 17 00:00:00 2001 From: BentiGorlich Date: Wed, 12 Feb 2025 12:47:22 +0100 Subject: [PATCH 3/3] Remove duplicate lightbox - Remove the lightbox call from the subject controller, as this is taken care of by the lightbox controller --- assets/controllers/lightbox_controller.js | 7 ++++++- assets/controllers/subject_controller.js | 4 ---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/assets/controllers/lightbox_controller.js b/assets/controllers/lightbox_controller.js index a54ee8399..3f7c05d0d 100644 --- a/assets/controllers/lightbox_controller.js +++ b/assets/controllers/lightbox_controller.js @@ -4,7 +4,12 @@ import GLightbox from 'glightbox'; /* stimulusFetch: 'lazy' */ export default class extends Controller { connect() { - const params = { selector: '.thumb', openEffect: 'none', closeEffect: 'none', slideEffect: 'none' }; + const params = { + selector: '.thumb', + openEffect: 'none', + closeEffect: 'none', + touchNavigation: true, + }; GLightbox(params); } } diff --git a/assets/controllers/subject_controller.js b/assets/controllers/subject_controller.js index ad672a39c..61f4ea40c 100644 --- a/assets/controllers/subject_controller.js +++ b/assets/controllers/subject_controller.js @@ -1,7 +1,6 @@ import { fetch, ok } from '../utils/http'; import getIntIdFromElement, { getDepth, getLevel, getTypeFromNotification } from '../utils/mbin'; import { Controller } from '@hotwired/stimulus'; -import GLightbox from 'glightbox'; import router from '../utils/routing'; import { useIntersection } from 'stimulus-use'; @@ -16,9 +15,6 @@ export default class extends Controller { static sendBtnLabel = null; connect() { - const params = { selector: '.thumb', openEffect: 'none', closeEffect: 'none', slideEffect: 'none' }; - GLightbox(params); - const self = this; if (this.hasMoreTarget) { this.moreTarget.addEventListener('focusin', () => {