diff options
author | Ben Coburn <btcoburn@silicodon.net> | 2006-04-28 03:51:58 +0200 |
---|---|---|
committer | Ben Coburn <btcoburn@silicodon.net> | 2006-04-28 03:51:58 +0200 |
commit | b1112787e60be712d508e80baaf0d6f9a861f0ac (patch) | |
tree | 8bcd2701fc510a6b2cd29d701ed678cc804c8add /lib/scripts/script.js | |
parent | 73ca7c9c18c7cdc9f38624ade2027d000a7d5372 (diff) | |
download | dokuwiki-b1112787e60be712d508e80baaf0d6f9a861f0ac.tar.gz dokuwiki-b1112787e60be712d508e80baaf0d6f9a861f0ac.zip |
accesskey tooltip rewriting
Does client-side rewriting of accesskey tooltip text so that it will be
more OS and browser specific. Dokuwiki should output all accesskey tooltips
as [ALT+<key>] because this patch matches on "[ALT+".
darcs-hash:20060428015158-05dcb-0102a1b2068c053e81dd21ad3927c78b6c9f349e.gz
Diffstat (limited to 'lib/scripts/script.js')
-rw-r--r-- | lib/scripts/script.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/scripts/script.js b/lib/scripts/script.js index 87fd8e503..d6be1cba9 100644 --- a/lib/scripts/script.js +++ b/lib/scripts/script.js @@ -17,6 +17,33 @@ if (clientPC.indexOf('opera')!=-1) { } /** + * Rewrite the accesskey tooltips to be more browser and OS specific. + * + * Accesskey tooltips are still only a best-guess of what will work + * on well known systems. + * + * @author Ben Coburn <btcoburn@silicodon.net> + */ +function updateAccessKeyTooltip() { + // determin tooltip text (order matters) + var tip = 'ALT+'; //default + if (domLib_isMac) { tip = 'CTRL+'; } + if (domLib_isOpera) { tip = 'SHIFT+ESC '; } + // add other cases here... + + // do tooltip update + if (tip=='ALT+') { return; } + var exp = /\[ALT\+/i; + var rep = '['+tip; + var elements = domLib_getElementsByTagNames(['a', 'input', 'button']); + for (var i=0; i<elements.length; i++) { + if (elements[i].accessKey.length==1 && elements[i].title.length>0) { + elements[i].title = elements[i].title.replace(exp, rep); + } + } +} + +/** * Handy shortcut to document.getElementById * * This function was taken from the prototype library |