Debian Codegraph @

resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaUserUploadsQueue.js

raw symbols SCIP
1 /*!
2 * MediaWiki Widgets - MediaUserUploadsQueue class.
3 *
4 * @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
6 */
7 ( function () {
8
9 /**
10 * @classdesc Media resource queue.
11 *
12 * @class
13 * @extends mw.widgets.MediaResourceQueue
14 *
15 * @constructor
16 * @description Create an instance of `mw.widgets.MediaUserUploadsQueue`.
17 * @param {Object} [config] Configuration options
18 * @param {number} config.maxHeight The maximum height of the media, used in the
19 * search call to the API.
20 */
21 mw.widgets.MediaUserUploadsQueue = function MwWidgetsMediaUserUploadsQueue( config ) {
22 config = config || {};
23
24 // Parent constructor
25 mw.widgets.MediaUserUploadsQueue.super.call( this, config );
26
27 if ( !mw.user.isAnon() ) {
28 this.setUser( mw.user.getName() );
29 }
30 };
31
32 /* Inheritance */
33 OO.inheritClass( mw.widgets.MediaUserUploadsQueue, mw.widgets.MediaResourceQueue );
34
35 /**
36 * Override parent method to set up the providers according to
37 * the file repos.
38 *
39 * @return {jQuery.Promise} Promise that resolves when the resources are set up
40 */
41 mw.widgets.MediaUserUploadsQueue.prototype.setup = function () {
42 return this.getFileRepos().then( ( sources ) => {
43 if ( this.providers.length === 0 ) {
44 // Set up the providers
45 for ( let i = 0, len = sources.length; i < len; i++ ) {
46 this.addProvider( new mw.widgets.MediaUserUploadsProvider(
47 sources[ i ].apiurl,
48 {
49 name: sources[ i ].name,
50 local: sources[ i ].local,
51 scriptDirUrl: sources[ i ].scriptDirUrl,
52 userParams: {
53 gaiuser: this.getUser()
54 },
55 staticParams: {
56 iiurlheight: this.getMaxHeight()
57 }
58 } )
59 );
60 }
61 }
62 } );
63 };
64
65 /**
66 * Set the user name.
67 *
68 * @param {string} user User name
69 */
70 mw.widgets.MediaUserUploadsQueue.prototype.setUser = function ( user ) {
71 this.setParams( { gaiuser: user } );
72 };
73
74 /**
75 * Get the user name.
76 *
77 * @return {string} API search query
78 */
79 mw.widgets.MediaUserUploadsQueue.prototype.getUser = function () {
80 return this.getParams().gaiuser;
81 };
82 }() );