32 lines
857 B
JavaScript
32 lines
857 B
JavaScript
$("#themeToggle").on("click", function() {
|
|
const currentTheme = $("body").attr("data-bs-theme");
|
|
const newTheme = currentTheme === "light" ? "dark" : "light";
|
|
updateTheme(newTheme);
|
|
});
|
|
|
|
function updateTheme(theme) {
|
|
$("body").attr("data-bs-theme", theme);
|
|
localStorage.setItem("theme", theme);
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
// Activate all tooltips
|
|
$('[data-bs-toggle="tooltip"]').tooltip();
|
|
|
|
// Activate select2s
|
|
$(".select-2").each(function() {
|
|
var dropdownParent = $(this).attr("data-dropdownparent");
|
|
$(this).select2({
|
|
theme: "bootstrap",
|
|
minimumResultsForSearch: 5,
|
|
dropdownParent: dropdownParent
|
|
})
|
|
});
|
|
|
|
// Load theme
|
|
var theme = localStorage.getItem("theme");
|
|
if (theme === null)
|
|
theme = "light";
|
|
|
|
updateTheme(theme);
|
|
}); |