From ace8aee14264a28ac0e3b297e70a1b45752172e1 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 10 Oct 2014 23:39:10 +0200 Subject: [PATCH] Improved access keys - Added underscore hint - Changed algorithm to provide access key for every button --- public_html/css/top-navigation.css | 15 +++++++++++++++ public_html/templates/top-navigation.tpl | 14 +++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/public_html/css/top-navigation.css b/public_html/css/top-navigation.css index 0cd6edaa..161d94fd 100644 --- a/public_html/css/top-navigation.css +++ b/public_html/css/top-navigation.css @@ -37,3 +37,18 @@ font-size: 40px; margin: 0 10px 5px; } + +#top-navigation .accesskey:before { + position: absolute; + display: inline-block; + right: 0; + left: 0; + content: '\a0'; + border-bottom: 1px solid; + opacity: .35; + height: 90%; +} +#top-navigation .accesskey { + position: relative; + text-decoration: none; +} diff --git a/public_html/templates/top-navigation.tpl b/public_html/templates/top-navigation.tpl index dc9daef4..33714540 100644 --- a/public_html/templates/top-navigation.tpl +++ b/public_html/templates/top-navigation.tpl @@ -74,10 +74,13 @@ link.className = link.title.toLowerCase(); } if (typeof(link.accessKey) === 'undefined') { - var accessKey = link.title.substring(0, 1); - if (!_.contains(takenAccessKeys, accessKey)) { - link.accessKey = accessKey; - takenAccessKeys.push(accessKey); + for (var i = 0; i < link.title.length; i ++) { + var accessKey = link.title.charAt(i); + if (!_.contains(takenAccessKeys, accessKey)) { + link.accessKey = accessKey; + takenAccessKeys.push(accessKey); + break; + } } } return link; @@ -88,7 +91,8 @@ -->
  • >
    - <%= link.title %> + <% var pos = link.title.indexOf(link.accessKey) %> + <%= pos === -1 ? link.title : link.title.substring(0, pos) + '' + link.accessKey + '' + link.title.substring(pos + 1) %>
  • <% }) %>