mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 04:38:28 +00:00
No not use per-browser settings for the theme to avoid flashing pages on navigation.
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -127,7 +127,13 @@ function testCookies() {
|
||||
}
|
||||
|
||||
function initCheckboxRadioStyle() {
|
||||
function getCheckboxURL(style) {
|
||||
var extra = style.startsWith("material-") ? "material" : "bootstrap";
|
||||
return "style/vendor/icheck-" + extra + ".min.css"
|
||||
}
|
||||
|
||||
function applyCheckboxRadioStyle(style) {
|
||||
boxsheet.attr('href', getCheckboxURL(style));
|
||||
var sel = $("input[type='radio'],input[type='checkbox']");
|
||||
sel.parent().removeClass();
|
||||
sel.parent().addClass("icheck-" + style);
|
||||
@@ -136,9 +142,12 @@ function initCheckboxRadioStyle() {
|
||||
// Read from local storage, initialize if needed
|
||||
var chkboxStyle = localStorage.getItem("theme_icheck");
|
||||
if (chkboxStyle === null) {
|
||||
chkboxStyle = "material-blue";
|
||||
chkboxStyle = "primary";
|
||||
}
|
||||
|
||||
var boxsheet = $('<link href="' + getCheckboxURL(chkboxStyle) + '" rel="stylesheet" />');
|
||||
boxsheet.appendTo('head');
|
||||
|
||||
applyCheckboxRadioStyle(chkboxStyle);
|
||||
|
||||
// Add handler when on settings page
|
||||
@@ -184,33 +193,6 @@ function initBoxedLayout() {
|
||||
}
|
||||
}
|
||||
|
||||
function initTheme() {
|
||||
function getThemeURL(themename) {
|
||||
return "style/themes/" + themename + ".css";
|
||||
}
|
||||
|
||||
// Read from local storage, initialize if needed
|
||||
var themename = localStorage.getItem("css-theme");
|
||||
if (themename === null) {
|
||||
themename = "default-light";
|
||||
localStorage.setItem("css-theme", themename);
|
||||
}
|
||||
|
||||
var themesheet = $('<link href="' + getThemeURL(themename) + '" rel="stylesheet" />');
|
||||
themesheet.appendTo("head");
|
||||
|
||||
// Add handler when on settings page
|
||||
var themeSelector = $("#theme-selector");
|
||||
if (themeSelector !== null) {
|
||||
themeSelector.val(themename);
|
||||
themeSelector.change(function () {
|
||||
themename = $(this).val();
|
||||
localStorage.setItem("css-theme", themename);
|
||||
themesheet.attr("href", getThemeURL(themename));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function initCPUtemp() {
|
||||
function setCPUtemp(unit) {
|
||||
localStorage.setItem("tempunit", tempunit);
|
||||
@@ -269,7 +251,6 @@ $(function () {
|
||||
// Apply per-browser styling settings
|
||||
initCheckboxRadioStyle();
|
||||
initBoxedLayout();
|
||||
initTheme();
|
||||
initCPUtemp();
|
||||
|
||||
if (typeof initpage === "function") {
|
||||
|
||||
Reference in New Issue
Block a user