@@ -54,13 +54,14 @@ define([
54
54
this . $fileInput = fileInput ;
55
55
56
56
_ . extend ( this . uploaderConfig , {
57
- dropZone : $ ( fileInput ) . closest ( this . dropZone ) ,
58
- change : this . onFilesChoosed . bind ( this ) ,
59
- drop : this . onFilesChoosed . bind ( this ) ,
60
- add : this . onBeforeFileUpload . bind ( this ) ,
61
- done : this . onFileUploaded . bind ( this ) ,
62
- start : this . onLoadingStart . bind ( this ) ,
63
- stop : this . onLoadingStop . bind ( this )
57
+ dropZone : $ ( fileInput ) . closest ( this . dropZone ) ,
58
+ change : this . onFilesChoosed . bind ( this ) ,
59
+ drop : this . onFilesChoosed . bind ( this ) ,
60
+ add : this . onBeforeFileUpload . bind ( this ) ,
61
+ fail : this . onFail . bind ( this ) ,
62
+ done : this . onFileUploaded . bind ( this ) ,
63
+ start : this . onLoadingStart . bind ( this ) ,
64
+ stop : this . onLoadingStop . bind ( this )
64
65
} ) ;
65
66
66
67
$ ( fileInput ) . fileupload ( this . uploaderConfig ) ;
@@ -328,11 +329,12 @@ define([
328
329
* May be used for implementation of additional validation rules,
329
330
* e.g. total files and a total size rules.
330
331
*
331
- * @param {Event } e - Event object.
332
+ * @param {Event } event - Event object.
332
333
* @param {Object } data - File data that will be uploaded.
333
334
*/
334
- onFilesChoosed : function ( e , data ) {
335
- // no option exists in fileuploader for restricting upload chains to single files; this enforces that policy
335
+ onFilesChoosed : function ( event , data ) {
336
+ // no option exists in file uploader for restricting upload chains to single files
337
+ // this enforces that policy
336
338
if ( ! this . isMultipleFiles ) {
337
339
data . files . splice ( 1 ) ;
338
340
}
@@ -341,13 +343,13 @@ define([
341
343
/**
342
344
* Handler which is invoked prior to the start of a file upload.
343
345
*
344
- * @param {Event } e - Event object.
346
+ * @param {Event } event - Event object.
345
347
* @param {Object } data - File data that will be uploaded.
346
348
*/
347
- onBeforeFileUpload : function ( e , data ) {
348
- var file = data . files [ 0 ] ,
349
- allowed = this . isFileAllowed ( file ) ,
350
- target = $ ( e . target ) ;
349
+ onBeforeFileUpload : function ( event , data ) {
350
+ var file = data . files [ 0 ] ,
351
+ allowed = this . isFileAllowed ( file ) ,
352
+ target = $ ( event . target ) ;
351
353
352
354
if ( this . disabled ( ) ) {
353
355
this . notifyError ( $t ( 'The file upload field is disabled.' ) ) ;
@@ -356,7 +358,7 @@ define([
356
358
}
357
359
358
360
if ( allowed . passed ) {
359
- target . on ( 'fileuploadsend' , function ( event , postData ) {
361
+ target . on ( 'fileuploadsend' , function ( eventBound , postData ) {
360
362
postData . data . append ( 'param_name' , this . paramName ) ;
361
363
} . bind ( data ) ) ;
362
364
@@ -386,16 +388,25 @@ define([
386
388
} ) ;
387
389
} ,
388
390
391
+ /**
392
+ * @param {Event } event
393
+ * @param {Object } data
394
+ */
395
+ onFail : function ( event , data ) {
396
+ console . error ( data . jqXHR . responseText ) ;
397
+ console . error ( data . jqXHR . status ) ;
398
+ } ,
399
+
389
400
/**
390
401
* Handler of the file upload complete event.
391
402
*
392
- * @param {Event } e
403
+ * @param {Event } event
393
404
* @param {Object } data
394
405
*/
395
- onFileUploaded : function ( e , data ) {
406
+ onFileUploaded : function ( event , data ) {
396
407
var uploadedFilename = data . files [ 0 ] . name ,
397
- file = data . result ,
398
- error = file . error ;
408
+ file = data . result ,
409
+ error = file . error ;
399
410
400
411
error ?
401
412
this . aggregateError ( uploadedFilename , error ) :
@@ -469,10 +480,10 @@ define([
469
480
* Handler of the preview image load event.
470
481
*
471
482
* @param {Object } file - File associated with an image.
472
- * @param {Event } e
483
+ * @param {Event } event
473
484
*/
474
- onPreviewLoad : function ( file , e ) {
475
- var img = e . currentTarget ;
485
+ onPreviewLoad : function ( file , event ) {
486
+ var img = event . currentTarget ;
476
487
477
488
file . previewWidth = img . naturalWidth ;
478
489
file . previewHeight = img . naturalHeight ;
0 commit comments