Skip to content

Commit 2f19cf9

Browse files
committed
Add keyboard shortcut for opening original page
Closes freeCodeCamp#510.
1 parent 3508fa8 commit 2f19cf9

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

assets/javascripts/app/shortcuts.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ class app.Shortcuts
137137
when 71
138138
@trigger 'altG'
139139
false
140+
when 79
141+
@trigger 'altO'
142+
false
140143
when 82
141144
@trigger 'altR'
142145
false

assets/javascripts/templates/pages/help_tmpl.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ app.templates.helpPage = """
9090
<dt class="_shortcuts-dt">
9191
<code class="_shortcut-code">alt + r</code>
9292
<dd class="_shortcuts-dd">Reveal current page in sidebar
93+
<dt class="_shortcuts-dt">
94+
<code class="_shortcut-code">alt + o</code>
95+
<dd class="_shortcuts-dd">Open original page
9396
<dt class="_shortcuts-dt">
9497
<code class="_shortcut-code">alt + g</code>
9598
<dd class="_shortcuts-dd">Search on Google

assets/javascripts/views/content/entry_page.coffee

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ class app.views.EntryPage extends app.View
55
@events:
66
click: 'onClick'
77

8+
@shortcuts:
9+
altO: 'onAltO'
10+
811
@routes:
912
before: 'beforeRoute'
1013

@@ -146,3 +149,8 @@ class app.views.EntryPage extends app.View
146149
target.classList.add if $.copyToClipboard(target.parentNode.textContent) then '_pre-clip-success' else '_pre-clip-error'
147150
setTimeout (-> target.className = '_pre-clip'), 2000
148151
return
152+
153+
onAltO: =>
154+
return unless link = @find('._attribution:last-child ._attribution-link')
155+
$.popup(link.href + location.hash)
156+
return

0 commit comments

Comments
 (0)