diff options
author | Jozef Selesi <jozef.selesi@sky.uk> | 2020-03-26 19:12:43 +0000 |
---|---|---|
committer | Jozef Selesi <jozef.selesi@sky.uk> | 2020-04-04 10:59:10 +0100 |
commit | a4de4a3a71e460141b740564ef22d1c79760db4e (patch) | |
tree | f7934df7d7daae99b03441cad8f192aa7dbed033 /app.js | |
parent | 0503e77861fcdfeaf20e1cc06dbc2f49d06bc45b (diff) | |
download | homer-a4de4a3a71e460141b740564ef22d1c79760db4e.tar.gz homer-a4de4a3a71e460141b740564ef22d1c79760db4e.tar.zst homer-a4de4a3a71e460141b740564ef22d1c79760db4e.zip |
Add keyboard shortcuts to navigate to the first search result.
Diffstat (limited to 'app.js')
-rw-r--r-- | app.js | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -84,6 +84,26 @@ const app = new Vue({ | |||
84 | }, | 84 | }, |
85 | toggleMenu: function() { | 85 | toggleMenu: function() { |
86 | this.showMenu = !this.showMenu; | 86 | this.showMenu = !this.showMenu; |
87 | }, | ||
88 | matchesFilter: function(item) { | ||
89 | return (item.name.toLowerCase().includes(this.filter.toLowerCase()) | ||
90 | || (item.tag && item.tag.toLowerCase().includes(this.filter.toLowerCase()))) | ||
91 | }, | ||
92 | firstMatchingService: function() { | ||
93 | for (group of this.config.services) { | ||
94 | for (item of group.items) { | ||
95 | if (this.matchesFilter(item)) { | ||
96 | return item; | ||
97 | } | ||
98 | } | ||
99 | } | ||
100 | return null; | ||
101 | }, | ||
102 | navigateToFirstService: function(target) { | ||
103 | service = this.firstMatchingService(); | ||
104 | if (service) { | ||
105 | window.open(service.url, target || service.target || '_self'); | ||
106 | } | ||
87 | } | 107 | } |
88 | }, | 108 | }, |
89 | mounted() { | 109 | mounted() { |