1import PhotoSwipeLightbox from './photoswipe-lightbox.esm.js'; 2 3function initPhotoSwipeForSliders() { 4 /** @type {NodeListOf<HTMLElement>} */ 5 const sliders = document.querySelectorAll('.slider-main[data-lightbox="true"]'); 6 sliders.forEach((sliderEl) => { 7 if (sliderEl.dataset.pswpInitialized === 'true') { 8 return; 9 } 10 11 // Slick creates clones; we only want real slides 12 const lightbox = new PhotoSwipeLightbox({ 13 gallery: sliderEl, 14 children: '.slick-slide:not(.slick-cloned) a.lightbox-link', 15 pswpModule: () => import('./photoswipe.esm.js') 16 }); 17 18 lightbox.init(); 19 sliderEl.dataset.pswpInitialized = 'true'; 20 }); 21} 22 23if (document.readyState === 'loading') { 24 document.addEventListener('DOMContentLoaded', initPhotoSwipeForSliders); 25} else { 26 initPhotoSwipeForSliders(); 27} 28 29// Support dynamic DOM insertions (Gutenberg / Ajax) 30if (window.MutationObserver) { 31 const observer = new MutationObserver(() => { 32 initPhotoSwipeForSliders(); 33 }); 34 if (document.body) { 35 observer.observe(document.body, { childList: true, subtree: true }); 36 } 37}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.