| | |
| | 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) { |
| | window.scrollTo({ |
| | top: targetElement.offsetTop - 100, |
| | behavior: 'smooth' |
| | }); |
| | } |
| | }); |
| | }); |
| |
|
| | |
| | document.addEventListener('DOMContentLoaded', () => { |
| | const mobileMenuBtn = document.querySelector('custom-navbar')?.shadowRoot?.querySelector('.mobile-menu-btn'); |
| | const navLinks = document.querySelector('custom-navbar')?.shadowRoot?.querySelector('.nav-links'); |
| | |
| | if (mobileMenuBtn && navLinks) { |
| | mobileMenuBtn.addEventListener('click', () => { |
| | const isOpen = navLinks.style.display === 'flex'; |
| | navLinks.style.display = isOpen ? 'none' : 'flex'; |
| | |
| | |
| | const icon = mobileMenuBtn.querySelector('i'); |
| | if (icon) { |
| | icon.setAttribute('data-feather', isOpen ? 'menu' : 'x'); |
| | feather.replace(); |
| | } |
| | }); |
| | } |
| | }); |
| | |
| | const animateOnScroll = () => { |
| | const elements = document.querySelectorAll('.feature-card, section h2, section h3'); |
| | |
| | elements.forEach(element => { |
| | const elementPosition = element.getBoundingClientRect().top; |
| | const screenPosition = window.innerHeight / 1.2; |
| | |
| | if (elementPosition < screenPosition) { |
| | element.style.opacity = '1'; |
| | element.style.transform = 'translateY(0)'; |
| | } |
| | }); |
| | }; |
| |
|
| | |
| | document.querySelectorAll('.feature-card, section h2, section h3').forEach(element => { |
| | element.style.opacity = '0'; |
| | element.style.transform = 'translateY(20px)'; |
| | element.style.transition = 'opacity 0.6s ease, transform 0.6s ease'; |
| | }); |
| |
|
| | window.addEventListener('scroll', animateOnScroll); |
| | window.addEventListener('load', animateOnScroll); |
| | |
| | const contactForm = document.querySelector('form'); |
| | if (contactForm) { |
| | contactForm.addEventListener('submit', async (e) => { |
| | e.preventDefault(); |
| | |
| | |
| | const formData = { |
| | name: document.getElementById('name').value.trim(), |
| | email: document.getElementById('email').value.trim(), |
| | message: document.getElementById('message').value.trim(), |
| | interest: document.getElementById('interest')?.value || 'general' |
| | }; |
| | |
| | |
| | if (!formData.name || !formData.email || !formData.message) { |
| | showAlert('Please fill in all required fields', 'error'); |
| | return; |
| | } |
| |
|
| | if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(formData.email)) { |
| | showAlert('Please enter a valid email address', 'error'); |
| | return; |
| | } |
| |
|
| | try { |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | await new Promise(resolve => setTimeout(resolve, 1000)); |
| | |
| | showAlert(`Thank you for your interest in ${formData.interest === 'general' ? 'our services' : 'our ' + formData.interest + ' solutions'}! Our team will contact you shortly.`, 'success'); |
| | contactForm.reset(); |
| | } catch (error) { |
| | showAlert('There was an error submitting your request. Please try again later.', 'error'); |
| | console.error('Form submission error:', error); |
| | } |
| | }); |
| | } |
| |
|
| | function showAlert(message, type = 'success') { |
| | const alertDiv = document.createElement('div'); |
| | alertDiv.className = `fixed top-4 right-4 px-6 py-4 rounded-lg shadow-lg text-white ${ |
| | type === 'success' ? 'bg-green-500' : 'bg-red-500' |
| | }`; |
| | alertDiv.textContent = message; |
| | document.body.appendChild(alertDiv); |
| | |
| | setTimeout(() => { |
| | alertDiv.style.opacity = '0'; |
| | setTimeout(() => alertDiv.remove(), 300); |
| | }, 5000); |
| | } |
| |
|