Add keyboard shortcut for searching on Google

pull/47/head
Thibaut 11 years ago
parent b30b816b52
commit 94119e1188

@ -101,6 +101,9 @@ class app.Shortcuts
when 40
@trigger 'altDown'
false
when 71
@trigger 'altG'
false
handleKeypressEvent: (event) ->
if event.which is 63 and not event.target.value

@ -77,6 +77,9 @@ app.templates.helpPage = """
</dl>
<h3 class="_shortcuts-title">Misc</h3>
<dl class="_shortcuts-dl">
<dt class="_shortcuts-dt">
<code class="_shortcut-code">Alt + g</code>
<dd class="_shortcuts-dd">Search on Google
<dt class="_shortcuts-dt">
<code class="_shortcut-code">escape</code>
<dd class="_shortcuts-dd">Reset

@ -24,7 +24,10 @@ newsItem = (date, news) ->
result
app.news = [
[ 1386979200000, # December 14, 2013
[ 1389484800000, # January 12, 2013
""" Added <code class="_label">Alt + g</code> shortcut for searching on Google. """
], [
1386979200000, # December 14, 2013
""" New <a href="/postgresql/">PostgreSQL</a> documentation """
], [
1386892800000, # December 13, 2013

@ -15,6 +15,7 @@ class app.views.Search extends app.View
@shortcuts:
typing: 'autoFocus'
altG: 'google'
@routes:
root: 'onRoot'
@ -82,6 +83,12 @@ class app.views.Search extends app.View
@removeClass @constructor.activeClass
@trigger 'clear'
google: =>
if @value
$.popup "https://www.google.com/search?q=#{encodeURIComponent @value}"
@reset()
return
onResults: (results) =>
@trigger 'results', results, @flags
@flags.initialResults = false

Loading…
Cancel
Save