MarkTraceur has uploaded a new change for review.
https://gerrit.wikimedia.org/r/86810
Change subject: jquery audit of mw.GroupProgressBar.js
......................................................................
jquery audit of mw.GroupProgressBar.js
Bug: 53245
Change-Id: I126aae3fe3344e6a8d1983a19d5cb3e8f7c52f16
---
M resources/mw.GroupProgressBar.js
M resources/uploadWizard.css
2 files changed, 63 insertions(+), 28 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard
refs/changes/10/86810/1
diff --git a/resources/mw.GroupProgressBar.js b/resources/mw.GroupProgressBar.js
index a6264f8..83dcfd0 100644
--- a/resources/mw.GroupProgressBar.js
+++ b/resources/mw.GroupProgressBar.js
@@ -2,22 +2,37 @@
/**
* this is a progress bar for monitoring multiple objects, giving summary view
*/
-mw.GroupProgressBar = function( selector, text, uploads, successStates,
errorStates, progressProperty, weightProperty ) {
+mw.GroupProgressBar = function ( selector, text, uploads, successStates,
errorStates, progressProperty, weightProperty ) {
+ var $body, $container;
+
+ this.$bar = $( '<div>' ).addClass( 'mwe-upwiz-progress-bar' );
+
+ // Estimated Time Remaining
+ this.$etr = $( '<div>' ).addClass( 'mwe-upwiz-etr' );
+
+ this.$innerContainer = $( '<div>' )
+ .addClass( 'mwe-upwiz-progress-bar-etr' )
+ .addClass( 'hidden' )
+ .append(
+ this.$bar,
+ this.$etr
+ );
+
+ $container = $( '<div>' )
+ .addClass( 'mwe-upwiz-progress-bar-etr-container' )
+ .html( this.$innerContainer );
+
+ $body = $( '<div>' )
+ .addClass( 'mwe-upwiz-progress' )
+ .html( $container );
+
// XXX need to figure out a way to put text inside bar
this.$selector = $( selector );
- this.$selector.html(
- '<div class="mwe-upwiz-progress">' +
- '<div class="mwe-upwiz-progress-bar-etr-container">' +
- '<div class="mwe-upwiz-progress-bar-etr"
style="display: none">' +
- '<div
class="mwe-upwiz-progress-bar"></div>' +
- '<div class="mwe-upwiz-etr"></div>' +
- '</div>' +
- '</div>' +
- '<div class="mwe-upwiz-count"></div>' +
- '</div>'
- );
+ this.$selector.html( $body );
- this.$selector.find( '.mwe-upwiz-progress-bar' ).progressbar( { value :
0 } );
+ this.$bar.progressbar( { value : 0 } );
+
+ this.$count = this.$selector.find( '.mwe-upwiz-count' );
this.uploads = uploads;
this.successStates = successStates;
@@ -32,8 +47,16 @@
/**
* Show the progress bar
*/
- showBar: function() {
- this.$selector.find( '.mwe-upwiz-progress-bar-etr' ).fadeIn(
200 );
+ showBar: function () {
+ var $ic = this.$innerContainer;
+
+ this.$innerContainer
+ .fadeIn( {
+ duration: 200,
+ start: function () {
+ $ic.removeClass( 'hidden' );
+ }
+ } );
},
/**
@@ -103,7 +126,15 @@
* Hide the progress bar with a slideup motion
*/
hideBar: function() {
- this.$selector.find( '.mwe-upwiz-progress-bar-etr' ).fadeOut(
200 );
+ var $ic = this.$innerContainer;
+
+ this.$innerContainer
+ .fadeOut( {
+ duration: 200,
+ done: function () {
+ $ic.addClass( 'hidden' );
+ }
+ } );
},
/**
@@ -113,9 +144,8 @@
* @param time optional; the time this bar is presumed to have started
(epoch milliseconds)
*/
setBeginTime: function( time ) {
- this.beginTime = time ? time : ( new Date() ).getTime();
+ this.beginTime = time ? time : Date.now();
},
-
/**
* Show overall progress for the entire UploadWizard
@@ -128,24 +158,24 @@
var t, timeString,
remainingTime = this.getRemainingTime( fraction );
- this.$selector.find( '.mwe-upwiz-progress-bar' ).progressbar(
'value', parseInt( fraction * 100, 10 ) );
+ this.$bar.progressbar( 'value', parseInt( fraction * 100, 10 )
);
if ( remainingTime !== null ) {
t = mw.seconds2Measurements( parseInt( remainingTime /
1000, 10 ) );
if (t.hours === 0) {
if (t.minutes === 0) {
if (t.seconds === 0) {
- timeString = mw.message(
'mwe-upwiz-finished' ).escaped();
+ timeString = mw.message(
'mwe-upwiz-finished' ).text();
} else {
- timeString = mw.message(
'mwe-upwiz-secs-remaining', t.seconds ).escaped();
+ timeString = mw.message(
'mwe-upwiz-secs-remaining', t.seconds ).text();
}
} else {
- timeString = mw.message(
'mwe-upwiz-mins-secs-remaining', t.minutes, t.seconds, t.minutes + t.seconds
).escaped();
+ timeString = mw.message(
'mwe-upwiz-mins-secs-remaining', t.minutes, t.seconds, t.minutes + t.seconds
).text();
}
} else {
- timeString = mw.message(
'mwe-upwiz-hrs-mins-secs-remaining', t.hours, t.minutes, t.seconds ).escaped();
+ timeString = mw.message(
'mwe-upwiz-hrs-mins-secs-remaining', t.hours, t.minutes, t.seconds ).text();
}
- this.$selector.find( '.mwe-upwiz-etr' ).html(
timeString );
+ this.$etr.text( timeString );
}
},
@@ -158,7 +188,7 @@
getRemainingTime: function ( fraction ) {
var elapsedTime, rate;
if ( this.beginTime ) {
- elapsedTime = ( new Date() ).getTime() - this.beginTime;
+ elapsedTime = Date.now() - this.beginTime;
if ( fraction > 0.0 && elapsedTime > 0 ) { // or some
other minimums for good data
rate = fraction / elapsedTime;
return parseInt( ( 1.0 - fraction ) / rate, 10
);
@@ -173,9 +203,10 @@
* @param count -- the number of items that have done whatever has
been done e.g. in "uploaded 2 of 5", this is the 2
*/
showCount: function( count ) {
- this.$selector
- .find( '.mwe-upwiz-count' )
- .html( mw.message( 'mwe-upwiz-upload-count', count,
this.uploads.length - this.countEmpties() ).escaped() );
+ var total = this.uploads.length - this.countEmpties();
+ this.$count.text(
+ mw.message( 'mwe-upwiz-upload-count', count, total
).text()
+ );
},
countEmpties: function () {
diff --git a/resources/uploadWizard.css b/resources/uploadWizard.css
index fe3cb0c..74ac4e0 100644
--- a/resources/uploadWizard.css
+++ b/resources/uploadWizard.css
@@ -192,6 +192,10 @@
width: 300px;
}
+.mwe-upwiz-progress-bar-etr.hidden {
+ display: none;
+}
+
#mwe-upwiz-upload-ctrl-container {
float: right;
display: none;
--
To view, visit https://gerrit.wikimedia.org/r/86810
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I126aae3fe3344e6a8d1983a19d5cb3e8f7c52f16
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits