dropzonejs-rails 0.8.4 → 0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/app/assets/javascripts/dropzone.js +1284 -977
- data/app/assets/stylesheets/dropzone/dropzone.scss +8 -0
- data/lib/dropzonejs-rails/version.rb +2 -2
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c2936c7f66c9f73c144fb0af95f4eb8fa8a8fa73975690ed8fac10336491a41
|
4
|
+
data.tar.gz: 65a4a6fcf27a8daffdc803de95bec09074120bc5b0755359bf19bb8d73319aa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21940b4f6ffed39dca1f44b37506e11c37e17a4069ad0dfbb269f468ae52256652bee7a0fe79e75166de87e46f6bbb4a9640f0ec653b015c0739f9f7ea75ee1f
|
7
|
+
data.tar.gz: 0a6f4f7ed83ac02615fe0a9774f05ba0e0bf6178f0448902ede3b350c163eb626861f91c17345a3f56e4cbf7895699194666152b1ffc2884baa5ab43b7b6b993
|
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 v5.
|
7
|
+
The latest version of this gem bundles **Dropzone v5.7.1**.
|
8
8
|
|
9
9
|
### Dropzone 4.x
|
10
10
|
|
@@ -67,6 +67,8 @@ Go to [this secret place](https://github.com/ncuesta/dropzonejs-rails/issues).
|
|
67
67
|
|
68
68
|
## Changelog
|
69
69
|
|
70
|
+
* v0.8.5
|
71
|
+
* Updates Dropzone to 5.7.1 **(kudos to [@pnghai](https://github.com/pnghai).**
|
70
72
|
* v0.8.4
|
71
73
|
* Updates Dropzone to 5.5.0 **#52 by [@HuntBurdick](https://github.com/HuntBurdick).**
|
72
74
|
* v0.8.1
|
@@ -84,7 +86,7 @@ Go to [this secret place](https://github.com/ncuesta/dropzonejs-rails/issues).
|
|
84
86
|
|
85
87
|
## Licence (MIT)
|
86
88
|
|
87
|
-
(c) Copyright 2013-
|
89
|
+
(c) Copyright 2013-2020 José Nahuel Cuesta Luengo
|
88
90
|
|
89
91
|
Permission is hereby granted, free of charge, to any person obtaining
|
90
92
|
a copy of this software and associated documentation files (the
|
@@ -1,13 +1,23 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
4
4
|
|
5
|
-
function _possibleConstructorReturn(self, call) { if (
|
5
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
6
6
|
|
7
|
-
function
|
7
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
8
|
+
|
9
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
10
|
+
|
11
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
12
|
+
|
13
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
8
14
|
|
9
15
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
10
16
|
|
17
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
18
|
+
|
19
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
20
|
+
|
11
21
|
/*
|
12
22
|
*
|
13
23
|
* More info at [www.dropzonejs.com](http://www.dropzonejs.com)
|
@@ -33,27 +43,29 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
33
43
|
* THE SOFTWARE.
|
34
44
|
*
|
35
45
|
*/
|
36
|
-
|
37
46
|
// The Emitter class provides the ability to call `.on()` on Dropzone to listen
|
38
47
|
// to events.
|
39
48
|
// It is strongly based on component's emitter class, and I removed the
|
40
49
|
// functionality because of the dependency hell with different frameworks.
|
41
|
-
var Emitter =
|
50
|
+
var Emitter =
|
51
|
+
/*#__PURE__*/
|
52
|
+
function () {
|
42
53
|
function Emitter() {
|
43
54
|
_classCallCheck(this, Emitter);
|
44
55
|
}
|
45
56
|
|
46
57
|
_createClass(Emitter, [{
|
47
58
|
key: "on",
|
48
|
-
|
49
59
|
// Add an event listener for given event
|
50
60
|
value: function on(event, fn) {
|
51
|
-
this._callbacks = this._callbacks || {};
|
52
|
-
|
61
|
+
this._callbacks = this._callbacks || {}; // Create namespace for this event
|
62
|
+
|
53
63
|
if (!this._callbacks[event]) {
|
54
64
|
this._callbacks[event] = [];
|
55
65
|
}
|
66
|
+
|
56
67
|
this._callbacks[event].push(fn);
|
68
|
+
|
57
69
|
return this;
|
58
70
|
}
|
59
71
|
}, {
|
@@ -63,32 +75,37 @@ var Emitter = function () {
|
|
63
75
|
var callbacks = this._callbacks[event];
|
64
76
|
|
65
77
|
if (callbacks) {
|
66
|
-
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
78
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
67
79
|
args[_key - 1] = arguments[_key];
|
68
80
|
}
|
69
81
|
|
70
|
-
|
71
|
-
|
82
|
+
var _iteratorNormalCompletion = true;
|
83
|
+
var _didIteratorError = false;
|
84
|
+
var _iteratorError = undefined;
|
72
85
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
86
|
+
try {
|
87
|
+
for (var _iterator = callbacks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
88
|
+
var callback = _step.value;
|
89
|
+
callback.apply(this, args);
|
90
|
+
}
|
91
|
+
} catch (err) {
|
92
|
+
_didIteratorError = true;
|
93
|
+
_iteratorError = err;
|
94
|
+
} finally {
|
95
|
+
try {
|
96
|
+
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
|
97
|
+
_iterator["return"]();
|
98
|
+
}
|
99
|
+
} finally {
|
100
|
+
if (_didIteratorError) {
|
101
|
+
throw _iteratorError;
|
102
|
+
}
|
80
103
|
}
|
81
|
-
|
82
|
-
var callback = _ref;
|
83
|
-
|
84
|
-
callback.apply(this, args);
|
85
104
|
}
|
86
105
|
}
|
87
106
|
|
88
107
|
return this;
|
89
|
-
}
|
90
|
-
|
91
|
-
// Remove event listener for given event. If fn is not provided, all event
|
108
|
+
} // Remove event listener for given event. If fn is not provided, all event
|
92
109
|
// listeners for that event will be removed. If neither is provided, all
|
93
110
|
// event listeners will be removed.
|
94
111
|
|
@@ -98,23 +115,25 @@ var Emitter = function () {
|
|
98
115
|
if (!this._callbacks || arguments.length === 0) {
|
99
116
|
this._callbacks = {};
|
100
117
|
return this;
|
101
|
-
}
|
118
|
+
} // specific event
|
119
|
+
|
102
120
|
|
103
|
-
// specific event
|
104
121
|
var callbacks = this._callbacks[event];
|
122
|
+
|
105
123
|
if (!callbacks) {
|
106
124
|
return this;
|
107
|
-
}
|
125
|
+
} // remove all handlers
|
126
|
+
|
108
127
|
|
109
|
-
// remove all handlers
|
110
128
|
if (arguments.length === 1) {
|
111
129
|
delete this._callbacks[event];
|
112
130
|
return this;
|
113
|
-
}
|
131
|
+
} // remove specific handler
|
132
|
+
|
114
133
|
|
115
|
-
// remove specific handler
|
116
134
|
for (var i = 0; i < callbacks.length; i++) {
|
117
135
|
var callback = callbacks[i];
|
136
|
+
|
118
137
|
if (callback === fn) {
|
119
138
|
callbacks.splice(i, 1);
|
120
139
|
break;
|
@@ -128,23 +147,23 @@ var Emitter = function () {
|
|
128
147
|
return Emitter;
|
129
148
|
}();
|
130
149
|
|
131
|
-
var Dropzone =
|
150
|
+
var Dropzone =
|
151
|
+
/*#__PURE__*/
|
152
|
+
function (_Emitter) {
|
132
153
|
_inherits(Dropzone, _Emitter);
|
133
154
|
|
134
155
|
_createClass(Dropzone, null, [{
|
135
156
|
key: "initClass",
|
136
157
|
value: function initClass() {
|
137
|
-
|
138
158
|
// Exposing the emitter class, mainly for tests
|
139
159
|
this.prototype.Emitter = Emitter;
|
140
|
-
|
141
160
|
/*
|
142
161
|
This is a list of all available events you can register on a dropzone object.
|
143
162
|
You can register an event handler like this:
|
144
163
|
dropzone.on("dragEnter", function() { });
|
145
164
|
*/
|
146
|
-
this.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"];
|
147
165
|
|
166
|
+
this.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"];
|
148
167
|
this.prototype.defaultOptions = {
|
149
168
|
/**
|
150
169
|
* Has to be specified on elements other than form (or when the form
|
@@ -172,7 +191,7 @@ var Dropzone = function (_Emitter) {
|
|
172
191
|
|
173
192
|
/**
|
174
193
|
* How many file uploads to process in parallel (See the
|
175
|
-
* Enqueuing file uploads
|
194
|
+
* Enqueuing file uploads documentation section for more info)
|
176
195
|
*/
|
177
196
|
parallelUploads: 2,
|
178
197
|
|
@@ -487,14 +506,20 @@ var Dropzone = function (_Emitter) {
|
|
487
506
|
* Allows you to translate the different units. Starting with `tb` for terabytes and going down to
|
488
507
|
* `b` for bytes.
|
489
508
|
*/
|
490
|
-
dictFileSizeUnits: {
|
509
|
+
dictFileSizeUnits: {
|
510
|
+
tb: "TB",
|
511
|
+
gb: "GB",
|
512
|
+
mb: "MB",
|
513
|
+
kb: "KB",
|
514
|
+
b: "b"
|
515
|
+
},
|
516
|
+
|
491
517
|
/**
|
492
518
|
* Called when dropzone initialized
|
493
519
|
* You can add event listeners here
|
494
520
|
*/
|
495
521
|
init: function init() {},
|
496
522
|
|
497
|
-
|
498
523
|
/**
|
499
524
|
* Can be an **object** of additional parameters to transfer to the server, **or** a `Function`
|
500
525
|
* that gets invoked with the `files`, `xhr` and, if it's a chunked upload, `chunk` arguments. In case
|
@@ -518,7 +543,6 @@ var Dropzone = function (_Emitter) {
|
|
518
543
|
}
|
519
544
|
},
|
520
545
|
|
521
|
-
|
522
546
|
/**
|
523
547
|
* A function that gets a [file](https://developer.mozilla.org/en-US/docs/DOM/File)
|
524
548
|
* and a `done` function as parameters.
|
@@ -532,7 +556,6 @@ var Dropzone = function (_Emitter) {
|
|
532
556
|
return done();
|
533
557
|
},
|
534
558
|
|
535
|
-
|
536
559
|
/**
|
537
560
|
* The callback that will be invoked when all chunks have been uploaded for a file.
|
538
561
|
* It gets the file for which the chunks have been uploaded as the first parameter,
|
@@ -550,35 +573,45 @@ var Dropzone = function (_Emitter) {
|
|
550
573
|
*/
|
551
574
|
fallback: function fallback() {
|
552
575
|
// This code should pass in IE7... :(
|
553
|
-
var messageElement
|
554
|
-
this.element.className = this.element.className
|
555
|
-
|
556
|
-
|
557
|
-
|
576
|
+
var messageElement;
|
577
|
+
this.element.className = "".concat(this.element.className, " dz-browser-not-supported");
|
578
|
+
var _iteratorNormalCompletion2 = true;
|
579
|
+
var _didIteratorError2 = false;
|
580
|
+
var _iteratorError2 = undefined;
|
558
581
|
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
} else {
|
563
|
-
_i2 = _iterator2.next();
|
564
|
-
if (_i2.done) break;
|
565
|
-
_ref2 = _i2.value;
|
566
|
-
}
|
582
|
+
try {
|
583
|
+
for (var _iterator2 = this.element.getElementsByTagName("div")[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
584
|
+
var child = _step2.value;
|
567
585
|
|
568
|
-
|
586
|
+
if (/(^| )dz-message($| )/.test(child.className)) {
|
587
|
+
messageElement = child;
|
588
|
+
child.className = "dz-message"; // Removes the 'dz-default' class
|
569
589
|
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
590
|
+
break;
|
591
|
+
}
|
592
|
+
}
|
593
|
+
} catch (err) {
|
594
|
+
_didIteratorError2 = true;
|
595
|
+
_iteratorError2 = err;
|
596
|
+
} finally {
|
597
|
+
try {
|
598
|
+
if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
|
599
|
+
_iterator2["return"]();
|
600
|
+
}
|
601
|
+
} finally {
|
602
|
+
if (_didIteratorError2) {
|
603
|
+
throw _iteratorError2;
|
604
|
+
}
|
574
605
|
}
|
575
606
|
}
|
607
|
+
|
576
608
|
if (!messageElement) {
|
577
609
|
messageElement = Dropzone.createElement("<div class=\"dz-message\"><span></span></div>");
|
578
610
|
this.element.appendChild(messageElement);
|
579
611
|
}
|
580
612
|
|
581
613
|
var span = messageElement.getElementsByTagName("span")[0];
|
614
|
+
|
582
615
|
if (span) {
|
583
616
|
if (span.textContent != null) {
|
584
617
|
span.textContent = this.options.dictFallbackMessage;
|
@@ -590,7 +623,6 @@ var Dropzone = function (_Emitter) {
|
|
590
623
|
return this.element.appendChild(this.getFallbackForm());
|
591
624
|
},
|
592
625
|
|
593
|
-
|
594
626
|
/**
|
595
627
|
* Gets called to calculate the thumbnail dimensions.
|
596
628
|
*
|
@@ -610,10 +642,8 @@ var Dropzone = function (_Emitter) {
|
|
610
642
|
srcWidth: file.width,
|
611
643
|
srcHeight: file.height
|
612
644
|
};
|
645
|
+
var srcRatio = file.width / file.height; // Automatically calculate dimensions if not specified
|
613
646
|
|
614
|
-
var srcRatio = file.width / file.height;
|
615
|
-
|
616
|
-
// Automatically calculate dimensions if not specified
|
617
647
|
if (width == null && height == null) {
|
618
648
|
width = info.srcWidth;
|
619
649
|
height = info.srcHeight;
|
@@ -621,12 +651,11 @@ var Dropzone = function (_Emitter) {
|
|
621
651
|
width = height * srcRatio;
|
622
652
|
} else if (height == null) {
|
623
653
|
height = width / srcRatio;
|
624
|
-
}
|
654
|
+
} // Make sure images aren't upscaled
|
655
|
+
|
625
656
|
|
626
|
-
// Make sure images aren't upscaled
|
627
657
|
width = Math.min(width, info.srcWidth);
|
628
658
|
height = Math.min(height, info.srcHeight);
|
629
|
-
|
630
659
|
var trgRatio = width / height;
|
631
660
|
|
632
661
|
if (info.srcWidth > width || info.srcHeight > height) {
|
@@ -647,20 +676,17 @@ var Dropzone = function (_Emitter) {
|
|
647
676
|
width = height * srcRatio;
|
648
677
|
}
|
649
678
|
} else {
|
650
|
-
throw new Error("Unknown resizeMethod '"
|
679
|
+
throw new Error("Unknown resizeMethod '".concat(resizeMethod, "'"));
|
651
680
|
}
|
652
681
|
}
|
653
682
|
|
654
683
|
info.srcX = (file.width - info.srcWidth) / 2;
|
655
684
|
info.srcY = (file.height - info.srcHeight) / 2;
|
656
|
-
|
657
685
|
info.trgWidth = width;
|
658
686
|
info.trgHeight = height;
|
659
|
-
|
660
687
|
return info;
|
661
688
|
},
|
662
689
|
|
663
|
-
|
664
690
|
/**
|
665
691
|
* Can be used to transform the file (for example, resize an image if necessary).
|
666
692
|
*
|
@@ -678,7 +704,6 @@ var Dropzone = function (_Emitter) {
|
|
678
704
|
}
|
679
705
|
},
|
680
706
|
|
681
|
-
|
682
707
|
/**
|
683
708
|
* A string that contains the template used for each dropped
|
684
709
|
* file. Change it to fulfill your needs but make sure to properly
|
@@ -693,12 +718,10 @@ var Dropzone = function (_Emitter) {
|
|
693
718
|
* .innerHTML
|
694
719
|
*
|
695
720
|
*/
|
696
|
-
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\"
|
697
|
-
|
721
|
+
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\">\n <title>Check</title>\n <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\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\" stroke-opacity=\"0.198794158\" stroke=\"#747474\" fill-opacity=\"0.816519475\" fill=\"#FFFFFF\"></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\">\n <title>Error</title>\n <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\n <g 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\"></path>\n </g>\n </g>\n </svg>\n </div>\n</div>",
|
698
722
|
// END OPTIONS
|
699
723
|
// (Required by the dropzone documentation parser)
|
700
724
|
|
701
|
-
|
702
725
|
/*
|
703
726
|
Those functions register themselves to the events on init and handle all
|
704
727
|
the user interface specific stuff. Overwriting them won't break the upload
|
@@ -707,7 +730,6 @@ var Dropzone = function (_Emitter) {
|
|
707
730
|
want to add an additional event handler, register it on the dropzone object
|
708
731
|
and don't overwrite those options.
|
709
732
|
*/
|
710
|
-
|
711
733
|
// Those are self explanatory and simply concern the DragnDrop.
|
712
734
|
drop: function drop(e) {
|
713
735
|
return this.element.classList.remove("dz-drag-hover");
|
@@ -726,15 +748,11 @@ var Dropzone = function (_Emitter) {
|
|
726
748
|
return this.element.classList.remove("dz-drag-hover");
|
727
749
|
},
|
728
750
|
paste: function paste(e) {},
|
729
|
-
|
730
|
-
|
731
751
|
// Called whenever there are no files left in the dropzone anymore, and the
|
732
752
|
// dropzone should be displayed as if in the initial state.
|
733
753
|
reset: function reset() {
|
734
754
|
return this.element.classList.remove("dz-started");
|
735
755
|
},
|
736
|
-
|
737
|
-
|
738
756
|
// Called when a file is added to the queue
|
739
757
|
// Receives `file`
|
740
758
|
addedfile: function addedfile(file) {
|
@@ -749,43 +767,63 @@ var Dropzone = function (_Emitter) {
|
|
749
767
|
file.previewTemplate = file.previewElement; // Backwards compatibility
|
750
768
|
|
751
769
|
this.previewsContainer.appendChild(file.previewElement);
|
752
|
-
|
753
|
-
|
770
|
+
var _iteratorNormalCompletion3 = true;
|
771
|
+
var _didIteratorError3 = false;
|
772
|
+
var _iteratorError3 = undefined;
|
754
773
|
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
774
|
+
try {
|
775
|
+
for (var _iterator3 = file.previewElement.querySelectorAll("[data-dz-name]")[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
776
|
+
var node = _step3.value;
|
777
|
+
node.textContent = file.name;
|
778
|
+
}
|
779
|
+
} catch (err) {
|
780
|
+
_didIteratorError3 = true;
|
781
|
+
_iteratorError3 = err;
|
782
|
+
} finally {
|
783
|
+
try {
|
784
|
+
if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) {
|
785
|
+
_iterator3["return"]();
|
786
|
+
}
|
787
|
+
} finally {
|
788
|
+
if (_didIteratorError3) {
|
789
|
+
throw _iteratorError3;
|
790
|
+
}
|
762
791
|
}
|
792
|
+
}
|
763
793
|
|
764
|
-
|
794
|
+
var _iteratorNormalCompletion4 = true;
|
795
|
+
var _didIteratorError4 = false;
|
796
|
+
var _iteratorError4 = undefined;
|
765
797
|
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
798
|
+
try {
|
799
|
+
for (var _iterator4 = file.previewElement.querySelectorAll("[data-dz-size]")[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
800
|
+
node = _step4.value;
|
801
|
+
node.innerHTML = this.filesize(file.size);
|
802
|
+
}
|
803
|
+
} catch (err) {
|
804
|
+
_didIteratorError4 = true;
|
805
|
+
_iteratorError4 = err;
|
806
|
+
} finally {
|
807
|
+
try {
|
808
|
+
if (!_iteratorNormalCompletion4 && _iterator4["return"] != null) {
|
809
|
+
_iterator4["return"]();
|
810
|
+
}
|
811
|
+
} finally {
|
812
|
+
if (_didIteratorError4) {
|
813
|
+
throw _iteratorError4;
|
814
|
+
}
|
776
815
|
}
|
777
|
-
|
778
|
-
node.innerHTML = this.filesize(file.size);
|
779
816
|
}
|
780
817
|
|
781
818
|
if (this.options.addRemoveLinks) {
|
782
|
-
file._removeLink = Dropzone.createElement("<a class=\"dz-remove\" href=\"javascript:undefined;\" data-dz-remove>"
|
819
|
+
file._removeLink = Dropzone.createElement("<a class=\"dz-remove\" href=\"javascript:undefined;\" data-dz-remove>".concat(this.options.dictRemoveFile, "</a>"));
|
783
820
|
file.previewElement.appendChild(file._removeLink);
|
784
821
|
}
|
785
822
|
|
786
823
|
var removeFileEvent = function removeFileEvent(e) {
|
787
824
|
e.preventDefault();
|
788
825
|
e.stopPropagation();
|
826
|
+
|
789
827
|
if (file.status === Dropzone.UPLOADING) {
|
790
828
|
return Dropzone.confirm(_this2.options.dictCancelUploadConfirmation, function () {
|
791
829
|
return _this2.removeFile(file);
|
@@ -801,56 +839,67 @@ var Dropzone = function (_Emitter) {
|
|
801
839
|
}
|
802
840
|
};
|
803
841
|
|
804
|
-
|
805
|
-
|
842
|
+
var _iteratorNormalCompletion5 = true;
|
843
|
+
var _didIteratorError5 = false;
|
844
|
+
var _iteratorError5 = undefined;
|
806
845
|
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
846
|
+
try {
|
847
|
+
for (var _iterator5 = file.previewElement.querySelectorAll("[data-dz-remove]")[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
|
848
|
+
var removeLink = _step5.value;
|
849
|
+
removeLink.addEventListener("click", removeFileEvent);
|
850
|
+
}
|
851
|
+
} catch (err) {
|
852
|
+
_didIteratorError5 = true;
|
853
|
+
_iteratorError5 = err;
|
854
|
+
} finally {
|
855
|
+
try {
|
856
|
+
if (!_iteratorNormalCompletion5 && _iterator5["return"] != null) {
|
857
|
+
_iterator5["return"]();
|
858
|
+
}
|
859
|
+
} finally {
|
860
|
+
if (_didIteratorError5) {
|
861
|
+
throw _iteratorError5;
|
862
|
+
}
|
814
863
|
}
|
815
|
-
|
816
|
-
var removeLink = _ref4;
|
817
|
-
|
818
|
-
removeLink.addEventListener("click", removeFileEvent);
|
819
864
|
}
|
820
865
|
}
|
821
866
|
},
|
822
|
-
|
823
|
-
|
824
867
|
// Called whenever a file is removed.
|
825
868
|
removedfile: function removedfile(file) {
|
826
869
|
if (file.previewElement != null && file.previewElement.parentNode != null) {
|
827
870
|
file.previewElement.parentNode.removeChild(file.previewElement);
|
828
871
|
}
|
872
|
+
|
829
873
|
return this._updateMaxFilesReachedClass();
|
830
874
|
},
|
831
|
-
|
832
|
-
|
833
875
|
// Called when a thumbnail has been generated
|
834
876
|
// Receives `file` and `dataUrl`
|
835
877
|
thumbnail: function thumbnail(file, dataUrl) {
|
836
878
|
if (file.previewElement) {
|
837
879
|
file.previewElement.classList.remove("dz-file-preview");
|
838
|
-
|
839
|
-
|
880
|
+
var _iteratorNormalCompletion6 = true;
|
881
|
+
var _didIteratorError6 = false;
|
882
|
+
var _iteratorError6 = undefined;
|
840
883
|
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
884
|
+
try {
|
885
|
+
for (var _iterator6 = file.previewElement.querySelectorAll("[data-dz-thumbnail]")[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
|
886
|
+
var thumbnailElement = _step6.value;
|
887
|
+
thumbnailElement.alt = file.name;
|
888
|
+
thumbnailElement.src = dataUrl;
|
889
|
+
}
|
890
|
+
} catch (err) {
|
891
|
+
_didIteratorError6 = true;
|
892
|
+
_iteratorError6 = err;
|
893
|
+
} finally {
|
894
|
+
try {
|
895
|
+
if (!_iteratorNormalCompletion6 && _iterator6["return"] != null) {
|
896
|
+
_iterator6["return"]();
|
897
|
+
}
|
898
|
+
} finally {
|
899
|
+
if (_didIteratorError6) {
|
900
|
+
throw _iteratorError6;
|
901
|
+
}
|
848
902
|
}
|
849
|
-
|
850
|
-
var thumbnailElement = _ref5;
|
851
|
-
|
852
|
-
thumbnailElement.alt = file.name;
|
853
|
-
thumbnailElement.src = dataUrl;
|
854
903
|
}
|
855
904
|
|
856
905
|
return setTimeout(function () {
|
@@ -858,88 +907,93 @@ var Dropzone = function (_Emitter) {
|
|
858
907
|
}, 1);
|
859
908
|
}
|
860
909
|
},
|
861
|
-
|
862
|
-
|
863
910
|
// Called whenever an error occurs
|
864
911
|
// Receives `file` and `message`
|
865
912
|
error: function error(file, message) {
|
866
913
|
if (file.previewElement) {
|
867
914
|
file.previewElement.classList.add("dz-error");
|
915
|
+
|
868
916
|
if (typeof message !== "String" && message.error) {
|
869
917
|
message = message.error;
|
870
918
|
}
|
871
|
-
for (var _iterator7 = file.previewElement.querySelectorAll("[data-dz-errormessage]"), _isArray7 = true, _i7 = 0, _iterator7 = _isArray7 ? _iterator7 : _iterator7[Symbol.iterator]();;) {
|
872
|
-
var _ref6;
|
873
|
-
|
874
|
-
if (_isArray7) {
|
875
|
-
if (_i7 >= _iterator7.length) break;
|
876
|
-
_ref6 = _iterator7[_i7++];
|
877
|
-
} else {
|
878
|
-
_i7 = _iterator7.next();
|
879
|
-
if (_i7.done) break;
|
880
|
-
_ref6 = _i7.value;
|
881
|
-
}
|
882
919
|
|
883
|
-
|
920
|
+
var _iteratorNormalCompletion7 = true;
|
921
|
+
var _didIteratorError7 = false;
|
922
|
+
var _iteratorError7 = undefined;
|
884
923
|
|
885
|
-
|
924
|
+
try {
|
925
|
+
for (var _iterator7 = file.previewElement.querySelectorAll("[data-dz-errormessage]")[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
|
926
|
+
var node = _step7.value;
|
927
|
+
node.textContent = message;
|
928
|
+
}
|
929
|
+
} catch (err) {
|
930
|
+
_didIteratorError7 = true;
|
931
|
+
_iteratorError7 = err;
|
932
|
+
} finally {
|
933
|
+
try {
|
934
|
+
if (!_iteratorNormalCompletion7 && _iterator7["return"] != null) {
|
935
|
+
_iterator7["return"]();
|
936
|
+
}
|
937
|
+
} finally {
|
938
|
+
if (_didIteratorError7) {
|
939
|
+
throw _iteratorError7;
|
940
|
+
}
|
941
|
+
}
|
886
942
|
}
|
887
943
|
}
|
888
944
|
},
|
889
945
|
errormultiple: function errormultiple() {},
|
890
|
-
|
891
|
-
|
892
946
|
// Called when a file gets processed. Since there is a cue, not all added
|
893
947
|
// files are processed immediately.
|
894
948
|
// Receives `file`
|
895
949
|
processing: function processing(file) {
|
896
950
|
if (file.previewElement) {
|
897
951
|
file.previewElement.classList.add("dz-processing");
|
952
|
+
|
898
953
|
if (file._removeLink) {
|
899
954
|
return file._removeLink.innerHTML = this.options.dictCancelUpload;
|
900
955
|
}
|
901
956
|
}
|
902
957
|
},
|
903
958
|
processingmultiple: function processingmultiple() {},
|
904
|
-
|
905
|
-
|
906
959
|
// Called whenever the upload progress gets updated.
|
907
960
|
// Receives `file`, `progress` (percentage 0-100) and `bytesSent`.
|
908
961
|
// To get the total number of bytes of the file, use `file.size`
|
909
962
|
uploadprogress: function uploadprogress(file, progress, bytesSent) {
|
910
963
|
if (file.previewElement) {
|
911
|
-
|
912
|
-
|
964
|
+
var _iteratorNormalCompletion8 = true;
|
965
|
+
var _didIteratorError8 = false;
|
966
|
+
var _iteratorError8 = undefined;
|
913
967
|
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
968
|
+
try {
|
969
|
+
for (var _iterator8 = file.previewElement.querySelectorAll("[data-dz-uploadprogress]")[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
|
970
|
+
var node = _step8.value;
|
971
|
+
node.nodeName === 'PROGRESS' ? node.value = progress : node.style.width = "".concat(progress, "%");
|
972
|
+
}
|
973
|
+
} catch (err) {
|
974
|
+
_didIteratorError8 = true;
|
975
|
+
_iteratorError8 = err;
|
976
|
+
} finally {
|
977
|
+
try {
|
978
|
+
if (!_iteratorNormalCompletion8 && _iterator8["return"] != null) {
|
979
|
+
_iterator8["return"]();
|
980
|
+
}
|
981
|
+
} finally {
|
982
|
+
if (_didIteratorError8) {
|
983
|
+
throw _iteratorError8;
|
984
|
+
}
|
921
985
|
}
|
922
|
-
|
923
|
-
var node = _ref7;
|
924
|
-
|
925
|
-
node.nodeName === 'PROGRESS' ? node.value = progress : node.style.width = progress + "%";
|
926
986
|
}
|
927
987
|
}
|
928
988
|
},
|
929
|
-
|
930
|
-
|
931
989
|
// Called whenever the total upload progress gets updated.
|
932
990
|
// Called with totalUploadProgress (0-100), totalBytes and totalBytesSent
|
933
991
|
totaluploadprogress: function totaluploadprogress() {},
|
934
|
-
|
935
|
-
|
936
992
|
// Called just before the file is sent. Gets the `xhr` object as second
|
937
993
|
// parameter, so you can modify it (for example to add a CSRF token) and a
|
938
994
|
// `formData` object to add additional information.
|
939
995
|
sending: function sending() {},
|
940
996
|
sendingmultiple: function sendingmultiple() {},
|
941
|
-
|
942
|
-
|
943
997
|
// When the complete upload is finished and successful
|
944
998
|
// Receives `file`
|
945
999
|
success: function success(file) {
|
@@ -948,21 +1002,18 @@ var Dropzone = function (_Emitter) {
|
|
948
1002
|
}
|
949
1003
|
},
|
950
1004
|
successmultiple: function successmultiple() {},
|
951
|
-
|
952
|
-
|
953
1005
|
// When the upload is canceled.
|
954
1006
|
canceled: function canceled(file) {
|
955
1007
|
return this.emit("error", file, this.options.dictUploadCanceled);
|
956
1008
|
},
|
957
1009
|
canceledmultiple: function canceledmultiple() {},
|
958
|
-
|
959
|
-
|
960
1010
|
// When the upload is finished, either with success or an error.
|
961
1011
|
// Receives `file`
|
962
1012
|
complete: function complete(file) {
|
963
1013
|
if (file._removeLink) {
|
964
1014
|
file._removeLink.innerHTML = this.options.dictRemoveFile;
|
965
1015
|
}
|
1016
|
+
|
966
1017
|
if (file.previewElement) {
|
967
1018
|
return file.previewElement.classList.add("dz-complete");
|
968
1019
|
}
|
@@ -973,91 +1024,70 @@ var Dropzone = function (_Emitter) {
|
|
973
1024
|
queuecomplete: function queuecomplete() {},
|
974
1025
|
addedfiles: function addedfiles() {}
|
975
1026
|
};
|
976
|
-
|
977
1027
|
this.prototype._thumbnailQueue = [];
|
978
1028
|
this.prototype._processingThumbnail = false;
|
979
|
-
}
|
980
|
-
|
981
|
-
// global utility
|
1029
|
+
} // global utility
|
982
1030
|
|
983
1031
|
}, {
|
984
1032
|
key: "extend",
|
985
1033
|
value: function extend(target) {
|
986
|
-
for (var _len2 = arguments.length, objects = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
1034
|
+
for (var _len2 = arguments.length, objects = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
987
1035
|
objects[_key2 - 1] = arguments[_key2];
|
988
1036
|
}
|
989
1037
|
|
990
|
-
for (var
|
991
|
-
var
|
992
|
-
|
993
|
-
if (_isArray9) {
|
994
|
-
if (_i9 >= _iterator9.length) break;
|
995
|
-
_ref8 = _iterator9[_i9++];
|
996
|
-
} else {
|
997
|
-
_i9 = _iterator9.next();
|
998
|
-
if (_i9.done) break;
|
999
|
-
_ref8 = _i9.value;
|
1000
|
-
}
|
1001
|
-
|
1002
|
-
var object = _ref8;
|
1038
|
+
for (var _i = 0, _objects = objects; _i < _objects.length; _i++) {
|
1039
|
+
var object = _objects[_i];
|
1003
1040
|
|
1004
1041
|
for (var key in object) {
|
1005
1042
|
var val = object[key];
|
1006
1043
|
target[key] = val;
|
1007
1044
|
}
|
1008
1045
|
}
|
1046
|
+
|
1009
1047
|
return target;
|
1010
1048
|
}
|
1011
1049
|
}]);
|
1012
1050
|
|
1013
1051
|
function Dropzone(el, options) {
|
1052
|
+
var _this;
|
1053
|
+
|
1014
1054
|
_classCallCheck(this, Dropzone);
|
1015
1055
|
|
1016
|
-
|
1056
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(Dropzone).call(this));
|
1057
|
+
var fallback, left;
|
1058
|
+
_this.element = el; // For backwards compatibility since the version was in the prototype previously
|
1017
1059
|
|
1018
|
-
var fallback = void 0,
|
1019
|
-
left = void 0;
|
1020
|
-
_this.element = el;
|
1021
|
-
// For backwards compatibility since the version was in the prototype previously
|
1022
1060
|
_this.version = Dropzone.version;
|
1023
|
-
|
1024
1061
|
_this.defaultOptions.previewTemplate = _this.defaultOptions.previewTemplate.replace(/\n*/g, "");
|
1025
|
-
|
1026
1062
|
_this.clickableElements = [];
|
1027
1063
|
_this.listeners = [];
|
1028
1064
|
_this.files = []; // All files
|
1029
1065
|
|
1030
1066
|
if (typeof _this.element === "string") {
|
1031
1067
|
_this.element = document.querySelector(_this.element);
|
1032
|
-
}
|
1068
|
+
} // Not checking if instance of HTMLElement or Element since IE9 is extremely weird.
|
1069
|
+
|
1033
1070
|
|
1034
|
-
// Not checking if instance of HTMLElement or Element since IE9 is extremely weird.
|
1035
1071
|
if (!_this.element || _this.element.nodeType == null) {
|
1036
1072
|
throw new Error("Invalid dropzone element.");
|
1037
1073
|
}
|
1038
1074
|
|
1039
1075
|
if (_this.element.dropzone) {
|
1040
1076
|
throw new Error("Dropzone already attached.");
|
1041
|
-
}
|
1077
|
+
} // Now add this dropzone to the instances.
|
1042
1078
|
|
1043
|
-
// Now add this dropzone to the instances.
|
1044
|
-
Dropzone.instances.push(_this);
|
1045
1079
|
|
1046
|
-
// Put the dropzone inside the element itself.
|
1047
|
-
_this.element.dropzone = _this;
|
1080
|
+
Dropzone.instances.push(_assertThisInitialized(_this)); // Put the dropzone inside the element itself.
|
1048
1081
|
|
1082
|
+
_this.element.dropzone = _assertThisInitialized(_this);
|
1049
1083
|
var elementOptions = (left = Dropzone.optionsForElement(_this.element)) != null ? left : {};
|
1084
|
+
_this.options = Dropzone.extend({}, _this.defaultOptions, elementOptions, options != null ? options : {}); // If the browser failed, just call the fallback and leave
|
1050
1085
|
|
1051
|
-
_this.options = Dropzone.extend({}, _this.defaultOptions, elementOptions, options != null ? options : {});
|
1052
|
-
|
1053
|
-
// If the browser failed, just call the fallback and leave
|
1054
1086
|
if (_this.options.forceFallback || !Dropzone.isBrowserSupported()) {
|
1055
|
-
|
1087
|
+
return _possibleConstructorReturn(_this, _this.options.fallback.call(_assertThisInitialized(_this)));
|
1088
|
+
} // @options.url = @element.getAttribute "action" unless @options.url?
|
1056
1089
|
|
1057
|
-
return _ret = _this.options.fallback.call(_this), _possibleConstructorReturn(_this, _ret);
|
1058
|
-
}
|
1059
1090
|
|
1060
|
-
// @options.url = @element.getAttribute "action" unless @options.url?
|
1061
1091
|
if (_this.options.url == null) {
|
1062
1092
|
_this.options.url = _this.element.getAttribute("action");
|
1063
1093
|
}
|
@@ -1072,18 +1102,18 @@ var Dropzone = function (_Emitter) {
|
|
1072
1102
|
|
1073
1103
|
if (_this.options.uploadMultiple && _this.options.chunking) {
|
1074
1104
|
throw new Error('You cannot set both: uploadMultiple and chunking.');
|
1075
|
-
}
|
1105
|
+
} // Backwards compatibility
|
1106
|
+
|
1076
1107
|
|
1077
|
-
// Backwards compatibility
|
1078
1108
|
if (_this.options.acceptedMimeTypes) {
|
1079
1109
|
_this.options.acceptedFiles = _this.options.acceptedMimeTypes;
|
1080
1110
|
delete _this.options.acceptedMimeTypes;
|
1081
|
-
}
|
1111
|
+
} // Backwards compatibility
|
1112
|
+
|
1082
1113
|
|
1083
|
-
// Backwards compatibility
|
1084
1114
|
if (_this.options.renameFilename != null) {
|
1085
1115
|
_this.options.renameFile = function (file) {
|
1086
|
-
return _this.options.renameFilename.call(_this, file.name, file);
|
1116
|
+
return _this.options.renameFilename.call(_assertThisInitialized(_this), file.name, file);
|
1087
1117
|
};
|
1088
1118
|
}
|
1089
1119
|
|
@@ -1092,9 +1122,9 @@ var Dropzone = function (_Emitter) {
|
|
1092
1122
|
if ((fallback = _this.getExistingFallback()) && fallback.parentNode) {
|
1093
1123
|
// Remove the fallback
|
1094
1124
|
fallback.parentNode.removeChild(fallback);
|
1095
|
-
}
|
1125
|
+
} // Display previews in the previewsContainer element or the Dropzone element unless explicitly set to false
|
1126
|
+
|
1096
1127
|
|
1097
|
-
// Display previews in the previewsContainer element or the Dropzone element unless explicitly set to false
|
1098
1128
|
if (_this.options.previewsContainer !== false) {
|
1099
1129
|
if (_this.options.previewsContainer) {
|
1100
1130
|
_this.previewsContainer = Dropzone.getElement(_this.options.previewsContainer, "previewsContainer");
|
@@ -1112,10 +1142,9 @@ var Dropzone = function (_Emitter) {
|
|
1112
1142
|
}
|
1113
1143
|
|
1114
1144
|
_this.init();
|
1115
|
-
return _this;
|
1116
|
-
}
|
1117
1145
|
|
1118
|
-
|
1146
|
+
return _this;
|
1147
|
+
} // Returns all files that have been accepted
|
1119
1148
|
|
1120
1149
|
|
1121
1150
|
_createClass(Dropzone, [{
|
@@ -1126,9 +1155,7 @@ var Dropzone = function (_Emitter) {
|
|
1126
1155
|
}).map(function (file) {
|
1127
1156
|
return file;
|
1128
1157
|
});
|
1129
|
-
}
|
1130
|
-
|
1131
|
-
// Returns all files that have been rejected
|
1158
|
+
} // Returns all files that have been rejected
|
1132
1159
|
// Not sure when that's going to be useful, but added for completeness.
|
1133
1160
|
|
1134
1161
|
}, {
|
@@ -1148,9 +1175,7 @@ var Dropzone = function (_Emitter) {
|
|
1148
1175
|
}).map(function (file) {
|
1149
1176
|
return file;
|
1150
1177
|
});
|
1151
|
-
}
|
1152
|
-
|
1153
|
-
// Returns all files that are in the queue
|
1178
|
+
} // Returns all files that are in the queue
|
1154
1179
|
|
1155
1180
|
}, {
|
1156
1181
|
key: "getQueuedFiles",
|
@@ -1166,9 +1191,7 @@ var Dropzone = function (_Emitter) {
|
|
1166
1191
|
key: "getAddedFiles",
|
1167
1192
|
value: function getAddedFiles() {
|
1168
1193
|
return this.getFilesWithStatus(Dropzone.ADDED);
|
1169
|
-
}
|
1170
|
-
|
1171
|
-
// Files that are either queued or uploading
|
1194
|
+
} // Files that are either queued or uploading
|
1172
1195
|
|
1173
1196
|
}, {
|
1174
1197
|
key: "getActiveFiles",
|
@@ -1178,9 +1201,7 @@ var Dropzone = function (_Emitter) {
|
|
1178
1201
|
}).map(function (file) {
|
1179
1202
|
return file;
|
1180
1203
|
});
|
1181
|
-
}
|
1182
|
-
|
1183
|
-
// The function that gets called when Dropzone is initialized. You
|
1204
|
+
} // The function that gets called when Dropzone is initialized. You
|
1184
1205
|
// can (and should) setup event listeners inside this function.
|
1185
1206
|
|
1186
1207
|
}, {
|
@@ -1194,7 +1215,7 @@ var Dropzone = function (_Emitter) {
|
|
1194
1215
|
}
|
1195
1216
|
|
1196
1217
|
if (this.element.classList.contains("dropzone") && !this.element.querySelector(".dz-message")) {
|
1197
|
-
this.element.appendChild(Dropzone.createElement("<div class=\"dz-default dz-message\"><
|
1218
|
+
this.element.appendChild(Dropzone.createElement("<div class=\"dz-default dz-message\"><button class=\"dz-button\" type=\"button\">".concat(this.options.dictDefaultMessage, "</button></div>")));
|
1198
1219
|
}
|
1199
1220
|
|
1200
1221
|
if (this.clickableElements.length) {
|
@@ -1202,22 +1223,27 @@ var Dropzone = function (_Emitter) {
|
|
1202
1223
|
if (_this3.hiddenFileInput) {
|
1203
1224
|
_this3.hiddenFileInput.parentNode.removeChild(_this3.hiddenFileInput);
|
1204
1225
|
}
|
1226
|
+
|
1205
1227
|
_this3.hiddenFileInput = document.createElement("input");
|
1228
|
+
|
1206
1229
|
_this3.hiddenFileInput.setAttribute("type", "file");
|
1230
|
+
|
1207
1231
|
if (_this3.options.maxFiles === null || _this3.options.maxFiles > 1) {
|
1208
1232
|
_this3.hiddenFileInput.setAttribute("multiple", "multiple");
|
1209
1233
|
}
|
1234
|
+
|
1210
1235
|
_this3.hiddenFileInput.className = "dz-hidden-input";
|
1211
1236
|
|
1212
1237
|
if (_this3.options.acceptedFiles !== null) {
|
1213
1238
|
_this3.hiddenFileInput.setAttribute("accept", _this3.options.acceptedFiles);
|
1214
1239
|
}
|
1240
|
+
|
1215
1241
|
if (_this3.options.capture !== null) {
|
1216
1242
|
_this3.hiddenFileInput.setAttribute("capture", _this3.options.capture);
|
1217
|
-
}
|
1218
|
-
|
1219
|
-
// Not setting `display="none"` because some browsers don't accept clicks
|
1243
|
+
} // Not setting `display="none"` because some browsers don't accept clicks
|
1220
1244
|
// on elements that aren't displayed.
|
1245
|
+
|
1246
|
+
|
1221
1247
|
_this3.hiddenFileInput.style.visibility = "hidden";
|
1222
1248
|
_this3.hiddenFileInput.style.position = "absolute";
|
1223
1249
|
_this3.hiddenFileInput.style.top = "0";
|
@@ -1229,65 +1255,79 @@ var Dropzone = function (_Emitter) {
|
|
1229
1255
|
var files = _this3.hiddenFileInput.files;
|
1230
1256
|
|
1231
1257
|
if (files.length) {
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
if (_isArray10) {
|
1236
|
-
if (_i10 >= _iterator10.length) break;
|
1237
|
-
_ref9 = _iterator10[_i10++];
|
1238
|
-
} else {
|
1239
|
-
_i10 = _iterator10.next();
|
1240
|
-
if (_i10.done) break;
|
1241
|
-
_ref9 = _i10.value;
|
1242
|
-
}
|
1258
|
+
var _iteratorNormalCompletion9 = true;
|
1259
|
+
var _didIteratorError9 = false;
|
1260
|
+
var _iteratorError9 = undefined;
|
1243
1261
|
|
1244
|
-
|
1262
|
+
try {
|
1263
|
+
for (var _iterator9 = files[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
|
1264
|
+
var file = _step9.value;
|
1245
1265
|
|
1246
|
-
|
1266
|
+
_this3.addFile(file);
|
1267
|
+
}
|
1268
|
+
} catch (err) {
|
1269
|
+
_didIteratorError9 = true;
|
1270
|
+
_iteratorError9 = err;
|
1271
|
+
} finally {
|
1272
|
+
try {
|
1273
|
+
if (!_iteratorNormalCompletion9 && _iterator9["return"] != null) {
|
1274
|
+
_iterator9["return"]();
|
1275
|
+
}
|
1276
|
+
} finally {
|
1277
|
+
if (_didIteratorError9) {
|
1278
|
+
throw _iteratorError9;
|
1279
|
+
}
|
1280
|
+
}
|
1247
1281
|
}
|
1248
1282
|
}
|
1283
|
+
|
1249
1284
|
_this3.emit("addedfiles", files);
|
1285
|
+
|
1250
1286
|
return setupHiddenFileInput();
|
1251
1287
|
});
|
1252
1288
|
};
|
1289
|
+
|
1253
1290
|
setupHiddenFileInput();
|
1254
1291
|
}
|
1255
1292
|
|
1256
|
-
this.URL = window.URL !== null ? window.URL : window.webkitURL;
|
1257
|
-
|
1258
|
-
// Setup all event listeners on the Dropzone object itself.
|
1293
|
+
this.URL = window.URL !== null ? window.URL : window.webkitURL; // Setup all event listeners on the Dropzone object itself.
|
1259
1294
|
// They're not in @setupEventListeners() because they shouldn't be removed
|
1260
1295
|
// again when the dropzone gets disabled.
|
1261
|
-
for (var _iterator11 = this.events, _isArray11 = true, _i11 = 0, _iterator11 = _isArray11 ? _iterator11 : _iterator11[Symbol.iterator]();;) {
|
1262
|
-
var _ref10;
|
1263
|
-
|
1264
|
-
if (_isArray11) {
|
1265
|
-
if (_i11 >= _iterator11.length) break;
|
1266
|
-
_ref10 = _iterator11[_i11++];
|
1267
|
-
} else {
|
1268
|
-
_i11 = _iterator11.next();
|
1269
|
-
if (_i11.done) break;
|
1270
|
-
_ref10 = _i11.value;
|
1271
|
-
}
|
1272
1296
|
|
1273
|
-
|
1297
|
+
var _iteratorNormalCompletion10 = true;
|
1298
|
+
var _didIteratorError10 = false;
|
1299
|
+
var _iteratorError10 = undefined;
|
1274
1300
|
|
1275
|
-
|
1301
|
+
try {
|
1302
|
+
for (var _iterator10 = this.events[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
|
1303
|
+
var eventName = _step10.value;
|
1304
|
+
this.on(eventName, this.options[eventName]);
|
1305
|
+
}
|
1306
|
+
} catch (err) {
|
1307
|
+
_didIteratorError10 = true;
|
1308
|
+
_iteratorError10 = err;
|
1309
|
+
} finally {
|
1310
|
+
try {
|
1311
|
+
if (!_iteratorNormalCompletion10 && _iterator10["return"] != null) {
|
1312
|
+
_iterator10["return"]();
|
1313
|
+
}
|
1314
|
+
} finally {
|
1315
|
+
if (_didIteratorError10) {
|
1316
|
+
throw _iteratorError10;
|
1317
|
+
}
|
1318
|
+
}
|
1276
1319
|
}
|
1277
1320
|
|
1278
1321
|
this.on("uploadprogress", function () {
|
1279
1322
|
return _this3.updateTotalUploadProgress();
|
1280
1323
|
});
|
1281
|
-
|
1282
1324
|
this.on("removedfile", function () {
|
1283
1325
|
return _this3.updateTotalUploadProgress();
|
1284
1326
|
});
|
1285
|
-
|
1286
1327
|
this.on("canceled", function (file) {
|
1287
1328
|
return _this3.emit("complete", file);
|
1288
|
-
});
|
1329
|
+
}); // Emit a `queuecomplete` event if all files finished uploading.
|
1289
1330
|
|
1290
|
-
// Emit a `queuecomplete` event if all files finished uploading.
|
1291
1331
|
this.on("complete", function (file) {
|
1292
1332
|
if (_this3.getAddedFiles().length === 0 && _this3.getUploadingFiles().length === 0 && _this3.getQueuedFiles().length === 0) {
|
1293
1333
|
// This needs to be deferred so that `queuecomplete` really triggers after `complete`
|
@@ -1297,16 +1337,34 @@ var Dropzone = function (_Emitter) {
|
|
1297
1337
|
}
|
1298
1338
|
});
|
1299
1339
|
|
1340
|
+
var containsFiles = function containsFiles(e) {
|
1341
|
+
if (e.dataTransfer.types) {
|
1342
|
+
// Because e.dataTransfer.types is an Object in
|
1343
|
+
// IE, we need to iterate like this instead of
|
1344
|
+
// using e.dataTransfer.types.some()
|
1345
|
+
for (var i = 0; i < e.dataTransfer.types.length; i++) {
|
1346
|
+
if (e.dataTransfer.types[i] === "Files") return true;
|
1347
|
+
}
|
1348
|
+
}
|
1349
|
+
|
1350
|
+
return false;
|
1351
|
+
};
|
1352
|
+
|
1300
1353
|
var noPropagation = function noPropagation(e) {
|
1354
|
+
// If there are no files, we don't want to stop
|
1355
|
+
// propagation so we don't interfere with other
|
1356
|
+
// drag and drop behaviour.
|
1357
|
+
if (!containsFiles(e)) return;
|
1301
1358
|
e.stopPropagation();
|
1359
|
+
|
1302
1360
|
if (e.preventDefault) {
|
1303
1361
|
return e.preventDefault();
|
1304
1362
|
} else {
|
1305
1363
|
return e.returnValue = false;
|
1306
1364
|
}
|
1307
|
-
};
|
1365
|
+
}; // Create the listeners
|
1366
|
+
|
1308
1367
|
|
1309
|
-
// Create the listeners
|
1310
1368
|
this.listeners = [{
|
1311
1369
|
element: this.element,
|
1312
1370
|
events: {
|
@@ -1321,12 +1379,13 @@ var Dropzone = function (_Emitter) {
|
|
1321
1379
|
// Makes it possible to drag files from chrome's download bar
|
1322
1380
|
// http://stackoverflow.com/questions/19526430/drag-and-drop-file-uploads-from-chrome-downloads-bar
|
1323
1381
|
// Try is required to prevent bug in Internet Explorer 11 (SCRIPT65535 exception)
|
1324
|
-
var efct
|
1382
|
+
var efct;
|
1383
|
+
|
1325
1384
|
try {
|
1326
1385
|
efct = e.dataTransfer.effectAllowed;
|
1327
1386
|
} catch (error) {}
|
1328
|
-
e.dataTransfer.dropEffect = 'move' === efct || 'linkMove' === efct ? 'move' : 'copy';
|
1329
1387
|
|
1388
|
+
e.dataTransfer.dropEffect = 'move' === efct || 'linkMove' === efct ? 'move' : 'copy';
|
1330
1389
|
noPropagation(e);
|
1331
1390
|
return _this3.emit("dragover", e);
|
1332
1391
|
},
|
@@ -1340,13 +1399,12 @@ var Dropzone = function (_Emitter) {
|
|
1340
1399
|
"dragend": function dragend(e) {
|
1341
1400
|
return _this3.emit("dragend", e);
|
1342
1401
|
}
|
1402
|
+
} // This is disabled right now, because the browsers don't implement it properly.
|
1403
|
+
// "paste": (e) =>
|
1404
|
+
// noPropagation e
|
1405
|
+
// @paste e
|
1343
1406
|
|
1344
|
-
|
1345
|
-
// "paste": (e) =>
|
1346
|
-
// noPropagation e
|
1347
|
-
// @paste e
|
1348
|
-
} }];
|
1349
|
-
|
1407
|
+
}];
|
1350
1408
|
this.clickableElements.forEach(function (clickableElement) {
|
1351
1409
|
return _this3.listeners.push({
|
1352
1410
|
element: clickableElement,
|
@@ -1355,68 +1413,73 @@ var Dropzone = function (_Emitter) {
|
|
1355
1413
|
// Only the actual dropzone or the message element should trigger file selection
|
1356
1414
|
if (clickableElement !== _this3.element || evt.target === _this3.element || Dropzone.elementInside(evt.target, _this3.element.querySelector(".dz-message"))) {
|
1357
1415
|
_this3.hiddenFileInput.click(); // Forward the click
|
1416
|
+
|
1358
1417
|
}
|
1418
|
+
|
1359
1419
|
return true;
|
1360
1420
|
}
|
1361
1421
|
}
|
1362
1422
|
});
|
1363
1423
|
});
|
1364
|
-
|
1365
1424
|
this.enable();
|
1366
|
-
|
1367
1425
|
return this.options.init.call(this);
|
1368
|
-
}
|
1369
|
-
|
1370
|
-
// Not fully tested yet
|
1426
|
+
} // Not fully tested yet
|
1371
1427
|
|
1372
1428
|
}, {
|
1373
1429
|
key: "destroy",
|
1374
1430
|
value: function destroy() {
|
1375
1431
|
this.disable();
|
1376
1432
|
this.removeAllFiles(true);
|
1433
|
+
|
1377
1434
|
if (this.hiddenFileInput != null ? this.hiddenFileInput.parentNode : undefined) {
|
1378
1435
|
this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput);
|
1379
1436
|
this.hiddenFileInput = null;
|
1380
1437
|
}
|
1438
|
+
|
1381
1439
|
delete this.element.dropzone;
|
1382
1440
|
return Dropzone.instances.splice(Dropzone.instances.indexOf(this), 1);
|
1383
1441
|
}
|
1384
1442
|
}, {
|
1385
1443
|
key: "updateTotalUploadProgress",
|
1386
1444
|
value: function updateTotalUploadProgress() {
|
1387
|
-
var totalUploadProgress
|
1445
|
+
var totalUploadProgress;
|
1388
1446
|
var totalBytesSent = 0;
|
1389
1447
|
var totalBytes = 0;
|
1390
|
-
|
1391
1448
|
var activeFiles = this.getActiveFiles();
|
1392
1449
|
|
1393
1450
|
if (activeFiles.length) {
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1451
|
+
var _iteratorNormalCompletion11 = true;
|
1452
|
+
var _didIteratorError11 = false;
|
1453
|
+
var _iteratorError11 = undefined;
|
1454
|
+
|
1455
|
+
try {
|
1456
|
+
for (var _iterator11 = this.getActiveFiles()[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
|
1457
|
+
var file = _step11.value;
|
1458
|
+
totalBytesSent += file.upload.bytesSent;
|
1459
|
+
totalBytes += file.upload.total;
|
1460
|
+
}
|
1461
|
+
} catch (err) {
|
1462
|
+
_didIteratorError11 = true;
|
1463
|
+
_iteratorError11 = err;
|
1464
|
+
} finally {
|
1465
|
+
try {
|
1466
|
+
if (!_iteratorNormalCompletion11 && _iterator11["return"] != null) {
|
1467
|
+
_iterator11["return"]();
|
1468
|
+
}
|
1469
|
+
} finally {
|
1470
|
+
if (_didIteratorError11) {
|
1471
|
+
throw _iteratorError11;
|
1472
|
+
}
|
1404
1473
|
}
|
1405
|
-
|
1406
|
-
var file = _ref11;
|
1407
|
-
|
1408
|
-
totalBytesSent += file.upload.bytesSent;
|
1409
|
-
totalBytes += file.upload.total;
|
1410
1474
|
}
|
1475
|
+
|
1411
1476
|
totalUploadProgress = 100 * totalBytesSent / totalBytes;
|
1412
1477
|
} else {
|
1413
1478
|
totalUploadProgress = 100;
|
1414
1479
|
}
|
1415
1480
|
|
1416
1481
|
return this.emit("totaluploadprogress", totalUploadProgress, totalBytes, totalBytesSent);
|
1417
|
-
}
|
1418
|
-
|
1419
|
-
// @options.paramName can be a function taking one parameter rather than a string.
|
1482
|
+
} // @options.paramName can be a function taking one parameter rather than a string.
|
1420
1483
|
// A parameter name for a file is obtained simply by calling this with an index number.
|
1421
1484
|
|
1422
1485
|
}, {
|
@@ -1425,11 +1488,9 @@ var Dropzone = function (_Emitter) {
|
|
1425
1488
|
if (typeof this.options.paramName === "function") {
|
1426
1489
|
return this.options.paramName(n);
|
1427
1490
|
} else {
|
1428
|
-
return ""
|
1491
|
+
return "".concat(this.options.paramName).concat(this.options.uploadMultiple ? "[".concat(n, "]") : "");
|
1429
1492
|
}
|
1430
|
-
}
|
1431
|
-
|
1432
|
-
// If @options.renameFile is a function,
|
1493
|
+
} // If @options.renameFile is a function,
|
1433
1494
|
// the function will be used to rename the file.name before appending it to the formData
|
1434
1495
|
|
1435
1496
|
}, {
|
@@ -1438,10 +1499,9 @@ var Dropzone = function (_Emitter) {
|
|
1438
1499
|
if (typeof this.options.renameFile !== "function") {
|
1439
1500
|
return file.name;
|
1440
1501
|
}
|
1441
|
-
return this.options.renameFile(file);
|
1442
|
-
}
|
1443
1502
|
|
1444
|
-
|
1503
|
+
return this.options.renameFile(file);
|
1504
|
+
} // Returns a form that can be used as fallback if the browser does not support DragnDrop
|
1445
1505
|
//
|
1446
1506
|
// If the dropzone is already a form, only the input field and button are returned. Otherwise a complete form element is provided.
|
1447
1507
|
// This code has to pass in IE7 :(
|
@@ -1449,31 +1509,32 @@ var Dropzone = function (_Emitter) {
|
|
1449
1509
|
}, {
|
1450
1510
|
key: "getFallbackForm",
|
1451
1511
|
value: function getFallbackForm() {
|
1452
|
-
var existingFallback
|
1453
|
-
|
1512
|
+
var existingFallback, form;
|
1513
|
+
|
1454
1514
|
if (existingFallback = this.getExistingFallback()) {
|
1455
1515
|
return existingFallback;
|
1456
1516
|
}
|
1457
1517
|
|
1458
1518
|
var fieldsString = "<div class=\"dz-fallback\">";
|
1519
|
+
|
1459
1520
|
if (this.options.dictFallbackText) {
|
1460
|
-
fieldsString += "<p>"
|
1521
|
+
fieldsString += "<p>".concat(this.options.dictFallbackText, "</p>");
|
1461
1522
|
}
|
1462
|
-
fieldsString += "<input type=\"file\" name=\"" + this._getParamName(0) + "\" " + (this.options.uploadMultiple ? 'multiple="multiple"' : undefined) + " /><input type=\"submit\" value=\"Upload!\"></div>";
|
1463
1523
|
|
1524
|
+
fieldsString += "<input type=\"file\" name=\"".concat(this._getParamName(0), "\" ").concat(this.options.uploadMultiple ? 'multiple="multiple"' : undefined, " /><input type=\"submit\" value=\"Upload!\"></div>");
|
1464
1525
|
var fields = Dropzone.createElement(fieldsString);
|
1526
|
+
|
1465
1527
|
if (this.element.tagName !== "FORM") {
|
1466
|
-
form = Dropzone.createElement("<form action=\""
|
1528
|
+
form = Dropzone.createElement("<form action=\"".concat(this.options.url, "\" enctype=\"multipart/form-data\" method=\"").concat(this.options.method, "\"></form>"));
|
1467
1529
|
form.appendChild(fields);
|
1468
1530
|
} else {
|
1469
1531
|
// Make sure that the enctype and method attributes are set properly
|
1470
1532
|
this.element.setAttribute("enctype", "multipart/form-data");
|
1471
1533
|
this.element.setAttribute("method", this.options.method);
|
1472
1534
|
}
|
1473
|
-
return form != null ? form : fields;
|
1474
|
-
}
|
1475
1535
|
|
1476
|
-
|
1536
|
+
return form != null ? form : fields;
|
1537
|
+
} // Returns the fallback elements if they exist already
|
1477
1538
|
//
|
1478
1539
|
// This code has to pass in IE7 :(
|
1479
1540
|
|
@@ -1481,37 +1542,43 @@ var Dropzone = function (_Emitter) {
|
|
1481
1542
|
key: "getExistingFallback",
|
1482
1543
|
value: function getExistingFallback() {
|
1483
1544
|
var getFallback = function getFallback(elements) {
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
if (_isArray13) {
|
1488
|
-
if (_i13 >= _iterator13.length) break;
|
1489
|
-
_ref12 = _iterator13[_i13++];
|
1490
|
-
} else {
|
1491
|
-
_i13 = _iterator13.next();
|
1492
|
-
if (_i13.done) break;
|
1493
|
-
_ref12 = _i13.value;
|
1494
|
-
}
|
1545
|
+
var _iteratorNormalCompletion12 = true;
|
1546
|
+
var _didIteratorError12 = false;
|
1547
|
+
var _iteratorError12 = undefined;
|
1495
1548
|
|
1496
|
-
|
1549
|
+
try {
|
1550
|
+
for (var _iterator12 = elements[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
|
1551
|
+
var el = _step12.value;
|
1497
1552
|
|
1498
|
-
|
1499
|
-
|
1553
|
+
if (/(^| )fallback($| )/.test(el.className)) {
|
1554
|
+
return el;
|
1555
|
+
}
|
1556
|
+
}
|
1557
|
+
} catch (err) {
|
1558
|
+
_didIteratorError12 = true;
|
1559
|
+
_iteratorError12 = err;
|
1560
|
+
} finally {
|
1561
|
+
try {
|
1562
|
+
if (!_iteratorNormalCompletion12 && _iterator12["return"] != null) {
|
1563
|
+
_iterator12["return"]();
|
1564
|
+
}
|
1565
|
+
} finally {
|
1566
|
+
if (_didIteratorError12) {
|
1567
|
+
throw _iteratorError12;
|
1568
|
+
}
|
1500
1569
|
}
|
1501
1570
|
}
|
1502
1571
|
};
|
1503
1572
|
|
1504
|
-
var _arr = ["div", "form"];
|
1505
|
-
|
1506
|
-
var tagName = _arr[_i14];
|
1573
|
+
for (var _i2 = 0, _arr = ["div", "form"]; _i2 < _arr.length; _i2++) {
|
1574
|
+
var tagName = _arr[_i2];
|
1507
1575
|
var fallback;
|
1576
|
+
|
1508
1577
|
if (fallback = getFallback(this.element.getElementsByTagName(tagName))) {
|
1509
1578
|
return fallback;
|
1510
1579
|
}
|
1511
1580
|
}
|
1512
|
-
}
|
1513
|
-
|
1514
|
-
// Activates all listeners stored in @listeners
|
1581
|
+
} // Activates all listeners stored in @listeners
|
1515
1582
|
|
1516
1583
|
}, {
|
1517
1584
|
key: "setupEventListeners",
|
@@ -1519,16 +1586,16 @@ var Dropzone = function (_Emitter) {
|
|
1519
1586
|
return this.listeners.map(function (elementListeners) {
|
1520
1587
|
return function () {
|
1521
1588
|
var result = [];
|
1589
|
+
|
1522
1590
|
for (var event in elementListeners.events) {
|
1523
1591
|
var listener = elementListeners.events[event];
|
1524
1592
|
result.push(elementListeners.element.addEventListener(event, listener, false));
|
1525
1593
|
}
|
1594
|
+
|
1526
1595
|
return result;
|
1527
1596
|
}();
|
1528
1597
|
});
|
1529
|
-
}
|
1530
|
-
|
1531
|
-
// Deactivates all listeners stored in @listeners
|
1598
|
+
} // Deactivates all listeners stored in @listeners
|
1532
1599
|
|
1533
1600
|
}, {
|
1534
1601
|
key: "removeEventListeners",
|
@@ -1536,16 +1603,16 @@ var Dropzone = function (_Emitter) {
|
|
1536
1603
|
return this.listeners.map(function (elementListeners) {
|
1537
1604
|
return function () {
|
1538
1605
|
var result = [];
|
1606
|
+
|
1539
1607
|
for (var event in elementListeners.events) {
|
1540
1608
|
var listener = elementListeners.events[event];
|
1541
1609
|
result.push(elementListeners.element.removeEventListener(event, listener, false));
|
1542
1610
|
}
|
1611
|
+
|
1543
1612
|
return result;
|
1544
1613
|
}();
|
1545
1614
|
});
|
1546
|
-
}
|
1547
|
-
|
1548
|
-
// Removes all event listeners and cancels all files in the queue or being processed.
|
1615
|
+
} // Removes all event listeners and cancels all files in the queue or being processed.
|
1549
1616
|
|
1550
1617
|
}, {
|
1551
1618
|
key: "disable",
|
@@ -1557,7 +1624,6 @@ var Dropzone = function (_Emitter) {
|
|
1557
1624
|
});
|
1558
1625
|
this.removeEventListeners();
|
1559
1626
|
this.disabled = true;
|
1560
|
-
|
1561
1627
|
return this.files.map(function (file) {
|
1562
1628
|
return _this4.cancelUpload(file);
|
1563
1629
|
});
|
@@ -1570,9 +1636,7 @@ var Dropzone = function (_Emitter) {
|
|
1570
1636
|
return element.classList.add("dz-clickable");
|
1571
1637
|
});
|
1572
1638
|
return this.setupEventListeners();
|
1573
|
-
}
|
1574
|
-
|
1575
|
-
// Returns a nicely formatted filesize
|
1639
|
+
} // Returns a nicely formatted filesize
|
1576
1640
|
|
1577
1641
|
}, {
|
1578
1642
|
key: "filesize",
|
@@ -1597,10 +1661,8 @@ var Dropzone = function (_Emitter) {
|
|
1597
1661
|
selectedSize = Math.round(10 * selectedSize) / 10; // Cutting of digits
|
1598
1662
|
}
|
1599
1663
|
|
1600
|
-
return "<strong>"
|
1601
|
-
}
|
1602
|
-
|
1603
|
-
// Adds or removes the `dz-max-files-reached` class from the form.
|
1664
|
+
return "<strong>".concat(selectedSize, "</strong> ").concat(this.options.dictFileSizeUnits[selectedUnit]);
|
1665
|
+
} // Adds or removes the `dz-max-files-reached` class from the form.
|
1604
1666
|
|
1605
1667
|
}, {
|
1606
1668
|
key: "_updateMaxFilesReachedClass",
|
@@ -1609,6 +1671,7 @@ var Dropzone = function (_Emitter) {
|
|
1609
1671
|
if (this.getAcceptedFiles().length === this.options.maxFiles) {
|
1610
1672
|
this.emit('maxfilesreached', this.files);
|
1611
1673
|
}
|
1674
|
+
|
1612
1675
|
return this.element.classList.add("dz-max-files-reached");
|
1613
1676
|
} else {
|
1614
1677
|
return this.element.classList.remove("dz-max-files-reached");
|
@@ -1620,18 +1683,17 @@ var Dropzone = function (_Emitter) {
|
|
1620
1683
|
if (!e.dataTransfer) {
|
1621
1684
|
return;
|
1622
1685
|
}
|
1623
|
-
this.emit("drop", e);
|
1624
1686
|
|
1625
|
-
// Convert the FileList to an Array
|
1687
|
+
this.emit("drop", e); // Convert the FileList to an Array
|
1626
1688
|
// This is necessary for IE11
|
1689
|
+
|
1627
1690
|
var files = [];
|
1691
|
+
|
1628
1692
|
for (var i = 0; i < e.dataTransfer.files.length; i++) {
|
1629
1693
|
files[i] = e.dataTransfer.files[i];
|
1630
|
-
}
|
1694
|
+
} // Even if it's a folder, files.length will contain the folders.
|
1631
1695
|
|
1632
|
-
this.emit("addedfiles", files);
|
1633
1696
|
|
1634
|
-
// Even if it's a folder, files.length will contain the folders.
|
1635
1697
|
if (files.length) {
|
1636
1698
|
var items = e.dataTransfer.items;
|
1637
1699
|
|
@@ -1642,6 +1704,8 @@ var Dropzone = function (_Emitter) {
|
|
1642
1704
|
this.handleFiles(files);
|
1643
1705
|
}
|
1644
1706
|
}
|
1707
|
+
|
1708
|
+
this.emit("addedfiles", files);
|
1645
1709
|
}
|
1646
1710
|
}, {
|
1647
1711
|
key: "paste",
|
@@ -1655,7 +1719,6 @@ var Dropzone = function (_Emitter) {
|
|
1655
1719
|
this.emit("paste", e);
|
1656
1720
|
var items = e.clipboardData.items;
|
1657
1721
|
|
1658
|
-
|
1659
1722
|
if (items.length) {
|
1660
1723
|
return this._addFilesFromItems(items);
|
1661
1724
|
}
|
@@ -1663,25 +1726,30 @@ var Dropzone = function (_Emitter) {
|
|
1663
1726
|
}, {
|
1664
1727
|
key: "handleFiles",
|
1665
1728
|
value: function handleFiles(files) {
|
1666
|
-
|
1667
|
-
|
1729
|
+
var _iteratorNormalCompletion13 = true;
|
1730
|
+
var _didIteratorError13 = false;
|
1731
|
+
var _iteratorError13 = undefined;
|
1668
1732
|
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1733
|
+
try {
|
1734
|
+
for (var _iterator13 = files[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
|
1735
|
+
var file = _step13.value;
|
1736
|
+
this.addFile(file);
|
1737
|
+
}
|
1738
|
+
} catch (err) {
|
1739
|
+
_didIteratorError13 = true;
|
1740
|
+
_iteratorError13 = err;
|
1741
|
+
} finally {
|
1742
|
+
try {
|
1743
|
+
if (!_iteratorNormalCompletion13 && _iterator13["return"] != null) {
|
1744
|
+
_iterator13["return"]();
|
1745
|
+
}
|
1746
|
+
} finally {
|
1747
|
+
if (_didIteratorError13) {
|
1748
|
+
throw _iteratorError13;
|
1749
|
+
}
|
1676
1750
|
}
|
1677
|
-
|
1678
|
-
var file = _ref13;
|
1679
|
-
|
1680
|
-
this.addFile(file);
|
1681
1751
|
}
|
1682
|
-
}
|
1683
|
-
|
1684
|
-
// When a folder is dropped (or files are pasted), items must be handled
|
1752
|
+
} // When a folder is dropped (or files are pasted), items must be handled
|
1685
1753
|
// instead of files.
|
1686
1754
|
|
1687
1755
|
}, {
|
@@ -1691,45 +1759,52 @@ var Dropzone = function (_Emitter) {
|
|
1691
1759
|
|
1692
1760
|
return function () {
|
1693
1761
|
var result = [];
|
1694
|
-
|
1695
|
-
|
1762
|
+
var _iteratorNormalCompletion14 = true;
|
1763
|
+
var _didIteratorError14 = false;
|
1764
|
+
var _iteratorError14 = undefined;
|
1696
1765
|
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
_i16 = _iterator15.next();
|
1702
|
-
if (_i16.done) break;
|
1703
|
-
_ref14 = _i16.value;
|
1704
|
-
}
|
1766
|
+
try {
|
1767
|
+
for (var _iterator14 = items[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {
|
1768
|
+
var item = _step14.value;
|
1769
|
+
var entry;
|
1705
1770
|
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1771
|
+
if (item.webkitGetAsEntry != null && (entry = item.webkitGetAsEntry())) {
|
1772
|
+
if (entry.isFile) {
|
1773
|
+
result.push(_this5.addFile(item.getAsFile()));
|
1774
|
+
} else if (entry.isDirectory) {
|
1775
|
+
// Append all files from that directory to files
|
1776
|
+
result.push(_this5._addFilesFromDirectory(entry, entry.name));
|
1777
|
+
} else {
|
1778
|
+
result.push(undefined);
|
1779
|
+
}
|
1780
|
+
} else if (item.getAsFile != null) {
|
1781
|
+
if (item.kind == null || item.kind === "file") {
|
1782
|
+
result.push(_this5.addFile(item.getAsFile()));
|
1783
|
+
} else {
|
1784
|
+
result.push(undefined);
|
1785
|
+
}
|
1715
1786
|
} else {
|
1716
1787
|
result.push(undefined);
|
1717
1788
|
}
|
1718
|
-
}
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1789
|
+
}
|
1790
|
+
} catch (err) {
|
1791
|
+
_didIteratorError14 = true;
|
1792
|
+
_iteratorError14 = err;
|
1793
|
+
} finally {
|
1794
|
+
try {
|
1795
|
+
if (!_iteratorNormalCompletion14 && _iterator14["return"] != null) {
|
1796
|
+
_iterator14["return"]();
|
1797
|
+
}
|
1798
|
+
} finally {
|
1799
|
+
if (_didIteratorError14) {
|
1800
|
+
throw _iteratorError14;
|
1723
1801
|
}
|
1724
|
-
} else {
|
1725
|
-
result.push(undefined);
|
1726
1802
|
}
|
1727
1803
|
}
|
1804
|
+
|
1728
1805
|
return result;
|
1729
1806
|
}();
|
1730
|
-
}
|
1731
|
-
|
1732
|
-
// Goes through the directory, and adds each file it finds recursively
|
1807
|
+
} // Goes through the directory, and adds each file it finds recursively
|
1733
1808
|
|
1734
1809
|
}, {
|
1735
1810
|
key: "_addFilesFromDirectory",
|
@@ -1747,46 +1822,54 @@ var Dropzone = function (_Emitter) {
|
|
1747
1822
|
var readEntries = function readEntries() {
|
1748
1823
|
return dirReader.readEntries(function (entries) {
|
1749
1824
|
if (entries.length > 0) {
|
1750
|
-
|
1751
|
-
|
1825
|
+
var _iteratorNormalCompletion15 = true;
|
1826
|
+
var _didIteratorError15 = false;
|
1827
|
+
var _iteratorError15 = undefined;
|
1752
1828
|
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
} else {
|
1757
|
-
_i17 = _iterator16.next();
|
1758
|
-
if (_i17.done) break;
|
1759
|
-
_ref15 = _i17.value;
|
1760
|
-
}
|
1829
|
+
try {
|
1830
|
+
for (var _iterator15 = entries[Symbol.iterator](), _step15; !(_iteratorNormalCompletion15 = (_step15 = _iterator15.next()).done); _iteratorNormalCompletion15 = true) {
|
1831
|
+
var entry = _step15.value;
|
1761
1832
|
|
1762
|
-
|
1833
|
+
if (entry.isFile) {
|
1834
|
+
entry.file(function (file) {
|
1835
|
+
if (_this6.options.ignoreHiddenFiles && file.name.substring(0, 1) === '.') {
|
1836
|
+
return;
|
1837
|
+
}
|
1763
1838
|
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1839
|
+
file.fullPath = "".concat(path, "/").concat(file.name);
|
1840
|
+
return _this6.addFile(file);
|
1841
|
+
});
|
1842
|
+
} else if (entry.isDirectory) {
|
1843
|
+
_this6._addFilesFromDirectory(entry, "".concat(path, "/").concat(entry.name));
|
1844
|
+
}
|
1845
|
+
} // Recursively call readEntries() again, since browser only handle
|
1846
|
+
// the first 100 entries.
|
1847
|
+
// See: https://developer.mozilla.org/en-US/docs/Web/API/DirectoryReader#readEntries
|
1848
|
+
|
1849
|
+
} catch (err) {
|
1850
|
+
_didIteratorError15 = true;
|
1851
|
+
_iteratorError15 = err;
|
1852
|
+
} finally {
|
1853
|
+
try {
|
1854
|
+
if (!_iteratorNormalCompletion15 && _iterator15["return"] != null) {
|
1855
|
+
_iterator15["return"]();
|
1856
|
+
}
|
1857
|
+
} finally {
|
1858
|
+
if (_didIteratorError15) {
|
1859
|
+
throw _iteratorError15;
|
1860
|
+
}
|
1774
1861
|
}
|
1775
1862
|
}
|
1776
1863
|
|
1777
|
-
// Recursively call readEntries() again, since browser only handle
|
1778
|
-
// the first 100 entries.
|
1779
|
-
// See: https://developer.mozilla.org/en-US/docs/Web/API/DirectoryReader#readEntries
|
1780
1864
|
readEntries();
|
1781
1865
|
}
|
1866
|
+
|
1782
1867
|
return null;
|
1783
1868
|
}, errorHandler);
|
1784
1869
|
};
|
1785
1870
|
|
1786
1871
|
return readEntries();
|
1787
|
-
}
|
1788
|
-
|
1789
|
-
// If `done()` is called without argument the file is accepted
|
1872
|
+
} // If `done()` is called without argument the file is accepted
|
1790
1873
|
// If you call it with an error message, the file is rejected
|
1791
1874
|
// (This allows for asynchronous validation)
|
1792
1875
|
//
|
@@ -1797,14 +1880,14 @@ var Dropzone = function (_Emitter) {
|
|
1797
1880
|
key: "accept",
|
1798
1881
|
value: function accept(file, done) {
|
1799
1882
|
if (this.options.maxFilesize && file.size > this.options.maxFilesize * 1024 * 1024) {
|
1800
|
-
|
1883
|
+
done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize));
|
1801
1884
|
} else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) {
|
1802
|
-
|
1885
|
+
done(this.options.dictInvalidFileType);
|
1803
1886
|
} else if (this.options.maxFiles != null && this.getAcceptedFiles().length >= this.options.maxFiles) {
|
1804
1887
|
done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}", this.options.maxFiles));
|
1805
|
-
|
1888
|
+
this.emit("maxfilesexceeded", file);
|
1806
1889
|
} else {
|
1807
|
-
|
1890
|
+
this.options.accept.call(this, file, done);
|
1808
1891
|
}
|
1809
1892
|
}
|
1810
1893
|
}, {
|
@@ -1819,53 +1902,63 @@ var Dropzone = function (_Emitter) {
|
|
1819
1902
|
// It's actual different than the size to be transmitted.
|
1820
1903
|
total: file.size,
|
1821
1904
|
bytesSent: 0,
|
1822
|
-
filename: this._renameFile(file),
|
1823
|
-
|
1824
|
-
|
1905
|
+
filename: this._renameFile(file) // Not setting chunking information here, because the acutal data — and
|
1906
|
+
// thus the chunks — might change if `options.transformFile` is set
|
1907
|
+
// and does something to the data.
|
1908
|
+
|
1825
1909
|
};
|
1826
1910
|
this.files.push(file);
|
1827
|
-
|
1828
1911
|
file.status = Dropzone.ADDED;
|
1829
|
-
|
1830
1912
|
this.emit("addedfile", file);
|
1831
1913
|
|
1832
1914
|
this._enqueueThumbnail(file);
|
1833
1915
|
|
1834
|
-
|
1916
|
+
this.accept(file, function (error) {
|
1835
1917
|
if (error) {
|
1836
1918
|
file.accepted = false;
|
1919
|
+
|
1837
1920
|
_this7._errorProcessing([file], error); // Will set the file.status
|
1921
|
+
|
1838
1922
|
} else {
|
1839
1923
|
file.accepted = true;
|
1924
|
+
|
1840
1925
|
if (_this7.options.autoQueue) {
|
1841
1926
|
_this7.enqueueFile(file);
|
1842
1927
|
} // Will set .accepted = true
|
1928
|
+
|
1843
1929
|
}
|
1844
|
-
return _this7._updateMaxFilesReachedClass();
|
1845
|
-
});
|
1846
|
-
}
|
1847
1930
|
|
1848
|
-
|
1931
|
+
_this7._updateMaxFilesReachedClass();
|
1932
|
+
});
|
1933
|
+
} // Wrapper for enqueueFile
|
1849
1934
|
|
1850
1935
|
}, {
|
1851
1936
|
key: "enqueueFiles",
|
1852
1937
|
value: function enqueueFiles(files) {
|
1853
|
-
|
1854
|
-
|
1938
|
+
var _iteratorNormalCompletion16 = true;
|
1939
|
+
var _didIteratorError16 = false;
|
1940
|
+
var _iteratorError16 = undefined;
|
1855
1941
|
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1942
|
+
try {
|
1943
|
+
for (var _iterator16 = files[Symbol.iterator](), _step16; !(_iteratorNormalCompletion16 = (_step16 = _iterator16.next()).done); _iteratorNormalCompletion16 = true) {
|
1944
|
+
var file = _step16.value;
|
1945
|
+
this.enqueueFile(file);
|
1946
|
+
}
|
1947
|
+
} catch (err) {
|
1948
|
+
_didIteratorError16 = true;
|
1949
|
+
_iteratorError16 = err;
|
1950
|
+
} finally {
|
1951
|
+
try {
|
1952
|
+
if (!_iteratorNormalCompletion16 && _iterator16["return"] != null) {
|
1953
|
+
_iterator16["return"]();
|
1954
|
+
}
|
1955
|
+
} finally {
|
1956
|
+
if (_didIteratorError16) {
|
1957
|
+
throw _iteratorError16;
|
1958
|
+
}
|
1863
1959
|
}
|
1864
|
-
|
1865
|
-
var file = _ref16;
|
1866
|
-
|
1867
|
-
this.enqueueFile(file);
|
1868
1960
|
}
|
1961
|
+
|
1869
1962
|
return null;
|
1870
1963
|
}
|
1871
1964
|
}, {
|
@@ -1875,6 +1968,7 @@ var Dropzone = function (_Emitter) {
|
|
1875
1968
|
|
1876
1969
|
if (file.status === Dropzone.ADDED && file.accepted === true) {
|
1877
1970
|
file.status = Dropzone.QUEUED;
|
1971
|
+
|
1878
1972
|
if (this.options.autoProcessQueue) {
|
1879
1973
|
return setTimeout(function () {
|
1880
1974
|
return _this8.processQueue();
|
@@ -1891,6 +1985,7 @@ var Dropzone = function (_Emitter) {
|
|
1891
1985
|
|
1892
1986
|
if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1024 * 1024) {
|
1893
1987
|
this._thumbnailQueue.push(file);
|
1988
|
+
|
1894
1989
|
return setTimeout(function () {
|
1895
1990
|
return _this9._processThumbnailQueue();
|
1896
1991
|
}, 0); // Deferring the call
|
@@ -1906,15 +2001,16 @@ var Dropzone = function (_Emitter) {
|
|
1906
2001
|
}
|
1907
2002
|
|
1908
2003
|
this._processingThumbnail = true;
|
2004
|
+
|
1909
2005
|
var file = this._thumbnailQueue.shift();
|
2006
|
+
|
1910
2007
|
return this.createThumbnail(file, this.options.thumbnailWidth, this.options.thumbnailHeight, this.options.thumbnailMethod, true, function (dataUrl) {
|
1911
2008
|
_this10.emit("thumbnail", file, dataUrl);
|
2009
|
+
|
1912
2010
|
_this10._processingThumbnail = false;
|
1913
2011
|
return _this10._processThumbnailQueue();
|
1914
2012
|
});
|
1915
|
-
}
|
1916
|
-
|
1917
|
-
// Can be called by the user to remove a file
|
2013
|
+
} // Can be called by the user to remove a file
|
1918
2014
|
|
1919
2015
|
}, {
|
1920
2016
|
key: "removeFile",
|
@@ -1922,15 +2018,14 @@ var Dropzone = function (_Emitter) {
|
|
1922
2018
|
if (file.status === Dropzone.UPLOADING) {
|
1923
2019
|
this.cancelUpload(file);
|
1924
2020
|
}
|
1925
|
-
this.files = without(this.files, file);
|
1926
2021
|
|
2022
|
+
this.files = without(this.files, file);
|
1927
2023
|
this.emit("removedfile", file);
|
2024
|
+
|
1928
2025
|
if (this.files.length === 0) {
|
1929
2026
|
return this.emit("reset");
|
1930
2027
|
}
|
1931
|
-
}
|
1932
|
-
|
1933
|
-
// Removes all files that aren't currently processed from the list
|
2028
|
+
} // Removes all files that aren't currently processed from the list
|
1934
2029
|
|
1935
2030
|
}, {
|
1936
2031
|
key: "removeAllFiles",
|
@@ -1939,28 +2034,36 @@ var Dropzone = function (_Emitter) {
|
|
1939
2034
|
if (cancelIfNecessary == null) {
|
1940
2035
|
cancelIfNecessary = false;
|
1941
2036
|
}
|
1942
|
-
for (var _iterator18 = this.files.slice(), _isArray18 = true, _i19 = 0, _iterator18 = _isArray18 ? _iterator18 : _iterator18[Symbol.iterator]();;) {
|
1943
|
-
var _ref17;
|
1944
2037
|
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
} else {
|
1949
|
-
_i19 = _iterator18.next();
|
1950
|
-
if (_i19.done) break;
|
1951
|
-
_ref17 = _i19.value;
|
1952
|
-
}
|
2038
|
+
var _iteratorNormalCompletion17 = true;
|
2039
|
+
var _didIteratorError17 = false;
|
2040
|
+
var _iteratorError17 = undefined;
|
1953
2041
|
|
1954
|
-
|
2042
|
+
try {
|
2043
|
+
for (var _iterator17 = this.files.slice()[Symbol.iterator](), _step17; !(_iteratorNormalCompletion17 = (_step17 = _iterator17.next()).done); _iteratorNormalCompletion17 = true) {
|
2044
|
+
var file = _step17.value;
|
1955
2045
|
|
1956
|
-
|
1957
|
-
|
2046
|
+
if (file.status !== Dropzone.UPLOADING || cancelIfNecessary) {
|
2047
|
+
this.removeFile(file);
|
2048
|
+
}
|
2049
|
+
}
|
2050
|
+
} catch (err) {
|
2051
|
+
_didIteratorError17 = true;
|
2052
|
+
_iteratorError17 = err;
|
2053
|
+
} finally {
|
2054
|
+
try {
|
2055
|
+
if (!_iteratorNormalCompletion17 && _iterator17["return"] != null) {
|
2056
|
+
_iterator17["return"]();
|
2057
|
+
}
|
2058
|
+
} finally {
|
2059
|
+
if (_didIteratorError17) {
|
2060
|
+
throw _iteratorError17;
|
2061
|
+
}
|
1958
2062
|
}
|
1959
2063
|
}
|
1960
|
-
return null;
|
1961
|
-
}
|
1962
2064
|
|
1963
|
-
|
2065
|
+
return null;
|
2066
|
+
} // Resizes an image before it gets sent to the server. This function is the default behavior of
|
1964
2067
|
// `options.transformFile` if `resizeWidth` or `resizeHeight` are set. The callback is invoked with
|
1965
2068
|
// the resized blob.
|
1966
2069
|
|
@@ -1979,11 +2082,14 @@ var Dropzone = function (_Emitter) {
|
|
1979
2082
|
if (resizeMimeType == null) {
|
1980
2083
|
resizeMimeType = file.type;
|
1981
2084
|
}
|
2085
|
+
|
1982
2086
|
var resizedDataURL = canvas.toDataURL(resizeMimeType, _this11.options.resizeQuality);
|
2087
|
+
|
1983
2088
|
if (resizeMimeType === 'image/jpeg' || resizeMimeType === 'image/jpg') {
|
1984
2089
|
// Now add the original EXIF information
|
1985
2090
|
resizedDataURL = ExifRestore.restore(file.dataURL, resizedDataURL);
|
1986
2091
|
}
|
2092
|
+
|
1987
2093
|
return callback(Dropzone.dataURItoBlob(resizedDataURL));
|
1988
2094
|
}
|
1989
2095
|
});
|
@@ -1996,26 +2102,54 @@ var Dropzone = function (_Emitter) {
|
|
1996
2102
|
var fileReader = new FileReader();
|
1997
2103
|
|
1998
2104
|
fileReader.onload = function () {
|
2105
|
+
file.dataURL = fileReader.result; // Don't bother creating a thumbnail for SVG images since they're vector
|
1999
2106
|
|
2000
|
-
file.dataURL = fileReader.result;
|
2001
|
-
|
2002
|
-
// Don't bother creating a thumbnail for SVG images since they're vector
|
2003
2107
|
if (file.type === "image/svg+xml") {
|
2004
2108
|
if (callback != null) {
|
2005
2109
|
callback(fileReader.result);
|
2006
2110
|
}
|
2111
|
+
|
2007
2112
|
return;
|
2008
2113
|
}
|
2009
2114
|
|
2010
|
-
|
2115
|
+
_this12.createThumbnailFromUrl(file, width, height, resizeMethod, fixOrientation, callback);
|
2011
2116
|
};
|
2012
2117
|
|
2013
|
-
|
2118
|
+
fileReader.readAsDataURL(file);
|
2119
|
+
} // `mockFile` needs to have these attributes:
|
2120
|
+
//
|
2121
|
+
// { name: 'name', size: 12345, imageUrl: '' }
|
2122
|
+
//
|
2123
|
+
// `callback` will be invoked when the image has been downloaded and displayed.
|
2124
|
+
// `crossOrigin` will be added to the `img` tag when accessing the file.
|
2125
|
+
|
2126
|
+
}, {
|
2127
|
+
key: "displayExistingFile",
|
2128
|
+
value: function displayExistingFile(mockFile, imageUrl, callback, crossOrigin) {
|
2129
|
+
var _this13 = this;
|
2130
|
+
|
2131
|
+
var resizeThumbnail = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
2132
|
+
this.emit("addedfile", mockFile);
|
2133
|
+
this.emit("complete", mockFile);
|
2134
|
+
|
2135
|
+
if (!resizeThumbnail) {
|
2136
|
+
this.emit("thumbnail", mockFile, imageUrl);
|
2137
|
+
if (callback) callback();
|
2138
|
+
} else {
|
2139
|
+
var onDone = function onDone(thumbnail) {
|
2140
|
+
_this13.emit('thumbnail', mockFile, thumbnail);
|
2141
|
+
|
2142
|
+
if (callback) callback();
|
2143
|
+
};
|
2144
|
+
|
2145
|
+
mockFile.dataURL = imageUrl;
|
2146
|
+
this.createThumbnailFromUrl(mockFile, this.options.thumbnailWidth, this.options.thumbnailHeight, this.options.resizeMethod, this.options.fixOrientation, onDone, crossOrigin);
|
2147
|
+
}
|
2014
2148
|
}
|
2015
2149
|
}, {
|
2016
2150
|
key: "createThumbnailFromUrl",
|
2017
2151
|
value: function createThumbnailFromUrl(file, width, height, resizeMethod, fixOrientation, callback, crossOrigin) {
|
2018
|
-
var
|
2152
|
+
var _this14 = this;
|
2019
2153
|
|
2020
2154
|
// Not using `new Image` here because of a bug in latest Chrome versions.
|
2021
2155
|
// See https://github.com/enyo/dropzone/pull/226
|
@@ -2029,6 +2163,7 @@ var Dropzone = function (_Emitter) {
|
|
2029
2163
|
var loadExif = function loadExif(callback) {
|
2030
2164
|
return callback(1);
|
2031
2165
|
};
|
2166
|
+
|
2032
2167
|
if (typeof EXIF !== 'undefined' && EXIF !== null && fixOrientation) {
|
2033
2168
|
loadExif = function loadExif(callback) {
|
2034
2169
|
return EXIF.getData(img, function () {
|
@@ -2041,11 +2176,10 @@ var Dropzone = function (_Emitter) {
|
|
2041
2176
|
file.width = img.width;
|
2042
2177
|
file.height = img.height;
|
2043
2178
|
|
2044
|
-
var resizeInfo =
|
2179
|
+
var resizeInfo = _this14.options.resize.call(_this14, file, width, height, resizeMethod);
|
2045
2180
|
|
2046
2181
|
var canvas = document.createElement("canvas");
|
2047
2182
|
var ctx = canvas.getContext("2d");
|
2048
|
-
|
2049
2183
|
canvas.width = resizeInfo.trgWidth;
|
2050
2184
|
canvas.height = resizeInfo.trgHeight;
|
2051
2185
|
|
@@ -2060,42 +2194,47 @@ var Dropzone = function (_Emitter) {
|
|
2060
2194
|
ctx.translate(canvas.width, 0);
|
2061
2195
|
ctx.scale(-1, 1);
|
2062
2196
|
break;
|
2197
|
+
|
2063
2198
|
case 3:
|
2064
2199
|
// 180° rotate left
|
2065
2200
|
ctx.translate(canvas.width, canvas.height);
|
2066
2201
|
ctx.rotate(Math.PI);
|
2067
2202
|
break;
|
2203
|
+
|
2068
2204
|
case 4:
|
2069
2205
|
// vertical flip
|
2070
2206
|
ctx.translate(0, canvas.height);
|
2071
2207
|
ctx.scale(1, -1);
|
2072
2208
|
break;
|
2209
|
+
|
2073
2210
|
case 5:
|
2074
2211
|
// vertical flip + 90 rotate right
|
2075
2212
|
ctx.rotate(0.5 * Math.PI);
|
2076
2213
|
ctx.scale(1, -1);
|
2077
2214
|
break;
|
2215
|
+
|
2078
2216
|
case 6:
|
2079
2217
|
// 90° rotate right
|
2080
2218
|
ctx.rotate(0.5 * Math.PI);
|
2081
2219
|
ctx.translate(0, -canvas.width);
|
2082
2220
|
break;
|
2221
|
+
|
2083
2222
|
case 7:
|
2084
2223
|
// horizontal flip + 90 rotate right
|
2085
2224
|
ctx.rotate(0.5 * Math.PI);
|
2086
2225
|
ctx.translate(canvas.height, -canvas.width);
|
2087
2226
|
ctx.scale(-1, 1);
|
2088
2227
|
break;
|
2228
|
+
|
2089
2229
|
case 8:
|
2090
2230
|
// 90° rotate left
|
2091
2231
|
ctx.rotate(-0.5 * Math.PI);
|
2092
2232
|
ctx.translate(-canvas.height, 0);
|
2093
2233
|
break;
|
2094
|
-
}
|
2234
|
+
} // This is a bugfix for iOS' scaling bug.
|
2095
2235
|
|
2096
|
-
// This is a bugfix for iOS' scaling bug.
|
2097
|
-
drawImageIOSFix(ctx, img, resizeInfo.srcX != null ? resizeInfo.srcX : 0, resizeInfo.srcY != null ? resizeInfo.srcY : 0, resizeInfo.srcWidth, resizeInfo.srcHeight, resizeInfo.trgX != null ? resizeInfo.trgX : 0, resizeInfo.trgY != null ? resizeInfo.trgY : 0, resizeInfo.trgWidth, resizeInfo.trgHeight);
|
2098
2236
|
|
2237
|
+
drawImageIOSFix(ctx, img, resizeInfo.srcX != null ? resizeInfo.srcX : 0, resizeInfo.srcY != null ? resizeInfo.srcY : 0, resizeInfo.srcWidth, resizeInfo.srcHeight, resizeInfo.trgX != null ? resizeInfo.trgX : 0, resizeInfo.trgY != null ? resizeInfo.trgY : 0, resizeInfo.trgWidth, resizeInfo.trgHeight);
|
2099
2238
|
var thumbnail = canvas.toDataURL("image/png");
|
2100
2239
|
|
2101
2240
|
if (callback != null) {
|
@@ -2109,19 +2248,15 @@ var Dropzone = function (_Emitter) {
|
|
2109
2248
|
}
|
2110
2249
|
|
2111
2250
|
return img.src = file.dataURL;
|
2112
|
-
}
|
2113
|
-
|
2114
|
-
// Goes through the queue and processes files if there aren't too many already.
|
2251
|
+
} // Goes through the queue and processes files if there aren't too many already.
|
2115
2252
|
|
2116
2253
|
}, {
|
2117
2254
|
key: "processQueue",
|
2118
2255
|
value: function processQueue() {
|
2119
2256
|
var parallelUploads = this.options.parallelUploads;
|
2120
|
-
|
2121
2257
|
var processingLength = this.getUploadingFiles().length;
|
2122
|
-
var i = processingLength;
|
2258
|
+
var i = processingLength; // There are already at least as many files uploading than should be
|
2123
2259
|
|
2124
|
-
// There are already at least as many files uploading than should be
|
2125
2260
|
if (processingLength >= parallelUploads) {
|
2126
2261
|
return;
|
2127
2262
|
}
|
@@ -2140,43 +2275,48 @@ var Dropzone = function (_Emitter) {
|
|
2140
2275
|
if (!queuedFiles.length) {
|
2141
2276
|
return;
|
2142
2277
|
} // Nothing left to process
|
2278
|
+
|
2279
|
+
|
2143
2280
|
this.processFile(queuedFiles.shift());
|
2144
2281
|
i++;
|
2145
2282
|
}
|
2146
2283
|
}
|
2147
|
-
}
|
2148
|
-
|
2149
|
-
// Wrapper for `processFiles`
|
2284
|
+
} // Wrapper for `processFiles`
|
2150
2285
|
|
2151
2286
|
}, {
|
2152
2287
|
key: "processFile",
|
2153
2288
|
value: function processFile(file) {
|
2154
2289
|
return this.processFiles([file]);
|
2155
|
-
}
|
2156
|
-
|
2157
|
-
// Loads the file, then calls finishedLoading()
|
2290
|
+
} // Loads the file, then calls finishedLoading()
|
2158
2291
|
|
2159
2292
|
}, {
|
2160
2293
|
key: "processFiles",
|
2161
2294
|
value: function processFiles(files) {
|
2162
|
-
|
2163
|
-
|
2295
|
+
var _iteratorNormalCompletion18 = true;
|
2296
|
+
var _didIteratorError18 = false;
|
2297
|
+
var _iteratorError18 = undefined;
|
2164
2298
|
|
2165
|
-
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
2170
|
-
|
2171
|
-
|
2299
|
+
try {
|
2300
|
+
for (var _iterator18 = files[Symbol.iterator](), _step18; !(_iteratorNormalCompletion18 = (_step18 = _iterator18.next()).done); _iteratorNormalCompletion18 = true) {
|
2301
|
+
var file = _step18.value;
|
2302
|
+
file.processing = true; // Backwards compatibility
|
2303
|
+
|
2304
|
+
file.status = Dropzone.UPLOADING;
|
2305
|
+
this.emit("processing", file);
|
2306
|
+
}
|
2307
|
+
} catch (err) {
|
2308
|
+
_didIteratorError18 = true;
|
2309
|
+
_iteratorError18 = err;
|
2310
|
+
} finally {
|
2311
|
+
try {
|
2312
|
+
if (!_iteratorNormalCompletion18 && _iterator18["return"] != null) {
|
2313
|
+
_iterator18["return"]();
|
2314
|
+
}
|
2315
|
+
} finally {
|
2316
|
+
if (_didIteratorError18) {
|
2317
|
+
throw _iteratorError18;
|
2318
|
+
}
|
2172
2319
|
}
|
2173
|
-
|
2174
|
-
var file = _ref18;
|
2175
|
-
|
2176
|
-
file.processing = true; // Backwards compatibility
|
2177
|
-
file.status = Dropzone.UPLOADING;
|
2178
|
-
|
2179
|
-
this.emit("processing", file);
|
2180
2320
|
}
|
2181
2321
|
|
2182
2322
|
if (this.options.uploadMultiple) {
|
@@ -2188,15 +2328,13 @@ var Dropzone = function (_Emitter) {
|
|
2188
2328
|
}, {
|
2189
2329
|
key: "_getFilesWithXhr",
|
2190
2330
|
value: function _getFilesWithXhr(xhr) {
|
2191
|
-
var files
|
2331
|
+
var files;
|
2192
2332
|
return files = this.files.filter(function (file) {
|
2193
2333
|
return file.xhr === xhr;
|
2194
2334
|
}).map(function (file) {
|
2195
2335
|
return file;
|
2196
2336
|
});
|
2197
|
-
}
|
2198
|
-
|
2199
|
-
// Cancels the file upload and sets the status to CANCELED
|
2337
|
+
} // Cancels the file upload and sets the status to CANCELED
|
2200
2338
|
// **if** the file is actually being uploaded.
|
2201
2339
|
// If it's still in the queue, the file is being removed from it and the status
|
2202
2340
|
// set to CANCELED.
|
@@ -2206,47 +2344,66 @@ var Dropzone = function (_Emitter) {
|
|
2206
2344
|
value: function cancelUpload(file) {
|
2207
2345
|
if (file.status === Dropzone.UPLOADING) {
|
2208
2346
|
var groupedFiles = this._getFilesWithXhr(file.xhr);
|
2209
|
-
for (var _iterator20 = groupedFiles, _isArray20 = true, _i21 = 0, _iterator20 = _isArray20 ? _iterator20 : _iterator20[Symbol.iterator]();;) {
|
2210
|
-
var _ref19;
|
2211
2347
|
|
2212
|
-
|
2213
|
-
|
2214
|
-
|
2215
|
-
} else {
|
2216
|
-
_i21 = _iterator20.next();
|
2217
|
-
if (_i21.done) break;
|
2218
|
-
_ref19 = _i21.value;
|
2219
|
-
}
|
2348
|
+
var _iteratorNormalCompletion19 = true;
|
2349
|
+
var _didIteratorError19 = false;
|
2350
|
+
var _iteratorError19 = undefined;
|
2220
2351
|
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2352
|
+
try {
|
2353
|
+
for (var _iterator19 = groupedFiles[Symbol.iterator](), _step19; !(_iteratorNormalCompletion19 = (_step19 = _iterator19.next()).done); _iteratorNormalCompletion19 = true) {
|
2354
|
+
var groupedFile = _step19.value;
|
2355
|
+
groupedFile.status = Dropzone.CANCELED;
|
2356
|
+
}
|
2357
|
+
} catch (err) {
|
2358
|
+
_didIteratorError19 = true;
|
2359
|
+
_iteratorError19 = err;
|
2360
|
+
} finally {
|
2361
|
+
try {
|
2362
|
+
if (!_iteratorNormalCompletion19 && _iterator19["return"] != null) {
|
2363
|
+
_iterator19["return"]();
|
2364
|
+
}
|
2365
|
+
} finally {
|
2366
|
+
if (_didIteratorError19) {
|
2367
|
+
throw _iteratorError19;
|
2368
|
+
}
|
2369
|
+
}
|
2224
2370
|
}
|
2371
|
+
|
2225
2372
|
if (typeof file.xhr !== 'undefined') {
|
2226
2373
|
file.xhr.abort();
|
2227
2374
|
}
|
2228
|
-
for (var _iterator21 = groupedFiles, _isArray21 = true, _i22 = 0, _iterator21 = _isArray21 ? _iterator21 : _iterator21[Symbol.iterator]();;) {
|
2229
|
-
var _ref20;
|
2230
2375
|
|
2231
|
-
|
2232
|
-
|
2233
|
-
|
2234
|
-
} else {
|
2235
|
-
_i22 = _iterator21.next();
|
2236
|
-
if (_i22.done) break;
|
2237
|
-
_ref20 = _i22.value;
|
2238
|
-
}
|
2376
|
+
var _iteratorNormalCompletion20 = true;
|
2377
|
+
var _didIteratorError20 = false;
|
2378
|
+
var _iteratorError20 = undefined;
|
2239
2379
|
|
2240
|
-
|
2241
|
-
|
2242
|
-
|
2380
|
+
try {
|
2381
|
+
for (var _iterator20 = groupedFiles[Symbol.iterator](), _step20; !(_iteratorNormalCompletion20 = (_step20 = _iterator20.next()).done); _iteratorNormalCompletion20 = true) {
|
2382
|
+
var _groupedFile = _step20.value;
|
2383
|
+
this.emit("canceled", _groupedFile);
|
2384
|
+
}
|
2385
|
+
} catch (err) {
|
2386
|
+
_didIteratorError20 = true;
|
2387
|
+
_iteratorError20 = err;
|
2388
|
+
} finally {
|
2389
|
+
try {
|
2390
|
+
if (!_iteratorNormalCompletion20 && _iterator20["return"] != null) {
|
2391
|
+
_iterator20["return"]();
|
2392
|
+
}
|
2393
|
+
} finally {
|
2394
|
+
if (_didIteratorError20) {
|
2395
|
+
throw _iteratorError20;
|
2396
|
+
}
|
2397
|
+
}
|
2243
2398
|
}
|
2399
|
+
|
2244
2400
|
if (this.options.uploadMultiple) {
|
2245
2401
|
this.emit("canceledmultiple", groupedFiles);
|
2246
2402
|
}
|
2247
2403
|
} else if (file.status === Dropzone.ADDED || file.status === Dropzone.QUEUED) {
|
2248
2404
|
file.status = Dropzone.CANCELED;
|
2249
2405
|
this.emit("canceled", file);
|
2406
|
+
|
2250
2407
|
if (this.options.uploadMultiple) {
|
2251
2408
|
this.emit("canceledmultiple", [file]);
|
2252
2409
|
}
|
@@ -2260,12 +2417,13 @@ var Dropzone = function (_Emitter) {
|
|
2260
2417
|
key: "resolveOption",
|
2261
2418
|
value: function resolveOption(option) {
|
2262
2419
|
if (typeof option === 'function') {
|
2263
|
-
for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
2420
|
+
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
2264
2421
|
args[_key3 - 1] = arguments[_key3];
|
2265
2422
|
}
|
2266
2423
|
|
2267
2424
|
return option.apply(this, args);
|
2268
2425
|
}
|
2426
|
+
|
2269
2427
|
return option;
|
2270
2428
|
}
|
2271
2429
|
}, {
|
@@ -2276,81 +2434,84 @@ var Dropzone = function (_Emitter) {
|
|
2276
2434
|
}, {
|
2277
2435
|
key: "uploadFiles",
|
2278
2436
|
value: function uploadFiles(files) {
|
2279
|
-
var
|
2437
|
+
var _this15 = this;
|
2280
2438
|
|
2281
2439
|
this._transformFiles(files, function (transformedFiles) {
|
2440
|
+
if (_this15.options.chunking) {
|
2441
|
+
// Chunking is not allowed to be used with `uploadMultiple` so we know
|
2442
|
+
// that there is only __one__file.
|
2443
|
+
var transformedFile = transformedFiles[0];
|
2444
|
+
files[0].upload.chunked = _this15.options.chunking && (_this15.options.forceChunking || transformedFile.size > _this15.options.chunkSize);
|
2445
|
+
files[0].upload.totalChunkCount = Math.ceil(transformedFile.size / _this15.options.chunkSize);
|
2446
|
+
}
|
2447
|
+
|
2282
2448
|
if (files[0].upload.chunked) {
|
2283
2449
|
// This file should be sent in chunks!
|
2284
|
-
|
2285
2450
|
// If the chunking option is set, we **know** that there can only be **one** file, since
|
2286
2451
|
// uploadMultiple is not allowed with this option.
|
2287
2452
|
var file = files[0];
|
2288
|
-
var
|
2453
|
+
var _transformedFile = transformedFiles[0];
|
2289
2454
|
var startedChunkCount = 0;
|
2290
|
-
|
2291
2455
|
file.upload.chunks = [];
|
2292
2456
|
|
2293
2457
|
var handleNextChunk = function handleNextChunk() {
|
2294
|
-
var chunkIndex = 0;
|
2458
|
+
var chunkIndex = 0; // Find the next item in file.upload.chunks that is not defined yet.
|
2295
2459
|
|
2296
|
-
// Find the next item in file.upload.chunks that is not defined yet.
|
2297
2460
|
while (file.upload.chunks[chunkIndex] !== undefined) {
|
2298
2461
|
chunkIndex++;
|
2299
|
-
}
|
2462
|
+
} // This means, that all chunks have already been started.
|
2300
2463
|
|
2301
|
-
// This means, that all chunks have already been started.
|
2302
|
-
if (chunkIndex >= file.upload.totalChunkCount) return;
|
2303
2464
|
|
2465
|
+
if (chunkIndex >= file.upload.totalChunkCount) return;
|
2304
2466
|
startedChunkCount++;
|
2305
|
-
|
2306
|
-
var
|
2307
|
-
var end = Math.min(start + _this14.options.chunkSize, file.size);
|
2308
|
-
|
2467
|
+
var start = chunkIndex * _this15.options.chunkSize;
|
2468
|
+
var end = Math.min(start + _this15.options.chunkSize, file.size);
|
2309
2469
|
var dataBlock = {
|
2310
|
-
name:
|
2311
|
-
data:
|
2470
|
+
name: _this15._getParamName(0),
|
2471
|
+
data: _transformedFile.webkitSlice ? _transformedFile.webkitSlice(start, end) : _transformedFile.slice(start, end),
|
2312
2472
|
filename: file.upload.filename,
|
2313
2473
|
chunkIndex: chunkIndex
|
2314
2474
|
};
|
2315
|
-
|
2316
2475
|
file.upload.chunks[chunkIndex] = {
|
2317
2476
|
file: file,
|
2318
2477
|
index: chunkIndex,
|
2319
|
-
dataBlock: dataBlock,
|
2478
|
+
dataBlock: dataBlock,
|
2479
|
+
// In case we want to retry.
|
2320
2480
|
status: Dropzone.UPLOADING,
|
2321
2481
|
progress: 0,
|
2322
2482
|
retries: 0 // The number of times this block has been retried.
|
2483
|
+
|
2323
2484
|
};
|
2324
2485
|
|
2325
|
-
|
2486
|
+
_this15._uploadData(files, [dataBlock]);
|
2326
2487
|
};
|
2327
2488
|
|
2328
2489
|
file.upload.finishedChunkUpload = function (chunk) {
|
2329
2490
|
var allFinished = true;
|
2330
|
-
chunk.status = Dropzone.SUCCESS;
|
2491
|
+
chunk.status = Dropzone.SUCCESS; // Clear the data from the chunk
|
2492
|
+
|
2493
|
+
chunk.dataBlock = null; // Leaving this reference to xhr intact here will cause memory leaks in some browsers
|
2331
2494
|
|
2332
|
-
// Clear the data from the chunk
|
2333
|
-
chunk.dataBlock = null;
|
2334
|
-
// Leaving this reference to xhr intact here will cause memory leaks in some browsers
|
2335
2495
|
chunk.xhr = null;
|
2336
2496
|
|
2337
2497
|
for (var i = 0; i < file.upload.totalChunkCount; i++) {
|
2338
2498
|
if (file.upload.chunks[i] === undefined) {
|
2339
2499
|
return handleNextChunk();
|
2340
2500
|
}
|
2501
|
+
|
2341
2502
|
if (file.upload.chunks[i].status !== Dropzone.SUCCESS) {
|
2342
2503
|
allFinished = false;
|
2343
2504
|
}
|
2344
2505
|
}
|
2345
2506
|
|
2346
2507
|
if (allFinished) {
|
2347
|
-
|
2348
|
-
|
2508
|
+
_this15.options.chunksUploaded(file, function () {
|
2509
|
+
_this15._finished(files, '', null);
|
2349
2510
|
});
|
2350
2511
|
}
|
2351
2512
|
};
|
2352
2513
|
|
2353
|
-
if (
|
2514
|
+
if (_this15.options.parallelChunkUploads) {
|
2354
2515
|
for (var i = 0; i < file.upload.totalChunkCount; i++) {
|
2355
2516
|
handleNextChunk();
|
2356
2517
|
}
|
@@ -2359,19 +2520,19 @@ var Dropzone = function (_Emitter) {
|
|
2359
2520
|
}
|
2360
2521
|
} else {
|
2361
2522
|
var dataBlocks = [];
|
2362
|
-
|
2363
|
-
|
2364
|
-
|
2365
|
-
|
2366
|
-
|
2523
|
+
|
2524
|
+
for (var _i3 = 0; _i3 < files.length; _i3++) {
|
2525
|
+
dataBlocks[_i3] = {
|
2526
|
+
name: _this15._getParamName(_i3),
|
2527
|
+
data: transformedFiles[_i3],
|
2528
|
+
filename: files[_i3].upload.filename
|
2367
2529
|
};
|
2368
2530
|
}
|
2369
|
-
|
2531
|
+
|
2532
|
+
_this15._uploadData(files, dataBlocks);
|
2370
2533
|
}
|
2371
2534
|
});
|
2372
|
-
}
|
2373
|
-
|
2374
|
-
/// Returns the right chunk for given file and xhr
|
2535
|
+
} /// Returns the right chunk for given file and xhr
|
2375
2536
|
|
2376
2537
|
}, {
|
2377
2538
|
key: "_getChunk",
|
@@ -2381,36 +2542,41 @@ var Dropzone = function (_Emitter) {
|
|
2381
2542
|
return file.upload.chunks[i];
|
2382
2543
|
}
|
2383
2544
|
}
|
2384
|
-
}
|
2385
|
-
|
2386
|
-
// This function actually uploads the file(s) to the server.
|
2545
|
+
} // This function actually uploads the file(s) to the server.
|
2387
2546
|
// If dataBlocks contains the actual data to upload (meaning, that this could either be transformed
|
2388
2547
|
// files, or individual chunks for chunked upload).
|
2389
2548
|
|
2390
2549
|
}, {
|
2391
2550
|
key: "_uploadData",
|
2392
2551
|
value: function _uploadData(files, dataBlocks) {
|
2393
|
-
var
|
2552
|
+
var _this16 = this;
|
2394
2553
|
|
2395
|
-
var xhr = new XMLHttpRequest();
|
2554
|
+
var xhr = new XMLHttpRequest(); // Put the xhr object in the file objects to be able to reference it later.
|
2396
2555
|
|
2397
|
-
|
2398
|
-
|
2399
|
-
|
2556
|
+
var _iteratorNormalCompletion21 = true;
|
2557
|
+
var _didIteratorError21 = false;
|
2558
|
+
var _iteratorError21 = undefined;
|
2400
2559
|
|
2401
|
-
|
2402
|
-
|
2403
|
-
|
2404
|
-
|
2405
|
-
|
2406
|
-
|
2407
|
-
|
2560
|
+
try {
|
2561
|
+
for (var _iterator21 = files[Symbol.iterator](), _step21; !(_iteratorNormalCompletion21 = (_step21 = _iterator21.next()).done); _iteratorNormalCompletion21 = true) {
|
2562
|
+
var file = _step21.value;
|
2563
|
+
file.xhr = xhr;
|
2564
|
+
}
|
2565
|
+
} catch (err) {
|
2566
|
+
_didIteratorError21 = true;
|
2567
|
+
_iteratorError21 = err;
|
2568
|
+
} finally {
|
2569
|
+
try {
|
2570
|
+
if (!_iteratorNormalCompletion21 && _iterator21["return"] != null) {
|
2571
|
+
_iterator21["return"]();
|
2572
|
+
}
|
2573
|
+
} finally {
|
2574
|
+
if (_didIteratorError21) {
|
2575
|
+
throw _iteratorError21;
|
2576
|
+
}
|
2408
2577
|
}
|
2409
|
-
|
2410
|
-
var file = _ref21;
|
2411
|
-
|
2412
|
-
file.xhr = xhr;
|
2413
2578
|
}
|
2579
|
+
|
2414
2580
|
if (files[0].upload.chunked) {
|
2415
2581
|
// Put the xhr object in the right chunk object, so it can be associated later, and found with _getChunk
|
2416
2582
|
files[0].upload.chunks[dataBlocks[0].chunkIndex].xhr = xhr;
|
@@ -2418,26 +2584,29 @@ var Dropzone = function (_Emitter) {
|
|
2418
2584
|
|
2419
2585
|
var method = this.resolveOption(this.options.method, files);
|
2420
2586
|
var url = this.resolveOption(this.options.url, files);
|
2421
|
-
xhr.open(method, url, true);
|
2587
|
+
xhr.open(method, url, true); // Setting the timeout after open because of IE11 issue: https://gitlab.com/meno/dropzone/issues/8
|
2422
2588
|
|
2423
|
-
//
|
2424
|
-
xhr.timeout = this.resolveOption(this.options.timeout, files);
|
2589
|
+
xhr.timeout = this.resolveOption(this.options.timeout, files); // Has to be after `.open()`. See https://github.com/enyo/dropzone/issues/179
|
2425
2590
|
|
2426
|
-
// Has to be after `.open()`. See https://github.com/enyo/dropzone/issues/179
|
2427
2591
|
xhr.withCredentials = !!this.options.withCredentials;
|
2428
2592
|
|
2429
2593
|
xhr.onload = function (e) {
|
2430
|
-
|
2594
|
+
_this16._finishedUploading(files, xhr, e);
|
2431
2595
|
};
|
2432
2596
|
|
2433
|
-
xhr.
|
2434
|
-
|
2597
|
+
xhr.ontimeout = function () {
|
2598
|
+
_this16._handleUploadError(files, xhr, "Request timedout after ".concat(_this16.options.timeout, " seconds"));
|
2435
2599
|
};
|
2436
2600
|
|
2437
|
-
|
2601
|
+
xhr.onerror = function () {
|
2602
|
+
_this16._handleUploadError(files, xhr);
|
2603
|
+
}; // Some browsers do not have the .upload property
|
2604
|
+
|
2605
|
+
|
2438
2606
|
var progressObj = xhr.upload != null ? xhr.upload : xhr;
|
2607
|
+
|
2439
2608
|
progressObj.onprogress = function (e) {
|
2440
|
-
return
|
2609
|
+
return _this16._updateFilesUploadProgress(files, xhr, e);
|
2441
2610
|
};
|
2442
2611
|
|
2443
2612
|
var headers = {
|
@@ -2452,16 +2621,17 @@ var Dropzone = function (_Emitter) {
|
|
2452
2621
|
|
2453
2622
|
for (var headerName in headers) {
|
2454
2623
|
var headerValue = headers[headerName];
|
2624
|
+
|
2455
2625
|
if (headerValue) {
|
2456
2626
|
xhr.setRequestHeader(headerName, headerValue);
|
2457
2627
|
}
|
2458
2628
|
}
|
2459
2629
|
|
2460
|
-
var formData = new FormData();
|
2630
|
+
var formData = new FormData(); // Adding all @options parameters
|
2461
2631
|
|
2462
|
-
// Adding all @options parameters
|
2463
2632
|
if (this.options.params) {
|
2464
2633
|
var additionalParams = this.options.params;
|
2634
|
+
|
2465
2635
|
if (typeof additionalParams === 'function') {
|
2466
2636
|
additionalParams = additionalParams.call(this, files, xhr, files[0].upload.chunked ? this._getChunk(files[0], xhr) : null);
|
2467
2637
|
}
|
@@ -2470,55 +2640,62 @@ var Dropzone = function (_Emitter) {
|
|
2470
2640
|
var value = additionalParams[key];
|
2471
2641
|
formData.append(key, value);
|
2472
2642
|
}
|
2473
|
-
}
|
2643
|
+
} // Let the user add additional data if necessary
|
2474
2644
|
|
2475
|
-
// Let the user add additional data if necessary
|
2476
|
-
for (var _iterator23 = files, _isArray23 = true, _i25 = 0, _iterator23 = _isArray23 ? _iterator23 : _iterator23[Symbol.iterator]();;) {
|
2477
|
-
var _ref22;
|
2478
|
-
|
2479
|
-
if (_isArray23) {
|
2480
|
-
if (_i25 >= _iterator23.length) break;
|
2481
|
-
_ref22 = _iterator23[_i25++];
|
2482
|
-
} else {
|
2483
|
-
_i25 = _iterator23.next();
|
2484
|
-
if (_i25.done) break;
|
2485
|
-
_ref22 = _i25.value;
|
2486
|
-
}
|
2487
2645
|
|
2488
|
-
|
2646
|
+
var _iteratorNormalCompletion22 = true;
|
2647
|
+
var _didIteratorError22 = false;
|
2648
|
+
var _iteratorError22 = undefined;
|
2489
2649
|
|
2490
|
-
|
2650
|
+
try {
|
2651
|
+
for (var _iterator22 = files[Symbol.iterator](), _step22; !(_iteratorNormalCompletion22 = (_step22 = _iterator22.next()).done); _iteratorNormalCompletion22 = true) {
|
2652
|
+
var _file = _step22.value;
|
2653
|
+
this.emit("sending", _file, xhr, formData);
|
2654
|
+
}
|
2655
|
+
} catch (err) {
|
2656
|
+
_didIteratorError22 = true;
|
2657
|
+
_iteratorError22 = err;
|
2658
|
+
} finally {
|
2659
|
+
try {
|
2660
|
+
if (!_iteratorNormalCompletion22 && _iterator22["return"] != null) {
|
2661
|
+
_iterator22["return"]();
|
2662
|
+
}
|
2663
|
+
} finally {
|
2664
|
+
if (_didIteratorError22) {
|
2665
|
+
throw _iteratorError22;
|
2666
|
+
}
|
2667
|
+
}
|
2491
2668
|
}
|
2669
|
+
|
2492
2670
|
if (this.options.uploadMultiple) {
|
2493
2671
|
this.emit("sendingmultiple", files, xhr, formData);
|
2494
2672
|
}
|
2495
2673
|
|
2496
|
-
this._addFormElementData(formData);
|
2497
|
-
|
2498
|
-
// Finally add the files
|
2674
|
+
this._addFormElementData(formData); // Finally add the files
|
2499
2675
|
// Has to be last because some servers (eg: S3) expect the file to be the last parameter
|
2676
|
+
|
2677
|
+
|
2500
2678
|
for (var i = 0; i < dataBlocks.length; i++) {
|
2501
2679
|
var dataBlock = dataBlocks[i];
|
2502
2680
|
formData.append(dataBlock.name, dataBlock.data, dataBlock.filename);
|
2503
2681
|
}
|
2504
2682
|
|
2505
2683
|
this.submitRequest(xhr, formData, files);
|
2506
|
-
}
|
2507
|
-
|
2508
|
-
// Transforms all files with this.options.transformFile and invokes done with the transformed files when done.
|
2684
|
+
} // Transforms all files with this.options.transformFile and invokes done with the transformed files when done.
|
2509
2685
|
|
2510
2686
|
}, {
|
2511
2687
|
key: "_transformFiles",
|
2512
2688
|
value: function _transformFiles(files, done) {
|
2513
|
-
var
|
2689
|
+
var _this17 = this;
|
2690
|
+
|
2691
|
+
var transformedFiles = []; // Clumsy way of handling asynchronous calls, until I get to add a proper Future library.
|
2514
2692
|
|
2515
|
-
var transformedFiles = [];
|
2516
|
-
// Clumsy way of handling asynchronous calls, until I get to add a proper Future library.
|
2517
2693
|
var doneCounter = 0;
|
2518
2694
|
|
2519
2695
|
var _loop = function _loop(i) {
|
2520
|
-
|
2696
|
+
_this17.options.transformFile.call(_this17, files[i], function (transformedFile) {
|
2521
2697
|
transformedFiles[i] = transformedFile;
|
2698
|
+
|
2522
2699
|
if (++doneCounter === files.length) {
|
2523
2700
|
done(transformedFiles);
|
2524
2701
|
}
|
@@ -2528,86 +2705,99 @@ var Dropzone = function (_Emitter) {
|
|
2528
2705
|
for (var i = 0; i < files.length; i++) {
|
2529
2706
|
_loop(i);
|
2530
2707
|
}
|
2531
|
-
}
|
2532
|
-
|
2533
|
-
// Takes care of adding other input elements of the form to the AJAX request
|
2708
|
+
} // Takes care of adding other input elements of the form to the AJAX request
|
2534
2709
|
|
2535
2710
|
}, {
|
2536
2711
|
key: "_addFormElementData",
|
2537
2712
|
value: function _addFormElementData(formData) {
|
2538
2713
|
// Take care of other input elements
|
2539
2714
|
if (this.element.tagName === "FORM") {
|
2540
|
-
|
2541
|
-
|
2542
|
-
|
2543
|
-
|
2544
|
-
|
2545
|
-
|
2546
|
-
|
2547
|
-
|
2548
|
-
|
2549
|
-
|
2550
|
-
|
2551
|
-
|
2552
|
-
|
2553
|
-
|
2554
|
-
|
2555
|
-
|
2556
|
-
|
2557
|
-
|
2558
|
-
|
2559
|
-
|
2560
|
-
|
2561
|
-
|
2562
|
-
|
2563
|
-
|
2564
|
-
|
2565
|
-
|
2566
|
-
|
2567
|
-
|
2568
|
-
|
2569
|
-
|
2570
|
-
|
2571
|
-
|
2572
|
-
|
2573
|
-
|
2574
|
-
|
2575
|
-
|
2576
|
-
|
2577
|
-
|
2578
|
-
|
2715
|
+
var _iteratorNormalCompletion23 = true;
|
2716
|
+
var _didIteratorError23 = false;
|
2717
|
+
var _iteratorError23 = undefined;
|
2718
|
+
|
2719
|
+
try {
|
2720
|
+
for (var _iterator23 = this.element.querySelectorAll("input, textarea, select, button")[Symbol.iterator](), _step23; !(_iteratorNormalCompletion23 = (_step23 = _iterator23.next()).done); _iteratorNormalCompletion23 = true) {
|
2721
|
+
var input = _step23.value;
|
2722
|
+
var inputName = input.getAttribute("name");
|
2723
|
+
var inputType = input.getAttribute("type");
|
2724
|
+
if (inputType) inputType = inputType.toLowerCase(); // If the input doesn't have a name, we can't use it.
|
2725
|
+
|
2726
|
+
if (typeof inputName === 'undefined' || inputName === null) continue;
|
2727
|
+
|
2728
|
+
if (input.tagName === "SELECT" && input.hasAttribute("multiple")) {
|
2729
|
+
// Possibly multiple values
|
2730
|
+
var _iteratorNormalCompletion24 = true;
|
2731
|
+
var _didIteratorError24 = false;
|
2732
|
+
var _iteratorError24 = undefined;
|
2733
|
+
|
2734
|
+
try {
|
2735
|
+
for (var _iterator24 = input.options[Symbol.iterator](), _step24; !(_iteratorNormalCompletion24 = (_step24 = _iterator24.next()).done); _iteratorNormalCompletion24 = true) {
|
2736
|
+
var option = _step24.value;
|
2737
|
+
|
2738
|
+
if (option.selected) {
|
2739
|
+
formData.append(inputName, option.value);
|
2740
|
+
}
|
2741
|
+
}
|
2742
|
+
} catch (err) {
|
2743
|
+
_didIteratorError24 = true;
|
2744
|
+
_iteratorError24 = err;
|
2745
|
+
} finally {
|
2746
|
+
try {
|
2747
|
+
if (!_iteratorNormalCompletion24 && _iterator24["return"] != null) {
|
2748
|
+
_iterator24["return"]();
|
2749
|
+
}
|
2750
|
+
} finally {
|
2751
|
+
if (_didIteratorError24) {
|
2752
|
+
throw _iteratorError24;
|
2753
|
+
}
|
2754
|
+
}
|
2579
2755
|
}
|
2756
|
+
} else if (!inputType || inputType !== "checkbox" && inputType !== "radio" || input.checked) {
|
2757
|
+
formData.append(inputName, input.value);
|
2758
|
+
}
|
2759
|
+
}
|
2760
|
+
} catch (err) {
|
2761
|
+
_didIteratorError23 = true;
|
2762
|
+
_iteratorError23 = err;
|
2763
|
+
} finally {
|
2764
|
+
try {
|
2765
|
+
if (!_iteratorNormalCompletion23 && _iterator23["return"] != null) {
|
2766
|
+
_iterator23["return"]();
|
2767
|
+
}
|
2768
|
+
} finally {
|
2769
|
+
if (_didIteratorError23) {
|
2770
|
+
throw _iteratorError23;
|
2580
2771
|
}
|
2581
|
-
} else if (!inputType || inputType !== "checkbox" && inputType !== "radio" || input.checked) {
|
2582
|
-
formData.append(inputName, input.value);
|
2583
2772
|
}
|
2584
2773
|
}
|
2585
2774
|
}
|
2586
|
-
}
|
2587
|
-
|
2588
|
-
// Invoked when there is new progress information about given files.
|
2775
|
+
} // Invoked when there is new progress information about given files.
|
2589
2776
|
// If e is not provided, it is assumed that the upload is finished.
|
2590
2777
|
|
2591
2778
|
}, {
|
2592
2779
|
key: "_updateFilesUploadProgress",
|
2593
2780
|
value: function _updateFilesUploadProgress(files, xhr, e) {
|
2594
|
-
var progress
|
2781
|
+
var progress;
|
2782
|
+
|
2595
2783
|
if (typeof e !== 'undefined') {
|
2596
2784
|
progress = 100 * e.loaded / e.total;
|
2597
2785
|
|
2598
2786
|
if (files[0].upload.chunked) {
|
2599
|
-
var file = files[0];
|
2600
|
-
|
2787
|
+
var file = files[0]; // Since this is a chunked upload, we need to update the appropriate chunk progress.
|
2788
|
+
|
2601
2789
|
var chunk = this._getChunk(file, xhr);
|
2790
|
+
|
2602
2791
|
chunk.progress = progress;
|
2603
2792
|
chunk.total = e.total;
|
2604
2793
|
chunk.bytesSent = e.loaded;
|
2605
2794
|
var fileProgress = 0,
|
2606
|
-
fileTotal
|
2607
|
-
fileBytesSent
|
2795
|
+
fileTotal,
|
2796
|
+
fileBytesSent;
|
2608
2797
|
file.upload.progress = 0;
|
2609
2798
|
file.upload.total = 0;
|
2610
2799
|
file.upload.bytesSent = 0;
|
2800
|
+
|
2611
2801
|
for (var i = 0; i < file.upload.totalChunkCount; i++) {
|
2612
2802
|
if (file.upload.chunks[i] !== undefined && file.upload.chunks[i].progress !== undefined) {
|
2613
2803
|
file.upload.progress += file.upload.chunks[i].progress;
|
@@ -2615,98 +2805,127 @@ var Dropzone = function (_Emitter) {
|
|
2615
2805
|
file.upload.bytesSent += file.upload.chunks[i].bytesSent;
|
2616
2806
|
}
|
2617
2807
|
}
|
2808
|
+
|
2618
2809
|
file.upload.progress = file.upload.progress / file.upload.totalChunkCount;
|
2619
2810
|
} else {
|
2620
|
-
|
2621
|
-
|
2811
|
+
var _iteratorNormalCompletion25 = true;
|
2812
|
+
var _didIteratorError25 = false;
|
2813
|
+
var _iteratorError25 = undefined;
|
2622
2814
|
|
2623
|
-
|
2624
|
-
|
2625
|
-
|
2626
|
-
|
2627
|
-
|
2628
|
-
|
2629
|
-
|
2815
|
+
try {
|
2816
|
+
for (var _iterator25 = files[Symbol.iterator](), _step25; !(_iteratorNormalCompletion25 = (_step25 = _iterator25.next()).done); _iteratorNormalCompletion25 = true) {
|
2817
|
+
var _file2 = _step25.value;
|
2818
|
+
_file2.upload.progress = progress;
|
2819
|
+
_file2.upload.total = e.total;
|
2820
|
+
_file2.upload.bytesSent = e.loaded;
|
2821
|
+
}
|
2822
|
+
} catch (err) {
|
2823
|
+
_didIteratorError25 = true;
|
2824
|
+
_iteratorError25 = err;
|
2825
|
+
} finally {
|
2826
|
+
try {
|
2827
|
+
if (!_iteratorNormalCompletion25 && _iterator25["return"] != null) {
|
2828
|
+
_iterator25["return"]();
|
2829
|
+
}
|
2830
|
+
} finally {
|
2831
|
+
if (_didIteratorError25) {
|
2832
|
+
throw _iteratorError25;
|
2833
|
+
}
|
2630
2834
|
}
|
2631
|
-
|
2632
|
-
var _file2 = _ref25;
|
2633
|
-
|
2634
|
-
_file2.upload.progress = progress;
|
2635
|
-
_file2.upload.total = e.total;
|
2636
|
-
_file2.upload.bytesSent = e.loaded;
|
2637
2835
|
}
|
2638
2836
|
}
|
2639
|
-
for (var _iterator27 = files, _isArray27 = true, _i29 = 0, _iterator27 = _isArray27 ? _iterator27 : _iterator27[Symbol.iterator]();;) {
|
2640
|
-
var _ref26;
|
2641
|
-
|
2642
|
-
if (_isArray27) {
|
2643
|
-
if (_i29 >= _iterator27.length) break;
|
2644
|
-
_ref26 = _iterator27[_i29++];
|
2645
|
-
} else {
|
2646
|
-
_i29 = _iterator27.next();
|
2647
|
-
if (_i29.done) break;
|
2648
|
-
_ref26 = _i29.value;
|
2649
|
-
}
|
2650
2837
|
|
2651
|
-
|
2838
|
+
var _iteratorNormalCompletion26 = true;
|
2839
|
+
var _didIteratorError26 = false;
|
2840
|
+
var _iteratorError26 = undefined;
|
2652
2841
|
|
2653
|
-
|
2842
|
+
try {
|
2843
|
+
for (var _iterator26 = files[Symbol.iterator](), _step26; !(_iteratorNormalCompletion26 = (_step26 = _iterator26.next()).done); _iteratorNormalCompletion26 = true) {
|
2844
|
+
var _file3 = _step26.value;
|
2845
|
+
this.emit("uploadprogress", _file3, _file3.upload.progress, _file3.upload.bytesSent);
|
2846
|
+
}
|
2847
|
+
} catch (err) {
|
2848
|
+
_didIteratorError26 = true;
|
2849
|
+
_iteratorError26 = err;
|
2850
|
+
} finally {
|
2851
|
+
try {
|
2852
|
+
if (!_iteratorNormalCompletion26 && _iterator26["return"] != null) {
|
2853
|
+
_iterator26["return"]();
|
2854
|
+
}
|
2855
|
+
} finally {
|
2856
|
+
if (_didIteratorError26) {
|
2857
|
+
throw _iteratorError26;
|
2858
|
+
}
|
2859
|
+
}
|
2654
2860
|
}
|
2655
2861
|
} else {
|
2656
2862
|
// Called when the file finished uploading
|
2657
|
-
|
2658
2863
|
var allFilesFinished = true;
|
2659
|
-
|
2660
2864
|
progress = 100;
|
2865
|
+
var _iteratorNormalCompletion27 = true;
|
2866
|
+
var _didIteratorError27 = false;
|
2867
|
+
var _iteratorError27 = undefined;
|
2661
2868
|
|
2662
|
-
|
2663
|
-
var
|
2869
|
+
try {
|
2870
|
+
for (var _iterator27 = files[Symbol.iterator](), _step27; !(_iteratorNormalCompletion27 = (_step27 = _iterator27.next()).done); _iteratorNormalCompletion27 = true) {
|
2871
|
+
var _file4 = _step27.value;
|
2664
2872
|
|
2665
|
-
|
2666
|
-
|
2667
|
-
|
2668
|
-
} else {
|
2669
|
-
_i30 = _iterator28.next();
|
2670
|
-
if (_i30.done) break;
|
2671
|
-
_ref27 = _i30.value;
|
2672
|
-
}
|
2873
|
+
if (_file4.upload.progress !== 100 || _file4.upload.bytesSent !== _file4.upload.total) {
|
2874
|
+
allFilesFinished = false;
|
2875
|
+
}
|
2673
2876
|
|
2674
|
-
|
2877
|
+
_file4.upload.progress = progress;
|
2878
|
+
_file4.upload.bytesSent = _file4.upload.total;
|
2879
|
+
} // Nothing to do, all files already at 100%
|
2675
2880
|
|
2676
|
-
|
2677
|
-
|
2881
|
+
} catch (err) {
|
2882
|
+
_didIteratorError27 = true;
|
2883
|
+
_iteratorError27 = err;
|
2884
|
+
} finally {
|
2885
|
+
try {
|
2886
|
+
if (!_iteratorNormalCompletion27 && _iterator27["return"] != null) {
|
2887
|
+
_iterator27["return"]();
|
2888
|
+
}
|
2889
|
+
} finally {
|
2890
|
+
if (_didIteratorError27) {
|
2891
|
+
throw _iteratorError27;
|
2892
|
+
}
|
2678
2893
|
}
|
2679
|
-
_file4.upload.progress = progress;
|
2680
|
-
_file4.upload.bytesSent = _file4.upload.total;
|
2681
2894
|
}
|
2682
2895
|
|
2683
|
-
// Nothing to do, all files already at 100%
|
2684
2896
|
if (allFilesFinished) {
|
2685
2897
|
return;
|
2686
2898
|
}
|
2687
2899
|
|
2688
|
-
|
2689
|
-
|
2900
|
+
var _iteratorNormalCompletion28 = true;
|
2901
|
+
var _didIteratorError28 = false;
|
2902
|
+
var _iteratorError28 = undefined;
|
2690
2903
|
|
2691
|
-
|
2692
|
-
|
2693
|
-
|
2694
|
-
|
2695
|
-
|
2696
|
-
|
2697
|
-
|
2904
|
+
try {
|
2905
|
+
for (var _iterator28 = files[Symbol.iterator](), _step28; !(_iteratorNormalCompletion28 = (_step28 = _iterator28.next()).done); _iteratorNormalCompletion28 = true) {
|
2906
|
+
var _file5 = _step28.value;
|
2907
|
+
this.emit("uploadprogress", _file5, progress, _file5.upload.bytesSent);
|
2908
|
+
}
|
2909
|
+
} catch (err) {
|
2910
|
+
_didIteratorError28 = true;
|
2911
|
+
_iteratorError28 = err;
|
2912
|
+
} finally {
|
2913
|
+
try {
|
2914
|
+
if (!_iteratorNormalCompletion28 && _iterator28["return"] != null) {
|
2915
|
+
_iterator28["return"]();
|
2916
|
+
}
|
2917
|
+
} finally {
|
2918
|
+
if (_didIteratorError28) {
|
2919
|
+
throw _iteratorError28;
|
2920
|
+
}
|
2698
2921
|
}
|
2699
|
-
|
2700
|
-
var _file5 = _ref28;
|
2701
|
-
|
2702
|
-
this.emit("uploadprogress", _file5, progress, _file5.upload.bytesSent);
|
2703
2922
|
}
|
2704
2923
|
}
|
2705
2924
|
}
|
2706
2925
|
}, {
|
2707
2926
|
key: "_finishedUploading",
|
2708
2927
|
value: function _finishedUploading(files, xhr, e) {
|
2709
|
-
var response
|
2928
|
+
var response;
|
2710
2929
|
|
2711
2930
|
if (files[0].status === Dropzone.CANCELED) {
|
2712
2931
|
return;
|
@@ -2750,61 +2969,54 @@ var Dropzone = function (_Emitter) {
|
|
2750
2969
|
|
2751
2970
|
if (files[0].upload.chunked && this.options.retryChunks) {
|
2752
2971
|
var chunk = this._getChunk(files[0], xhr);
|
2972
|
+
|
2753
2973
|
if (chunk.retries++ < this.options.retryChunksLimit) {
|
2754
2974
|
this._uploadData(files, [chunk.dataBlock]);
|
2975
|
+
|
2755
2976
|
return;
|
2756
2977
|
} else {
|
2757
2978
|
console.warn('Retried this chunk too often. Giving up.');
|
2758
2979
|
}
|
2759
2980
|
}
|
2760
2981
|
|
2761
|
-
|
2762
|
-
var _ref29;
|
2763
|
-
|
2764
|
-
if (_isArray30) {
|
2765
|
-
if (_i32 >= _iterator30.length) break;
|
2766
|
-
_ref29 = _iterator30[_i32++];
|
2767
|
-
} else {
|
2768
|
-
_i32 = _iterator30.next();
|
2769
|
-
if (_i32.done) break;
|
2770
|
-
_ref29 = _i32.value;
|
2771
|
-
}
|
2772
|
-
|
2773
|
-
var file = _ref29;
|
2774
|
-
|
2775
|
-
this._errorProcessing(files, response || this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr);
|
2776
|
-
}
|
2982
|
+
this._errorProcessing(files, response || this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr);
|
2777
2983
|
}
|
2778
2984
|
}, {
|
2779
2985
|
key: "submitRequest",
|
2780
2986
|
value: function submitRequest(xhr, formData, files) {
|
2781
2987
|
xhr.send(formData);
|
2782
|
-
}
|
2783
|
-
|
2784
|
-
// Called internally when processing is finished.
|
2988
|
+
} // Called internally when processing is finished.
|
2785
2989
|
// Individual callbacks have to be called in the appropriate sections.
|
2786
2990
|
|
2787
2991
|
}, {
|
2788
2992
|
key: "_finished",
|
2789
2993
|
value: function _finished(files, responseText, e) {
|
2790
|
-
|
2791
|
-
|
2994
|
+
var _iteratorNormalCompletion29 = true;
|
2995
|
+
var _didIteratorError29 = false;
|
2996
|
+
var _iteratorError29 = undefined;
|
2792
2997
|
|
2793
|
-
|
2794
|
-
|
2795
|
-
|
2796
|
-
|
2797
|
-
|
2798
|
-
|
2799
|
-
|
2998
|
+
try {
|
2999
|
+
for (var _iterator29 = files[Symbol.iterator](), _step29; !(_iteratorNormalCompletion29 = (_step29 = _iterator29.next()).done); _iteratorNormalCompletion29 = true) {
|
3000
|
+
var file = _step29.value;
|
3001
|
+
file.status = Dropzone.SUCCESS;
|
3002
|
+
this.emit("success", file, responseText, e);
|
3003
|
+
this.emit("complete", file);
|
3004
|
+
}
|
3005
|
+
} catch (err) {
|
3006
|
+
_didIteratorError29 = true;
|
3007
|
+
_iteratorError29 = err;
|
3008
|
+
} finally {
|
3009
|
+
try {
|
3010
|
+
if (!_iteratorNormalCompletion29 && _iterator29["return"] != null) {
|
3011
|
+
_iterator29["return"]();
|
3012
|
+
}
|
3013
|
+
} finally {
|
3014
|
+
if (_didIteratorError29) {
|
3015
|
+
throw _iteratorError29;
|
3016
|
+
}
|
2800
3017
|
}
|
2801
|
-
|
2802
|
-
var file = _ref30;
|
2803
|
-
|
2804
|
-
file.status = Dropzone.SUCCESS;
|
2805
|
-
this.emit("success", file, responseText, e);
|
2806
|
-
this.emit("complete", file);
|
2807
3018
|
}
|
3019
|
+
|
2808
3020
|
if (this.options.uploadMultiple) {
|
2809
3021
|
this.emit("successmultiple", files, responseText, e);
|
2810
3022
|
this.emit("completemultiple", files);
|
@@ -2813,32 +3025,38 @@ var Dropzone = function (_Emitter) {
|
|
2813
3025
|
if (this.options.autoProcessQueue) {
|
2814
3026
|
return this.processQueue();
|
2815
3027
|
}
|
2816
|
-
}
|
2817
|
-
|
2818
|
-
// Called internally when processing is finished.
|
3028
|
+
} // Called internally when processing is finished.
|
2819
3029
|
// Individual callbacks have to be called in the appropriate sections.
|
2820
3030
|
|
2821
3031
|
}, {
|
2822
3032
|
key: "_errorProcessing",
|
2823
3033
|
value: function _errorProcessing(files, message, xhr) {
|
2824
|
-
|
2825
|
-
|
3034
|
+
var _iteratorNormalCompletion30 = true;
|
3035
|
+
var _didIteratorError30 = false;
|
3036
|
+
var _iteratorError30 = undefined;
|
2826
3037
|
|
2827
|
-
|
2828
|
-
|
2829
|
-
|
2830
|
-
|
2831
|
-
|
2832
|
-
|
2833
|
-
|
3038
|
+
try {
|
3039
|
+
for (var _iterator30 = files[Symbol.iterator](), _step30; !(_iteratorNormalCompletion30 = (_step30 = _iterator30.next()).done); _iteratorNormalCompletion30 = true) {
|
3040
|
+
var file = _step30.value;
|
3041
|
+
file.status = Dropzone.ERROR;
|
3042
|
+
this.emit("error", file, message, xhr);
|
3043
|
+
this.emit("complete", file);
|
3044
|
+
}
|
3045
|
+
} catch (err) {
|
3046
|
+
_didIteratorError30 = true;
|
3047
|
+
_iteratorError30 = err;
|
3048
|
+
} finally {
|
3049
|
+
try {
|
3050
|
+
if (!_iteratorNormalCompletion30 && _iterator30["return"] != null) {
|
3051
|
+
_iterator30["return"]();
|
3052
|
+
}
|
3053
|
+
} finally {
|
3054
|
+
if (_didIteratorError30) {
|
3055
|
+
throw _iteratorError30;
|
3056
|
+
}
|
2834
3057
|
}
|
2835
|
-
|
2836
|
-
var file = _ref31;
|
2837
|
-
|
2838
|
-
file.status = Dropzone.ERROR;
|
2839
|
-
this.emit("error", file, message, xhr);
|
2840
|
-
this.emit("complete", file);
|
2841
3058
|
}
|
3059
|
+
|
2842
3060
|
if (this.options.uploadMultiple) {
|
2843
3061
|
this.emit("errormultiple", files, message, xhr);
|
2844
3062
|
this.emit("completemultiple", files);
|
@@ -2863,10 +3081,7 @@ var Dropzone = function (_Emitter) {
|
|
2863
3081
|
}(Emitter);
|
2864
3082
|
|
2865
3083
|
Dropzone.initClass();
|
2866
|
-
|
2867
|
-
Dropzone.version = "5.5.0";
|
2868
|
-
|
2869
|
-
// This is a map of options for your different dropzones. Add configurations
|
3084
|
+
Dropzone.version = "5.7.1"; // This is a map of options for your different dropzones. Add configurations
|
2870
3085
|
// to this object for your different dropzone elemens.
|
2871
3086
|
//
|
2872
3087
|
// Example:
|
@@ -2880,9 +3095,9 @@ Dropzone.version = "5.5.0";
|
|
2880
3095
|
// And in html:
|
2881
3096
|
//
|
2882
3097
|
// <form action="/upload" id="my-dropzone-element-id" class="dropzone"></form>
|
2883
|
-
Dropzone.options = {};
|
2884
3098
|
|
2885
|
-
// Returns the options for an element or undefined if none available.
|
3099
|
+
Dropzone.options = {}; // Returns the options for an element or undefined if none available.
|
3100
|
+
|
2886
3101
|
Dropzone.optionsForElement = function (element) {
|
2887
3102
|
// Get the `Dropzone.options.elementId` for this element if it exists
|
2888
3103
|
if (element.getAttribute("id")) {
|
@@ -2890,91 +3105,109 @@ Dropzone.optionsForElement = function (element) {
|
|
2890
3105
|
} else {
|
2891
3106
|
return undefined;
|
2892
3107
|
}
|
2893
|
-
};
|
3108
|
+
}; // Holds a list of all dropzone instances
|
3109
|
+
|
2894
3110
|
|
2895
|
-
|
2896
|
-
Dropzone.instances = [];
|
3111
|
+
Dropzone.instances = []; // Returns the dropzone for given element if any
|
2897
3112
|
|
2898
|
-
// Returns the dropzone for given element if any
|
2899
3113
|
Dropzone.forElement = function (element) {
|
2900
3114
|
if (typeof element === "string") {
|
2901
3115
|
element = document.querySelector(element);
|
2902
3116
|
}
|
3117
|
+
|
2903
3118
|
if ((element != null ? element.dropzone : undefined) == null) {
|
2904
3119
|
throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone.");
|
2905
3120
|
}
|
3121
|
+
|
2906
3122
|
return element.dropzone;
|
2907
|
-
};
|
3123
|
+
}; // Set to false if you don't want Dropzone to automatically find and attach to .dropzone elements.
|
2908
3124
|
|
2909
|
-
// Set to false if you don't want Dropzone to automatically find and attach to .dropzone elements.
|
2910
|
-
Dropzone.autoDiscover = true;
|
2911
3125
|
|
2912
|
-
// Looks for all .dropzone elements and creates a dropzone for them
|
3126
|
+
Dropzone.autoDiscover = true; // Looks for all .dropzone elements and creates a dropzone for them
|
3127
|
+
|
2913
3128
|
Dropzone.discover = function () {
|
2914
|
-
var dropzones
|
3129
|
+
var dropzones;
|
3130
|
+
|
2915
3131
|
if (document.querySelectorAll) {
|
2916
3132
|
dropzones = document.querySelectorAll(".dropzone");
|
2917
3133
|
} else {
|
2918
|
-
dropzones = [];
|
2919
|
-
|
3134
|
+
dropzones = []; // IE :(
|
3135
|
+
|
2920
3136
|
var checkElements = function checkElements(elements) {
|
2921
3137
|
return function () {
|
2922
3138
|
var result = [];
|
2923
|
-
|
2924
|
-
|
3139
|
+
var _iteratorNormalCompletion31 = true;
|
3140
|
+
var _didIteratorError31 = false;
|
3141
|
+
var _iteratorError31 = undefined;
|
2925
3142
|
|
2926
|
-
|
2927
|
-
|
2928
|
-
|
2929
|
-
} else {
|
2930
|
-
_i35 = _iterator33.next();
|
2931
|
-
if (_i35.done) break;
|
2932
|
-
_ref32 = _i35.value;
|
2933
|
-
}
|
2934
|
-
|
2935
|
-
var el = _ref32;
|
3143
|
+
try {
|
3144
|
+
for (var _iterator31 = elements[Symbol.iterator](), _step31; !(_iteratorNormalCompletion31 = (_step31 = _iterator31.next()).done); _iteratorNormalCompletion31 = true) {
|
3145
|
+
var el = _step31.value;
|
2936
3146
|
|
2937
|
-
|
2938
|
-
|
2939
|
-
|
2940
|
-
|
3147
|
+
if (/(^| )dropzone($| )/.test(el.className)) {
|
3148
|
+
result.push(dropzones.push(el));
|
3149
|
+
} else {
|
3150
|
+
result.push(undefined);
|
3151
|
+
}
|
3152
|
+
}
|
3153
|
+
} catch (err) {
|
3154
|
+
_didIteratorError31 = true;
|
3155
|
+
_iteratorError31 = err;
|
3156
|
+
} finally {
|
3157
|
+
try {
|
3158
|
+
if (!_iteratorNormalCompletion31 && _iterator31["return"] != null) {
|
3159
|
+
_iterator31["return"]();
|
3160
|
+
}
|
3161
|
+
} finally {
|
3162
|
+
if (_didIteratorError31) {
|
3163
|
+
throw _iteratorError31;
|
3164
|
+
}
|
2941
3165
|
}
|
2942
3166
|
}
|
3167
|
+
|
2943
3168
|
return result;
|
2944
3169
|
}();
|
2945
3170
|
};
|
3171
|
+
|
2946
3172
|
checkElements(document.getElementsByTagName("div"));
|
2947
3173
|
checkElements(document.getElementsByTagName("form"));
|
2948
3174
|
}
|
2949
3175
|
|
2950
3176
|
return function () {
|
2951
3177
|
var result = [];
|
2952
|
-
|
2953
|
-
|
2954
|
-
|
2955
|
-
if (_isArray34) {
|
2956
|
-
if (_i36 >= _iterator34.length) break;
|
2957
|
-
_ref33 = _iterator34[_i36++];
|
2958
|
-
} else {
|
2959
|
-
_i36 = _iterator34.next();
|
2960
|
-
if (_i36.done) break;
|
2961
|
-
_ref33 = _i36.value;
|
2962
|
-
}
|
3178
|
+
var _iteratorNormalCompletion32 = true;
|
3179
|
+
var _didIteratorError32 = false;
|
3180
|
+
var _iteratorError32 = undefined;
|
2963
3181
|
|
2964
|
-
|
3182
|
+
try {
|
3183
|
+
for (var _iterator32 = dropzones[Symbol.iterator](), _step32; !(_iteratorNormalCompletion32 = (_step32 = _iterator32.next()).done); _iteratorNormalCompletion32 = true) {
|
3184
|
+
var dropzone = _step32.value;
|
2965
3185
|
|
2966
|
-
|
2967
|
-
|
2968
|
-
|
2969
|
-
|
2970
|
-
|
3186
|
+
// Create a dropzone unless auto discover has been disabled for specific element
|
3187
|
+
if (Dropzone.optionsForElement(dropzone) !== false) {
|
3188
|
+
result.push(new Dropzone(dropzone));
|
3189
|
+
} else {
|
3190
|
+
result.push(undefined);
|
3191
|
+
}
|
3192
|
+
}
|
3193
|
+
} catch (err) {
|
3194
|
+
_didIteratorError32 = true;
|
3195
|
+
_iteratorError32 = err;
|
3196
|
+
} finally {
|
3197
|
+
try {
|
3198
|
+
if (!_iteratorNormalCompletion32 && _iterator32["return"] != null) {
|
3199
|
+
_iterator32["return"]();
|
3200
|
+
}
|
3201
|
+
} finally {
|
3202
|
+
if (_didIteratorError32) {
|
3203
|
+
throw _iteratorError32;
|
3204
|
+
}
|
2971
3205
|
}
|
2972
3206
|
}
|
3207
|
+
|
2973
3208
|
return result;
|
2974
3209
|
}();
|
2975
|
-
};
|
2976
|
-
|
2977
|
-
// Since the whole Drag'n'Drop API is pretty new, some browsers implement it,
|
3210
|
+
}; // Since the whole Drag'n'Drop API is pretty new, some browsers implement it,
|
2978
3211
|
// but not correctly.
|
2979
3212
|
// So I created a blacklist of userAgents. Yes, yes. Browser sniffing, I know.
|
2980
3213
|
// But what to do when browsers *theoretically* support an API, but crash
|
@@ -2985,11 +3218,11 @@ Dropzone.discover = function () {
|
|
2985
3218
|
// ** It should only be used on browser that *do* support the API, but
|
2986
3219
|
// incorrectly **
|
2987
3220
|
//
|
2988
|
-
Dropzone.blacklistedBrowsers = [
|
2989
|
-
// The mac os and windows phone version of opera 12 seems to have a problem with the File drag'n'drop API.
|
2990
|
-
/opera.*(Macintosh|Windows Phone).*version\/12/i];
|
2991
3221
|
|
2992
|
-
|
3222
|
+
|
3223
|
+
Dropzone.blacklistedBrowsers = [// The mac os and windows phone version of opera 12 seems to have a problem with the File drag'n'drop API.
|
3224
|
+
/opera.*(Macintosh|Windows Phone).*version\/12/i]; // Checks if the browser is supported
|
3225
|
+
|
2993
3226
|
Dropzone.isBrowserSupported = function () {
|
2994
3227
|
var capableBrowser = true;
|
2995
3228
|
|
@@ -2998,23 +3231,31 @@ Dropzone.isBrowserSupported = function () {
|
|
2998
3231
|
capableBrowser = false;
|
2999
3232
|
} else {
|
3000
3233
|
// The browser supports the API, but may be blacklisted.
|
3001
|
-
|
3002
|
-
|
3234
|
+
var _iteratorNormalCompletion33 = true;
|
3235
|
+
var _didIteratorError33 = false;
|
3236
|
+
var _iteratorError33 = undefined;
|
3003
3237
|
|
3004
|
-
|
3005
|
-
|
3006
|
-
|
3007
|
-
} else {
|
3008
|
-
_i37 = _iterator35.next();
|
3009
|
-
if (_i37.done) break;
|
3010
|
-
_ref34 = _i37.value;
|
3011
|
-
}
|
3012
|
-
|
3013
|
-
var regex = _ref34;
|
3238
|
+
try {
|
3239
|
+
for (var _iterator33 = Dropzone.blacklistedBrowsers[Symbol.iterator](), _step33; !(_iteratorNormalCompletion33 = (_step33 = _iterator33.next()).done); _iteratorNormalCompletion33 = true) {
|
3240
|
+
var regex = _step33.value;
|
3014
3241
|
|
3015
|
-
|
3016
|
-
|
3017
|
-
|
3242
|
+
if (regex.test(navigator.userAgent)) {
|
3243
|
+
capableBrowser = false;
|
3244
|
+
continue;
|
3245
|
+
}
|
3246
|
+
}
|
3247
|
+
} catch (err) {
|
3248
|
+
_didIteratorError33 = true;
|
3249
|
+
_iteratorError33 = err;
|
3250
|
+
} finally {
|
3251
|
+
try {
|
3252
|
+
if (!_iteratorNormalCompletion33 && _iterator33["return"] != null) {
|
3253
|
+
_iterator33["return"]();
|
3254
|
+
}
|
3255
|
+
} finally {
|
3256
|
+
if (_didIteratorError33) {
|
3257
|
+
throw _iteratorError33;
|
3258
|
+
}
|
3018
3259
|
}
|
3019
3260
|
}
|
3020
3261
|
}
|
@@ -3028,176 +3269,214 @@ Dropzone.isBrowserSupported = function () {
|
|
3028
3269
|
Dropzone.dataURItoBlob = function (dataURI) {
|
3029
3270
|
// convert base64 to raw binary data held in a string
|
3030
3271
|
// doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this
|
3031
|
-
var byteString = atob(dataURI.split(',')[1]);
|
3272
|
+
var byteString = atob(dataURI.split(',')[1]); // separate out the mime component
|
3032
3273
|
|
3033
|
-
//
|
3034
|
-
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
|
3274
|
+
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; // write the bytes of the string to an ArrayBuffer
|
3035
3275
|
|
3036
|
-
// write the bytes of the string to an ArrayBuffer
|
3037
3276
|
var ab = new ArrayBuffer(byteString.length);
|
3038
3277
|
var ia = new Uint8Array(ab);
|
3278
|
+
|
3039
3279
|
for (var i = 0, end = byteString.length, asc = 0 <= end; asc ? i <= end : i >= end; asc ? i++ : i--) {
|
3040
3280
|
ia[i] = byteString.charCodeAt(i);
|
3041
|
-
}
|
3281
|
+
} // write the ArrayBuffer to a blob
|
3282
|
+
|
3283
|
+
|
3284
|
+
return new Blob([ab], {
|
3285
|
+
type: mimeString
|
3286
|
+
});
|
3287
|
+
}; // Returns an array without the rejected item
|
3042
3288
|
|
3043
|
-
// write the ArrayBuffer to a blob
|
3044
|
-
return new Blob([ab], { type: mimeString });
|
3045
|
-
};
|
3046
3289
|
|
3047
|
-
// Returns an array without the rejected item
|
3048
3290
|
var without = function without(list, rejectedItem) {
|
3049
3291
|
return list.filter(function (item) {
|
3050
3292
|
return item !== rejectedItem;
|
3051
3293
|
}).map(function (item) {
|
3052
3294
|
return item;
|
3053
3295
|
});
|
3054
|
-
};
|
3296
|
+
}; // abc-def_ghi -> abcDefGhi
|
3297
|
+
|
3055
3298
|
|
3056
|
-
// abc-def_ghi -> abcDefGhi
|
3057
3299
|
var camelize = function camelize(str) {
|
3058
3300
|
return str.replace(/[\-_](\w)/g, function (match) {
|
3059
3301
|
return match.charAt(1).toUpperCase();
|
3060
3302
|
});
|
3061
|
-
};
|
3303
|
+
}; // Creates an element from string
|
3304
|
+
|
3062
3305
|
|
3063
|
-
// Creates an element from string
|
3064
3306
|
Dropzone.createElement = function (string) {
|
3065
3307
|
var div = document.createElement("div");
|
3066
3308
|
div.innerHTML = string;
|
3067
3309
|
return div.childNodes[0];
|
3068
|
-
};
|
3310
|
+
}; // Tests if given element is inside (or simply is) the container
|
3311
|
+
|
3069
3312
|
|
3070
|
-
// Tests if given element is inside (or simply is) the container
|
3071
3313
|
Dropzone.elementInside = function (element, container) {
|
3072
3314
|
if (element === container) {
|
3073
3315
|
return true;
|
3074
3316
|
} // Coffeescript doesn't support do/while loops
|
3317
|
+
|
3318
|
+
|
3075
3319
|
while (element = element.parentNode) {
|
3076
3320
|
if (element === container) {
|
3077
3321
|
return true;
|
3078
3322
|
}
|
3079
3323
|
}
|
3324
|
+
|
3080
3325
|
return false;
|
3081
3326
|
};
|
3082
3327
|
|
3083
3328
|
Dropzone.getElement = function (el, name) {
|
3084
|
-
var element
|
3329
|
+
var element;
|
3330
|
+
|
3085
3331
|
if (typeof el === "string") {
|
3086
3332
|
element = document.querySelector(el);
|
3087
3333
|
} else if (el.nodeType != null) {
|
3088
3334
|
element = el;
|
3089
3335
|
}
|
3336
|
+
|
3090
3337
|
if (element == null) {
|
3091
|
-
throw new Error("Invalid `"
|
3338
|
+
throw new Error("Invalid `".concat(name, "` option provided. Please provide a CSS selector or a plain HTML element."));
|
3092
3339
|
}
|
3340
|
+
|
3093
3341
|
return element;
|
3094
3342
|
};
|
3095
3343
|
|
3096
3344
|
Dropzone.getElements = function (els, name) {
|
3097
|
-
var el
|
3098
|
-
|
3345
|
+
var el, elements;
|
3346
|
+
|
3099
3347
|
if (els instanceof Array) {
|
3100
3348
|
elements = [];
|
3349
|
+
|
3101
3350
|
try {
|
3102
|
-
|
3103
|
-
|
3104
|
-
|
3105
|
-
el = _iterator36[_i38++];
|
3106
|
-
} else {
|
3107
|
-
_i38 = _iterator36.next();
|
3108
|
-
if (_i38.done) break;
|
3109
|
-
el = _i38.value;
|
3110
|
-
}
|
3351
|
+
var _iteratorNormalCompletion34 = true;
|
3352
|
+
var _didIteratorError34 = false;
|
3353
|
+
var _iteratorError34 = undefined;
|
3111
3354
|
|
3112
|
-
|
3355
|
+
try {
|
3356
|
+
for (var _iterator34 = els[Symbol.iterator](), _step34; !(_iteratorNormalCompletion34 = (_step34 = _iterator34.next()).done); _iteratorNormalCompletion34 = true) {
|
3357
|
+
el = _step34.value;
|
3358
|
+
elements.push(this.getElement(el, name));
|
3359
|
+
}
|
3360
|
+
} catch (err) {
|
3361
|
+
_didIteratorError34 = true;
|
3362
|
+
_iteratorError34 = err;
|
3363
|
+
} finally {
|
3364
|
+
try {
|
3365
|
+
if (!_iteratorNormalCompletion34 && _iterator34["return"] != null) {
|
3366
|
+
_iterator34["return"]();
|
3367
|
+
}
|
3368
|
+
} finally {
|
3369
|
+
if (_didIteratorError34) {
|
3370
|
+
throw _iteratorError34;
|
3371
|
+
}
|
3372
|
+
}
|
3113
3373
|
}
|
3114
3374
|
} catch (e) {
|
3115
3375
|
elements = null;
|
3116
3376
|
}
|
3117
3377
|
} else if (typeof els === "string") {
|
3118
3378
|
elements = [];
|
3119
|
-
|
3120
|
-
|
3121
|
-
|
3122
|
-
el = _iterator37[_i39++];
|
3123
|
-
} else {
|
3124
|
-
_i39 = _iterator37.next();
|
3125
|
-
if (_i39.done) break;
|
3126
|
-
el = _i39.value;
|
3127
|
-
}
|
3379
|
+
var _iteratorNormalCompletion35 = true;
|
3380
|
+
var _didIteratorError35 = false;
|
3381
|
+
var _iteratorError35 = undefined;
|
3128
3382
|
|
3129
|
-
|
3383
|
+
try {
|
3384
|
+
for (var _iterator35 = document.querySelectorAll(els)[Symbol.iterator](), _step35; !(_iteratorNormalCompletion35 = (_step35 = _iterator35.next()).done); _iteratorNormalCompletion35 = true) {
|
3385
|
+
el = _step35.value;
|
3386
|
+
elements.push(el);
|
3387
|
+
}
|
3388
|
+
} catch (err) {
|
3389
|
+
_didIteratorError35 = true;
|
3390
|
+
_iteratorError35 = err;
|
3391
|
+
} finally {
|
3392
|
+
try {
|
3393
|
+
if (!_iteratorNormalCompletion35 && _iterator35["return"] != null) {
|
3394
|
+
_iterator35["return"]();
|
3395
|
+
}
|
3396
|
+
} finally {
|
3397
|
+
if (_didIteratorError35) {
|
3398
|
+
throw _iteratorError35;
|
3399
|
+
}
|
3400
|
+
}
|
3130
3401
|
}
|
3131
3402
|
} else if (els.nodeType != null) {
|
3132
3403
|
elements = [els];
|
3133
3404
|
}
|
3134
3405
|
|
3135
3406
|
if (elements == null || !elements.length) {
|
3136
|
-
throw new Error("Invalid `"
|
3407
|
+
throw new Error("Invalid `".concat(name, "` option provided. Please provide a CSS selector, a plain HTML element or a list of those."));
|
3137
3408
|
}
|
3138
3409
|
|
3139
3410
|
return elements;
|
3140
|
-
};
|
3141
|
-
|
3142
|
-
// Asks the user the question and calls accepted or rejected accordingly
|
3411
|
+
}; // Asks the user the question and calls accepted or rejected accordingly
|
3143
3412
|
//
|
3144
3413
|
// The default implementation just uses `window.confirm` and then calls the
|
3145
3414
|
// appropriate callback.
|
3415
|
+
|
3416
|
+
|
3146
3417
|
Dropzone.confirm = function (question, accepted, rejected) {
|
3147
3418
|
if (window.confirm(question)) {
|
3148
3419
|
return accepted();
|
3149
3420
|
} else if (rejected != null) {
|
3150
3421
|
return rejected();
|
3151
3422
|
}
|
3152
|
-
};
|
3153
|
-
|
3154
|
-
// Validates the mime type like this:
|
3423
|
+
}; // Validates the mime type like this:
|
3155
3424
|
//
|
3156
3425
|
// https://developer.mozilla.org/en-US/docs/HTML/Element/input#attr-accept
|
3426
|
+
|
3427
|
+
|
3157
3428
|
Dropzone.isValidFile = function (file, acceptedFiles) {
|
3158
3429
|
if (!acceptedFiles) {
|
3159
3430
|
return true;
|
3160
3431
|
} // If there are no accepted mime types, it's OK
|
3161
|
-
acceptedFiles = acceptedFiles.split(",");
|
3162
3432
|
|
3433
|
+
|
3434
|
+
acceptedFiles = acceptedFiles.split(",");
|
3163
3435
|
var mimeType = file.type;
|
3164
3436
|
var baseMimeType = mimeType.replace(/\/.*$/, "");
|
3437
|
+
var _iteratorNormalCompletion36 = true;
|
3438
|
+
var _didIteratorError36 = false;
|
3439
|
+
var _iteratorError36 = undefined;
|
3165
3440
|
|
3166
|
-
|
3167
|
-
var
|
3168
|
-
|
3169
|
-
|
3170
|
-
if (_i40 >= _iterator38.length) break;
|
3171
|
-
_ref35 = _iterator38[_i40++];
|
3172
|
-
} else {
|
3173
|
-
_i40 = _iterator38.next();
|
3174
|
-
if (_i40.done) break;
|
3175
|
-
_ref35 = _i40.value;
|
3176
|
-
}
|
3177
|
-
|
3178
|
-
var validType = _ref35;
|
3441
|
+
try {
|
3442
|
+
for (var _iterator36 = acceptedFiles[Symbol.iterator](), _step36; !(_iteratorNormalCompletion36 = (_step36 = _iterator36.next()).done); _iteratorNormalCompletion36 = true) {
|
3443
|
+
var validType = _step36.value;
|
3444
|
+
validType = validType.trim();
|
3179
3445
|
|
3180
|
-
|
3181
|
-
|
3182
|
-
|
3183
|
-
|
3446
|
+
if (validType.charAt(0) === ".") {
|
3447
|
+
if (file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.length - validType.length) !== -1) {
|
3448
|
+
return true;
|
3449
|
+
}
|
3450
|
+
} else if (/\/\*$/.test(validType)) {
|
3451
|
+
// This is something like a image/* mime type
|
3452
|
+
if (baseMimeType === validType.replace(/\/.*$/, "")) {
|
3453
|
+
return true;
|
3454
|
+
}
|
3455
|
+
} else {
|
3456
|
+
if (mimeType === validType) {
|
3457
|
+
return true;
|
3458
|
+
}
|
3184
3459
|
}
|
3185
|
-
}
|
3186
|
-
|
3187
|
-
|
3188
|
-
|
3460
|
+
}
|
3461
|
+
} catch (err) {
|
3462
|
+
_didIteratorError36 = true;
|
3463
|
+
_iteratorError36 = err;
|
3464
|
+
} finally {
|
3465
|
+
try {
|
3466
|
+
if (!_iteratorNormalCompletion36 && _iterator36["return"] != null) {
|
3467
|
+
_iterator36["return"]();
|
3189
3468
|
}
|
3190
|
-
}
|
3191
|
-
if (
|
3192
|
-
|
3469
|
+
} finally {
|
3470
|
+
if (_didIteratorError36) {
|
3471
|
+
throw _iteratorError36;
|
3193
3472
|
}
|
3194
3473
|
}
|
3195
3474
|
}
|
3196
3475
|
|
3197
3476
|
return false;
|
3198
|
-
};
|
3477
|
+
}; // Augment jQuery
|
3478
|
+
|
3199
3479
|
|
3200
|
-
// Augment jQuery
|
3201
3480
|
if (typeof jQuery !== 'undefined' && jQuery !== null) {
|
3202
3481
|
jQuery.fn.dropzone = function (options) {
|
3203
3482
|
return this.each(function () {
|
@@ -3210,23 +3489,20 @@ if (typeof module !== 'undefined' && module !== null) {
|
|
3210
3489
|
module.exports = Dropzone;
|
3211
3490
|
} else {
|
3212
3491
|
window.Dropzone = Dropzone;
|
3213
|
-
}
|
3492
|
+
} // Dropzone file status codes
|
3214
3493
|
|
3215
|
-
// Dropzone file status codes
|
3216
|
-
Dropzone.ADDED = "added";
|
3217
3494
|
|
3218
|
-
Dropzone.
|
3219
|
-
// For backwards compatibility. Now, if a file is accepted, it's either queued
|
3495
|
+
Dropzone.ADDED = "added";
|
3496
|
+
Dropzone.QUEUED = "queued"; // For backwards compatibility. Now, if a file is accepted, it's either queued
|
3220
3497
|
// or uploading.
|
3221
|
-
Dropzone.ACCEPTED = Dropzone.QUEUED;
|
3222
3498
|
|
3499
|
+
Dropzone.ACCEPTED = Dropzone.QUEUED;
|
3223
3500
|
Dropzone.UPLOADING = "uploading";
|
3224
3501
|
Dropzone.PROCESSING = Dropzone.UPLOADING; // alias
|
3225
3502
|
|
3226
3503
|
Dropzone.CANCELED = "canceled";
|
3227
3504
|
Dropzone.ERROR = "error";
|
3228
3505
|
Dropzone.SUCCESS = "success";
|
3229
|
-
|
3230
3506
|
/*
|
3231
3507
|
|
3232
3508
|
Bugfix for iOS 6 and 7
|
@@ -3234,10 +3510,10 @@ Dropzone.SUCCESS = "success";
|
|
3234
3510
|
based on the work of https://github.com/stomita/ios-imagefile-megapixel
|
3235
3511
|
|
3236
3512
|
*/
|
3237
|
-
|
3238
3513
|
// Detecting vertical squash in loaded image.
|
3239
3514
|
// Fixes a bug which squash image vertically while drawing into canvas for some images.
|
3240
3515
|
// This is a bug in iOS6 devices. This function from https://github.com/stomita/ios-imagefile-megapixel
|
3516
|
+
|
3241
3517
|
var detectVerticalSquash = function detectVerticalSquash(img) {
|
3242
3518
|
var iw = img.naturalWidth;
|
3243
3519
|
var ih = img.naturalHeight;
|
@@ -3248,14 +3524,13 @@ var detectVerticalSquash = function detectVerticalSquash(img) {
|
|
3248
3524
|
ctx.drawImage(img, 0, 0);
|
3249
3525
|
|
3250
3526
|
var _ctx$getImageData = ctx.getImageData(1, 0, 1, ih),
|
3251
|
-
data = _ctx$getImageData.data;
|
3252
|
-
|
3253
|
-
// search image edge pixel position in case it is squashed vertically.
|
3527
|
+
data = _ctx$getImageData.data; // search image edge pixel position in case it is squashed vertically.
|
3254
3528
|
|
3255
3529
|
|
3256
3530
|
var sy = 0;
|
3257
3531
|
var ey = ih;
|
3258
3532
|
var py = ih;
|
3533
|
+
|
3259
3534
|
while (py > sy) {
|
3260
3535
|
var alpha = data[(py - 1) * 4 + 3];
|
3261
3536
|
|
@@ -3267,6 +3542,7 @@ var detectVerticalSquash = function detectVerticalSquash(img) {
|
|
3267
3542
|
|
3268
3543
|
py = ey + sy >> 1;
|
3269
3544
|
}
|
3545
|
+
|
3270
3546
|
var ratio = py / ih;
|
3271
3547
|
|
3272
3548
|
if (ratio === 0) {
|
@@ -3274,20 +3550,21 @@ var detectVerticalSquash = function detectVerticalSquash(img) {
|
|
3274
3550
|
} else {
|
3275
3551
|
return ratio;
|
3276
3552
|
}
|
3277
|
-
};
|
3278
|
-
|
3279
|
-
// A replacement for context.drawImage
|
3553
|
+
}; // A replacement for context.drawImage
|
3280
3554
|
// (args are for source and destination).
|
3555
|
+
|
3556
|
+
|
3281
3557
|
var drawImageIOSFix = function drawImageIOSFix(ctx, img, sx, sy, sw, sh, dx, dy, dw, dh) {
|
3282
3558
|
var vertSquashRatio = detectVerticalSquash(img);
|
3283
3559
|
return ctx.drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh / vertSquashRatio);
|
3284
|
-
};
|
3285
|
-
|
3286
|
-
// Based on MinifyJpeg
|
3560
|
+
}; // Based on MinifyJpeg
|
3287
3561
|
// Source: http://www.perry.cz/files/ExifRestorer.js
|
3288
3562
|
// http://elicon.blog57.fc2.com/blog-entry-206.html
|
3289
3563
|
|
3290
|
-
|
3564
|
+
|
3565
|
+
var ExifRestore =
|
3566
|
+
/*#__PURE__*/
|
3567
|
+
function () {
|
3291
3568
|
function ExifRestore() {
|
3292
3569
|
_classCallCheck(this, ExifRestore);
|
3293
3570
|
}
|
@@ -3309,6 +3586,7 @@ var ExifRestore = function () {
|
|
3309
3586
|
var enc3 = undefined;
|
3310
3587
|
var enc4 = '';
|
3311
3588
|
var i = 0;
|
3589
|
+
|
3312
3590
|
while (true) {
|
3313
3591
|
chr1 = input[i++];
|
3314
3592
|
chr2 = input[i++];
|
@@ -3317,18 +3595,22 @@ var ExifRestore = function () {
|
|
3317
3595
|
enc2 = (chr1 & 3) << 4 | chr2 >> 4;
|
3318
3596
|
enc3 = (chr2 & 15) << 2 | chr3 >> 6;
|
3319
3597
|
enc4 = chr3 & 63;
|
3598
|
+
|
3320
3599
|
if (isNaN(chr2)) {
|
3321
3600
|
enc3 = enc4 = 64;
|
3322
3601
|
} else if (isNaN(chr3)) {
|
3323
3602
|
enc4 = 64;
|
3324
3603
|
}
|
3604
|
+
|
3325
3605
|
output = output + this.KEY_STR.charAt(enc1) + this.KEY_STR.charAt(enc2) + this.KEY_STR.charAt(enc3) + this.KEY_STR.charAt(enc4);
|
3326
3606
|
chr1 = chr2 = chr3 = '';
|
3327
3607
|
enc1 = enc2 = enc3 = enc4 = '';
|
3608
|
+
|
3328
3609
|
if (!(i < input.length)) {
|
3329
3610
|
break;
|
3330
3611
|
}
|
3331
3612
|
}
|
3613
|
+
|
3332
3614
|
return output;
|
3333
3615
|
}
|
3334
3616
|
}, {
|
@@ -3337,10 +3619,11 @@ var ExifRestore = function () {
|
|
3337
3619
|
if (!origFileBase64.match('data:image/jpeg;base64,')) {
|
3338
3620
|
return resizedFileBase64;
|
3339
3621
|
}
|
3622
|
+
|
3340
3623
|
var rawImage = this.decode64(origFileBase64.replace('data:image/jpeg;base64,', ''));
|
3341
3624
|
var segments = this.slice2Segments(rawImage);
|
3342
3625
|
var image = this.exifManipulation(resizedFileBase64, segments);
|
3343
|
-
return "data:image/jpeg;base64,"
|
3626
|
+
return "data:image/jpeg;base64,".concat(this.encode64(image));
|
3344
3627
|
}
|
3345
3628
|
}, {
|
3346
3629
|
key: "exifManipulation",
|
@@ -3355,13 +3638,17 @@ var ExifRestore = function () {
|
|
3355
3638
|
value: function getExifArray(segments) {
|
3356
3639
|
var seg = undefined;
|
3357
3640
|
var x = 0;
|
3641
|
+
|
3358
3642
|
while (x < segments.length) {
|
3359
3643
|
seg = segments[x];
|
3644
|
+
|
3360
3645
|
if (seg[0] === 255 & seg[1] === 225) {
|
3361
3646
|
return seg;
|
3362
3647
|
}
|
3648
|
+
|
3363
3649
|
x++;
|
3364
3650
|
}
|
3651
|
+
|
3365
3652
|
return [];
|
3366
3653
|
}
|
3367
3654
|
}, {
|
@@ -3382,11 +3669,14 @@ var ExifRestore = function () {
|
|
3382
3669
|
value: function slice2Segments(rawImageArray) {
|
3383
3670
|
var head = 0;
|
3384
3671
|
var segments = [];
|
3672
|
+
|
3385
3673
|
while (true) {
|
3386
3674
|
var length;
|
3675
|
+
|
3387
3676
|
if (rawImageArray[head] === 255 & rawImageArray[head + 1] === 218) {
|
3388
3677
|
break;
|
3389
3678
|
}
|
3679
|
+
|
3390
3680
|
if (rawImageArray[head] === 255 & rawImageArray[head + 1] === 216) {
|
3391
3681
|
head += 2;
|
3392
3682
|
} else {
|
@@ -3396,10 +3686,12 @@ var ExifRestore = function () {
|
|
3396
3686
|
segments.push(seg);
|
3397
3687
|
head = endPoint;
|
3398
3688
|
}
|
3689
|
+
|
3399
3690
|
if (head > rawImageArray.length) {
|
3400
3691
|
break;
|
3401
3692
|
}
|
3402
3693
|
}
|
3694
|
+
|
3403
3695
|
return segments;
|
3404
3696
|
}
|
3405
3697
|
}, {
|
@@ -3414,13 +3706,16 @@ var ExifRestore = function () {
|
|
3414
3706
|
var enc3 = undefined;
|
3415
3707
|
var enc4 = '';
|
3416
3708
|
var i = 0;
|
3417
|
-
var buf = [];
|
3418
|
-
|
3709
|
+
var buf = []; // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
|
3710
|
+
|
3419
3711
|
var base64test = /[^A-Za-z0-9\+\/\=]/g;
|
3712
|
+
|
3420
3713
|
if (base64test.exec(input)) {
|
3421
3714
|
console.warn('There were invalid base64 characters in the input text.\nValid base64 characters are A-Z, a-z, 0-9, \'+\', \'/\',and \'=\'\nExpect errors in decoding.');
|
3422
3715
|
}
|
3716
|
+
|
3423
3717
|
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
|
3718
|
+
|
3424
3719
|
while (true) {
|
3425
3720
|
enc1 = this.KEY_STR.indexOf(input.charAt(i++));
|
3426
3721
|
enc2 = this.KEY_STR.indexOf(input.charAt(i++));
|
@@ -3430,18 +3725,23 @@ var ExifRestore = function () {
|
|
3430
3725
|
chr2 = (enc2 & 15) << 4 | enc3 >> 2;
|
3431
3726
|
chr3 = (enc3 & 3) << 6 | enc4;
|
3432
3727
|
buf.push(chr1);
|
3728
|
+
|
3433
3729
|
if (enc3 !== 64) {
|
3434
3730
|
buf.push(chr2);
|
3435
3731
|
}
|
3732
|
+
|
3436
3733
|
if (enc4 !== 64) {
|
3437
3734
|
buf.push(chr3);
|
3438
3735
|
}
|
3736
|
+
|
3439
3737
|
chr1 = chr2 = chr3 = '';
|
3440
3738
|
enc1 = enc2 = enc3 = enc4 = '';
|
3739
|
+
|
3441
3740
|
if (!(i < input.length)) {
|
3442
3741
|
break;
|
3443
3742
|
}
|
3444
3743
|
}
|
3744
|
+
|
3445
3745
|
return buf;
|
3446
3746
|
}
|
3447
3747
|
}]);
|
@@ -3450,7 +3750,6 @@ var ExifRestore = function () {
|
|
3450
3750
|
}();
|
3451
3751
|
|
3452
3752
|
ExifRestore.initClass();
|
3453
|
-
|
3454
3753
|
/*
|
3455
3754
|
* contentloaded.js
|
3456
3755
|
*
|
@@ -3464,9 +3763,9 @@ ExifRestore.initClass();
|
|
3464
3763
|
* http://javascript.nwbox.com/ContentLoaded/
|
3465
3764
|
* http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE
|
3466
3765
|
*/
|
3467
|
-
|
3468
3766
|
// @win window reference
|
3469
3767
|
// @fn function reference
|
3768
|
+
|
3470
3769
|
var contentLoaded = function contentLoaded(win, fn) {
|
3471
3770
|
var done = false;
|
3472
3771
|
var top = true;
|
@@ -3475,11 +3774,14 @@ var contentLoaded = function contentLoaded(win, fn) {
|
|
3475
3774
|
var add = doc.addEventListener ? "addEventListener" : "attachEvent";
|
3476
3775
|
var rem = doc.addEventListener ? "removeEventListener" : "detachEvent";
|
3477
3776
|
var pre = doc.addEventListener ? "" : "on";
|
3777
|
+
|
3478
3778
|
var init = function init(e) {
|
3479
3779
|
if (e.type === "readystatechange" && doc.readyState !== "complete") {
|
3480
3780
|
return;
|
3481
3781
|
}
|
3782
|
+
|
3482
3783
|
(e.type === "load" ? win : doc)[rem](pre + e.type, init, false);
|
3784
|
+
|
3483
3785
|
if (!done && (done = true)) {
|
3484
3786
|
return fn.call(win, e.type || e);
|
3485
3787
|
}
|
@@ -3492,6 +3794,7 @@ var contentLoaded = function contentLoaded(win, fn) {
|
|
3492
3794
|
setTimeout(poll, 50);
|
3493
3795
|
return;
|
3494
3796
|
}
|
3797
|
+
|
3495
3798
|
return init("poll");
|
3496
3799
|
};
|
3497
3800
|
|
@@ -3500,27 +3803,31 @@ var contentLoaded = function contentLoaded(win, fn) {
|
|
3500
3803
|
try {
|
3501
3804
|
top = !win.frameElement;
|
3502
3805
|
} catch (error) {}
|
3806
|
+
|
3503
3807
|
if (top) {
|
3504
3808
|
poll();
|
3505
3809
|
}
|
3506
3810
|
}
|
3811
|
+
|
3507
3812
|
doc[add](pre + "DOMContentLoaded", init, false);
|
3508
3813
|
doc[add](pre + "readystatechange", init, false);
|
3509
3814
|
return win[add](pre + "load", init, false);
|
3510
3815
|
}
|
3511
|
-
};
|
3816
|
+
}; // As a single function to be able to write tests.
|
3817
|
+
|
3512
3818
|
|
3513
|
-
// As a single function to be able to write tests.
|
3514
3819
|
Dropzone._autoDiscoverFunction = function () {
|
3515
3820
|
if (Dropzone.autoDiscover) {
|
3516
3821
|
return Dropzone.discover();
|
3517
3822
|
}
|
3518
3823
|
};
|
3824
|
+
|
3519
3825
|
contentLoaded(window, Dropzone._autoDiscoverFunction);
|
3520
3826
|
|
3521
3827
|
function __guard__(value, transform) {
|
3522
3828
|
return typeof value !== 'undefined' && value !== null ? transform(value) : undefined;
|
3523
3829
|
}
|
3830
|
+
|
3524
3831
|
function __guardMethod__(obj, methodName, transform) {
|
3525
3832
|
if (typeof obj !== 'undefined' && obj !== null && typeof obj[methodName] === 'function') {
|
3526
3833
|
return transform(obj, methodName);
|