1(function () { 2 var SWIPE_THRESHOLD_PX = 40; 3 var savedScrollY = 0; 4 var scrollLockActive = false; 5 var scrollFixBound = false; 6 7 function goToSlide(gallery, index) { 8 var mainSlides = gallery.querySelectorAll('.rel .slides > li'); 9 var minLinks = gallery.querySelectorAll('.mins .min'); 10 var total = mainSlides.length; 11 12 if (!total) { 13 return; 14 } 15 16 var nextIndex = index; 17 if (nextIndex < 0) { 18 nextIndex = total - 1; 19 } else if (nextIndex >= total) { 20 nextIndex = 0; 21 } 22 23 mainSlides.forEach(function (slide, slideIndex) { 24 var active = slideIndex === nextIndex; 25 slide.classList.toggle('flex-active-slide', active); 26 slide.hidden = !active; 27 }); 28 29 minLinks.forEach(function (minLink, minIndex) { 30 minLink.classList.toggle('flex-active-slide', minIndex === nextIndex); 31 }); 32 33 gallery.dataset.currentIndex = String(nextIndex); 34 } 35 36 function getCurrentIndex(gallery) { 37 return Number(gallery.dataset.currentIndex || '0'); 38 } 39 40 function bindGallery(gallery) { 41 if (gallery.dataset.bound === '1') { 42 return; 43 } 44 gallery.dataset.bound = '1'; 45 46 var mainSlides = gallery.querySelectorAll('.rel .slides > li'); 47 var total = mainSlides.length; 48 if (!total) { 49 return; 50 } 51 52 gallery.dataset.currentIndex = '0'; 53 54 gallery.querySelectorAll('.mins .min').forEach(function (link) { 55 link.addEventListener('click', function (event) { 56 event.preventDefault(); 57 goToSlide(gallery, Number(link.getAttribute('data-gallery-index') || '0')); 58 }); 59 }); 60 61 var prevBtn = gallery.querySelector('.flex-prev'); 62 if (prevBtn) { 63 prevBtn.addEventListener('click', function (event) { 64 event.preventDefault(); 65 goToSlide(gallery, getCurrentIndex(gallery) - 1); 66 }); 67 } 68 69 var nextBtn = gallery.querySelector('.flex-next'); 70 if (nextBtn) { 71 nextBtn.addEventListener('click', function (event) { 72 event.preventDefault(); 73 goToSlide(gallery, getCurrentIndex(gallery) + 1); 74 }); 75 } 76 77 if (total < 2) { 78 return; 79 } 80 81 var rel = gallery.querySelector('.rel'); 82 if (!rel) { 83 return; 84 } 85 86 var startX = 0; 87 rel.addEventListener( 88 'touchstart', 89 function (event) { 90 if (event.touches.length !== 1) { 91 return; 92 } 93 startX = event.touches[0].screenX; 94 }, 95 { passive: true }, 96 ); 97 98 rel.addEventListener( 99 'touchend', 100 function (event) { 101 if (event.changedTouches.length !== 1) { 102 return; 103 } 104 105 var diff = event.changedTouches[0].screenX - startX; 106 if (Math.abs(diff) < SWIPE_THRESHOLD_PX) { 107 return; 108 } 109 110 var current = getCurrentIndex(gallery); 111 if (diff < 0) { 112 goToSlide(gallery, current + 1); 113 } else { 114 goToSlide(gallery, current - 1); 115 } 116 }, 117 { passive: true }, 118 ); 119 } 120 121 function initNewsGalleries() { 122 document.querySelectorAll('[data-news-gallery]').forEach(bindGallery); 123 } 124 125 function refreshNewsLightbox() { 126 if (typeof window.refreshFsLightbox === 'function') { 127 window.refreshFsLightbox(); 128 } 129 } 130 131 function getScrollY() { 132 return window.scrollY || document.documentElement.scrollTop || 0; 133 } 134 135 function lockPageScroll() { 136 if (scrollLockActive) { 137 return; 138 } 139 140 scrollLockActive = true; 141 document.body.style.position = 'fixed'; 142 document.body.style.top = '-' + savedScrollY + 'px'; 143 document.body.style.left = '0'; 144 document.body.style.right = '0'; 145 document.body.style.width = '100%'; 146 } 147 148 function unlockPageScroll() { 149 if (!scrollLockActive) { 150 return; 151 } 152 153 scrollLockActive = false; 154 document.body.style.removeProperty('position'); 155 document.body.style.removeProperty('top'); 156 document.body.style.removeProperty('left'); 157 document.body.style.removeProperty('right'); 158 document.body.style.removeProperty('width'); 159 window.scrollTo(0, savedScrollY); 160 } 161 162 function bindLightboxScrollFix() { 163 if (scrollFixBound) { 164 return; 165 } 166 scrollFixBound = true; 167 168 document.addEventListener( 169 'click', 170 function (event) { 171 var target = event.target; 172 if (!target || typeof target.closest !== 'function') { 173 return; 174 } 175 176 var link = target.closest('a[data-fslightbox]'); 177 if (!link) { 178 return; 179 } 180 181 savedScrollY = getScrollY(); 182 }, 183 true, 184 ); 185 186 var observer = new MutationObserver(function () { 187 if (document.documentElement.classList.contains('fslightbox-open')) { 188 lockPageScroll(); 189 return; 190 } 191 192 unlockPageScroll(); 193 }); 194 195 observer.observe(document.documentElement, { 196 attributes: true, 197 attributeFilter: ['class'], 198 }); 199 } 200 201 window.initNewsGalleries = initNewsGalleries; 202 window.refreshNewsLightbox = refreshNewsLightbox; 203 204 document.addEventListener('DOMContentLoaded', function () { 205 initNewsGalleries(); 206 refreshNewsLightbox(); 207 bindLightboxScrollFix(); 208 }); 209})();
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.