diff --git a/inc/html.php b/inc/html.php index 908849d2b72489fa8476b69feb988810070df5fd..6d0b7e1162547fbdda36ea7dc86b063693713ef4 100644 --- a/inc/html.php +++ b/inc/html.php @@ -248,7 +248,7 @@ function html_btn($name,$id,$akey,$params,$method='get'){ $ret .= '<input type="submit" value="'.htmlspecialchars($label).'" class="button" '; if($akey){ - $ret .= 'title="ALT+'.strtoupper($akey).'" '; + $ret .= 'title="[ALT+'.strtoupper($akey).']" '; $ret .= 'accesskey="'.$akey.'" '; } $ret .= '/>'; diff --git a/lib/exe/js.php b/lib/exe/js.php index f18edc5d632e4cc2bb2d99ae057519b4e59afc33..5c7ee1dbdec2e901834a221f0ff65bf202b123e0 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -121,7 +121,8 @@ function js_out(){ // load user script @readfile(DOKU_CONF.'userscript.js'); - // add scroll event + // add scroll event and tooltip rewriting + js_runonstart('updateAccessKeyTooltip()'); js_runonstart('scrollToMarker()'); // initialize init pseudo event diff --git a/lib/scripts/script.js b/lib/scripts/script.js index 87fd8e50348595f8098f02352f0adb42579ea72b..d6be1cba937a83b419f1ee240b67b893742fa754 100644 --- a/lib/scripts/script.js +++ b/lib/scripts/script.js @@ -16,6 +16,33 @@ if (clientPC.indexOf('opera')!=-1) { var is_opera_seven = (window.opera && document.childNodes); } +/** + * 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 *