08.03.2024, 07:36
Hello, Is it possible to put a switch on the visualisation to switch between dark theme and light theme ?
dark / light mode
|
08.03.2024, 07:36
Hello, Is it possible to put a switch on the visualisation to switch between dark theme and light theme ?
08.03.2024, 07:43
Do you want to change it locally (only for the current user session) or globally (for all users)?
08.03.2024, 08:56
08.03.2024, 09:18
Add this to Custom JavaScript:
Code: 1234567891011121314 $(function(){
if (window.Storage) {
var dark = !!Storage.get('darkmode', '');
$('body').toggleClass('dark', dark);
$('.toggle-dark-mode').off('vclick').on('vclick', function() {
dark = !dark;
Storage.set('darkmode', dark ? 'y' : '');
$('body').toggleClass('dark', dark);
});
}
});Create a dummy object and attach a visualization element to it. Set Additional classes to toggle-dark-mode Clicking this element will toggle between light/dark mode. This setting is stored in browser's local storage.
08.03.2024, 09:30
(08.03.2024, 09:18)admin Wrote: Add this to Custom JavaScript: Thanks
08.03.2024, 13:38
(08.03.2024, 09:18)admin Wrote: Add this to Custom JavaScript: when I switch from one mode to another the page trends do not immediately change color. I have to refresh the page manually
11.03.2024, 12:55
This should work with iframes:
Code: 1234567891011121314151617181920212223242526 $(function(){
if (!window.Storage) {
return;
}
var bc = new BroadcastChannel('darkmode');
function get() {
return !!Storage.get('darkmode', '');
}
function set() {
$('body').toggleClass('dark', get());
}
$('.toggle-dark-mode').off('vclick').on('vclick', function() {
Storage.set('darkmode', get() ? '' : 'y');
bc.postMessage('set');
set();
});
bc.addEventListener('message', set);
set();
}); |
« Next Oldest | Next Newest »
|