History

Add ProTip for sidebar and scrolling keyboard shortcuts

Thibaut committed 11 years ago

Commit d0d47e21 parent 6ce3aa27 files · +55 −1Browse files

Unified · Split

7 files
  1. assets/javascripts/app/app.coffee +9 −0
  2. assets/javascripts/app/shortcuts.coffee +6 −0
  3. assets/javascripts/templates/tip_tmpl.coffee +10 −0
  4. assets/javascripts/views/misc/tip.coffee +11 −0
  5. assets/stylesheets/components/_notif.scss +13 −1
  6. assets/stylesheets/global/_variables.scss +3 −0
  7. assets/stylesheets/global/variables-dark.scss +3 −0
assets/javascripts/app/app.coffee+9−0
@@ -133,6 +133,15 @@ · 132 unmodified lines
133133 window.location = '/'
134134 return
135135
136+ showTip: (tip) ->
137+ return if @isSingleDoc()
138+ tips = @settings.get('tips') || []
139+ if tips.indexOf(tip) is -1
140+ tips.push(tip)
141+ @settings.set('tips', tips)
142+ new app.views.Tip(tip)
143+ return
144+
136145 showLoading: ->
137146 document.body.classList.remove '_noscript'
138147 document.body.classList.add '_loading'
assets/javascripts/app/shortcuts.coffee+6−0
@@ -15,6 +15,10 @@ class app.Shortcuts · 14 unmodified lines
1515 $.off document, 'keypress', @onKeypress
1616 return
1717
18+ showTip: ->
19+ app.showTip('KeyNav')
20+ @showTip = null
21+
1822 onKeydown: (event) =>
1923 result = if event.ctrlKey or event.metaKey
2024 @handleKeydownSuperEvent event unless event.altKey or event.shiftKey
@@ -62,11 +66,13 @@ class app.Shortcuts · 41 unmodified lines
6266 @trigger 'left' unless event.target.value
6367 when 38
6468 @trigger 'up'
69+ @showTip?()
6570 false
6671 when 39
6772 @trigger 'right' unless event.target.value
6873 when 40
6974 @trigger 'down'
75+ @showTip?()
7076 false
7177
7278 handleKeydownSuperEvent: (event) ->
assets/javascripts/templates/tip_tmpl.coffee+10−0
@@ -0,0 +1,10 @@
1+app.templates.tipKeyNav = """
2+ <p class="_notif-text">
3+ <strong>ProTip</strong>
4+ <span class="_notif-info">(click to dismiss)</span>
5+ <p class="_notif-text">
6+ Hit <code class="_label">&darr;</code> <code class="_label">&uarr;</code> <code class="_label">&larr;</code> <code class="_label">&rarr;</code> to navigate the sidebar.<br>
7+ Hit <code class="_label">alt &darr;</code> <code class="_label">alt &uarr;</code> or <code class="_label">space</code> <code class="_label">shift space</code> to scroll the page.
8+ <p class="_notif-text">
9+ <a href="/help#shortcuts" class="_notif-link">See all keyboard shortcuts</a>
10+"""
assets/javascripts/views/misc/tip.coffee+11−0
@@ -0,0 +1,11 @@
1+#= require views/misc/notif
2+
3+class app.views.Tip extends app.views.Notif
4+ @className: '_notif _notif-tip'
5+
6+ @defautOptions:
7+ autoHide: false
8+
9+ render: ->
10+ @html @tmpl("tip#{@type}")
11+ return
assets/stylesheets/components/_notif.scss+13−1
@@ -5,7 +5,7 @@ · 4 unmodified lines
55 right: 1rem;
66 width: 25rem;
77 max-width: 90%;
8− padding: .75rem 1rem;
8+ padding: .625rem 1rem;
99 font-size: .75rem;
1010 color: $notifColor;
1111 background: $notifBackground;
@@ -25,6 +25,12 @@ · 13 unmodified lines
2525 }
2626
2727 ._notif-text { margin-bottom: 0; }
28+._notif-text + ._notif-text { margin-top: .25rem; }
29+
30+._notif-info {
31+ float: right;
32+ color: $textColorLight;
33+}
2834
2935 ._notif-link,
3036 ._notif-link:hover {
@@ -91,3 +97,9 @@ · 60 unmodified lines
9197 margin: .5em 0;
9298 padding-left: 1rem;
9399 }
100+
101+._notif-tip {
102+ color: $textColor;
103+ background: rgba($tipBackground, .95);
104+ border: 1px solid $tipBorder;
105+}
assets/stylesheets/global/_variables.scss+3−0
@@ -73,6 +73,9 @@ $notifBackground: rgba(#333, .85); · 72 unmodified lines
7373 $notifColor: #fff;
7474 $notifColorLight: #bbb;
7575
76+$tipBackground: #fffdcd;
77+$tipBorder: #e7dca9;
78+
7679 $mediumScreen: '(max-width: 800px)';
7780
7881 $contentZ: 1;
assets/stylesheets/global/variables-dark.scss+3−0
@@ -73,6 +73,9 @@ $notifBackground: rgba(#000, .85); · 72 unmodified lines
7373 $notifColor: #fff;
7474 $notifColorLight: #bbb;
7575
76+$tipBackground: #3d4449;
77+$tipBorder: #566166;
78+
7679 $mediumScreen: '(max-width: 800px)';
7780
7881 $contentZ: 1;

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