Unicodesnowman has uploaded a new change for review.

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

Change subject: Make jquery.suggestions obey maxRows setting
......................................................................

Make jquery.suggestions obey maxRows setting

The maxRows setting was previously unused and had no effect. This patch
passes the property in the fetch() call, and updates the handlers to
respect the maxRows setting.

The previously unused setting of 7 is changed to 10 to match current
behaviour.

Bug: T39316
Change-Id: I2873963aba9fd751607d11904b94bfcec8eb2d32
---
M resources/src/jquery/jquery.suggestions.js
M resources/src/mediawiki/mediawiki.searchSuggest.js
M resources/src/mediawiki/mediawiki.userSuggest.js
3 files changed, 8 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/42/182642/1

diff --git a/resources/src/jquery/jquery.suggestions.js 
b/resources/src/jquery/jquery.suggestions.js
index a83a70a..1a05e2a 100644
--- a/resources/src/jquery/jquery.suggestions.js
+++ b/resources/src/jquery/jquery.suggestions.js
@@ -28,7 +28,7 @@
  * suggestions: Suggestions to display
  *             Type: Array of strings
  * maxRows: Maximum number of suggestions to display at one time
- *             Type: Number, Range: 1 - 100, Default: 7
+ *             Type: Number, Range: 1 - 100, Default: 10
  * delay: Number of ms to wait for the user to stop typing
  *             Type: Number, Range: 0 - 1200, Default: 120
  * cache: Whether to cache results from a fetch
@@ -124,6 +124,7 @@
                                        context.config.fetch.call(
                                                context.data.$textbox,
                                                val,
+                                               context.config.maxRows,
                                                function ( suggestions ) {
                                                        
context.data.$textbox.suggestions( 'suggestions', suggestions );
                                                        if ( 
context.config.cache ) {
@@ -513,7 +514,7 @@
                                        result: {},
                                        $region: $( this ),
                                        suggestions: [],
-                                       maxRows: 7,
+                                       maxRows: 10,
                                        delay: 120,
                                        cache: false,
                                        cacheMaxAge: 60000,
diff --git a/resources/src/mediawiki/mediawiki.searchSuggest.js 
b/resources/src/mediawiki/mediawiki.searchSuggest.js
index d372e8f..3079fde 100644
--- a/resources/src/mediawiki/mediawiki.searchSuggest.js
+++ b/resources/src/mediawiki/mediawiki.searchSuggest.js
@@ -119,7 +119,7 @@
                ];
                $( searchboxesSelectors.join( ', ' ) )
                        .suggestions( {
-                               fetch: function ( query, response ) {
+                               fetch: function ( query, maxRows, response ) {
                                        var node = this[0];
 
                                        api = api || new mw.Api();
@@ -128,6 +128,7 @@
                                                action: 'opensearch',
                                                search: query,
                                                namespace: 0,
+                                               limit: maxRows,
                                                suggest: ''
                                        } ).done( function ( data ) {
                                                response( data[ 1 ] );
diff --git a/resources/src/mediawiki/mediawiki.userSuggest.js 
b/resources/src/mediawiki/mediawiki.userSuggest.js
index aed093c..db2b145 100644
--- a/resources/src/mediawiki/mediawiki.userSuggest.js
+++ b/resources/src/mediawiki/mediawiki.userSuggest.js
@@ -5,7 +5,7 @@
        var api, config;
 
        config = {
-               fetch: function ( userInput ) {
+               fetch: function ( userInput, maxRows ) {
                        var $textbox = this,
                                node = this[0];
 
@@ -16,7 +16,8 @@
                                list: 'allusers',
                                // Prefix of list=allusers is case sensitive. 
Normalise first
                                // character to uppercase so that "fo" may 
yield "Foo".
-                               auprefix: userInput.charAt( 0 ).toUpperCase() + 
userInput.slice( 1 )
+                               auprefix: userInput.charAt( 0 ).toUpperCase() + 
userInput.slice( 1 ),
+                               limit: maxRows
                        } ).done( function ( data ) {
                                var users = $.map( data.query.allusers, 
function ( userObj ) {
                                        return userObj.name;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2873963aba9fd751607d11904b94bfcec8eb2d32
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Unicodesnowman <[email protected]>

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

Reply via email to