diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-07-24 16:03:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-24 16:03:11 -0400 |
commit | 3754c920410e90fc6b98aadc9f0dbe60dfa6a14d (patch) | |
tree | 80bf3a530f4c7cb0254fc8d06dc4c42e94d3039c /ext/bg/js/search.js | |
parent | 99f5655e534421aca110bcf9bcdbf899b001f0dc (diff) |
Query parser refactor (#683)
* Rename files to better match class name
* Don't pass setContent to QueryParser; use a generic event instead
Diffstat (limited to 'ext/bg/js/search.js')
-rw-r--r-- | ext/bg/js/search.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 5be71555..b3e3ebca 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -40,7 +40,6 @@ class DisplaySearch extends Display { }); this._queryParser = new QueryParser({ getOptionsContext: this.getOptionsContext.bind(this), - setContent: this.setContent.bind(this), setSpinnerVisible: this.setSpinnerVisible.bind(this) }); this._onKeyDownIgnoreKeys = new Map([ @@ -67,6 +66,9 @@ class DisplaySearch extends Display { await this.updateOptions(); yomichan.on('optionsUpdated', () => this.updateOptions()); await this._queryParser.prepare(); + + this._queryParser.on('searched', this._onQueryParserSearch.bind(this)); + const options = this.getOptions(); const {queryParams: {query='', mode=''}} = parseUrl(window.location.href); @@ -169,6 +171,18 @@ class DisplaySearch extends Display { // Private + _onQueryParserSearch({type, definitions, sentence, cause}) { + this.setContent(type, { + definitions, + context: { + focus: false, + disableHistory: cause === 'mouse', + sentence, + url: window.location.href + } + }); + } + _onSearchInput() { this._updateSearchButton(); |