diff --git a/Gemfile.lock b/Gemfile.lock index 4a50e8a..987a9b8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - dropzonejs-rails (0.7.0) + dropzonejs-rails (0.7.1) rails (> 3.1) GEM diff --git a/app/assets/javascripts/dropzone.js b/app/assets/javascripts/dropzone.js index 2ec628c..babbdd4 100644 --- a/app/assets/javascripts/dropzone.js +++ b/app/assets/javascripts/dropzone.js @@ -1054,7 +1054,6 @@ 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) { @@ -1062,36 +1061,45 @@ } 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; @@ -1377,7 +1385,7 @@ })(Emitter); - Dropzone.version = "4.0.0"; + Dropzone.version = "4.0.1"; Dropzone.options = {};