dropzonejs-rails 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/lib/dropzonejs-rails/version.rb +2 -2
- data/vendor/assets/javascripts/dropzone.js +134 -88
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OThkY2Q2NjliYWY1Njk0Zjk5OTFmOTNlNGQ5NjAyY2I1OWRhOTU2ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGFkNjZhZjdjYzU0NjQ4MzZlNWQxOWY0N2RjNjUwYTczYzA1ZWFjYQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjgxN2MzOWMxYTc4NzZkNjkzZmUwOGI1N2U1YWIwYThjMzVmNmQzZjMxOTNj
|
10
|
+
MzA1NzQzYjkyZWY3MjhjNzBlOGU5NzZmNmU2OGY3MjVlYzY5ZWFmNGMxNjIy
|
11
|
+
NDM1NmIyZmZlMjc5M2MwZTU5YzM1MDZjY2ZjZWVkNDg4ZGVjOWY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODFkODVlOGIzMWU1MTI5YjdmMDMyYzU5ZjA1Yzk3NmZmMDBkMGY0ODUwMzU3
|
14
|
+
MDJlNjFlM2RiNzdlY2Y1ZTc4ZmI2YWIzZTk5Mzg1MGIzOGRkMDYzNzkyMzI5
|
15
|
+
MmM4Mzk5NzY3MjhkOWEyNjExMjcxMGJmZGRjYjBjYmQ5NjRlMDg=
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -64,7 +64,6 @@ require.aliases = {};
|
|
64
64
|
|
65
65
|
require.resolve = function(path) {
|
66
66
|
if (path.charAt(0) === '/') path = path.slice(1);
|
67
|
-
var index = path + '/index.js';
|
68
67
|
|
69
68
|
var paths = [
|
70
69
|
path,
|
@@ -77,10 +76,7 @@ require.resolve = function(path) {
|
|
77
76
|
for (var i = 0; i < paths.length; i++) {
|
78
77
|
var path = paths[i];
|
79
78
|
if (require.modules.hasOwnProperty(path)) return path;
|
80
|
-
|
81
|
-
|
82
|
-
if (require.aliases.hasOwnProperty(index)) {
|
83
|
-
return require.aliases[index];
|
79
|
+
if (require.aliases.hasOwnProperty(path)) return require.aliases[path];
|
84
80
|
}
|
85
81
|
};
|
86
82
|
|
@@ -400,6 +396,8 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
400
396
|
noop = function() {};
|
401
397
|
|
402
398
|
Dropzone = (function(_super) {
|
399
|
+
var extend;
|
400
|
+
|
403
401
|
__extends(Dropzone, _super);
|
404
402
|
|
405
403
|
/*
|
@@ -416,6 +414,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
416
414
|
Dropzone.prototype.defaultOptions = {
|
417
415
|
url: null,
|
418
416
|
method: "post",
|
417
|
+
withCredentials: false,
|
419
418
|
parallelUploads: 2,
|
420
419
|
maxFilesize: 256,
|
421
420
|
paramName: "file",
|
@@ -444,7 +443,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
444
443
|
forceFallback: false,
|
445
444
|
fallback: function() {
|
446
445
|
var child, messageElement, span, _i, _len, _ref;
|
447
|
-
|
448
446
|
this.element.className = "" + this.element.className + " dz-browser-not-supported";
|
449
447
|
_ref = this.element.getElementsByTagName("div");
|
450
448
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
@@ -467,7 +465,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
467
465
|
},
|
468
466
|
resize: function(file) {
|
469
467
|
var info, srcRatio, trgRatio;
|
470
|
-
|
471
468
|
info = {
|
472
469
|
srcX: 0,
|
473
470
|
srcY: 0,
|
@@ -533,11 +530,11 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
533
530
|
return file.previewElement.querySelector("[data-dz-size]").innerHTML = this.filesize(file.size);
|
534
531
|
},
|
535
532
|
removedfile: function(file) {
|
536
|
-
|
533
|
+
var _ref;
|
534
|
+
return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
|
537
535
|
},
|
538
536
|
thumbnail: function(file, dataUrl) {
|
539
537
|
var thumbnailElement;
|
540
|
-
|
541
538
|
file.previewElement.classList.remove("dz-file-preview");
|
542
539
|
file.previewElement.classList.add("dz-image-preview");
|
543
540
|
thumbnailElement = file.previewElement.querySelector("[data-dz-thumbnail]");
|
@@ -563,12 +560,30 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
563
560
|
previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n <div class=\"dz-details\">\n <div class=\"dz-filename\"><span data-dz-name></span></div>\n <div class=\"dz-size\" data-dz-size></div>\n <img data-dz-thumbnail />\n </div>\n <div class=\"dz-progress\"><span class=\"dz-upload\" data-dz-uploadprogress></span></div>\n <div class=\"dz-success-mark\"><span>✔</span></div>\n <div class=\"dz-error-mark\"><span>✘</span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>"
|
564
561
|
};
|
565
562
|
|
566
|
-
function
|
567
|
-
var
|
563
|
+
extend = function() {
|
564
|
+
var key, object, objects, target, val, _i, _len;
|
565
|
+
target = arguments[0], objects = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
566
|
+
for (_i = 0, _len = objects.length; _i < _len; _i++) {
|
567
|
+
object = objects[_i];
|
568
|
+
for (key in object) {
|
569
|
+
val = object[key];
|
570
|
+
target[key] = val;
|
571
|
+
}
|
572
|
+
}
|
573
|
+
return target;
|
574
|
+
};
|
568
575
|
|
576
|
+
function Dropzone(element, options) {
|
577
|
+
var elementOptions, fallback, _ref;
|
569
578
|
this.element = element;
|
570
579
|
this.version = Dropzone.version;
|
571
580
|
this.defaultOptions.previewTemplate = this.defaultOptions.previewTemplate.replace(/\n*/g, "");
|
581
|
+
this.clickableElements = [];
|
582
|
+
this.listeners = [];
|
583
|
+
this.files = [];
|
584
|
+
this.acceptedFiles = [];
|
585
|
+
this.filesQueue = [];
|
586
|
+
this.filesProcessing = [];
|
572
587
|
if (typeof this.element === "string") {
|
573
588
|
this.element = document.querySelector(this.element);
|
574
589
|
}
|
@@ -581,19 +596,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
581
596
|
Dropzone.instances.push(this);
|
582
597
|
element.dropzone = this;
|
583
598
|
elementOptions = (_ref = Dropzone.optionsForElement(this.element)) != null ? _ref : {};
|
584
|
-
extend = function() {
|
585
|
-
var key, object, objects, target, val, _i, _len;
|
586
|
-
|
587
|
-
target = arguments[0], objects = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
588
|
-
for (_i = 0, _len = objects.length; _i < _len; _i++) {
|
589
|
-
object = objects[_i];
|
590
|
-
for (key in object) {
|
591
|
-
val = object[key];
|
592
|
-
target[key] = val;
|
593
|
-
}
|
594
|
-
}
|
595
|
-
return target;
|
596
|
-
};
|
597
599
|
this.options = extend({}, this.defaultOptions, elementOptions, options != null ? options : {});
|
598
600
|
if (this.options.url == null) {
|
599
601
|
this.options.url = this.element.action;
|
@@ -622,8 +624,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
622
624
|
} else {
|
623
625
|
this.clickableElements = Dropzone.getElements(this.options.clickable, "clickable");
|
624
626
|
}
|
625
|
-
} else {
|
626
|
-
this.clickableElements = [];
|
627
627
|
}
|
628
628
|
this.init();
|
629
629
|
}
|
@@ -631,7 +631,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
631
631
|
Dropzone.prototype.init = function() {
|
632
632
|
var eventName, noPropagation, setupHiddenFileInput, _i, _len, _ref, _ref1,
|
633
633
|
_this = this;
|
634
|
-
|
635
634
|
if (this.element.tagName === "form") {
|
636
635
|
this.element.setAttribute("enctype", "multipart/form-data");
|
637
636
|
}
|
@@ -661,7 +660,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
661
660
|
document.body.appendChild(_this.hiddenFileInput);
|
662
661
|
return _this.hiddenFileInput.addEventListener("change", function() {
|
663
662
|
var files;
|
664
|
-
|
665
663
|
files = _this.hiddenFileInput.files;
|
666
664
|
if (files.length) {
|
667
665
|
_this.emit("selectedfiles", files);
|
@@ -672,10 +670,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
672
670
|
};
|
673
671
|
setupHiddenFileInput();
|
674
672
|
}
|
675
|
-
this.files = [];
|
676
|
-
this.acceptedFiles = [];
|
677
|
-
this.filesQueue = [];
|
678
|
-
this.filesProcessing = [];
|
679
673
|
this.URL = (_ref = window.URL) != null ? _ref : window.webkitURL;
|
680
674
|
_ref1 = this.events;
|
681
675
|
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
@@ -684,7 +678,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
684
678
|
}
|
685
679
|
this.on("uploadprogress", function(file) {
|
686
680
|
var totalBytes, totalBytesSent, totalUploadProgress, _j, _len1, _ref2;
|
687
|
-
|
688
681
|
totalBytesSent = 0;
|
689
682
|
totalBytes = 0;
|
690
683
|
_ref2 = _this.acceptedFiles;
|
@@ -749,9 +742,18 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
749
742
|
return this.options.init.call(this);
|
750
743
|
};
|
751
744
|
|
745
|
+
Dropzone.prototype.destroy = function() {
|
746
|
+
var _ref;
|
747
|
+
this.disable();
|
748
|
+
this.removeAllFiles();
|
749
|
+
if ((_ref = this.hiddenFileInput) != null ? _ref.parentNode : void 0) {
|
750
|
+
this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput);
|
751
|
+
return this.hiddenFileInput = null;
|
752
|
+
}
|
753
|
+
};
|
754
|
+
|
752
755
|
Dropzone.prototype.getFallbackForm = function() {
|
753
756
|
var existingFallback, fields, fieldsString, form;
|
754
|
-
|
755
757
|
if (existingFallback = this.getExistingFallback()) {
|
756
758
|
return existingFallback;
|
757
759
|
}
|
@@ -773,10 +775,8 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
773
775
|
|
774
776
|
Dropzone.prototype.getExistingFallback = function() {
|
775
777
|
var fallback, getFallback, tagName, _i, _len, _ref;
|
776
|
-
|
777
778
|
getFallback = function(elements) {
|
778
779
|
var el, _i, _len;
|
779
|
-
|
780
780
|
for (_i = 0, _len = elements.length; _i < _len; _i++) {
|
781
781
|
el = elements[_i];
|
782
782
|
if (/(^| )fallback($| )/.test(el.className)) {
|
@@ -795,14 +795,12 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
795
795
|
|
796
796
|
Dropzone.prototype.setupEventListeners = function() {
|
797
797
|
var elementListeners, event, listener, _i, _len, _ref, _results;
|
798
|
-
|
799
798
|
_ref = this.listeners;
|
800
799
|
_results = [];
|
801
800
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
802
801
|
elementListeners = _ref[_i];
|
803
802
|
_results.push((function() {
|
804
803
|
var _ref1, _results1;
|
805
|
-
|
806
804
|
_ref1 = elementListeners.events;
|
807
805
|
_results1 = [];
|
808
806
|
for (event in _ref1) {
|
@@ -817,14 +815,12 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
817
815
|
|
818
816
|
Dropzone.prototype.removeEventListeners = function() {
|
819
817
|
var elementListeners, event, listener, _i, _len, _ref, _results;
|
820
|
-
|
821
818
|
_ref = this.listeners;
|
822
819
|
_results = [];
|
823
820
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
824
821
|
elementListeners = _ref[_i];
|
825
822
|
_results.push((function() {
|
826
823
|
var _ref1, _results1;
|
827
|
-
|
828
824
|
_ref1 = elementListeners.events;
|
829
825
|
_results1 = [];
|
830
826
|
for (event in _ref1) {
|
@@ -838,12 +834,23 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
838
834
|
};
|
839
835
|
|
840
836
|
Dropzone.prototype.disable = function() {
|
837
|
+
var file, _i, _j, _len, _len1, _ref, _ref1, _results;
|
841
838
|
this.clickableElements.forEach(function(element) {
|
842
839
|
return element.classList.remove("dz-clickable");
|
843
840
|
});
|
844
841
|
this.removeEventListeners();
|
845
|
-
this.filesProcessing
|
846
|
-
|
842
|
+
_ref = this.filesProcessing;
|
843
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
844
|
+
file = _ref[_i];
|
845
|
+
this.cancelUpload(file);
|
846
|
+
}
|
847
|
+
_ref1 = this.filesQueue;
|
848
|
+
_results = [];
|
849
|
+
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
850
|
+
file = _ref1[_j];
|
851
|
+
_results.push(this.cancelUpload(file));
|
852
|
+
}
|
853
|
+
return _results;
|
847
854
|
};
|
848
855
|
|
849
856
|
Dropzone.prototype.enable = function() {
|
@@ -855,7 +862,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
855
862
|
|
856
863
|
Dropzone.prototype.filesize = function(size) {
|
857
864
|
var string;
|
858
|
-
|
859
865
|
if (size >= 100000000000) {
|
860
866
|
size = size / 100000000000;
|
861
867
|
string = "TB";
|
@@ -877,7 +883,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
877
883
|
|
878
884
|
Dropzone.prototype.drop = function(e) {
|
879
885
|
var files;
|
880
|
-
|
881
886
|
if (!e.dataTransfer) {
|
882
887
|
return;
|
883
888
|
}
|
@@ -890,7 +895,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
890
895
|
|
891
896
|
Dropzone.prototype.handleFiles = function(files) {
|
892
897
|
var file, _i, _len, _results;
|
893
|
-
|
894
898
|
_results = [];
|
895
899
|
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
896
900
|
file = files[_i];
|
@@ -911,13 +915,13 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
911
915
|
|
912
916
|
Dropzone.prototype.addFile = function(file) {
|
913
917
|
var _this = this;
|
914
|
-
|
915
918
|
file.upload = {
|
916
919
|
progress: 0,
|
917
920
|
total: file.size,
|
918
921
|
bytesSent: 0
|
919
922
|
};
|
920
923
|
this.files.push(file);
|
924
|
+
file.status = Dropzone.ADDED;
|
921
925
|
this.emit("addedfile", file);
|
922
926
|
if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1024 * 1024) {
|
923
927
|
this.createThumbnail(file);
|
@@ -927,6 +931,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
927
931
|
file.accepted = false;
|
928
932
|
return _this.errorProcessing(file, error);
|
929
933
|
} else {
|
934
|
+
file.status = Dropzone.ACCEPTED;
|
930
935
|
file.accepted = true;
|
931
936
|
_this.acceptedFiles.push(file);
|
932
937
|
if (_this.options.enqueueForUpload) {
|
@@ -938,8 +943,8 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
938
943
|
};
|
939
944
|
|
940
945
|
Dropzone.prototype.removeFile = function(file) {
|
941
|
-
if (file.
|
942
|
-
|
946
|
+
if (file.status === Dropzone.UPLOADING) {
|
947
|
+
this.cancelUpload(file);
|
943
948
|
}
|
944
949
|
this.files = without(this.files, file);
|
945
950
|
this.filesQueue = without(this.filesQueue, file);
|
@@ -951,7 +956,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
951
956
|
|
952
957
|
Dropzone.prototype.removeAllFiles = function() {
|
953
958
|
var file, _i, _len, _ref;
|
954
|
-
|
955
959
|
_ref = this.files.slice();
|
956
960
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
957
961
|
file = _ref[_i];
|
@@ -965,29 +969,26 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
965
969
|
Dropzone.prototype.createThumbnail = function(file) {
|
966
970
|
var fileReader,
|
967
971
|
_this = this;
|
968
|
-
|
969
972
|
fileReader = new FileReader;
|
970
973
|
fileReader.onload = function() {
|
971
974
|
var img;
|
972
|
-
|
973
975
|
img = new Image;
|
974
976
|
img.onload = function() {
|
975
|
-
var canvas, ctx, resizeInfo, thumbnail, _ref, _ref1, _ref2, _ref3
|
976
|
-
|
977
|
+
var canvas, ctx, resizeInfo, thumbnail, _ref, _ref1, _ref2, _ref3;
|
977
978
|
file.width = img.width;
|
978
979
|
file.height = img.height;
|
979
980
|
resizeInfo = _this.options.resize.call(_this, file);
|
980
|
-
if (
|
981
|
+
if (resizeInfo.trgWidth == null) {
|
981
982
|
resizeInfo.trgWidth = _this.options.thumbnailWidth;
|
982
983
|
}
|
983
|
-
if (
|
984
|
+
if (resizeInfo.trgHeight == null) {
|
984
985
|
resizeInfo.trgHeight = _this.options.thumbnailHeight;
|
985
986
|
}
|
986
987
|
canvas = document.createElement("canvas");
|
987
988
|
ctx = canvas.getContext("2d");
|
988
989
|
canvas.width = resizeInfo.trgWidth;
|
989
990
|
canvas.height = resizeInfo.trgHeight;
|
990
|
-
ctx.drawImage(img, (
|
991
|
+
ctx.drawImage(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);
|
991
992
|
thumbnail = canvas.toDataURL("image/png");
|
992
993
|
return _this.emit("thumbnail", file, thumbnail);
|
993
994
|
};
|
@@ -998,7 +999,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
998
999
|
|
999
1000
|
Dropzone.prototype.processQueue = function() {
|
1000
1001
|
var i, parallelUploads, processingLength;
|
1001
|
-
|
1002
1002
|
parallelUploads = this.options.parallelUploads;
|
1003
1003
|
processingLength = this.filesProcessing.length;
|
1004
1004
|
i = processingLength;
|
@@ -1014,23 +1014,61 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1014
1014
|
Dropzone.prototype.processFile = function(file) {
|
1015
1015
|
this.filesProcessing.push(file);
|
1016
1016
|
file.processing = true;
|
1017
|
+
file.status = Dropzone.UPLOADING;
|
1017
1018
|
this.emit("processingfile", file);
|
1018
1019
|
return this.uploadFile(file);
|
1019
1020
|
};
|
1020
1021
|
|
1022
|
+
Dropzone.prototype.cancelUpload = function(file) {
|
1023
|
+
var _ref;
|
1024
|
+
if (file.status === Dropzone.UPLOADING) {
|
1025
|
+
file.status = Dropzone.CANCELED;
|
1026
|
+
file.xhr.abort();
|
1027
|
+
return this.filesProcessing = without(this.filesProcessing, file);
|
1028
|
+
} else if ((_ref = file.status) === Dropzone.ADDED || _ref === Dropzone.ACCEPTED) {
|
1029
|
+
file.status = Dropzone.CANCELED;
|
1030
|
+
return this.filesQueue = without(this.filesQueue, file);
|
1031
|
+
}
|
1032
|
+
};
|
1033
|
+
|
1021
1034
|
Dropzone.prototype.uploadFile = function(file) {
|
1022
|
-
var formData, handleError, input, inputName, inputType, key, progressObj, response, value, xhr, _i, _len, _ref, _ref1, _ref2,
|
1035
|
+
var formData, handleError, header, headers, input, inputName, inputType, key, name, progressObj, response, updateProgress, value, xhr, _i, _len, _ref, _ref1, _ref2,
|
1023
1036
|
_this = this;
|
1024
|
-
|
1025
1037
|
xhr = new XMLHttpRequest();
|
1038
|
+
file.xhr = xhr;
|
1039
|
+
xhr.withCredentials = !!this.options.withCredentials;
|
1026
1040
|
xhr.open(this.options.method, this.options.url, true);
|
1027
1041
|
response = null;
|
1028
1042
|
handleError = function() {
|
1029
1043
|
return _this.errorProcessing(file, response || _this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr);
|
1030
1044
|
};
|
1045
|
+
updateProgress = function(e) {
|
1046
|
+
var progress;
|
1047
|
+
if (e != null) {
|
1048
|
+
progress = 100 * e.loaded / e.total;
|
1049
|
+
file.upload = {
|
1050
|
+
progress: progress,
|
1051
|
+
total: e.total,
|
1052
|
+
bytesSent: e.loaded
|
1053
|
+
};
|
1054
|
+
} else {
|
1055
|
+
if (file.upload.progress === 100 && file.upload.bytesSent === file.upload.total) {
|
1056
|
+
return;
|
1057
|
+
}
|
1058
|
+
progress = 100;
|
1059
|
+
file.upload.progress = progress;
|
1060
|
+
file.upload.bytesSent = file.upload.total;
|
1061
|
+
}
|
1062
|
+
return _this.emit("uploadprogress", file, progress, file.upload.bytesSent);
|
1063
|
+
};
|
1031
1064
|
xhr.onload = function(e) {
|
1032
1065
|
var _ref;
|
1033
|
-
|
1066
|
+
if (file.status === Dropzone.CANCELED) {
|
1067
|
+
return;
|
1068
|
+
}
|
1069
|
+
if (xhr.readyState !== 4) {
|
1070
|
+
return;
|
1071
|
+
}
|
1034
1072
|
response = xhr.responseText;
|
1035
1073
|
if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) {
|
1036
1074
|
try {
|
@@ -1040,6 +1078,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1040
1078
|
response = "Invalid JSON response from server.";
|
1041
1079
|
}
|
1042
1080
|
}
|
1081
|
+
updateProgress();
|
1043
1082
|
if (!((200 <= (_ref = xhr.status) && _ref < 300))) {
|
1044
1083
|
return handleError();
|
1045
1084
|
} else {
|
@@ -1047,24 +1086,26 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1047
1086
|
}
|
1048
1087
|
};
|
1049
1088
|
xhr.onerror = function() {
|
1089
|
+
if (file.status === Dropzone.CANCELED) {
|
1090
|
+
return;
|
1091
|
+
}
|
1050
1092
|
return handleError();
|
1051
1093
|
};
|
1052
1094
|
progressObj = (_ref = xhr.upload) != null ? _ref : xhr;
|
1053
|
-
progressObj.onprogress =
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
bytesSent: e.loaded
|
1060
|
-
};
|
1061
|
-
progress = 100 * e.loaded / e.total;
|
1062
|
-
return _this.emit("uploadprogress", file, progress, e.loaded);
|
1095
|
+
progressObj.onprogress = updateProgress;
|
1096
|
+
headers = {
|
1097
|
+
"Accept": "application/json",
|
1098
|
+
"Cache-Control": "no-cache",
|
1099
|
+
"X-Requested-With": "XMLHttpRequest",
|
1100
|
+
"X-File-Name": encodeURIComponent(file.name)
|
1063
1101
|
};
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1102
|
+
if (this.options.headers) {
|
1103
|
+
extend(headers, this.options.headers);
|
1104
|
+
}
|
1105
|
+
for (header in headers) {
|
1106
|
+
name = headers[header];
|
1107
|
+
xhr.setRequestHeader(header, name);
|
1108
|
+
}
|
1068
1109
|
formData = new FormData();
|
1069
1110
|
if (this.options.params) {
|
1070
1111
|
_ref1 = this.options.params;
|
@@ -1092,6 +1133,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1092
1133
|
Dropzone.prototype.finished = function(file, responseText, e) {
|
1093
1134
|
this.filesProcessing = without(this.filesProcessing, file);
|
1094
1135
|
file.processing = false;
|
1136
|
+
file.status = Dropzone.SUCCESS;
|
1095
1137
|
this.processQueue();
|
1096
1138
|
this.emit("success", file, responseText, e);
|
1097
1139
|
this.emit("finished", file, responseText, e);
|
@@ -1101,6 +1143,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1101
1143
|
Dropzone.prototype.errorProcessing = function(file, message, xhr) {
|
1102
1144
|
this.filesProcessing = without(this.filesProcessing, file);
|
1103
1145
|
file.processing = false;
|
1146
|
+
file.status = Dropzone.ERROR;
|
1104
1147
|
this.processQueue();
|
1105
1148
|
this.emit("error", file, message, xhr);
|
1106
1149
|
return this.emit("complete", file);
|
@@ -1110,7 +1153,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1110
1153
|
|
1111
1154
|
})(Em);
|
1112
1155
|
|
1113
|
-
Dropzone.version = "3.
|
1156
|
+
Dropzone.version = "3.4.1";
|
1114
1157
|
|
1115
1158
|
Dropzone.options = {};
|
1116
1159
|
|
@@ -1125,19 +1168,19 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1125
1168
|
Dropzone.instances = [];
|
1126
1169
|
|
1127
1170
|
Dropzone.forElement = function(element) {
|
1128
|
-
var _ref;
|
1129
|
-
|
1130
1171
|
if (typeof element === "string") {
|
1131
1172
|
element = document.querySelector(element);
|
1132
1173
|
}
|
1133
|
-
|
1174
|
+
if ((element != null ? element.dropzone : void 0) == null) {
|
1175
|
+
throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone.");
|
1176
|
+
}
|
1177
|
+
return element.dropzone;
|
1134
1178
|
};
|
1135
1179
|
|
1136
1180
|
Dropzone.autoDiscover = true;
|
1137
1181
|
|
1138
1182
|
Dropzone.discover = function() {
|
1139
1183
|
var checkElements, dropzone, dropzones, _i, _len, _results;
|
1140
|
-
|
1141
1184
|
if (!Dropzone.autoDiscover) {
|
1142
1185
|
return;
|
1143
1186
|
}
|
@@ -1147,7 +1190,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1147
1190
|
dropzones = [];
|
1148
1191
|
checkElements = function(elements) {
|
1149
1192
|
var el, _i, _len, _results;
|
1150
|
-
|
1151
1193
|
_results = [];
|
1152
1194
|
for (_i = 0, _len = elements.length; _i < _len; _i++) {
|
1153
1195
|
el = elements[_i];
|
@@ -1178,7 +1220,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1178
1220
|
|
1179
1221
|
Dropzone.isBrowserSupported = function() {
|
1180
1222
|
var capableBrowser, regex, _i, _len, _ref;
|
1181
|
-
|
1182
1223
|
capableBrowser = true;
|
1183
1224
|
if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) {
|
1184
1225
|
if (!("classList" in document.createElement("a"))) {
|
@@ -1201,7 +1242,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1201
1242
|
|
1202
1243
|
without = function(list, rejectedItem) {
|
1203
1244
|
var item, _i, _len, _results;
|
1204
|
-
|
1205
1245
|
_results = [];
|
1206
1246
|
for (_i = 0, _len = list.length; _i < _len; _i++) {
|
1207
1247
|
item = list[_i];
|
@@ -1220,7 +1260,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1220
1260
|
|
1221
1261
|
Dropzone.createElement = function(string) {
|
1222
1262
|
var div;
|
1223
|
-
|
1224
1263
|
div = document.createElement("div");
|
1225
1264
|
div.innerHTML = string;
|
1226
1265
|
return div.childNodes[0];
|
@@ -1240,7 +1279,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1240
1279
|
|
1241
1280
|
Dropzone.getElement = function(el, name) {
|
1242
1281
|
var element;
|
1243
|
-
|
1244
1282
|
if (typeof el === "string") {
|
1245
1283
|
element = document.querySelector(el);
|
1246
1284
|
} else if (el.nodeType != null) {
|
@@ -1254,7 +1292,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1254
1292
|
|
1255
1293
|
Dropzone.getElements = function(els, name) {
|
1256
1294
|
var e, el, elements, _i, _j, _len, _len1, _ref;
|
1257
|
-
|
1258
1295
|
if (els instanceof Array) {
|
1259
1296
|
elements = [];
|
1260
1297
|
try {
|
@@ -1284,7 +1321,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1284
1321
|
|
1285
1322
|
Dropzone.isValidMimeType = function(mimeType, acceptedMimeTypes) {
|
1286
1323
|
var baseMimeType, validMimeType, _i, _len;
|
1287
|
-
|
1288
1324
|
if (!acceptedMimeTypes) {
|
1289
1325
|
return true;
|
1290
1326
|
}
|
@@ -1320,6 +1356,18 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1320
1356
|
window.Dropzone = Dropzone;
|
1321
1357
|
}
|
1322
1358
|
|
1359
|
+
Dropzone.ADDED = "added";
|
1360
|
+
|
1361
|
+
Dropzone.ACCEPTED = "accepted";
|
1362
|
+
|
1363
|
+
Dropzone.UPLOADING = "uploading";
|
1364
|
+
|
1365
|
+
Dropzone.CANCELED = "canceled";
|
1366
|
+
|
1367
|
+
Dropzone.ERROR = "error";
|
1368
|
+
|
1369
|
+
Dropzone.SUCCESS = "success";
|
1370
|
+
|
1323
1371
|
/*
|
1324
1372
|
# contentloaded.js
|
1325
1373
|
#
|
@@ -1337,7 +1385,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1337
1385
|
|
1338
1386
|
contentLoaded = function(win, fn) {
|
1339
1387
|
var add, doc, done, init, poll, pre, rem, root, top;
|
1340
|
-
|
1341
1388
|
done = false;
|
1342
1389
|
top = true;
|
1343
1390
|
doc = win.document;
|
@@ -1356,7 +1403,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1356
1403
|
};
|
1357
1404
|
poll = function() {
|
1358
1405
|
var e;
|
1359
|
-
|
1360
1406
|
try {
|
1361
1407
|
root.doScroll("left");
|
1362
1408
|
} catch (_error) {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dropzonejs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Nahuel Cuesta Luengo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|