| |
|
|
| document.addEventListener('DOMContentLoaded', () => { |
| |
| if (typeof lucide !== 'undefined') { |
| lucide.createIcons(); |
| } |
|
|
| |
| const mobileMenuBtn = document.querySelector('[onclick="toggleMobileMenu()"]'); |
| const mobileMenu = document.getElementById('mobileMenu'); |
| |
| if (mobileMenuBtn && mobileMenu) { |
| |
| document.addEventListener('click', (e) => { |
| if (!mobileMenu.contains(e.target) && !mobileMenuBtn.contains(e.target)) { |
| mobileMenu.classList.add('hidden'); |
| } |
| }); |
|
|
| |
| window.addEventListener('resize', () => { |
| if (window.innerWidth >= 768) { |
| mobileMenu.classList.add('hidden'); |
| } |
| }); |
| } |
|
|
| |
| let lastScroll = 0; |
| const navbar = document.getElementById('navbar'); |
| |
| window.addEventListener('scroll', () => { |
| const currentScroll = window.pageYOffset; |
| |
| |
| if (currentScroll > 50) { |
| navbar.classList.add('shadow-md'); |
| } else { |
| navbar.classList.remove('shadow-md'); |
| } |
| |
| |
| if (currentScroll > lastScroll && currentScroll > 100) { |
| navbar.style.transform = 'translateY(-100%)'; |
| } else { |
| navbar.style.transform = 'translateY(0)'; |
| } |
| |
| navbar.style.transition = 'transform 0.3s ease-in-out'; |
| lastScroll = currentScroll; |
| }); |
|
|
| |
| const observerOptions = { |
| root: null, |
| rootMargin: '0px', |
| threshold: 0.1 |
| }; |
|
|
| const fadeInObserver = new IntersectionObserver((entries) => { |
| entries.forEach(entry => { |
| if (entry.isIntersecting) { |
| entry.target.style.opacity = '1'; |
| entry.target.style.transform = 'translateY(0)'; |
| |
| |
| const staggerContainer = entry.target.querySelector('.stagger-children'); |
| if (staggerContainer) { |
| staggerContainer.classList.add('animate'); |
| } |
| |
| fadeInObserver.unobserve(entry.target); |
| } |
| }); |
| }, observerOptions); |
|
|
| |
| document.querySelectorAll('.card-hover, .process-step, .testimonial-card').forEach(el => { |
| el.style.opacity = '0'; |
| el.style.transform = 'translateY(20px)'; |
| el.style.transition = 'opacity 0.6s ease-out, transform 0.6s ease-out'; |
| fadeInObserver.observe(el); |
| }); |
|
|
| |
| const contactForm = document.getElementById('contactForm'); |
| if (contactForm) { |
| contactForm.addEventListener('submit', handleFormSubmit); |
| } |
|
|
| |
| const destinationSelect = document.querySelector('select'); |
| if (destinationSelect) { |
| destinationSelect.addEventListener('change', function() { |
| if (this.value && this.value !== 'Select a destination type') { |
| this.classList.add('text-gray-900'); |
| } |
| }); |
| } |
|
|
| |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { |
| anchor.addEventListener('click', function (e) { |
| e.preventDefault(); |
| const targetId = this.getAttribute('href'); |
| const targetElement = document.querySelector(targetId); |
| |
| if (targetElement) { |
| const headerOffset = 80; |
| const elementPosition = targetElement.getBoundingClientRect().top; |
| const offsetPosition = elementPosition + window.pageYOffset - headerOffset; |
| |
| window.scrollTo({ |
| top: offsetPosition, |
| behavior: 'smooth' |
| }); |
| |
| |
| if (mobileMenu && !mobileMenu.classList.contains('hidden')) { |
| mobileMenu.classList.add('hidden'); |
| } |
| } |
| }); |
| }); |
|
|
| |
| const imageObserver = new IntersectionObserver((entries, observer) => { |
| entries.forEach(entry => { |
| if (entry.isIntersecting) { |
| const img = entry.target; |
| if (img.dataset.src) { |
| img.src = img.dataset.src; |
| img.removeAttribute('data-src'); |
| img.addEventListener('load', () => { |
| img.style.opacity = '1'; |
| }); |
| } |
| observer.unobserve(img); |
| } |
| }); |
| }); |
|
|
| document.querySelectorAll('img[data-src]').forEach(img => { |
| img.style.opacity = '0'; |
| img.style.transition = 'opacity 0.3s'; |
| imageObserver.observe(img); |
| }); |
|
|
| |
| const sections = document.querySelectorAll('section[id]'); |
| const navLinks = document.querySelectorAll('nav a[href^="#"]'); |
|
|
| window.addEventListener('scroll', () => { |
| let current = ''; |
| sections.forEach(section => { |
| const sectionTop = section.offsetTop; |
| const sectionHeight = section.clientHeight; |
| if (pageYOffset >= sectionTop - 200) { |
| current = section.getAttribute('id'); |
| } |
| }); |
|
|
| navLinks.forEach(link => { |
| link.classList.remove('text-primary'); |
| link.classList.add('text-gray-600'); |
| if (link.getAttribute('href') === `#${current}`) { |
| link.classList.remove('text-gray-600'); |
| link.classList.add('text-primary'); |
| } |
| }); |
| }); |
|
|
| |
| let currentTestimonial = 0; |
| const testimonials = document.querySelectorAll('.testimonial-card'); |
| |
| if (testimonials.length > 3) { |
| setInterval(() => { |
| testimonials.forEach((t, index) => { |
| if (index === currentTestimonial) { |
| t.style.transform = 'scale(1.05)'; |
| t.style.opacity = '1'; |
| } else { |
| t.style.transform = 'scale(1)'; |
| t.style.opacity = '0.7'; |
| } |
| }); |
| currentTestimonial = (currentTestimonial + 1) % testimonials.length; |
| }, 5000); |
| } |
|
|
| console.log('Mobile Travel Agent Profile loaded successfully'); |
| }); |
|
|
| |
| function handleFormSubmit(e) { |
| e.preventDefault(); |
| |
| const form = e.target; |
| const submitBtn = form.querySelector('button[type="submit"]'); |
| const originalText = submitBtn.innerHTML; |
| |
| |
| submitBtn.disabled = true; |
| submitBtn.innerHTML = '<span class="flex items-center justify-center"><svg class="animate-spin -ml-1 mr-3 h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>Sending...</span>'; |
| |
| setTimeout(() => { |
| |
| submitBtn.classList.remove('bg-primary', 'hover:bg-teal-700'); |
| submitBtn.classList.add('bg-green-600'); |
| submitBtn.innerHTML = '<span class="flex items-center justify-center"><i data-lucide="check-circle" class="w-5 h-5 mr-2"></i>Message Sent!</span>'; |
| |
| if (typeof lucide !== 'undefined') { |
| lucide.createIcons(); |
| } |
| |
| |
| setTimeout(() => { |
| form.reset(); |
| submitBtn.disabled = false; |
| submitBtn.classList.remove('bg-green-600'); |
| submitBtn.classList.add('bg-primary', 'hover:bg-teal-700'); |
| submitBtn.innerHTML = originalText; |
| |
| if (typeof lucide !== 'undefined') { |
| lucide.createIcons(); |
| } |
| }, 3000); |
| }, 1500); |
| } |
|
|
| |
| function debounce(func, wait) { |
| let timeout; |
| return function executedFunction(...args) { |
| const later = () => { |
| clearTimeout(timeout); |
| func(...args); |
| }; |
| clearTimeout(timeout); |
| timeout = setTimeout(later, wait); |
| }; |
| } |
|
|
| |
| const handleResize = debounce(() => { |
| |
| console.log('Window resized, layouts adjusted'); |
| }, 250); |
|
|
| window.addEventListener('resize', handleResize); |