Enable tab navigation in the main content area using alt+tab

Fixes #77
pull/90/head
Thibaut 11 years ago
parent 07134dd144
commit fa0941a037

@ -95,6 +95,8 @@ class app.Shortcuts
handleKeydownAltEvent: (event) -> handleKeydownAltEvent: (event) ->
switch event.which switch event.which
when 9
@trigger 'altTab', event
when 38 when 38
@trigger 'altUp' @trigger 'altUp'
false false

@ -77,6 +77,9 @@ app.templates.helpPage = """
</dl> </dl>
<h3 class="_shortcuts-title">Misc</h3> <h3 class="_shortcuts-title">Misc</h3>
<dl class="_shortcuts-dl"> <dl class="_shortcuts-dl">
<dt class="_shortcuts-dt">
<code class="_shortcut-code">alt + tab</code>
<dd class="_shortcuts-dd">Focus first link in the content area<br>(press tab to focus the other links)
<dt class="_shortcuts-dt"> <dt class="_shortcuts-dt">
<code class="_shortcut-code">alt + r</code> <code class="_shortcut-code">alt + r</code>
<dd class="_shortcuts-dd">Reveal current page in sidebar <dd class="_shortcuts-dd">Reveal current page in sidebar

@ -12,6 +12,7 @@ class app.views.Content extends app.View
pageDown: 'scrollPageDown' pageDown: 'scrollPageDown'
home: 'scrollToTop' home: 'scrollToTop'
end: 'scrollToBottom' end: 'scrollToBottom'
altTab: 'onAltTab'
@routes: @routes:
before: 'beforeRoute' before: 'beforeRoute'
@ -150,6 +151,11 @@ class app.views.Content extends app.View
$.popup(link) $.popup(link)
return return
onAltTab: (event) =>
unless document.activeElement and $.hasChild @el, document.activeElement
@findByTag('a').focus()
$.stopEvent(event)
findTargetByHash: (hash) -> findTargetByHash: (hash) ->
try $.id decodeURIComponent(hash) catch try $.id decodeURIComponent(hash) catch

@ -16,6 +16,8 @@
box-shadow: inset 0 1px rgba(white, .8), // top inner glow box-shadow: inset 0 1px rgba(white, .8), // top inner glow
inset 0 -1px rgba(white, .3); // bottom inner glow inset 0 -1px rgba(white, .3); // bottom inner glow
@extend %user-select-none; @extend %user-select-none;
a:focus { outline: 0; }
} }
// //

@ -17,6 +17,7 @@
@media #{$mediumScreen} { left: $sidebarMediumWidth; } @media #{$mediumScreen} { left: $sidebarMediumWidth; }
~ ._container { padding-bottom: 2rem; } ~ ._container { padding-bottom: 2rem; }
a:focus { outline: 0; }
} }
._path-item { ._path-item {

@ -33,6 +33,8 @@
border-width: 2px; border-width: 2px;
} }
} }
a:focus { outline: 0; }
} }
// //

@ -28,8 +28,6 @@ a {
color: $linkColorHover; color: $linkColorHover;
text-decoration: underline; text-decoration: underline;
} }
&:focus { outline: 0; }
} }
img { img {

Loading…
Cancel
Save