// Taj Mahal Photoshoot — site interactions (function () { 'use strict'; var WHATSAPP_NUMBER = '919528335646'; function buildWaLink(message) { return 'https://wa.me/' + WHATSAPP_NUMBER + '?text=' + encodeURIComponent(message); } // Expose for inline enquiry buttons that carry a data-message attribute. document.addEventListener('click', function (e) { var trigger = e.target.closest('[data-wa-message]'); if (!trigger) return; e.preventDefault(); window.open(buildWaLink(trigger.getAttribute('data-wa-message')), '_blank', 'noopener'); }); // Mobile nav var navToggle = document.querySelector('.nav-toggle'); var mobileNav = document.querySelector('.mobile-nav'); var navClose = document.querySelector('.mobile-nav-close'); var navCloseTimer = null; function openNav() { clearTimeout(navCloseTimer); mobileNav.style.display = 'flex'; // Force a reflow so the browser registers display:flex before the // transform transition starts (otherwise it jumps straight to open). void mobileNav.offsetHeight; mobileNav.classList.add('is-open'); document.body.style.overflow = 'hidden'; navToggle.setAttribute('aria-expanded', 'true'); } function closeNav() { mobileNav.classList.remove('is-open'); document.body.style.overflow = ''; navToggle.setAttribute('aria-expanded', 'false'); clearTimeout(navCloseTimer); navCloseTimer = setTimeout(function () { mobileNav.style.display = 'none'; }, 320); } if (navToggle && mobileNav) { navToggle.addEventListener('click', openNav); navClose.addEventListener('click', closeNav); mobileNav.querySelectorAll('a').forEach(function (a) { a.addEventListener('click', closeNav); }); document.addEventListener('keydown', function (e) { if (e.key === 'Escape') closeNav(); }); } // FAQ accordion document.querySelectorAll('.faq-q').forEach(function (btn) { btn.addEventListener('click', function () { var item = btn.closest('.faq-item'); var wasOpen = item.classList.contains('is-open'); item.parentElement.querySelectorAll('.faq-item').forEach(function (i) { i.classList.remove('is-open'); i.querySelector('.faq-q').setAttribute('aria-expanded', 'false'); }); if (!wasOpen) { item.classList.add('is-open'); btn.setAttribute('aria-expanded', 'true'); } }); }); // Reveal on scroll var revealEls = document.querySelectorAll('.reveal'); if ('IntersectionObserver' in window && revealEls.length) { var io = new IntersectionObserver( function (entries) { entries.forEach(function (entry) { if (entry.isIntersecting) { entry.target.classList.add('is-visible'); io.unobserve(entry.target); } }); }, { threshold: 0.12, rootMargin: '0px 0px -40px 0px' } ); revealEls.forEach(function (el) { io.observe(el); }); } else { revealEls.forEach(function (el) { el.classList.add('is-visible'); }); } // Contact / enquiry form -> WhatsApp var enquiryForm = document.getElementById('enquiry-form'); if (enquiryForm) { enquiryForm.addEventListener('submit', function (e) { e.preventDefault(); var data = new FormData(enquiryForm); var name = (data.get('name') || '').toString().trim(); var interest = (data.get('interest') || '').toString().trim(); var date = (data.get('date') || '').toString().trim(); var travellers = (data.get('travellers') || '').toString().trim(); var messageText = (data.get('message') || '').toString().trim(); var lines = ['Hello Taj Mahal Photoshoot, I would like to make an enquiry.']; if (name) lines.push('Name: ' + name); if (interest) lines.push('Interested in: ' + interest); if (date) lines.push('Preferred date: ' + date); if (travellers) lines.push('Travellers: ' + travellers); if (messageText) lines.push('Message: ' + messageText); window.open(buildWaLink(lines.join('\n')), '_blank', 'noopener'); }); } // Footer year var yearEl = document.getElementById('year'); if (yearEl) yearEl.textContent = new Date().getFullYear(); // Inject the shared Taj Mahal line-art motif into every placeholder // element without repeating the markup on every page. var iconTargets = document.querySelectorAll('[data-taj-icon]'); if (iconTargets.length) { fetch('assets/taj-motif.svg') .then(function (r) { return r.text(); }) .then(function (svgText) { var doc = new DOMParser().parseFromString(svgText, 'image/svg+xml'); var group = doc.querySelector('g'); if (!group) return; iconTargets.forEach(function (el) { el.appendChild(group.cloneNode(true)); }); }) .catch(function () { /* placeholders stay empty, e.g. under file:// */ }); } })();