// modules/lightbox-trigger/index.js import { UIManager } from '../ui/UIManager.js'; import { Logger } from '../../core/logger.js'; import { useEvent } from '../../core/useEvent.js'; function onClick(e) { // Check if the clicked element is an image let img = null; if (e.target.tagName === 'IMG') { img = e.target; } else { // Check if clicked element contains an image img = e.target.querySelector('img'); } if (!img) return; // Opt-out mechanism: skip if image has data-lightbox="false" if (img.dataset.lightbox === 'false') return; // Skip very small images (likely icons, thumbnails, decorative) if (img.naturalWidth < 200 || img.naturalHeight < 200) return; // Skip images in specific containers that shouldn't open lightbox if (img.closest('nav, header, footer, .no-lightbox')) return; e.preventDefault(); // Get the best quality source for lightbox const lightboxSrc = getBestImageSource(img); const caption = img.alt || img.dataset.caption || img.title || ''; // Create responsive picture element for lightbox const pictureElement = img.closest('picture'); let lightboxContent; if (pictureElement) { // Clone the entire picture element for responsive display const clonedPicture = pictureElement.cloneNode(true); const clonedImg = clonedPicture.querySelector('img'); clonedImg.className = 'lightbox-image'; lightboxContent = `