73 lines
2.8 KiB
JavaScript
73 lines
2.8 KiB
JavaScript
/* ── NAV TOGGLE ─────────────────────────────────────── */
|
|
(function () {
|
|
const nav = document.querySelector('.nav');
|
|
const toggle = document.querySelector('.nav-toggle');
|
|
if (!toggle) return;
|
|
toggle.addEventListener('click', () => {
|
|
const open = nav.classList.toggle('menu-open');
|
|
toggle.setAttribute('aria-expanded', open);
|
|
});
|
|
document.addEventListener('click', (e) => {
|
|
if (!nav.contains(e.target)) {
|
|
nav.classList.remove('menu-open');
|
|
toggle.setAttribute('aria-expanded', 'false');
|
|
}
|
|
});
|
|
})();
|
|
|
|
/* ── EVENT CARDS ─────────────────────────────────────── */
|
|
(function () {
|
|
document.querySelectorAll('.event-summary').forEach((summary) => {
|
|
summary.addEventListener('click', () => {
|
|
const card = summary.closest('.event-card');
|
|
const isOpen = card.classList.contains('open');
|
|
// close all
|
|
document.querySelectorAll('.event-card.open').forEach(c => c.classList.remove('open'));
|
|
if (!isOpen) card.classList.add('open');
|
|
});
|
|
});
|
|
})();
|
|
|
|
/* ── BOOKING FORMS ───────────────────────────────────── */
|
|
(function () {
|
|
document.querySelectorAll('.booking-form').forEach((form) => {
|
|
form.addEventListener('submit', (e) => {
|
|
e.preventDefault();
|
|
const card = form.closest('.form-card');
|
|
const success = card.querySelector('.form-success');
|
|
if (!success) return;
|
|
form.style.display = 'none';
|
|
success.style.display = 'block';
|
|
});
|
|
});
|
|
})();
|
|
|
|
/* ── DATE → TIME DEPENDENCY ──────────────────────────── */
|
|
(function () {
|
|
document.querySelectorAll('input[type="date"]').forEach((dateInput) => {
|
|
const form = dateInput.closest('form');
|
|
if (!form) return;
|
|
const timeSelect = form.querySelector('select[name="time"]');
|
|
if (!timeSelect) return;
|
|
dateInput.addEventListener('change', () => {
|
|
timeSelect.disabled = !dateInput.value;
|
|
if (!dateInput.value) {
|
|
timeSelect.value = '';
|
|
timeSelect.querySelector('option[value=""]').textContent = 'Pick a date first';
|
|
} else {
|
|
timeSelect.querySelector('option[value=""]').textContent = 'Select a time';
|
|
}
|
|
});
|
|
});
|
|
})();
|
|
|
|
/* ── MARK CURRENT NAV LINK ───────────────────────────── */
|
|
(function () {
|
|
const path = window.location.pathname.replace(/\/$/, '') || '/';
|
|
document.querySelectorAll('.nav-links a').forEach((a) => {
|
|
const href = a.getAttribute('href').replace(/\/$/, '') || '/';
|
|
if (path === href || (href !== '/' && path.startsWith(href))) {
|
|
a.setAttribute('aria-current', 'page');
|
|
}
|
|
});
|
|
})();
|