History

Add keyboard shortcut to open preferences

Thibaut Courouble committed 9 years ago

Commit 031b6241 parent 4984f003 files · +35 −17Browse files

Unified · Split

3 files
  1. assets/javascripts/app/shortcuts.coffee +3 −0
  2. assets/javascripts/templates/pages/help_tmpl.coffee +19 −13
  3. assets/javascripts/views/layout/document.coffee +13 −4
assets/javascripts/app/shortcuts.coffee+3−0
@@ -104,6 +104,9 @@ class app.Shortcuts · 103 unmodified lines
104104 when 40
105105 @trigger 'pageBottom'
106106 false
107+ when 188
108+ @trigger 'preferences'
109+ false
107110
108111 handleKeydownShiftEvent: (event, _force) ->
109112 return @handleKeydownEvent(event, true) if not _force and event.which in [37, 38, 39, 40] and @swapArrowKeysBehavior()
assets/javascripts/templates/pages/help_tmpl.coffee+19−13
@@ -45,7 +45,7 @@ app.templates.helpPage = """ · 44 unmodified lines
4545 </dl>
4646
4747 <h2 class="_block-heading" id="shortcuts">Keyboard Shortcuts</h2>
48− <h3 class="_shortcuts-title">Selection</h3>
48+ <h3 class="_shortcuts-title">Sidebar</h3>
4949 <dl class="_shortcuts-dl">
5050 <dt class="_shortcuts-dt">
5151 <code class="_shortcut-code">&darr;</code>
@@ -61,8 +61,11 @@ app.templates.helpPage = """ · 9 unmodified lines
6161 <dt class="_shortcuts-dt">
6262 <code class="_shortcut-code">#{ctrlKey} + enter</code>
6363 <dd class="_shortcuts-dd">Open selection in a new tab
64+ <dt class="_shortcuts-dt">
65+ <code class="_shortcut-code">alt + r</code>
66+ <dd class="_shortcuts-dd">Reveal current page in sidebar
6467 </dl>
65− <h3 class="_shortcuts-title">Navigation</h3>
68+ <h3 class="_shortcuts-title">Browsing</h3>
6669 <dl class="_shortcuts-dl">
6770 <dt class="_shortcuts-dt">
6871 <code class="_shortcut-code">#{navKey} + &larr;</code>
@@ -83,15 +86,24 @@ app.templates.helpPage = """ · 14 unmodified lines
8386 <code class="_shortcut-code">#{ctrlKey} + &uarr;</code>
8487 <code class="_shortcut-code">#{ctrlKey} + &darr;</code>
8588 <dd class="_shortcuts-dd">Scroll to the top/bottom
86− </dl>
87− <h3 class="_shortcuts-title">Misc</h3>
88− <dl class="_shortcuts-dl">
8989 <dt class="_shortcuts-dt">
9090 <code class="_shortcut-code">alt + f</code>
9191 <dd class="_shortcuts-dd">Focus first link in the content area<br>(press tab to focus the other links)
92+ </dl>
93+ <h3 class="_shortcuts-title">App</h3>
94+ <dl class="_shortcuts-dl">
9295 <dt class="_shortcuts-dt">
93− <code class="_shortcut-code">alt + r</code>
94− <dd class="_shortcuts-dd">Reveal current page in sidebar
96+ <code class="_shortcut-code">ctrl + ,</code>
97+ <dd class="_shortcuts-dd">Open preferences
98+ <dt class="_shortcuts-dt">
99+ <code class="_shortcut-code">escape</code>
100+ <dd class="_shortcuts-dd">Reset UI
101+ <dt class="_shortcuts-dt">
102+ <code class="_shortcut-code">?</code>
103+ <dd class="_shortcuts-dd">Show this page
104+ </dl>
105+ <h3 class="_shortcuts-title">Miscellaneous</h3>
106+ <dl class="_shortcuts-dl">
95107 <dt class="_shortcuts-dt">
96108 <code class="_shortcut-code">alt + o</code>
97109 <dd class="_shortcuts-dd">Open original page
@@ -101,12 +113,6 @@ app.templates.helpPage = """ · 3 unmodified lines
101113 <dt class="_shortcuts-dt">
102114 <code class="_shortcut-code">alt + s</code>
103115 <dd class="_shortcuts-dd">Search on Stack Overflow
104− <dt class="_shortcuts-dt">
105− <code class="_shortcut-code">escape</code>
106− <dd class="_shortcuts-dd">Reset<br>(press twice in single doc mode)
107− <dt class="_shortcuts-dt">
108− <code class="_shortcut-code">?</code>
109− <dd class="_shortcuts-dd">Show this page
110116 </dl>
111117 <p class="_note">
112118 <strong>Tip:</strong> If the cursor is no longer in the search field, press <code class="_label">/</code> or
assets/javascripts/views/layout/document.coffee+13−4
@@ -5,10 +5,11 @@ class app.views.Document extends app.View · 4 unmodified lines
55 visibilitychange: 'onVisibilityChange'
66
77 @shortcuts:
8− help: 'onHelp'
9− escape: 'onEscape'
10− superLeft: 'onBack'
11− superRight: 'onForward'
8+ help: 'onHelp'
9+ preferences: 'onPreferences'
10+ escape: 'onEscape'
11+ superLeft: 'onBack'
12+ superRight: 'onForward'
1213
1314 @routes:
1415 after: 'afterRoute'
@@ -46,6 +47,11 @@ class app.views.Document extends app.View · 31 unmodified lines
4647
4748 onHelp: ->
4849 app.router.show '/help#shortcuts'
50+ return
51+
52+ onPreferences: ->
53+ app.router.show '/settings'
54+ return
4955
5056 onEscape: ->
5157 path = if !app.isSingleDoc() or location.pathname is app.doc.fullPath()
@@ -54,12 +60,15 @@ class app.views.Document extends app.View · 2 unmodified lines
5460 app.doc.fullPath()
5561
5662 app.router.show(path)
63+ return
5764
5865 onBack: ->
5966 history.back()
67+ return
6068
6169 onForward: ->
6270 history.forward()
71+ return
6372
6473 onClick: (event) ->
6574 return unless event.target.hasAttribute('data-behavior')

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t