Skip to content

Commit d86b8f5

Browse files
committed
update jquery.fileupload to 5.19.2
1 parent f7c4bb6 commit d86b8f5

File tree

3 files changed

+269
-237
lines changed

3 files changed

+269
-237
lines changed

vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-fp.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jQuery File Upload File Processing Plugin 1.0
2+
* jQuery File Upload File Processing Plugin 1.2
33
* https://github.com/blueimp/jQuery-File-Upload
44
*
55
* Copyright 2012, Sebastian Tschan
@@ -32,9 +32,9 @@
3232
}(function ($, loadImage) {
3333
'use strict';
3434

35-
// The File Upload IP version extends the basic fileupload widget
35+
// The File Upload FP version extends the fileupload widget
3636
// with file processing functionality:
37-
$.widget('blueimpFP.fileupload', $.blueimp.fileupload, {
37+
$.widget('blueimp.fileupload', $.blueimp.fileupload, {
3838

3939
options: {
4040
// The list of file processing actions:
@@ -70,7 +70,7 @@
7070

7171
processActions: {
7272
// Loads the image given via data.files and data.index
73-
// as canvas element.
73+
// as img element if the browser supports canvas.
7474
// Accepts the options fileTypes (regular expression)
7575
// and maxFileSize (integer) to limit the files to load:
7676
load: function (data, options) {
@@ -85,28 +85,29 @@
8585
options.fileTypes.test(file.type))) {
8686
loadImage(
8787
file,
88-
function (canvas) {
89-
data.canvas = canvas;
88+
function (img) {
89+
data.img = img;
9090
dfd.resolveWith(that, [data]);
91-
},
92-
{canvas: true}
91+
}
9392
);
9493
} else {
9594
dfd.rejectWith(that, [data]);
9695
}
9796
return dfd.promise();
9897
},
99-
// Resizes the image given as data.canvas and updates
100-
// data.canvas with the resized image.
98+
// Resizes the image given as data.img and updates
99+
// data.canvas with the resized image as canvas element.
101100
// Accepts the options maxWidth, maxHeight, minWidth and
102101
// minHeight to scale the given image:
103102
resize: function (data, options) {
104-
if (data.canvas) {
105-
var canvas = loadImage.scale(data.canvas, options);
106-
if (canvas.width !== data.canvas.width ||
107-
canvas.height !== data.canvas.height) {
103+
var img = data.img,
104+
canvas;
105+
options = $.extend({canvas: true}, options);
106+
if (img) {
107+
canvas = loadImage.scale(img, options);
108+
if (canvas.width !== img.width ||
109+
canvas.height !== img.height) {
108110
data.canvas = canvas;
109-
data.processed = true;
110111
}
111112
}
112113
return data;
@@ -115,7 +116,7 @@
115116
// inplace at data.index of data.files:
116117
save: function (data, options) {
117118
// Do nothing if no processing has happened:
118-
if (!data.canvas || !data.processed) {
119+
if (!data.canvas) {
119120
return data;
120121
}
121122
var that = this,
@@ -208,7 +209,7 @@
208209
},
209210

210211
_create: function () {
211-
$.blueimp.fileupload.prototype._create.call(this);
212+
this._super();
212213
this._processing = 0;
213214
this._processingQueue = $.Deferred().resolveWith(this)
214215
.promise();

vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-ui.js

Lines changed: 72 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jQuery File Upload User Interface Plugin 6.9.4
2+
* jQuery File Upload User Interface Plugin 6.11
33
* https://github.com/blueimp/jQuery-File-Upload
44
*
55
* Copyright 2010, Sebastian Tschan
@@ -10,7 +10,7 @@
1010
*/
1111

1212
/*jslint nomen: true, unparam: true, regexp: true */
13-
/*global define, window, document, URL, webkitURL, FileReader */
13+
/*global define, window, URL, webkitURL, FileReader */
1414

1515
(function (factory) {
1616
'use strict';
@@ -33,10 +33,9 @@
3333
}(function ($, tmpl, loadImage) {
3434
'use strict';
3535

36-
// The UI version extends the FP (file processing) version or the basic
37-
// file upload widget and adds complete user interface interaction:
38-
var parentWidget = ($.blueimpFP || $.blueimp).fileupload;
39-
$.widget('blueimpUI.fileupload', parentWidget, {
36+
// The UI version extends the file upload widget
37+
// and adds complete user interface interaction:
38+
$.widget('blueimp.fileupload', $.blueimp.fileupload, {
4039

4140
options: {
4241
// By default, files added to the widget are uploaded as soon
@@ -144,7 +143,8 @@
144143
if (data.context) {
145144
data.context.each(function (index) {
146145
var file = ($.isArray(data.result) &&
147-
data.result[index]) || {error: 'emptyResult'};
146+
data.result[index]) ||
147+
{error: 'Empty file upload result'};
148148
if (file.error) {
149149
that._adjustMaxNumberOfFiles(1);
150150
}
@@ -398,22 +398,22 @@
398398
// maxNumberOfFiles before validation, so we check if
399399
// maxNumberOfFiles is below 0 (instead of below 1):
400400
if (this.options.maxNumberOfFiles < 0) {
401-
return 'maxNumberOfFiles';
401+
return 'Maximum number of files exceeded';
402402
}
403403
// Files are accepted if either the file type or the file name
404404
// matches against the acceptFileTypes regular expression, as
405405
// only browsers with support for the File API report the type:
406406
if (!(this.options.acceptFileTypes.test(file.type) ||
407407
this.options.acceptFileTypes.test(file.name))) {
408-
return 'acceptFileTypes';
408+
return 'Filetype not allowed';
409409
}
410410
if (this.options.maxFileSize &&
411411
file.size > this.options.maxFileSize) {
412-
return 'maxFileSize';
412+
return 'File is too big';
413413
}
414414
if (typeof file.size === 'number' &&
415415
file.size < this.options.minFileSize) {
416-
return 'minFileSize';
416+
return 'File is too small';
417417
}
418418
return null;
419419
},
@@ -457,7 +457,7 @@
457457
that._transition(node).done(function () {
458458
dfd.resolveWith(node);
459459
});
460-
if (!$.contains(document.body, node[0])) {
460+
if (!$.contains(that.document[0].body, node[0])) {
461461
// If the element is not part of the DOM,
462462
// transition events are not triggered,
463463
// so we have to resolve manually:
@@ -510,7 +510,7 @@
510510

511511
_startHandler: function (e) {
512512
e.preventDefault();
513-
var button = $(this),
513+
var button = $(e.currentTarget),
514514
template = button.closest('.template-upload'),
515515
data = template.data('data');
516516
if (data && data.submit && !data.jqXHR && data.submit()) {
@@ -520,25 +520,24 @@
520520

521521
_cancelHandler: function (e) {
522522
e.preventDefault();
523-
var template = $(this).closest('.template-upload'),
523+
var template = $(e.currentTarget).closest('.template-upload'),
524524
data = template.data('data') || {};
525525
if (!data.jqXHR) {
526526
data.errorThrown = 'abort';
527-
e.data.fileupload._trigger('fail', e, data);
527+
this._trigger('fail', e, data);
528528
} else {
529529
data.jqXHR.abort();
530530
}
531531
},
532532

533533
_deleteHandler: function (e) {
534534
e.preventDefault();
535-
var button = $(this);
536-
e.data.fileupload._trigger('destroy', e, {
535+
var button = $(e.currentTarget);
536+
this._trigger('destroy', e, $.extend({
537537
context: button.closest('.template-download'),
538-
url: button.attr('data-url'),
539-
type: button.attr('data-type') || 'DELETE',
540-
dataType: e.data.fileupload.options.dataType
541-
});
538+
type: 'DELETE',
539+
dataType: this.options.dataType
540+
}, button.data()));
542541
},
543542

544543
_forceReflow: function (node) {
@@ -569,75 +568,63 @@
569568

570569
_initButtonBarEventHandlers: function () {
571570
var fileUploadButtonBar = this.element.find('.fileupload-buttonbar'),
572-
filesList = this.options.filesContainer,
573-
ns = this.options.namespace;
574-
fileUploadButtonBar.find('.start')
575-
.bind('click.' + ns, function (e) {
571+
filesList = this.options.filesContainer;
572+
this._on(fileUploadButtonBar.find('.start'), {
573+
click: function (e) {
576574
e.preventDefault();
577575
filesList.find('.start button').click();
578-
});
579-
fileUploadButtonBar.find('.cancel')
580-
.bind('click.' + ns, function (e) {
576+
}
577+
});
578+
this._on(fileUploadButtonBar.find('.cancel'), {
579+
click: function (e) {
581580
e.preventDefault();
582581
filesList.find('.cancel button').click();
583-
});
584-
fileUploadButtonBar.find('.delete')
585-
.bind('click.' + ns, function (e) {
582+
}
583+
});
584+
this._on(fileUploadButtonBar.find('.delete'), {
585+
click: function (e) {
586586
e.preventDefault();
587587
filesList.find('.delete input:checked')
588588
.siblings('button').click();
589589
fileUploadButtonBar.find('.toggle')
590590
.prop('checked', false);
591-
});
592-
fileUploadButtonBar.find('.toggle')
593-
.bind('change.' + ns, function (e) {
591+
}
592+
});
593+
this._on(fileUploadButtonBar.find('.toggle'), {
594+
change: function (e) {
594595
filesList.find('.delete input').prop(
595596
'checked',
596-
$(this).is(':checked')
597+
$(e.currentTarget).is(':checked')
597598
);
598-
});
599+
}
600+
});
599601
},
600602

601603
_destroyButtonBarEventHandlers: function () {
602-
this.element.find('.fileupload-buttonbar button')
603-
.unbind('click.' + this.options.namespace);
604-
this.element.find('.fileupload-buttonbar .toggle')
605-
.unbind('change.' + this.options.namespace);
604+
this._off(
605+
this.element.find('.fileupload-buttonbar button'),
606+
'click'
607+
);
608+
this._off(
609+
this.element.find('.fileupload-buttonbar .toggle'),
610+
'change.'
611+
);
606612
},
607613

608614
_initEventHandlers: function () {
609-
parentWidget.prototype._initEventHandlers.call(this);
610-
var eventData = {fileupload: this};
611-
this.options.filesContainer
612-
.delegate(
613-
'.start button',
614-
'click.' + this.options.namespace,
615-
eventData,
616-
this._startHandler
617-
)
618-
.delegate(
619-
'.cancel button',
620-
'click.' + this.options.namespace,
621-
eventData,
622-
this._cancelHandler
623-
)
624-
.delegate(
625-
'.delete button',
626-
'click.' + this.options.namespace,
627-
eventData,
628-
this._deleteHandler
629-
);
615+
this._super();
616+
this._on(this.options.filesContainer, {
617+
'click .start button': this._startHandler,
618+
'click .cancel button': this._cancelHandler,
619+
'click .delete button': this._deleteHandler
620+
});
630621
this._initButtonBarEventHandlers();
631622
},
632623

633624
_destroyEventHandlers: function () {
634-
var options = this.options;
635625
this._destroyButtonBarEventHandlers();
636-
options.filesContainer
637-
.undelegate('.start button', 'click.' + options.namespace)
638-
.undelegate('.cancel button', 'click.' + options.namespace)
639-
.undelegate('.delete button', 'click.' + options.namespace);
640-
parentWidget.prototype._destroyEventHandlers.call(this);
626+
this._off(this.options.filesContainer, 'click');
627+
this._super();
641628
},
642629

643630
_enableFileInputButton: function () {
@@ -654,7 +641,7 @@
654641

655642
_initTemplates: function () {
656643
var options = this.options;
657-
options.templatesContainer = document.createElement(
644+
options.templatesContainer = this.document[0].createElement(
658645
options.filesContainer.prop('nodeName')
659646
);
660647
if (tmpl) {
@@ -698,20 +685,20 @@
698685
},
699686

700687
_initSpecialOptions: function () {
701-
parentWidget.prototype._initSpecialOptions.call(this);
688+
this._super();
702689
this._initFilesContainer();
703690
this._initTemplates();
704691
this._initRegExpOptions();
705692
},
706693

707694
_create: function () {
708-
parentWidget.prototype._create.call(this);
695+
this._super();
709696
this._refreshOptionsList.push(
710697
'filesContainer',
711698
'uploadTemplateId',
712699
'downloadTemplateId'
713700
);
714-
if (!$.blueimpFP) {
701+
if (!this._processingQueue) {
715702
this._processingQueue = $.Deferred().resolveWith(this).promise();
716703
this.process = function () {
717704
return this._processingQueue;
@@ -720,15 +707,23 @@
720707
},
721708

722709
enable: function () {
723-
parentWidget.prototype.enable.call(this);
724-
this.element.find('input, button').prop('disabled', false);
725-
this._enableFileInputButton();
710+
var wasDisabled = false;
711+
if (this.options.disabled) {
712+
wasDisabled = true;
713+
}
714+
this._super();
715+
if (wasDisabled) {
716+
this.element.find('input, button').prop('disabled', false);
717+
this._enableFileInputButton();
718+
}
726719
},
727720

728721
disable: function () {
729-
this.element.find('input, button').prop('disabled', true);
730-
this._disableFileInputButton();
731-
parentWidget.prototype.disable.call(this);
722+
if (!this.options.disabled) {
723+
this.element.find('input, button').prop('disabled', true);
724+
this._disableFileInputButton();
725+
}
726+
this._super();
732727
}
733728

734729
});

0 commit comments

Comments
 (0)