r66619 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66618‎ | r66619 | r66620 >
Date:19:46, 18 May 2010
Author:neilk
Status:deferred
Tags:
Comment:
primitive validation on upload page
Modified paths:
  • /trunk/extensions/UploadWizard/UploadWizard.i18n.php (modified) (history)
  • /trunk/extensions/UploadWizard/js/mw.UploadWizard.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php
@@ -105,6 +105,9 @@
106106 'mwe-upwiz-tooltip-description' => 'Briefly describe everything notable about the work. For a photo, mention the main things that are depicted, the occasion or the place.',
107107 'mwe-upwiz-tooltip-other' => 'Any other information you want to include about this work. You may use wikitext code.',
108108 'mwe-upwiz-tooltip-more-info' => 'Learn more.',
 109+ 'mwe-upwiz-file-need-file' => 'Please add an upload first.',
 110+ 'mwe-upwiz-file-need-start' => 'Please press this button to start your uploads.',
 111+ 'mwe-upwiz-file-need-complete' => 'Please wait until all files have finished uploading.',
109112 );
110113
111114 /** Message documentation (Message documentation)
Index: trunk/extensions/UploadWizard/js/mw.UploadWizard.js
@@ -6,7 +6,7 @@
77
88
99 /**
10 - *
 10+ * Sort of an abstract class for deeds
1111 */
1212 mw.UploadWizardDeed = function() {
1313 var _this = this;
@@ -367,7 +367,6 @@
368368 _this.transportProgress = 1;
369369 $j( _this ).trigger( 'transportedEvent' );
370370
371 - debugger;
372371 if ( result.upload && result.upload.imageinfo && result.upload.imageinfo.descriptionurl ) {
373372 // success
374373 _this.extractUploadInfo( result );
@@ -1868,7 +1867,28 @@
18691868 } );
18701869
18711870 $j( '#mwe-upwiz-stepdiv-file .mwe-upwiz-button-next').click( function() {
1872 - _this.moveToStep( 'deeds' );
 1871+ if ( _this.uploads.length === 0 ) {
 1872+ alert( gM( 'mwe-upwiz-file-need-file' ) );
 1873+ return;
 1874+ }
 1875+ var overallState = 'new';
 1876+ $j.each( _this.uploads, function( i, upload ) {
 1877+ if ( upload.state == 'transporting' ) {
 1878+ overallState = 'transporting';
 1879+ } else if ( upload.state == 'transported' && overallState != 'transporting' ) {
 1880+ overallState = 'transported';
 1881+ }
 1882+ } );
 1883+ if ( overallState == 'new' ) {
 1884+ alert( gM( 'mwe-upwiz-file-need-start' ) );
 1885+ } else if ( overallState == 'transporting' ) {
 1886+ alert( gM( 'mwe-upwiz-file-need-complete' ) );
 1887+ } else if ( overallState == 'transported' ) {
 1888+ _this.moveToStep( 'deeds' );
 1889+ } else {
 1890+ alert( "error: could not recognize state of uploads: " + overallState );
 1891+ }
 1892+
18731893 } );
18741894
18751895 // DEEDS div
@@ -2349,7 +2369,7 @@
23502370 $j( '<textarea class="mwe-long-textarea" rows="1"/>' )
23512371 .growTextArea()
23522372 .append( thumbWikiText )
2353 - .resizeIfNeeded()
 2373+ .trigger('change')
23542374 ),
23552375 $j('<p/>').append(
23562376 gM( 'mwe-upwiz-thanks-url' ),
@@ -2357,7 +2377,7 @@
23582378 $j( '<textarea class="mwe-long-textarea" rows="1"/>' )
23592379 .growTextArea()
23602380 .append( upload.imageinfo.descriptionurl )
2361 - .resizeIfNeeded()
 2381+ .trigger('change')
23622382 )
23632383 )
23642384 );
@@ -2962,7 +2982,7 @@
29632983 } );
29642984 }
29652985
2966 - this.resizeIfNeeded = function() {
 2986+ var resizeIfNeeded = function() {
29672987 // this is the dom element
29682988 while (this.scrollHeight > this.offsetHeight) {
29692989 this.rows++;
@@ -2972,8 +2992,8 @@
29732993
29742994 this.addClass( 'mwe-grow-textarea' );
29752995
2976 - this.change(this.resizeIfNeeded);
2977 - this.keyup(this.resizeIfNeeded);
 2996+ this.keyup( resizeIfNeeded );
 2997+ this.change( resizeIfNeeded );
29782998
29792999
29803000 return this;

Status & tagging log