r66432 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66431‎ | r66432 | r66433 >
Date:19:07, 14 May 2010
Author:neilk
Status:deferred
Tags:
Comment:
more jquery-like progressbar; shows and hides on first page
Modified paths:
  • /trunk/extensions/UploadWizard/js/mw.UploadWizard.js (modified) (history)
  • /trunk/extensions/UploadWizard/styles/uploadWizard.css (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/styles/uploadWizard.css
@@ -137,6 +137,10 @@
138138 text-align: center;
139139 }
140140
 141+.mwe-upwiz-count {
 142+ height: 60px;
 143+}
 144+
141145 .mwe-upwiz-add-files-n {
142146 float: left;
143147 margin-top: 5px;
@@ -496,3 +500,7 @@
497501 text-align: right; /* works for now, only one 'next' button */
498502 }
499503
 504+a.mwe-upwiz-tooltip-link {
 505+ cursor: pointer;
 506+ color: red;
 507+}
Index: trunk/extensions/UploadWizard/js/mw.UploadWizard.js
@@ -139,42 +139,53 @@
140140
141141 };
142142
 143+
143144 mw.ProgressBar = function( selector, text ) {
144145 var _this = this;
145146 // XXX need to figure out a way to put text inside bar
146147
147 - _this.progressBarDiv = $j('<div></div>')
148 - .addClass("mwe-upwiz-progress-bar")
149 - .progressbar( { value: 0 } );
 148+ _this.$selector = $j( selector );
 149+ _this.$selector.html(
 150+ '<div class="mwe-upwiz-progress">'
 151+ + '<div class="mwe-upwiz-progress-bar-etr" style="display: none">'
 152+ + '<div class="mwe-upwiz-progress-bar"></div>'
 153+ + '<div class="mwe-upwiz-etr"></div>'
 154+ + '</div>'
 155+ + '<div class="mwe-upwiz-count"></div>'
 156+ + '</div>'
 157+ );
150158
151 - _this.timeRemainingDiv = $j('<div></div>').addClass("mwe-upwiz-etr");
152 -
153 - _this.countDiv = $j('<div></div>').addClass("mwe-upwiz-count");
154 -
 159+ _this.$selector.find( '.mwe-upwiz-progress-bar' ).progressbar( { value : 0 } );
 160+
155161 _this.beginTime = undefined;
156 -
157 - $j( selector ).html(
158 - $j('<div />').addClass( 'mwe-upwiz-progress' )
159 - .append( $j( '<div></div>' )
160 - .addClass( 'mwe-upwiz-progress-bar-etr' )
161 - .append( _this.progressBarDiv )
162 - .append( _this.timeRemainingDiv ) )
163 - .append( $j( _this.countDiv ) )
164 - );
165162
166163 };
167164
168165 mw.ProgressBar.prototype = {
169166
170167 /**
 168+ * Show the progress bar with a slideout motion
 169+ */
 170+ showBar: function() {
 171+ this.$selector.find( '.mwe-upwiz-progress-bar-etr' ).slideDown( 500 );
 172+ },
 173+
 174+
 175+ /**
 176+ * Hide the progress bar with a slideup motion
 177+ */
 178+ hideBar: function() {
 179+ this.$selector.find( '.mwe-upwiz-progress-bar-etr' ).slideUp( 500 );
 180+ },
 181+
 182+ /**
171183 * sets the beginning time (useful for figuring out estimated time remaining)
172184 * if time parameter omitted, will set beginning time to now
173185 *
174186 * @param time optional; the time this bar is presumed to have started (epoch milliseconds)
175187 */
176188 setBeginTime: function( time ) {
177 - var _this = this;
178 - _this.beginTime = time ? time : ( new Date() ).getTime();
 189+ this.beginTime = time ? time : ( new Date() ).getTime();
179190 },
180191
181192 /**
@@ -182,8 +193,7 @@
183194 * @param total an integer, for display e.g. uploaded 1 of 5, this is the 5
184195 */
185196 setTotal: function(total) {
186 - var _this = this;
187 - _this.total = total;
 197+ this.total = total;
188198 },
189199
190200 /**
@@ -196,7 +206,7 @@
197207 showProgress: function( fraction ) {
198208 var _this = this;
199209
200 - _this.progressBarDiv.progressbar( 'value', parseInt( fraction * 100, 10 ) );
 210+ _this.$selector.find( '.mwe-upwiz-progress-bar' ).progressbar( 'value', parseInt( fraction * 100, 10 ) );
201211
202212 var remainingTime;
203213 if (_this.beginTime === null) {
@@ -206,8 +216,9 @@
207217 }
208218
209219 if ( remainingTime !== null ) {
210 - _this.timeRemainingDiv
211 - .html( gM( 'mwe-upwiz-remaining', mw.seconds2npt(parseInt(remainingTime / 1000), 10) ) );
 220+ _this.$selector
 221+ .find( '.mwe-upwiz-etr' )
 222+ .html( gM( 'mwe-upwiz-remaining', mw.seconds2npt( parseInt( remainingTime / 1000 ), 10 ) ) );
212223 }
213224 },
214225
@@ -236,7 +247,9 @@
237248 */
238249 showCount: function( count ) {
239250 var _this = this;
240 - _this.countDiv.html( gM( 'mwe-upwiz-upload-count', [ count, _this.total ] ) );
 251+ _this.$selector
 252+ .find( '.mwe-upwiz-count' )
 253+ .html( gM( 'mwe-upwiz-upload-count', [ count, _this.total ] ) );
241254 }
242255
243256
@@ -2216,8 +2229,14 @@
22172230 var totalCount = wizard.uploads.length;
22182231
22192232 var progressBar = new mw.ProgressBar( progressBarSelector, progressBarText );
 2233+ progressBar.showBar();
22202234 progressBar.setTotal( totalCount );
22212235
 2236+ var end = function() {
 2237+ progressBar.hideBar();
 2238+ endCallback();
 2239+ };
 2240+
22222241 transitioner = function() {
22232242 var fraction = 0.0;
22242243 var uploadsToStart = wizard.maxSimultaneousUploads;
@@ -2240,8 +2259,9 @@
22412260 progressBar.showProgress( fraction );
22422261 progressBar.showCount( endStateCount );
22432262
2244 - // build in a little delay even for the end state, so user can see progress bar in a complete state.
2245 - var nextAction = (endStateCount == totalCount) ? endCallback : transitioner;
 2263+ // build in a little delay even for the end state, so user can see progress bar in a complete state.
 2264+ var nextAction = (endStateCount == totalCount) ? end : transitioner;
 2265+
22462266 setTimeout( nextAction, wizard.transitionerDelay );
22472267 };
22482268

Status & tagging log