Create single function for how the frontend shows popup content
This commit is contained in:
parent
8ef57936d7
commit
14e48cf854
@ -53,10 +53,7 @@ class Frontend extends TextScanner {
|
|||||||
async onResize() {
|
async onResize() {
|
||||||
const textSource = this.textSourceCurrent;
|
const textSource = this.textSourceCurrent;
|
||||||
if (textSource !== null && await this.popup.isVisible()) {
|
if (textSource !== null && await this.popup.isVisible()) {
|
||||||
this._lastShowPromise = this.popup.showContent(
|
this._showPopupContent(textSource);
|
||||||
textSource.getRect(),
|
|
||||||
textSource.getWritingMode()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,11 +108,7 @@ class Frontend extends TextScanner {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (this._orphaned) {
|
if (this._orphaned) {
|
||||||
if (textSource !== null && this.options.scanning.modifier !== 'none') {
|
if (textSource !== null && this.options.scanning.modifier !== 'none') {
|
||||||
this._lastShowPromise = this.popup.showContent(
|
this._showPopupContent(textSource, 'orphaned');
|
||||||
textSource.getRect(),
|
|
||||||
textSource.getWritingMode(),
|
|
||||||
'orphaned'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.onError(e);
|
this.onError(e);
|
||||||
@ -132,9 +125,8 @@ class Frontend extends TextScanner {
|
|||||||
showContent(textSource, focus, definitions, type) {
|
showContent(textSource, focus, definitions, type) {
|
||||||
const sentence = docSentenceExtract(textSource, this.options.anki.sentenceExt);
|
const sentence = docSentenceExtract(textSource, this.options.anki.sentenceExt);
|
||||||
const url = window.location.href;
|
const url = window.location.href;
|
||||||
this._lastShowPromise = this.popup.showContent(
|
this._showPopupContent(
|
||||||
textSource.getRect(),
|
textSource,
|
||||||
textSource.getWritingMode(),
|
|
||||||
type,
|
type,
|
||||||
{definitions, context: {sentence, url, focus, disableHistory: true}}
|
{definitions, context: {sentence, url, focus, disableHistory: true}}
|
||||||
);
|
);
|
||||||
@ -180,6 +172,16 @@ class Frontend extends TextScanner {
|
|||||||
this.optionsContext.url = this.popup.url;
|
this.optionsContext.url = this.popup.url;
|
||||||
return this.optionsContext;
|
return this.optionsContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_showPopupContent(textSource, type=null, details=null) {
|
||||||
|
this._lastShowPromise = this.popup.showContent(
|
||||||
|
textSource.getRect(),
|
||||||
|
textSource.getWritingMode(),
|
||||||
|
type,
|
||||||
|
details
|
||||||
|
);
|
||||||
|
return this._lastShowPromise;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Frontend._windowMessageHandlers = new Map([
|
Frontend._windowMessageHandlers = new Map([
|
||||||
|
Loading…
Reference in New Issue
Block a user