-
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.
Add localstore trigger to remember alert closed
- Loading branch information
1 parent
f6fd8b8
commit 3661b2d
Showing
3 changed files
with
25 additions
and
6 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,10 +1,19 @@ | ||
import "../css/main.css"; | ||
|
||
document.addEventListener("DOMContentLoaded", function () { | ||
document | ||
.querySelector(".rvo-alert .rvo-button__close") | ||
.addEventListener("click", function (event) { | ||
const parrent = event.target.closest(".rvo-alert"); | ||
parrent.style.display = "none"; | ||
document.querySelectorAll(".rvo-alert").forEach(function (alertDiv) { | ||
const closeButton = alertDiv.querySelector(".rvo-button__close"); | ||
const alertId = alertDiv.getAttribute("data-alert-id"); | ||
|
||
if (localStorage.getItem(`alertClosed-${alertId}`) === "true") { | ||
alertDiv.style.display = "none"; | ||
} | ||
|
||
closeButton.addEventListener("click", function (event) { | ||
alertDiv.style.display = "none"; | ||
|
||
// Set a localStorage item to remember the alert is closed | ||
localStorage.setItem(`alertClosed-${alertId}`, "true"); | ||
}); | ||
}); | ||
}); |
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
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