// ---------- nav toggle ---------- const navToggle = document.getElementById("navToggle"); const navLinks = document.getElementById("navLinks"); navToggle.addEventListener("click", () => { const isOpen = navLinks.classList.toggle("open"); navToggle.setAttribute("aria-expanded", String(isOpen)); }); navLinks.querySelectorAll("a").forEach(a => a.addEventListener("click", () => { navLinks.classList.remove("open"); navToggle.setAttribute("aria-expanded", "false"); })); // ---------- build hotel gallery ---------- const galleryEl = document.getElementById("galleryGrid"); HOTEL_GALLERY.forEach((src, i) => { const item = document.createElement("button"); item.type = "button"; item.className = "gallery-item"; item.dataset.i = i; item.setAttribute("aria-label", `View gallery photo ${i + 1}`); item.innerHTML = `The Hub Hotel — photo ${i + 1}`; item.addEventListener("click", () => openGallery(i)); galleryEl.appendChild(item); }); // ---------- lightbox ---------- const lightbox = document.getElementById("lightbox"); const lightboxImg = document.getElementById("lightboxImg"); const lightboxThumbs = document.getElementById("lightboxThumbs"); const lightboxPrev = document.getElementById("lightboxPrev"); const lightboxNext = document.getElementById("lightboxNext"); const lightboxClose = document.getElementById("lightboxClose"); const pageWrap = document.getElementById("pageWrap"); let lbIndex = 0; function renderLightbox(){ lightboxImg.src = HOTEL_GALLERY[lbIndex]; lightboxImg.alt = `Hotel photo ${lbIndex + 1} of ${HOTEL_GALLERY.length}`; lightboxThumbs.querySelectorAll("button").forEach((t, i) => t.classList.toggle("active", i === lbIndex)); } function openGallery(startIndex){ lbIndex = startIndex || 0; lightboxThumbs.innerHTML = HOTEL_GALLERY.map((src, i) => `` ).join(""); lightboxThumbs.querySelectorAll("button").forEach(t => t.addEventListener("click", () => { lbIndex = Number(t.dataset.i); renderLightbox(); }) ); renderLightbox(); lightbox.classList.add("open"); pageWrap.classList.add("blurred"); document.body.style.overflow = "hidden"; } function closeLightbox(){ lightbox.classList.remove("open"); pageWrap.classList.remove("blurred"); document.body.style.overflow = ""; } function lbStep(dir){ lbIndex = (lbIndex + dir + HOTEL_GALLERY.length) % HOTEL_GALLERY.length; renderLightbox(); } lightboxPrev.addEventListener("click", () => lbStep(-1)); lightboxNext.addEventListener("click", () => lbStep(1)); lightboxClose.addEventListener("click", closeLightbox); lightbox.addEventListener("click", e => { if (e.target === lightbox) closeLightbox(); }); document.addEventListener("keydown", e => { if (!lightbox.classList.contains("open")) return; if (e.key === "Escape") closeLightbox(); if (e.key === "ArrowLeft") lbStep(-1); if (e.key === "ArrowRight") lbStep(1); });