diff options
Diffstat (limited to 'view/theme/redbasic/js/redbasic.js')
-rw-r--r-- | view/theme/redbasic/js/redbasic.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/view/theme/redbasic/js/redbasic.js b/view/theme/redbasic/js/redbasic.js index 04469cb85..7584f9421 100644 --- a/view/theme/redbasic/js/redbasic.js +++ b/view/theme/redbasic/js/redbasic.js @@ -2,6 +2,19 @@ * redbasic theme specific JavaScript */ +let redbasic_dark_mode = localStorage.getItem('redbasic_dark_mode'); + +if (redbasic_dark_mode == 1) { + $('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'); +} + $(document).ready(function() { // CSS3 calc() fallback (for unsupported browsers) @@ -40,6 +53,20 @@ $(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); + $('#theme-switch-icon').removeClass('fa-sun-o').addClass('fa-moon-o'); + } + else { + $('html').attr('data-bs-theme', 'dark'); + localStorage.setItem('redbasic_dark_mode', 2); + $('#theme-switch-icon').removeClass('fa-moon-o').addClass('fa-sun-o'); + } + }); + + $('#menu-btn').click(function() { if($('#navbar-collapse-1').hasClass('show')){ $('#navbar-collapse-1').removeClass('show'); |