dropzonejs-rails 0.2.0 → 0.2.1

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
- NDRiZTA1MTFjM2EwNzliZjliZTQzODVkNTMzYWQwOGNkNjc4YzYwYQ==
4
+ NzkxOTExMWY3OTFlYWY2NmNmODg0ZDYyYTY0NWM0Zjc4YTQ5YWQ1NQ==
5
5
  data.tar.gz: !binary |-
6
- OWU3MmI2ZDVlOGViYWMxYzE4NzE3YjM0ZDY5MTkwMjY5NmRiODEyMQ==
6
+ YjhjN2Q5MTdhOGNhMjNkN2EzYjkzMmQxZmRiOGQzNzI4ODM3MTM2MQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZGIzN2U3YmVjN2M5N2ViNWZkMzczN2Q2NDhmMmQzODZiODVkOWM5MmE1NWE4
10
- Mjc1M2E5MWJlZWM0MDhkMjAxYWIzZmJiZjBlODc2MzhhMWExNjc0YmViNzY2
11
- NWNhMjQxNDhjZWIyNGVjNGI4MmVmZGNkOTY4OTg4OTY2ODU1NmU=
9
+ YTQ4YTEyODM2YjNlYTE0ZmJjYTUzMzAxNjdjMjU2NzZlODYxYzE3MGEzYjIz
10
+ YTViZDM5NmVjMzY2MGUxNDNhOGZhNGE0MWY5M2ZjZjBlNjE3NDM3NjEyYjIw
11
+ MDQ1NjNjMDY4MWYwOWUxNTJmYjc1ZTg3ZDNhYjQ5M2VkNDJhMTI=
12
12
  data.tar.gz: !binary |-
13
- M2VhYTlhYWExM2ViODc4OGUyNjJjY2JmN2Q2ZDk2MTQyODA1MTk2NmEyODgx
14
- NjAyYWRmNWE3ZjY0NTMyZjI4NWM5ZGE5YmMzYjc2NTRmMmVlNTJlNjdmZjE5
15
- NTE5NzE2NjdiZWZlNzIyZDU0YmQzOGMxNTlhYTg5ZGFmZmY1MmQ=
13
+ OTY3MzI1YjAxZWZmMzRmY2MwNmNhZmYxY2JiOWNhMjU3NzViZTdlYmExOWU1
14
+ ODUxNjEyYjEwNzYwZWY1YmNhMzY1OGY3ZTEwYzExY2JjYzgwNWU5YjhjMzQ4
15
+ MWQ4OGU0NDcxNDRiYTY4OGQwZjA4ODI4M2RlN2Q3YjMwODQ4YzY=
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 v2.0.15**.
7
+ The latest version of this gem bundles **Dropzone v2.0.16**.
8
8
 
9
9
  ## Installation and usage
10
10
 
@@ -1,4 +1,4 @@
1
1
  module DropzonejsRails
2
- VERSION = '0.2.0'
3
- DROPZONE_VERSION = '2.0.15'
2
+ VERSION = '0.2.1'
3
+ DROPZONE_VERSION = '2.0.16'
4
4
  end
@@ -432,13 +432,19 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
432
432
  thumbnailHeight: 100,
433
433
  params: {},
434
434
  clickable: true,
435
+ acceptedMimeTypes: null,
435
436
  acceptParameter: null,
436
437
  enqueueForUpload: true,
437
438
  previewsContainer: null,
438
439
  dictDefaultMessage: "Drop files here to upload",
439
440
  dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.",
440
441
  dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.",
442
+ dictInvalidFileType: "You can't upload files of this type.",
443
+ dictResponseError: "Server responded with {{statusCode}} code.",
441
444
  accept: function(file, done) {
445
+ if (!Dropzone.isValidMimeType(file.type, this.options.acceptedMimeTypes)) {
446
+ return done(this.options.dictInvalidFileType);
447
+ }
442
448
  return done();
443
449
  },
444
450
  init: function() {
@@ -502,32 +508,33 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
502
508
  return this.element.classList.remove("started");
503
509
  },
504
510
  addedfile: function(file) {
505
- file.previewTemplate = Dropzone.createElement(this.options.previewTemplate);
506
- this.previewsContainer.appendChild(file.previewTemplate);
507
- file.previewTemplate.querySelector(".filename span").textContent = file.name;
508
- return file.previewTemplate.querySelector(".details").appendChild(Dropzone.createElement("<div class=\"size\">" + (this.filesize(file.size)) + "</div>"));
511
+ file.previewElement = Dropzone.createElement(this.options.previewTemplate);
512
+ file.previewTemplate = file.previewElement;
513
+ this.previewsContainer.appendChild(file.previewElement);
514
+ file.previewElement.querySelector(".filename span").textContent = file.name;
515
+ return file.previewElement.querySelector(".details").appendChild(Dropzone.createElement("<div class=\"size\">" + (this.filesize(file.size)) + "</div>"));
509
516
  },
510
517
  removedfile: function(file) {
511
- return file.previewTemplate.parentNode.removeChild(file.previewTemplate);
518
+ return file.previewElement.parentNode.removeChild(file.previewElement);
512
519
  },
513
520
  thumbnail: function(file, dataUrl) {
514
- file.previewTemplate.classList.remove("file-preview");
515
- file.previewTemplate.classList.add("image-preview");
516
- return file.previewTemplate.querySelector(".details").appendChild(Dropzone.createElement("<img alt=\"" + file.name + "\" src=\"" + dataUrl + "\"/>"));
521
+ file.previewElement.classList.remove("file-preview");
522
+ file.previewElement.classList.add("image-preview");
523
+ return file.previewElement.querySelector(".details").appendChild(Dropzone.createElement("<img alt=\"" + file.name + "\" src=\"" + dataUrl + "\"/>"));
517
524
  },
518
525
  error: function(file, message) {
519
- file.previewTemplate.classList.add("error");
520
- return file.previewTemplate.querySelector(".error-message span").textContent = message;
526
+ file.previewElement.classList.add("error");
527
+ return file.previewElement.querySelector(".error-message span").textContent = message;
521
528
  },
522
529
  processingfile: function(file) {
523
- return file.previewTemplate.classList.add("processing");
530
+ return file.previewElement.classList.add("processing");
524
531
  },
525
532
  uploadprogress: function(file, progress, bytesSent) {
526
- return file.previewTemplate.querySelector(".progress .upload").style.width = "" + progress + "%";
533
+ return file.previewElement.querySelector(".progress .upload").style.width = "" + progress + "%";
527
534
  },
528
535
  sending: noop,
529
536
  success: function(file) {
530
- return file.previewTemplate.classList.add("success");
537
+ return file.previewElement.classList.add("success");
531
538
  },
532
539
  complete: noop,
533
540
  previewTemplate: "<div class=\"preview file-preview\">\n <div class=\"details\">\n <div class=\"filename\"><span></span></div>\n </div>\n <div class=\"progress\"><span class=\"upload\"></span></div>\n <div class=\"success-mark\"><span>✔</span></div>\n <div class=\"error-mark\"><span>✘</span></div>\n <div class=\"error-message\"><span></span></div>\n</div>"
@@ -571,6 +578,9 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
571
578
  if (!this.options.url) {
572
579
  throw new Error("No URL provided.");
573
580
  }
581
+ if (this.options.acceptParameter && this.options.acceptedMimeTypes) {
582
+ throw new Error("You can't provide both 'acceptParameter' and 'acceptedMimeTypes'. 'acceptParameter' is deprecated.");
583
+ }
574
584
  this.options.method = this.options.method.toUpperCase();
575
585
  if (this.options.forceFallback || !Dropzone.isBrowserSupported()) {
576
586
  return this.options.fallback.call(this);
@@ -623,6 +633,9 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
623
633
  _this.hiddenFileInput = document.createElement("input");
624
634
  _this.hiddenFileInput.setAttribute("type", "file");
625
635
  _this.hiddenFileInput.setAttribute("multiple", "multiple");
636
+ if (_this.options.acceptedMimeTypes != null) {
637
+ _this.hiddenFileInput.setAttribute("accept", _this.options.acceptedMimeTypes);
638
+ }
626
639
  if (_this.options.acceptParameter != null) {
627
640
  _this.hiddenFileInput.setAttribute("accept", _this.options.acceptParameter);
628
641
  }
@@ -988,7 +1001,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
988
1001
  xhr = new XMLHttpRequest();
989
1002
  xhr.open(this.options.method, this.options.url, true);
990
1003
  handleError = function() {
991
- return _this.errorProcessing(file, xhr.responseText || ("Server responded with " + xhr.status + " code."));
1004
+ return _this.errorProcessing(file, xhr.responseText || _this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr);
992
1005
  };
993
1006
  xhr.onload = function(e) {
994
1007
  var response, _ref;
@@ -1048,11 +1061,11 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
1048
1061
  return this.emit("complete", file);
1049
1062
  };
1050
1063
 
1051
- Dropzone.prototype.errorProcessing = function(file, message) {
1064
+ Dropzone.prototype.errorProcessing = function(file, message, xhr) {
1052
1065
  this.filesProcessing = without(this.filesProcessing, file);
1053
1066
  file.processing = false;
1054
1067
  this.processQueue();
1055
- this.emit("error", file, message);
1068
+ this.emit("error", file, message, xhr);
1056
1069
  return this.emit("complete", file);
1057
1070
  };
1058
1071
 
@@ -1060,7 +1073,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
1060
1073
 
1061
1074
  })(Em);
1062
1075
 
1063
- Dropzone.version = "2.0.15";
1076
+ Dropzone.version = "2.0.16";
1064
1077
 
1065
1078
  Dropzone.options = {};
1066
1079
 
@@ -1188,6 +1201,30 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
1188
1201
  return false;
1189
1202
  };
1190
1203
 
1204
+ Dropzone.isValidMimeType = function(mimeType, acceptedMimeTypes) {
1205
+ var baseMimeType, validMimeType, _i, _len;
1206
+
1207
+ if (!acceptedMimeTypes) {
1208
+ return true;
1209
+ }
1210
+ acceptedMimeTypes = acceptedMimeTypes.split(",");
1211
+ baseMimeType = mimeType.replace(/\/.*$/, "");
1212
+ for (_i = 0, _len = acceptedMimeTypes.length; _i < _len; _i++) {
1213
+ validMimeType = acceptedMimeTypes[_i];
1214
+ validMimeType = validMimeType.trim();
1215
+ if (/\/\*$/.test(validMimeType)) {
1216
+ if (baseMimeType === validMimeType.replace(/\/.*$/, "")) {
1217
+ return true;
1218
+ }
1219
+ } else {
1220
+ if (mimeType === validMimeType) {
1221
+ return true;
1222
+ }
1223
+ }
1224
+ }
1225
+ return false;
1226
+ };
1227
+
1191
1228
  if (typeof jQuery !== "undefined" && jQuery !== null) {
1192
1229
  jQuery.fn.dropzone = function(options) {
1193
1230
  return this.each(function() {
@@ -171,7 +171,7 @@
171
171
  -o-transition: opacity 0.3s ease-in-out;
172
172
  -ms-transition: opacity 0.3s ease-in-out;
173
173
  transition: opacity 0.3s ease-in-out;
174
- background-image: image-url("dropzone/spritemap.png");
174
+ background-image: image-path("dropzone/spritemap.png");
175
175
  background-repeat: no-repeat;
176
176
  background-position: 0 0;
177
177
  position: absolute;
@@ -184,7 +184,7 @@
184
184
  }
185
185
  @media all and (-webkit-min-device-pixel-ratio: 1.5) {
186
186
  .dropzone .default.message {
187
- background-image: image-url("dropzone/spritemap@2x.png");
187
+ background-image: image-path("dropzone/spritemap@2x.png");
188
188
  -webkit-background-size: 428px 406px;
189
189
  -moz-background-size: 428px 406px;
190
190
  background-size: 428px 406px;
@@ -258,7 +258,7 @@
258
258
  -o-transition: opacity 0.4s ease-in-out;
259
259
  -ms-transition: opacity 0.4s ease-in-out;
260
260
  transition: opacity 0.4s ease-in-out;
261
- background-image: image-url("dropzone/spritemap.png");
261
+ background-image: image-path("dropzone/spritemap.png");
262
262
  background-repeat: no-repeat;
263
263
  }
264
264
  @media all and (-webkit-min-device-pixel-ratio: 1.5) {
@@ -266,7 +266,7 @@
266
266
  .dropzone-previews .preview .error-mark,
267
267
  .dropzone .preview .success-mark,
268
268
  .dropzone-previews .preview .success-mark {
269
- background-image: image-url("dropzone/spritemap@2x.png");
269
+ background-image: image-path("dropzone/spritemap@2x.png");
270
270
  -webkit-background-size: 428px 406px;
271
271
  -moz-background-size: 428px 406px;
272
272
  background-size: 428px 406px;
@@ -305,14 +305,14 @@
305
305
  left: 0;
306
306
  width: 0%;
307
307
  height: 100%;
308
- background-image: image-url("dropzone/spritemap.png");
308
+ background-image: image-path("dropzone/spritemap.png");
309
309
  background-repeat: repeat-x;
310
310
  background-position: 0px -400px;
311
311
  }
312
312
  @media all and (-webkit-min-device-pixel-ratio: 1.5) {
313
313
  .dropzone .preview .progress .upload,
314
314
  .dropzone-previews .preview .progress .upload {
315
- background-image: image-url("dropzone/spritemap@2x.png");
315
+ background-image: image-path("dropzone/spritemap@2x.png");
316
316
  -webkit-background-size: 428px 406px;
317
317
  -moz-background-size: 428px 406px;
318
318
  background-size: 428px 406px;
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.2.0
4
+ version: 0.2.1
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-07 00:00:00.000000000 Z
11
+ date: 2013-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails