浏览代码

Add keyboard shortcut for revealing the current page in the sidebar

Thibaut 12 年之前
父节点
当前提交
ed3c1dcb28

+ 3 - 0
assets/javascripts/app/shortcuts.coffee

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

+ 3 - 0
assets/javascripts/templates/pages/help_tmpl.coffee

@@ -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 + r</code>
+    <dd class="_shortcuts-dd">Reveal current page in sidebar
     <dt class="_shortcuts-dt">
       <code class="_shortcut-code">Alt + g</code>
     <dd class="_shortcuts-dd">Search on Google

+ 2 - 1
assets/javascripts/templates/pages/news_tmpl.coffee

@@ -25,7 +25,8 @@ newsItem = (date, news) ->
 
 app.news = [
   [ 1389484800000, # January 12, 2013
-    """ Added <code class="_label">Alt + g</code> shortcut for searching on Google. """
+    """ Added <code class="_label">Alt + g</code> shortcut for searching on Google. """,
+    """ Added <code class="_label">Alt + r</code> shortcut for revealing the current page in the sidebar. """
   ], [
     1386979200000, # December 14, 2013
     """ New <a href="/postgresql/">PostgreSQL</a> documentation """

+ 5 - 0
assets/javascripts/views/sidebar/sidebar.coffee

@@ -6,6 +6,7 @@ class app.views.Sidebar extends app.View
     click: 'onClick'
 
   @shortcuts:
+    altR: 'onAltR'
     escape: 'onEscape'
 
   init: ->
@@ -85,6 +86,10 @@ class app.views.Sidebar extends app.View
       @showDocList() unless $.hasChild @el, event.target
     return
 
+  onAltR: =>
+    @showDocList true
+    return
+
   onEscape: =>
     @showDocList true
     @scrollToTop()