-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathScript.js
107 lines (85 loc) · 3.21 KB
/
Script.js
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* --------------------------------- HOME IMAGES SLIDER ------------------------------------------------- */
let currentSlide = 0;
const slides = document.querySelectorAll('.slide');
const totalSlides = slides.length;
const indicatorsContainer = document.querySelector('.slide-indicators');
for (let i = 0; i < totalSlides; i++) {
const indicator = document.createElement('div');
indicator.classList.add('indicator');
indicatorsContainer.appendChild(indicator);
}
const indicators = document.querySelectorAll('.indicator');
updateIndicators();
function updateIndicators() {
indicators.forEach((indicator, index) => {
indicator.classList.toggle('active', index === currentSlide);
});
}
function nextSlide() {
currentSlide = (currentSlide + 1) % totalSlides;
updateSlider();
}
function prevSlide() {
currentSlide = (currentSlide - 1 + totalSlides) % totalSlides;
updateSlider();
}
function updateSlider() {
const translateValue = -currentSlide * 100 + '%';
document.querySelector('.slider').style.transform = 'translateX(' + translateValue + ')';
updateIndicators();
}
setInterval(nextSlide, 5000); // Auto slide every 5 seconds
/* ---------------------------------------- OFFERS IMAGES SLIDER ----------------------------------------- */
const offerSlider = document.querySelector('.offer-images-collection');
const offerSlides = document.querySelectorAll('.offerSlide');
const offerIndicatorsContainer = document.querySelector('.offerSlider-indicators');
let offerCurrentIndex = 0;
function updateOfferSlider() {
offerSlider.style.transform = `translateX(${-offerCurrentIndex * 100}%)`;
const offerIndicators = Array.from(offerIndicatorsContainer.children);
offerIndicators.forEach((indicator, index) => {
indicator.classList.toggle('active', index === offerCurrentIndex);
});
}
function nextOfferSlide() {
offerCurrentIndex = (offerCurrentIndex + 1) % offerSlides.length;
updateOfferSlider();
}
function prevOfferSlide() {
offerCurrentIndex = (offerCurrentIndex - 1 + offerSlides.length) % offerSlides.length;
updateOfferSlider();
}
function createOfferIndicators() {
offerSlides.forEach((_, index) => {
const indicator = document.createElement('div');
indicator.classList.add('offerSlider-indicator');
indicator.addEventListener('click', () => {
offerCurrentIndex = index;
updateOfferSlider();
});
offerIndicatorsContainer.appendChild(indicator);
});
}
createOfferIndicators();
setInterval(nextOfferSlide, 3000); // Auto slide in 3 seconds
/* -------------------------------- GO UP BUTTON ----------------------------------- */
function scrollToTop() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
window.onscroll = function () {
var goUpButton = document.querySelector('.go-up');
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
goUpButton.style.display = 'block';
} else {
goUpButton.style.display = 'none';
}
};
/* ----------------------- For Rooms OnClick Redirection -------------------------- */
function viewRooms(loc) {
window.location.href = loc;
}
/* ----------------------- For Blog OnClick Redirection -------------------------- */
function redirectToBlog(url) {
window.location.href = url;
}