dropzonejs-rails 0.3.1 → 0.3.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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YmRkMWIyNWYxMDJmZDQwYmMzZmE5ZjUzZTYwZjZhYTZkMDU1YmE0OQ==
4
+ YTkwMTIzM2RiNzE2ZGEwMDFhNTIzN2M3ZTc4MzBmZWUzYzk2YjFlNA==
5
5
  data.tar.gz: !binary |-
6
- NGU5NzM5MjUzZmFjODc1NTI2MDIyNzU1ZTk0ZjRiNWYwNWRhYWE3MQ==
6
+ ZWMyNDZkYjZiY2M0NGExMDhmYWY4MjM3MDZhZTAxMTI4Y2RkMDZjOA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NTA3OTAyNTc2NGVkMjk5NzNlYzNhYmRiZGRjZDhjNWIxYWZiNjRkMzA5ZTVj
10
- NzMxZTlhOTQzOTZkM2NhY2Y0NjljNDcxNTAwNzExMWQ1MTFjZDZlMzc2ZGI5
11
- MzgzMzUyZWMyZDg3MDFmYzIzNjVmM2E5OTAwMDZkZDY2ZDBiMjY=
9
+ ODc0MjFhNjJkYzQxY2YwNTBjYTdhNjZkZTFhY2I1OTNiYTExM2U0Njc4ZTdh
10
+ MTJhMmNhODU5YTZhOTE5MzdkZjA3ZTRkOTcwMDg2NThhZGUxZWRkYTI1ZWNj
11
+ MjFiNTAzM2FiY2EzMzcxNmMzNDZhM2I5MDA1YTRlODNhMTY1MWI=
12
12
  data.tar.gz: !binary |-
13
- ZDUyNzFmZTg3ZjQ3MTA2MGQ4MzQ0N2Y2YmFlOTdlMDgwODhlZjdhMTgwYTVk
14
- MmE5YmI4MTJhN2FhMmUwN2FjMmM1ZGY2MjBhNWY0OTAyNjJkZWY5MjM0Yzcx
15
- OTY2ZjY5YzBkNzMyMTg4NWE5OWFiN2ZkNTQ5NjFkZmY1ODEwZTg=
13
+ YTZkYzNkNzRlZTJjZWIxMzRkYTI0MGVhOWQyZTRhYTI1MmFjY2QyOTdlZTgx
14
+ YTRkMDVkMDU5MzlkNGUyNDg0MDUwODk4YWRlMjlmOTViYTM1ZWNkZDQ3NjEy
15
+ ZjM3OGZkNmEzMzk5NTE5NDVjYWEyNmI1MmYzOTM5MGRkZGE1ZTk=
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.1.0**.
7
+ The latest version of this gem bundles **Dropzone v3.2.0**.
8
8
 
9
9
  ## Installation and usage
10
10
 
@@ -27,11 +27,11 @@ After that, you need to make `dropzone.js` available on your pages. To do that,
27
27
 
28
28
  And if you would like to use one of the styles bundled with Dropzone, add to your `application.css`:
29
29
  ```scss
30
- //= require dropzone/basic
30
+ *= require dropzone/basic
31
31
  ```
32
32
  or
33
33
  ```scss
34
- //= require dropzone/dropzone
34
+ *= require dropzone/dropzone
35
35
  ```
36
36
 
37
37
  And **Bam!** - you're all set.
@@ -1,4 +1,4 @@
1
1
  module DropzonejsRails
2
- VERSION = '0.3.1'
3
- DROPZONE_VERSION = '3.1.0'
2
+ VERSION = '0.3.2'
3
+ DROPZONE_VERSION = '3.2.0'
4
4
  end
@@ -1,12 +1,5 @@
1
1
  ;(function(){
2
2
 
3
-
4
- /**
5
- * hasOwnProperty.
6
- */
7
-
8
- var has = Object.prototype.hasOwnProperty;
9
-
10
3
  /**
11
4
  * Require the given path.
12
5
  *
@@ -83,10 +76,10 @@ require.resolve = function(path) {
83
76
 
84
77
  for (var i = 0; i < paths.length; i++) {
85
78
  var path = paths[i];
86
- if (has.call(require.modules, path)) return path;
79
+ if (require.modules.hasOwnProperty(path)) return path;
87
80
  }
88
81
 
89
- if (has.call(require.aliases, index)) {
82
+ if (require.aliases.hasOwnProperty(index)) {
90
83
  return require.aliases[index];
91
84
  }
92
85
  };
@@ -140,7 +133,7 @@ require.register = function(path, definition) {
140
133
  */
141
134
 
142
135
  require.alias = function(from, to) {
143
- if (!has.call(require.modules, from)) {
136
+ if (!require.modules.hasOwnProperty(from)) {
144
137
  throw new Error('Failed to alias "' + from + '", it does not exist');
145
138
  }
146
139
  require.aliases[to] = from;
@@ -202,7 +195,7 @@ require.relative = function(parent) {
202
195
  */
203
196
 
204
197
  localRequire.exists = function(path) {
205
- return has.call(require.modules, localRequire.resolve(path));
198
+ return require.modules.hasOwnProperty(localRequire.resolve(path));
206
199
  };
207
200
 
208
201
  return localRequire;
@@ -418,7 +411,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
418
411
  */
419
412
 
420
413
 
421
- Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "selectedfiles", "addedfile", "removedfile", "thumbnail", "error", "processingfile", "uploadprogress", "sending", "success", "complete", "reset"];
414
+ Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "selectedfiles", "addedfile", "removedfile", "thumbnail", "error", "processingfile", "uploadprogress", "totaluploadprogress", "sending", "success", "complete", "reset"];
422
415
 
423
416
  Dropzone.prototype.defaultOptions = {
424
417
  url: null,
@@ -561,6 +554,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
561
554
  uploadprogress: function(file, progress, bytesSent) {
562
555
  return file.previewElement.querySelector("[data-dz-uploadprogress]").style.width = "" + progress + "%";
563
556
  },
557
+ totaluploadprogress: noop,
564
558
  sending: noop,
565
559
  success: function(file) {
566
560
  return file.previewElement.classList.add("dz-success");
@@ -618,28 +612,18 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
618
612
  fallback.parentNode.removeChild(fallback);
619
613
  }
620
614
  if (this.options.previewsContainer) {
621
- if (typeof this.options.previewsContainer === "string") {
622
- this.previewsContainer = document.querySelector(this.options.previewsContainer);
623
- } else if (this.options.previewsContainer.nodeType != null) {
624
- this.previewsContainer = this.options.previewsContainer;
625
- }
626
- if (this.previewsContainer == null) {
627
- throw new Error("Invalid `previewsContainer` option provided. Please provide a CSS selector or a plain HTML element.");
628
- }
615
+ this.previewsContainer = Dropzone.getElement(this.options.previewsContainer, "previewsContainer");
629
616
  } else {
630
617
  this.previewsContainer = this.element;
631
618
  }
632
619
  if (this.options.clickable) {
633
620
  if (this.options.clickable === true) {
634
- this.clickableElement = this.element;
635
- } else if (typeof this.options.clickable === "string") {
636
- this.clickableElement = document.querySelector(this.options.clickable);
637
- } else if (this.options.clickable.nodeType != null) {
638
- this.clickableElement = this.options.clickable;
639
- }
640
- if (!this.clickableElement) {
641
- throw new Error("Invalid `clickable` element provided. Please set it to `true`, a plain HTML element or a valid CSS selector.");
621
+ this.clickableElements = [this.element];
622
+ } else {
623
+ this.clickableElements = Dropzone.getElements(this.options.clickable, "clickable");
642
624
  }
625
+ } else {
626
+ this.clickableElements = [];
643
627
  }
644
628
  this.init();
645
629
  }
@@ -654,7 +638,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
654
638
  if (this.element.classList.contains("dropzone") && !this.element.querySelector("[data-dz-message]")) {
655
639
  this.element.appendChild(Dropzone.createElement("<div class=\"dz-default dz-message\" data-dz-message><span>" + this.options.dictDefaultMessage + "</span></div>"));
656
640
  }
657
- if (this.clickableElement) {
641
+ if (this.clickableElements.length) {
658
642
  setupHiddenFileInput = function() {
659
643
  if (_this.hiddenFileInput) {
660
644
  document.body.removeChild(_this.hiddenFileInput);
@@ -689,6 +673,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
689
673
  setupHiddenFileInput();
690
674
  }
691
675
  this.files = [];
676
+ this.acceptedFiles = [];
692
677
  this.filesQueue = [];
693
678
  this.filesProcessing = [];
694
679
  this.URL = (_ref = window.URL) != null ? _ref : window.webkitURL;
@@ -702,7 +687,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
702
687
 
703
688
  totalBytesSent = 0;
704
689
  totalBytes = 0;
705
- _ref2 = _this.files;
690
+ _ref2 = _this.acceptedFiles;
706
691
  for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
707
692
  file = _ref2[_j];
708
693
  totalBytesSent += file.upload.bytesSent;
@@ -748,18 +733,18 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
748
733
  }
749
734
  }
750
735
  ];
751
- if (this.clickableElement) {
752
- this.listeners.push({
753
- element: this.clickableElement,
736
+ this.clickableElements.forEach(function(clickableElement) {
737
+ return _this.listeners.push({
738
+ element: clickableElement,
754
739
  events: {
755
740
  "click": function(evt) {
756
- if ((_this.clickableElement !== _this.element) || (evt.target === _this.element || Dropzone.elementInside(evt.target, _this.element.querySelector(".dz-message")))) {
741
+ if ((clickableElement !== _this.element) || (evt.target === _this.element || Dropzone.elementInside(evt.target, _this.element.querySelector(".dz-message")))) {
757
742
  return _this.hiddenFileInput.click();
758
743
  }
759
744
  }
760
745
  }
761
746
  });
762
- }
747
+ });
763
748
  this.enable();
764
749
  return this.options.init.call(this);
765
750
  };
@@ -774,7 +759,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
774
759
  if (this.options.dictFallbackText) {
775
760
  fieldsString += "<p>" + this.options.dictFallbackText + "</p>";
776
761
  }
777
- fieldsString += "<input type=\"file\" name=\"" + this.options.paramName + "\" multiple=\"multiple\" /><button type=\"submit\">Upload!</button></div>";
762
+ fieldsString += "<input type=\"file\" name=\"" + this.options.paramName + "[]\" multiple=\"multiple\" /><button type=\"submit\">Upload!</button></div>";
778
763
  fields = Dropzone.createElement(fieldsString);
779
764
  if (this.element.tagName !== "FORM") {
780
765
  form = Dropzone.createElement("<form action=\"" + this.options.url + "\" enctype=\"multipart/form-data\" method=\"" + this.options.method + "\"></form>");
@@ -853,18 +838,18 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
853
838
  };
854
839
 
855
840
  Dropzone.prototype.disable = function() {
856
- if (this.clickableElement === this.element) {
857
- this.element.classList.remove("dz-clickable");
858
- }
841
+ this.clickableElements.forEach(function(element) {
842
+ return element.classList.remove("dz-clickable");
843
+ });
859
844
  this.removeEventListeners();
860
845
  this.filesProcessing = [];
861
846
  return this.filesQueue = [];
862
847
  };
863
848
 
864
849
  Dropzone.prototype.enable = function() {
865
- if (this.clickableElement === this.element) {
866
- this.element.classList.add("dz-clickable");
867
- }
850
+ this.clickableElements.forEach(function(element) {
851
+ return element.classList.add("dz-clickable");
852
+ });
868
853
  return this.setupEventListeners();
869
854
  };
870
855
 
@@ -939,8 +924,11 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
939
924
  }
940
925
  return this.accept(file, function(error) {
941
926
  if (error) {
927
+ file.accepted = false;
942
928
  return _this.errorProcessing(file, error);
943
929
  } else {
930
+ file.accepted = true;
931
+ _this.acceptedFiles.push(file);
944
932
  if (_this.options.enqueueForUpload) {
945
933
  _this.filesQueue.push(file);
946
934
  return _this.processQueue();
@@ -1122,7 +1110,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
1122
1110
 
1123
1111
  })(Em);
1124
1112
 
1125
- Dropzone.version = "3.1.0";
1113
+ Dropzone.version = "3.2.0";
1126
1114
 
1127
1115
  Dropzone.options = {};
1128
1116
 
@@ -1250,6 +1238,50 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
1250
1238
  return false;
1251
1239
  };
1252
1240
 
1241
+ Dropzone.getElement = function(el, name) {
1242
+ var element;
1243
+
1244
+ if (typeof el === "string") {
1245
+ element = document.querySelector(el);
1246
+ } else if (el.nodeType != null) {
1247
+ element = el;
1248
+ }
1249
+ if (element == null) {
1250
+ throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector or a plain HTML element.");
1251
+ }
1252
+ return element;
1253
+ };
1254
+
1255
+ Dropzone.getElements = function(els, name) {
1256
+ var e, el, elements, _i, _j, _len, _len1, _ref;
1257
+
1258
+ if (els instanceof Array) {
1259
+ elements = [];
1260
+ try {
1261
+ for (_i = 0, _len = els.length; _i < _len; _i++) {
1262
+ el = els[_i];
1263
+ elements.push(this.getElement(el, name));
1264
+ }
1265
+ } catch (_error) {
1266
+ e = _error;
1267
+ elements = null;
1268
+ }
1269
+ } else if (typeof els === "string") {
1270
+ elements = [];
1271
+ _ref = document.querySelectorAll(els);
1272
+ for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
1273
+ el = _ref[_j];
1274
+ elements.push(el);
1275
+ }
1276
+ } else if (els.nodeType != null) {
1277
+ elements = [els];
1278
+ }
1279
+ if (!((elements != null) && elements.length)) {
1280
+ throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector, a plain HTML element or a list of those.");
1281
+ }
1282
+ return elements;
1283
+ };
1284
+
1253
1285
  Dropzone.isValidMimeType = function(mimeType, acceptedMimeTypes) {
1254
1286
  var baseMimeType, validMimeType, _i, _len;
1255
1287
 
@@ -1355,11 +1387,12 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
1355
1387
 
1356
1388
  });
1357
1389
  require.alias("component-emitter/index.js", "dropzone/deps/emitter/index.js");
1390
+ require.alias("component-emitter/index.js", "emitter/index.js");
1358
1391
 
1359
1392
  if (typeof exports == "object") {
1360
1393
  module.exports = require("dropzone");
1361
1394
  } else if (typeof define == "function" && define.amd) {
1362
1395
  define(function(){ return require("dropzone"); });
1363
1396
  } else {
1364
- window["Dropzone"] = require("dropzone");
1397
+ this["Dropzone"] = require("dropzone");
1365
1398
  }})();
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.3.1
4
+ version: 0.3.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-05-23 00:00:00.000000000 Z
11
+ date: 2013-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails