2 * MediaWiki Widgets - MediaUserUploadsProvider class.
4 * @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
10 * @classdesc User uploads provider.
13 * @extends mw.widgets.MediaResourceProvider
16 * @description Create an instance of `mw.widgets.MediaUserUploadsProvider`.
17 * @param {string} apiurl The API url
18 * @param {Object} [config] Configuration options
20 mw.widgets.MediaUserUploadsProvider = function MwWidgetsMediaUserUploadsProvider( apiurl, config ) {
21 config = config || {};
23 config.staticParams = Object.assign( {
24 generator: 'allimages',
27 }, config.staticParams );
30 mw.widgets.MediaUserUploadsProvider.super.call( this, apiurl, config );
34 OO.inheritClass( mw.widgets.MediaUserUploadsProvider, mw.widgets.MediaResourceProvider );
41 mw.widgets.MediaUserUploadsProvider.prototype.getContinueData = function ( howMany ) {
43 gaicontinue: this.getOffset() || undefined,
44 gailimit: howMany || this.getDefaultFetchLimit()
51 mw.widgets.MediaUserUploadsProvider.prototype.setContinue = function ( continueData ) {
52 // Update the offset for next time
53 this.setOffset( continueData.gaicontinue );
59 mw.widgets.MediaUserUploadsProvider.prototype.sort = function ( results ) {
61 // timestamps are strings
62 ( a, b ) => a.timestamp < b.timestamp ? 1 : ( a.timestamp === b.timestamp ? 0 : -1 )
69 mw.widgets.MediaUserUploadsProvider.prototype.isValid = function () {
70 return this.getUserParams().gaiuser && mw.widgets.MediaUserUploadsProvider.super.prototype.isValid.call( this );