/**
* Photo Gallery & Lightbox
* Airbnb-style photo gallery with fullscreen lightbox viewer
*/
class PhotoGallery {
constructor() {
this.photos = [];
this.currentIndex = 0;
this.lightbox = null;
this.isOpen = false;
this.init();
}
init() {
// Collect all gallery photos
const galleryItems = document.querySelectorAll('.photo-gallery .photo-item img');
galleryItems.forEach((img, index) => {
this.photos.push({
src: img.src,
alt: img.alt || `Photo ${index + 1}`
});
});
// Create lightbox DOM
this.createLightbox();
// Attach click events to gallery - redirect to photo tour page
const gallery = document.querySelector('.photo-gallery');
if (gallery) {
gallery.addEventListener('click', (e) => {
const photoItem = e.target.closest('.photo-item');
if (photoItem) {
window.location.href = 'photos.php';
}
});
}
// Keyboard navigation
document.addEventListener('keydown', (e) => {
if (!this.isOpen) return;
switch (e.key) {
case 'Escape':
this.close();
break;
case 'ArrowLeft':
this.prev();
break;
case 'ArrowRight':
this.next();
break;
}
});
}
createLightbox() {
this.lightbox = document.createElement('div');
this.lightbox.className = 'lightbox-overlay';
this.lightbox.innerHTML = `