The maxRows setting was previously unused and had no effect. This patch
passes the property in the fetch() call, and makes it enforce the setting.
Also updates mediawiki.userSuggest.js to use response()
The previously unused setting of 7 is changed to 10 to match current
behaviour.
Bug: T39316
Change-Id: I2873963aba9fd751607d11904b94bfcec8eb2d32
* suggestions: Suggestions to display
* Type: Array of strings
* maxRows: Maximum number of suggestions to display at one time
* 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
* 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
context.data.$textbox,
val,
function ( suggestions ) {
context.data.$textbox,
val,
function ( suggestions ) {
+ suggestions = suggestions.slice( 0, context.config.maxRows );
context.data.$textbox.suggestions( 'suggestions', suggestions );
if ( context.config.cache ) {
cache[ val ] = {
context.data.$textbox.suggestions( 'suggestions', suggestions );
if ( context.config.cache ) {
cache[ val ] = {
timestamp: +new Date()
};
}
timestamp: +new Date()
};
}
+ },
+ context.config.maxRows
result: {},
$region: $( this ),
suggestions: [],
result: {},
$region: $( this ),
suggestions: [],
delay: 120,
cache: false,
cacheMaxAge: 60000,
delay: 120,
cache: false,
cacheMaxAge: 60000,
];
$( searchboxesSelectors.join( ', ' ) )
.suggestions( {
];
$( searchboxesSelectors.join( ', ' ) )
.suggestions( {
- fetch: function ( query, response ) {
+ fetch: function ( query, response, maxRows ) {
var node = this[0];
api = api || new mw.Api();
var node = this[0];
api = api || new mw.Api();
action: 'opensearch',
search: query,
namespace: 0,
action: 'opensearch',
search: query,
namespace: 0,
suggest: ''
} ).done( function ( data ) {
response( data[ 1 ] );
suggest: ''
} ).done( function ( data ) {
response( data[ 1 ] );
var api, config;
config = {
var api, config;
config = {
- fetch: function ( userInput ) {
- var $textbox = this,
- node = this[0];
+ fetch: function ( userInput, response, maxRows ) {
+ var node = this[0];
api = api || new mw.Api();
api = api || new mw.Api();
list: 'allusers',
// Prefix of list=allusers is case sensitive. Normalise first
// character to uppercase so that "fo" may yield "Foo".
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 ),
+ aulimit: maxRows
} ).done( function ( data ) {
var users = $.map( data.query.allusers, function ( userObj ) {
return userObj.name;
} );
} ).done( function ( data ) {
var users = $.map( data.query.allusers, function ( userObj ) {
return userObj.name;
} );
- // Set the results as the autocomplete options
- $textbox.suggestions( 'suggestions', users );
} ) );
},
cancel: function () {
} ) );
},
cancel: function () {