
simetrical at svn
Aug 13, 2008, 8:11 AM
Post #1 of 1
(39 views)
Permalink
|
|
SVN: [39287] trunk/phase3
|
|
Revision: 39287 Author: simetrical Date: 2008-08-13 15:11:36 +0000 (Wed, 13 Aug 2008) Log Message: ----------- Fix regression from r37834: accesskey tooltip hint should be given for the minor edit and watch labels on the edit page. This code could still use refactoring, but that's a separate issue. :) 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. Modified Paths: -------------- trunk/phase3/includes/EditPage.php trunk/phase3/includes/Linker.php trunk/phase3/skins/common/wikibits.js Modified: trunk/phase3/includes/EditPage.php =================================================================== --- trunk/phase3/includes/EditPage.php 2008-08-13 14:52:40 UTC (rev 39286) +++ trunk/phase3/includes/EditPage.php 2008-08-13 15:11:36 UTC (rev 39287) @@ -1994,7 +1994,7 @@ ); $checkboxes['minor'] = Xml::check( 'wpMinoredit', $checked['minor'], $attribs ) . - " <label for='wpMinoredit'".$skin->tooltip('minoredit').">{$minorLabel}</label>"; + " <label for='wpMinoredit'".$skin->tooltip('minoredit', 'withaccess').">{$minorLabel}</label>"; } $watchLabel = wfMsgExt('watchthis', array('parseinline')); @@ -2007,7 +2007,7 @@ ); $checkboxes['watch'] = Xml::check( 'wpWatchthis', $checked['watch'], $attribs ) . - " <label for='wpWatchthis'".$skin->tooltip('watch').">{$watchLabel}</label>"; + " <label for='wpWatchthis'".$skin->tooltip('watch', 'withaccess').">{$watchLabel}</label>"; } return $checkboxes; } Modified: trunk/phase3/includes/Linker.php =================================================================== --- trunk/phase3/includes/Linker.php 2008-08-13 14:52:40 UTC (rev 39286) +++ trunk/phase3/includes/Linker.php 2008-08-13 15:11:36 UTC (rev 39287) @@ -1667,9 +1667,9 @@ $attribs['accesskey'] = $accesskey; } - $out = Xml::expandAttributes( $attribs ); + $ret = Xml::expandAttributes( $attribs ); wfProfileOut( __METHOD__ ); - return $out; + return $ret; } /** @@ -1678,20 +1678,32 @@ * 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; } } Modified: trunk/phase3/skins/common/wikibits.js =================================================================== --- trunk/phase3/skins/common/wikibits.js 2008-08-13 14:52:40 UTC (rev 39286) +++ trunk/phase3/skins/common/wikibits.js 2008-08-13 15:11:36 UTC (rev 39287) @@ -215,7 +215,7 @@ } 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 @@ 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 ); } } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS [at] lists https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs
|