centralize elementById('rl-app')

This commit is contained in:
the-djmaze 2023-02-20 15:47:46 +01:00
parent ec3e99c6ab
commit 8a8d1d756e
4 changed files with 31 additions and 32 deletions

View file

@ -1,5 +1,5 @@
import ko from 'ko';
import { $htmlCL, elementById, leftPanelDisabled, Settings, SettingsGet } from 'Common/Globals';
import { $htmlCL, appEl, elementById, leftPanelDisabled, Settings, SettingsGet } from 'Common/Globals';
import { isArray, arrayLength } from 'Common/Utils';
import { cssLink, serverRequestRaw } from 'Common/Links';
import { SaveSettingStatus } from 'Common/Enums';
@ -7,8 +7,6 @@ import { SaveSettingStatus } from 'Common/Enums';
let __themeTimer = 0;
export const
appEl = () => elementById('rl-app'),
ThemeStore = {
theme: ko.observable(''),
themes: ko.observableArray(),
@ -66,7 +64,7 @@ ThemeStore.isMobile.subscribe(value => $htmlCL.toggle('rl-mobile', value));
ThemeStore.fontSansSerif.subscribe(value => {
if (null != value) {
let cl = appEl().classList;
let cl = appEl.classList;
cl.forEach(name => {
if (name.startsWith('font') && !/font(Serif|Mono)/.test(name)) {
cl.remove(name);
@ -77,20 +75,20 @@ ThemeStore.fontSansSerif.subscribe(value => {
});
ThemeStore.fontSerif.subscribe(value => {
if (null != value) {
let cl = appEl().classList;
let cl = appEl.classList;
cl.forEach(name => name.startsWith('fontSerif') && cl.remove(name));
value && cl.add('fontSerif'+value);
}
});
ThemeStore.fontMono.subscribe(value => {
if (null != value) {
let cl = appEl().classList;
let cl = appEl.classList;
cl.forEach(name => name.startsWith('fontMono') && cl.remove(name));
value && cl.add('fontMono'+value);
}
});
ThemeStore.userBackgroundHash.subscribe(value => {
appEl().classList.toggle('UserBackground', !!value);
appEl().style.backgroundImage = value ? "url("+serverRequestRaw('UserBackground', value)+")" : null;
appEl.classList.toggle('UserBackground', !!value);
appEl.style.backgroundImage = value ? "url("+serverRequestRaw('UserBackground', value)+")" : null;
});