summaryrefslogtreecommitdiff
path: root/ext/js/display/display.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-10-17 00:15:43 -0400
committerGitHub <noreply@github.com>2021-10-17 00:15:43 -0400
commitca4ed0300b06e8424f4c2e49ff8533a37883e850 (patch)
tree5c352e96130231977a9c4da066338f7198f80ac5 /ext/js/display/display.js
parent75aabd983da29023b8423bd44d565202aad6b664 (diff)
Display button updates (#1991)
* Update display buttons * Remove use of _addMultipleEventListeners
Diffstat (limited to 'ext/js/display/display.js')
-rw-r--r--ext/js/display/display.js25
1 files changed, 15 insertions, 10 deletions
diff --git a/ext/js/display/display.js b/ext/js/display/display.js
index 882d69c9..a5c3f980 100644
--- a/ext/js/display/display.js
+++ b/ext/js/display/display.js
@@ -107,6 +107,10 @@ class Display extends EventDispatcher {
this._optionToggleHotkeyHandler = new OptionToggleHotkeyHandler(this);
this._elementOverflowController = new ElementOverflowController();
this._frameVisible = (pageType === 'search');
+ this._onEntryClickBind = this._onEntryClick.bind(this);
+ this._onKanjiLookupBind = this._onKanjiLookup.bind(this);
+ this._onDebugLogClickBind = this._onDebugLogClick.bind(this);
+ this._onTagClickBind = this._onTagClick.bind(this);
this._hotkeyHandler.registerActions([
['close', () => { this._onHotkeyClose(); }],
@@ -1353,17 +1357,18 @@ class Display extends EventDispatcher {
parent.removeChild(textarea);
}
- _addMultipleEventListeners(container, selector, ...args) {
- for (const node of container.querySelectorAll(selector)) {
- this._eventListeners.addEventListener(node, ...args);
- }
- }
-
_addEntryEventListeners(entry) {
- this._eventListeners.addEventListener(entry, 'click', this._onEntryClick.bind(this));
- this._addMultipleEventListeners(entry, '.headword-kanji-link', 'click', this._onKanjiLookup.bind(this));
- this._addMultipleEventListeners(entry, '.debug-log-link', 'click', this._onDebugLogClick.bind(this));
- this._addMultipleEventListeners(entry, '.tag-label', 'click', this._onTagClick.bind(this));
+ const eventListeners = this._eventListeners;
+ eventListeners.addEventListener(entry, 'click', this._onEntryClickBind);
+ for (const node of entry.querySelectorAll('.headword-kanji-link')) {
+ eventListeners.addEventListener(node, 'click', this._onKanjiLookupBind);
+ }
+ for (const node of entry.querySelectorAll('.debug-log-link')) {
+ eventListeners.addEventListener(node, 'click', this._onDebugLogClickBind);
+ }
+ for (const node of entry.querySelectorAll('.tag-label')) {
+ eventListeners.addEventListener(node, 'click', this._onTagClickBind);
+ }
}
_updateContentTextScanner(options) {