jenkins-bot has submitted this change and it was merged.

Change subject: Move progress bar functionality up to DataTransferHandler
......................................................................


Move progress bar functionality up to DataTransferHandler

Some non-file DTH's may need to show progress bars, e.g. if they
make an AJAX request.

Change-Id: Ied21e574baad8384c86dd642d8abd469c51b4688
---
M src/ui/ve.ui.DataTransferHandler.js
M src/ui/ve.ui.FileTransferHandler.js
2 files changed, 39 insertions(+), 26 deletions(-)

Approvals:
  Cscott: Looks good to me, but someone else must approve
  Jforrester: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/ui/ve.ui.DataTransferHandler.js 
b/src/ui/ve.ui.DataTransferHandler.js
index 85bc600..06a47fb 100644
--- a/src/ui/ve.ui.DataTransferHandler.js
+++ b/src/ui/ve.ui.DataTransferHandler.js
@@ -18,6 +18,8 @@
        // Properties
        this.surface = surface;
        this.item = item;
+       this.progress = false;
+       this.progressBar = null;
 
        this.insertableDataDeferred = $.Deferred();
 };
@@ -125,3 +127,34 @@
 ve.ui.DataTransferHandler.prototype.abort = function () {
        this.insertableDataDeferred.reject();
 };
+
+/**
+ * Create a progress bar with a specified label
+ *
+ * @param {jQuery.Promise} progressCompletePromise Promise which resolves when 
the progress action is complete
+ * @param {jQuery|string|Function} label Progress bar label
+ */
+ve.ui.DataTransferHandler.prototype.createProgress = function ( 
progressCompletePromise, label ) {
+       var handler = this;
+
+       this.surface.createProgress( progressCompletePromise, label ).done( 
function ( progressBar, cancelPromise ) {
+               // Set any progress that was achieved before this resolved
+               progressBar.setProgress( handler.progress );
+               handler.progressBar = progressBar;
+               cancelPromise.fail( handler.abort.bind( handler ) );
+       } );
+};
+
+/**
+ * Set progress bar progress
+ *
+ * Progress is stored in a property in case the progress bar doesn't exist yet.
+ *
+ * @param {number} progress Progress percent
+ */
+ve.ui.DataTransferHandler.prototype.setProgress = function ( progress ) {
+       this.progress = progress;
+       if ( this.progressBar ) {
+               this.progressBar.setProgress( this.progress );
+       }
+};
diff --git a/src/ui/ve.ui.FileTransferHandler.js 
b/src/ui/ve.ui.FileTransferHandler.js
index 31c2e8f..1780c2f 100644
--- a/src/ui/ve.ui.FileTransferHandler.js
+++ b/src/ui/ve.ui.FileTransferHandler.js
@@ -24,9 +24,6 @@
 
        this.reader = new FileReader();
 
-       this.progress = false;
-       this.progressBar = null;
-
        // Events
        this.reader.addEventListener( 'progress', this.onFileProgress.bind( 
this ) );
        this.reader.addEventListener( 'load', this.onFileLoad.bind( this ) );
@@ -104,32 +101,15 @@
 };
 
 /**
- * Create a progress bar with a specified label
+ * Overrides the parent to make the default label the filename
  *
- * @param {jQuery.Promise} progressCompletePromise Promise which resolves when 
the progress action is complete
+ * @param {jQuery.Promise} progressCompletePromise
  * @param {jQuery|string|Function} [label] Progress bar label, defaults to 
file name
  */
 ve.ui.FileTransferHandler.prototype.createProgress = function ( 
progressCompletePromise, label ) {
-       var handler = this;
+       // Make the default label the filename
+       label = label || this.file.name;
 
-       this.surface.createProgress( progressCompletePromise, label || 
this.file.name ).done( function ( progressBar, cancelPromise ) {
-               // Set any progress that was achieved before this resolved
-               progressBar.setProgress( handler.progress );
-               handler.progressBar = progressBar;
-               cancelPromise.fail( handler.abort.bind( handler ) );
-       } );
-};
-
-/**
- * Set progress bar progress
- *
- * Progress is stored in a property in case the progress bar doesn't exist yet.
- *
- * @param {number} progress Progress percent
- */
-ve.ui.FileTransferHandler.prototype.setProgress = function ( progress ) {
-       this.progress = progress;
-       if ( this.progressBar ) {
-               this.progressBar.setProgress( this.progress );
-       }
+       // Parent method
+       ve.ui.FileTransferHandler.super.prototype.createProgress.call( this, 
progressCompletePromise, label );
 };

-- 
To view, visit https://gerrit.wikimedia.org/r/233203
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ied21e574baad8384c86dd642d8abd469c51b4688
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to