1(function () { 2 'use strict'; 3 4 var AUTOPLAY_MS = 5000; 5 var INDEX_ATTR = 'data-i-event-slider-index'; 6 var NO_TRANSITION = 'i_event-slider--no-transition'; 7 8 function stripIds(node) { 9 node.removeAttribute('id'); 10 Array.prototype.forEach.call(node.querySelectorAll('[id]'), function (el) { 11 el.removeAttribute('id'); 12 }); 13 } 14 15 function cloneSlide(slide) { 16 var clone = slide.cloneNode(true); 17 stripIds(clone); 18 clone.setAttribute('aria-hidden', 'true'); 19 clone.setAttribute('aria-roledescription', 'slide'); 20 return clone; 21 } 22 23 function initSlider(root) { 24 var track = root.querySelector('.i_event-slider__track'); 25 var realSlides = Array.prototype.slice.call(root.querySelectorAll('.i_event-slider__slide')); 26 var dotsRoot = root.querySelector('.i_event-slider__dots'); 27 if (!track || !dotsRoot || realSlides.length === 0) { 28 return; 29 } 30 31 var realCount = realSlides.length; 32 var multi = realCount > 1; 33 var reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches; 34 var canHover = window.matchMedia('(hover: hover) and (pointer: fine)').matches; 35 var timer = null; 36 var animating = false; 37 // With clones: [cloneLast, ...reals, cloneFirst] â start on first real (= 1) 38 var trackIndex = multi ? 1 : 0; 39 40 if (multi) { 41 track.insertBefore(cloneSlide(realSlides[realCount - 1]), realSlides[0]); 42 track.appendChild(cloneSlide(realSlides[0])); 43 } 44 45 dotsRoot.replaceChildren(); 46 realSlides.forEach(function (_slide, i) { 47 var btn = document.createElement('button'); 48 btn.type = 'button'; 49 btn.className = 'i_event-slider__dot' + (i === 0 ? ' i_event-slider__dot--active' : ''); 50 btn.setAttribute('aria-label', 'Slide ' + (i + 1)); 51 btn.addEventListener('click', function () { 52 goToReal(i, true); 53 }); 54 dotsRoot.appendChild(btn); 55 }); 56 57 if (!multi) { 58 dotsRoot.hidden = true; 59 } 60 61 root.setAttribute(INDEX_ATTR, String(trackIndex)); 62 63 function realIndexFromTrack(ti) { 64 if (!multi) { 65 return 0; 66 } 67 if (ti === 0) { 68 return realCount - 1; 69 } 70 if (ti === realCount + 1) { 71 return 0; 72 } 73 return ti - 1; 74 } 75 76 function updateDots() { 77 var real = realIndexFromTrack(trackIndex); 78 var dots = dotsRoot.querySelectorAll('.i_event-slider__dot'); 79 Array.prototype.forEach.call(dots, function (dot, i) { 80 dot.classList.toggle('i_event-slider__dot--active', i === real); 81 }); 82 } 83 84 function snapTo(ti) { 85 root.classList.add(NO_TRANSITION); 86 trackIndex = ti; 87 root.setAttribute(INDEX_ATTR, String(trackIndex)); 88 // Force reflow so the next transition is not skipped 89 void track.offsetWidth; 90 root.classList.remove(NO_TRANSITION); 91 updateDots(); 92 animating = false; 93 } 94 95 function onTransitionEnd(event) { 96 if (event.target !== track || event.propertyName !== 'transform') { 97 return; 98 } 99 if (trackIndex === realCount + 1) { 100 snapTo(1); 101 return; 102 } 103 if (trackIndex === 0) { 104 snapTo(realCount); 105 return; 106 } 107 animating = false; 108 } 109 110 function setTrackIndex(ti) { 111 animating = true; 112 trackIndex = ti; 113 root.setAttribute(INDEX_ATTR, String(trackIndex)); 114 updateDots(); 115 if (reduceMotion) { 116 if (trackIndex === realCount + 1) { 117 snapTo(1); 118 } else if (trackIndex === 0) { 119 snapTo(realCount); 120 } else { 121 animating = false; 122 } 123 } 124 } 125 126 function goToReal(realIndex, fromUser) { 127 if (!multi || animating) { 128 return; 129 } 130 setTrackIndex(realIndex + 1); 131 if (fromUser) { 132 restartTimer(); 133 } 134 } 135 136 function next() { 137 if (!multi || animating) { 138 return; 139 } 140 setTrackIndex(trackIndex + 1); 141 } 142 143 function stopTimer() { 144 if (timer) { 145 window.clearInterval(timer); 146 timer = null; 147 } 148 } 149 150 function restartTimer() { 151 stopTimer(); 152 if (!multi || reduceMotion) { 153 return; 154 } 155 timer = window.setInterval(next, AUTOPLAY_MS); 156 } 157 158 if (multi) { 159 track.addEventListener('transitionend', onTransitionEnd); 160 } 161 162 if (canHover && multi) { 163 root.addEventListener('pointerenter', stopTimer); 164 root.addEventListener('pointerleave', restartTimer); 165 } 166 167 restartTimer(); 168 } 169 170 function boot() { 171 document.querySelectorAll('[data-i-event-slider]').forEach(initSlider); 172 } 173 174 if (document.readyState === 'loading') { 175 document.addEventListener('DOMContentLoaded', boot); 176 } else { 177 boot(); 178 } 179})();
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.