EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
theme-switcher.js
Go to the documentation of this file.
1document.addEventListener("DOMContentLoaded", function () {
2 const themeStylesheet = document.getElementById("theme-stylesheet");
3
4 // Load saved theme from local storage
5 const savedTheme = localStorage.getItem("theme");
6 if (savedTheme) {
7 const safeTheme = ((savedTheme != 'default') ? encodeURIComponent(savedTheme) : encodeURIComponent('..'));
8 themeStylesheet.href = `styles/themes/${safeTheme}/bootstrap-min.css`;
9 }
10
11 // Initialize Select2 on all select elements with the 'select2' class
12 $(".select2").select2({
13 theme: "bootstrap-5",
14 width: $(this).data("width")
15 ? $(this).data("width")
16 : $(this).hasClass("w-100")
17 ? "100%"
18 : "style",
19 placeholder: $(this).data("placeholder"),
20 });
21});