jenkins-bot has submitted this change and it was merged. Change subject: jquery.accessKeyLabel: Replace hardcoded brackets and space ......................................................................
jquery.accessKeyLabel: Replace hardcoded brackets and space Since If914e26f2af23f04c46f011ad8a276a9d3190583 the brackets of the accesskey are localized, so do it also on the client side. Also added a comment to match php and js. Adjust tests to work on wikis with changed messages. Bug: 65010 Change-Id: Id9908b9efcb923f0b740e2c8fd77d1ef676b489f --- M includes/Linker.php M resources/Resources.php M resources/src/jquery/jquery.accessKeyLabel.js M tests/qunit/suites/resources/jquery/jquery.accessKeyLabel.test.js M tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js 5 files changed, 22 insertions(+), 6 deletions(-) Approvals: Krinkle: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/Linker.php b/includes/Linker.php index a912fde..14821cf 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -2114,6 +2114,7 @@ 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 { diff --git a/resources/Resources.php b/resources/Resources.php index 3a6f5e3..abc1661 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -202,7 +202,9 @@ '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( diff --git a/resources/src/jquery/jquery.accessKeyLabel.js b/resources/src/jquery/jquery.accessKeyLabel.js index 4caf072..80b8303 100644 --- a/resources/src/jquery/jquery.accessKeyLabel.js +++ b/resources/src/jquery/jquery.accessKeyLabel.js @@ -3,7 +3,7 @@ * * @class jQuery.plugin.accessKeyLabel */ -( function ( $ ) { +( function ( $, mw ) { // Cached access key prefix for used browser var cachedAccessKeyPrefix, @@ -111,8 +111,10 @@ * @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 ); @@ -122,7 +124,8 @@ } 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; @@ -194,4 +197,4 @@ * @mixins jQuery.plugin.accessKeyLabel */ -}( jQuery ) ); +}( jQuery, mediaWiki ) ); diff --git a/tests/qunit/suites/resources/jquery/jquery.accessKeyLabel.test.js b/tests/qunit/suites/resources/jquery/jquery.accessKeyLabel.test.js index d5c5d27e..60a63f9 100644 --- a/tests/qunit/suites/resources/jquery/jquery.accessKeyLabel.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.accessKeyLabel.test.js @@ -1,5 +1,10 @@ ( 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 diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js index 81fda7e..b2587be 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js @@ -5,6 +5,11 @@ }, teardown: function () { $.fn.updateTooltipAccessKeys.setTestMode( false ); + }, + messages: { + // Used by accessKeyLabel in test for addPortletLink + 'brackets': '[$1]', + 'word-separator': ' ' } } ) ); -- To view, visit https://gerrit.wikimedia.org/r/132009 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id9908b9efcb923f0b740e2c8fd77d1ef676b489f Gerrit-PatchSet: 7 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Umherirrender <umherirrender_de...@web.de> Gerrit-Reviewer: Daniel Friesen <dan...@nadir-seen-fire.com> Gerrit-Reviewer: Fomafix Gerrit-Reviewer: Gerrit Patch Uploader <gerritpatchuploa...@gmail.com> Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net> Gerrit-Reviewer: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: Umherirrender <umherirrender_de...@web.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits