dropzonejs-rails 0.4.4 → 0.4.5
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/lib/dropzonejs-rails/version.rb +2 -2
- data/vendor/assets/javascripts/dropzone.js +231 -96
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzIxZTY2ZjRjMmE1YWJmZGYyYjdlMWIxOTczY2QwZDBkY2YwODRhMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWJiZDY2YzFiNTNkNDIwMzU5MThmMWNhNGRkYTAwMTBhNDc3YjA0Mg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmE5MWFlYTZjYjFkMWY4ZGUwOTA5YTUzMDMwNGRiZDMwMDI5NmMwNzk2YjJi
|
10
|
+
NTc0MjA4Zjk0MGZjZTQxZmQwZjgzZDdkM2M1MTEzNDVkMzZkN2RlZThmMWU3
|
11
|
+
N2RjYzM2M2E5ZmRkZDg1MWJhY2E5OWM1OWRhY2MzY2M2YjBmZjY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjhjNzJjZDkyYzVmNzFiODAzYmNiZDQyZWFmOWFiMTczYzFhOGFmZGU2MTQ2
|
14
|
+
OTNlOTM0ZmNhZmY5OGY4Yjk2ZWM3MjE4ZmM0YTRlNjk4NTg0MzNjOWIwMjRj
|
15
|
+
OGI2YjBmZDUyMjczNTc2NWUxYjVjZTc4NDRlODlkZGI2MTU5Njc=
|
data/README.md
CHANGED
@@ -408,13 +408,14 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
408
408
|
*/
|
409
409
|
|
410
410
|
|
411
|
-
Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "selectedfiles", "addedfile", "removedfile", "thumbnail", "error", "
|
411
|
+
Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "selectedfiles", "addedfile", "removedfile", "thumbnail", "error", "processing", "processingmultiple", "uploadprogress", "totaluploadprogress", "sending", "sendingmultiple", "success", "successmultiple", "canceled", "canceledmultiple", "complete", "completemultiple", "reset"];
|
412
412
|
|
413
413
|
Dropzone.prototype.defaultOptions = {
|
414
414
|
url: null,
|
415
415
|
method: "post",
|
416
416
|
withCredentials: false,
|
417
417
|
parallelUploads: 2,
|
418
|
+
uploadMultiple: false,
|
418
419
|
maxFilesize: 256,
|
419
420
|
paramName: "file",
|
420
421
|
createImageThumbnails: true,
|
@@ -424,9 +425,9 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
424
425
|
params: {},
|
425
426
|
clickable: true,
|
426
427
|
ignoreHiddenFiles: true,
|
428
|
+
acceptedFiles: null,
|
427
429
|
acceptedMimeTypes: null,
|
428
|
-
|
429
|
-
enqueueForUpload: true,
|
430
|
+
autoProcessQueue: true,
|
430
431
|
addRemoveLinks: false,
|
431
432
|
previewsContainer: null,
|
432
433
|
dictDefaultMessage: "Drop files here to upload",
|
@@ -565,25 +566,33 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
565
566
|
file.previewElement.classList.add("dz-error");
|
566
567
|
return file.previewElement.querySelector("[data-dz-errormessage]").textContent = message;
|
567
568
|
},
|
568
|
-
|
569
|
+
processing: function(file) {
|
569
570
|
file.previewElement.classList.add("dz-processing");
|
570
571
|
if (file._removeLink) {
|
571
572
|
return file._removeLink.textContent = this.options.dictCancelUpload;
|
572
573
|
}
|
573
574
|
},
|
575
|
+
processingmultiple: noop,
|
574
576
|
uploadprogress: function(file, progress, bytesSent) {
|
575
577
|
return file.previewElement.querySelector("[data-dz-uploadprogress]").style.width = "" + progress + "%";
|
576
578
|
},
|
577
579
|
totaluploadprogress: noop,
|
578
580
|
sending: noop,
|
581
|
+
sendingmultiple: noop,
|
579
582
|
success: function(file) {
|
580
583
|
return file.previewElement.classList.add("dz-success");
|
581
584
|
},
|
585
|
+
successmultiple: noop,
|
586
|
+
canceled: function(file) {
|
587
|
+
return this.emit("error", file, "Upload canceled.");
|
588
|
+
},
|
589
|
+
canceledmultiple: noop,
|
582
590
|
complete: function(file) {
|
583
591
|
if (file._removeLink) {
|
584
592
|
return file._removeLink.textContent = this.options.dictRemoveFile;
|
585
593
|
}
|
586
594
|
},
|
595
|
+
completemultiple: noop,
|
587
596
|
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>"
|
588
597
|
};
|
589
598
|
|
@@ -627,8 +636,12 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
627
636
|
if (!this.options.url) {
|
628
637
|
throw new Error("No URL provided.");
|
629
638
|
}
|
630
|
-
if (this.options.
|
631
|
-
throw new Error("You can't provide both '
|
639
|
+
if (this.options.acceptedFiles && this.options.acceptedMimeTypes) {
|
640
|
+
throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated.");
|
641
|
+
}
|
642
|
+
if (this.options.acceptedMimeTypes) {
|
643
|
+
this.options.acceptedFiles = this.options.acceptedMimeTypes;
|
644
|
+
delete this.options.acceptedMimeTypes;
|
632
645
|
}
|
633
646
|
this.options.method = this.options.method.toUpperCase();
|
634
647
|
if (this.options.forceFallback || !Dropzone.isBrowserSupported()) {
|
@@ -667,15 +680,15 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
667
680
|
|
668
681
|
Dropzone.prototype.getRejectedFiles = function() {
|
669
682
|
var file, _i, _len, _ref, _results;
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
683
|
+
_ref = this.files;
|
684
|
+
_results = [];
|
685
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
686
|
+
file = _ref[_i];
|
687
|
+
if (!file.accepted) {
|
675
688
|
_results.push(file);
|
676
689
|
}
|
677
|
-
return _results;
|
678
690
|
}
|
691
|
+
return _results;
|
679
692
|
};
|
680
693
|
|
681
694
|
Dropzone.prototype.getQueuedFiles = function() {
|
@@ -704,15 +717,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
704
717
|
return _results;
|
705
718
|
};
|
706
719
|
|
707
|
-
Dropzone.prototype.enqueueFile = function(file) {
|
708
|
-
if (file.status === Dropzone.ACCEPTED) {
|
709
|
-
file.status = Dropzone.QUEUED;
|
710
|
-
return this.processQueue();
|
711
|
-
} else {
|
712
|
-
throw new Error("This file can't be queued because it has already been processed or was rejected.");
|
713
|
-
}
|
714
|
-
};
|
715
|
-
|
716
720
|
Dropzone.prototype.init = function() {
|
717
721
|
var eventName, noPropagation, setupHiddenFileInput, _i, _len, _ref, _ref1,
|
718
722
|
_this = this;
|
@@ -729,12 +733,11 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
729
733
|
}
|
730
734
|
_this.hiddenFileInput = document.createElement("input");
|
731
735
|
_this.hiddenFileInput.setAttribute("type", "file");
|
732
|
-
_this.
|
733
|
-
|
734
|
-
_this.hiddenFileInput.setAttribute("accept", _this.options.acceptedMimeTypes);
|
736
|
+
if (_this.options.uploadMultiple) {
|
737
|
+
_this.hiddenFileInput.setAttribute("multiple", "multiple");
|
735
738
|
}
|
736
|
-
if (_this.options.
|
737
|
-
_this.hiddenFileInput.setAttribute("accept", _this.options.
|
739
|
+
if (_this.options.acceptedFiles != null) {
|
740
|
+
_this.hiddenFileInput.setAttribute("accept", _this.options.acceptedFiles);
|
738
741
|
}
|
739
742
|
_this.hiddenFileInput.style.visibility = "hidden";
|
740
743
|
_this.hiddenFileInput.style.position = "absolute";
|
@@ -767,6 +770,9 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
767
770
|
this.on("removedfile", function() {
|
768
771
|
return _this.updateTotalUploadProgress();
|
769
772
|
});
|
773
|
+
this.on("canceled", function(file) {
|
774
|
+
return _this.emit("complete", file);
|
775
|
+
});
|
770
776
|
noPropagation = function(e) {
|
771
777
|
e.stopPropagation();
|
772
778
|
if (e.preventDefault) {
|
@@ -859,7 +865,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
859
865
|
if (this.options.dictFallbackText) {
|
860
866
|
fieldsString += "<p>" + this.options.dictFallbackText + "</p>";
|
861
867
|
}
|
862
|
-
fieldsString += "<input type=\"file\" name=\"" + this.options.paramName + "[]\" multiple
|
868
|
+
fieldsString += "<input type=\"file\" name=\"" + this.options.paramName + (this.options.uploadMultiple ? "[]" : "") + "\" " + (this.options.uploadMultiple ? 'multiple="multiple"' : void 0) + " /><button type=\"submit\">Upload!</button></div>";
|
863
869
|
fields = Dropzone.createElement(fieldsString);
|
864
870
|
if (this.element.tagName !== "FORM") {
|
865
871
|
form = Dropzone.createElement("<form action=\"" + this.options.url + "\" enctype=\"multipart/form-data\" method=\"" + this.options.method + "\"></form>");
|
@@ -1021,7 +1027,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1021
1027
|
Dropzone.prototype.accept = function(file, done) {
|
1022
1028
|
if (file.size > this.options.maxFilesize * 1024 * 1024) {
|
1023
1029
|
return done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize));
|
1024
|
-
} else if (!Dropzone.
|
1030
|
+
} else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) {
|
1025
1031
|
return done(this.options.dictInvalidFileType);
|
1026
1032
|
} else {
|
1027
1033
|
return this.options.accept.call(this, file, done);
|
@@ -1044,18 +1050,37 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1044
1050
|
return this.accept(file, function(error) {
|
1045
1051
|
if (error) {
|
1046
1052
|
file.accepted = false;
|
1047
|
-
return _this.
|
1053
|
+
return _this._errorProcessing([file], error);
|
1048
1054
|
} else {
|
1049
|
-
file.status = Dropzone.ACCEPTED;
|
1050
1055
|
file.accepted = true;
|
1051
|
-
|
1052
|
-
file.status = Dropzone.QUEUED;
|
1053
|
-
return _this.processQueue();
|
1054
|
-
}
|
1056
|
+
return _this.enqueueFile(file);
|
1055
1057
|
}
|
1056
1058
|
});
|
1057
1059
|
};
|
1058
1060
|
|
1061
|
+
Dropzone.prototype.enqueueFiles = function(files) {
|
1062
|
+
var file, _i, _len;
|
1063
|
+
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
1064
|
+
file = files[_i];
|
1065
|
+
this.enqueueFile(file);
|
1066
|
+
}
|
1067
|
+
return null;
|
1068
|
+
};
|
1069
|
+
|
1070
|
+
Dropzone.prototype.enqueueFile = function(file) {
|
1071
|
+
var _this = this;
|
1072
|
+
if (file.status === Dropzone.ADDED) {
|
1073
|
+
file.status = Dropzone.QUEUED;
|
1074
|
+
if (this.options.autoProcessQueue) {
|
1075
|
+
return setTimeout((function() {
|
1076
|
+
return _this.processQueue();
|
1077
|
+
}), 1);
|
1078
|
+
}
|
1079
|
+
} else {
|
1080
|
+
throw new Error("This file can't be queued because it has already been processed or was rejected.");
|
1081
|
+
}
|
1082
|
+
};
|
1083
|
+
|
1059
1084
|
Dropzone.prototype.addDirectory = function(entry, path) {
|
1060
1085
|
var dirReader, entriesReader,
|
1061
1086
|
_this = this;
|
@@ -1145,67 +1170,145 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1145
1170
|
processingLength = this.getUploadingFiles().length;
|
1146
1171
|
i = processingLength;
|
1147
1172
|
queuedFiles = this.getQueuedFiles();
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1173
|
+
if (!(queuedFiles.length > 0)) {
|
1174
|
+
return;
|
1175
|
+
}
|
1176
|
+
if (this.options.uploadMultiple) {
|
1177
|
+
return this.processFiles(queuedFiles.slice(0, parallelUploads));
|
1178
|
+
} else {
|
1179
|
+
while (i < parallelUploads) {
|
1180
|
+
if (!queuedFiles.length) {
|
1181
|
+
return;
|
1182
|
+
}
|
1183
|
+
this.processFile(queuedFiles.shift());
|
1184
|
+
i++;
|
1151
1185
|
}
|
1152
|
-
this.processFile(queuedFiles.shift());
|
1153
|
-
i++;
|
1154
1186
|
}
|
1155
1187
|
};
|
1156
1188
|
|
1157
1189
|
Dropzone.prototype.processFile = function(file) {
|
1158
|
-
file
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1190
|
+
return this.processFiles([file]);
|
1191
|
+
};
|
1192
|
+
|
1193
|
+
Dropzone.prototype.processFiles = function(files) {
|
1194
|
+
var file, _i, _len;
|
1195
|
+
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
1196
|
+
file = files[_i];
|
1197
|
+
file.processing = true;
|
1198
|
+
file.status = Dropzone.UPLOADING;
|
1199
|
+
this.emit("processing", file);
|
1200
|
+
}
|
1201
|
+
if (this.options.uploadMultiple) {
|
1202
|
+
this.emit("processingmultiple", files);
|
1203
|
+
}
|
1204
|
+
return this.uploadFiles(files);
|
1205
|
+
};
|
1206
|
+
|
1207
|
+
Dropzone.prototype._getFilesWithXhr = function(xhr) {
|
1208
|
+
var file, files;
|
1209
|
+
return files = (function() {
|
1210
|
+
var _i, _len, _ref, _results;
|
1211
|
+
_ref = this.files;
|
1212
|
+
_results = [];
|
1213
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1214
|
+
file = _ref[_i];
|
1215
|
+
if (file.xhr === xhr) {
|
1216
|
+
_results.push(file);
|
1217
|
+
}
|
1218
|
+
}
|
1219
|
+
return _results;
|
1220
|
+
}).call(this);
|
1162
1221
|
};
|
1163
1222
|
|
1164
1223
|
Dropzone.prototype.cancelUpload = function(file) {
|
1165
|
-
var _ref;
|
1224
|
+
var groupedFile, groupedFiles, _i, _j, _len, _len1, _ref;
|
1166
1225
|
if (file.status === Dropzone.UPLOADING) {
|
1167
|
-
|
1226
|
+
groupedFiles = this._getFilesWithXhr(file.xhr);
|
1227
|
+
for (_i = 0, _len = groupedFiles.length; _i < _len; _i++) {
|
1228
|
+
groupedFile = groupedFiles[_i];
|
1229
|
+
groupedFile.status = Dropzone.CANCELED;
|
1230
|
+
}
|
1168
1231
|
file.xhr.abort();
|
1169
|
-
|
1232
|
+
for (_j = 0, _len1 = groupedFiles.length; _j < _len1; _j++) {
|
1233
|
+
groupedFile = groupedFiles[_j];
|
1234
|
+
this.emit("canceled", groupedFile);
|
1235
|
+
}
|
1236
|
+
if (this.options.uploadMultiple) {
|
1237
|
+
this.emit("canceledmultiple", groupedFiles);
|
1238
|
+
}
|
1239
|
+
} else if ((_ref = file.status) === Dropzone.ADDED || _ref === Dropzone.QUEUED) {
|
1170
1240
|
file.status = Dropzone.CANCELED;
|
1241
|
+
this.emit("canceled", file);
|
1242
|
+
if (this.options.uploadMultiple) {
|
1243
|
+
this.emit("canceledmultiple", [file]);
|
1244
|
+
}
|
1245
|
+
}
|
1246
|
+
if (this.options.autoProcessQueue) {
|
1247
|
+
return this.processQueue();
|
1171
1248
|
}
|
1172
|
-
this.emit("complete", file);
|
1173
|
-
return this.processQueue();
|
1174
1249
|
};
|
1175
1250
|
|
1176
1251
|
Dropzone.prototype.uploadFile = function(file) {
|
1177
|
-
|
1252
|
+
return this.uploadFiles([file]);
|
1253
|
+
};
|
1254
|
+
|
1255
|
+
Dropzone.prototype.uploadFiles = function(files) {
|
1256
|
+
var file, formData, handleError, header, headers, input, inputName, inputType, key, name, progressObj, response, updateProgress, value, xhr, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3,
|
1178
1257
|
_this = this;
|
1179
1258
|
xhr = new XMLHttpRequest();
|
1180
|
-
|
1259
|
+
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
1260
|
+
file = files[_i];
|
1261
|
+
file.xhr = xhr;
|
1262
|
+
}
|
1181
1263
|
xhr.open(this.options.method, this.options.url, true);
|
1182
1264
|
xhr.withCredentials = !!this.options.withCredentials;
|
1183
1265
|
response = null;
|
1184
1266
|
handleError = function() {
|
1185
|
-
|
1267
|
+
var _j, _len1, _results;
|
1268
|
+
_results = [];
|
1269
|
+
for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
|
1270
|
+
file = files[_j];
|
1271
|
+
_results.push(_this._errorProcessing(files, response || _this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr));
|
1272
|
+
}
|
1273
|
+
return _results;
|
1186
1274
|
};
|
1187
1275
|
updateProgress = function(e) {
|
1188
|
-
var progress;
|
1276
|
+
var allFilesFinished, progress, _j, _k, _l, _len1, _len2, _len3, _results;
|
1189
1277
|
if (e != null) {
|
1190
1278
|
progress = 100 * e.loaded / e.total;
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1279
|
+
for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
|
1280
|
+
file = files[_j];
|
1281
|
+
file.upload = {
|
1282
|
+
progress: progress,
|
1283
|
+
total: e.total,
|
1284
|
+
bytesSent: e.loaded
|
1285
|
+
};
|
1286
|
+
}
|
1196
1287
|
} else {
|
1197
|
-
|
1288
|
+
allFilesFinished = true;
|
1289
|
+
progress = 100;
|
1290
|
+
for (_k = 0, _len2 = files.length; _k < _len2; _k++) {
|
1291
|
+
file = files[_k];
|
1292
|
+
if (!(file.upload.progress === 100 && file.upload.bytesSent === file.upload.total)) {
|
1293
|
+
allFilesFinished = false;
|
1294
|
+
}
|
1295
|
+
file.upload.progress = progress;
|
1296
|
+
file.upload.bytesSent = file.upload.total;
|
1297
|
+
}
|
1298
|
+
if (allFilesFinished) {
|
1198
1299
|
return;
|
1199
1300
|
}
|
1200
|
-
progress = 100;
|
1201
|
-
file.upload.progress = progress;
|
1202
|
-
file.upload.bytesSent = file.upload.total;
|
1203
1301
|
}
|
1204
|
-
|
1302
|
+
_results = [];
|
1303
|
+
for (_l = 0, _len3 = files.length; _l < _len3; _l++) {
|
1304
|
+
file = files[_l];
|
1305
|
+
_results.push(_this.emit("uploadprogress", file, progress, file.upload.bytesSent));
|
1306
|
+
}
|
1307
|
+
return _results;
|
1205
1308
|
};
|
1206
1309
|
xhr.onload = function(e) {
|
1207
1310
|
var _ref;
|
1208
|
-
if (
|
1311
|
+
if (files[0].status === Dropzone.CANCELED) {
|
1209
1312
|
return;
|
1210
1313
|
}
|
1211
1314
|
if (xhr.readyState !== 4) {
|
@@ -1224,11 +1327,11 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1224
1327
|
if (!((200 <= (_ref = xhr.status) && _ref < 300))) {
|
1225
1328
|
return handleError();
|
1226
1329
|
} else {
|
1227
|
-
return _this.
|
1330
|
+
return _this._finished(files, response, e);
|
1228
1331
|
}
|
1229
1332
|
};
|
1230
1333
|
xhr.onerror = function() {
|
1231
|
-
if (
|
1334
|
+
if (files[0].status === Dropzone.CANCELED) {
|
1232
1335
|
return;
|
1233
1336
|
}
|
1234
1337
|
return handleError();
|
@@ -1238,8 +1341,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1238
1341
|
headers = {
|
1239
1342
|
"Accept": "application/json",
|
1240
1343
|
"Cache-Control": "no-cache",
|
1241
|
-
"X-Requested-With": "XMLHttpRequest"
|
1242
|
-
"X-File-Name": encodeURIComponent(file.name)
|
1344
|
+
"X-Requested-With": "XMLHttpRequest"
|
1243
1345
|
};
|
1244
1346
|
if (this.options.headers) {
|
1245
1347
|
extend(headers, this.options.headers);
|
@@ -1256,42 +1358,70 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1256
1358
|
formData.append(key, value);
|
1257
1359
|
}
|
1258
1360
|
}
|
1361
|
+
for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
|
1362
|
+
file = files[_j];
|
1363
|
+
this.emit("sending", file, xhr, formData);
|
1364
|
+
}
|
1365
|
+
if (this.options.uploadMultiple) {
|
1366
|
+
this.emit("sendingmultiple", files, xhr, formData);
|
1367
|
+
}
|
1259
1368
|
if (this.element.tagName === "FORM") {
|
1260
1369
|
_ref2 = this.element.querySelectorAll("input, textarea, select, button");
|
1261
|
-
for (
|
1262
|
-
input = _ref2[
|
1370
|
+
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
1371
|
+
input = _ref2[_k];
|
1263
1372
|
inputName = input.getAttribute("name");
|
1264
1373
|
inputType = input.getAttribute("type");
|
1265
|
-
if (!inputType || inputType.toLowerCase() !== "checkbox" || input.checked) {
|
1374
|
+
if (!inputType || ((_ref3 = inputType.toLowerCase()) !== "checkbox" && _ref3 !== "radio") || input.checked) {
|
1266
1375
|
formData.append(inputName, input.value);
|
1267
1376
|
}
|
1268
1377
|
}
|
1269
1378
|
}
|
1270
|
-
|
1271
|
-
|
1379
|
+
for (_l = 0, _len3 = files.length; _l < _len3; _l++) {
|
1380
|
+
file = files[_l];
|
1381
|
+
formData.append("" + this.options.paramName + (this.options.uploadMultiple ? "[]" : ""), file, file.name);
|
1382
|
+
}
|
1272
1383
|
return xhr.send(formData);
|
1273
1384
|
};
|
1274
1385
|
|
1275
|
-
Dropzone.prototype.
|
1276
|
-
file
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1386
|
+
Dropzone.prototype._finished = function(files, responseText, e) {
|
1387
|
+
var file, _i, _len;
|
1388
|
+
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
1389
|
+
file = files[_i];
|
1390
|
+
file.status = Dropzone.SUCCESS;
|
1391
|
+
this.emit("success", file, responseText, e);
|
1392
|
+
this.emit("complete", file);
|
1393
|
+
}
|
1394
|
+
if (this.options.uploadMultiple) {
|
1395
|
+
this.emit("successmultiple", files, responseText, e);
|
1396
|
+
this.emit("completemultiple", files);
|
1397
|
+
}
|
1398
|
+
if (this.options.autoProcessQueue) {
|
1399
|
+
return this.processQueue();
|
1400
|
+
}
|
1281
1401
|
};
|
1282
1402
|
|
1283
|
-
Dropzone.prototype.
|
1284
|
-
file
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1403
|
+
Dropzone.prototype._errorProcessing = function(files, message, xhr) {
|
1404
|
+
var file, _i, _len;
|
1405
|
+
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
1406
|
+
file = files[_i];
|
1407
|
+
file.status = Dropzone.ERROR;
|
1408
|
+
this.emit("error", file, message, xhr);
|
1409
|
+
this.emit("complete", file);
|
1410
|
+
}
|
1411
|
+
if (this.options.uploadMultiple) {
|
1412
|
+
this.emit("errormultiple", files, message, xhr);
|
1413
|
+
this.emit("completemultiple", files);
|
1414
|
+
}
|
1415
|
+
if (this.options.autoProcessQueue) {
|
1416
|
+
return this.processQueue();
|
1417
|
+
}
|
1288
1418
|
};
|
1289
1419
|
|
1290
1420
|
return Dropzone;
|
1291
1421
|
|
1292
1422
|
})(Em);
|
1293
1423
|
|
1294
|
-
Dropzone.version = "3.
|
1424
|
+
Dropzone.version = "3.6.1";
|
1295
1425
|
|
1296
1426
|
Dropzone.options = {};
|
1297
1427
|
|
@@ -1457,22 +1587,27 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1457
1587
|
return elements;
|
1458
1588
|
};
|
1459
1589
|
|
1460
|
-
Dropzone.
|
1461
|
-
var baseMimeType,
|
1462
|
-
if (!
|
1590
|
+
Dropzone.isValidFile = function(file, acceptedFiles) {
|
1591
|
+
var baseMimeType, mimeType, validType, _i, _len;
|
1592
|
+
if (!acceptedFiles) {
|
1463
1593
|
return true;
|
1464
1594
|
}
|
1465
|
-
|
1595
|
+
acceptedFiles = acceptedFiles.split(",");
|
1596
|
+
mimeType = file.type;
|
1466
1597
|
baseMimeType = mimeType.replace(/\/.*$/, "");
|
1467
|
-
for (_i = 0, _len =
|
1468
|
-
|
1469
|
-
|
1470
|
-
if (
|
1471
|
-
if (
|
1598
|
+
for (_i = 0, _len = acceptedFiles.length; _i < _len; _i++) {
|
1599
|
+
validType = acceptedFiles[_i];
|
1600
|
+
validType = validType.trim();
|
1601
|
+
if (validType.charAt(0) === ".") {
|
1602
|
+
if (file.name.indexOf(validType, file.name.length - validType.length) !== -1) {
|
1603
|
+
return true;
|
1604
|
+
}
|
1605
|
+
} else if (/\/\*$/.test(validType)) {
|
1606
|
+
if (baseMimeType === validType.replace(/\/.*$/, "")) {
|
1472
1607
|
return true;
|
1473
1608
|
}
|
1474
1609
|
} else {
|
1475
|
-
if (mimeType ===
|
1610
|
+
if (mimeType === validType) {
|
1476
1611
|
return true;
|
1477
1612
|
}
|
1478
1613
|
}
|
@@ -1496,10 +1631,10 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
|
1496
1631
|
|
1497
1632
|
Dropzone.ADDED = "added";
|
1498
1633
|
|
1499
|
-
Dropzone.ACCEPTED = "accepted";
|
1500
|
-
|
1501
1634
|
Dropzone.QUEUED = "queued";
|
1502
1635
|
|
1636
|
+
Dropzone.ACCEPTED = Dropzone.QUEUED;
|
1637
|
+
|
1503
1638
|
Dropzone.UPLOADING = "uploading";
|
1504
1639
|
|
1505
1640
|
Dropzone.PROCESSING = Dropzone.UPLOADING;
|
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.5
|
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-
|
11
|
+
date: 2013-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|