Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js |
— | — | @@ -216,11 +216,26 @@ |
217 | 217 | var _this = this; |
218 | 218 | _this.clearErrors(); |
219 | 219 | _this.upload.extractLocalFileInfo( _this.$fileInputCtrl.val() ); |
220 | | - if ( _this.isGoodExtension( _this.upload.title.getExtension() ) ) { |
| 220 | + var extension = _this.upload.title.getExtension(); |
| 221 | + var isGoodExtension = $j.inArray( extension.toLowerCase(), mw.UploadWizard.config[ 'fileExtensions' ] ) !== -1; |
| 222 | + if ( isGoodExtension ) { |
221 | 223 | _this.updateFilename(); |
222 | 224 | } else { |
223 | | - //_this.error( 'bad-filename-extension', ext ); |
224 | | - alert("bad extension"); |
| 225 | + $( '<div>' ) |
| 226 | + .append( |
| 227 | + $j( '<p>' ).msg( 'mwe-upwiz-upload-error-bad-filename-extension', extension ), |
| 228 | + $j( '<p>' ).msg( 'mwe-upwiz-allowed-filename-extensions' ), |
| 229 | + $j( '<blockquote>' ).append( $j( '<tt>' ).append( |
| 230 | + mw.UploadWizard.config[ 'fileExtensions' ].join( " " ) |
| 231 | + ) ) |
| 232 | + ) |
| 233 | + .dialog({ |
| 234 | + width: 500, |
| 235 | + zIndex: 200000, |
| 236 | + autoOpen: true, |
| 237 | + title: gM( 'mwe-upwiz-help-popup' ) + ': ' + gM( 'mwe-upwiz-help-allowed-filename-extensions' ), |
| 238 | + modal: true |
| 239 | + }); |
225 | 240 | } |
226 | 241 | this.clearStatus(); |
227 | 242 | }, |
— | — | @@ -337,15 +352,6 @@ |
338 | 353 | // apply a error style to entire did |
339 | 354 | $j( _this.div ).addClass( 'mwe-upwiz-upload-error' ); |
340 | 355 | $j( _this.errorDiv ).show(); |
341 | | - }, |
342 | | - |
343 | | - /** |
344 | | - * This is used when checking for "bad" extensions in a filename. |
345 | | - * @param ext |
346 | | - * @return boolean if extension was acceptable |
347 | | - */ |
348 | | - isGoodExtension: function( ext ) { |
349 | | - return $j.inArray( ext.toLowerCase(), mw.UploadWizard.config[ 'fileExtensions' ] ) !== -1; |
350 | 356 | } |
351 | 357 | |
352 | 358 | }; |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js |
— | — | @@ -62,14 +62,13 @@ |
63 | 63 | // we signal to the wizard to update itself, which has to delete the final vestige of |
64 | 64 | // this upload (the ui.div). We have to do this silly dance because we |
65 | 65 | // trigger through the div. Triggering through objects doesn't always work. |
66 | | - // TODO fix -- this now works in jquery 1.4.2 |
| 66 | + // TODO v.1.1 fix, don't need to use the div any more -- this now works in jquery 1.4.2 |
67 | 67 | $j( this.ui.div ).trigger( 'removeUploadEvent' ); |
68 | 68 | }, |
69 | 69 | |
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Wear our current progress, for observing processes to see |
73 | | - * XXX this is kind of a misnomer; this event is not firing except for the very first time. |
74 | 73 | * @param fraction |
75 | 74 | */ |
76 | 75 | setTransportProgress: function ( fraction ) { |
— | — | @@ -188,9 +187,9 @@ |
189 | 188 | } |
190 | 189 | } |
191 | 190 | |
192 | | - // TODO this needs to be rethought. |
193 | | - // we should already have an extension, but if we don't... ?? |
194 | 191 | if ( _this.title.getExtension() === null ) { |
| 192 | + // TODO v1.1 what if we don't have an extension? Should be impossible as it is currently impossible to upload without extension, but you |
| 193 | + // never know... theoretically there is no restriction on extensions if we are uploading to the stash, but the check is performed anyway. |
195 | 194 | /* |
196 | 195 | var extension = mw.UploadWizardUtil.getExtension( _this.imageinfo.url ); |
197 | 196 | if ( !extension ) { |
— | — | @@ -409,8 +408,14 @@ |
410 | 409 | .click( function() { |
411 | 410 | // check if there is an upload at all (should never happen) |
412 | 411 | if ( _this.uploads.length === 0 ) { |
413 | | - // XXX use standard error message |
414 | | - alert( gM( 'mwe-upwiz-file-need-file' ) ); |
| 412 | + $( '<div>' ) |
| 413 | + .html( gM( 'mwe-upwiz-file-need-file' ) ) |
| 414 | + .dialog({ |
| 415 | + width: 500, |
| 416 | + zIndex: 200000, |
| 417 | + autoOpen: true, |
| 418 | + modal: true |
| 419 | + }); |
415 | 420 | return; |
416 | 421 | } |
417 | 422 | |
— | — | @@ -619,7 +624,6 @@ |
620 | 625 | setUploadFilled: function( upload ) { |
621 | 626 | var _this = this; |
622 | 627 | |
623 | | - // XXX check if it has a file? |
624 | 628 | _this.uploads.push( upload ); |
625 | 629 | |
626 | 630 | /* useful for making ids unique and so on */ |
— | — | @@ -630,9 +634,7 @@ |
631 | 635 | |
632 | 636 | upload.deedPreview = new mw.UploadWizardDeedPreview( upload ); |
633 | 637 | |
634 | | - // XXX do we really need to do this now? some things will even change after step 2. |
635 | | - // legacy. |
636 | | - // set up details |
| 638 | + // TODO v1.1 consider if we really have to set up details now |
637 | 639 | upload.details = new mw.UploadWizardDetails( upload, $j( '#mwe-upwiz-macro-files' ) ); |
638 | 640 | }, |
639 | 641 | |
— | — | @@ -937,8 +939,6 @@ |
938 | 940 | // some details blocks cannot be submitted (for instance, identical file hash) |
939 | 941 | _this.removeBlockedDetails(); |
940 | 942 | |
941 | | - // XXX validate all |
942 | | - |
943 | 943 | // remove ability to edit details |
944 | 944 | $j.each( _this.uploads, function( i, upload ) { |
945 | 945 | upload.details.div.mask(); |
— | — | @@ -1136,7 +1136,7 @@ |
1137 | 1137 | * Adds a tipsy pop-up help button to the field. Can be called in two ways -- with simple string id, which identifies |
1138 | 1138 | * the string as 'mwe-upwiz-tooltip-' plus that id, and creates the hint with a similar id |
1139 | 1139 | * or with function and id -- function will be called to generate the hint every time |
1140 | | - * XXX split into two plugins? |
| 1140 | + * TODO v1.1 split into two plugins? |
1141 | 1141 | * @param key {string} -- will base the tooltip on a message found with this key |
1142 | 1142 | * @param fn {function} optional -- call this function every time tip is created to generate message. If present HTML element gets an id of the exact key specified |
1143 | 1143 | */ |