File size: 2,498 Bytes
8609464
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
65
66
67
68
69
70
71
72
// 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');
}