|
1 | 1 | // Showreel slider |
2 | | - |
3 | 2 | (function() { |
4 | | - |
5 | 3 | const container = document.getElementById('showreel'); |
6 | | - |
7 | 4 | if (!container) return; |
8 | 5 |
|
9 | | - |
10 | 6 | const slides = Array.from(container.querySelectorAll('.slide')); |
11 | | - |
12 | 7 | if (slides.length === 0) return; |
13 | 8 |
|
14 | | - |
15 | 9 | let currentIndex = 0; |
16 | 10 |
|
17 | | - |
18 | | -// إظهار أول شريحة فوراً |
19 | | - |
| 11 | + // إظهار أول شريحة فوراً |
20 | 12 | slides[0].classList.add('active'); |
21 | 13 |
|
22 | | - |
23 | | -// تشغيل أول فيديو لو موجود |
24 | | - |
| 14 | + // تشغيل أول فيديو لو موجود |
25 | 15 | const firstVideo = slides[0].querySelector('video'); |
26 | | - |
27 | 16 | if (firstVideo) { |
28 | | - |
29 | 17 | firstVideo.play().catch(() => {}); |
30 | | - |
31 | 18 | } |
32 | 19 |
|
33 | | - |
34 | 20 | function showSlide(index) { |
35 | | - |
36 | 21 | slides.forEach((s, i) => { |
37 | | - |
38 | 22 | s.classList.toggle('active', i === index); |
39 | | - |
40 | 23 | const video = s.querySelector('video'); |
41 | 24 |
|
42 | | - |
43 | 25 | if (video) { |
44 | | - |
45 | 26 | if (i === index) { |
46 | | - |
47 | | -// تشغيل الفيديو للشريحة النشطة فقط |
48 | | - |
| 27 | + // تشغيل الفيديو للشريحة النشطة فقط |
49 | 28 | video.currentTime = 0; |
50 | | - |
51 | 29 | video.play().catch(() => {}); |
52 | | - |
53 | 30 | } else { |
54 | | - |
55 | | -// إيقاف الفيديوهات في الشرائح المخفية لتوفير الأداء |
56 | | - |
| 31 | + // إيقاف الفيديوهات في الشرائح المخفية لتوفير الأداء |
57 | 32 | video.pause(); |
58 | | - |
59 | 33 | } |
60 | | - |
61 | 34 | } |
62 | | - |
63 | 35 | }); |
64 | | - |
65 | 36 | } |
66 | 37 |
|
67 | | - |
68 | 38 | function nextSlide() { |
69 | | - |
70 | 39 | currentIndex = (currentIndex + 1) % slides.length; |
71 | | - |
72 | 40 | showSlide(currentIndex); |
73 | | - |
74 | 41 | } |
75 | 42 |
|
76 | | - |
77 | | -// تغيير الشريحة كل 5 ثواني |
78 | | - |
| 43 | + // تغيير الشريحة كل 5 ثواني |
79 | 44 | setInterval(nextSlide, 5000); |
80 | | - |
81 | 45 | })(); |
82 | 46 |
|
83 | | - |
84 | 47 | // Facade Pattern for Vimeo videos |
85 | | - |
86 | 48 | document.addEventListener("DOMContentLoaded", function () { |
87 | | - |
88 | 49 | const videoWrappers = document.querySelectorAll(".video-wrapper"); |
89 | 50 |
|
90 | | - |
91 | 51 | videoWrappers.forEach((wrapper) => { |
92 | | - |
93 | 52 | const playButton = wrapper.querySelector(".facade-play-btn"); |
94 | | - |
95 | 53 | const iframe = wrapper.querySelector("iframe"); |
96 | 54 |
|
97 | | - |
98 | 55 | if (playButton) { |
99 | | - |
100 | 56 | playButton.addEventListener("click", function () { |
101 | | - |
102 | | - playButton.style.display = "none"; // إخفاء الزر |
| 57 | + playButton.style.display = "none"; // Hide the play button |
| 58 | + wrapper.classList.add("is-playing"); // Add the playing class for visual effects |
103 | 59 |
|
104 | 60 | if (iframe) { |
105 | | - |
106 | | - iframe.src = iframe.dataset.src; // تعيين src للإطار |
107 | | - |
| 61 | + iframe.src = iframe.dataset.src; // Set the iframe source |
108 | 62 | } |
109 | 63 |
|
110 | 64 | wrapper.style.cursor = "default"; |
111 | | - |
112 | 65 | }); |
113 | | - |
114 | 66 | } |
115 | | - |
116 | 67 | }); |
117 | | - |
118 | | -}) |
| 68 | +}); |
0 commit comments