Merge "mediawiki.Upload: Add #getApi method, use it instead of undocumented properties"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 6 Jan 2016 22:21:40 +0000 (22:21 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 6 Jan 2016 22:21:40 +0000 (22:21 +0000)
resources/src/mediawiki/mediawiki.ForeignStructuredUpload.BookletLayout.js
resources/src/mediawiki/mediawiki.ForeignUpload.js
resources/src/mediawiki/mediawiki.Upload.BookletLayout.js
resources/src/mediawiki/mediawiki.Upload.js

index ddf7f2b..4806097 100644 (file)
@@ -43,7 +43,7 @@
                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
index 61fb59f..aa08b6c 100644 (file)
         * 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
         */
index 26eabc7..1cd9101 100644 (file)
         */
        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 ) {
index d80b4eb..8a74ffc 100644 (file)
 
        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.
         *