dropzonejs-rails 0.0.2 → 0.1.0

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
- NDBlNjVhY2IzNjcxMTc4MzgyYzEzZGQzYWE5ZjZjMDFhZjU3M2M5OA==
4
+ ZjYwZWZlZmU2MjdjOGNmYWM4MzFjMGVhMDBkMzUwYWU2YTAxYmUzZQ==
5
5
  data.tar.gz: !binary |-
6
- MWEwOGVlNzYwMzdjNjhlNTM1MzI0ZDMxNWViZDFkNTExMzJlM2Q4Mw==
6
+ ZWY2Yjk4NjE1NDJlMzlkNjkxNzc3NzU1ZjU4YzFhMzMzMDUzMDFmZg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YjgwMWM5YzNjZjY2MTcwNTUzY2M1ZTBjNjhhMDU5ZThjZTZmMDhmYzEyNDkz
10
- NWQ1ZmQ0ZDQxYjhiNjUyYzE5ZTNmNWRlMjI1OGYwNGIxMGIxODg2NTE3YWI3
11
- NWUzYjg4YTc5YTRlNGRhMzgyNWUyYmZkNjQ2M2NkMTY5NDk4MWI=
9
+ YjE3OTRiNWFkZDg0MDM0ODc0NDJjY2ViYmMyZDRmNmVhMTM0YjMwMWQ3MWM4
10
+ YmFmYzZkMzBmZWE3MDI3YzAyMTk0ZTk3MTFjN2VlNzA1ODhlNWIxODFmNDdm
11
+ NGQxNmEwOTZiMWUxM2EyYmU3ODFkMjRhZTAwMDc1Zjg2MjhiMjI=
12
12
  data.tar.gz: !binary |-
13
- YjgxYzIzZDM0ZTg1YzIzNmZhODQ0ZDdlMWYyZDFlODY4NTU4NWE4NzdjMTY3
14
- NjZlZTViNzVmYmJhNWYxOGYyZWRkNDYyM2MwODUwYzk2ZjEwNjBiYzZiOTdl
15
- MzExYjViY2UwMDI4NGExNDRiNzllZWEyNWM1ZWQ0ZDIwZmFmNTM=
13
+ YzYwNDY4OThhNGU1YjQ0YTJjZTQ5MmZhM2E3NWNhNDVjNGIzOWZlMDk1ZGNl
14
+ YjU0YTI2Yjc0MDdmZTE4MWRkNWVhNmE2YTI1Y2U5NzY0NWJkMjBjZTBhNzMx
15
+ ZjMxM2Y0ZjQyZjZmNDFlNGE2Zjg2ZGU0ZWZkMTA5M2M1N2IxMmI=
@@ -1,4 +1,4 @@
1
1
  module DropzonejsRails
2
- VERSION = '0.0.2'
3
- DROPZONE_VERSION = '1.3.12'
2
+ VERSION = '0.1.0'
3
+ DROPZONE_VERSION = '2.0.0'
4
4
  end
@@ -396,20 +396,20 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
396
396
 
397
397
 
398
398
  (function() {
399
- var Dropzone, Em, camelize, o, without,
399
+ var Dropzone, Em, camelize, contentLoaded, createElement, noop, without,
400
400
  __hasProp = {}.hasOwnProperty,
401
401
  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
402
402
  __slice = [].slice;
403
403
 
404
- o = typeof jQuery !== "undefined" && jQuery !== null ? jQuery : require("jquery");
405
-
406
404
  Em = typeof Emitter !== "undefined" && Emitter !== null ? Emitter : require("emitter");
407
405
 
406
+ noop = function() {};
407
+
408
408
  Dropzone = (function(_super) {
409
409
 
410
410
  __extends(Dropzone, _super);
411
411
 
412
- Dropzone.prototype.version = "1.3.12";
412
+ Dropzone.prototype.version = "2.0.0";
413
413
 
414
414
  /*
415
415
  This is a list of all available events you can register on a dropzone object.
@@ -422,8 +422,6 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
422
422
 
423
423
  Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "selectedfiles", "addedfile", "removedfile", "thumbnail", "error", "processingfile", "uploadprogress", "sending", "success", "complete", "reset"];
424
424
 
425
- Dropzone.prototype.blacklistedBrowsers = [/opera.*Macintosh.*version\/12/i];
426
-
427
425
  Dropzone.prototype.defaultOptions = {
428
426
  url: null,
429
427
  parallelUploads: 2,
@@ -437,18 +435,36 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
437
435
  clickable: true,
438
436
  enqueueForUpload: true,
439
437
  previewsContainer: null,
438
+ dictDefaultMessage: "Drop files here to upload",
439
+ dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.",
440
+ dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.",
440
441
  accept: function(file, done) {
441
442
  return done();
442
443
  },
443
444
  init: function() {
444
- return o.noop;
445
+ return noop;
445
446
  },
446
447
  fallback: function() {
447
- this.element.addClass("browser-not-supported");
448
- this.element.find(".message").removeClass("default");
449
- this.element.find(".message span").html("Your browser does not support drag'n'drop file uploads.");
450
- this.element.append("Please use the fallback form below to upload your files like in the olden days.</p>");
451
- return this.element.append(this.getFallbackForm());
448
+ var child, messageElement, span, _i, _len, _ref;
449
+ this.element.className = "" + this.element.className + " browser-not-supported";
450
+ _ref = this.element.getElementsByTagName("div");
451
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
452
+ child = _ref[_i];
453
+ if (/message/.test(child.className)) {
454
+ messageElement = child;
455
+ child.className = "message";
456
+ continue;
457
+ }
458
+ }
459
+ if (!messageElement) {
460
+ messageElement = createElement("<div class=\"message\"><span></span></div>");
461
+ this.element.appendChild(messageElement);
462
+ }
463
+ span = messageElement.getElementsByTagName("span")[0];
464
+ if (span) {
465
+ span.textContent = this.options.dictFallbackMessage;
466
+ }
467
+ return this.element.appendChild(this.getFallbackForm());
452
468
  },
453
469
  /*
454
470
  Those functions register themselves to the events on init and handle all
@@ -460,76 +476,76 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
460
476
  */
461
477
 
462
478
  drop: function(e) {
463
- return this.element.removeClass("drag-hover");
479
+ return this.element.classList.remove("drag-hover");
464
480
  },
465
- dragstart: o.noop,
481
+ dragstart: noop,
466
482
  dragend: function(e) {
467
- return this.element.removeClass("drag-hover");
483
+ return this.element.classList.remove("drag-hover");
468
484
  },
469
485
  dragenter: function(e) {
470
- return this.element.addClass("drag-hover");
486
+ return this.element.classList.add("drag-hover");
471
487
  },
472
488
  dragover: function(e) {
473
- return this.element.addClass("drag-hover");
489
+ return this.element.classList.add("drag-hover");
474
490
  },
475
491
  dragleave: function(e) {
476
- return this.element.removeClass("drag-hover");
492
+ return this.element.classList.remove("drag-hover");
477
493
  },
478
494
  selectedfiles: function(files) {
479
- if (this.element.is(this.previewsContainer)) {
480
- return this.element.addClass("started");
495
+ if (this.element === this.previewsContainer) {
496
+ return this.element.classList.add("started");
481
497
  }
482
498
  },
483
499
  reset: function() {
484
- return this.element.removeClass("started");
500
+ return this.element.classList.remove("started");
485
501
  },
486
502
  addedfile: function(file) {
487
- file.previewTemplate = o(this.options.previewTemplate);
488
- this.previewsContainer.append(file.previewTemplate);
489
- file.previewTemplate.find(".filename span").text(file.name);
490
- return file.previewTemplate.find(".details").append(o("<div class=\"size\">" + (this.filesize(file.size)) + "</div>"));
503
+ file.previewTemplate = createElement(this.options.previewTemplate);
504
+ this.previewsContainer.appendChild(file.previewTemplate);
505
+ file.previewTemplate.querySelector(".filename span").textContent = file.name;
506
+ return file.previewTemplate.querySelector(".details").appendChild(createElement("<div class=\"size\">" + (this.filesize(file.size)) + "</div>"));
491
507
  },
492
508
  removedfile: function(file) {
493
- return file.previewTemplate.remove();
509
+ return file.previewTemplate.parentNode.removeChild(file.previewTemplate);
494
510
  },
495
511
  thumbnail: function(file, dataUrl) {
496
- file.previewTemplate.removeClass("file-preview").addClass("image-preview");
497
- return file.previewTemplate.find(".details").append(o("<img alt=\"" + file.name + "\" src=\"" + dataUrl + "\"/>"));
512
+ file.previewTemplate.classList.remove("file-preview");
513
+ file.previewTemplate.classList.add("image-preview");
514
+ return file.previewTemplate.querySelector(".details").appendChild(createElement("<img alt=\"" + file.name + "\" src=\"" + dataUrl + "\"/>"));
498
515
  },
499
516
  error: function(file, message) {
500
- file.previewTemplate.addClass("error");
501
- return file.previewTemplate.find(".error-message span").text(message);
517
+ file.previewTemplate.classList.add("error");
518
+ return file.previewTemplate.querySelector(".error-message span").textContent = message;
502
519
  },
503
520
  processingfile: function(file) {
504
- return file.previewTemplate.addClass("processing");
521
+ return file.previewTemplate.classList.add("processing");
505
522
  },
506
523
  uploadprogress: function(file, progress) {
507
- return file.previewTemplate.find(".progress .upload").css({
508
- width: "" + progress + "%"
509
- });
524
+ return file.previewTemplate.querySelector(".progress .upload").style.width = "" + progress + "%";
510
525
  },
511
- sending: o.noop,
526
+ sending: noop,
512
527
  success: function(file) {
513
- return file.previewTemplate.addClass("success");
528
+ return file.previewTemplate.classList.add("success");
514
529
  },
515
- complete: o.noop,
530
+ complete: noop,
516
531
  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>"
517
532
  };
518
533
 
519
534
  function Dropzone(element, options) {
520
- var elementId, elementOptions, extend, _ref;
535
+ var elementId, elementOptions, extend, fallback, _ref;
536
+ this.element = element;
521
537
  this.defaultOptions.previewTemplate = this.defaultOptions.previewTemplate.replace(/\n*/g, "");
522
- this.element = o(element);
523
- if (this.element.length !== 1) {
524
- throw new Error("You can only instantiate dropzone on a single element.");
538
+ if (typeof this.element === "string") {
539
+ this.element = document.querySelector(this.element);
540
+ }
541
+ if (!(this.element && (this.element.nodeType != null))) {
542
+ throw new Error("Invalid dropzone element.");
525
543
  }
526
- if (this.element.data("dropzone")) {
544
+ if (Dropzone.forElement(this.element)) {
527
545
  throw new Error("Dropzone already attached.");
528
546
  }
529
- this.element.data("dropzone", this);
530
- elementId = this.element.attr("id");
547
+ elementId = this.element.id;
531
548
  elementOptions = (_ref = (elementId ? Dropzone.options[camelize(elementId)] : void 0)) != null ? _ref : {};
532
- this.elementTagName = this.element.get(0).tagName;
533
549
  extend = function() {
534
550
  var key, object, objects, target, val, _i, _len;
535
551
  target = arguments[0], objects = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
@@ -544,141 +560,175 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
544
560
  };
545
561
  this.options = extend({}, this.defaultOptions, elementOptions, options != null ? options : {});
546
562
  if (this.options.url == null) {
547
- this.options.url = this.element.attr("action");
563
+ this.options.url = this.element.action;
548
564
  }
549
565
  if (!this.options.url) {
550
566
  throw new Error("No URL provided.");
551
567
  }
552
- this.previewsContainer = this.options.previewsContainer ? o(this.options.previewsContainer) : this.element;
568
+ if (!Dropzone.isBrowserSupported()) {
569
+ return this.options.fallback.call(this);
570
+ }
571
+ if (fallback = this.getExistingFallback()) {
572
+ fallback.remove();
573
+ }
574
+ this.previewsContainer = this.options.previewsContainer ? createElement(this.options.previewsContainer) : this.element;
553
575
  this.init();
554
576
  }
555
577
 
556
578
  Dropzone.prototype.init = function() {
557
- var capableBrowser, regex, _i, _len, _ref, _ref1;
558
- if (this.elementTagName === "form" && this.element.attr("enctype") !== "multipart/form-data") {
559
- this.element.attr("enctype", "multipart/form-data");
560
- }
561
- if (this.element.hasClass("dropzone") && this.element.find(".message").length === 0) {
562
- this.element.append(o("<div class=\"default message\"><span>Drop files here to upload</span></div>"));
563
- }
564
- capableBrowser = true;
565
- if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData) {
566
- _ref = this.blacklistedBrowsers;
567
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
568
- regex = _ref[_i];
569
- if (regex.test(navigator.userAgent)) {
570
- capableBrowser = false;
571
- continue;
572
- }
573
- }
574
- } else {
575
- capableBrowser = false;
579
+ var eventName, noPropagation, _i, _len, _ref, _ref1,
580
+ _this = this;
581
+ if (this.element.tagName === "form") {
582
+ this.element.setAttribute("enctype", "multipart/form-data");
576
583
  }
577
- if (!capableBrowser) {
578
- return this.options.fallback.call(this);
584
+ if (this.element.classList.contains("dropzone") && !this.element.querySelector(".message")) {
585
+ this.element.appendChild(createElement("<div class=\"default message\"><span>" + this.options.dictDefaultMessage + "</span></div>"));
579
586
  }
580
587
  if (this.options.clickable) {
581
- this.hiddenFileInput = o("<input type=\"file\" multiple />");
588
+ this.hiddenFileInput = document.createElement("input");
589
+ this.hiddenFileInput.setAttribute("type", "file");
590
+ this.hiddenFileInput.setAttribute("multiple", "multiple");
591
+ this.hiddenFileInput.style.display = "none";
592
+ document.body.appendChild(this.hiddenFileInput);
593
+ this.hiddenFileInput.addEventListener("change", function() {
594
+ var files;
595
+ files = _this.hiddenFileInput.files;
596
+ if (files.length) {
597
+ _this.emit("selectedfiles", files);
598
+ return _this.handleFiles(files);
599
+ }
600
+ });
582
601
  }
583
602
  this.files = [];
584
603
  this.filesQueue = [];
585
604
  this.filesProcessing = [];
586
- this.URL = (_ref1 = window.URL) != null ? _ref1 : window.webkitURL;
587
- this.setupEventListeners();
605
+ this.URL = (_ref = window.URL) != null ? _ref : window.webkitURL;
606
+ _ref1 = this.events;
607
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
608
+ eventName = _ref1[_i];
609
+ this.on(eventName, this.options[eventName]);
610
+ }
611
+ noPropagation = function(e) {
612
+ e.stopPropagation();
613
+ if (e.preventDefault) {
614
+ return e.preventDefault();
615
+ } else {
616
+ return e.returnValue = false;
617
+ }
618
+ };
619
+ this.listeners = {
620
+ "dragstart": function(e) {
621
+ return _this.emit("dragstart", e);
622
+ },
623
+ "dragenter": function(e) {
624
+ noPropagation(e);
625
+ return _this.emit("dragenter", e);
626
+ },
627
+ "dragover": function(e) {
628
+ noPropagation(e);
629
+ return _this.emit("dragover", e);
630
+ },
631
+ "dragleave": function(e) {
632
+ return _this.emit("dragleave", e);
633
+ },
634
+ "drop": function(e) {
635
+ noPropagation(e);
636
+ _this.drop(e);
637
+ return _this.emit("drop", e);
638
+ },
639
+ "dragend": function(e) {
640
+ return _this.emit("dragend", e);
641
+ },
642
+ "click": function(evt) {
643
+ if (!_this.options.clickable) {
644
+ return;
645
+ }
646
+ if (evt.target === _this.element || evt.target === _this.element.querySelector(".message")) {
647
+ return _this.hiddenFileInput.click();
648
+ }
649
+ }
650
+ };
651
+ this.enable();
588
652
  return this.options.init.call(this);
589
653
  };
590
654
 
591
655
  Dropzone.prototype.getFallbackForm = function() {
592
- var fields;
593
- fields = o("<div class=\"fallback-elements\"><input type=\"file\" name=\"" + this.options.paramName + "\" multiple=\"multiple\" /><button type=\"submit\">Upload!</button></div>");
594
- if (this.elementTagName !== "FORM") {
595
- fields = o("<form action=\"" + this.options.url + "\" enctype=\"multipart/form-data\" method=\"post\"></form>").append(fields);
656
+ var existingFallback, fields, fieldsString, form;
657
+ if (existingFallback = this.getExistingFallback()) {
658
+ return existingFallback;
659
+ }
660
+ fieldsString = "<div class=\"fallback\">";
661
+ if (this.options.dictFallbackText) {
662
+ fieldsString += "<p>" + this.options.dictFallbackText + "</p>";
663
+ }
664
+ fieldsString += "<input type=\"file\" name=\"" + this.options.paramName + "\" multiple=\"multiple\" /><button type=\"submit\">Upload!</button></div>";
665
+ fields = createElement(fieldsString);
666
+ if (this.element.tagName !== "FORM") {
667
+ form = createElement("<form action=\"" + this.options.url + "\" enctype=\"multipart/form-data\" method=\"post\"></form>");
668
+ form.appendChild(fields);
596
669
  } else {
597
- if (!this.element.attr("enctype")) {
598
- this.element.attr("enctype", "multipart/form-data");
599
- }
600
- if (!this.element.attr("method")) {
601
- this.element.attr("method", "post");
602
- }
670
+ this.element.setAttribute("enctype", "multipart/form-data");
671
+ this.element.setAttribute("method", "post");
603
672
  }
604
- return fields;
673
+ return form != null ? form : fields;
605
674
  };
606
675
 
607
- Dropzone.prototype.setupEventListeners = function(initial) {
608
- var eventName, noPropagation, _i, _len, _ref,
609
- _this = this;
610
- if (initial == null) {
611
- initial = true;
612
- }
613
- if (initial) {
614
- _ref = this.events;
615
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
616
- eventName = _ref[_i];
617
- this.on(eventName, this.options[eventName]);
676
+ Dropzone.prototype.getExistingFallback = function() {
677
+ var fallback, getFallback, tagName, _i, _len, _ref;
678
+ getFallback = function(elements) {
679
+ var el, _i, _len;
680
+ for (_i = 0, _len = elements.length; _i < _len; _i++) {
681
+ el = elements[_i];
682
+ if (/fallback/.test(el.className)) {
683
+ return el;
684
+ }
618
685
  }
619
- }
620
- noPropagation = function(e) {
621
- e.stopPropagation();
622
- return e.preventDefault();
623
686
  };
624
- this.element.on("dragstart.dropzone", function(e) {
625
- return _this.emit("dragstart", e);
626
- });
627
- this.element.on("dragenter.dropzone", function(e) {
628
- noPropagation(e);
629
- return _this.emit("dragenter", e);
630
- });
631
- this.element.on("dragover.dropzone", function(e) {
632
- noPropagation(e);
633
- return _this.emit("dragover", e);
634
- });
635
- this.element.on("dragleave.dropzone", function(e) {
636
- return _this.emit("dragleave", e);
637
- });
638
- this.element.on("drop.dropzone", function(e) {
639
- noPropagation(e);
640
- _this.drop(e);
641
- return _this.emit("drop", e);
642
- });
643
- this.element.on("dragend.dropzone", function(e) {
644
- return _this.emit("dragend", e);
645
- });
646
- if (this.options.clickable) {
647
- this.element.addClass("clickable");
648
- this.element.on("click.dropzone", function(evt) {
649
- var target;
650
- target = o(evt.target);
651
- if (target.is(_this.element) || target.is(_this.element.find(".message"))) {
652
- return _this.hiddenFileInput.click();
653
- }
654
- });
655
- return this.hiddenFileInput.on("change", function() {
656
- var files;
657
- files = _this.hiddenFileInput.get(0).files;
658
- _this.emit("selectedfiles", files);
659
- if (files.length) {
660
- return _this.handleFiles(files);
661
- }
662
- });
687
+ _ref = ["div", "form"];
688
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
689
+ tagName = _ref[_i];
690
+ if (fallback = getFallback(this.element.getElementsByTagName("div"))) {
691
+ return fallback;
692
+ }
693
+ }
694
+ };
695
+
696
+ Dropzone.prototype.setupEventListeners = function() {
697
+ var event, listener, _ref, _results;
698
+ _ref = this.listeners;
699
+ _results = [];
700
+ for (event in _ref) {
701
+ listener = _ref[event];
702
+ _results.push(this.element.addEventListener(event, listener, false));
663
703
  }
704
+ return _results;
664
705
  };
665
706
 
666
707
  Dropzone.prototype.removeEventListeners = function() {
667
- this.element.off(".dropzone");
668
- if (this.options.clickable) {
669
- this.element.removeClass("clickable");
670
- return this.hiddenFileInput.off();
708
+ var event, listener, _ref, _results;
709
+ _ref = this.listeners;
710
+ _results = [];
711
+ for (event in _ref) {
712
+ listener = _ref[event];
713
+ _results.push(this.element.removeEventListener(event, listener, false));
671
714
  }
715
+ return _results;
672
716
  };
673
717
 
674
718
  Dropzone.prototype.disable = function() {
719
+ if (this.options.clickable) {
720
+ this.element.classList.remove("clickable");
721
+ }
675
722
  this.removeEventListeners();
676
723
  this.filesProcessing = [];
677
724
  return this.filesQueue = [];
678
725
  };
679
726
 
680
727
  Dropzone.prototype.enable = function() {
681
- return this.setupEventListeners(false);
728
+ if (this.options.clickable) {
729
+ this.element.classList.add("clickable");
730
+ }
731
+ return this.setupEventListeners();
682
732
  };
683
733
 
684
734
  Dropzone.prototype.filesize = function(size) {
@@ -704,10 +754,10 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
704
754
 
705
755
  Dropzone.prototype.drop = function(e) {
706
756
  var files;
707
- if (!e.originalEvent.dataTransfer) {
757
+ if (!e.dataTransfer) {
708
758
  return;
709
759
  }
710
- files = e.originalEvent.dataTransfer.files;
760
+ files = e.dataTransfer.files;
711
761
  this.emit("selectedfiles", files);
712
762
  if (files.length) {
713
763
  return this.handleFiles(files);
@@ -833,7 +883,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
833
883
  };
834
884
 
835
885
  Dropzone.prototype.uploadFile = function(file) {
836
- var formData, handleError, input, inputElement, inputName, key, progressObj, value, xhr, _i, _len, _ref, _ref1, _ref2,
886
+ var formData, handleError, input, inputName, inputType, key, progressObj, value, xhr, _i, _len, _ref, _ref1, _ref2,
837
887
  _this = this;
838
888
  xhr = new XMLHttpRequest();
839
889
  xhr.open("POST", this.options.url, true);
@@ -872,14 +922,14 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
872
922
  formData.append(key, value);
873
923
  }
874
924
  }
875
- if (this.elementTagName = "FORM") {
876
- _ref2 = this.element.find("input, textarea, select, button");
925
+ if (this.element.tagName = "FORM") {
926
+ _ref2 = this.element.querySelectorAll("input, textarea, select, button");
877
927
  for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
878
- inputElement = _ref2[_i];
879
- input = o(inputElement);
880
- inputName = input.attr("name");
881
- if (!input.attr("type") || input.attr("type").toLowerCase() !== "checkbox" || inputElement.checked) {
882
- formData.append(input.attr("name"), input.val());
928
+ input = _ref2[_i];
929
+ inputName = input.getAttribute("name");
930
+ inputType = input.getAttribute("type");
931
+ if (!inputType || inputType.toLowerCase() !== "checkbox" || input.checked) {
932
+ formData.append(inputName, input.value);
883
933
  }
884
934
  }
885
935
  }
@@ -911,6 +961,47 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
911
961
 
912
962
  Dropzone.options = {};
913
963
 
964
+ Dropzone.instances = [];
965
+
966
+ Dropzone.forElement = function(element) {
967
+ var instance, _i, _len, _ref;
968
+ if (typeof element === "string") {
969
+ element = document.querySelector(element);
970
+ }
971
+ _ref = Dropzone.instances;
972
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
973
+ instance = _ref[_i];
974
+ if (instance.element === element) {
975
+ return instance;
976
+ }
977
+ }
978
+ return null;
979
+ };
980
+
981
+ Dropzone.blacklistedBrowsers = [/opera.*Macintosh.*version\/12/i];
982
+
983
+ Dropzone.isBrowserSupported = function() {
984
+ var capableBrowser, regex, _i, _len, _ref;
985
+ capableBrowser = true;
986
+ if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData) {
987
+ if (!("classList" in document.createElement("a"))) {
988
+ capableBrowser = false;
989
+ } else {
990
+ _ref = Dropzone.blacklistedBrowsers;
991
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
992
+ regex = _ref[_i];
993
+ if (regex.test(navigator.userAgent)) {
994
+ capableBrowser = false;
995
+ continue;
996
+ }
997
+ }
998
+ }
999
+ } else {
1000
+ capableBrowser = false;
1001
+ }
1002
+ return capableBrowser;
1003
+ };
1004
+
914
1005
  without = function(list, rejectedItem) {
915
1006
  var item, _i, _len, _results;
916
1007
  _results = [];
@@ -929,15 +1020,20 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
929
1020
  });
930
1021
  };
931
1022
 
932
- o.fn.dropzone = function(options) {
933
- return this.each(function() {
934
- return new Dropzone(this, options);
935
- });
1023
+ createElement = function(string) {
1024
+ var div;
1025
+ div = document.createElement("div");
1026
+ div.innerHTML = string;
1027
+ return div.childNodes[0];
936
1028
  };
937
1029
 
938
- o(function() {
939
- return o(".dropzone").dropzone();
940
- });
1030
+ if (typeof jQuery !== "undefined" && jQuery !== null) {
1031
+ jQuery.fn.dropzone = function(options) {
1032
+ return this.each(function() {
1033
+ return new Dropzone(this, options);
1034
+ });
1035
+ };
1036
+ }
941
1037
 
942
1038
  if (typeof module !== "undefined" && module !== null) {
943
1039
  module.exports = Dropzone;
@@ -945,6 +1041,78 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
945
1041
  window.Dropzone = Dropzone;
946
1042
  }
947
1043
 
1044
+ contentLoaded = function(win, fn) {
1045
+ var add, doc, done, init, poll, pre, rem, root, top;
1046
+ done = false;
1047
+ top = true;
1048
+ doc = win.document;
1049
+ root = doc.documentElement;
1050
+ add = (doc.addEventListener ? "addEventListener" : "attachEvent");
1051
+ rem = (doc.addEventListener ? "removeEventListener" : "detachEvent");
1052
+ pre = (doc.addEventListener ? "" : "on");
1053
+ init = function(e) {
1054
+ if (e.type === "readystatechange" && doc.readyState !== "complete") {
1055
+ return;
1056
+ }
1057
+ (e.type === "load" ? win : doc)[rem](pre + e.type, init, false);
1058
+ if (!done && (done = true)) {
1059
+ return fn.call(win, e.type || e);
1060
+ }
1061
+ };
1062
+ poll = function() {
1063
+ try {
1064
+ root.doScroll("left");
1065
+ } catch (e) {
1066
+ setTimeout(poll, 50);
1067
+ return;
1068
+ }
1069
+ return init("poll");
1070
+ };
1071
+ if (doc.readyState !== "complete") {
1072
+ if (doc.createEventObject && root.doScroll) {
1073
+ try {
1074
+ top = !win.frameElement;
1075
+ } catch (_error) {}
1076
+ if (top) {
1077
+ poll();
1078
+ }
1079
+ }
1080
+ doc[add](pre + "DOMContentLoaded", init, false);
1081
+ doc[add](pre + "readystatechange", init, false);
1082
+ return win[add](pre + "load", init, false);
1083
+ }
1084
+ };
1085
+
1086
+ contentLoaded(window, function() {
1087
+ var checkElements, dropzone, dropzones, _i, _len, _results;
1088
+ if (false) {
1089
+ dropzones = document.querySelectorAll(".dropzone");
1090
+ } else {
1091
+ dropzones = [];
1092
+ checkElements = function(elements) {
1093
+ var el, _i, _len, _results;
1094
+ _results = [];
1095
+ for (_i = 0, _len = elements.length; _i < _len; _i++) {
1096
+ el = elements[_i];
1097
+ if (/dropzone/.test(el.className)) {
1098
+ _results.push(dropzones.push(el));
1099
+ } else {
1100
+ _results.push(void 0);
1101
+ }
1102
+ }
1103
+ return _results;
1104
+ };
1105
+ checkElements(document.getElementsByTagName("div"));
1106
+ checkElements(document.getElementsByTagName("form"));
1107
+ }
1108
+ _results = [];
1109
+ for (_i = 0, _len = dropzones.length; _i < _len; _i++) {
1110
+ dropzone = dropzones[_i];
1111
+ _results.push(new Dropzone(dropzone));
1112
+ }
1113
+ return _results;
1114
+ });
1115
+
948
1116
  }).call(this);
949
1117
 
950
1118
  });
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.0.2
4
+ version: 0.1.0
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-03-11 00:00:00.000000000 Z
11
+ date: 2013-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  version: '0'
60
60
  requirements: []
61
61
  rubyforge_project:
62
- rubygems_version: 2.0.1
62
+ rubygems_version: 2.0.3
63
63
  signing_key:
64
64
  specification_version: 4
65
65
  summary: Integrates Dropzone JS File upload into Rails Asset pipeline.