if ( $options == 'withaccess' ) {
$accesskey = self::accesskey( $name );
if ( $accesskey !== false ) {
+ // Should be build the same as in jquery.accessKeyLabel.js
if ( $tooltip === false || $tooltip === '' ) {
$tooltip = wfMessage( 'brackets', $accesskey )->escaped();
} else {
'scripts' => 'resources/src/jquery/jquery.accessKeyLabel.js',
'dependencies' => array(
'jquery.client',
+ 'jquery.mwExtension',
),
+ 'messages' => array( 'brackets', 'word-separator' ),
'targets' => array( 'mobile', 'desktop' ),
),
'jquery.appear' => array(
*
* @class jQuery.plugin.accessKeyLabel
*/
-( function ( $ ) {
+( function ( $, mw ) {
// Cached access key prefix for used browser
var cachedAccessKeyPrefix,
* @param {HTMLElement} titleElement Element with the title to update (may be the same as `element`)
*/
function updateTooltipOnElement( element, titleElement ) {
- var oldTitle = titleElement.title,
- rawTitle = oldTitle.replace( / \[.*?\]$/, '' ),
+ var array = ( mw.msg( 'word-separator' ) + mw.msg( 'brackets' ) ).split( '$1' ),
+ regexp = new RegExp( $.map( array, $.escapeRE ).join( '.*?' ) + '$' ),
+ oldTitle = titleElement.title,
+ rawTitle = oldTitle.replace( regexp, '' ),
newTitle = rawTitle,
accessKeyLabel = getAccessKeyLabel( element );
}
if ( accessKeyLabel ) {
- newTitle += ' [' + accessKeyLabel + ']';
+ // Should be build the same as in Linker::titleAttrib
+ newTitle += mw.msg( 'word-separator' ) + mw.msg( 'brackets', accessKeyLabel );
}
if ( oldTitle !== newTitle ) {
titleElement.title = newTitle;
* @mixins jQuery.plugin.accessKeyLabel
*/
-}( jQuery ) );
+}( jQuery, mediaWiki ) );
( function ( $ ) {
- QUnit.module( 'jquery.accessKeyLabel', QUnit.newMwEnvironment() );
+ QUnit.module( 'jquery.accessKeyLabel', QUnit.newMwEnvironment( {
+ messages: {
+ 'brackets': '[$1]',
+ 'word-separator': ' '
+ }
+ } ) );
var getAccessKeyPrefixTestData = [
//ua string, platform string, expected prefix