summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/exe/js.php3
-rw-r--r--lib/scripts/script.js27
2 files changed, 29 insertions, 1 deletions
diff --git a/lib/exe/js.php b/lib/exe/js.php
index f18edc5d6..5c7ee1dbd 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 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