mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-11-28 13:09:07 -05:00
Update theme-switcher.js
Remove on theme change event
This commit is contained in:
@@ -1,29 +1,21 @@
|
|||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
const themeStylesheet = document.getElementById("theme-stylesheet");
|
||||||
const themeSwitcher = document.getElementById('theme-switcher');
|
|
||||||
const themeStylesheet = document.getElementById('theme-stylesheet');
|
|
||||||
|
|
||||||
// Load saved theme from local storage
|
// Load saved theme from local storage
|
||||||
const savedTheme = localStorage.getItem('theme');
|
const savedTheme = localStorage.getItem("theme");
|
||||||
if (savedTheme) {
|
if (savedTheme) {
|
||||||
const safeTheme = encodeURIComponent(savedTheme);
|
const safeTheme = encodeURIComponent(savedTheme);
|
||||||
themeStylesheet.href = `styles/themes/${safeTheme}/bootstrap.min.css`;
|
themeStylesheet.href = `styles/themes/${safeTheme}/bootstrap.min.css`;
|
||||||
themeSwitcher.value = savedTheme;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change theme on selection
|
|
||||||
themeSwitcher.addEventListener('change', function () {
|
|
||||||
const selectedTheme = themeSwitcher.value;
|
|
||||||
const safeTheme = encodeURIComponent(selectedTheme);
|
|
||||||
themeStylesheet.href = `styles/themes/${safeTheme}/bootstrap.min.css`;
|
|
||||||
// Save selected theme to local storage
|
|
||||||
localStorage.setItem('theme', selectedTheme);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Initialize Select2 on all select elements with the 'select2' class
|
// Initialize Select2 on all select elements with the 'select2' class
|
||||||
$('.select2').select2({
|
$(".select2").select2({
|
||||||
theme: 'bootstrap-5',
|
theme: "bootstrap-5",
|
||||||
width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style',
|
width: $(this).data("width")
|
||||||
placeholder: $( this ).data( 'placeholder' ),
|
? $(this).data("width")
|
||||||
|
: $(this).hasClass("w-100")
|
||||||
|
? "100%"
|
||||||
|
: "style",
|
||||||
|
placeholder: $(this).data("placeholder"),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user