History

Shortcut to copy URL of original page (alt + C)

Fixes #1199.

Simon Legner committed 5 years ago

Commit c0ddcf31 parent cd6664a4 files · +17 −0Browse files

Unified · Split

4 files
  1. assets/javascripts/app/shortcuts.coffee +3 −0
  2. assets/javascripts/news.json +4 −0
  3. assets/javascripts/templates/pages/help_tmpl.coffee +3 −0
  4. assets/javascripts/views/content/entry_page.coffee +7 −0
assets/javascripts/app/shortcuts.coffee+3−0
@@ -149,6 +149,9 @@ class app.Shortcuts · 148 unmodified lines
149149 when 40
150150 @trigger 'altDown'
151151 false
152+ when 67
153+ @trigger 'altC'
154+ false
152155 when 68
153156 @trigger 'altD'
154157 false
assets/javascripts/news.json+4−0
@@ -1,4 +1,8 @@
11 [
2+ [
3+ "2021-04-29",
4+ "Added <code class=\"_label\">alt + c</code> shortcut to copy URL of original page."
5+ ],
26 [
37 "2021-02-26",
48 "New documentation: <a href=\"/react_bootstrap/\">React Bootstrap</a>"
assets/javascripts/templates/pages/help_tmpl.coffee+3−0
@@ -130,6 +130,9 @@ app.templates.helpPage = -> · 129 unmodified lines
130130 </dl>
131131 <h3 class="_shortcuts-title">Miscellaneous</h3>
132132 <dl class="_shortcuts-dl">
133+ <dt class="_shortcuts-dt">
134+ <code class="_shortcut-code">alt + c</code>
135+ <dd class="_shortcuts-dd">Copy URL of original page
133136 <dt class="_shortcuts-dt">
134137 <code class="_shortcut-code">alt + o</code>
135138 <dd class="_shortcuts-dd">Open original page
assets/javascripts/views/content/entry_page.coffee+7−0
@@ -6,6 +6,7 @@ class app.views.EntryPage extends app.View · 5 unmodified lines
66 click: 'onClick'
77
88 @shortcuts:
9+ altC: 'onAltC'
910 altO: 'onAltO'
1011
1112 @routes:
@@ -153,6 +154,12 @@ class app.views.EntryPage extends app.View · 141 unmodified lines
153154 setTimeout (-> target.className = '_pre-clip'), 2000
154155 return
155156
157+ onAltC: =>
158+ return unless link = @find('._attribution:last-child ._attribution-link')
159+ console.log(link.href + location.hash)
160+ navigator.clipboard.writeText(link.href + location.hash)
161+ return
162+
156163 onAltO: =>
157164 return unless link = @find('._attribution:last-child ._attribution-link')
158165 @delay -> $.popup(link.href + location.hash)