// Simple global lightbox functionality
function openSimpleLightbox(imageSrc, imageAlt) {
// Remove existing lightbox if present
const existing = document.getElementById('simple-lightbox');
if (existing) {
existing.remove();
}
// Create lightbox HTML
const lightboxHTML = `
`;
// Add to body
document.body.insertAdjacentHTML('beforeend', lightboxHTML);
// Prevent body scroll
document.body.style.overflow = 'hidden';
// Close on background click
const lightbox = document.getElementById('simple-lightbox');
lightbox.addEventListener('click', function(e) {
if (e.target === lightbox) {
closeSimpleLightbox();
}
});
// Close on Escape key
function handleEscape(e) {
if (e.key === 'Escape') {
closeSimpleLightbox();
document.removeEventListener('keydown', handleEscape);
}
}
document.addEventListener('keydown', handleEscape);
}
function closeSimpleLightbox() {
const lightbox = document.getElementById('simple-lightbox');
if (lightbox) {
lightbox.remove();
}
document.body.style.overflow = '';
}
// Make functions globally available
window.openSimpleLightbox = openSimpleLightbox;
window.closeSimpleLightbox = closeSimpleLightbox;
// Export for the system
export function init() {
// Functions are already global, nothing needed here
}
export function teardown() {
// Clean up if needed
const lightbox = document.getElementById('simple-lightbox');
if (lightbox) {
lightbox.remove();
}
document.body.style.overflow = '';
}