mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
Added Luke's patch to re-factor the accesskey-hints.js file using JSON notation.
Fixes #223. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@205 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
0ee4b8f6d1
commit
c18db17054
2 changed files with 51 additions and 72 deletions
|
|
@ -13,20 +13,17 @@
|
|||
* Use the following markup to include the library:
|
||||
* <script type="text/javascript" src="access-key-hints.js"></script>
|
||||
*/
|
||||
var accessKeyHintsAdder = {
|
||||
|
||||
addEvent(window, "load", addAccessKeyHints);
|
||||
|
||||
function addAccessKeyHints()
|
||||
{
|
||||
run : function() {
|
||||
var elemTypes = new Array('a','area','button','input','label','legend','textarea');
|
||||
for(var i = 0; i < elemTypes.length; i++)
|
||||
{
|
||||
addHint(document.getElementsByTagName(elemTypes[i]));
|
||||
}
|
||||
this.addHint(document.getElementsByTagName(elemTypes[i]));
|
||||
}
|
||||
},
|
||||
|
||||
function addHint(elems)
|
||||
{
|
||||
addHint : function(elems) {
|
||||
var elem;
|
||||
var i = 0;
|
||||
|
||||
|
|
@ -46,22 +43,20 @@ function addHint(elems)
|
|||
if (title.value.toLowerCase().indexOf(overrides[j]) != -1)
|
||||
continue processElements;
|
||||
}
|
||||
elem.setAttribute("title", title.value + ' (' + getHintText(accessKey.value) + ')');
|
||||
elem.setAttribute("title", title.value + ' (' + this.getHintText(accessKey.value) + ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
elem.setAttribute("title", getHintText(accessKey.value));
|
||||
}
|
||||
elem.setAttribute("title", this.getHintText(accessKey.value));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
function getHintText(accessKey)
|
||||
{
|
||||
return getModifier() + '+' + accessKey.toUpperCase();
|
||||
}
|
||||
getHintText : function(accessKey) {
|
||||
return this.getModifier() + '+' + accessKey.toUpperCase();
|
||||
},
|
||||
|
||||
function getModifier()
|
||||
{
|
||||
getModifier : function() {
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
if (ua.indexOf('mac') == -1)
|
||||
return 'Alt';
|
||||
|
|
@ -69,22 +64,6 @@ function getModifier()
|
|||
return 'Ctrl';
|
||||
}
|
||||
|
||||
// This is a cross-browser function for event addition.
|
||||
function addEvent(obj, evType, fn)
|
||||
{
|
||||
if (obj.addEventListener)
|
||||
{
|
||||
obj.addEventListener(evType, fn, false);
|
||||
return true;
|
||||
}
|
||||
else if (obj.attachEvent)
|
||||
{
|
||||
var r = obj.attachEvent("on" + evType, fn);
|
||||
return r;
|
||||
}
|
||||
else
|
||||
{
|
||||
alert("Event handler could not be attached");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Event.observe(window, "load", accessKeyHintsAdder.run.bindAsEventListener(accessKeyHintsAdder));
|
||||
Loading…
Add table
Add a link
Reference in a new issue