// Intersection Observer for reveal animations let revealObserver; function handleReveal(entries) { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('visible'); } }); } // Smooth scroll to map function function scrollToMap() { const mapSection = document.getElementById('sv0jjq'); if (mapSection) { mapSection.scrollIntoView({ behavior: 'smooth', block: 'start' }); } } // Merchant modal functions function openMerchantModal() { const modal = document.getElementById('merchant-signup'); if (modal) { modal.style.display = 'flex'; // Small delay to ensure display is set before animations setTimeout(() => { modal.classList.remove('opacity-0', 'invisible'); modal.classList.add('opacity-100', 'visible'); const modalContent = modal.querySelector('.transform'); if (modalContent) { modalContent.classList.remove('scale-95'); modalContent.classList.add('scale-100'); } }, 10); document.body.style.overflow = 'hidden'; } } function closeMerchantModal() { const modal = document.getElementById('merchant-signup'); if (modal) { modal.classList.add('opacity-0', 'invisible'); modal.classList.remove('opacity-100', 'visible'); const modalContent = modal.querySelector('.transform'); if (modalContent) { modalContent.classList.add('scale-95'); modalContent.classList.remove('scale-100'); } // Hide with delay to allow animation setTimeout(() => { modal.style.display = 'none'; }, 300); document.body.style.overflow = ''; } } // Handle merchant signup clicks function handleMerchantSignupClick(event) { event.preventDefault(); openMerchantModal(); } // Handle modal backdrop clicks function handleModalBackdropClick(event) { if (event.target === event.currentTarget) { closeMerchantModal(); } } // Handle escape key function handleEscapeKey(event) { if (event.key === 'Escape') { closeMerchantModal(); } } function init() { // Initialize Intersection Observer for reveal animations revealObserver = new IntersectionObserver(handleReveal, { threshold: 0.12, rootMargin: '0px 0px -50px 0px' }); // Observe all reveal elements document.querySelectorAll('.reveal').forEach(el => { revealObserver.observe(el); }); // Set current year in footer if element exists const yearElement = document.getElementById('y'); if (yearElement) { yearElement.textContent = new Date().getFullYear(); } // Ensure modal is hidden on load const modal = document.getElementById('merchant-signup'); if (modal) { modal.style.display = 'none'; modal.classList.add('opacity-0', 'invisible'); } // Add merchant signup modal functionality const merchantSignupLinks = document.querySelectorAll('a[href="#merchant-signup"]'); merchantSignupLinks.forEach(link => { link.addEventListener('click', handleMerchantSignupClick); }); // Add modal backdrop click listener if (modal) { modal.addEventListener('click', handleModalBackdropClick); } // Add escape key listener document.addEventListener('keydown', handleEscapeKey); // Make functions globally available for onclick handlers window.closeMerchantModal = closeMerchantModal; window.openMerchantModal = openMerchantModal; window.scrollToMap = scrollToMap; } function teardown() { // Clean up observer if (revealObserver) { revealObserver.disconnect(); revealObserver = null; } // Remove event listeners const merchantSignupLinks = document.querySelectorAll('a[href="#merchant-signup"]'); merchantSignupLinks.forEach(link => { link.removeEventListener('click', handleMerchantSignupClick); }); const modal = document.getElementById('merchant-signup'); if (modal) { modal.removeEventListener('click', handleModalBackdropClick); } document.removeEventListener('keydown', handleEscapeKey); // Clean up global functions if (window.closeMerchantModal) { delete window.closeMerchantModal; } if (window.openMerchantModal) { delete window.openMerchantModal; } if (window.scrollToMap) { delete window.scrollToMap; } } // Export functions for the landing site system export { init, teardown };