Theopolisme has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/103345


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(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard 
refs/changes/45/103345/1

diff --git a/resources/jquery/jquery.mwCoolCats.js 
b/resources/jquery/jquery.mwCoolCats.js
index 7f6bdb0..d634361 100644
--- a/resources/jquery/jquery.mwCoolCats.js
+++ b/resources/jquery/jquery.mwCoolCats.js
@@ -13,6 +13,7 @@
 ( function ( $ ) { $.fn.mwCoolCats = function( options ) {
 
        var catNsId = mw.config.get( 'wgNamespaceIds' ).category;
+       var catPrefixRegex = new RegExp( '^' + 
mw.config.get('wgFormattedNamespaces')[catNsId] + ':', 'i');
 
        /**
         * Get content from our text field, and attempt to insert it as a 
category.
@@ -176,7 +177,16 @@
                        $( _input ).suggestions( 'suggestions', catList );
                };
 
-               $( _input ).data( 'request', 
settings.api.getCategoriesByPrefix( prefix, ok ) );
+               // Try initially assuming that user has entered only the 
category name,
+               // not including the "Category:" prefix. If no matches, try 
removing
+               // the category prefix and search again.
+               var suggestions = settings.api.getCategoriesByPrefix( prefix, 
ok );
+               if ( !suggestions.length ) {
+                       prefix = prefix.replace( catPrefixRegex, '' );
+                       suggestions = settings.api.getCategoriesByPrefix( 
prefix, ok );
+               }
+
+               $( _input ).data( 'request', suggestions );
        }
 
        var defaults = {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie5cc9dbcfeae48398ab0fe3c43e2a85f2307e3dc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Theopolisme <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to