Spaces:
Running
Running
| // Main JavaScript file for global functionality | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Mobile menu toggle functionality | |
| document.addEventListener('click', function(e) { | |
| if (e.target.closest('.mobile-menu-button')) { | |
| const navbar = document.querySelector('custom-navbar'); | |
| const shadowRoot = navbar.shadowRoot; | |
| const navLinks = shadowRoot.querySelector('.nav-links'); | |
| if (navLinks.style.display === 'flex') { | |
| navLinks.style.display = 'none'; | |
| } else { | |
| navLinks.style.display = 'flex'; | |
| navLinks.style.flexDirection = 'column'; | |
| navLinks.style.position = 'absolute'; | |
| navLinks.style.top = '100%'; | |
| navLinks.style.left = '0'; | |
| navLinks.style.right = '0'; | |
| navLinks.style.backgroundColor = 'white'; | |
| navLinks.style.padding = '1rem'; | |
| navLinks.style.boxShadow = '0 4px 6px -1px rgba(0, 0, 0, 0.1)'; | |
| } | |
| } | |
| }); | |
| // Smooth scrolling for anchor links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function (e) { | |
| e.preventDefault(); | |
| const targetId = this.getAttribute('href'); | |
| if (targetId === '#') return; | |
| const targetElement = document.querySelector(targetId); | |
| if (targetElement) { | |
| targetElement.scrollIntoView({ | |
| behavior: 'smooth' | |
| }); | |
| } | |
| }); | |
| }); | |
| // Form submission handling | |
| const forms = document.querySelectorAll('form'); | |
| forms.forEach(form => { | |
| form.addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| // In a real app, you would send this data to your server | |
| const formData = new FormData(this); | |
| const data = Object.fromEntries(formData.entries()); | |
| console.log('Form submitted:', data); | |
| // Show success message | |
| alert('Thank you for your interest! We\'ll be in touch soon.'); | |
| this.reset(); | |
| }); | |
| }); | |
| }); |