User Theme saved to local storage
The theme will no longer reset to the default on page change or reload.
This commit is contained in:
parent
4d7f2ba3ea
commit
e342680351
@ -1,15 +1,22 @@
|
|||||||
$("#themeToggle").on("click", function() {
|
$(document).ready(function() {
|
||||||
const currentTheme = $("body").attr("data-bs-theme");
|
// Activate all tooltips
|
||||||
|
$('[data-bs-toggle="tooltip"]').tooltip();
|
||||||
|
|
||||||
if (currentTheme == "light") {
|
// Apply the user preferred theme
|
||||||
$("body").attr("data-bs-theme", "dark");
|
const theme = localStorage.getItem("theme");
|
||||||
|
if (theme == "light" || theme == "dark") {
|
||||||
|
$("body").attr("data-bs-theme", theme);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$("body").attr("data-bs-theme", "light");
|
$("body").attr("data-bs-theme", "light");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).ready(function() {
|
$("#themeToggle").on("click", function() {
|
||||||
// Activate all tooltips
|
var theme = $("body").attr("data-bs-theme");
|
||||||
$('[data-bs-toggle="tooltip"]').tooltip();
|
|
||||||
|
theme = theme == "light" ? "dark" : "light";
|
||||||
|
|
||||||
|
localStorage.setItem("theme", theme)
|
||||||
|
$("body").attr("data-bs-theme", theme);
|
||||||
});
|
});
|
Loading…
x
Reference in New Issue
Block a user