diff options
author | StefanVukovic99 <stefanvukovic44@gmail.com> | 2024-06-03 19:25:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-03 17:25:51 +0000 |
commit | 7955fc85ac089d856b44bdea78eccd26ffbd690c (patch) | |
tree | 6a7cfc6464612f9f129b25fa59a46f9c7c0e72b5 /ext/js/display/display.js | |
parent | d2fce502ecb00e3c9202295c93fbb8c554ddbd69 (diff) |
display inflection rule descriptions (#1000)24.6.3.0
* load descriptions in deinflector
* description functions in deinflectors
* show descriptions in title
* use toaster
* use names without internal
* css lint
* reformat transform descriptors
* fix merge errors
* done?
* rename method
Diffstat (limited to 'ext/js/display/display.js')
-rw-r--r-- | ext/js/display/display.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/ext/js/display/display.js b/ext/js/display/display.js index dc6b4713..82d84979 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -162,6 +162,8 @@ export class Display extends EventDispatcher { this._contentTextScanner = null; /** @type {?import('./display-notification.js').DisplayNotification} */ this._tagNotification = null; + /** @type {?import('./display-notification.js').DisplayNotification} */ + this._inflectionNotification = null; /** @type {HTMLElement} */ this._footerNotificationContainer = querySelectorNotNull(document, '#content-footer'); /** @type {OptionToggleHotkeyHandler} */ @@ -181,6 +183,8 @@ export class Display extends EventDispatcher { /** @type {(event: MouseEvent) => void} */ this._onTagClickBind = this._onTagClick.bind(this); /** @type {(event: MouseEvent) => void} */ + this._onInflectionClickBind = this._onInflectionClick.bind(this); + /** @type {(event: MouseEvent) => void} */ this._onMenuButtonClickBind = this._onMenuButtonClick.bind(this); /** @type {(event: import('popup-menu').MenuCloseEvent) => void} */ this._onMenuButtonMenuCloseBind = this._onMenuButtonMenuClose.bind(this); @@ -1026,6 +1030,14 @@ export class Display extends EventDispatcher { /** * @param {MouseEvent} e */ + _onInflectionClick(e) { + const node = /** @type {HTMLElement} */ (e.currentTarget); + this._showInflectionNotification(node); + } + + /** + * @param {MouseEvent} e + */ _onMenuButtonClick(e) { const node = /** @type {HTMLElement} */ (e.currentTarget); @@ -1086,6 +1098,21 @@ export class Display extends EventDispatcher { } /** + * @param {HTMLSpanElement} inflectionNode + */ + _showInflectionNotification(inflectionNode) { + const description = inflectionNode.title; + if (!description || !(inflectionNode instanceof HTMLSpanElement)) { return; } + + if (this._inflectionNotification === null) { + this._inflectionNotification = this.createNotification(true); + } + + this._inflectionNotification.setContent(description); + this._inflectionNotification.open(); + } + + /** * @param {boolean} animate */ _hideTagNotification(animate) { @@ -1797,6 +1824,9 @@ export class Display extends EventDispatcher { for (const node of entry.querySelectorAll('.headword-kanji-link')) { eventListeners.addEventListener(node, 'click', this._onKanjiLookupBind); } + for (const node of entry.querySelectorAll('.inflection[data-reason]')) { + eventListeners.addEventListener(node, 'click', this._onInflectionClickBind); + } for (const node of entry.querySelectorAll('.tag-label')) { eventListeners.addEventListener(node, 'click', this._onTagClickBind); } |