Add getImageInfo to mw.Upload
authorMark Holmquist <mtraceur@member.fsf.org>
Thu, 30 Jul 2015 18:52:38 +0000 (13:52 -0500)
committerMark Holmquist <mtraceur@member.fsf.org>
Thu, 30 Jul 2015 18:59:22 +0000 (13:59 -0500)
Just a little shortcut and so you don't need to rely on the promises.

Bug: T107460
Change-Id: I1e36f3cd8cb6b50ec5db6d77512ce03cd98a2caf

resources/src/mediawiki/mediawiki.Upload.js

index 197ea6f..b842545 100644 (file)
@@ -21,6 +21,8 @@
                this.filename = null;
                this.file = null;
                this.state = Upload.State.NEW;
+
+               this.imageinfo = undefined;
        }
 
        UP = Upload.prototype;
                return this.state;
        };
 
+       /**
+        * Get the imageinfo object for the finished upload.
+        * Only available once the upload is finished! Don't try to get it
+        * beforehand.
+        * @return {Object|undefined}
+        */
+       UP.getImageInfo = function () {
+               return this.imageinfo;
+       };
+
        /**
         * Upload the file directly.
         * @return {jQuery.Promise}
                        text: this.text
                } ).then( function ( result ) {
                        upload.state = Upload.State.UPLOADED;
+                       upload.imageinfo = result.upload.imageinfo;
                        return result;
                }, function () {
                        upload.state = Upload.State.ERROR;