-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbazaar.js
More file actions
130 lines (110 loc) · 4.32 KB
/
bazaar.js
File metadata and controls
130 lines (110 loc) · 4.32 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
document.addEventListener("DOMContentLoaded", function () {
const lightbox = document.getElementById("lightbox");
const lightboxImg = document.getElementById("lightbox-img");
const closeBtn = document.querySelector(".close");
const prevBtn = document.querySelector(".prev");
const nextBtn = document.querySelector(".next");
const dotsContainer = document.querySelector(".dots-container");
const galleryImages = document.querySelectorAll(".gallery-container img");
let currentIndex = 0;
// Function to open the lightbox
function openLightbox(index) {
currentIndex = index;
lightbox.style.display = "flex";
lightboxImg.src = galleryImages[currentIndex].getAttribute("src");
updateDots();
}
// Add event listener to all gallery images
galleryImages.forEach((img, index) => {
img.addEventListener("click", () => {
openLightbox(index);
});
});
// Function to close the lightbox
closeBtn.addEventListener("click", () => {
lightbox.style.display = "none";
});
// Function to navigate next
nextBtn.addEventListener("click", () => {
currentIndex = (currentIndex + 1) % galleryImages.length;
openLightbox(currentIndex);
});
// Function to navigate previous
prevBtn.addEventListener("click", () => {
currentIndex = (currentIndex - 1 + galleryImages.length) % galleryImages.length;
openLightbox(currentIndex);
});
// Close lightbox when clicking outside the image
lightbox.addEventListener("click", (event) => {
if (event.target === lightbox) {
lightbox.style.display = "none";
}
});
// Create dots for each image
function createDots() {
dotsContainer.innerHTML = "";
galleryImages.forEach((_, index) => {
let dot = document.createElement("span");
dot.classList.add("dot");
if (index === currentIndex) {
dot.classList.add("active");
}
dot.addEventListener("click", () => {
openLightbox(index);
});
dotsContainer.appendChild(dot);
});
}
// Function to update dot indicators
function updateDots() {
let dots = document.querySelectorAll(".dot");
dots.forEach((dot, index) => {
dot.classList.toggle("active", index === currentIndex);
});
}
// Initialize dots on page load
createDots();
});
document.addEventListener("DOMContentLoaded", function () {
const menuLink = document.getElementById("menu-link");
const lightbox = document.getElementById("pdf-lightbox");
const closeBtn = document.querySelector(".close-btn");
menuLink.addEventListener("click", function (event) {
event.preventDefault(); // Prevent default link behavior
lightbox.style.display = "flex";
});
closeBtn.addEventListener("click", function () {
lightbox.style.display = "none";
});
// Close lightbox when clicking outside of it
lightbox.addEventListener("click", function (event) {
if (event.target === lightbox) {
lightbox.style.display = "none";
}
});
});
document.addEventListener("DOMContentLoaded", function () {
const lightbox = document.getElementById("pdf-lightbox");
const pdfViewer = document.querySelector(".pdf-viewer");
const closeBtn = document.querySelector(".close-btn");
// Handle button clicks
document.querySelectorAll(".view-menu-btn").forEach(button => {
button.addEventListener("click", function () {
let pdfUrl = this.getAttribute("data-pdf");
pdfViewer.src = pdfUrl + "#toolbar=0&navpanes=0&scrollbar=0";
lightbox.style.display = "flex";
});
});
// Close the lightbox
closeBtn.addEventListener("click", function () {
lightbox.style.display = "none";
pdfViewer.src = ""; // Clear PDF when closing
});
// Close when clicking outside the content
lightbox.addEventListener("click", function (event) {
if (event.target === lightbox) {
lightbox.style.display = "none";
pdfViewer.src = "";
}
});
});