diff options
Diffstat (limited to 'ext/fg')
-rw-r--r-- | ext/fg/float.html | 2 | ||||
-rw-r--r-- | ext/fg/js/float.js | 18 | ||||
-rw-r--r-- | ext/fg/js/frontend.js | 14 | ||||
-rw-r--r-- | ext/fg/js/popup-proxy-host.js | 6 | ||||
-rw-r--r-- | ext/fg/js/popup-proxy.js | 4 | ||||
-rw-r--r-- | ext/fg/js/popup.js | 21 |
6 files changed, 39 insertions, 26 deletions
diff --git a/ext/fg/float.html b/ext/fg/float.html index 465db589..52c7faa3 100644 --- a/ext/fg/float.html +++ b/ext/fg/float.html @@ -31,7 +31,6 @@ </div> </div> - <script src="/mixed/lib/jquery.min.js"></script> <script src="/mixed/lib/wanakana.min.js"></script> <script src="/mixed/js/extension.js"></script> @@ -41,6 +40,7 @@ <script src="/fg/js/document.js"></script> <script src="/fg/js/source.js"></script> <script src="/mixed/js/display.js"></script> + <script src="/mixed/js/scroll.js"></script> <script src="/fg/js/float.js"></script> diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index fd7986b8..2e952efb 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -19,7 +19,7 @@ class DisplayFloat extends Display { constructor() { - super($('#spinner'), $('#definitions')); + super(document.querySelector('#spinner'), document.querySelector('#definitions')); this.autoPlayAudioTimer = null; this.styleNode = null; @@ -30,7 +30,7 @@ class DisplayFloat extends Display { this.dependencies = Object.assign({}, this.dependencies, {docRangeFromPoint, docSentenceExtract}); - $(window).on('message', utilAsync(this.onMessage.bind(this))); + window.addEventListener('message', (e) => this.onMessage(e), false); } onError(error) { @@ -42,8 +42,16 @@ class DisplayFloat extends Display { } onOrphaned() { - $('#definitions').hide(); - $('#error-orphaned').show(); + const definitions = document.querySelector('#definitions'); + const errorOrphaned = document.querySelector('#error-orphaned'); + + if (definitions !== null) { + definitions.style.setProperty('display', 'none', 'important'); + } + + if (errorOrphaned !== null) { + errorOrphaned.style.setProperty('display', 'block', 'important'); + } } onSearchClear() { @@ -86,7 +94,7 @@ class DisplayFloat extends Display { } }; - const {action, params} = e.originalEvent.data; + const {action, params} = e.data; const handler = handlers[action]; if (handler) { handler(params); diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 167e82c0..d5bb00c0 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -128,7 +128,7 @@ class Frontend { } this.popupTimerClear(); - this.searchClear(); + this.searchClear(true); } onMouseOut(e) { @@ -138,7 +138,7 @@ class Frontend { onFrameMessage(e) { const handlers = { popupClose: () => { - this.searchClear(); + this.searchClear(true); }, selectionCopy: () => { @@ -153,7 +153,7 @@ class Frontend { } onResize() { - this.searchClear(); + this.searchClear(true); } onClick(e) { @@ -265,7 +265,7 @@ class Frontend { async updateOptions() { this.options = await apiOptionsGet(this.getOptionsContext()); if (!this.options.enable) { - this.searchClear(); + this.searchClear(false); } } @@ -320,7 +320,7 @@ class Frontend { textSource.cleanup(); } if (hideResults && this.options.scanning.autoHideResults) { - this.searchClear(); + this.searchClear(true); } this.pendingLookup = false; @@ -392,8 +392,8 @@ class Frontend { return true; } - searchClear() { - this.popup.hide(); + searchClear(changeFocus) { + this.popup.hide(changeFocus); this.popup.clearAutoPlayTimer(); if (this.options.scanning.selectText && this.textSourceLast) { diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js index 396f7556..cb9741be 100644 --- a/ext/fg/js/popup-proxy-host.js +++ b/ext/fg/js/popup-proxy-host.js @@ -40,7 +40,7 @@ class PopupProxyHost { createNestedPopup: ({parentId}) => this.createNestedPopup(parentId), show: ({id, elementRect, options}) => this.show(id, elementRect, options), showOrphaned: ({id, elementRect, options}) => this.show(id, elementRect, options), - hide: ({id}) => this.hide(id), + hide: ({id, changeFocus}) => this.hide(id, changeFocus), setVisible: ({id, visible}) => this.setVisible(id, visible), containsPoint: ({id, x, y}) => this.containsPoint(id, x, y), termsShow: ({id, elementRect, writingMode, definitions, options, context}) => this.termsShow(id, elementRect, writingMode, definitions, options, context), @@ -98,9 +98,9 @@ class PopupProxyHost { return await popup.showOrphaned(elementRect, options); } - async hide(id) { + async hide(id, changeFocus) { const popup = this.getPopup(id); - return popup.hide(); + return popup.hide(changeFocus); } async setVisible(id, visible) { diff --git a/ext/fg/js/popup-proxy.js b/ext/fg/js/popup-proxy.js index 235e1730..072cebc9 100644 --- a/ext/fg/js/popup-proxy.js +++ b/ext/fg/js/popup-proxy.js @@ -58,11 +58,11 @@ class PopupProxy { return await this.invokeHostApi('showOrphaned', {id, elementRect, options}); } - async hide() { + async hide(changeFocus) { if (this.id === null) { return; } - return await this.invokeHostApi('hide', {id: this.id}); + return await this.invokeHostApi('hide', {id: this.id, changeFocus}); } async setVisible(visible) { diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index 08965084..64da9aef 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -105,7 +105,7 @@ class Popup { container.style.height = `${height}px`; container.style.visibility = 'visible'; - this.hideChildren(); + this.hideChildren(true); } static getPositionForHorizontalText(elementRect, width, height, maxWidth, maxHeight, optionsGeneral) { @@ -206,16 +206,21 @@ class Popup { this.invokeApi('orphaned'); } - hide() { - this.hideChildren(); + hide(changeFocus) { + if (this.isContainerHidden()) { + changeFocus = false; + } + this.hideChildren(changeFocus); this.hideContainer(); - this.focusParent(); + if (changeFocus) { + this.focusParent(); + } } - hideChildren() { - // recursively hides all children - if (this.child && !this.child.isContainerHidden()) { - this.child.hide(); + hideChildren(changeFocus) { + // Recursively hides all children. + if (this.child !== null && !this.child.isContainerHidden()) { + this.child.hide(changeFocus); } } |