(function () { function initEventCarousel(carousel) { var slides = Array.prototype.slice.call(carousel.querySelectorAll('[data-event-slide]')); var dots = Array.prototype.slice.call(carousel.querySelectorAll('[data-event-dot]')); if (!slides.length || slides.length !== dots.length) return; function showSlide(index, focusDot) { slides.forEach(function (slide, slideIndex) { var isActive = slideIndex === index; slide.classList.toggle('active', isActive); slide.setAttribute('aria-hidden', isActive ? 'false' : 'true'); }); dots.forEach(function (dot, dotIndex) { var isActive = dotIndex === index; dot.classList.toggle('active', isActive); dot.setAttribute('aria-selected', isActive ? 'true' : 'false'); dot.setAttribute('tabindex', isActive ? '0' : '-1'); }); if (focusDot) dots[index].focus(); } dots.forEach(function (dot, index) { dot.addEventListener('click', function () { showSlide(index, false); }); dot.addEventListener('keydown', function (event) { var nextIndex = index; if (event.key === 'ArrowRight' || event.key === 'ArrowDown') nextIndex = (index + 1) % dots.length; if (event.key === 'ArrowLeft' || event.key === 'ArrowUp') nextIndex = (index - 1 + dots.length) % dots.length; if (event.key === 'Home') nextIndex = 0; if (event.key === 'End') nextIndex = dots.length - 1; if (nextIndex === index) return; event.preventDefault(); showSlide(nextIndex, true); }); }); showSlide(0, false); } document.querySelectorAll('[data-event-carousel]').forEach(initEventCarousel); function initCookieConsent() { var notice = document.querySelector('[data-cookie-notice]'); var form = document.querySelector('[data-cookie-consent-form]'); if (!notice || !form || !window.fetch) return; form.addEventListener('submit', function (event) { var button = form.querySelector('button[type="submit"]'); var returnField = form.querySelector('input[name="return_url"]'); var requestBody = 'action=accept&ajax=1&return_url=' + encodeURIComponent(window.location.href); event.preventDefault(); if (returnField) returnField.value = window.location.href; if (button) button.disabled = true; fetch(form.action, { method: 'POST', body: requestBody, credentials: 'same-origin', cache: 'no-store', headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'X-Requested-With': 'XMLHttpRequest' } }) .then(function (response) { if (!response.ok) throw new Error('Cookie consent request failed'); return response.json(); }) .then(function (result) { if (!result || result.ok !== true) throw new Error('Cookie consent was not saved'); notice.hidden = true; }) .catch(function () { form.submit(); }); }); } initCookieConsent(); }());