* @inheritdoc
*/
mw.ForeignStructuredUpload.BookletLayout.prototype.initialize = function () {
- var deferred = $.Deferred();
- mw.ForeignStructuredUpload.BookletLayout.parent.prototype.initialize.call( this )
- .done( function () {
+ var booklet = this;
+ return mw.ForeignStructuredUpload.BookletLayout.parent.prototype.initialize.call( this ).then(
+ function () {
// Point the CategorySelector to the right wiki
- 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
- this.categoriesWidget.api = new mw.ForeignApi( api.apiUrl );
+ return booklet.upload.getApi().then(
+ 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
+ booklet.categoriesWidget.api = new mw.ForeignApi( api.apiUrl );
+ }
+ return $.Deferred().resolve();
+ },
+ function () {
+ return $.Deferred().resolve();
}
- }.bind( this ) ).always( function () {
- deferred.resolve();
- } );
- }.bind( this ) );
- return deferred.promise();
+ );
+ },
+ function () {
+ return $.Deferred().resolve();
+ }
+ );
};
/**
* @return {jQuery.Promise} Promise resolved when everything is initialized
*/
mw.Upload.BookletLayout.prototype.initialize = function () {
- var
- booklet = this,
- deferred = $.Deferred();
+ var booklet = this;
this.clear();
this.upload = this.createUpload();
this.setPage( 'upload' );
- 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 ) {
- // TODO Use a better error message when not all logged-in users can upload
- booklet.getPage( 'upload' ).$element.msg( 'api-error-mustbeloggedin' );
- }
- } ).always( function () {
- deferred.resolve();
- } );
- } ).fail( function ( errorMsg ) {
- booklet.getPage( 'upload' ).$element.msg( errorMsg );
- deferred.resolve();
- } );
-
- return deferred.promise();
+ return this.upload.getApi().then(
+ function ( api ) {
+ // If the user can't upload anything, don't give them the option to.
+ return api.getUserInfo().then(
+ function ( userInfo ) {
+ if ( userInfo.rights.indexOf( 'upload' ) === -1 ) {
+ // TODO Use a better error message when not all logged-in users can upload
+ booklet.getPage( 'upload' ).$element.msg( 'api-error-mustbeloggedin' );
+ }
+ return $.Deferred().resolve();
+ },
+ function () {
+ return $.Deferred().resolve();
+ }
+ );
+ },
+ function ( errorMsg ) {
+ booklet.getPage( 'upload' ).$element.msg( errorMsg );
+ return $.Deferred().resolve();
+ }
+ );
};
/**