mirror of
https://github.com/rottenwheel/revuo-weekly.git
synced 2024-12-22 07:40:24 +00:00
fix saving of mobile theme, add IE compatibility
This commit is contained in:
parent
38301f8715
commit
35203f4eda
1 changed files with 11 additions and 3 deletions
14
js/main.js
14
js/main.js
|
@ -67,12 +67,20 @@ if (document.body.clientWidth < 940) {
|
|||
]
|
||||
]
|
||||
|
||||
// Switch the theme when the theme switcher is clicked.
|
||||
themeSwitcher.addEventListener('change', () => {
|
||||
const checkMobileTheme = () => {
|
||||
const theme = themeVariables[themeSwitcher.checked ? 1 : 0];
|
||||
|
||||
theme.forEach(variable => {
|
||||
document.documentElement.style.setProperty(`--${variable.name}`, variable.value);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// Ensure IE compatibility
|
||||
if (document.addEventListener) {
|
||||
themeSwitcher.addEventListener('change', checkMobileTheme);
|
||||
} else if (document.attachEvent) {
|
||||
themeSwitcher.attachEvent('onchange', checkMobileTheme);
|
||||
}
|
||||
|
||||
checkMobileTheme();
|
||||
}
|
Loading…
Reference in a new issue