aboutsummaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-07-25 09:58:06 -0400
committerGitHub <noreply@github.com>2020-07-25 09:58:06 -0400
commit4a43b41f79d46b8a677bbfb11c27d43e126e670f (patch)
tree93730428d5caaf8076f796349b9bf38e11ef8bfe /ext/bg
parent64ddb4d9011c3577bf70d746bc91787983ec12b5 (diff)
Set content refactor (#686)
* Simplify invoke * Pass isTerms instead of type * Update DisplaySearch.setContent to pass argument array * Simplify argument object structure for setContent * Move focus and disableHistory level * Always include focus and disableHistory options * Change disableHistory to history * Pass source text to setContent * Use consistent argument/object field order * Remove unused previous field * Combine logic for forward/back navigation
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/search.js29
1 files changed, 18 insertions, 11 deletions
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js
index b3e3ebca..93f45468 100644
--- a/ext/bg/js/search.js
+++ b/ext/bg/js/search.js
@@ -158,10 +158,10 @@ class DisplaySearch extends Display {
}
}
- async setContent(type, details) {
+ async setContent(...args) {
this._query.blur();
this._closePopups();
- return await super.setContent(type, details);
+ return await super.setContent(...args);
}
clearContent() {
@@ -171,12 +171,14 @@ class DisplaySearch extends Display {
// Private
- _onQueryParserSearch({type, definitions, sentence, cause}) {
- this.setContent(type, {
+ _onQueryParserSearch({type, definitions, sentence, cause, textSource}) {
+ this.setContent({
+ focus: false,
+ history: cause !== 'mouse',
+ type,
+ source: textSource.text(),
definitions,
context: {
- focus: false,
- disableHistory: cause === 'mouse',
sentence,
url: window.location.href
}
@@ -254,12 +256,17 @@ class DisplaySearch extends Display {
this._updateSearchButton();
if (valid) {
const {definitions} = await api.termsFind(query, details, this.getOptionsContext());
- this.setContent('terms', {definitions, context: {
+ this.setContent({
focus: false,
- disableHistory: true,
- sentence: {text: query, offset: 0},
- url: window.location.href
- }});
+ history: false,
+ definitions,
+ source: query,
+ type: 'terms',
+ context: {
+ sentence: {text: query, offset: 0},
+ url: window.location.href
+ }
+ });
} else {
this.clearContent();
}