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