Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
163 lines (138 loc) · 5.52 KB
/
Copy pathscript.js
File metadata and controls
163 lines (138 loc) · 5.52 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
//menu hamburguer
document.addEventListener("DOMContentLoaded", () => {
const menuToggle = document.querySelector(".menu-toggle");
const nav = document.querySelector("header nav");
menuToggle.addEventListener("click", () => {
nav.classList.toggle("menu-active");
});
});
//leia mais/menos
document.addEventListener("DOMContentLoaded", () => {
const readMoreButtons = document.querySelectorAll(".read-more-btn");
readMoreButtons.forEach(button => {
button.addEventListener("click", () => {
const card = button.parentElement;
const shortDescription = card.querySelector(".short-description");
const fullDescription = card.querySelector(".full-description");
if (fullDescription.style.display === "none" || fullDescription.style.display === "") {
fullDescription.style.display = "block";
shortDescription.style.display = "none";
button.textContent = "Leia Menos";
} else {
fullDescription.style.display = "none";
shortDescription.style.display = "block";
button.textContent = "Leia Mais";
}
});
});
});
//lightbox para imagens
document.addEventListener("DOMContentLoaded", () => {
const images = document.querySelectorAll(".gallery img");
const lightbox = document.getElementById("lightbox");
const lightboxImage = document.getElementById("lightbox-image");
const closeButton = lightbox.querySelector(".close");
const prevButton = lightbox.querySelector(".prev");
const nextButton = lightbox.querySelector(".next");
let currentIndex = 0;
// Abre o Lightbox ao clicar em uma imagem
images.forEach((image, index) => {
image.addEventListener("click", () => {
currentIndex = index;
updateLightbox();
lightbox.style.display = "flex";
});
});
// Fecha o Lightbox
closeButton.addEventListener("click", () => {
lightbox.style.display = "none";
});
// Navega para a imagem anterior
prevButton.addEventListener("click", (e) => {
e.stopPropagation();
currentIndex = (currentIndex - 1 + images.length) % images.length;
updateLightbox();
});
// Navega para a próxima imagem
nextButton.addEventListener("click", (e) => {
e.stopPropagation();
currentIndex = (currentIndex + 1) % images.length;
updateLightbox();
});
// Fecha o Lightbox ao clicar fora da imagem
lightbox.addEventListener("click", (e) => {
if (e.target === lightbox) {
lightbox.style.display = "none";
}
});
// Atualiza a imagem no Lightbox
function updateLightbox() {
lightboxImage.src = images[currentIndex].src;
}
});
//ver mais fotos
document.addEventListener("DOMContentLoaded", () => {
const images = document.querySelectorAll(".gallery img");
const lightbox = document.getElementById("lightbox");
const lightboxImage = document.getElementById("lightbox-image");
const closeButton = lightbox.querySelector(".close");
const prevButton = lightbox.querySelector(".prev");
const nextButton = lightbox.querySelector(".next");
const viewMoreButton = document.getElementById("view-more");
const additionalImages = [
"images/tour/tour9.jpg",
"images/tour/tour10.jpg",
"images/tour/tour11.jpg",
"images/tour/tour12.jpg",
"images/tour/tour13.jpg",
"images/tour/tour14.jpg",
"images/tour/tour15.jpg"
];
let currentIndex = 0;
let isAdditionalImages = false;
// Abre o Lightbox ao clicar em uma imagem
images.forEach((image, index) => {
image.addEventListener("click", () => {
isAdditionalImages = false;
currentIndex = index;
updateLightbox();
lightbox.style.display = "flex";
});
});
// Abre o Lightbox com imagens adicionais ao clicar no botão "Ver Mais Fotos"
viewMoreButton.addEventListener("click", () => {
isAdditionalImages = true;
currentIndex = 0;
updateLightbox();
lightbox.style.display = "flex";
});
// Fecha o Lightbox
closeButton.addEventListener("click", () => {
lightbox.style.display = "none";
});
// Navega para a imagem anterior
prevButton.addEventListener("click", (e) => {
e.stopPropagation();
const imagesArray = isAdditionalImages ? additionalImages : Array.from(images).map(img => img.src);
currentIndex = (currentIndex - 1 + imagesArray.length) % imagesArray.length;
updateLightbox();
});
// Navega para a próxima imagem
nextButton.addEventListener("click", (e) => {
e.stopPropagation();
const imagesArray = isAdditionalImages ? additionalImages : Array.from(images).map(img => img.src);
currentIndex = (currentIndex + 1) % imagesArray.length;
updateLightbox();
});
// Fecha o Lightbox ao clicar fora da imagem
lightbox.addEventListener("click", (e) => {
if (e.target === lightbox) {
lightbox.style.display = "none";
}
});
// Atualiza a imagem no Lightbox
function updateLightbox() {
const imagesArray = isAdditionalImages ? additionalImages : Array.from(images).map(img => img.src);
lightboxImage.src = imagesArray[currentIndex];
}
});