diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-10-17 00:15:43 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-17 00:15:43 -0400 |
commit | ca4ed0300b06e8424f4c2e49ff8533a37883e850 (patch) | |
tree | 5c352e96130231977a9c4da066338f7198f80ac5 /ext/js/display/display-anki.js | |
parent | 75aabd983da29023b8423bd44d565202aad6b664 (diff) |
Display button updates (#1991)
* Update display buttons
* Remove use of _addMultipleEventListeners
Diffstat (limited to 'ext/js/display/display-anki.js')
-rw-r--r-- | ext/js/display/display-anki.js | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/ext/js/display/display-anki.js b/ext/js/display/display-anki.js index 46e88ae0..e30e29fc 100644 --- a/ext/js/display/display-anki.js +++ b/ext/js/display/display-anki.js @@ -168,11 +168,18 @@ class DisplayAnki { } _onContentUpdateEntry({element}) { - this._addMultipleEventListeners(element, '.action-view-tags', 'click', this._onShowTagsBind); - this._addMultipleEventListeners(element, '.action-add-note', 'click', this._onNoteAddBind); - this._addMultipleEventListeners(element, '.action-view-note', 'click', this._onViewNoteButtonClickBind); - this._addMultipleEventListeners(element, '.action-view-note', 'contextmenu', this._onViewNoteButtonContextMenuBind); - this._addMultipleEventListeners(element, '.action-view-note', 'menuClose', this._onViewNoteButtonMenuCloseBind); + const eventListeners = this._eventListeners; + for (const node of element.querySelectorAll('.action-button[data-action=view-tags]')) { + eventListeners.addEventListener(node, 'click', this._onShowTagsBind); + } + for (const node of element.querySelectorAll('.action-button[data-action=add-note]')) { + eventListeners.addEventListener(node, 'click', this._onNoteAddBind); + } + for (const node of element.querySelectorAll('.action-button[data-action=view-note]')) { + eventListeners.addEventListener(node, 'click', this._onViewNoteButtonClickBind); + eventListeners.addEventListener(node, 'contextmenu', this._onViewNoteButtonContextMenuBind); + eventListeners.addEventListener(node, 'menuClose', this._onViewNoteButtonMenuCloseBind); + } } _onContentUpdateComplete() { @@ -196,20 +203,14 @@ class DisplayAnki { this._showAnkiTagsNotification(tags); } - _addMultipleEventListeners(container, selector, ...args) { - for (const node of container.querySelectorAll(selector)) { - this._eventListeners.addEventListener(node, ...args); - } - } - _adderButtonFind(index, mode) { const entry = this._getEntry(index); - return entry !== null ? entry.querySelector(`.action-add-note[data-mode="${mode}"]`) : null; + return entry !== null ? entry.querySelector(`.action-button[data-action=add-note][data-mode="${mode}"]`) : null; } _tagsIndicatorFind(index) { const entry = this._getEntry(index); - return entry !== null ? entry.querySelector('.action-view-tags') : null; + return entry !== null ? entry.querySelector('.action-button[data-action=view-tags]') : null; } _getEntry(index) { @@ -672,7 +673,7 @@ class DisplayAnki { _getViewNoteButton(index) { const entry = this._getEntry(index); - return entry !== null ? entry.querySelector('.action-view-note') : null; + return entry !== null ? entry.querySelector('.action-button[data-action=view-note]') : null; } _viewNoteForSelectedEntry() { |