Skip to content

Commit 7cd6724

Browse files
committed
all .js files updated from the current original jQuery project
1 parent 9472810 commit 7cd6724

8 files changed

+1188
-450
lines changed

fileupload/static/js/jquery.fileupload-fp.js

+21-17
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.1
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,32 @@
8585
options.fileTypes.test(file.type))) {
8686
loadImage(
8787
file,
88-
function (canvas) {
89-
data.canvas = canvas;
88+
function (img) {
89+
if (!img.src) {
90+
return dfd.rejectWith(that, [data]);
91+
}
92+
data.img = img;
9093
dfd.resolveWith(that, [data]);
91-
},
92-
{canvas: true}
94+
}
9395
);
9496
} else {
9597
dfd.rejectWith(that, [data]);
9698
}
9799
return dfd.promise();
98100
},
99-
// Resizes the image given as data.canvas and updates
100-
// data.canvas with the resized image.
101+
// Resizes the image given as data.img and updates
102+
// data.canvas with the resized image as canvas element.
101103
// Accepts the options maxWidth, maxHeight, minWidth and
102104
// minHeight to scale the given image:
103105
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) {
106+
var img = data.img,
107+
canvas;
108+
options = $.extend({canvas: true}, options);
109+
if (img) {
110+
canvas = loadImage.scale(img, options);
111+
if (canvas.width !== img.width ||
112+
canvas.height !== img.height) {
108113
data.canvas = canvas;
109-
data.processed = true;
110114
}
111115
}
112116
return data;
@@ -115,7 +119,7 @@
115119
// inplace at data.index of data.files:
116120
save: function (data, options) {
117121
// Do nothing if no processing has happened:
118-
if (!data.canvas || !data.processed) {
122+
if (!data.canvas) {
119123
return data;
120124
}
121125
var that = this,
@@ -208,7 +212,7 @@
208212
},
209213

210214
_create: function () {
211-
$.blueimp.fileupload.prototype._create.call(this);
215+
this._super();
212216
this._processing = 0;
213217
this._processingQueue = $.Deferred().resolveWith(this)
214218
.promise();

0 commit comments

Comments
 (0)