-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
29 lines (26 loc) · 835 Bytes
/
popup.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
// Select all images and modals
const projectImages = document.querySelectorAll('.project-image');
const modals = document.querySelectorAll('.modal');
// Add event listener to each project image
projectImages.forEach((image) => {
image.addEventListener('click', () => {
const modalId = image.getAttribute('data-modal');
const modal = document.getElementById(modalId);
if (modal) {
modal.style.display = 'flex';
}
});
});
// Add event listener to close buttons
modals.forEach((modal) => {
const closeBtn = modal.querySelector('.close');
closeBtn.addEventListener('click', () => {
modal.style.display = 'none';
});
// Close modal when clicking outside of content
modal.addEventListener('click', (event) => {
if (event.target === modal) {
modal.style.display = 'none';
}
});
});