aboutsummaryrefslogtreecommitdiff
path: root/ext/js/display/display.js
diff options
context:
space:
mode:
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) {