Omanjelato/flotech-solutions-clean-engineering-excellence
0
1document.addEventListener('DOMContentLoaded', function() {2 // Product carousel3 const productCarousel = new Swiper('.product-carousel', {4 slidesPerView: 1,5 spaceBetween: 20,6 navigation: {7 nextEl: '.product-carousel-next',8 prevEl: '.product-carousel-prev',9 },10 breakpoints: {11 640: {12 slidesPerView: 2,13 },14 1024: {15 slidesPerView: 3,16 }17 }18 });19 20 // Testimonial carousel21 const testimonialCarousel = new Swiper('.testimonial-carousel', {22 loop: true,23 autoplay: {24 delay: 5000,25 },26 pagination: {27 el: '.testimonial-pagination',28 clickable: true,29 },30 });31 32 // Smooth scroll for anchor links33 document.querySelectorAll('a[href^="#"]').forEach(anchor => {34 anchor.addEventListener('click', function (e) {35 e.preventDefault();36 document.querySelector(this.getAttribute('href')).scrollIntoView({37 behavior: 'smooth'38 });39 });40 });41 42 // Mobile menu toggle43 document.getElementById('mobile-menu-button').addEventListener('click', function() {44 const mobileMenu = document.getElementById('mobile-menu');45 mobileMenu.classList.toggle('hidden');46 });47 48 // Form submission handling49 const forms = document.querySelectorAll('form');50 forms.forEach(form => {51 form.addEventListener('submit', function(e) {52 e.preventDefault();53 // Here you would typically add AJAX form submission54 // For demo purposes we'll just show a success state55 const submitBtn = this.querySelector('button[type="submit"]');56 const successElement = this.querySelector('.form-success');57 58 if (submitBtn && successElement) {59 submitBtn.classList.add('hidden');60 successElement.classList.remove('hidden');61 }62 });63 });64});65 66// Load Swiper if not already loaded67function loadSwiper() {68 if (typeof Swiper === 'undefined') {69 const script = document.createElement('script');70 script.src = 'https://unpkg.com/swiper/swiper-bundle.min.js';71 document.head.appendChild(script);72 73 const link = document.createElement('link');74 link.rel = 'stylesheet';75 link.href = 'https://unpkg.com/swiper/swiper-bundle.min.css';76 document.head.appendChild(link);77 78 script.onload = function() {79 // Reinitialize swipers after load80 document.dispatchEvent(new Event('DOMContentLoaded'));81 };82 }83}84loadSwiper();