add dynamic theme switcher js utility
This commit is contained in:
parent
23d94e1335
commit
8cbded79db
@ -49,3 +49,30 @@ if (I18n) {
|
|||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
setupDatepicker(document.body);
|
setupDatepicker(document.body);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The following code should be moved to profile.julius as soon as the widget file is actually used.
|
||||||
|
*/
|
||||||
|
(function() {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var DEFAULT_THEME = 'theme--default';
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
|
||||||
|
var themeSwitcher = document.querySelector('#theme-select');
|
||||||
|
var currentTheme = DEFAULT_THEME;
|
||||||
|
|
||||||
|
if (themeSwitcher) {
|
||||||
|
currentTheme = 'theme--' + themeSwitcher.value;
|
||||||
|
themeSwitcher.addEventListener('input', function() {
|
||||||
|
|
||||||
|
var desiredTheme = 'theme--' + themeSwitcher.value;
|
||||||
|
document.body.classList.remove(currentTheme);
|
||||||
|
document.body.classList.add(desiredTheme);
|
||||||
|
currentTheme = desiredTheme;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
})();
|
||||||
|
|||||||
24
templates/profile.julius
Normal file
24
templates/profile.julius
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
(function() {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var DEFAULT_THEME = 'theme--default';
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
|
||||||
|
var themeSwitcher = document.querySelector('#theme-select');
|
||||||
|
var currentTheme = DEFAULT_THEME;
|
||||||
|
|
||||||
|
if (themeSwitcher) {
|
||||||
|
currentTheme = 'theme--' + themeSwitcher.value;
|
||||||
|
themeSwitcher.addEventListener('input', function() {
|
||||||
|
|
||||||
|
var desiredTheme = 'theme--' + themeSwitcher.value;
|
||||||
|
document.body.classList.remove(currentTheme);
|
||||||
|
document.body.classList.add(desiredTheme);
|
||||||
|
currentTheme = desiredTheme;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
})();
|
||||||
Reference in New Issue
Block a user