@@ -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,11 @@ 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; this enforces that policy
336
337
if ( ! this . isMultipleFiles ) {
337
338
data . files . splice ( 1 ) ;
338
339
}
@@ -341,13 +342,13 @@ define([
341
342
/**
342
343
* Handler which is invoked prior to the start of a file upload.
343
344
*
344
- * @param {Event } e - Event object.
345
+ * @param {Event } event - Event object.
345
346
* @param {Object } data - File data that will be uploaded.
346
347
*/
347
- onBeforeFileUpload : function ( e , data ) {
348
- var file = data . files [ 0 ] ,
349
- allowed = this . isFileAllowed ( file ) ,
350
- target = $ ( e . target ) ;
348
+ onBeforeFileUpload : function ( event , data ) {
349
+ var file = data . files [ 0 ] ,
350
+ allowed = this . isFileAllowed ( file ) ,
351
+ target = $ ( event . target ) ;
351
352
352
353
if ( this . disabled ( ) ) {
353
354
this . notifyError ( $t ( 'The file upload field is disabled.' ) ) ;
@@ -356,7 +357,7 @@ define([
356
357
}
357
358
358
359
if ( allowed . passed ) {
359
- target . on ( 'fileuploadsend' , function ( event , postData ) {
360
+ target . on ( 'fileuploadsend' , function ( eventBound , postData ) {
360
361
postData . data . append ( 'param_name' , this . paramName ) ;
361
362
} . bind ( data ) ) ;
362
363
@@ -386,16 +387,25 @@ define([
386
387
} ) ;
387
388
} ,
388
389
390
+ /**
391
+ * @param {Event } event
392
+ * @param {Object } data
393
+ */
394
+ onFail : function ( event , data ) {
395
+ console . error ( data . jqXHR . responseText ) ;
396
+ console . error ( data . jqXHR . status ) ;
397
+ } ,
398
+
389
399
/**
390
400
* Handler of the file upload complete event.
391
401
*
392
- * @param {Event } e
402
+ * @param {Event } event
393
403
* @param {Object } data
394
404
*/
395
- onFileUploaded : function ( e , data ) {
405
+ onFileUploaded : function ( event , data ) {
396
406
var uploadedFilename = data . files [ 0 ] . name ,
397
- file = data . result ,
398
- error = file . error ;
407
+ file = data . result ,
408
+ error = file . error ;
399
409
400
410
error ?
401
411
this . aggregateError ( uploadedFilename , error ) :
@@ -469,10 +479,10 @@ define([
469
479
* Handler of the preview image load event.
470
480
*
471
481
* @param {Object } file - File associated with an image.
472
- * @param {Event } e
482
+ * @param {Event } event
473
483
*/
474
- onPreviewLoad : function ( file , e ) {
475
- var img = e . currentTarget ;
484
+ onPreviewLoad : function ( file , event ) {
485
+ var img = event . currentTarget ;
476
486
477
487
file . previewWidth = img . naturalWidth ;
478
488
file . previewHeight = img . naturalHeight ;
0 commit comments