jenkins-bot has submitted this change and it was merged.
Change subject: Move progress bar handling to upload step
......................................................................
Move progress bar handling to upload step
Bug: T86679
Change-Id: Id0f0f62a69bb693f454975813c28a5349ff203be
---
M resources/controller/uw.controller.Upload.js
M resources/mw.UploadWizard.js
2 files changed, 49 insertions(+), 29 deletions(-)
Approvals:
Gilles: Looks good to me, approved
jenkins-bot: Verified
diff --git a/resources/controller/uw.controller.Upload.js
b/resources/controller/uw.controller.Upload.js
index 0153dfa..26fefd9 100644
--- a/resources/controller/uw.controller.Upload.js
+++ b/resources/controller/uw.controller.Upload.js
@@ -71,5 +71,50 @@
this.ui.empty();
};
+ UP.moveTo = function () {
+ uw.controller.Step.prototype.moveTo.call( this );
+ this.progressBar = undefined;
+ };
+
+ /**
+ * Starts the upload progress bar.
+ */
+ UP.startProgressBar = function () {
+ $( '#mwe-upwiz-progress' ).show();
+ this.progressBar = new mw.GroupProgressBar(
'#mwe-upwiz-progress',
+ mw.message( 'mwe-upwiz-uploading' ).escaped(),
+ this.uploads,
+ [ 'stashed' ],
+ [ 'error' ],
+ 'transportProgress',
+ 'transportWeight' );
+ this.progressBar.start();
+ };
+
+ /**
+ * Starts progress bar if there's not an existing one.
+ */
+ UP.maybeStartProgressBar = function () {
+ if ( this.progressBarEmptyOrFinished() ) {
+ this.startProgressBar();
+ }
+ };
+
+ /**
+ * Check if there is a vacancy for a new progress bar.
+ */
+ UP.progressBarEmptyOrFinished = function () {
+ return !this.progressBar || this.progressBar.finished === true;
+ };
+
+ /**
+ * Update success count on the progress bar.
+ */
+ UP.updateProgressBarCount = function ( okCount ) {
+ if ( this.progressBar ) {
+ this.progressBar.showCount( okCount );
+ }
+ };
+
uw.controller.Upload = Upload;
}( mediaWiki.uploadWizard, jQuery, OO ) );
diff --git a/resources/mw.UploadWizard.js b/resources/mw.UploadWizard.js
index fbe673f..b35c04b 100644
--- a/resources/mw.UploadWizard.js
+++ b/resources/mw.UploadWizard.js
@@ -332,9 +332,7 @@
} )
.on( 'starting', function () {
- if ( !wizard.progressBar ||
wizard.progressBar.finished === true ) {
- wizard.startProgressBar();
- }
+
wizard.steps.file.maybeStartProgressBar();
wizard.allowCloseWindow =
mw.confirmCloseWindow( {
message: function () { return
mw.message( 'mwe-upwiz-prevent-close', wizard.uploads.length ).escaped(); },
@@ -538,18 +536,6 @@
transitionerDelay: 200, // milliseconds
- startProgressBar: function () {
- $( '#mwe-upwiz-progress' ).show();
- this.progressBar = new mw.GroupProgressBar(
'#mwe-upwiz-progress',
- mw.message( 'mwe-upwiz-uploading' ).escaped(),
- this.uploads,
- [ 'stashed' ],
- [ 'error' ],
- 'transportProgress',
- 'transportWeight' );
- this.progressBar.start();
- },
-
/**
* Helper function to check whether the upload process is
totally
* complete and we can safely leave the window.
@@ -595,15 +581,7 @@
test: function () { return !wizard.isComplete()
&& wizard.uploads.length > 0; }
} );
- $( '#mwe-upwiz-progress' ).show();
- this.progressBar = new mw.GroupProgressBar(
'#mwe-upwiz-progress',
- mw.message( 'mwe-upwiz-uploading' ).escaped(),
- this.uploads,
- [ 'stashed' ],
- [ 'error' ],
- 'transportProgress',
- 'transportWeight' );
- this.progressBar.start();
+ this.steps.file.startProgressBar();
// remove ability to change files
// ideally also hide the "button"... but then we
require styleable file input CSS trickery
@@ -666,9 +644,8 @@
}
} );
- if ( this.progressBar ) {
- this.progressBar.showCount( okCount );
- }
+ this.steps.file.updateProgressBarCount( okCount );
+
if ( okCount === ( this.uploads.length -
this.countEmpties() ) ) {
allOk = true;
selector = '.mwe-upwiz-file-next-all-ok';
@@ -736,8 +713,6 @@
}
this.moveToStep( 'file' );
-
- this.progressBar = undefined;
}
},
--
To view, visit https://gerrit.wikimedia.org/r/184688
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id0f0f62a69bb693f454975813c28a5349ff203be
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
Gerrit-Reviewer: Gilles <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits