/** * Theme "Ostsee-Licht": small progressive enhancements. Everything works without JavaScript. */ // Lightbox for galleries: links with data-lightbox open the large image in a . document.addEventListener('click', (event) => { const link = event.target.closest('a[data-lightbox]'); if (!link) { return; } const dialog = document.getElementById('lightbox'); if (!dialog || typeof dialog.showModal !== 'function') { return; } event.preventDefault(); const image = dialog.querySelector('img'); image.src = link.href; image.alt = link.dataset.alt ?? ''; dialog.querySelector('[data-caption]').textContent = link.dataset.alt ?? ''; dialog.showModal(); }); document.addEventListener('click', (event) => { const dialog = event.target.closest('dialog#lightbox'); if (dialog && (event.target === dialog || event.target.closest('[data-close]'))) { dialog.close(); } }); // Availability search in the hero: forwards the dates to the booking page. document.addEventListener('submit', (event) => { const form = event.target.closest('form[data-availability-search]'); if (!form) { return; } const arrival = form.querySelector('[name=anreise]').value; const departure = form.querySelector('[name=abreise]').value; if (!arrival || !departure) { event.preventDefault(); form.querySelector('[name=anreise]').focus(); } });