*
* @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;
}
}
- // Search it as parent, because the form control can also inside the label element itself
+ // Search it as parent, because the form control can also be inside the label element itself
$labelParent = $element.parents( 'label' );
if ( $labelParent.length === 1 ) {
updateTooltipOnElement( element, $labelParent[0] );
* @mixins jQuery.plugin.accessKeyLabel
*/
-}( jQuery ) );
+}( jQuery, mediaWiki ) );