Index: trunk/extensions/UploadWizard/resources/mw.GroupProgressBar.js |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | /** |
3 | 3 | * this is a progress bar for monitoring multiple objects, giving summary view |
4 | 4 | */ |
5 | | -mw.GroupProgressBar = function( selector, text, uploads, endState, progressProperty, weightProperty ) { |
| 5 | +mw.GroupProgressBar = function( selector, text, uploads, endStates, progressProperty, weightProperty ) { |
6 | 6 | var _this = this; |
7 | 7 | |
8 | 8 | // XXX need to figure out a way to put text inside bar |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | _this.$selector.find( '.mwe-upwiz-progress-bar' ).progressbar( { value : 0 } ); |
23 | 23 | |
24 | 24 | _this.uploads = uploads; |
25 | | - _this.endState = endState; |
| 25 | + _this.endStates = endStates; |
26 | 26 | _this.progressProperty = progressProperty; |
27 | 27 | _this.weightProperty = weightProperty; |
28 | 28 | _this.beginTime = undefined; |
— | — | @@ -56,7 +56,7 @@ |
57 | 57 | var endStateCount = 0; |
58 | 58 | var hasData = false; |
59 | 59 | $j.each( _this.uploads, function( i, upload ) { |
60 | | - if ( upload.state == _this.endState ) { |
| 60 | + if ( $j.inArray( upload.state, _this.endStates ) !== -1 ) { |
61 | 61 | endStateCount++; |
62 | 62 | } |
63 | 63 | if (upload[_this.progressProperty] !== undefined) { |
Index: trunk/extensions/UploadWizard/resources/uploadWizard.css |
— | — | @@ -222,13 +222,13 @@ |
223 | 223 | } |
224 | 224 | |
225 | 225 | .mwe-upwiz-status-completed { |
226 | | - background: url(checkmark.gif) no-repeat left center; |
| 226 | + background: url(32px-Dialog-apply.svg.png) no-repeat left center; |
227 | 227 | font-weight: bold; |
228 | 228 | color: #009900; |
229 | 229 | } |
230 | 230 | |
231 | | -.mwe-upwiz-status-failed { |
232 | | - background: url(16px-Gnome-process-stop.svg.png) no-repeat left center; |
| 231 | +.mwe-upwiz-status-error { |
| 232 | + background: url(32px-Nuvola_apps_important_orange.svg.png) no-repeat left center; |
233 | 233 | font-weight: bold; |
234 | 234 | color: #CC0000; |
235 | 235 | } |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | * Represents the upload -- in its local and remote state. (Possibly those could be separate objects too...) |
4 | 4 | * This is our 'model' object if we are thinking MVC. Needs to be better factored, lots of feature envy with the UploadWizard |
5 | 5 | * states: |
6 | | - * 'new' 'transporting' 'transported' 'details' 'submitting-details' 'complete' 'failed' |
| 6 | + * 'new' 'transporting' 'transported' 'metadata' 'thumbnailed' 'details' 'submitting-details' 'complete' 'error' |
7 | 7 | * should fork this into two -- local and remote, e.g. filename |
8 | 8 | */ |
9 | 9 | ( function( $j ) { |
— | — | @@ -81,11 +81,11 @@ |
82 | 82 | /** |
83 | 83 | * Stop the upload -- we have failed for some reason |
84 | 84 | */ |
85 | | - setFailed: function( code ) { |
| 85 | + setError: function( code, info ) { |
86 | 86 | /* stop the upload progress */ |
87 | | - this.state = 'failed'; |
| 87 | + this.state = 'error'; |
88 | 88 | this.transportProgress = 0; |
89 | | - this.ui.showFailed( code ); |
| 89 | + this.ui.showError( code, info ); |
90 | 90 | }, |
91 | 91 | |
92 | 92 | /** |
— | — | @@ -113,14 +113,14 @@ |
114 | 114 | |
115 | 115 | // and other errors that result in a stash |
116 | 116 | } else { |
117 | | - // XXX handle errors better |
118 | | - _this.state = 'error'; |
119 | | - _this.ui.showFailed(); |
| 117 | + // XXX handle errors better -- get code and pass to showError |
| 118 | + var code = 'unknown'; |
| 119 | + var info = 'unknown'; |
120 | 120 | if ( result.error ) { |
121 | | - alert( "error : " + result.error.code + " : " + result.error.info ); |
| 121 | + code = result.error.code; |
| 122 | + info = result.error.info; |
122 | 123 | } |
123 | | - // TODO now we should tag the upload as failed |
124 | | - // if can recover, should maybe allow re-uploading. |
| 124 | + _this.setError( code, info ); |
125 | 125 | } |
126 | 126 | |
127 | 127 | }, |
— | — | @@ -275,9 +275,8 @@ |
276 | 276 | _this.div = $j('<div class="mwe-upwiz-file"></div>').get(0); |
277 | 277 | _this.isFilled = false; |
278 | 278 | |
279 | | - _this.fileInputCtrl = $j('<input size="1" class="mwe-upwiz-file-input" name="file" type="file"/>') |
280 | | - .change( function() { _this.fileChanged(); } ) |
281 | | - .get(0); |
| 279 | + _this.$fileInputCtrl = $j('<input size="1" class="mwe-upwiz-file-input" name="file" type="file"/>') |
| 280 | + .change( function() { _this.fileChanged(); } ); |
282 | 281 | |
283 | 282 | |
284 | 283 | visibleFilenameDiv = $j('<div class="mwe-upwiz-visible-file"></div>') |
— | — | @@ -292,13 +291,14 @@ |
293 | 292 | + '</div>' |
294 | 293 | + '</div>' |
295 | 294 | ); |
296 | | - visibleFilenameDiv.find( '.mwe-upwiz-file-status-line' ).append( |
297 | | - $j.fn.removeCtrl( |
298 | | - 'mwe-upwiz-remove', |
299 | | - 'mwe-upwiz-remove-upload', |
300 | | - function() { _this.upload.remove(); } |
301 | | - ).addClass( "mwe-upwiz-file-status-line-item" ) |
| 295 | + _this.$removeCtrl = $j.fn.removeCtrl( |
| 296 | + 'mwe-upwiz-remove', |
| 297 | + 'mwe-upwiz-remove-upload', |
| 298 | + function() { _this.upload.remove(); } |
302 | 299 | ); |
| 300 | + visibleFilenameDiv.find( '.mwe-upwiz-file-status-line' ) |
| 301 | + .append( _this.$removeCtrl ) |
| 302 | + .addClass( "mwe-upwiz-file-status-line-item" ); |
303 | 303 | |
304 | 304 | |
305 | 305 | //_this.errorDiv = $j('<div class="mwe-upwiz-upload-error mwe-upwiz-file-indicator" style="display: none;"></div>').get(0); |
— | — | @@ -324,7 +324,7 @@ |
325 | 325 | _this.form = $j('<form class="mwe-upwiz-form"></form>') |
326 | 326 | .append( visibleFilenameDiv ) |
327 | 327 | .append( _this.fileCtrlContainer |
328 | | - .append( _this.fileInputCtrl ) |
| 328 | + .append( _this.$fileInputCtrl ) |
329 | 329 | ) |
330 | 330 | .append( _this.filenameCtrl ) |
331 | 331 | .append( _this.thumbnailParam ) |
— | — | @@ -362,17 +362,11 @@ |
363 | 363 | .remove(); |
364 | 364 | }, |
365 | 365 | |
366 | | - busy: function() { |
367 | | - var _this = this; |
368 | | - // for now we implement this as looking like "100% progress" |
369 | | - // e.g. an animated bar that takes up all the space |
370 | | - // _this.showTransportProgress(); |
371 | | - }, |
372 | | - |
373 | 366 | /** |
374 | 367 | * change the indicator at the far right |
375 | 368 | */ |
376 | 369 | showIndicatorMessage: function( statusClass, msgKey ) { |
| 370 | + debugger; |
377 | 371 | var _this = this; |
378 | 372 | var $indicator = $j( _this.div ).find( '.mwe-upwiz-file-indicator' ); |
379 | 373 | $j.each( $indicator.attr( 'class' ).split( /\s+/ ), function( i, className ) { |
— | — | @@ -410,22 +404,26 @@ |
411 | 405 | * @param fraction The fraction of progress. Float between 0 and 1 |
412 | 406 | */ |
413 | 407 | showTransportProgress: function( fraction ) { |
414 | | - this.showIndicatorMessage( 'progress', 'mwe-upwiz-uploading' ); |
415 | | - // update individual progress bar with fraction? |
| 408 | + // if fraction available, update individual progress bar / estimates, etc. |
| 409 | + this.showIndicatorMessage( 'progress' ); |
| 410 | + this.setStatus( 'mwe-upwiz-uploading' ); |
416 | 411 | }, |
417 | 412 | |
418 | 413 | /** |
419 | 414 | * Show that upload is transported |
420 | 415 | */ |
421 | 416 | showTransported: function() { |
| 417 | + this.$removeCtrl.detach(); |
| 418 | + this.$fileInputCtrl.detach(); |
422 | 419 | this.showIndicatorMessage( 'completed', 'mwe-upwiz-transported' ); |
423 | 420 | }, |
424 | 421 | |
425 | 422 | /** |
426 | 423 | * Show that transport has failed |
427 | 424 | */ |
428 | | - showFailed: function( code ) { |
429 | | - this.showIndicatorMessage( 'failed', 'mwe-upwiz-failed' ); |
| 425 | + showError: function( code, info ) { |
| 426 | + // XXX TODO use code |
| 427 | + this.showIndicatorMessage( 'error', 'mwe-upwiz-error' ); |
430 | 428 | //add a "retry" button, too? |
431 | 429 | }, |
432 | 430 | |
— | — | @@ -436,7 +434,7 @@ |
437 | 435 | fileChanged: function() { |
438 | 436 | var _this = this; |
439 | 437 | _this.clearErrors(); |
440 | | - _this.upload.extractLocalFileInfo( $j( _this.fileInputCtrl ).val() ); |
| 438 | + _this.upload.extractLocalFileInfo( _this.$fileInputCtrl.val() ); |
441 | 439 | if ( _this.isGoodExtension( _this.upload.title.getExtension() ) ) { |
442 | 440 | _this.updateFilename(); |
443 | 441 | } else { |
— | — | @@ -465,9 +463,9 @@ |
466 | 464 | // shift the file input over with negative margins, |
467 | 465 | // internal to the overflow-containing div, so the div shows all button |
468 | 466 | // and none of the textfield-like input |
469 | | - $j( this.fileInputCtrl ).css( { |
470 | | - 'margin-left': '-' + ~~( $j( this.fileInputCtrl ).width() - $covered.outerWidth() - 10 ) + 'px', |
471 | | - 'margin-top' : '-' + ~~( $j( this.fileInputCtrl ).height() - $covered.outerHeight() - 10 ) + 'px' |
| 467 | + this.$fileInputCtrl.css( { |
| 468 | + 'margin-left': '-' + ~~( this.$fileInputCtrl.width() - $covered.outerWidth() - 10 ) + 'px', |
| 469 | + 'margin-top' : '-' + ~~( this.$fileInputCtrl.height() - $covered.outerHeight() - 10 ) + 'px' |
472 | 470 | } ); |
473 | 471 | |
474 | 472 | |
— | — | @@ -484,7 +482,7 @@ |
485 | 483 | updateFilename: function() { |
486 | 484 | var _this = this; |
487 | 485 | // TODO get basename of file; Chrome does this C:\fakepath\something which is highly irritating |
488 | | - var path = _this.fileInputCtrl.value; |
| 486 | + var path = _this.$fileInputCtrl.val(); |
489 | 487 | |
490 | 488 | // visible filenam. |
491 | 489 | $j( _this.form ).find( '.mwe-upwiz-visible-file-filename-text' ).html( path ); |
— | — | @@ -1529,56 +1527,21 @@ |
1530 | 1528 | $j( '#mwe-upwiz-stepdiv-file .mwe-upwiz-button-next') |
1531 | 1529 | .append( gM( 'mwe-upwiz-next-file' ) ) |
1532 | 1530 | .click( function() { |
1533 | | - // check if there is an upload at all |
1534 | | - if ( _this.uploads.length === 0 ) { |
1535 | | - // XXX use standard error message |
1536 | | - alert( gM( 'mwe-upwiz-file-need-file' ) ); |
1537 | | - return; |
1538 | | - } |
1539 | | - |
1540 | | - _this.removeEmptyUploads(); |
1541 | | - _this.startUploads( function() { |
1542 | | - |
1543 | | - // okay all uploads are done, we're ready to go to the next step |
1544 | | - |
1545 | | - // do some last minute prep before advancing to the DEEDS page |
1546 | | - |
1547 | | - // these deeds are standard |
1548 | | - var deeds = [ |
1549 | | - new mw.UploadWizardDeedOwnWork( _this.uploads.length ), |
1550 | | - new mw.UploadWizardDeedThirdParty( _this.uploads.length ) |
1551 | | - ]; |
1552 | | - |
1553 | | - // if we have multiple uploads, also give them the option to set |
1554 | | - // licenses individually |
1555 | | - if ( _this.uploads.length > 1 ) { |
1556 | | - var customDeed = $j.extend( new mw.UploadWizardDeed(), { |
1557 | | - valid: function() { return true; }, |
1558 | | - name: 'custom' |
1559 | | - } ); |
1560 | | - deeds.push( customDeed ); |
| 1531 | + // check if there is an upload at all (should never happen) |
| 1532 | + if ( _this.uploads.length === 0 ) { |
| 1533 | + // XXX use standard error message |
| 1534 | + alert( gM( 'mwe-upwiz-file-need-file' ) ); |
| 1535 | + return; |
1561 | 1536 | } |
1562 | 1537 | |
1563 | | - _this.deedChooser = new mw.UploadWizardDeedChooser( |
1564 | | - '#mwe-upwiz-deeds', |
1565 | | - deeds, |
1566 | | - _this.uploads.length ); |
1567 | | - |
1568 | | - $j( '<div>' ).html( gM( 'mwe-upwiz-deeds-macro-prompt', _this.uploads.length ) ) |
1569 | | - .insertBefore ( _this.deedChooser.$selector.find( '.mwe-upwiz-deed-ownwork' ) ); |
| 1538 | + _this.removeEmptyUploads(); |
| 1539 | + _this.startUploads( function() { |
| 1540 | + // okay all uploads are done, we may be ready to go to the next step |
| 1541 | + alert( "hey, uploads are done"); |
1570 | 1542 | |
1571 | | - if ( _this.uploads.length > 1 ) { |
1572 | | - $j( '<div style="margin-top: 1em">' ).html( gM( 'mwe-upwiz-deeds-custom-prompt' ) ) |
1573 | | - .insertBefore( _this.deedChooser.$selector.find( '.mwe-upwiz-deed-custom' ) ); |
1574 | | - } |
| 1543 | + } ); |
| 1544 | + } ); |
1575 | 1545 | |
1576 | | - |
1577 | | - _this.moveToStep( 'deeds' ); |
1578 | | - |
1579 | | - } ); |
1580 | | - } ); |
1581 | | - |
1582 | | - |
1583 | 1546 | // DEEDS div |
1584 | 1547 | |
1585 | 1548 | $j( '#mwe-upwiz-deeds-intro' ).html( gM( 'mwe-upwiz-deeds-intro' ) ); |
— | — | @@ -1639,6 +1602,43 @@ |
1640 | 1603 | |
1641 | 1604 | }, |
1642 | 1605 | |
| 1606 | + |
| 1607 | + // do some last minute prep before advancing to the DEEDS page |
| 1608 | + prepareAndMoveToDeeds: function() { |
| 1609 | + |
| 1610 | + // these deeds are standard |
| 1611 | + var deeds = [ |
| 1612 | + new mw.UploadWizardDeedOwnWork( _this.uploads.length ), |
| 1613 | + new mw.UploadWizardDeedThirdParty( _this.uploads.length ) |
| 1614 | + ]; |
| 1615 | + |
| 1616 | + // if we have multiple uploads, also give them the option to set |
| 1617 | + // licenses individually |
| 1618 | + if ( _this.uploads.length > 1 ) { |
| 1619 | + var customDeed = $j.extend( new mw.UploadWizardDeed(), { |
| 1620 | + valid: function() { return true; }, |
| 1621 | + name: 'custom' |
| 1622 | + } ); |
| 1623 | + deeds.push( customDeed ); |
| 1624 | + } |
| 1625 | + |
| 1626 | + _this.deedChooser = new mw.UploadWizardDeedChooser( |
| 1627 | + '#mwe-upwiz-deeds', |
| 1628 | + deeds, |
| 1629 | + _this.uploads.length ); |
| 1630 | + |
| 1631 | + $j( '<div>' ).html( gM( 'mwe-upwiz-deeds-macro-prompt', _this.uploads.length ) ) |
| 1632 | + .insertBefore ( _this.deedChooser.$selector.find( '.mwe-upwiz-deed-ownwork' ) ); |
| 1633 | + |
| 1634 | + if ( _this.uploads.length > 1 ) { |
| 1635 | + $j( '<div style="margin-top: 1em">' ).html( gM( 'mwe-upwiz-deeds-custom-prompt' ) ) |
| 1636 | + .insertBefore( _this.deedChooser.$selector.find( '.mwe-upwiz-deed-custom' ) ); |
| 1637 | + } |
| 1638 | + |
| 1639 | + _this.moveToStep( 'deeds' ); |
| 1640 | + |
| 1641 | + }, |
| 1642 | + |
1643 | 1643 | /** |
1644 | 1644 | * Advance one "step" in the wizard interface. |
1645 | 1645 | * It is assumed that the previous step to the current one was selected. |
— | — | @@ -1783,7 +1783,7 @@ |
1784 | 1784 | var toRemove = []; |
1785 | 1785 | |
1786 | 1786 | for ( var i = 0; i < _this.uploads.length; i++ ) { |
1787 | | - if ( mw.isEmpty( _this.uploads[i].ui.fileInputCtrl.value ) ) { |
| 1787 | + if ( mw.isEmpty( _this.uploads[i].ui.$fileInputCtrl.val() ) ) { |
1788 | 1788 | toRemove.push( _this.uploads[i] ); |
1789 | 1789 | } |
1790 | 1790 | } |
— | — | @@ -1798,11 +1798,11 @@ |
1799 | 1799 | * |
1800 | 1800 | * @param beginState what state the upload should be in before starting. |
1801 | 1801 | * @param progressState the state to set the upload to while it's doing whatever |
1802 | | - * @param endState the state to set the upload to after it's done whatever |
| 1802 | + * @param endState the state (or array of states) that signify we're done with this process |
1803 | 1803 | * @param starter function, taking single argument (upload) which starts the process we're interested in |
1804 | 1804 | * @param endCallback function to call when all uploads are in the end state. |
1805 | 1805 | */ |
1806 | | - makeTransitioner: function( beginState, progressState, endState, starter, endCallback ) { |
| 1806 | + makeTransitioner: function( beginState, progressStates, endStates, starter, endCallback ) { |
1807 | 1807 | |
1808 | 1808 | var _this = this; |
1809 | 1809 | |
— | — | @@ -1810,9 +1810,9 @@ |
1811 | 1811 | var uploadsToStart = _this.maxSimultaneousConnections; |
1812 | 1812 | var endStateCount = 0; |
1813 | 1813 | $j.each( _this.uploads, function(i, upload) { |
1814 | | - if ( upload.state == endState ) { |
| 1814 | + if ( $j.inArray( upload.state, endStates ) !== -1 ) { |
1815 | 1815 | endStateCount++; |
1816 | | - } else if ( upload.state == progressState ) { |
| 1816 | + } else if ( $j.inArray( upload.state, progressStates ) !== -1 ) { |
1817 | 1817 | uploadsToStart--; |
1818 | 1818 | } else if ( ( upload.state == beginState ) && ( uploadsToStart > 0 ) ) { |
1819 | 1819 | starter( upload ); |
— | — | @@ -1852,7 +1852,7 @@ |
1853 | 1853 | var progressBar = new mw.GroupProgressBar( '#mwe-upwiz-progress', |
1854 | 1854 | gM( 'mwe-upwiz-uploading' ), |
1855 | 1855 | _this.uploads, |
1856 | | - 'transported', |
| 1856 | + [ 'error', 'thumbnailed' ], |
1857 | 1857 | 'transportProgress', |
1858 | 1858 | 'transportWeight' ); |
1859 | 1859 | progressBar.start(); |
— | — | @@ -1866,8 +1866,8 @@ |
1867 | 1867 | // the progress bar and elapsed time |
1868 | 1868 | _this.makeTransitioner( |
1869 | 1869 | 'new', |
1870 | | - 'transporting', |
1871 | | - 'transported', |
| 1870 | + [ 'transporting', 'transported', 'metadata' ], |
| 1871 | + [ 'error', 'thumbnailed' ], |
1872 | 1872 | function( upload ) { |
1873 | 1873 | upload.start(); |
1874 | 1874 | }, |
— | — | @@ -1975,8 +1975,8 @@ |
1976 | 1976 | // add in the upload count |
1977 | 1977 | _this.makeTransitioner( |
1978 | 1978 | 'details', |
1979 | | - 'submitting-details', |
1980 | | - 'complete', |
| 1979 | + [ 'submitting-details' ], |
| 1980 | + [ 'complete' ], |
1981 | 1981 | function( upload ) { |
1982 | 1982 | upload.details.submit( function() { |
1983 | 1983 | upload.details.div.data( 'mask' ).html(); |
Index: trunk/extensions/UploadWizard/resources/mw.ApiUploadHandler.js |
— | — | @@ -21,8 +21,12 @@ |
22 | 22 | var _this = this; |
23 | 23 | this.transport = new mw.IframeTransport( |
24 | 24 | this.$form, |
25 | | - function( fraction ){ _this.upload.setTransportProgress( fraction ); }, |
| 25 | + function( fraction ) { |
| 26 | + debugger; |
| 27 | + _this.upload.setTransportProgress( fraction ); |
| 28 | + }, |
26 | 29 | function( result ) { |
| 30 | + debugger; |
27 | 31 | _this.upload.setTransported( result ); |
28 | 32 | } |
29 | 33 | ); |
— | — | @@ -107,7 +111,8 @@ |
108 | 112 | var ok = function() { |
109 | 113 | mw.log( "api: upload start!" ); |
110 | 114 | _this.beginTime = ( new Date() ).getTime(); |
111 | | - _this.upload.ui.busy(); |
| 115 | + _this.upload.ui.setStatus( 'mwe-upwiz-transport-started' ); |
| 116 | + _this.upload.ui.showTransportProgress(); |
112 | 117 | _this.$form.submit(); |
113 | 118 | }; |
114 | 119 | var err = function( code, info ) { |
Index: trunk/extensions/UploadWizard/resources/mw.IframeTransport.js |
— | — | @@ -56,6 +56,7 @@ |
57 | 57 | // Set up the completion callback |
58 | 58 | var _this = this; |
59 | 59 | $j( '#' + this.iframeId ).load( function() { |
| 60 | + debugger; |
60 | 61 | mw.log( "received result in iframe" ); |
61 | 62 | _this.progressCb( 1.0 ); |
62 | 63 | _this.processIframeResult( $j( this ).get( 0 ) ); |