diff options
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/Searcher.vue | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/components/Searcher.vue b/src/components/Searcher.vue index 4a252a0..43dd7bd 100644 --- a/src/components/Searcher.vue +++ b/src/components/Searcher.vue | |||
| @@ -1,6 +1,14 @@ | |||
| 1 | <template> | 1 | <template> |
| 2 | <div id="searcher"> | 2 | <div id="searcher"> |
| 3 | <input type="text" v-model='search' ref='input' @keydown="hotkeys" placeholder="Search!"> | 3 | <input |
| 4 | type="text" | ||
| 5 | v-model='search' | ||
| 6 | ref='input' | ||
| 7 | @keydown="hotkeys" | ||
| 8 | @blur="close()" | ||
| 9 | placeholder="Search!" | ||
| 10 | /> | ||
| 11 | |||
| 4 | <Sugestion | 12 | <Sugestion |
| 5 | v-for="sugestion in sugestions" | 13 | v-for="sugestion in sugestions" |
| 6 | :key="sugestion[0]" | 14 | :key="sugestion[0]" |
| @@ -41,6 +49,10 @@ export default { | |||
| 41 | this.sugestions = sugestions | 49 | this.sugestions = sugestions |
| 42 | }, | 50 | }, |
| 43 | 51 | ||
| 52 | close() { | ||
| 53 | this.$emit('close') | ||
| 54 | }, | ||
| 55 | |||
| 44 | change_current(a=1) { | 56 | change_current(a=1) { |
| 45 | let index = this.sugestions.findIndex(element => element===this.current) | 57 | let index = this.sugestions.findIndex(element => element===this.current) |
| 46 | let new_current = this.sugestions[index+a] | 58 | let new_current = this.sugestions[index+a] |
| @@ -61,8 +73,8 @@ export default { | |||
| 61 | hotkeys(e) { | 73 | hotkeys(e) { |
| 62 | switch(e.code) { | 74 | switch(e.code) { |
| 63 | case 'Escape': | 75 | case 'Escape': |
| 64 | this.$emit('close') | 76 | this.close() |
| 65 | break | 77 | break |
| 66 | case 'ArrowDown': | 78 | case 'ArrowDown': |
| 67 | e.preventDefault() | 79 | e.preventDefault() |
| 68 | this.change_current(1) | 80 | this.change_current(1) |
