File size: 2,008 Bytes
2279b71 | 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 61 62 63 64 | // Initialize animations when page loads
document.addEventListener('DOMContentLoaded', function() {
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Intersection Observer for scroll animations
const observerOptions = {
threshold: 0.1
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate-fade-in');
observer.unobserve(entry.target);
}
});
}, observerOptions);
document.querySelectorAll('.service-card-container, .floating-3d-image').forEach(el => {
observer.observe(el);
});
// Initialize feather icons
feather.replace();
});
// Form validation for contact form
function validateForm(formId) {
const form = document.getElementById(formId);
if (form) {
form.addEventListener('submit', function(e) {
let isValid = true;
const inputs = form.querySelectorAll('input[required], textarea[required]');
inputs.forEach(input => {
if (!input.value.trim()) {
isValid = false;
input.classList.add('border-red-500');
} else {
input.classList.remove('border-red-500');
}
});
if (!isValid) {
e.preventDefault();
alert('Veuillez remplir tous les champs obligatoires.');
}
});
}
}
// Initialize forms on page load
document.addEventListener('DOMContentLoaded', function() {
validateForm('contact-form');
validateForm('training-form');
}); |