From 2f19cf9664451b6590c70a6d667ecad7c0025402 Mon Sep 17 00:00:00 2001 From: Thibaut Courouble Date: Sun, 30 Oct 2016 18:01:14 -0400 Subject: [PATCH] Add keyboard shortcut for opening original page Closes #510. --- assets/javascripts/app/shortcuts.coffee | 3 +++ assets/javascripts/templates/pages/help_tmpl.coffee | 3 +++ assets/javascripts/views/content/entry_page.coffee | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/assets/javascripts/app/shortcuts.coffee b/assets/javascripts/app/shortcuts.coffee index 0bdb8e95..bf7beffe 100644 --- a/assets/javascripts/app/shortcuts.coffee +++ b/assets/javascripts/app/shortcuts.coffee @@ -137,6 +137,9 @@ class app.Shortcuts when 71 @trigger 'altG' false + when 79 + @trigger 'altO' + false when 82 @trigger 'altR' false diff --git a/assets/javascripts/templates/pages/help_tmpl.coffee b/assets/javascripts/templates/pages/help_tmpl.coffee index 41bd68d3..c66f8dc9 100644 --- a/assets/javascripts/templates/pages/help_tmpl.coffee +++ b/assets/javascripts/templates/pages/help_tmpl.coffee @@ -90,6 +90,9 @@ app.templates.helpPage = """
alt + r
Reveal current page in sidebar +
+ alt + o +
Open original page
alt + g
Search on Google diff --git a/assets/javascripts/views/content/entry_page.coffee b/assets/javascripts/views/content/entry_page.coffee index 1af420ab..92ef80fb 100644 --- a/assets/javascripts/views/content/entry_page.coffee +++ b/assets/javascripts/views/content/entry_page.coffee @@ -5,6 +5,9 @@ class app.views.EntryPage extends app.View @events: click: 'onClick' + @shortcuts: + altO: 'onAltO' + @routes: before: 'beforeRoute' @@ -146,3 +149,8 @@ class app.views.EntryPage extends app.View target.classList.add if $.copyToClipboard(target.parentNode.textContent) then '_pre-clip-success' else '_pre-clip-error' setTimeout (-> target.className = '_pre-clip'), 2000 return + + onAltO: => + return unless link = @find('._attribution:last-child ._attribution-link') + $.popup(link.href + location.hash) + return