mw.ForeignStructuredUpload.BookletLayout.parent.prototype.initialize.call( this )
.done( function () {
// Point the CategorySelector to the right wiki
- this.upload.apiPromise.done( function ( api ) {
+ this.upload.getApi().done( function ( api ) {
// If this is a ForeignApi, it will have a apiUrl, otherwise we don't need to do anything
if ( api.apiUrl ) {
// Can't reuse the same object, CategorySelector calls #abort on its mw.Api instance
* or to local uploads if no foreign target is configured.
*/
+ /**
+ * @inheritdoc
+ */
+ ForeignUpload.prototype.getApi = function () {
+ return this.apiPromise;
+ };
+
/**
* Override from mw.Upload to make sure the API info is found and allowed
*/
*/
mw.Upload.BookletLayout.prototype.initialize = function () {
var
- apiPromise,
booklet = this,
deferred = $.Deferred();
this.upload = this.createUpload();
this.setPage( 'upload' );
- apiPromise = this.upload.apiPromise || $.Deferred().resolve( this.upload.api );
- apiPromise.done( function ( api ) {
+ this.upload.getApi().done( function ( api ) {
// If the user can't upload anything, don't give them the option to.
api.getUserInfo().done( function ( userInfo ) {
if ( userInfo.rights.indexOf( 'upload' ) === -1 ) {
UP = Upload.prototype;
+ /**
+ * Get the mw.Api instance used by this Upload object.
+ *
+ * @return {jQuery.Promise}
+ * @return {Function} return.done
+ * @return {mw.Api} return.done.api
+ */
+ UP.getApi = function () {
+ return $.Deferred().resolve( this.api ).promise();
+ };
+
/**
* Set the text of the file page, to be created on file upload.
*