dropzonejs-rails 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2EzZDA4ZWZjNWMyMDBhYzkyZjk4MzJlZmJkOThlYzBkYjk5ODE5Mw==
4
+ YzIxZTY2ZjRjMmE1YWJmZGYyYjdlMWIxOTczY2QwZDBkY2YwODRhMA==
5
5
  data.tar.gz: !binary |-
6
- ODkyMjUyNzk0MzRlOGEwNjQyY2RmNTA1NjJmZTlkOTM4YWQ4ZDY5NA==
6
+ MWJiZDY2YzFiNTNkNDIwMzU5MThmMWNhNGRkYTAwMTBhNDc3YjA0Mg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OGY0MDExMjY2Y2Y3ZmVmYTEzMDc4ZWVjYzY0NDhhZWJjNTViOTUwNTNlNzgz
10
- NWY2ZWI2ZWFkOTk3ZTZiMTYxNThmMzVhNTQyYjYxZDMyOGY0Yjg1YzY1MTQ4
11
- MzkyMmY0Y2EyYTI5MmQzN2I2YjQzNDE1NzVhMWRmZDI3YWZkYTI=
9
+ YmE5MWFlYTZjYjFkMWY4ZGUwOTA5YTUzMDMwNGRiZDMwMDI5NmMwNzk2YjJi
10
+ NTc0MjA4Zjk0MGZjZTQxZmQwZjgzZDdkM2M1MTEzNDVkMzZkN2RlZThmMWU3
11
+ N2RjYzM2M2E5ZmRkZDg1MWJhY2E5OWM1OWRhY2MzY2M2YjBmZjY=
12
12
  data.tar.gz: !binary |-
13
- NDcwOTk1OGJjNjFiZWY4YjlkZmVjOTk1NWFmNGI5OTU2NDgxNGY3ZGRlMjc0
14
- NjA3ZWYwZTYwOTgyZWY4MGE4MTlhZmMyMjM3NGQzODJhMzA2YjcwY2M5MjI1
15
- OWZlOTg1OWQ2NDhlYWZhYjFiZWEyNGE2NzdlYjhhMGJkM2FkMDM=
13
+ MjhjNzJjZDkyYzVmNzFiODAzYmNiZDQyZWFmOWFiMTczYzFhOGFmZGU2MTQ2
14
+ OTNlOTM0ZmNhZmY5OGY4Yjk2ZWM3MjE4ZmM0YTRlNjk4NTg0MzNjOWIwMjRj
15
+ OGI2YjBmZDUyMjczNTc2NWUxYjVjZTc4NDRlODlkZGI2MTU5Njc=
data/README.md CHANGED
@@ -4,7 +4,7 @@ Integrate [Matias Meno's Dropzone](http://www.dropzonejs.com/) awesome file uplo
4
4
 
5
5
  ## Version
6
6
 
7
- The latest version of this gem bundles **Dropzone v3.5.3**.
7
+ The latest version of this gem bundles **Dropzone v3.6.1**.
8
8
 
9
9
  ## Installation and usage
10
10
 
@@ -1,4 +1,4 @@
1
1
  module DropzonejsRails
2
- VERSION = '0.4.4'
3
- DROPZONE_VERSION = '3.5.3'
2
+ VERSION = '0.4.5'
3
+ DROPZONE_VERSION = '3.6.1'
4
4
  end
@@ -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", "processingfile", "uploadprogress", "totaluploadprogress", "sending", "success", "complete", "reset"];
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
- acceptParameter: null,
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
- processingfile: function(file) {
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.acceptParameter && this.options.acceptedMimeTypes) {
631
- throw new Error("You can't provide both 'acceptParameter' and 'acceptedMimeTypes'. 'acceptParameter' is deprecated.");
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
- if (!file.accepted) {
671
- _ref = this.files;
672
- _results = [];
673
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
674
- file = _ref[_i];
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.hiddenFileInput.setAttribute("multiple", "multiple");
733
- if (_this.options.acceptedMimeTypes != null) {
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.acceptParameter != null) {
737
- _this.hiddenFileInput.setAttribute("accept", _this.options.acceptParameter);
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=\"multiple\" /><button type=\"submit\">Upload!</button></div>";
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.isValidMimeType(file.type, this.options.acceptedMimeTypes)) {
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.errorProcessing(file, error);
1053
+ return _this._errorProcessing([file], error);
1048
1054
  } else {
1049
- file.status = Dropzone.ACCEPTED;
1050
1055
  file.accepted = true;
1051
- if (_this.options.enqueueForUpload) {
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
- while (i < parallelUploads) {
1149
- if (!queuedFiles.length) {
1150
- return;
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.processing = true;
1159
- file.status = Dropzone.UPLOADING;
1160
- this.emit("processingfile", file);
1161
- return this.uploadFile(file);
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
- file.status = Dropzone.CANCELED;
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
- } else if ((_ref = file.status) === Dropzone.ADDED || _ref === Dropzone.ACCEPTED || _ref === Dropzone.QUEUED) {
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
- var formData, handleError, header, headers, input, inputName, inputType, key, name, progressObj, response, updateProgress, value, xhr, _i, _len, _ref, _ref1, _ref2,
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
- file.xhr = xhr;
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
- return _this.errorProcessing(file, response || _this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr);
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
- file.upload = {
1192
- progress: progress,
1193
- total: e.total,
1194
- bytesSent: e.loaded
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
- if (file.upload.progress === 100 && file.upload.bytesSent === file.upload.total) {
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
- return _this.emit("uploadprogress", file, progress, file.upload.bytesSent);
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 (file.status === Dropzone.CANCELED) {
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.finished(file, response, e);
1330
+ return _this._finished(files, response, e);
1228
1331
  }
1229
1332
  };
1230
1333
  xhr.onerror = function() {
1231
- if (file.status === Dropzone.CANCELED) {
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 (_i = 0, _len = _ref2.length; _i < _len; _i++) {
1262
- input = _ref2[_i];
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
- this.emit("sending", file, xhr, formData);
1271
- formData.append(this.options.paramName, file);
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.finished = function(file, responseText, e) {
1276
- file.status = Dropzone.SUCCESS;
1277
- this.processQueue();
1278
- this.emit("success", file, responseText, e);
1279
- this.emit("finished", file, responseText, e);
1280
- return this.emit("complete", file);
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.errorProcessing = function(file, message, xhr) {
1284
- file.status = Dropzone.ERROR;
1285
- this.processQueue();
1286
- this.emit("error", file, message, xhr);
1287
- return this.emit("complete", file);
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.5.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.isValidMimeType = function(mimeType, acceptedMimeTypes) {
1461
- var baseMimeType, validMimeType, _i, _len;
1462
- if (!acceptedMimeTypes) {
1590
+ Dropzone.isValidFile = function(file, acceptedFiles) {
1591
+ var baseMimeType, mimeType, validType, _i, _len;
1592
+ if (!acceptedFiles) {
1463
1593
  return true;
1464
1594
  }
1465
- acceptedMimeTypes = acceptedMimeTypes.split(",");
1595
+ acceptedFiles = acceptedFiles.split(",");
1596
+ mimeType = file.type;
1466
1597
  baseMimeType = mimeType.replace(/\/.*$/, "");
1467
- for (_i = 0, _len = acceptedMimeTypes.length; _i < _len; _i++) {
1468
- validMimeType = acceptedMimeTypes[_i];
1469
- validMimeType = validMimeType.trim();
1470
- if (/\/\*$/.test(validMimeType)) {
1471
- if (baseMimeType === validMimeType.replace(/\/.*$/, "")) {
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 === validMimeType) {
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
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-06-26 00:00:00.000000000 Z
11
+ date: 2013-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit