Spaces:
Running
Running
| // Global functions | |
| function formatPrice(price) { | |
| return new Intl.NumberFormat('ar-EG', { style: 'currency', currency: 'EGP' }).format(price); | |
| } | |
| function toggleMobileMenu() { | |
| const menu = document.getElementById('mobile-menu'); | |
| menu.classList.toggle('hidden'); | |
| } | |
| // Initialize product carousels | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Initialize deals carousel | |
| const dealsCarousel = new Glide('.deals-carousel', { | |
| type: 'carousel', | |
| perView: 4, | |
| gap: 20, | |
| breakpoints: { | |
| 1024: { perView: 3 }, | |
| 768: { perView: 2 }, | |
| 640: { perView: 1 } | |
| } | |
| }); | |
| dealsCarousel.mount(); | |
| // Initialize bestsellers carousel | |
| const bestsellersCarousel = new Glide('.bestsellers-carousel', { | |
| type: 'carousel', | |
| perView: 5, | |
| gap: 20, | |
| breakpoints: { | |
| 1024: { perView: 4 }, | |
| 768: { perView: 3 }, | |
| 640: { perView: 2 }, | |
| 480: { perView: 1 } | |
| } | |
| }); | |
| bestsellersCarousel.mount(); | |
| // Initialize featured categories | |
| const categories = document.querySelectorAll('.category-card'); | |
| categories.forEach(category => { | |
| category.addEventListener('mouseenter', () => { | |
| category.querySelector('.category-overlay').classList.remove('opacity-0'); | |
| category.querySelector('.category-overlay').classList.add('opacity-100'); | |
| }); | |
| category.addEventListener('mouseleave', () => { | |
| category.querySelector('.category-overlay').classList.remove('opacity-100'); | |
| category.querySelector('.category-overlay').classList.add('opacity-0'); | |
| }); | |
| }); | |
| }); | |
| // Product quick view modal | |
| function openQuickView(productId) { | |
| // Fetch product data and populate modal | |
| fetch(`/api/products/${productId}`) | |
| .then(response => response.json()) | |
| .then(data => { | |
| document.getElementById('quick-view-title').textContent = data.name; | |
| document.getElementById('quick-view-price').textContent = formatPrice(data.price); | |
| document.getElementById('quick-view-desc').textContent = data.description; | |
| document.getElementById('quick-view-image').src = data.image; | |
| // Show modal | |
| document.getElementById('quick-view-modal').classList.remove('hidden'); | |
| }); | |
| } | |
| function closeQuickView() { | |
| document.getElementById('quick-view-modal').classList.add('hidden'); | |
| } |