* Don't iterate through all elements to update tooltips/accesskeys, iterate through...
authorAryeh Gregor <simetrical@users.mediawiki.org>
Sun, 14 Jan 2007 23:48:42 +0000 (23:48 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Sun, 14 Jan 2007 23:48:42 +0000 (23:48 +0000)
* Only call updateTooltipAccessKeys from addPortletLink if necessary
* Give search box a tooltip in Monobook

includes/DefaultSettings.php
skins/MonoBook.php
skins/common/wikibits.js

index 9ffc5fc..46f9ce6 100644 (file)
@@ -1105,7 +1105,7 @@ $wgCacheEpoch = '20030516000000';
  * to ensure that client-side caches don't keep obsolete copies of global
  * styles.
  */
-$wgStyleVersion = '46';
+$wgStyleVersion = '47';
 
 
 # Server-side caching:
index 04d135f..b9f5f2c 100644 (file)
@@ -170,9 +170,7 @@ class MonoBookTemplate extends QuickTemplate {
                <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
                <div id="searchBody" class="pBody">
                        <form action="<?php $this->text('searchaction') ?>" id="searchform"><div>
-                               <input id="searchInput" name="search" type="text" <?php
-                                       if($this->haveMsg('accesskey-search')) {
-                                               ?>accesskey="<?php $this->msg('accesskey-search') ?>"<?php }
+                               <input id="searchInput" name="search" type="text"<?php echo $skin->tooltipAndAccesskey('search');
                                        if( isset( $this->data['search'] ) ) {
                                                ?> value="<?php $this->text('search') ?>"<?php } ?> />
                                <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg('searcharticle') ?>" />&nbsp;
index 3a0c496..4486c01 100644 (file)
@@ -490,25 +490,43 @@ if (is_opera) {
        tooltipAccessKeyPrefix = 'alt-shift-';
 }
 var tooltipAccessKeyRegexp = /\[(ctrl-)?(alt-)?(shift-)?(esc-)?.\]$/;
+var parentNode = null;
 
 /**
  * Add the appropriate prefix to the accesskey shown in the tooltip.
- * If the nodeList parameter is given, only those nodes are updated.
+ * If the nodeList parameter is given, only those nodes are updated;
+ * otherwise, all the nodes that will probably have accesskeys by default
+ * are updated.
  *
  * @param Array nodeList -- list of elements to update
  */
 function updateTooltipAccessKeys( nodeList ) {
-       if ( !nodeList )
-               nodeList = document.getElementsByTagName("*");
-
-       for ( var i = 0; i < nodeList.length; i++ ) {
-               var element = nodeList[i];
-               var tip = element.getAttribute("title");
-               var key = element.getAttribute("accesskey");
-               if ( key && tooltipAccessKeyRegexp.exec(tip) ) {
-                       tip = tip.replace(tooltipAccessKeyRegexp,
-                                         "["+tooltipAccessKeyPrefix+key+"]");
-                       element.setAttribute("title", tip );
+       if ( !nodeList ) {
+               if ( !parentNode ) {
+                       if ( !document.getElementById( "wpSave" ) && !document.getElementById( "pagehistory" ) ) {
+                               // If this is an edit page, we need to go through the whole page.
+                               // Otherwise we can just do non-content stuff.
+                               // Note: hacky heuristic! Any better?
+                               parentNode = document.getElementById( "column-one" );
+                       }
+                       if (!parentNode) {
+                               // Presumably non-Monobook, have to go through the whole page
+                               parentNode = document;
+                       }
+               }
+               updateTooltipAccessKeys( parentNode.getElementsByTagName("a") );
+               updateTooltipAccessKeys( parentNode.getElementsByTagName("input") );
+               updateTooltipAccessKeys( parentNode.getElementsByTagName("label") );
+       } else {
+               for ( var i = 0; i < nodeList.length; i++ ) {
+                       var element = nodeList[i];
+                       var tip = element.getAttribute("title");
+                       var key = element.getAttribute("accesskey");
+                       if ( key && tooltipAccessKeyRegexp.exec(tip) ) {
+                               tip = tip.replace(tooltipAccessKeyRegexp,
+                                                 "["+tooltipAccessKeyPrefix+key+"]");
+                               element.setAttribute("title", tip );
+                       }
                }
        }
 }
@@ -562,7 +580,9 @@ function addPortletLink(portlet, href, text, id, tooltip, accesskey, nextnode) {
        if ( tooltip ) {
                link.setAttribute( "title", tooltip );
        }
-       updateTooltipAccessKeys( new Array( link ) );
+       if ( accesskey && tooltip ) {
+               updateTooltipAccessKeys( new Array( link ) );
+       }
 
        if ( nextnode && nextnode.parentNode != node ) nextnode = null;
        node.insertBefore( item, nextnode );
@@ -982,6 +1002,8 @@ function runOnloadHook() {
                return;
        }
 
+       var startTime = new Date().getTime();
+
        // set this before running any hooks, since any errors below
        // might cause the function to terminate prematurely
        doneOnloadHook = true;
@@ -999,6 +1021,9 @@ function runOnloadHook() {
        for (var i = 0; i < onloadFuncts.length; i++) {
                onloadFuncts[i]();
        }
+
+       var endTime = new Date().getTime();
+       alert( endTime - startTime );
 }
 
 //note: all skins should call runOnloadHook() at the end of html output,