Simplify event to use bind
This commit is contained in:
parent
2d109c3e56
commit
fdfc2d33bb
@ -46,10 +46,7 @@ class SettingsPopupPreview {
|
|||||||
// Setup events
|
// Setup events
|
||||||
window.addEventListener('message', this.onMessage.bind(this), false);
|
window.addEventListener('message', this.onMessage.bind(this), false);
|
||||||
|
|
||||||
const themeDarkCheckbox = document.querySelector('#theme-dark-checkbox');
|
document.querySelector('#theme-dark-checkbox').addEventListener('change', this.onThemeDarkCheckboxChanged.bind(this), false);
|
||||||
if (themeDarkCheckbox !== null) {
|
|
||||||
themeDarkCheckbox.addEventListener('change', () => this.onThemeDarkCheckboxChanged(themeDarkCheckbox), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Overwrite API functions
|
// Overwrite API functions
|
||||||
window.apiOptionsGet = this.apiOptionsGet.bind(this);
|
window.apiOptionsGet = this.apiOptionsGet.bind(this);
|
||||||
@ -113,8 +110,8 @@ class SettingsPopupPreview {
|
|||||||
handler(params);
|
handler(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
onThemeDarkCheckboxChanged(node) {
|
onThemeDarkCheckboxChanged(e) {
|
||||||
document.documentElement.classList.toggle('dark', node.checked);
|
document.documentElement.classList.toggle('dark', e.target.checked);
|
||||||
if (this.themeChangeTimeout !== null) {
|
if (this.themeChangeTimeout !== null) {
|
||||||
clearTimeout(this.themeChangeTimeout);
|
clearTimeout(this.themeChangeTimeout);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user