Fix regression from r37834: accesskey tooltip hint should be given for the minor...
authorAryeh Gregor <simetrical@users.mediawiki.org>
Wed, 13 Aug 2008 15:11:36 +0000 (15:11 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Wed, 13 Aug 2008 15:11:36 +0000 (15:11 +0000)
I relied on the fact that $n is usable to catch back-references in JavaScript replacement text -- this seems to work in latest-ish versions of Firefox, Konqueror, and Opera, so I'm assuming it works everywhere.  ;)  As usual, the Web gives tons of dodgy-looking cookbooks with no useful info whenever I try to search for anything JavaScript-related.

Since I'm backporting this to 1.13 as a regression fix, this fix causes no change from 1.12 or 1.13 and so I'm not putting it in the release notes.

includes/EditPage.php
includes/Linker.php
skins/common/wikibits.js

index 3e67d06..41a2e6d 100644 (file)
@@ -1994,7 +1994,7 @@ END
                        );
                        $checkboxes['minor'] =
                                Xml::check( 'wpMinoredit', $checked['minor'], $attribs ) .
-                               "&nbsp;<label for='wpMinoredit'".$skin->tooltip('minoredit').">{$minorLabel}</label>";
+                               "&nbsp;<label for='wpMinoredit'".$skin->tooltip('minoredit', 'withaccess').">{$minorLabel}</label>";
                }
 
                $watchLabel = wfMsgExt('watchthis', array('parseinline'));
@@ -2007,7 +2007,7 @@ END
                        );
                        $checkboxes['watch'] =
                                Xml::check( 'wpWatchthis', $checked['watch'], $attribs ) .
-                               "&nbsp;<label for='wpWatchthis'".$skin->tooltip('watch').">{$watchLabel}</label>";
+                               "&nbsp;<label for='wpWatchthis'".$skin->tooltip('watch', 'withaccess').">{$watchLabel}</label>";
                }
                return $checkboxes;
        }
index cafd4bc..6ddf331 100644 (file)
@@ -1667,9 +1667,9 @@ class Linker {
                        $attribs['accesskey'] = $accesskey;
                }
 
-               $out = Xml::expandAttributes( $attribs );
+               $ret = Xml::expandAttributes( $attribs );
                wfProfileOut( __METHOD__ );
-               return $out;
+               return $ret;
        }
 
        /**
@@ -1678,20 +1678,32 @@ class Linker {
         * isn't always, because sometimes the accesskey needs to go on a different
         * element than the id, for reverse-compatibility, etc.)
         *
-        * @param string $name Id of the element, minus prefixes.
+        * @param string $name    Id of the element, minus prefixes.
+        * @param mixed  $options null or the string 'withaccess' to add an access-
+        *   key hint
         * @return string title attribute, ready to drop in an element
         * (e.g., ' title="This does something"').
         */
-       public function tooltip( $name ) {
+       public function tooltip( $name, $options = null ) {
                wfProfileIn( __METHOD__ );
 
+               $attribs = array();
+
                $tooltip = wfMsg( "tooltip-$name" );
-               if ( !wfEmptyMsg( "tooltip-$name", $tooltip ) && $tooltip != '-' ) {
-                       wfProfileOut( __METHOD__ );
-                       return ' title="'.htmlspecialchars( $tooltip ).'"';
+               if( !wfEmptyMsg( "tooltip-$name", $tooltip ) && $tooltip != '-' ) {
+                       $attribs['title'] = $tooltip;
+               }
+
+               if( isset( $attribs['title'] ) && $options == 'withaccess' ) {
+                       $accesskey = wfMsg( "accesskey-$name" );
+                       if( $accesskey && $accesskey != '-' &&
+                       !wfEmptyMsg( "accesskey-$name", $accesskey ) ) {
+                               $attribs['title'] .= " [$accesskey]";
+                       }
                }
 
+               $ret = Xml::expandAttributes( $attribs );
                wfProfileOut( __METHOD__ );
-               return '';
+               return $ret;
        }
 }
index 678492b..59f15ce 100644 (file)
@@ -215,7 +215,7 @@ if (is_opera) {
 } else if (is_ff2) {
        tooltipAccessKeyPrefix = 'alt-shift-';
 }
-var tooltipAccessKeyRegexp = /\[(ctrl-)?(alt-)?(shift-)?(esc-)?.\]$/;
+var tooltipAccessKeyRegexp = /\[(ctrl-)?(alt-)?(shift-)?(esc-)?(.)\]$/;
 
 /**
  * Add the appropriate prefix to the accesskey shown in the tooltip.
@@ -240,10 +240,9 @@ function updateTooltipAccessKeys( nodeList ) {
        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) ) {
+               if ( tip && tooltipAccessKeyRegexp.exec(tip) ) {
                        tip = tip.replace(tooltipAccessKeyRegexp,
-                                         "["+tooltipAccessKeyPrefix+key+"]");
+                                         "["+tooltipAccessKeyPrefix+"$5]");
                        element.setAttribute("title", tip );
                }
        }