Skip to content
Snippets Groups Projects
Commit b1112787 authored by Ben Coburn's avatar Ben Coburn
Browse files

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
parent 73ca7c9c
No related branches found
No related tags found
No related merge requests found
......@@ -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 .= '/>';
......
......@@ -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
......
......@@ -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
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment