jenkins-bot has submitted this change and it was merged.

Change subject: Allow category prefix when entering categories
......................................................................


Allow category prefix when entering categories

When users are entering categories, allow either
"Foo" or "Category:Foo" (with the prefix text
localized as necessary).

Bug: 56273
Change-Id: Ie5cc9dbcfeae48398ab0fe3c43e2a85f2307e3dc
---
M resources/jquery/jquery.mwCoolCats.js
1 file changed, 11 insertions(+), 3 deletions(-)

Approvals:
  MarkTraceur: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/resources/jquery/jquery.mwCoolCats.js 
b/resources/jquery/jquery.mwCoolCats.js
index 7f6bdb0..d27d7a3 100644
--- a/resources/jquery/jquery.mwCoolCats.js
+++ b/resources/jquery/jquery.mwCoolCats.js
@@ -166,8 +166,16 @@
         */
        function _fetchSuggestions() {
                var _input = this;
-               // ignore bad characters, they will be stripped out
-               var prefix = _stripText( $( this ).val() );
+
+               // Get the name of the category (no "Category:"), stripping out
+               // bad characters as necessary.
+               var prefix = _stripText( $( this ).val() ),
+                       title = mw.Title.newFromText( prefix, catNsId );
+               if ( title && title.getNamespaceId() === catNsId ) {
+                       prefix = title.getMainText();
+               } else {
+                       prefix = title.getPrefixedText();
+               }
 
                var ok = function( catList ) {
                        for ( var c in catList ) {
@@ -176,7 +184,7 @@
                        $( _input ).suggestions( 'suggestions', catList );
                };
 
-               $( _input ).data( 'request', 
settings.api.getCategoriesByPrefix( prefix, ok ) );
+               $( _input ).data( 'request', 
settings.api.getCategoriesByPrefix( prefix, ok ) );
        }
 
        var defaults = {

-- 
To view, visit https://gerrit.wikimedia.org/r/103345
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie5cc9dbcfeae48398ab0fe3c43e2a85f2307e3dc
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Theopolisme <theopolismew...@gmail.com>
Gerrit-Reviewer: Bartosz DziewoƄski <matma....@gmail.com>
Gerrit-Reviewer: Brian Wolff <bawolff...@gmail.com>
Gerrit-Reviewer: MarkTraceur <mtrac...@member.fsf.org>
Gerrit-Reviewer: Qgil <q...@wikimedia.org>
Gerrit-Reviewer: Theopolisme <theopolismew...@gmail.com>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to