Skip to content

Commit

Permalink
Updates dropzone to v4.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Nahuel Cuesta Luengo committed Feb 19, 2015
1 parent 912b155 commit d9ee059
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
dropzonejs-rails (0.7.0)
dropzonejs-rails (0.7.1)
rails (> 3.1)

GEM
Expand Down
62 changes: 35 additions & 27 deletions app/assets/javascripts/dropzone.js
Expand Up @@ -1054,44 +1054,52 @@
fileReader = new FileReader;
fileReader.onload = (function(_this) {
return function() {
var img;
if (file.type === "image/svg+xml") {
_this.emit("thumbnail", file, fileReader.result);
if (callback != null) {
callback();
}
return;
}
img = document.createElement("img");
img.onload = function() {
var canvas, ctx, resizeInfo, thumbnail, _ref, _ref1, _ref2, _ref3;
file.width = img.width;
file.height = img.height;
resizeInfo = _this.options.resize.call(_this, file);
if (resizeInfo.trgWidth == null) {
resizeInfo.trgWidth = resizeInfo.optWidth;
}
if (resizeInfo.trgHeight == null) {
resizeInfo.trgHeight = resizeInfo.optHeight;
}
canvas = document.createElement("canvas");
ctx = canvas.getContext("2d");
canvas.width = resizeInfo.trgWidth;
canvas.height = resizeInfo.trgHeight;
drawImageIOSFix(ctx, img, (_ref = resizeInfo.srcX) != null ? _ref : 0, (_ref1 = resizeInfo.srcY) != null ? _ref1 : 0, resizeInfo.srcWidth, resizeInfo.srcHeight, (_ref2 = resizeInfo.trgX) != null ? _ref2 : 0, (_ref3 = resizeInfo.trgY) != null ? _ref3 : 0, resizeInfo.trgWidth, resizeInfo.trgHeight);
thumbnail = canvas.toDataURL("image/png");
_this.emit("thumbnail", file, thumbnail);
if (callback != null) {
return callback();
}
};
img.onerror = callback;
return img.src = fileReader.result;
return _this.createThumbnailFromUrl(file, fileReader.result, callback);
};
})(this);
return fileReader.readAsDataURL(file);
};

Dropzone.prototype.createThumbnailFromUrl = function(file, imageUrl, callback) {
var img;
img = document.createElement("img");
img.onload = (function(_this) {
return function() {
var canvas, ctx, resizeInfo, thumbnail, _ref, _ref1, _ref2, _ref3;
file.width = img.width;
file.height = img.height;
resizeInfo = _this.options.resize.call(_this, file);
if (resizeInfo.trgWidth == null) {
resizeInfo.trgWidth = resizeInfo.optWidth;
}
if (resizeInfo.trgHeight == null) {
resizeInfo.trgHeight = resizeInfo.optHeight;
}
canvas = document.createElement("canvas");
ctx = canvas.getContext("2d");
canvas.width = resizeInfo.trgWidth;
canvas.height = resizeInfo.trgHeight;
drawImageIOSFix(ctx, img, (_ref = resizeInfo.srcX) != null ? _ref : 0, (_ref1 = resizeInfo.srcY) != null ? _ref1 : 0, resizeInfo.srcWidth, resizeInfo.srcHeight, (_ref2 = resizeInfo.trgX) != null ? _ref2 : 0, (_ref3 = resizeInfo.trgY) != null ? _ref3 : 0, resizeInfo.trgWidth, resizeInfo.trgHeight);
thumbnail = canvas.toDataURL("image/png");
_this.emit("thumbnail", file, thumbnail);
if (callback != null) {
return callback();
}
};
})(this);
if (callback != null) {
img.onerror = callback;
}
return img.src = imageUrl;
};

Dropzone.prototype.processQueue = function() {
var i, parallelUploads, processingLength, queuedFiles;
parallelUploads = this.options.parallelUploads;
Expand Down Expand Up @@ -1377,7 +1385,7 @@

})(Emitter);

Dropzone.version = "4.0.0";
Dropzone.version = "4.0.1";

Dropzone.options = {};

Expand Down

0 comments on commit d9ee059

Please sign in to comment.