Merge pull request #7121 from rezzorix/fix/theme-localstorage-staging
Fix theme localStorage collision with rspamd UI
This commit is contained in:
commit
d4bf377a96
@ -345,7 +345,7 @@ $(document).ready(function() {
|
|||||||
$('.main-logo-dark').addClass('d-none');
|
$('.main-logo-dark').addClass('d-none');
|
||||||
if ($('#rspamd_logo').length) $('#rspamd_logo').attr('src', '/img/rspamd_logo_dark.png');
|
if ($('#rspamd_logo').length) $('#rspamd_logo').attr('src', '/img/rspamd_logo_dark.png');
|
||||||
if ($('#rspamd_logo_sm').length) $('#rspamd_logo_sm').attr('src', '/img/rspamd_logo_dark.png');
|
if ($('#rspamd_logo_sm').length) $('#rspamd_logo_sm').attr('src', '/img/rspamd_logo_dark.png');
|
||||||
localStorage.setItem('theme', 'light');
|
localStorage.setItem('mailcow_theme', 'light');
|
||||||
}else{
|
}else{
|
||||||
$('head').append('<link id="dark-mode-theme" rel="stylesheet" type="text/css" href="/css/themes/mailcow-darkmode.css">');
|
$('head').append('<link id="dark-mode-theme" rel="stylesheet" type="text/css" href="/css/themes/mailcow-darkmode.css">');
|
||||||
$('#dark-mode-toggle').prop('checked', true);
|
$('#dark-mode-toggle').prop('checked', true);
|
||||||
@ -353,7 +353,7 @@ $(document).ready(function() {
|
|||||||
$('.main-logo-dark').removeClass('d-none');
|
$('.main-logo-dark').removeClass('d-none');
|
||||||
if ($('#rspamd_logo').length) $('#rspamd_logo').attr('src', '/img/rspamd_logo_light.png');
|
if ($('#rspamd_logo').length) $('#rspamd_logo').attr('src', '/img/rspamd_logo_light.png');
|
||||||
if ($('#rspamd_logo_sm').length) $('#rspamd_logo_sm').attr('src', '/img/rspamd_logo_light.png');
|
if ($('#rspamd_logo_sm').length) $('#rspamd_logo_sm').attr('src', '/img/rspamd_logo_light.png');
|
||||||
localStorage.setItem('theme', 'dark');
|
localStorage.setItem('mailcow_theme', 'dark');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var theme = localStorage.getItem("theme");
|
var theme = localStorage.getItem("mailcow_theme");
|
||||||
localStorage.clear();
|
if (theme !== null) {
|
||||||
localStorage.setItem("theme", theme);
|
localStorage.setItem("mailcow_theme", theme);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -11,8 +11,8 @@
|
|||||||
<link rel="stylesheet" href="{{ css_path }}">
|
<link rel="stylesheet" href="{{ css_path }}">
|
||||||
<script>
|
<script>
|
||||||
// check if darkmode is preferred by OS or set by localStorage
|
// check if darkmode is preferred by OS or set by localStorage
|
||||||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches && localStorage.getItem("theme") !== "light" ||
|
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches && localStorage.getItem("mailcow_theme") !== "light" ||
|
||||||
localStorage.getItem("theme") === "dark") {
|
localStorage.getItem("mailcow_theme") === "dark") {
|
||||||
var head = document.getElementsByTagName('head')[0];
|
var head = document.getElementsByTagName('head')[0];
|
||||||
var link = document.createElement('link');
|
var link = document.createElement('link');
|
||||||
link.id = 'dark-mode-theme';
|
link.id = 'dark-mode-theme';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user