dropzonejs-rails 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 56a0173ec08b69509951bf1e974c2f86fcd743f9
4
- data.tar.gz: 02ddfe7c21416d3ab877a1cc0109d74efd09efd8
3
+ metadata.gz: c040bfdcb98b7e16531d426e4880f2372765256d
4
+ data.tar.gz: dcc2d26ec689cbccb794891544e294ea85c489e3
5
5
  SHA512:
6
- metadata.gz: f1755eb86e2a085d79eef80abbc734ba48371781c644f6cf0843fedb0f7ba26eab8f82aadbccbcdab78ccb92a1121be37a6edce5b23bffd1c1faf0a089439b4b
7
- data.tar.gz: bfe492d67b1156463c23cbc3ea9195c80a8e9546a534c737c87f7c68a8b9e01b2a0749feda45d499de595502d667701b71b3ee05d335ee87f7ea3eaf63d4e6b8
6
+ metadata.gz: 18c8dfc08cfbc8fec8486a0900173f8793572eef2bbdd7bf96fa2b4c11b87be147fcc7a306350f781b927dd7a1e93566d7c8c1005b77bfd9f1fc5fa8fab0dc34
7
+ data.tar.gz: ec4aa40a72cd5fd42dad48b9e24f6504f8462a3ebbf3c4593dbbefda116f79caf5d741a5abf84444518ad4e92df3adf83aa75e7b641aedde8f251f76ea835960
data/README.md CHANGED
@@ -4,11 +4,11 @@ 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 v4.0.1**.
7
+ The latest version of this gem bundles **Dropzone v4.2.0**.
8
8
 
9
9
  ### Dropzone 3.x
10
10
 
11
- If you depend on Dropzone's 3.x branch, you need to specify `gem 'dropzonejs-rails', '~> 0.6.0'` in your Gemfile, otherwise you'll get 4.x.
11
+ If you depend on Dropzone's 3.x branch, you need to specify `gem 'dropzonejs-rails', '~> 0.5.3'` in your Gemfile, otherwise you'll get 4.x.
12
12
 
13
13
  ## Installation and usage
14
14
 
@@ -111,7 +111,7 @@
111
111
  dropzone.on("dragEnter", function() { });
112
112
  */
113
113
 
114
- Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "addedfile", "removedfile", "thumbnail", "error", "errormultiple", "processing", "processingmultiple", "uploadprogress", "totaluploadprogress", "sending", "sendingmultiple", "success", "successmultiple", "canceled", "canceledmultiple", "complete", "completemultiple", "reset", "maxfilesexceeded", "maxfilesreached", "queuecomplete"];
114
+ Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "addedfile", "addedfiles", "removedfile", "thumbnail", "error", "errormultiple", "processing", "processingmultiple", "uploadprogress", "totaluploadprogress", "sending", "sendingmultiple", "success", "successmultiple", "canceled", "canceledmultiple", "complete", "completemultiple", "reset", "maxfilesexceeded", "maxfilesreached", "queuecomplete"];
115
115
 
116
116
  Dropzone.prototype.defaultOptions = {
117
117
  url: null,
@@ -127,7 +127,6 @@
127
127
  thumbnailHeight: 120,
128
128
  filesizeBase: 1000,
129
129
  maxFiles: null,
130
- filesizeBase: 1000,
131
130
  params: {},
132
131
  clickable: true,
133
132
  ignoreHiddenFiles: true,
@@ -137,6 +136,7 @@
137
136
  autoQueue: true,
138
137
  addRemoveLinks: false,
139
138
  previewsContainer: null,
139
+ hiddenInputContainer: "body",
140
140
  capture: null,
141
141
  dictDefaultMessage: "Drop files here to upload",
142
142
  dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.",
@@ -174,7 +174,11 @@
174
174
  }
175
175
  span = messageElement.getElementsByTagName("span")[0];
176
176
  if (span) {
177
- span.textContent = this.options.dictFallbackMessage;
177
+ if (span.textContent != null) {
178
+ span.textContent = this.options.dictFallbackMessage;
179
+ } else if (span.innerText != null) {
180
+ span.innerText = this.options.dictFallbackMessage;
181
+ }
178
182
  }
179
183
  return this.element.appendChild(this.getFallbackForm());
180
184
  },
@@ -387,6 +391,7 @@
387
391
  maxfilesexceeded: noop,
388
392
  maxfilesreached: noop,
389
393
  queuecomplete: noop,
394
+ addedfiles: noop,
390
395
  previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n <div class=\"dz-image\"><img data-dz-thumbnail /></div>\n <div class=\"dz-details\">\n <div class=\"dz-size\"><span data-dz-size></span></div>\n <div class=\"dz-filename\"><span data-dz-name></span></div>\n </div>\n <div class=\"dz-progress\"><span class=\"dz-upload\" data-dz-uploadprogress></span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n <div class=\"dz-success-mark\">\n <svg width=\"54px\" height=\"54px\" viewBox=\"0 0 54 54\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:sketch=\"http://www.bohemiancoding.com/sketch/ns\">\n <title>Check</title>\n <defs></defs>\n <g id=\"Page-1\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\" sketch:type=\"MSPage\">\n <path d=\"M23.5,31.8431458 L17.5852419,25.9283877 C16.0248253,24.3679711 13.4910294,24.366835 11.9289322,25.9289322 C10.3700136,27.4878508 10.3665912,30.0234455 11.9283877,31.5852419 L20.4147581,40.0716123 C20.5133999,40.1702541 20.6159315,40.2626649 20.7218615,40.3488435 C22.2835669,41.8725651 24.794234,41.8626202 26.3461564,40.3106978 L43.3106978,23.3461564 C44.8771021,21.7797521 44.8758057,19.2483887 43.3137085,17.6862915 C41.7547899,16.1273729 39.2176035,16.1255422 37.6538436,17.6893022 L23.5,31.8431458 Z M27,53 C41.3594035,53 53,41.3594035 53,27 C53,12.6405965 41.3594035,1 27,1 C12.6405965,1 1,12.6405965 1,27 C1,41.3594035 12.6405965,53 27,53 Z\" id=\"Oval-2\" stroke-opacity=\"0.198794158\" stroke=\"#747474\" fill-opacity=\"0.816519475\" fill=\"#FFFFFF\" sketch:type=\"MSShapeGroup\"></path>\n </g>\n </svg>\n </div>\n <div class=\"dz-error-mark\">\n <svg width=\"54px\" height=\"54px\" viewBox=\"0 0 54 54\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:sketch=\"http://www.bohemiancoding.com/sketch/ns\">\n <title>Error</title>\n <defs></defs>\n <g id=\"Page-1\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\" sketch:type=\"MSPage\">\n <g id=\"Check-+-Oval-2\" sketch:type=\"MSLayerGroup\" stroke=\"#747474\" stroke-opacity=\"0.198794158\" fill=\"#FFFFFF\" fill-opacity=\"0.816519475\">\n <path d=\"M32.6568542,29 L38.3106978,23.3461564 C39.8771021,21.7797521 39.8758057,19.2483887 38.3137085,17.6862915 C36.7547899,16.1273729 34.2176035,16.1255422 32.6538436,17.6893022 L27,23.3431458 L21.3461564,17.6893022 C19.7823965,16.1255422 17.2452101,16.1273729 15.6862915,17.6862915 C14.1241943,19.2483887 14.1228979,21.7797521 15.6893022,23.3461564 L21.3431458,29 L15.6893022,34.6538436 C14.1228979,36.2202479 14.1241943,38.7516113 15.6862915,40.3137085 C17.2452101,41.8726271 19.7823965,41.8744578 21.3461564,40.3106978 L27,34.6568542 L32.6538436,40.3106978 C34.2176035,41.8744578 36.7547899,41.8726271 38.3137085,40.3137085 C39.8758057,38.7516113 39.8771021,36.2202479 38.3106978,34.6538436 L32.6568542,29 Z M27,53 C41.3594035,53 53,41.3594035 53,27 C53,12.6405965 41.3594035,1 27,1 C12.6405965,1 1,12.6405965 1,27 C1,41.3594035 12.6405965,53 27,53 Z\" id=\"Oval-2\" sketch:type=\"MSShapeGroup\"></path>\n </g>\n </g>\n </svg>\n </div>\n</div>"
391
396
  };
392
397
 
@@ -508,6 +513,10 @@
508
513
  return this.getFilesWithStatus(Dropzone.UPLOADING);
509
514
  };
510
515
 
516
+ Dropzone.prototype.getAddedFiles = function() {
517
+ return this.getFilesWithStatus(Dropzone.ADDED);
518
+ };
519
+
511
520
  Dropzone.prototype.getActiveFiles = function() {
512
521
  var file, _i, _len, _ref, _results;
513
522
  _ref = this.files;
@@ -533,7 +542,7 @@
533
542
  setupHiddenFileInput = (function(_this) {
534
543
  return function() {
535
544
  if (_this.hiddenFileInput) {
536
- document.body.removeChild(_this.hiddenFileInput);
545
+ _this.hiddenFileInput.parentNode.removeChild(_this.hiddenFileInput);
537
546
  }
538
547
  _this.hiddenFileInput = document.createElement("input");
539
548
  _this.hiddenFileInput.setAttribute("type", "file");
@@ -553,7 +562,7 @@
553
562
  _this.hiddenFileInput.style.left = "0";
554
563
  _this.hiddenFileInput.style.height = "0";
555
564
  _this.hiddenFileInput.style.width = "0";
556
- document.body.appendChild(_this.hiddenFileInput);
565
+ document.querySelector(_this.options.hiddenInputContainer).appendChild(_this.hiddenFileInput);
557
566
  return _this.hiddenFileInput.addEventListener("change", function() {
558
567
  var file, files, _i, _len;
559
568
  files = _this.hiddenFileInput.files;
@@ -563,6 +572,7 @@
563
572
  _this.addFile(file);
564
573
  }
565
574
  }
575
+ _this.emit("addedfiles", files);
566
576
  return setupHiddenFileInput();
567
577
  });
568
578
  };
@@ -592,7 +602,7 @@
592
602
  })(this));
593
603
  this.on("complete", (function(_this) {
594
604
  return function(file) {
595
- if (_this.getUploadingFiles().length === 0 && _this.getQueuedFiles().length === 0) {
605
+ if (_this.getAddedFiles().length === 0 && _this.getUploadingFiles().length === 0 && _this.getQueuedFiles().length === 0) {
596
606
  return setTimeout((function() {
597
607
  return _this.emit("queuecomplete");
598
608
  }), 0);
@@ -659,8 +669,9 @@
659
669
  events: {
660
670
  "click": function(evt) {
661
671
  if ((clickableElement !== _this.element) || (evt.target === _this.element || Dropzone.elementInside(evt.target, _this.element.querySelector(".dz-message")))) {
662
- return _this.hiddenFileInput.click();
672
+ _this.hiddenFileInput.click();
663
673
  }
674
+ return true;
664
675
  }
665
676
  }
666
677
  });
@@ -814,18 +825,21 @@
814
825
 
815
826
  Dropzone.prototype.filesize = function(size) {
816
827
  var cutoff, i, selectedSize, selectedUnit, unit, units, _i, _len;
817
- units = ['TB', 'GB', 'MB', 'KB', 'b'];
818
- selectedSize = selectedUnit = null;
819
- for (i = _i = 0, _len = units.length; _i < _len; i = ++_i) {
820
- unit = units[i];
821
- cutoff = Math.pow(this.options.filesizeBase, 4 - i) / 10;
822
- if (size >= cutoff) {
823
- selectedSize = size / Math.pow(this.options.filesizeBase, 4 - i);
824
- selectedUnit = unit;
825
- break;
828
+ selectedSize = 0;
829
+ selectedUnit = "b";
830
+ if (size > 0) {
831
+ units = ['TB', 'GB', 'MB', 'KB', 'b'];
832
+ for (i = _i = 0, _len = units.length; _i < _len; i = ++_i) {
833
+ unit = units[i];
834
+ cutoff = Math.pow(this.options.filesizeBase, 4 - i) / 10;
835
+ if (size >= cutoff) {
836
+ selectedSize = size / Math.pow(this.options.filesizeBase, 4 - i);
837
+ selectedUnit = unit;
838
+ break;
839
+ }
826
840
  }
841
+ selectedSize = Math.round(10 * selectedSize) / 10;
827
842
  }
828
- selectedSize = Math.round(10 * selectedSize) / 10;
829
843
  return "<strong>" + selectedSize + "</strong> " + selectedUnit;
830
844
  };
831
845
 
@@ -847,6 +861,7 @@
847
861
  }
848
862
  this.emit("drop", e);
849
863
  files = e.dataTransfer.files;
864
+ this.emit("addedfiles", files);
850
865
  if (files.length) {
851
866
  items = e.dataTransfer.items;
852
867
  if (items && items.length && (items[0].webkitGetAsEntry != null)) {
@@ -1067,9 +1082,12 @@
1067
1082
  return fileReader.readAsDataURL(file);
1068
1083
  };
1069
1084
 
1070
- Dropzone.prototype.createThumbnailFromUrl = function(file, imageUrl, callback) {
1085
+ Dropzone.prototype.createThumbnailFromUrl = function(file, imageUrl, callback, crossOrigin) {
1071
1086
  var img;
1072
1087
  img = document.createElement("img");
1088
+ if (crossOrigin) {
1089
+ img.crossOrigin = crossOrigin;
1090
+ }
1073
1091
  img.onload = (function(_this) {
1074
1092
  return function() {
1075
1093
  var canvas, ctx, resizeInfo, thumbnail, _ref, _ref1, _ref2, _ref3;
@@ -1305,7 +1323,9 @@
1305
1323
  }
1306
1324
  for (headerName in headers) {
1307
1325
  headerValue = headers[headerName];
1308
- xhr.setRequestHeader(headerName, headerValue);
1326
+ if (headerValue) {
1327
+ xhr.setRequestHeader(headerName, headerValue);
1328
+ }
1309
1329
  }
1310
1330
  formData = new FormData();
1311
1331
  if (this.options.params) {
@@ -1344,6 +1364,10 @@
1344
1364
  for (i = _m = 0, _ref5 = files.length - 1; 0 <= _ref5 ? _m <= _ref5 : _m >= _ref5; i = 0 <= _ref5 ? ++_m : --_m) {
1345
1365
  formData.append(this._getParamName(i), files[i], files[i].name);
1346
1366
  }
1367
+ return this.submitRequest(xhr, formData, files);
1368
+ };
1369
+
1370
+ Dropzone.prototype.submitRequest = function(xhr, formData, files) {
1347
1371
  return xhr.send(formData);
1348
1372
  };
1349
1373
 
@@ -1385,7 +1409,7 @@
1385
1409
 
1386
1410
  })(Emitter);
1387
1411
 
1388
- Dropzone.version = "4.0.1";
1412
+ Dropzone.version = "4.2.0";
1389
1413
 
1390
1414
  Dropzone.options = {};
1391
1415
 
@@ -1,4 +1,4 @@
1
1
  module DropzonejsRails
2
- VERSION = '0.7.1'
3
- DROPZONE_VERSION = '4.0.1'
2
+ VERSION = '0.7.2'
3
+ DROPZONE_VERSION = '4.2.0'
4
4
  end
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.7.1
4
+ version: 0.7.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: 2015-02-19 00:00:00.000000000 Z
11
+ date: 2015-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  requirements: []
91
91
  rubyforge_project:
92
- rubygems_version: 2.4.5
92
+ rubygems_version: 2.4.8
93
93
  signing_key:
94
94
  specification_version: 4
95
95
  summary: Integrates Dropzone JS File upload into Rails Asset pipeline.