summaryrefslogtreecommitdiff
path: root/ext/bg/js/display-window.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-08-05 19:11:06 -0700
committerAlex Yatskov <alex@foosoft.net>2017-08-05 19:11:06 -0700
commitdfecef1f23435c933237794de6665f6fbacf90ec (patch)
tree5f14e45c7a569ec9850813bde0f3f6d829927680 /ext/bg/js/display-window.js
parent8e1c6776d1a6149c222ac0bda6b7b0d373453d11 (diff)
more cleanup
Diffstat (limited to 'ext/bg/js/display-window.js')
-rw-r--r--ext/bg/js/display-window.js19
1 files changed, 11 insertions, 8 deletions
diff --git a/ext/bg/js/display-window.js b/ext/bg/js/display-window.js
index 1f607510..52c0cafa 100644
--- a/ext/bg/js/display-window.js
+++ b/ext/bg/js/display-window.js
@@ -21,12 +21,11 @@ window.displayWindow = new class extends Display {
constructor() {
super($('#spinner'), $('#content'));
- const search = $('#search');
- search.click(this.onSearch.bind(this));
+ this.search = $('#search').click(this.onSearch.bind(this));
+ this.query = $('#query').on('input', this.inputSearch.bind(this));
+ this.intro = $('#intro');
- const query = $('#query');
- query.on('input', () => search.prop('disabled', query.val().length === 0));
- window.wanakana.bind(query.get(0));
+ window.wanakana.bind(this.query.get(0));
}
handleError(error) {
@@ -34,15 +33,19 @@ window.displayWindow = new class extends Display {
}
clearSearch() {
- $('#query').focus().select();
+ this.query.focus().select();
+ }
+
+ inputSearch() {
+ this.search.prop('disabled', this.query.val().length === 0);
}
async onSearch(e) {
e.preventDefault();
try {
- $('#intro').slideUp();
- const {length, definitions} = await apiTermsFind($('#query').val());
+ this.intro.slideUp();
+ const {length, definitions} = await apiTermsFind(this.query.val());
super.showTermDefs(definitions, await apiOptionsGet());
} catch (e) {
this.handleError(e);