| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
( function () { |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
mw.widgets.MediaSearchProvider = function MwWidgetsMediaSearchProvider( apiurl, config ) { |
| 21 |
config = config || {}; |
| 22 |
|
| 23 |
config.staticParams = Object.assign( { |
| 24 |
generator: 'search', |
| 25 |
gsrnamespace: mw.config.get( 'wgNamespaceIds' ).file, |
| 26 |
uselang: mw.config.get( 'wgUserLanguage' ) |
| 27 |
}, config.staticParams ); |
| 28 |
|
| 29 |
|
| 30 |
mw.widgets.MediaSearchProvider.super.call( this, apiurl, config ); |
| 31 |
}; |
| 32 |
|
| 33 |
|
| 34 |
OO.inheritClass( mw.widgets.MediaSearchProvider, mw.widgets.MediaResourceProvider ); |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
mw.widgets.MediaSearchProvider.prototype.getContinueData = function ( howMany ) { |
| 42 |
return { |
| 43 |
gsroffset: this.getOffset(), |
| 44 |
gsrlimit: howMany || this.getDefaultFetchLimit() |
| 45 |
}; |
| 46 |
}; |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
mw.widgets.MediaSearchProvider.prototype.setContinue = function ( continueData ) { |
| 52 |
|
| 53 |
this.setOffset( continueData.gsroffset ); |
| 54 |
}; |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
mw.widgets.MediaSearchProvider.prototype.sort = function ( results ) { |
| 60 |
return results.sort( ( a, b ) => a.index - b.index ); |
| 61 |
}; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
mw.widgets.MediaSearchProvider.prototype.isValid = function () { |
| 67 |
return this.getUserParams().gsrsearch && mw.widgets.MediaSearchProvider.super.prototype.isValid.call( this ); |
| 68 |
}; |
| 69 |
}() ); |