aboutsummaryrefslogtreecommitdiffstats
path: root/view/theme/redbasic/js/redbasic.js
diff options
context:
space:
mode:
Diffstat (limited to 'view/theme/redbasic/js/redbasic.js')
-rw-r--r--view/theme/redbasic/js/redbasic.js40
1 files changed, 30 insertions, 10 deletions
diff --git a/view/theme/redbasic/js/redbasic.js b/view/theme/redbasic/js/redbasic.js
index 7a6d795a4..b7036262d 100644
--- a/view/theme/redbasic/js/redbasic.js
+++ b/view/theme/redbasic/js/redbasic.js
@@ -3,21 +3,35 @@
*/
let redbasic_dark_mode = localStorage.getItem('redbasic_dark_mode');
+let redbasic_theme_color = localStorage.getItem('redbasic_theme_color');
if (redbasic_dark_mode == 1) {
+ $('html').attr('data-bs-theme', 'dark');
+}
+if (redbasic_dark_mode == 0) {
$('html').attr('data-bs-theme', 'light');
- $('#theme-switch-icon').removeClass('fa-sun-o').addClass('fa-moon-o');
}
-if (redbasic_dark_mode == 2) {
- $('html').attr('data-bs-theme', 'dark');
- $('#theme-switch-icon').removeClass('fa-moon-o').addClass('fa-sun-o');
-}
+if (redbasic_theme_color) {
+ $('meta[name=theme-color]').attr('content', redbasic_theme_color);
+}
$(document).ready(function() {
- $('meta[name=theme-color]').attr('content', $('nav').css('background-color'));
+ if (redbasic_dark_mode == 1) {
+ $('#theme-switch-icon').removeClass('fa-moon-o').addClass('fa-sun-o');
+ $('[data-bs-theme="light"]').attr('data-bs-theme', 'dark');
+ }
+ if (redbasic_dark_mode == 0) {
+ $('#theme-switch-icon').removeClass('fa-sun-o').addClass('fa-moon-o');
+ $('[data-bs-theme="dark"]:not(nav)').attr('data-bs-theme', 'light');
+ }
+
+ if (redbasic_theme_color != $('nav').css('background-color')) {
+ $('meta[name=theme-color]').attr('content', $('nav').css('background-color'));
+ localStorage.setItem('redbasic_theme_color', $('nav').css('background-color'));
+ }
// CSS3 calc() fallback (for unsupported browsers)
$('body').append('<div id="css3-calc" style="width: 10px; width: calc(10px + 10px); display: none;"></div>');
@@ -58,16 +72,22 @@ $(document).ready(function() {
$('#theme-switch').click(function() {
if ($('html').attr('data-bs-theme') === 'dark') {
- $('html').attr('data-bs-theme', 'light');
- localStorage.setItem('redbasic_dark_mode', 1);
+ if ($('nav').data('bs-theme') === 'dark') {
+ $('[data-bs-theme="dark"]:not(nav)').attr('data-bs-theme', 'light');
+ }
+ else {
+ $('[data-bs-theme="dark"]').attr('data-bs-theme', 'light');
+ }
+ localStorage.setItem('redbasic_dark_mode', 0);
$('#theme-switch-icon').removeClass('fa-sun-o').addClass('fa-moon-o');
}
else {
- $('html').attr('data-bs-theme', 'dark');
- localStorage.setItem('redbasic_dark_mode', 2);
+ $('[data-bs-theme="light"]').attr('data-bs-theme', 'dark');
+ localStorage.setItem('redbasic_dark_mode', 1);
$('#theme-switch-icon').removeClass('fa-moon-o').addClass('fa-sun-o');
}
$('meta[name=theme-color]').attr('content', $('nav').css('background-color'));
+ localStorage.setItem('redbasic_theme_color', $('nav').css('background-color'));
});