Spaces:
Running
Running
File size: 2,273 Bytes
11cc93c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
// 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();
});
});
}); |