2 * MediaWiki Widgets - MediaSearchProvider class.
4 * @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
10 * MediaWiki media search provider.
13 * @extends mw.widgets.MediaResourceProvider
16 * @param {string} apiurl The API url
17 * @param {Object} [config] Configuration options
19 mw.widgets.MediaSearchProvider = function MwWidgetsMediaSearchProvider( apiurl, config ) {
20 config = config || {};
22 config.staticParams = $.extend( {
24 gsrnamespace: mw.config.get( 'wgNamespaceIds' ).file
25 }, config.staticParams );
28 mw.widgets.MediaSearchProvider.super.call( this, apiurl, config );
32 OO.inheritClass( mw.widgets.MediaSearchProvider, mw.widgets.MediaResourceProvider );
39 mw.widgets.MediaSearchProvider.prototype.getContinueData = function ( howMany ) {
41 gsroffset: this.getOffset(),
42 gsrlimit: howMany || this.getDefaultFetchLimit()
49 mw.widgets.MediaSearchProvider.prototype.setContinue = function ( continueData ) {
50 // Update the offset for next time
51 this.setOffset( continueData.gsroffset );
57 mw.widgets.MediaSearchProvider.prototype.sort = function ( results ) {
58 return results.sort( function ( a, b ) {
59 return a.index - b.index;
66 mw.widgets.MediaSearchProvider.prototype.isValid = function () {
67 return this.getUserParams().gsrsearch && mw.widgets.MediaSearchProvider.super.prototype.isValid.call( this );
69 }( jQuery, mediaWiki ) );