summaryrefslogtreecommitdiff
path: root/ext/fg/js/frontend.js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2020-04-11 15:32:04 +0300
committersiikamiika <siikamiika@users.noreply.github.com>2020-04-11 21:04:30 +0300
commitd93e3e1a6727e23547c44d4fc3b82244f560c459 (patch)
treec76d8871ca94499fd292280f64a2378d4b9fda07 /ext/fg/js/frontend.js
parent275f455e73c48294aeefd6c02959b1ddd3cbf4e8 (diff)
use setters instead of EventDispatcher
Diffstat (limited to 'ext/fg/js/frontend.js')
-rw-r--r--ext/fg/js/frontend.js36
1 files changed, 15 insertions, 21 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index cd811115..288d3589 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -26,7 +26,7 @@
*/
class Frontend extends TextScanner {
- constructor(popup, initEventDispatcher=null) {
+ constructor(popup) {
super(
window,
() => this.popup.isProxy() ? [] : [this.popup.getContainer()],
@@ -35,7 +35,6 @@ class Frontend extends TextScanner {
);
this.popup = popup;
- this.initEventDispatcher = initEventDispatcher;
this._disabledOverride = false;
@@ -77,11 +76,6 @@ class Frontend extends TextScanner {
window.visualViewport.addEventListener('resize', this.onVisualViewportResize.bind(this));
}
- if (this.initEventDispatcher !== null) {
- this.initEventDispatcher.on('setDisabledOverride', this.onSetDisabledOverride.bind(this));
- this.initEventDispatcher.on('popupChange', this.onPopupChange.bind(this));
- }
-
yomichan.on('orphaned', this.onOrphaned.bind(this));
yomichan.on('optionsUpdated', this.updateOptions.bind(this));
yomichan.on('zoomChanged', this.onZoomChanged.bind(this));
@@ -142,6 +136,20 @@ class Frontend extends TextScanner {
];
}
+ setDisabledOverride(disabled) {
+ this._disabledOverride = disabled;
+ // other cases handed by regular options update
+ if (disabled && this.enabled) {
+ this.setEnabled(false);
+ }
+ }
+
+ async setPopup(popup) {
+ this.onSearchClear(true);
+ this.popup = popup;
+ await popup.setOptions(this.options);
+ }
+
async updateOptions() {
this.setOptions(await apiOptionsGet(this.getOptionsContext()));
@@ -237,20 +245,6 @@ class Frontend extends TextScanner {
super.onSearchClear(changeFocus);
}
- onSetDisabledOverride({disabled}) {
- this._disabledOverride = disabled;
- // other cases handed by regular options update
- if (disabled && this.enabled) {
- this.setEnabled(false);
- }
- }
-
- async onPopupChange({popup}) {
- this.onSearchClear(true);
- this.popup = popup;
- await popup.setOptions(this.options);
- }
-
getOptionsContext() {
this.optionsContext.url = this.popup.url;
return this.optionsContext;