mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-23 10:40:13 +01:00
Removed superfluous 'tracks' directory at the root of the repository.
Testing commits to github.
This commit is contained in:
parent
6a42901514
commit
4cbf5a34d3
2269 changed files with 0 additions and 0 deletions
69
public/javascripts/accesskey-hints.js
Normal file
69
public/javascripts/accesskey-hints.js
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* AccessKey Hints
|
||||
*
|
||||
* Checks all HTML elements on this page that can have an accesskey attribute
|
||||
* (<a>, <area>, <button>, <input>, <label>, <legend> and <textarea>)
|
||||
* and creates or appends the title attribute to include platform-specific
|
||||
* hint in the title, i.e. "Alt+S" (Win)
|
||||
* or "Ctrl+S)" (Mac). If a title exists, a space plus the hint wrapped in
|
||||
* parentheses is appended. The only exception is if the title already contains
|
||||
* 'accesskey', 'Alt+' or 'Ctrl+' (case-insensitive) in which case this script
|
||||
* will leave it alone.
|
||||
*
|
||||
* Use the following markup to include the library:
|
||||
* <script type="text/javascript" src="access-key-hints.js"></script>
|
||||
*/
|
||||
var accessKeyHintsAdder = {
|
||||
|
||||
run : function() {
|
||||
var elemTypes = new Array('a','area','button','input','label','legend','textarea');
|
||||
for(var i = 0; i < elemTypes.length; i++)
|
||||
{
|
||||
this.addHint(document.getElementsByTagName(elemTypes[i]));
|
||||
}
|
||||
},
|
||||
|
||||
addHint : function(elems) {
|
||||
var elem;
|
||||
var i = 0;
|
||||
|
||||
processElements:
|
||||
while(elem = elems.item(i++))
|
||||
{
|
||||
var accessKey = elem.getAttributeNode("accesskey");
|
||||
if (!accessKey || !accessKey.value)
|
||||
continue processElements;
|
||||
|
||||
var title = elem.getAttributeNode("title");
|
||||
if (title && title.value)
|
||||
{
|
||||
var overrides = new Array('accesskey','alt+','ctrl+');
|
||||
for (var j=0; j < overrides.length; j++)
|
||||
{
|
||||
if (title.value.toLowerCase().indexOf(overrides[j]) != -1)
|
||||
continue processElements;
|
||||
}
|
||||
elem.setAttribute("title", title.value + ' (' + this.getHintText(accessKey.value) + ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
elem.setAttribute("title", this.getHintText(accessKey.value));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getHintText : function(accessKey) {
|
||||
return this.getModifier() + '+' + accessKey.toUpperCase();
|
||||
},
|
||||
|
||||
getModifier : function() {
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
if (ua.indexOf('mac') == -1)
|
||||
return 'Alt';
|
||||
else
|
||||
return 'Ctrl';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Event.observe(window, "load", accessKeyHintsAdder.run.bindAsEventListener(accessKeyHintsAdder));
|
||||
Loading…
Add table
Add a link
Reference in a new issue