diff options
author | Bastien Wirtz <bastien.wirtz@gmail.com> | 2020-04-13 09:46:48 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-13 09:46:48 -0700 |
commit | d2bf5e5f62c2a8d94b27529424a96066ead3e5b1 (patch) | |
tree | f7934df7d7daae99b03441cad8f192aa7dbed033 /app.js | |
parent | 0503e77861fcdfeaf20e1cc06dbc2f49d06bc45b (diff) | |
parent | a4de4a3a71e460141b740564ef22d1c79760db4e (diff) | |
download | homer-d2bf5e5f62c2a8d94b27529424a96066ead3e5b1.tar.gz homer-d2bf5e5f62c2a8d94b27529424a96066ead3e5b1.tar.zst homer-d2bf5e5f62c2a8d94b27529424a96066ead3e5b1.zip |
Merge pull request #37 from jozefs/master
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() { |