mw.widgets.CategorySelector: Add configuration to limit number of results
authorPrateek Saxena <prtksxna@gmail.com>
Fri, 11 Sep 2015 06:05:38 +0000 (11:35 +0530)
committerPrateek Saxena <prtksxna@gmail.com>
Fri, 11 Sep 2015 09:32:41 +0000 (15:02 +0530)
Change-Id: I530bca7950fa75e667d7e5f08d51b304fe3ad14b

resources/src/mediawiki.widgets/mw.widgets.CategorySelector.js

index a15cd87..8d6452c 100644 (file)
         *
         * @constructor
         * @param {Object} [config] Configuration options
+        * @cfg {number} [limit=10] Maximum number of results to load
         */
        mw.widgets.CategorySelector = function ( config ) {
+               // Config initialization
+               config = $.extend( { limit: 10 }, config );
+               this.limit = config.limit;
+
                // Parent constructor
                mw.widgets.CategorySelector.parent.call( this, config );
 
@@ -82,7 +87,7 @@
                api.get( {
                        action: 'opensearch',
                        namespace: catNsId,
-                       limit: 10,
+                       limit: this.limit,
                        search: input
                } ).done( function ( res ) {
                        var categoryNames = res[ 1 ].map( function ( name ) {