Closes #174.
Unified · Split
| @@ -123,6 +123,9 @@ class app.Shortcuts · 122 unmodified lines | ||
| 123 | 123 | when 82 |
| 124 | 124 | @trigger 'altR' |
| 125 | 125 | false |
| 126 | + when 83 | |
| 127 | + @trigger 'altS' | |
| 128 | + false | |
| 126 | 129 | |
| 127 | 130 | handleKeypressEvent: (event) -> |
| 128 | 131 | if event.which is 63 and not event.target.value |
| @@ -87,6 +87,9 @@ app.templates.helpPage = """ · 86 unmodified lines | ||
| 87 | 87 | <dt class="_shortcuts-dt"> |
| 88 | 88 | <code class="_shortcut-code">alt + g</code> |
| 89 | 89 | <dd class="_shortcuts-dd">Search on Google |
| 90 | + <dt class="_shortcuts-dt"> | |
| 91 | + <code class="_shortcut-code">alt + s</code> | |
| 92 | + <dd class="_shortcuts-dd">Search on Stack Overflow | |
| 90 | 93 | <dt class="_shortcuts-dt"> |
| 91 | 94 | <code class="_shortcut-code">escape</code> |
| 92 | 95 | <dd class="_shortcuts-dd">Reset<br>(press twice in single doc mode) |
| @@ -16,6 +16,7 @@ class app.views.Search extends app.View · 15 unmodified lines | ||
| 16 | 16 | @shortcuts: |
| 17 | 17 | typing: 'autoFocus' |
| 18 | 18 | altG: 'google' |
| 19 | + altS: 'stackoverflow' | |
| 19 | 20 | |
| 20 | 21 | @routes: |
| 21 | 22 | root: 'onRoot' |
| @@ -86,12 +87,21 @@ class app.views.Search extends app.View · 64 unmodified lines | ||
| 86 | 87 | @removeClass @constructor.activeClass |
| 87 | 88 | @trigger 'clear' |
| 88 | 89 | |
| 89 | − google: => | |
| 90 | − if @value | |
| 91 | − $.popup "https://www.google.com/search?q=#{encodeURIComponent @value}" | |
| 90 | + externalSearch: (url) -> | |
| 91 | + if value = @value | |
| 92 | + value = "#{@scope.name()} #{value}" if @scope.name() | |
| 93 | + $.popup "#{url}#{encodeURIComponent value}" | |
| 92 | 94 | @reset() |
| 93 | 95 | return |
| 94 | 96 | |
| 97 | + google: => | |
| 98 | + @externalSearch "https://www.google.com/search?q=" | |
| 99 | + return | |
| 100 | + | |
| 101 | + stackoverflow: => | |
| 102 | + @externalSearch "https://stackoverflow.com/search?q=" | |
| 103 | + return | |
| 104 | + | |
| 95 | 105 | onResults: (results) => |
| 96 | 106 | @hasResults = true if results.length |
| 97 | 107 | @trigger 'results', results, @flags |
| @@ -26,6 +26,9 @@ class app.views.SearchScope extends app.View · 25 unmodified lines | ||
| 26 | 26 | getScope: -> |
| 27 | 27 | @doc or app |
| 28 | 28 | |
| 29 | + name: -> | |
| 30 | + @doc?.name | |
| 31 | + | |
| 29 | 32 | search: (value) -> |
| 30 | 33 | unless @doc |
| 31 | 34 | @searcher.find app.docs.all(), 'text', value |