mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Cleanup a bit of javascript
This commit is contained in:
parent
0b8ec5c664
commit
938c209869
3 changed files with 54 additions and 48 deletions
|
|
@ -6,6 +6,7 @@ import { i18n } from 'Common/Translator';
|
||||||
import { SettingsCapa } from 'Common/Globals';
|
import { SettingsCapa } from 'Common/Globals';
|
||||||
|
|
||||||
import { ThemeStore, convertThemeName, changeTheme } from 'Stores/Theme';
|
import { ThemeStore, convertThemeName, changeTheme } from 'Stores/Theme';
|
||||||
|
import { addSubscribablesTo } from 'External/ko';
|
||||||
|
|
||||||
import Remote from 'Remote/User/Fetch';
|
import Remote from 'Remote/User/Fetch';
|
||||||
|
|
||||||
|
|
@ -24,20 +25,22 @@ export class UserSettingsThemes /*extends AbstractViewSettings*/ {
|
||||||
this.fontSansSerif = ThemeStore.fontSansSerif;
|
this.fontSansSerif = ThemeStore.fontSansSerif;
|
||||||
this.fontSerif = ThemeStore.fontSerif;
|
this.fontSerif = ThemeStore.fontSerif;
|
||||||
this.fontMono = ThemeStore.fontMono;
|
this.fontMono = ThemeStore.fontMono;
|
||||||
ThemeStore.fontSansSerif.subscribe(value => {
|
addSubscribablesTo(ThemeStore, {
|
||||||
|
fontSansSerif: value => {
|
||||||
Remote.saveSettings(null, {
|
Remote.saveSettings(null, {
|
||||||
fontSansSerif: value
|
fontSansSerif: value
|
||||||
});
|
});
|
||||||
});
|
},
|
||||||
ThemeStore.fontSerif.subscribe(value => {
|
fontSerif: value => {
|
||||||
Remote.saveSettings(null, {
|
Remote.saveSettings(null, {
|
||||||
fontSerif: value
|
fontSerif: value
|
||||||
});
|
});
|
||||||
});
|
},
|
||||||
ThemeStore.fontMono.subscribe(value => {
|
fontMono: value => {
|
||||||
Remote.saveSettings(null, {
|
Remote.saveSettings(null, {
|
||||||
fontMono: value
|
fontMono: value
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.theme = ThemeStore.theme;
|
this.theme = ThemeStore.theme;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { $htmlCL, appEl, elementById, leftPanelDisabled, Settings, SettingsGet }
|
||||||
import { isArray, arrayLength } from 'Common/Utils';
|
import { isArray, arrayLength } from 'Common/Utils';
|
||||||
import { cssLink, serverRequestRaw } from 'Common/Links';
|
import { cssLink, serverRequestRaw } from 'Common/Links';
|
||||||
import { SaveSettingStatus } from 'Common/Enums';
|
import { SaveSettingStatus } from 'Common/Enums';
|
||||||
|
import { addSubscribablesTo } from 'External/ko';
|
||||||
|
|
||||||
let __themeTimer = 0;
|
let __themeTimer = 0;
|
||||||
|
|
||||||
|
|
@ -60,9 +61,10 @@ export const
|
||||||
|
|
||||||
convertThemeName = theme => theme.replace(/@[a-z]+$/, '').replace(/([A-Z])/g, ' $1').trim();
|
convertThemeName = theme => theme.replace(/@[a-z]+$/, '').replace(/([A-Z])/g, ' $1').trim();
|
||||||
|
|
||||||
ThemeStore.isMobile.subscribe(value => $htmlCL.toggle('rl-mobile', value));
|
addSubscribablesTo(ThemeStore, {
|
||||||
|
isMobile: value => $htmlCL.toggle('rl-mobile', value),
|
||||||
|
|
||||||
ThemeStore.fontSansSerif.subscribe(value => {
|
fontSansSerif: value => {
|
||||||
if (null != value) {
|
if (null != value) {
|
||||||
let cl = appEl.classList;
|
let cl = appEl.classList;
|
||||||
cl.forEach(name => {
|
cl.forEach(name => {
|
||||||
|
|
@ -72,23 +74,26 @@ ThemeStore.fontSansSerif.subscribe(value => {
|
||||||
});
|
});
|
||||||
value && cl.add('font'+value);
|
value && cl.add('font'+value);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
ThemeStore.fontSerif.subscribe(value => {
|
|
||||||
|
fontSerif: value => {
|
||||||
if (null != value) {
|
if (null != value) {
|
||||||
let cl = appEl.classList;
|
let cl = appEl.classList;
|
||||||
cl.forEach(name => name.startsWith('fontSerif') && cl.remove(name));
|
cl.forEach(name => name.startsWith('fontSerif') && cl.remove(name));
|
||||||
value && cl.add('fontSerif'+value);
|
value && cl.add('fontSerif'+value);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
ThemeStore.fontMono.subscribe(value => {
|
|
||||||
|
fontMono: value => {
|
||||||
if (null != value) {
|
if (null != value) {
|
||||||
let cl = appEl.classList;
|
let cl = appEl.classList;
|
||||||
cl.forEach(name => name.startsWith('fontMono') && cl.remove(name));
|
cl.forEach(name => name.startsWith('fontMono') && cl.remove(name));
|
||||||
value && cl.add('fontMono'+value);
|
value && cl.add('fontMono'+value);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
|
||||||
ThemeStore.userBackgroundHash.subscribe(value => {
|
userBackgroundHash: value => {
|
||||||
appEl.classList.toggle('UserBackground', !!value);
|
appEl.classList.toggle('UserBackground', !!value);
|
||||||
appEl.style.backgroundImage = value ? "url("+serverRequestRaw('UserBackground', value)+")" : null;
|
appEl.style.backgroundImage = value ? "url("+serverRequestRaw('UserBackground', value)+")" : null;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
8
dev/prototype.js
vendored
8
dev/prototype.js
vendored
|
|
@ -53,7 +53,7 @@
|
||||||
return function(...args) {
|
return function(...args) {
|
||||||
timer && clearTimeout(timer);
|
timer && clearTimeout(timer);
|
||||||
timer = setTimeout(()=>{
|
timer = setTimeout(()=>{
|
||||||
func.apply(this, args)
|
func.apply(this, args);
|
||||||
timer = 0;
|
timer = 0;
|
||||||
}, ms);
|
}, ms);
|
||||||
};
|
};
|
||||||
|
|
@ -68,12 +68,10 @@
|
||||||
Function.prototype.throttle = function(ms) {
|
Function.prototype.throttle = function(ms) {
|
||||||
let func = this, timer;
|
let func = this, timer;
|
||||||
return function(...args) {
|
return function(...args) {
|
||||||
if (!timer) {
|
timer = timer || setTimeout(()=>{
|
||||||
timer = setTimeout(()=>{
|
func.apply(this, args);
|
||||||
func.apply(this, args)
|
|
||||||
timer = 0;
|
timer = 0;
|
||||||
}, ms);
|
}, ms);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue