-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
19 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
const icon = document.getElementById('infoIcon'); | ||
const popup = document.getElementById('popupInfo'); | ||
const popup = document.getElementById('popupInfo'); | ||
let popupOpen = false; // Track if the popup is open | ||
|
||
// Show popup when clicking on the icon | ||
icon.addEventListener('click', (e) => { | ||
e.stopPropagation(); // Prevents the click from triggering the window event | ||
popup.style.display = 'block'; | ||
}); | ||
// Show popup when clicking on the icon | ||
icon.addEventListener('click', (e) => { | ||
e.stopPropagation(); // Prevents the window click event from firing | ||
popup.style.display = popupOpen ? 'none' : 'block'; // Toggle the popup's visibility | ||
popupOpen = !popupOpen; // Update the state | ||
}); | ||
|
||
// Hide popup when clicking outside the popup or icon | ||
window.addEventListener('click', (e) => { | ||
if (!popup.contains(e.target) && e.target !== icon && !icon.contains(e.target)) { | ||
popup.style.display = 'none'; | ||
} | ||
}); | ||
// Hide popup when clicking outside the popup or icon | ||
window.addEventListener('click', (e) => { | ||
if (popupOpen && !popup.contains(e.target) && !icon.contains(e.target)) { | ||
popup.style.display = 'none'; // Hide the popup | ||
popupOpen = false; // Update the state | ||
} | ||
}); | ||
|
||
// Prevent closing the popup when clicking inside it | ||
popup.addEventListener('click', (e) => { | ||
e.stopPropagation(); // Prevents closing the popup when clicking inside it | ||
}); | ||
// Prevent closing the popup when clicking inside it | ||
popup.addEventListener('click', (e) => { | ||
e.stopPropagation(); // Prevents closing the popup when clicking inside it | ||
}); |