summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/bg/js/search.js6
-rw-r--r--ext/fg/js/float.js4
-rw-r--r--ext/fg/js/frontend.js5
-rw-r--r--ext/fg/js/popup-proxy-host.js18
-rw-r--r--ext/fg/js/popup-proxy.js12
-rw-r--r--ext/fg/js/popup.js30
-rw-r--r--ext/mixed/js/display.js18
7 files changed, 48 insertions, 45 deletions
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js
index 7a8fdf5e..80519f4a 100644
--- a/ext/bg/js/search.js
+++ b/ext/bg/js/search.js
@@ -103,7 +103,11 @@ class DisplaySearch extends Display {
this.updateSearchButton();
if (valid) {
const {definitions} = await apiTermsFind(query, this.optionsContext);
- this.termsShow(definitions, this.options);
+ this.termsShow(definitions, {
+ focus: false,
+ sentence: null,
+ url: window.location.href
+ });
} else {
this.container.textContent = '';
}
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js
index d9b483d7..4a571466 100644
--- a/ext/fg/js/float.js
+++ b/ext/fg/js/float.js
@@ -143,8 +143,8 @@ DisplayFloat.onKeyDownHandlers = {
};
DisplayFloat.messageHandlers = {
- termsShow: (self, {definitions, options, context}) => self.termsShow(definitions, options, context),
- kanjiShow: (self, {definitions, options, context}) => self.kanjiShow(definitions, options, context),
+ termsShow: (self, {definitions, context}) => self.termsShow(definitions, context),
+ kanjiShow: (self, {definitions, context}) => self.kanjiShow(definitions, context),
clearAutoPlayTimer: (self) => self.clearAutoPlayTimer(),
orphaned: (self) => self.onOrphaned(),
initialize: (self, {options, popupInfo, url, childrenSupported}) => self.initialize(options, popupInfo, url, childrenSupported)
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index f67441af..52a23889 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -333,8 +333,7 @@ class Frontend {
if (textSource && this.options.scanning.modifier !== 'none') {
this.popup.showOrphaned(
textSource.getRect(),
- textSource.getWritingMode(),
- this.options
+ textSource.getWritingMode()
);
}
} else {
@@ -374,7 +373,6 @@ class Frontend {
textSource.getRect(),
textSource.getWritingMode(),
definitions,
- this.options,
{sentence, url, focus}
);
@@ -405,7 +403,6 @@ class Frontend {
textSource.getRect(),
textSource.getWritingMode(),
definitions,
- this.options,
{sentence, url, focus}
);
diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js
index c3acec7f..74a5153a 100644
--- a/ext/fg/js/popup-proxy-host.js
+++ b/ext/fg/js/popup-proxy-host.js
@@ -39,12 +39,12 @@ class PopupProxyHost {
this.apiReceiver = new FrontendApiReceiver(`popup-proxy-host#${frameId}`, {
createNestedPopup: ({parentId}) => this.createNestedPopup(parentId),
setOptions: ({id, options}) => this.setOptions(id, options),
- showOrphaned: ({id, elementRect, options}) => this.showOrphaned(id, elementRect, options),
+ showOrphaned: ({id, elementRect}) => this.showOrphaned(id, elementRect),
hide: ({id, changeFocus}) => this.hide(id, changeFocus),
setVisibleOverride: ({id, visible}) => this.setVisibleOverride(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),
- kanjiShow: ({id, elementRect, writingMode, definitions, options, context}) => this.kanjiShow(id, elementRect, writingMode, definitions, options, context),
+ termsShow: ({id, elementRect, writingMode, definitions, context}) => this.termsShow(id, elementRect, writingMode, definitions, context),
+ kanjiShow: ({id, elementRect, writingMode, definitions, context}) => this.kanjiShow(id, elementRect, writingMode, definitions, context),
clearAutoPlayTimer: ({id}) => this.clearAutoPlayTimer(id)
});
}
@@ -91,10 +91,10 @@ class PopupProxyHost {
return await popup.setOptions(options);
}
- async showOrphaned(id, elementRect, options) {
+ async showOrphaned(id, elementRect) {
const popup = this.getPopup(id);
elementRect = this.jsonRectToDOMRect(popup, elementRect);
- return await popup.showOrphaned(elementRect, options);
+ return await popup.showOrphaned(elementRect);
}
async hide(id, changeFocus) {
@@ -112,18 +112,18 @@ class PopupProxyHost {
return await popup.containsPoint(x, y);
}
- async termsShow(id, elementRect, writingMode, definitions, options, context) {
+ async termsShow(id, elementRect, writingMode, definitions, context) {
const popup = this.getPopup(id);
elementRect = this.jsonRectToDOMRect(popup, elementRect);
if (!PopupProxyHost.popupCanShow(popup)) { return false; }
- return await popup.termsShow(elementRect, writingMode, definitions, options, context);
+ return await popup.termsShow(elementRect, writingMode, definitions, context);
}
- async kanjiShow(id, elementRect, writingMode, definitions, options, context) {
+ async kanjiShow(id, elementRect, writingMode, definitions, context) {
const popup = this.getPopup(id);
elementRect = this.jsonRectToDOMRect(popup, elementRect);
if (!PopupProxyHost.popupCanShow(popup)) { return false; }
- return await popup.kanjiShow(elementRect, writingMode, definitions, options, context);
+ return await popup.kanjiShow(elementRect, writingMode, definitions, context);
}
async clearAutoPlayTimer(id) {
diff --git a/ext/fg/js/popup-proxy.js b/ext/fg/js/popup-proxy.js
index 96fc8890..e8d6bc98 100644
--- a/ext/fg/js/popup-proxy.js
+++ b/ext/fg/js/popup-proxy.js
@@ -51,10 +51,10 @@ class PopupProxy {
return await this.invokeHostApi('setOptions', {id, options});
}
- async showOrphaned(elementRect, options) {
+ async showOrphaned(elementRect) {
const id = await this.getPopupId();
elementRect = PopupProxy.DOMRectToJson(elementRect);
- return await this.invokeHostApi('showOrphaned', {id, elementRect, options});
+ return await this.invokeHostApi('showOrphaned', {id, elementRect});
}
async hide(changeFocus) {
@@ -76,16 +76,16 @@ class PopupProxy {
return await this.invokeHostApi('containsPoint', {id: this.id, x, y});
}
- async termsShow(elementRect, writingMode, definitions, options, context) {
+ async termsShow(elementRect, writingMode, definitions, context) {
const id = await this.getPopupId();
elementRect = PopupProxy.DOMRectToJson(elementRect);
- return await this.invokeHostApi('termsShow', {id, elementRect, writingMode, definitions, options, context});
+ return await this.invokeHostApi('termsShow', {id, elementRect, writingMode, definitions, context});
}
- async kanjiShow(elementRect, writingMode, definitions, options, context) {
+ async kanjiShow(elementRect, writingMode, definitions, context) {
const id = await this.getPopupId();
elementRect = PopupProxy.DOMRectToJson(elementRect);
- return await this.invokeHostApi('kanjiShow', {id, elementRect, writingMode, definitions, options, context});
+ return await this.invokeHostApi('kanjiShow', {id, elementRect, writingMode, definitions, context});
}
async clearAutoPlayTimer() {
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index a9fde7b6..f36bb436 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -41,14 +41,14 @@ class Popup {
this.updateVisibility();
}
- inject(options) {
+ inject() {
if (this.injectPromise === null) {
- this.injectPromise = this.createInjectPromise(options);
+ this.injectPromise = this.createInjectPromise();
}
return this.injectPromise;
}
- async createInjectPromise(options) {
+ async createInjectPromise() {
try {
const {frameId} = await this.frameIdPromise;
if (typeof frameId === 'number') {
@@ -62,7 +62,7 @@ class Popup {
const parentFrameId = (typeof this.frameId === 'number' ? this.frameId : null);
this.container.addEventListener('load', () => {
this.invokeApi('initialize', {
- options: options,
+ options: this.options,
popupInfo: {
id: this.id,
depth: this.depth,
@@ -87,10 +87,10 @@ class Popup {
this.options = options;
}
- async show(elementRect, writingMode, options) {
- await this.inject(options);
+ async show(elementRect, writingMode) {
+ await this.inject();
- const optionsGeneral = options.general;
+ const optionsGeneral = this.options.general;
const container = this.container;
const containerRect = container.getBoundingClientRect();
const getPosition = (
@@ -215,9 +215,9 @@ class Popup {
return [position, size, after];
}
- async showOrphaned(elementRect, writingMode, options) {
+ async showOrphaned(elementRect, writingMode) {
if (!this.isInitialized()) { return; }
- await this.show(elementRect, writingMode, options);
+ await this.show(elementRect, writingMode);
this.invokeApi('orphaned');
}
@@ -279,16 +279,16 @@ class Popup {
return false;
}
- async termsShow(elementRect, writingMode, definitions, options, context) {
+ async termsShow(elementRect, writingMode, definitions, context) {
if (!this.isInitialized()) { return; }
- await this.show(elementRect, writingMode, options);
- this.invokeApi('termsShow', {definitions, options, context});
+ await this.show(elementRect, writingMode);
+ this.invokeApi('termsShow', {definitions, context});
}
- async kanjiShow(elementRect, writingMode, definitions, options, context) {
+ async kanjiShow(elementRect, writingMode, definitions, context) {
if (!this.isInitialized()) { return; }
- await this.show(elementRect, writingMode, options);
- this.invokeApi('kanjiShow', {definitions, options, context});
+ await this.show(elementRect, writingMode);
+ this.invokeApi('kanjiShow', {definitions, context});
}
clearAutoPlayTimer() {
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index d5d055e0..b3ddae72 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -76,7 +76,7 @@ class Display {
}
const kanjiDefs = await apiKanjiFind(link.textContent, this.getOptionsContext());
- this.kanjiShow(kanjiDefs, this.options, context);
+ this.kanjiShow(kanjiDefs, context);
} catch (e) {
this.onError(e);
}
@@ -125,7 +125,7 @@ class Display {
context.source.source = this.context.source;
}
- this.termsShow(definitions, this.options, context);
+ this.termsShow(definitions, context);
} catch (e) {
this.onError(e);
}
@@ -239,10 +239,12 @@ class Display {
});
}
- async termsShow(definitions, options, context) {
+ async termsShow(definitions, context) {
if (!this.isInitialized()) { return; }
try {
+ const options = this.options;
+
this.setEventListenersActive(false);
if (!context || context.focus !== false) {
@@ -250,7 +252,6 @@ class Display {
}
this.definitions = definitions;
- this.options = options;
this.context = context;
const sequence = ++this.sequence;
@@ -280,7 +281,7 @@ class Display {
const {index, scroll} = context || {};
this.entryScrollIntoView(index || 0, scroll);
- if (this.options.audio.enabled && this.options.audio.autoPlay) {
+ if (options.audio.enabled && options.audio.autoPlay) {
this.autoPlayAudio();
}
@@ -292,10 +293,12 @@ class Display {
}
}
- async kanjiShow(definitions, options, context) {
+ async kanjiShow(definitions, context) {
if (!this.isInitialized()) { return; }
try {
+ const options = this.options;
+
this.setEventListenersActive(false);
if (!context || context.focus !== false) {
@@ -303,7 +306,6 @@ class Display {
}
this.definitions = definitions;
- this.options = options;
this.context = context;
const sequence = ++this.sequence;
@@ -415,7 +417,7 @@ class Display {
source: this.context.source.source
};
- this.termsShow(this.context.source.definitions, this.options, context);
+ this.termsShow(this.context.source.definitions, context);
}
}