|
| 1 | +// script.js - Enhanced functionality |
| 2 | + |
| 3 | +document.addEventListener('DOMContentLoaded', function() { |
| 4 | + // Model tabs functionality |
| 5 | + const modelTabs = document.querySelectorAll('.model-tab'); |
| 6 | + const modelContents = document.querySelectorAll('.model-content'); |
| 7 | + |
| 8 | + modelTabs.forEach(tab => { |
| 9 | + tab.addEventListener('click', function() { |
| 10 | + const modelId = this.getAttribute('data-model'); |
| 11 | + |
| 12 | + // Remove active class from all tabs and contents |
| 13 | + modelTabs.forEach(t => t.classList.remove('active')); |
| 14 | + modelContents.forEach(c => c.classList.remove('active')); |
| 15 | + |
| 16 | + // Add active class to clicked tab |
| 17 | + this.classList.add('active'); |
| 18 | + |
| 19 | + // Show corresponding content |
| 20 | + const contentId = modelId + '-model'; |
| 21 | + const activeContent = document.getElementById(contentId); |
| 22 | + if (activeContent) { |
| 23 | + activeContent.classList.add('active'); |
| 24 | + } |
| 25 | + }); |
| 26 | + }); |
| 27 | + |
| 28 | + // Add fade-in animations on scroll |
| 29 | + const observerOptions = { |
| 30 | + root: null, |
| 31 | + rootMargin: '0px', |
| 32 | + threshold: 0.1 |
| 33 | + }; |
| 34 | + |
| 35 | + const observer = new IntersectionObserver((entries) => { |
| 36 | + entries.forEach(entry => { |
| 37 | + if (entry.isIntersecting) { |
| 38 | + entry.target.classList.add('fade-in-up'); |
| 39 | + } |
| 40 | + }); |
| 41 | + }, observerOptions); |
| 42 | + |
| 43 | + // Observe all sections for animation |
| 44 | + document.querySelectorAll('section').forEach(section => { |
| 45 | + observer.observe(section); |
| 46 | + }); |
| 47 | + |
| 48 | + // Form submission handling |
| 49 | + const contactForm = document.getElementById('contact-form'); |
| 50 | + if (contactForm) { |
| 51 | + contactForm.addEventListener('submit', function(e) { |
| 52 | + e.preventDefault(); |
| 53 | + |
| 54 | + // Get form data |
| 55 | + const formData = new FormData(this); |
| 56 | + const data = Object.fromEntries(formData); |
| 57 | + |
| 58 | + // Here you would typically send the data to a server |
| 59 | + console.log('Form submitted:', data); |
| 60 | + |
| 61 | + // Show success message |
| 62 | + alert('Thank you for your message! We will get back to you soon.'); |
| 63 | + this.reset(); |
| 64 | + }); |
| 65 | + } |
| 66 | +}); |
0 commit comments