-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
1 lines (1 loc) · 3.54 KB
/
script.js
File metadata and controls
1 lines (1 loc) · 3.54 KB
1
document.addEventListener('DOMContentLoaded',function(){const header=document.querySelector('.header');const navLinks=document.querySelectorAll('.nav a');const experienceCards=document.querySelectorAll('.experience-card');const menuItems=document.querySelectorAll('.menu-item');const galleryItems=document.querySelectorAll('.gallery-item');const contactForm=document.getElementById('contactForm');const formMessage=document.getElementById('formMessage');let lastScrollTop=0;window.addEventListener('scroll',function(){let scrollTop=window.pageYOffset||document.documentElement.scrollTop;if(scrollTop>100){header.style.padding='1rem 0';}else{header.style.padding='1.5rem 0';}lastScrollTop=scrollTop;});navLinks.forEach(link=>{link.addEventListener('click',function(e){e.preventDefault();const targetId=this.getAttribute('href');const targetSection=document.querySelector(targetId);if(targetSection){const headerHeight=header.offsetHeight;const targetPosition=targetSection.getBoundingClientRect().top+window.pageYOffset-headerHeight;window.scrollTo({top:targetPosition,behavior:'smooth'});}});});const observerOptions={threshold:0.1,rootMargin:'0px 0px -100px 0px'};const observer=new IntersectionObserver(function(entries){entries.forEach(entry=>{if(entry.isIntersecting){entry.target.style.opacity='1';entry.target.style.transform='translateY(0)';observer.unobserve(entry.target);}});},observerOptions);experienceCards.forEach((card,index)=>{card.style.opacity='0';card.style.transform='translateY(30px)';card.style.transition=`all 0.6s ease ${index*0.1}s`;observer.observe(card);});menuItems.forEach((item,index)=>{item.style.opacity='0';item.style.transform='translateX(-30px)';item.style.transition=`all 0.6s ease ${index*0.05}s`;observer.observe(item);});galleryItems.forEach((item,index)=>{item.style.opacity='0';item.style.transform='scale(0.95)';item.style.transition=`all 0.6s ease ${index*0.1}s`;observer.observe(item);});if(contactForm){contactForm.addEventListener('submit',async function(e){e.preventDefault();formMessage.classList.remove('success','error');formMessage.style.display='none';const submitButton=contactForm.querySelector('button[type="submit"]');const originalButtonText=submitButton.textContent;submitButton.textContent='Sending...';submitButton.disabled=true;const formData={name:document.getElementById('name').value,email:document.getElementById('email').value,phone:document.getElementById('phone').value,message:document.getElementById('message').value};const apiConfig={"endpoint":"http://landing-hub.local:3000/send_contact_mailer","method":"POST","body":{"client_id":2,"briefing_id":6,"token":"IEcaJpI13jR8JKu7dpLxehLL7dwCjwvmF48IRwmMCWI"}};try{const response=await fetch(apiConfig.endpoint,{method:apiConfig.method,headers:{'Content-Type':'application/json'},body:JSON.stringify({...apiConfig.body,...formData})});if(response.ok){formMessage.textContent='Thank you for your reservation request. We will contact you shortly.';formMessage.classList.add('success');contactForm.reset();}else{throw new Error('Submission failed');}}catch(error){formMessage.textContent='There was an error sending your message. Please try again or contact us directly.';formMessage.classList.add('error');}finally{submitButton.textContent=originalButtonText;submitButton.disabled=false;}});}const style=document.createElement('style');style.textContent=`@media (prefers-reduced-motion: reduce) {*,*::before,*::after {animation-duration: 0.01ms !important;animation-iteration-count: 1 !important;transition-duration: 0.01ms !important;scroll-behavior: auto !important;}}`;document.head.appendChild(style);});