dropzonejs-rails 0.7.4 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/app/assets/javascripts/dropzone.js +626 -341
- data/lib/dropzonejs-rails/version.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb06c40c8dffd3c26a74bfa8ddd3e85304833fae
|
4
|
+
data.tar.gz: f69288d7791c83f923fb7fed4e58834a86a4e57c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c897e11aa006cdb081f245bd9a1039eacc8642969d12001fda015f9066945295cd1e5855ebcdc8c253b0c66d4651a2dbc788c61630742d331942d086039a07b0
|
7
|
+
data.tar.gz: 7d94fe29bd14a7493a27007f37367be103234ebadc3bbb56bf8a59554e74facf88c8f6c843a7e979cdbd358f18e9b525bd0ce2ecd1eec271cc7800284412bf0a
|
data/README.md
CHANGED
@@ -4,7 +4,11 @@ Integrate [Matias Meno's Dropzone](http://www.dropzonejs.com/) awesome file uplo
|
|
4
4
|
|
5
5
|
## Version
|
6
6
|
|
7
|
-
The latest version of this gem bundles **Dropzone
|
7
|
+
The latest version of this gem bundles **Dropzone v5.1.0**.
|
8
|
+
|
9
|
+
### Dropzone 4.x
|
10
|
+
|
11
|
+
If you depend on Dropzone's 4.x branch, you need to specify `gem 'dropzonejs-rails', '~> 0.7.4'` in your Gemfile, otherwise you'll get 5.x.
|
8
12
|
|
9
13
|
### Dropzone 3.x
|
10
14
|
|
@@ -63,6 +67,8 @@ Go to [this secret place](https://github.com/ncuesta/dropzonejs-rails/issues).
|
|
63
67
|
|
64
68
|
## Changelog
|
65
69
|
|
70
|
+
* v0.8.0
|
71
|
+
* Updates Dropzone to the 5.1 branch. **#43 By [@lerarybak](https://github.com/lerarybak).**
|
66
72
|
* v0.7.4
|
67
73
|
* Refactors rake tasks for better separation of concerns and a cleaner use. **#41 By [@thomasstephane](https://github.com/thomasstephane).**
|
68
74
|
* v0.7.0
|
@@ -26,10 +26,10 @@
|
|
26
26
|
*/
|
27
27
|
|
28
28
|
(function() {
|
29
|
-
var Dropzone, Emitter, camelize, contentLoaded, detectVerticalSquash, drawImageIOSFix, noop, without,
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
var Dropzone, Emitter, ExifRestore, camelize, contentLoaded, detectVerticalSquash, drawImageIOSFix, noop, without,
|
30
|
+
slice = [].slice,
|
31
|
+
extend1 = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
32
|
+
hasProp = {}.hasOwnProperty;
|
33
33
|
|
34
34
|
noop = function() {};
|
35
35
|
|
@@ -48,13 +48,13 @@
|
|
48
48
|
};
|
49
49
|
|
50
50
|
Emitter.prototype.emit = function() {
|
51
|
-
var args, callback, callbacks, event,
|
52
|
-
event = arguments[0], args = 2 <= arguments.length ?
|
51
|
+
var args, callback, callbacks, event, j, len;
|
52
|
+
event = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
53
53
|
this._callbacks = this._callbacks || {};
|
54
54
|
callbacks = this._callbacks[event];
|
55
55
|
if (callbacks) {
|
56
|
-
for (
|
57
|
-
callback = callbacks[
|
56
|
+
for (j = 0, len = callbacks.length; j < len; j++) {
|
57
|
+
callback = callbacks[j];
|
58
58
|
callback.apply(this, args);
|
59
59
|
}
|
60
60
|
}
|
@@ -68,7 +68,7 @@
|
|
68
68
|
Emitter.prototype.removeEventListener = Emitter.prototype.off;
|
69
69
|
|
70
70
|
Emitter.prototype.off = function(event, fn) {
|
71
|
-
var callback, callbacks, i,
|
71
|
+
var callback, callbacks, i, j, len;
|
72
72
|
if (!this._callbacks || arguments.length === 0) {
|
73
73
|
this._callbacks = {};
|
74
74
|
return this;
|
@@ -81,7 +81,7 @@
|
|
81
81
|
delete this._callbacks[event];
|
82
82
|
return this;
|
83
83
|
}
|
84
|
-
for (i =
|
84
|
+
for (i = j = 0, len = callbacks.length; j < len; i = ++j) {
|
85
85
|
callback = callbacks[i];
|
86
86
|
if (callback === fn) {
|
87
87
|
callbacks.splice(i, 1);
|
@@ -95,10 +95,10 @@
|
|
95
95
|
|
96
96
|
})();
|
97
97
|
|
98
|
-
Dropzone = (function(
|
98
|
+
Dropzone = (function(superClass) {
|
99
99
|
var extend, resolveOption;
|
100
100
|
|
101
|
-
|
101
|
+
extend1(Dropzone, superClass);
|
102
102
|
|
103
103
|
Dropzone.prototype.Emitter = Emitter;
|
104
104
|
|
@@ -117,6 +117,7 @@
|
|
117
117
|
url: null,
|
118
118
|
method: "post",
|
119
119
|
withCredentials: false,
|
120
|
+
timeout: 30000,
|
120
121
|
parallelUploads: 2,
|
121
122
|
uploadMultiple: false,
|
122
123
|
maxFilesize: 256,
|
@@ -125,9 +126,16 @@
|
|
125
126
|
maxThumbnailFilesize: 10,
|
126
127
|
thumbnailWidth: 120,
|
127
128
|
thumbnailHeight: 120,
|
129
|
+
thumbnailMethod: 'crop',
|
130
|
+
resizeWidth: null,
|
131
|
+
resizeHeight: null,
|
132
|
+
resizeMimeType: null,
|
133
|
+
resizeQuality: 0.8,
|
134
|
+
resizeMethod: 'contain',
|
128
135
|
filesizeBase: 1000,
|
129
136
|
maxFiles: null,
|
130
137
|
params: {},
|
138
|
+
headers: null,
|
131
139
|
clickable: true,
|
132
140
|
ignoreHiddenFiles: true,
|
133
141
|
acceptedFiles: null,
|
@@ -139,6 +147,8 @@
|
|
139
147
|
hiddenInputContainer: "body",
|
140
148
|
capture: null,
|
141
149
|
renameFilename: null,
|
150
|
+
renameFile: null,
|
151
|
+
forceFallback: false,
|
142
152
|
dictDefaultMessage: "Drop files here to upload",
|
143
153
|
dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.",
|
144
154
|
dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.",
|
@@ -150,19 +160,25 @@
|
|
150
160
|
dictRemoveFile: "Remove file",
|
151
161
|
dictRemoveFileConfirmation: null,
|
152
162
|
dictMaxFilesExceeded: "You can not upload any more files.",
|
153
|
-
|
154
|
-
|
163
|
+
dictFileSizeUnits: {
|
164
|
+
tb: "TB",
|
165
|
+
gb: "GB",
|
166
|
+
mb: "MB",
|
167
|
+
kb: "KB",
|
168
|
+
b: "b"
|
155
169
|
},
|
156
170
|
init: function() {
|
157
171
|
return noop;
|
158
172
|
},
|
159
|
-
|
173
|
+
accept: function(file, done) {
|
174
|
+
return done();
|
175
|
+
},
|
160
176
|
fallback: function() {
|
161
|
-
var child,
|
162
|
-
this.element.className =
|
163
|
-
|
164
|
-
for (
|
165
|
-
child =
|
177
|
+
var child, j, len, messageElement, ref, span;
|
178
|
+
this.element.className = this.element.className + " dz-browser-not-supported";
|
179
|
+
ref = this.element.getElementsByTagName("div");
|
180
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
181
|
+
child = ref[j];
|
166
182
|
if (/(^| )dz-message($| )/.test(child.className)) {
|
167
183
|
messageElement = child;
|
168
184
|
child.className = "dz-message";
|
@@ -183,7 +199,7 @@
|
|
183
199
|
}
|
184
200
|
return this.element.appendChild(this.getFallbackForm());
|
185
201
|
},
|
186
|
-
resize: function(file) {
|
202
|
+
resize: function(file, width, height, resizeMethod) {
|
187
203
|
var info, srcRatio, trgRatio;
|
188
204
|
info = {
|
189
205
|
srcX: 0,
|
@@ -192,33 +208,50 @@
|
|
192
208
|
srcHeight: file.height
|
193
209
|
};
|
194
210
|
srcRatio = file.width / file.height;
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
} else if (
|
201
|
-
|
202
|
-
} else if (info.optHeight == null) {
|
203
|
-
info.optHeight = (1 / srcRatio) * info.optWidth;
|
211
|
+
if ((width == null) && (height == null)) {
|
212
|
+
width = info.srcWidth;
|
213
|
+
height = info.srcHeight;
|
214
|
+
} else if (width == null) {
|
215
|
+
width = height * srcRatio;
|
216
|
+
} else if (height == null) {
|
217
|
+
height = width / srcRatio;
|
204
218
|
}
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
219
|
+
width = Math.min(width, info.srcWidth);
|
220
|
+
height = Math.min(height, info.srcHeight);
|
221
|
+
trgRatio = width / height;
|
222
|
+
if (info.srcWidth > width || info.srcHeight > height) {
|
223
|
+
if (resizeMethod === 'crop') {
|
224
|
+
if (srcRatio > trgRatio) {
|
225
|
+
info.srcHeight = file.height;
|
226
|
+
info.srcWidth = info.srcHeight * trgRatio;
|
227
|
+
} else {
|
228
|
+
info.srcWidth = file.width;
|
229
|
+
info.srcHeight = info.srcWidth / trgRatio;
|
230
|
+
}
|
231
|
+
} else if (resizeMethod === 'contain') {
|
232
|
+
if (srcRatio > trgRatio) {
|
233
|
+
height = width / srcRatio;
|
234
|
+
} else {
|
235
|
+
width = height * srcRatio;
|
236
|
+
}
|
213
237
|
} else {
|
214
|
-
|
215
|
-
info.srcHeight = info.srcWidth / trgRatio;
|
238
|
+
throw new Error("Unknown resizeMethod '" + resizeMethod + "'");
|
216
239
|
}
|
217
240
|
}
|
218
241
|
info.srcX = (file.width - info.srcWidth) / 2;
|
219
242
|
info.srcY = (file.height - info.srcHeight) / 2;
|
243
|
+
info.trgWidth = width;
|
244
|
+
info.trgHeight = height;
|
220
245
|
return info;
|
221
246
|
},
|
247
|
+
transformFile: function(file, done) {
|
248
|
+
if ((this.options.resizeWidth || this.options.resizeHeight) && file.type.match(/image.*/)) {
|
249
|
+
return this.resizeImage(file, this.options.resizeWidth, this.options.resizeHeight, this.options.resizeMethod, done);
|
250
|
+
} else {
|
251
|
+
return done(file);
|
252
|
+
}
|
253
|
+
},
|
254
|
+
previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n <div class=\"dz-image\"><img data-dz-thumbnail /></div>\n <div class=\"dz-details\">\n <div class=\"dz-size\"><span data-dz-size></span></div>\n <div class=\"dz-filename\"><span data-dz-name></span></div>\n </div>\n <div class=\"dz-progress\"><span class=\"dz-upload\" data-dz-uploadprogress></span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n <div class=\"dz-success-mark\">\n <svg width=\"54px\" height=\"54px\" viewBox=\"0 0 54 54\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:sketch=\"http://www.bohemiancoding.com/sketch/ns\">\n <title>Check</title>\n <defs></defs>\n <g id=\"Page-1\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\" sketch:type=\"MSPage\">\n <path d=\"M23.5,31.8431458 L17.5852419,25.9283877 C16.0248253,24.3679711 13.4910294,24.366835 11.9289322,25.9289322 C10.3700136,27.4878508 10.3665912,30.0234455 11.9283877,31.5852419 L20.4147581,40.0716123 C20.5133999,40.1702541 20.6159315,40.2626649 20.7218615,40.3488435 C22.2835669,41.8725651 24.794234,41.8626202 26.3461564,40.3106978 L43.3106978,23.3461564 C44.8771021,21.7797521 44.8758057,19.2483887 43.3137085,17.6862915 C41.7547899,16.1273729 39.2176035,16.1255422 37.6538436,17.6893022 L23.5,31.8431458 Z M27,53 C41.3594035,53 53,41.3594035 53,27 C53,12.6405965 41.3594035,1 27,1 C12.6405965,1 1,12.6405965 1,27 C1,41.3594035 12.6405965,53 27,53 Z\" id=\"Oval-2\" stroke-opacity=\"0.198794158\" stroke=\"#747474\" fill-opacity=\"0.816519475\" fill=\"#FFFFFF\" sketch:type=\"MSShapeGroup\"></path>\n </g>\n </svg>\n </div>\n <div class=\"dz-error-mark\">\n <svg width=\"54px\" height=\"54px\" viewBox=\"0 0 54 54\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:sketch=\"http://www.bohemiancoding.com/sketch/ns\">\n <title>Error</title>\n <defs></defs>\n <g id=\"Page-1\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\" sketch:type=\"MSPage\">\n <g id=\"Check-+-Oval-2\" sketch:type=\"MSLayerGroup\" stroke=\"#747474\" stroke-opacity=\"0.198794158\" fill=\"#FFFFFF\" fill-opacity=\"0.816519475\">\n <path d=\"M32.6568542,29 L38.3106978,23.3461564 C39.8771021,21.7797521 39.8758057,19.2483887 38.3137085,17.6862915 C36.7547899,16.1273729 34.2176035,16.1255422 32.6538436,17.6893022 L27,23.3431458 L21.3461564,17.6893022 C19.7823965,16.1255422 17.2452101,16.1273729 15.6862915,17.6862915 C14.1241943,19.2483887 14.1228979,21.7797521 15.6893022,23.3461564 L21.3431458,29 L15.6893022,34.6538436 C14.1228979,36.2202479 14.1241943,38.7516113 15.6862915,40.3137085 C17.2452101,41.8726271 19.7823965,41.8744578 21.3461564,40.3106978 L27,34.6568542 L32.6538436,40.3106978 C34.2176035,41.8744578 36.7547899,41.8726271 38.3137085,40.3137085 C39.8758057,38.7516113 39.8771021,36.2202479 38.3106978,34.6538436 L32.6568542,29 Z M27,53 C41.3594035,53 53,41.3594035 53,27 C53,12.6405965 41.3594035,1 27,1 C12.6405965,1 1,12.6405965 1,27 C1,41.3594035 12.6405965,53 27,53 Z\" id=\"Oval-2\" sketch:type=\"MSShapeGroup\"></path>\n </g>\n </g>\n </svg>\n </div>\n</div>",
|
222
255
|
|
223
256
|
/*
|
224
257
|
Those functions register themselves to the events on init and handle all
|
@@ -249,7 +282,7 @@
|
|
249
282
|
return this.element.classList.remove("dz-started");
|
250
283
|
},
|
251
284
|
addedfile: function(file) {
|
252
|
-
var
|
285
|
+
var j, k, l, len, len1, len2, node, ref, ref1, ref2, removeFileEvent, removeLink, results;
|
253
286
|
if (this.element === this.previewsContainer) {
|
254
287
|
this.element.classList.add("dz-started");
|
255
288
|
}
|
@@ -257,14 +290,14 @@
|
|
257
290
|
file.previewElement = Dropzone.createElement(this.options.previewTemplate.trim());
|
258
291
|
file.previewTemplate = file.previewElement;
|
259
292
|
this.previewsContainer.appendChild(file.previewElement);
|
260
|
-
|
261
|
-
for (
|
262
|
-
node =
|
263
|
-
node.textContent =
|
293
|
+
ref = file.previewElement.querySelectorAll("[data-dz-name]");
|
294
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
295
|
+
node = ref[j];
|
296
|
+
node.textContent = file.upload.filename;
|
264
297
|
}
|
265
|
-
|
266
|
-
for (
|
267
|
-
node =
|
298
|
+
ref1 = file.previewElement.querySelectorAll("[data-dz-size]");
|
299
|
+
for (k = 0, len1 = ref1.length; k < len1; k++) {
|
300
|
+
node = ref1[k];
|
268
301
|
node.innerHTML = this.filesize(file.size);
|
269
302
|
}
|
270
303
|
if (this.options.addRemoveLinks) {
|
@@ -290,31 +323,31 @@
|
|
290
323
|
}
|
291
324
|
};
|
292
325
|
})(this);
|
293
|
-
|
294
|
-
|
295
|
-
for (
|
296
|
-
removeLink =
|
297
|
-
|
326
|
+
ref2 = file.previewElement.querySelectorAll("[data-dz-remove]");
|
327
|
+
results = [];
|
328
|
+
for (l = 0, len2 = ref2.length; l < len2; l++) {
|
329
|
+
removeLink = ref2[l];
|
330
|
+
results.push(removeLink.addEventListener("click", removeFileEvent));
|
298
331
|
}
|
299
|
-
return
|
332
|
+
return results;
|
300
333
|
}
|
301
334
|
},
|
302
335
|
removedfile: function(file) {
|
303
|
-
var
|
336
|
+
var ref;
|
304
337
|
if (file.previewElement) {
|
305
|
-
if ((
|
306
|
-
|
338
|
+
if ((ref = file.previewElement) != null) {
|
339
|
+
ref.parentNode.removeChild(file.previewElement);
|
307
340
|
}
|
308
341
|
}
|
309
342
|
return this._updateMaxFilesReachedClass();
|
310
343
|
},
|
311
344
|
thumbnail: function(file, dataUrl) {
|
312
|
-
var
|
345
|
+
var j, len, ref, thumbnailElement;
|
313
346
|
if (file.previewElement) {
|
314
347
|
file.previewElement.classList.remove("dz-file-preview");
|
315
|
-
|
316
|
-
for (
|
317
|
-
thumbnailElement =
|
348
|
+
ref = file.previewElement.querySelectorAll("[data-dz-thumbnail]");
|
349
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
350
|
+
thumbnailElement = ref[j];
|
318
351
|
thumbnailElement.alt = file.name;
|
319
352
|
thumbnailElement.src = dataUrl;
|
320
353
|
}
|
@@ -326,19 +359,19 @@
|
|
326
359
|
}
|
327
360
|
},
|
328
361
|
error: function(file, message) {
|
329
|
-
var
|
362
|
+
var j, len, node, ref, results;
|
330
363
|
if (file.previewElement) {
|
331
364
|
file.previewElement.classList.add("dz-error");
|
332
365
|
if (typeof message !== "String" && message.error) {
|
333
366
|
message = message.error;
|
334
367
|
}
|
335
|
-
|
336
|
-
|
337
|
-
for (
|
338
|
-
node =
|
339
|
-
|
368
|
+
ref = file.previewElement.querySelectorAll("[data-dz-errormessage]");
|
369
|
+
results = [];
|
370
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
371
|
+
node = ref[j];
|
372
|
+
results.push(node.textContent = message);
|
340
373
|
}
|
341
|
-
return
|
374
|
+
return results;
|
342
375
|
}
|
343
376
|
},
|
344
377
|
errormultiple: noop,
|
@@ -352,19 +385,19 @@
|
|
352
385
|
},
|
353
386
|
processingmultiple: noop,
|
354
387
|
uploadprogress: function(file, progress, bytesSent) {
|
355
|
-
var
|
388
|
+
var j, len, node, ref, results;
|
356
389
|
if (file.previewElement) {
|
357
|
-
|
358
|
-
|
359
|
-
for (
|
360
|
-
node =
|
390
|
+
ref = file.previewElement.querySelectorAll("[data-dz-uploadprogress]");
|
391
|
+
results = [];
|
392
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
393
|
+
node = ref[j];
|
361
394
|
if (node.nodeName === 'PROGRESS') {
|
362
|
-
|
395
|
+
results.push(node.value = progress);
|
363
396
|
} else {
|
364
|
-
|
397
|
+
results.push(node.style.width = progress + "%");
|
365
398
|
}
|
366
399
|
}
|
367
|
-
return
|
400
|
+
return results;
|
368
401
|
}
|
369
402
|
},
|
370
403
|
totaluploadprogress: noop,
|
@@ -392,15 +425,14 @@
|
|
392
425
|
maxfilesexceeded: noop,
|
393
426
|
maxfilesreached: noop,
|
394
427
|
queuecomplete: noop,
|
395
|
-
addedfiles: noop
|
396
|
-
previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n <div class=\"dz-image\"><img data-dz-thumbnail /></div>\n <div class=\"dz-details\">\n <div class=\"dz-size\"><span data-dz-size></span></div>\n <div class=\"dz-filename\"><span data-dz-name></span></div>\n </div>\n <div class=\"dz-progress\"><span class=\"dz-upload\" data-dz-uploadprogress></span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n <div class=\"dz-success-mark\">\n <svg width=\"54px\" height=\"54px\" viewBox=\"0 0 54 54\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:sketch=\"http://www.bohemiancoding.com/sketch/ns\">\n <title>Check</title>\n <defs></defs>\n <g id=\"Page-1\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\" sketch:type=\"MSPage\">\n <path d=\"M23.5,31.8431458 L17.5852419,25.9283877 C16.0248253,24.3679711 13.4910294,24.366835 11.9289322,25.9289322 C10.3700136,27.4878508 10.3665912,30.0234455 11.9283877,31.5852419 L20.4147581,40.0716123 C20.5133999,40.1702541 20.6159315,40.2626649 20.7218615,40.3488435 C22.2835669,41.8725651 24.794234,41.8626202 26.3461564,40.3106978 L43.3106978,23.3461564 C44.8771021,21.7797521 44.8758057,19.2483887 43.3137085,17.6862915 C41.7547899,16.1273729 39.2176035,16.1255422 37.6538436,17.6893022 L23.5,31.8431458 Z M27,53 C41.3594035,53 53,41.3594035 53,27 C53,12.6405965 41.3594035,1 27,1 C12.6405965,1 1,12.6405965 1,27 C1,41.3594035 12.6405965,53 27,53 Z\" id=\"Oval-2\" stroke-opacity=\"0.198794158\" stroke=\"#747474\" fill-opacity=\"0.816519475\" fill=\"#FFFFFF\" sketch:type=\"MSShapeGroup\"></path>\n </g>\n </svg>\n </div>\n <div class=\"dz-error-mark\">\n <svg width=\"54px\" height=\"54px\" viewBox=\"0 0 54 54\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:sketch=\"http://www.bohemiancoding.com/sketch/ns\">\n <title>Error</title>\n <defs></defs>\n <g id=\"Page-1\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\" sketch:type=\"MSPage\">\n <g id=\"Check-+-Oval-2\" sketch:type=\"MSLayerGroup\" stroke=\"#747474\" stroke-opacity=\"0.198794158\" fill=\"#FFFFFF\" fill-opacity=\"0.816519475\">\n <path d=\"M32.6568542,29 L38.3106978,23.3461564 C39.8771021,21.7797521 39.8758057,19.2483887 38.3137085,17.6862915 C36.7547899,16.1273729 34.2176035,16.1255422 32.6538436,17.6893022 L27,23.3431458 L21.3461564,17.6893022 C19.7823965,16.1255422 17.2452101,16.1273729 15.6862915,17.6862915 C14.1241943,19.2483887 14.1228979,21.7797521 15.6893022,23.3461564 L21.3431458,29 L15.6893022,34.6538436 C14.1228979,36.2202479 14.1241943,38.7516113 15.6862915,40.3137085 C17.2452101,41.8726271 19.7823965,41.8744578 21.3461564,40.3106978 L27,34.6568542 L32.6538436,40.3106978 C34.2176035,41.8744578 36.7547899,41.8726271 38.3137085,40.3137085 C39.8758057,38.7516113 39.8771021,36.2202479 38.3106978,34.6538436 L32.6568542,29 Z M27,53 C41.3594035,53 53,41.3594035 53,27 C53,12.6405965 41.3594035,1 27,1 C12.6405965,1 1,12.6405965 1,27 C1,41.3594035 12.6405965,53 27,53 Z\" id=\"Oval-2\" sketch:type=\"MSShapeGroup\"></path>\n </g>\n </g>\n </svg>\n </div>\n</div>"
|
428
|
+
addedfiles: noop
|
397
429
|
};
|
398
430
|
|
399
431
|
extend = function() {
|
400
|
-
var key, object, objects, target, val
|
401
|
-
target = arguments[0], objects = 2 <= arguments.length ?
|
402
|
-
for (
|
403
|
-
object = objects[
|
432
|
+
var j, key, len, object, objects, target, val;
|
433
|
+
target = arguments[0], objects = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
434
|
+
for (j = 0, len = objects.length; j < len; j++) {
|
435
|
+
object = objects[j];
|
404
436
|
for (key in object) {
|
405
437
|
val = object[key];
|
406
438
|
target[key] = val;
|
@@ -409,9 +441,9 @@
|
|
409
441
|
return target;
|
410
442
|
};
|
411
443
|
|
412
|
-
function Dropzone(
|
413
|
-
var elementOptions, fallback,
|
414
|
-
this.element =
|
444
|
+
function Dropzone(element1, options) {
|
445
|
+
var elementOptions, fallback, ref;
|
446
|
+
this.element = element1;
|
415
447
|
this.version = Dropzone.version;
|
416
448
|
this.defaultOptions.previewTemplate = this.defaultOptions.previewTemplate.replace(/\n*/g, "");
|
417
449
|
this.clickableElements = [];
|
@@ -428,7 +460,7 @@
|
|
428
460
|
}
|
429
461
|
Dropzone.instances.push(this);
|
430
462
|
this.element.dropzone = this;
|
431
|
-
elementOptions = (
|
463
|
+
elementOptions = (ref = Dropzone.optionsForElement(this.element)) != null ? ref : {};
|
432
464
|
this.options = extend({}, this.defaultOptions, elementOptions, options != null ? options : {});
|
433
465
|
if (this.options.forceFallback || !Dropzone.isBrowserSupported()) {
|
434
466
|
return this.options.fallback.call(this);
|
@@ -446,6 +478,13 @@
|
|
446
478
|
this.options.acceptedFiles = this.options.acceptedMimeTypes;
|
447
479
|
delete this.options.acceptedMimeTypes;
|
448
480
|
}
|
481
|
+
if (this.options.renameFilename != null) {
|
482
|
+
this.options.renameFile = (function(_this) {
|
483
|
+
return function(file) {
|
484
|
+
return _this.options.renameFilename.call(_this, file.name, file);
|
485
|
+
};
|
486
|
+
})(this);
|
487
|
+
}
|
449
488
|
this.options.method = this.options.method.toUpperCase();
|
450
489
|
if ((fallback = this.getExistingFallback()) && fallback.parentNode) {
|
451
490
|
fallback.parentNode.removeChild(fallback);
|
@@ -468,42 +507,42 @@
|
|
468
507
|
}
|
469
508
|
|
470
509
|
Dropzone.prototype.getAcceptedFiles = function() {
|
471
|
-
var file,
|
472
|
-
|
473
|
-
|
474
|
-
for (
|
475
|
-
file =
|
510
|
+
var file, j, len, ref, results;
|
511
|
+
ref = this.files;
|
512
|
+
results = [];
|
513
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
514
|
+
file = ref[j];
|
476
515
|
if (file.accepted) {
|
477
|
-
|
516
|
+
results.push(file);
|
478
517
|
}
|
479
518
|
}
|
480
|
-
return
|
519
|
+
return results;
|
481
520
|
};
|
482
521
|
|
483
522
|
Dropzone.prototype.getRejectedFiles = function() {
|
484
|
-
var file,
|
485
|
-
|
486
|
-
|
487
|
-
for (
|
488
|
-
file =
|
523
|
+
var file, j, len, ref, results;
|
524
|
+
ref = this.files;
|
525
|
+
results = [];
|
526
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
527
|
+
file = ref[j];
|
489
528
|
if (!file.accepted) {
|
490
|
-
|
529
|
+
results.push(file);
|
491
530
|
}
|
492
531
|
}
|
493
|
-
return
|
532
|
+
return results;
|
494
533
|
};
|
495
534
|
|
496
535
|
Dropzone.prototype.getFilesWithStatus = function(status) {
|
497
|
-
var file,
|
498
|
-
|
499
|
-
|
500
|
-
for (
|
501
|
-
file =
|
536
|
+
var file, j, len, ref, results;
|
537
|
+
ref = this.files;
|
538
|
+
results = [];
|
539
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
540
|
+
file = ref[j];
|
502
541
|
if (file.status === status) {
|
503
|
-
|
542
|
+
results.push(file);
|
504
543
|
}
|
505
544
|
}
|
506
|
-
return
|
545
|
+
return results;
|
507
546
|
};
|
508
547
|
|
509
548
|
Dropzone.prototype.getQueuedFiles = function() {
|
@@ -519,20 +558,20 @@
|
|
519
558
|
};
|
520
559
|
|
521
560
|
Dropzone.prototype.getActiveFiles = function() {
|
522
|
-
var file,
|
523
|
-
|
524
|
-
|
525
|
-
for (
|
526
|
-
file =
|
561
|
+
var file, j, len, ref, results;
|
562
|
+
ref = this.files;
|
563
|
+
results = [];
|
564
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
565
|
+
file = ref[j];
|
527
566
|
if (file.status === Dropzone.UPLOADING || file.status === Dropzone.QUEUED) {
|
528
|
-
|
567
|
+
results.push(file);
|
529
568
|
}
|
530
569
|
}
|
531
|
-
return
|
570
|
+
return results;
|
532
571
|
};
|
533
572
|
|
534
573
|
Dropzone.prototype.init = function() {
|
535
|
-
var eventName,
|
574
|
+
var eventName, j, len, noPropagation, ref, ref1, setupHiddenFileInput;
|
536
575
|
if (this.element.tagName === "form") {
|
537
576
|
this.element.setAttribute("enctype", "multipart/form-data");
|
538
577
|
}
|
@@ -565,11 +604,11 @@
|
|
565
604
|
_this.hiddenFileInput.style.width = "0";
|
566
605
|
document.querySelector(_this.options.hiddenInputContainer).appendChild(_this.hiddenFileInput);
|
567
606
|
return _this.hiddenFileInput.addEventListener("change", function() {
|
568
|
-
var file, files,
|
607
|
+
var file, files, j, len;
|
569
608
|
files = _this.hiddenFileInput.files;
|
570
609
|
if (files.length) {
|
571
|
-
for (
|
572
|
-
file = files[
|
610
|
+
for (j = 0, len = files.length; j < len; j++) {
|
611
|
+
file = files[j];
|
573
612
|
_this.addFile(file);
|
574
613
|
}
|
575
614
|
}
|
@@ -580,10 +619,10 @@
|
|
580
619
|
})(this);
|
581
620
|
setupHiddenFileInput();
|
582
621
|
}
|
583
|
-
this.URL = (
|
584
|
-
|
585
|
-
for (
|
586
|
-
eventName =
|
622
|
+
this.URL = (ref = window.URL) != null ? ref : window.webkitURL;
|
623
|
+
ref1 = this.events;
|
624
|
+
for (j = 0, len = ref1.length; j < len; j++) {
|
625
|
+
eventName = ref1[j];
|
587
626
|
this.on(eventName, this.options[eventName]);
|
588
627
|
}
|
589
628
|
this.on("uploadprogress", (function(_this) {
|
@@ -638,7 +677,7 @@
|
|
638
677
|
var efct;
|
639
678
|
try {
|
640
679
|
efct = e.dataTransfer.effectAllowed;
|
641
|
-
} catch (
|
680
|
+
} catch (undefined) {}
|
642
681
|
e.dataTransfer.dropEffect = 'move' === efct || 'linkMove' === efct ? 'move' : 'copy';
|
643
682
|
noPropagation(e);
|
644
683
|
return _this.emit("dragover", e);
|
@@ -683,10 +722,10 @@
|
|
683
722
|
};
|
684
723
|
|
685
724
|
Dropzone.prototype.destroy = function() {
|
686
|
-
var
|
725
|
+
var ref;
|
687
726
|
this.disable();
|
688
727
|
this.removeAllFiles(true);
|
689
|
-
if ((
|
728
|
+
if ((ref = this.hiddenFileInput) != null ? ref.parentNode : void 0) {
|
690
729
|
this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput);
|
691
730
|
this.hiddenFileInput = null;
|
692
731
|
}
|
@@ -695,14 +734,14 @@
|
|
695
734
|
};
|
696
735
|
|
697
736
|
Dropzone.prototype.updateTotalUploadProgress = function() {
|
698
|
-
var activeFiles, file,
|
737
|
+
var activeFiles, file, j, len, ref, totalBytes, totalBytesSent, totalUploadProgress;
|
699
738
|
totalBytesSent = 0;
|
700
739
|
totalBytes = 0;
|
701
740
|
activeFiles = this.getActiveFiles();
|
702
741
|
if (activeFiles.length) {
|
703
|
-
|
704
|
-
for (
|
705
|
-
file =
|
742
|
+
ref = this.getActiveFiles();
|
743
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
744
|
+
file = ref[j];
|
706
745
|
totalBytesSent += file.upload.bytesSent;
|
707
746
|
totalBytes += file.upload.total;
|
708
747
|
}
|
@@ -721,11 +760,11 @@
|
|
721
760
|
}
|
722
761
|
};
|
723
762
|
|
724
|
-
Dropzone.prototype.
|
725
|
-
if (typeof this.options.
|
726
|
-
return name;
|
763
|
+
Dropzone.prototype._renameFile = function(file) {
|
764
|
+
if (typeof this.options.renameFile !== "function") {
|
765
|
+
return file.name;
|
727
766
|
}
|
728
|
-
return this.options.
|
767
|
+
return this.options.renameFile(file);
|
729
768
|
};
|
730
769
|
|
731
770
|
Dropzone.prototype.getFallbackForm = function() {
|
@@ -750,19 +789,19 @@
|
|
750
789
|
};
|
751
790
|
|
752
791
|
Dropzone.prototype.getExistingFallback = function() {
|
753
|
-
var fallback, getFallback,
|
792
|
+
var fallback, getFallback, j, len, ref, tagName;
|
754
793
|
getFallback = function(elements) {
|
755
|
-
var el,
|
756
|
-
for (
|
757
|
-
el = elements[
|
794
|
+
var el, j, len;
|
795
|
+
for (j = 0, len = elements.length; j < len; j++) {
|
796
|
+
el = elements[j];
|
758
797
|
if (/(^| )fallback($| )/.test(el.className)) {
|
759
798
|
return el;
|
760
799
|
}
|
761
800
|
}
|
762
801
|
};
|
763
|
-
|
764
|
-
for (
|
765
|
-
tagName =
|
802
|
+
ref = ["div", "form"];
|
803
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
804
|
+
tagName = ref[j];
|
766
805
|
if (fallback = getFallback(this.element.getElementsByTagName(tagName))) {
|
767
806
|
return fallback;
|
768
807
|
}
|
@@ -770,58 +809,58 @@
|
|
770
809
|
};
|
771
810
|
|
772
811
|
Dropzone.prototype.setupEventListeners = function() {
|
773
|
-
var elementListeners, event,
|
774
|
-
|
775
|
-
|
776
|
-
for (
|
777
|
-
elementListeners =
|
778
|
-
|
779
|
-
var
|
780
|
-
|
781
|
-
|
782
|
-
for (event in
|
783
|
-
listener =
|
784
|
-
|
812
|
+
var elementListeners, event, j, len, listener, ref, results;
|
813
|
+
ref = this.listeners;
|
814
|
+
results = [];
|
815
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
816
|
+
elementListeners = ref[j];
|
817
|
+
results.push((function() {
|
818
|
+
var ref1, results1;
|
819
|
+
ref1 = elementListeners.events;
|
820
|
+
results1 = [];
|
821
|
+
for (event in ref1) {
|
822
|
+
listener = ref1[event];
|
823
|
+
results1.push(elementListeners.element.addEventListener(event, listener, false));
|
785
824
|
}
|
786
|
-
return
|
825
|
+
return results1;
|
787
826
|
})());
|
788
827
|
}
|
789
|
-
return
|
828
|
+
return results;
|
790
829
|
};
|
791
830
|
|
792
831
|
Dropzone.prototype.removeEventListeners = function() {
|
793
|
-
var elementListeners, event,
|
794
|
-
|
795
|
-
|
796
|
-
for (
|
797
|
-
elementListeners =
|
798
|
-
|
799
|
-
var
|
800
|
-
|
801
|
-
|
802
|
-
for (event in
|
803
|
-
listener =
|
804
|
-
|
832
|
+
var elementListeners, event, j, len, listener, ref, results;
|
833
|
+
ref = this.listeners;
|
834
|
+
results = [];
|
835
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
836
|
+
elementListeners = ref[j];
|
837
|
+
results.push((function() {
|
838
|
+
var ref1, results1;
|
839
|
+
ref1 = elementListeners.events;
|
840
|
+
results1 = [];
|
841
|
+
for (event in ref1) {
|
842
|
+
listener = ref1[event];
|
843
|
+
results1.push(elementListeners.element.removeEventListener(event, listener, false));
|
805
844
|
}
|
806
|
-
return
|
845
|
+
return results1;
|
807
846
|
})());
|
808
847
|
}
|
809
|
-
return
|
848
|
+
return results;
|
810
849
|
};
|
811
850
|
|
812
851
|
Dropzone.prototype.disable = function() {
|
813
|
-
var file,
|
852
|
+
var file, j, len, ref, results;
|
814
853
|
this.clickableElements.forEach(function(element) {
|
815
854
|
return element.classList.remove("dz-clickable");
|
816
855
|
});
|
817
856
|
this.removeEventListeners();
|
818
|
-
|
819
|
-
|
820
|
-
for (
|
821
|
-
file =
|
822
|
-
|
857
|
+
ref = this.files;
|
858
|
+
results = [];
|
859
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
860
|
+
file = ref[j];
|
861
|
+
results.push(this.cancelUpload(file));
|
823
862
|
}
|
824
|
-
return
|
863
|
+
return results;
|
825
864
|
};
|
826
865
|
|
827
866
|
Dropzone.prototype.enable = function() {
|
@@ -832,12 +871,12 @@
|
|
832
871
|
};
|
833
872
|
|
834
873
|
Dropzone.prototype.filesize = function(size) {
|
835
|
-
var cutoff, i, selectedSize, selectedUnit, unit, units
|
874
|
+
var cutoff, i, j, len, selectedSize, selectedUnit, unit, units;
|
836
875
|
selectedSize = 0;
|
837
876
|
selectedUnit = "b";
|
838
877
|
if (size > 0) {
|
839
|
-
units = ['
|
840
|
-
for (i =
|
878
|
+
units = ['tb', 'gb', 'mb', 'kb', 'b'];
|
879
|
+
for (i = j = 0, len = units.length; j < len; i = ++j) {
|
841
880
|
unit = units[i];
|
842
881
|
cutoff = Math.pow(this.options.filesizeBase, 4 - i) / 10;
|
843
882
|
if (size >= cutoff) {
|
@@ -848,7 +887,7 @@
|
|
848
887
|
}
|
849
888
|
selectedSize = Math.round(10 * selectedSize) / 10;
|
850
889
|
}
|
851
|
-
return "<strong>" + selectedSize + "</strong> " + selectedUnit;
|
890
|
+
return "<strong>" + selectedSize + "</strong> " + this.options.dictFileSizeUnits[selectedUnit];
|
852
891
|
};
|
853
892
|
|
854
893
|
Dropzone.prototype._updateMaxFilesReachedClass = function() {
|
@@ -881,8 +920,8 @@
|
|
881
920
|
};
|
882
921
|
|
883
922
|
Dropzone.prototype.paste = function(e) {
|
884
|
-
var items,
|
885
|
-
if ((e != null ? (
|
923
|
+
var items, ref;
|
924
|
+
if ((e != null ? (ref = e.clipboardData) != null ? ref.items : void 0 : void 0) == null) {
|
886
925
|
return;
|
887
926
|
}
|
888
927
|
this.emit("paste", e);
|
@@ -893,39 +932,39 @@
|
|
893
932
|
};
|
894
933
|
|
895
934
|
Dropzone.prototype.handleFiles = function(files) {
|
896
|
-
var file,
|
897
|
-
|
898
|
-
for (
|
899
|
-
file = files[
|
900
|
-
|
935
|
+
var file, j, len, results;
|
936
|
+
results = [];
|
937
|
+
for (j = 0, len = files.length; j < len; j++) {
|
938
|
+
file = files[j];
|
939
|
+
results.push(this.addFile(file));
|
901
940
|
}
|
902
|
-
return
|
941
|
+
return results;
|
903
942
|
};
|
904
943
|
|
905
944
|
Dropzone.prototype._addFilesFromItems = function(items) {
|
906
|
-
var entry, item,
|
907
|
-
|
908
|
-
for (
|
909
|
-
item = items[
|
945
|
+
var entry, item, j, len, results;
|
946
|
+
results = [];
|
947
|
+
for (j = 0, len = items.length; j < len; j++) {
|
948
|
+
item = items[j];
|
910
949
|
if ((item.webkitGetAsEntry != null) && (entry = item.webkitGetAsEntry())) {
|
911
950
|
if (entry.isFile) {
|
912
|
-
|
951
|
+
results.push(this.addFile(item.getAsFile()));
|
913
952
|
} else if (entry.isDirectory) {
|
914
|
-
|
953
|
+
results.push(this._addFilesFromDirectory(entry, entry.name));
|
915
954
|
} else {
|
916
|
-
|
955
|
+
results.push(void 0);
|
917
956
|
}
|
918
957
|
} else if (item.getAsFile != null) {
|
919
958
|
if ((item.kind == null) || item.kind === "file") {
|
920
|
-
|
959
|
+
results.push(this.addFile(item.getAsFile()));
|
921
960
|
} else {
|
922
|
-
|
961
|
+
results.push(void 0);
|
923
962
|
}
|
924
963
|
} else {
|
925
|
-
|
964
|
+
results.push(void 0);
|
926
965
|
}
|
927
966
|
}
|
928
|
-
return
|
967
|
+
return results;
|
929
968
|
};
|
930
969
|
|
931
970
|
Dropzone.prototype._addFilesFromDirectory = function(directory, path) {
|
@@ -937,20 +976,20 @@
|
|
937
976
|
readEntries = (function(_this) {
|
938
977
|
return function() {
|
939
978
|
return dirReader.readEntries(function(entries) {
|
940
|
-
var entry,
|
979
|
+
var entry, j, len;
|
941
980
|
if (entries.length > 0) {
|
942
|
-
for (
|
943
|
-
entry = entries[
|
981
|
+
for (j = 0, len = entries.length; j < len; j++) {
|
982
|
+
entry = entries[j];
|
944
983
|
if (entry.isFile) {
|
945
984
|
entry.file(function(file) {
|
946
985
|
if (_this.options.ignoreHiddenFiles && file.name.substring(0, 1) === '.') {
|
947
986
|
return;
|
948
987
|
}
|
949
|
-
file.fullPath =
|
988
|
+
file.fullPath = path + "/" + file.name;
|
950
989
|
return _this.addFile(file);
|
951
990
|
});
|
952
991
|
} else if (entry.isDirectory) {
|
953
|
-
_this._addFilesFromDirectory(entry,
|
992
|
+
_this._addFilesFromDirectory(entry, path + "/" + entry.name);
|
954
993
|
}
|
955
994
|
}
|
956
995
|
readEntries();
|
@@ -979,7 +1018,8 @@
|
|
979
1018
|
file.upload = {
|
980
1019
|
progress: 0,
|
981
1020
|
total: file.size,
|
982
|
-
bytesSent: 0
|
1021
|
+
bytesSent: 0,
|
1022
|
+
filename: this._renameFile(file)
|
983
1023
|
};
|
984
1024
|
this.files.push(file);
|
985
1025
|
file.status = Dropzone.ADDED;
|
@@ -1002,9 +1042,9 @@
|
|
1002
1042
|
};
|
1003
1043
|
|
1004
1044
|
Dropzone.prototype.enqueueFiles = function(files) {
|
1005
|
-
var file,
|
1006
|
-
for (
|
1007
|
-
file = files[
|
1045
|
+
var file, j, len;
|
1046
|
+
for (j = 0, len = files.length; j < len; j++) {
|
1047
|
+
file = files[j];
|
1008
1048
|
this.enqueueFile(file);
|
1009
1049
|
}
|
1010
1050
|
return null;
|
@@ -1041,12 +1081,15 @@
|
|
1041
1081
|
};
|
1042
1082
|
|
1043
1083
|
Dropzone.prototype._processThumbnailQueue = function() {
|
1084
|
+
var file;
|
1044
1085
|
if (this._processingThumbnail || this._thumbnailQueue.length === 0) {
|
1045
1086
|
return;
|
1046
1087
|
}
|
1047
1088
|
this._processingThumbnail = true;
|
1048
|
-
|
1049
|
-
|
1089
|
+
file = this._thumbnailQueue.shift();
|
1090
|
+
return this.createThumbnail(file, this.options.thumbnailWidth, this.options.thumbnailHeight, this.options.thumbnailMethod, true, (function(_this) {
|
1091
|
+
return function(dataUrl) {
|
1092
|
+
_this.emit("thumbnail", file, dataUrl);
|
1050
1093
|
_this._processingThumbnail = false;
|
1051
1094
|
return _this._processThumbnailQueue();
|
1052
1095
|
};
|
@@ -1065,13 +1108,13 @@
|
|
1065
1108
|
};
|
1066
1109
|
|
1067
1110
|
Dropzone.prototype.removeAllFiles = function(cancelIfNecessary) {
|
1068
|
-
var file,
|
1111
|
+
var file, j, len, ref;
|
1069
1112
|
if (cancelIfNecessary == null) {
|
1070
1113
|
cancelIfNecessary = false;
|
1071
1114
|
}
|
1072
|
-
|
1073
|
-
for (
|
1074
|
-
file =
|
1115
|
+
ref = this.files.slice();
|
1116
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
1117
|
+
file = ref[j];
|
1075
1118
|
if (file.status !== Dropzone.UPLOADING || cancelIfNecessary) {
|
1076
1119
|
this.removeFile(file);
|
1077
1120
|
}
|
@@ -1079,25 +1122,46 @@
|
|
1079
1122
|
return null;
|
1080
1123
|
};
|
1081
1124
|
|
1082
|
-
Dropzone.prototype.
|
1125
|
+
Dropzone.prototype.resizeImage = function(file, width, height, resizeMethod, callback) {
|
1126
|
+
return this.createThumbnail(file, width, height, resizeMethod, false, (function(_this) {
|
1127
|
+
return function(dataUrl, canvas) {
|
1128
|
+
var resizeMimeType, resizedDataURL;
|
1129
|
+
if (canvas === null) {
|
1130
|
+
return callback(file);
|
1131
|
+
} else {
|
1132
|
+
resizeMimeType = _this.options.resizeMimeType;
|
1133
|
+
if (resizeMimeType == null) {
|
1134
|
+
resizeMimeType = file.type;
|
1135
|
+
}
|
1136
|
+
resizedDataURL = canvas.toDataURL(resizeMimeType, _this.options.resizeQuality);
|
1137
|
+
if (resizeMimeType === 'image/jpeg' || resizeMimeType === 'image/jpg') {
|
1138
|
+
resizedDataURL = ExifRestore.restore(file.dataURL, resizedDataURL);
|
1139
|
+
}
|
1140
|
+
return callback(Dropzone.dataURItoBlob(resizedDataURL));
|
1141
|
+
}
|
1142
|
+
};
|
1143
|
+
})(this));
|
1144
|
+
};
|
1145
|
+
|
1146
|
+
Dropzone.prototype.createThumbnail = function(file, width, height, resizeMethod, fixOrientation, callback) {
|
1083
1147
|
var fileReader;
|
1084
1148
|
fileReader = new FileReader;
|
1085
1149
|
fileReader.onload = (function(_this) {
|
1086
1150
|
return function() {
|
1151
|
+
file.dataURL = fileReader.result;
|
1087
1152
|
if (file.type === "image/svg+xml") {
|
1088
|
-
_this.emit("thumbnail", file, fileReader.result);
|
1089
1153
|
if (callback != null) {
|
1090
|
-
callback();
|
1154
|
+
callback(fileReader.result);
|
1091
1155
|
}
|
1092
1156
|
return;
|
1093
1157
|
}
|
1094
|
-
return _this.createThumbnailFromUrl(file,
|
1158
|
+
return _this.createThumbnailFromUrl(file, width, height, resizeMethod, fixOrientation, callback);
|
1095
1159
|
};
|
1096
1160
|
})(this);
|
1097
1161
|
return fileReader.readAsDataURL(file);
|
1098
1162
|
};
|
1099
1163
|
|
1100
|
-
Dropzone.prototype.createThumbnailFromUrl = function(file,
|
1164
|
+
Dropzone.prototype.createThumbnailFromUrl = function(file, width, height, resizeMethod, fixOrientation, callback, crossOrigin) {
|
1101
1165
|
var img;
|
1102
1166
|
img = document.createElement("img");
|
1103
1167
|
if (crossOrigin) {
|
@@ -1105,32 +1169,72 @@
|
|
1105
1169
|
}
|
1106
1170
|
img.onload = (function(_this) {
|
1107
1171
|
return function() {
|
1108
|
-
var
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
if (
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
canvas = document.createElement("canvas");
|
1119
|
-
ctx = canvas.getContext("2d");
|
1120
|
-
canvas.width = resizeInfo.trgWidth;
|
1121
|
-
canvas.height = resizeInfo.trgHeight;
|
1122
|
-
drawImageIOSFix(ctx, img, (_ref = resizeInfo.srcX) != null ? _ref : 0, (_ref1 = resizeInfo.srcY) != null ? _ref1 : 0, resizeInfo.srcWidth, resizeInfo.srcHeight, (_ref2 = resizeInfo.trgX) != null ? _ref2 : 0, (_ref3 = resizeInfo.trgY) != null ? _ref3 : 0, resizeInfo.trgWidth, resizeInfo.trgHeight);
|
1123
|
-
thumbnail = canvas.toDataURL("image/png");
|
1124
|
-
_this.emit("thumbnail", file, thumbnail);
|
1125
|
-
if (callback != null) {
|
1126
|
-
return callback();
|
1172
|
+
var loadExif;
|
1173
|
+
loadExif = function(callback) {
|
1174
|
+
return callback(1);
|
1175
|
+
};
|
1176
|
+
if ((typeof EXIF !== "undefined" && EXIF !== null) && fixOrientation) {
|
1177
|
+
loadExif = function(callback) {
|
1178
|
+
return EXIF.getData(img, function() {
|
1179
|
+
return callback(EXIF.getTag(this, 'Orientation'));
|
1180
|
+
});
|
1181
|
+
};
|
1127
1182
|
}
|
1183
|
+
return loadExif(function(orientation) {
|
1184
|
+
var canvas, ctx, ref, ref1, ref2, ref3, resizeInfo, thumbnail;
|
1185
|
+
file.width = img.width;
|
1186
|
+
file.height = img.height;
|
1187
|
+
resizeInfo = _this.options.resize.call(_this, file, width, height, resizeMethod);
|
1188
|
+
canvas = document.createElement("canvas");
|
1189
|
+
ctx = canvas.getContext("2d");
|
1190
|
+
canvas.width = resizeInfo.trgWidth;
|
1191
|
+
canvas.height = resizeInfo.trgHeight;
|
1192
|
+
if (orientation > 4) {
|
1193
|
+
canvas.width = resizeInfo.trgHeight;
|
1194
|
+
canvas.height = resizeInfo.trgWidth;
|
1195
|
+
}
|
1196
|
+
switch (orientation) {
|
1197
|
+
case 2:
|
1198
|
+
ctx.translate(canvas.width, 0);
|
1199
|
+
ctx.scale(-1, 1);
|
1200
|
+
break;
|
1201
|
+
case 3:
|
1202
|
+
ctx.translate(canvas.width, canvas.height);
|
1203
|
+
ctx.rotate(Math.PI);
|
1204
|
+
break;
|
1205
|
+
case 4:
|
1206
|
+
ctx.translate(0, canvas.height);
|
1207
|
+
ctx.scale(1, -1);
|
1208
|
+
break;
|
1209
|
+
case 5:
|
1210
|
+
ctx.rotate(0.5 * Math.PI);
|
1211
|
+
ctx.scale(1, -1);
|
1212
|
+
break;
|
1213
|
+
case 6:
|
1214
|
+
ctx.rotate(0.5 * Math.PI);
|
1215
|
+
ctx.translate(0, -canvas.height);
|
1216
|
+
break;
|
1217
|
+
case 7:
|
1218
|
+
ctx.rotate(0.5 * Math.PI);
|
1219
|
+
ctx.translate(canvas.width, -canvas.height);
|
1220
|
+
ctx.scale(-1, 1);
|
1221
|
+
break;
|
1222
|
+
case 8:
|
1223
|
+
ctx.rotate(-0.5 * Math.PI);
|
1224
|
+
ctx.translate(-canvas.width, 0);
|
1225
|
+
}
|
1226
|
+
drawImageIOSFix(ctx, img, (ref = resizeInfo.srcX) != null ? ref : 0, (ref1 = resizeInfo.srcY) != null ? ref1 : 0, resizeInfo.srcWidth, resizeInfo.srcHeight, (ref2 = resizeInfo.trgX) != null ? ref2 : 0, (ref3 = resizeInfo.trgY) != null ? ref3 : 0, resizeInfo.trgWidth, resizeInfo.trgHeight);
|
1227
|
+
thumbnail = canvas.toDataURL("image/png");
|
1228
|
+
if (callback != null) {
|
1229
|
+
return callback(thumbnail, canvas);
|
1230
|
+
}
|
1231
|
+
});
|
1128
1232
|
};
|
1129
1233
|
})(this);
|
1130
1234
|
if (callback != null) {
|
1131
1235
|
img.onerror = callback;
|
1132
1236
|
}
|
1133
|
-
return img.src =
|
1237
|
+
return img.src = file.dataURL;
|
1134
1238
|
};
|
1135
1239
|
|
1136
1240
|
Dropzone.prototype.processQueue = function() {
|
@@ -1163,9 +1267,9 @@
|
|
1163
1267
|
};
|
1164
1268
|
|
1165
1269
|
Dropzone.prototype.processFiles = function(files) {
|
1166
|
-
var file,
|
1167
|
-
for (
|
1168
|
-
file = files[
|
1270
|
+
var file, j, len;
|
1271
|
+
for (j = 0, len = files.length; j < len; j++) {
|
1272
|
+
file = files[j];
|
1169
1273
|
file.processing = true;
|
1170
1274
|
file.status = Dropzone.UPLOADING;
|
1171
1275
|
this.emit("processing", file);
|
@@ -1179,36 +1283,36 @@
|
|
1179
1283
|
Dropzone.prototype._getFilesWithXhr = function(xhr) {
|
1180
1284
|
var file, files;
|
1181
1285
|
return files = (function() {
|
1182
|
-
var
|
1183
|
-
|
1184
|
-
|
1185
|
-
for (
|
1186
|
-
file =
|
1286
|
+
var j, len, ref, results;
|
1287
|
+
ref = this.files;
|
1288
|
+
results = [];
|
1289
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
1290
|
+
file = ref[j];
|
1187
1291
|
if (file.xhr === xhr) {
|
1188
|
-
|
1292
|
+
results.push(file);
|
1189
1293
|
}
|
1190
1294
|
}
|
1191
|
-
return
|
1295
|
+
return results;
|
1192
1296
|
}).call(this);
|
1193
1297
|
};
|
1194
1298
|
|
1195
1299
|
Dropzone.prototype.cancelUpload = function(file) {
|
1196
|
-
var groupedFile, groupedFiles,
|
1300
|
+
var groupedFile, groupedFiles, j, k, len, len1, ref;
|
1197
1301
|
if (file.status === Dropzone.UPLOADING) {
|
1198
1302
|
groupedFiles = this._getFilesWithXhr(file.xhr);
|
1199
|
-
for (
|
1200
|
-
groupedFile = groupedFiles[
|
1303
|
+
for (j = 0, len = groupedFiles.length; j < len; j++) {
|
1304
|
+
groupedFile = groupedFiles[j];
|
1201
1305
|
groupedFile.status = Dropzone.CANCELED;
|
1202
1306
|
}
|
1203
1307
|
file.xhr.abort();
|
1204
|
-
for (
|
1205
|
-
groupedFile = groupedFiles[
|
1308
|
+
for (k = 0, len1 = groupedFiles.length; k < len1; k++) {
|
1309
|
+
groupedFile = groupedFiles[k];
|
1206
1310
|
this.emit("canceled", groupedFile);
|
1207
1311
|
}
|
1208
1312
|
if (this.options.uploadMultiple) {
|
1209
1313
|
this.emit("canceledmultiple", groupedFiles);
|
1210
1314
|
}
|
1211
|
-
} else if ((
|
1315
|
+
} else if ((ref = file.status) === Dropzone.ADDED || ref === Dropzone.QUEUED) {
|
1212
1316
|
file.status = Dropzone.CANCELED;
|
1213
1317
|
this.emit("canceled", file);
|
1214
1318
|
if (this.options.uploadMultiple) {
|
@@ -1222,7 +1326,7 @@
|
|
1222
1326
|
|
1223
1327
|
resolveOption = function() {
|
1224
1328
|
var args, option;
|
1225
|
-
option = arguments[0], args = 2 <= arguments.length ?
|
1329
|
+
option = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
1226
1330
|
if (typeof option === 'function') {
|
1227
1331
|
return option.apply(this, args);
|
1228
1332
|
}
|
@@ -1234,35 +1338,36 @@
|
|
1234
1338
|
};
|
1235
1339
|
|
1236
1340
|
Dropzone.prototype.uploadFiles = function(files) {
|
1237
|
-
var file, formData, handleError, headerName, headerValue, headers, i, input, inputName, inputType,
|
1341
|
+
var doneCounter, doneFunction, file, formData, handleError, headerName, headerValue, headers, i, input, inputName, inputType, j, k, key, l, len, len1, len2, len3, m, method, o, option, progressObj, ref, ref1, ref2, ref3, ref4, ref5, response, results, updateProgress, url, value, xhr;
|
1238
1342
|
xhr = new XMLHttpRequest();
|
1239
|
-
for (
|
1240
|
-
file = files[
|
1343
|
+
for (j = 0, len = files.length; j < len; j++) {
|
1344
|
+
file = files[j];
|
1241
1345
|
file.xhr = xhr;
|
1242
1346
|
}
|
1243
1347
|
method = resolveOption(this.options.method, files);
|
1244
1348
|
url = resolveOption(this.options.url, files);
|
1245
1349
|
xhr.open(method, url, true);
|
1350
|
+
xhr.timeout = resolveOption(this.options.timeout, files);
|
1246
1351
|
xhr.withCredentials = !!this.options.withCredentials;
|
1247
1352
|
response = null;
|
1248
1353
|
handleError = (function(_this) {
|
1249
1354
|
return function() {
|
1250
|
-
var
|
1251
|
-
|
1252
|
-
for (
|
1253
|
-
file = files[
|
1254
|
-
|
1355
|
+
var k, len1, results;
|
1356
|
+
results = [];
|
1357
|
+
for (k = 0, len1 = files.length; k < len1; k++) {
|
1358
|
+
file = files[k];
|
1359
|
+
results.push(_this._errorProcessing(files, response || _this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr));
|
1255
1360
|
}
|
1256
|
-
return
|
1361
|
+
return results;
|
1257
1362
|
};
|
1258
1363
|
})(this);
|
1259
1364
|
updateProgress = (function(_this) {
|
1260
1365
|
return function(e) {
|
1261
|
-
var allFilesFinished,
|
1366
|
+
var allFilesFinished, k, l, len1, len2, len3, m, progress, results;
|
1262
1367
|
if (e != null) {
|
1263
1368
|
progress = 100 * e.loaded / e.total;
|
1264
|
-
for (
|
1265
|
-
file = files[
|
1369
|
+
for (k = 0, len1 = files.length; k < len1; k++) {
|
1370
|
+
file = files[k];
|
1266
1371
|
file.upload = {
|
1267
1372
|
progress: progress,
|
1268
1373
|
total: e.total,
|
@@ -1272,8 +1377,8 @@
|
|
1272
1377
|
} else {
|
1273
1378
|
allFilesFinished = true;
|
1274
1379
|
progress = 100;
|
1275
|
-
for (
|
1276
|
-
file = files[
|
1380
|
+
for (l = 0, len2 = files.length; l < len2; l++) {
|
1381
|
+
file = files[l];
|
1277
1382
|
if (!(file.upload.progress === 100 && file.upload.bytesSent === file.upload.total)) {
|
1278
1383
|
allFilesFinished = false;
|
1279
1384
|
}
|
@@ -1284,17 +1389,17 @@
|
|
1284
1389
|
return;
|
1285
1390
|
}
|
1286
1391
|
}
|
1287
|
-
|
1288
|
-
for (
|
1289
|
-
file = files[
|
1290
|
-
|
1392
|
+
results = [];
|
1393
|
+
for (m = 0, len3 = files.length; m < len3; m++) {
|
1394
|
+
file = files[m];
|
1395
|
+
results.push(_this.emit("uploadprogress", file, progress, file.upload.bytesSent));
|
1291
1396
|
}
|
1292
|
-
return
|
1397
|
+
return results;
|
1293
1398
|
};
|
1294
1399
|
})(this);
|
1295
1400
|
xhr.onload = (function(_this) {
|
1296
1401
|
return function(e) {
|
1297
|
-
var
|
1402
|
+
var error1, ref;
|
1298
1403
|
if (files[0].status === Dropzone.CANCELED) {
|
1299
1404
|
return;
|
1300
1405
|
}
|
@@ -1305,13 +1410,13 @@
|
|
1305
1410
|
if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) {
|
1306
1411
|
try {
|
1307
1412
|
response = JSON.parse(response);
|
1308
|
-
} catch (
|
1309
|
-
e =
|
1413
|
+
} catch (error1) {
|
1414
|
+
e = error1;
|
1310
1415
|
response = "Invalid JSON response from server.";
|
1311
1416
|
}
|
1312
1417
|
}
|
1313
1418
|
updateProgress();
|
1314
|
-
if (!((200 <= (
|
1419
|
+
if (!((200 <= (ref = xhr.status) && ref < 300))) {
|
1315
1420
|
return handleError();
|
1316
1421
|
} else {
|
1317
1422
|
return _this._finished(files, response, e);
|
@@ -1326,7 +1431,7 @@
|
|
1326
1431
|
return handleError();
|
1327
1432
|
};
|
1328
1433
|
})(this);
|
1329
|
-
progressObj = (
|
1434
|
+
progressObj = (ref = xhr.upload) != null ? ref : xhr;
|
1330
1435
|
progressObj.onprogress = updateProgress;
|
1331
1436
|
headers = {
|
1332
1437
|
"Accept": "application/json",
|
@@ -1344,42 +1449,54 @@
|
|
1344
1449
|
}
|
1345
1450
|
formData = new FormData();
|
1346
1451
|
if (this.options.params) {
|
1347
|
-
|
1348
|
-
for (key in
|
1349
|
-
value =
|
1452
|
+
ref1 = this.options.params;
|
1453
|
+
for (key in ref1) {
|
1454
|
+
value = ref1[key];
|
1350
1455
|
formData.append(key, value);
|
1351
1456
|
}
|
1352
1457
|
}
|
1353
|
-
for (
|
1354
|
-
file = files[
|
1458
|
+
for (k = 0, len1 = files.length; k < len1; k++) {
|
1459
|
+
file = files[k];
|
1355
1460
|
this.emit("sending", file, xhr, formData);
|
1356
1461
|
}
|
1357
1462
|
if (this.options.uploadMultiple) {
|
1358
1463
|
this.emit("sendingmultiple", files, xhr, formData);
|
1359
1464
|
}
|
1360
1465
|
if (this.element.tagName === "FORM") {
|
1361
|
-
|
1362
|
-
for (
|
1363
|
-
input =
|
1466
|
+
ref2 = this.element.querySelectorAll("input, textarea, select, button");
|
1467
|
+
for (l = 0, len2 = ref2.length; l < len2; l++) {
|
1468
|
+
input = ref2[l];
|
1364
1469
|
inputName = input.getAttribute("name");
|
1365
1470
|
inputType = input.getAttribute("type");
|
1366
1471
|
if (input.tagName === "SELECT" && input.hasAttribute("multiple")) {
|
1367
|
-
|
1368
|
-
for (
|
1369
|
-
option =
|
1472
|
+
ref3 = input.options;
|
1473
|
+
for (m = 0, len3 = ref3.length; m < len3; m++) {
|
1474
|
+
option = ref3[m];
|
1370
1475
|
if (option.selected) {
|
1371
1476
|
formData.append(inputName, option.value);
|
1372
1477
|
}
|
1373
1478
|
}
|
1374
|
-
} else if (!inputType || ((
|
1479
|
+
} else if (!inputType || ((ref4 = inputType.toLowerCase()) !== "checkbox" && ref4 !== "radio") || input.checked) {
|
1375
1480
|
formData.append(inputName, input.value);
|
1376
1481
|
}
|
1377
1482
|
}
|
1378
1483
|
}
|
1379
|
-
|
1380
|
-
|
1484
|
+
doneCounter = 0;
|
1485
|
+
results = [];
|
1486
|
+
for (i = o = 0, ref5 = files.length - 1; 0 <= ref5 ? o <= ref5 : o >= ref5; i = 0 <= ref5 ? ++o : --o) {
|
1487
|
+
doneFunction = (function(_this) {
|
1488
|
+
return function(file, paramName, fileName) {
|
1489
|
+
return function(transformedFile) {
|
1490
|
+
formData.append(paramName, transformedFile, fileName);
|
1491
|
+
if (++doneCounter === files.length) {
|
1492
|
+
return _this.submitRequest(xhr, formData, files);
|
1493
|
+
}
|
1494
|
+
};
|
1495
|
+
};
|
1496
|
+
})(this);
|
1497
|
+
results.push(this.options.transformFile.call(this, files[i], doneFunction(files[i], this._getParamName(i), files[i].upload.filename)));
|
1381
1498
|
}
|
1382
|
-
return
|
1499
|
+
return results;
|
1383
1500
|
};
|
1384
1501
|
|
1385
1502
|
Dropzone.prototype.submitRequest = function(xhr, formData, files) {
|
@@ -1387,9 +1504,9 @@
|
|
1387
1504
|
};
|
1388
1505
|
|
1389
1506
|
Dropzone.prototype._finished = function(files, responseText, e) {
|
1390
|
-
var file,
|
1391
|
-
for (
|
1392
|
-
file = files[
|
1507
|
+
var file, j, len;
|
1508
|
+
for (j = 0, len = files.length; j < len; j++) {
|
1509
|
+
file = files[j];
|
1393
1510
|
file.status = Dropzone.SUCCESS;
|
1394
1511
|
this.emit("success", file, responseText, e);
|
1395
1512
|
this.emit("complete", file);
|
@@ -1404,9 +1521,9 @@
|
|
1404
1521
|
};
|
1405
1522
|
|
1406
1523
|
Dropzone.prototype._errorProcessing = function(files, message, xhr) {
|
1407
|
-
var file,
|
1408
|
-
for (
|
1409
|
-
file = files[
|
1524
|
+
var file, j, len;
|
1525
|
+
for (j = 0, len = files.length; j < len; j++) {
|
1526
|
+
file = files[j];
|
1410
1527
|
file.status = Dropzone.ERROR;
|
1411
1528
|
this.emit("error", file, message, xhr);
|
1412
1529
|
this.emit("complete", file);
|
@@ -1424,7 +1541,7 @@
|
|
1424
1541
|
|
1425
1542
|
})(Emitter);
|
1426
1543
|
|
1427
|
-
Dropzone.version = "
|
1544
|
+
Dropzone.version = "5.1.0";
|
1428
1545
|
|
1429
1546
|
Dropzone.options = {};
|
1430
1547
|
|
@@ -1451,51 +1568,51 @@
|
|
1451
1568
|
Dropzone.autoDiscover = true;
|
1452
1569
|
|
1453
1570
|
Dropzone.discover = function() {
|
1454
|
-
var checkElements, dropzone, dropzones,
|
1571
|
+
var checkElements, dropzone, dropzones, j, len, results;
|
1455
1572
|
if (document.querySelectorAll) {
|
1456
1573
|
dropzones = document.querySelectorAll(".dropzone");
|
1457
1574
|
} else {
|
1458
1575
|
dropzones = [];
|
1459
1576
|
checkElements = function(elements) {
|
1460
|
-
var el,
|
1461
|
-
|
1462
|
-
for (
|
1463
|
-
el = elements[
|
1577
|
+
var el, j, len, results;
|
1578
|
+
results = [];
|
1579
|
+
for (j = 0, len = elements.length; j < len; j++) {
|
1580
|
+
el = elements[j];
|
1464
1581
|
if (/(^| )dropzone($| )/.test(el.className)) {
|
1465
|
-
|
1582
|
+
results.push(dropzones.push(el));
|
1466
1583
|
} else {
|
1467
|
-
|
1584
|
+
results.push(void 0);
|
1468
1585
|
}
|
1469
1586
|
}
|
1470
|
-
return
|
1587
|
+
return results;
|
1471
1588
|
};
|
1472
1589
|
checkElements(document.getElementsByTagName("div"));
|
1473
1590
|
checkElements(document.getElementsByTagName("form"));
|
1474
1591
|
}
|
1475
|
-
|
1476
|
-
for (
|
1477
|
-
dropzone = dropzones[
|
1592
|
+
results = [];
|
1593
|
+
for (j = 0, len = dropzones.length; j < len; j++) {
|
1594
|
+
dropzone = dropzones[j];
|
1478
1595
|
if (Dropzone.optionsForElement(dropzone) !== false) {
|
1479
|
-
|
1596
|
+
results.push(new Dropzone(dropzone));
|
1480
1597
|
} else {
|
1481
|
-
|
1598
|
+
results.push(void 0);
|
1482
1599
|
}
|
1483
1600
|
}
|
1484
|
-
return
|
1601
|
+
return results;
|
1485
1602
|
};
|
1486
1603
|
|
1487
1604
|
Dropzone.blacklistedBrowsers = [/opera.*Macintosh.*version\/12/i];
|
1488
1605
|
|
1489
1606
|
Dropzone.isBrowserSupported = function() {
|
1490
|
-
var capableBrowser,
|
1607
|
+
var capableBrowser, j, len, ref, regex;
|
1491
1608
|
capableBrowser = true;
|
1492
1609
|
if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) {
|
1493
1610
|
if (!("classList" in document.createElement("a"))) {
|
1494
1611
|
capableBrowser = false;
|
1495
1612
|
} else {
|
1496
|
-
|
1497
|
-
for (
|
1498
|
-
regex =
|
1613
|
+
ref = Dropzone.blacklistedBrowsers;
|
1614
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
1615
|
+
regex = ref[j];
|
1499
1616
|
if (regex.test(navigator.userAgent)) {
|
1500
1617
|
capableBrowser = false;
|
1501
1618
|
continue;
|
@@ -1508,16 +1625,30 @@
|
|
1508
1625
|
return capableBrowser;
|
1509
1626
|
};
|
1510
1627
|
|
1628
|
+
Dropzone.dataURItoBlob = function(dataURI) {
|
1629
|
+
var ab, byteString, i, ia, j, mimeString, ref;
|
1630
|
+
byteString = atob(dataURI.split(',')[1]);
|
1631
|
+
mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
|
1632
|
+
ab = new ArrayBuffer(byteString.length);
|
1633
|
+
ia = new Uint8Array(ab);
|
1634
|
+
for (i = j = 0, ref = byteString.length; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) {
|
1635
|
+
ia[i] = byteString.charCodeAt(i);
|
1636
|
+
}
|
1637
|
+
return new Blob([ab], {
|
1638
|
+
type: mimeString
|
1639
|
+
});
|
1640
|
+
};
|
1641
|
+
|
1511
1642
|
without = function(list, rejectedItem) {
|
1512
|
-
var item,
|
1513
|
-
|
1514
|
-
for (
|
1515
|
-
item = list[
|
1643
|
+
var item, j, len, results;
|
1644
|
+
results = [];
|
1645
|
+
for (j = 0, len = list.length; j < len; j++) {
|
1646
|
+
item = list[j];
|
1516
1647
|
if (item !== rejectedItem) {
|
1517
|
-
|
1648
|
+
results.push(item);
|
1518
1649
|
}
|
1519
1650
|
}
|
1520
|
-
return
|
1651
|
+
return results;
|
1521
1652
|
};
|
1522
1653
|
|
1523
1654
|
camelize = function(str) {
|
@@ -1559,23 +1690,23 @@
|
|
1559
1690
|
};
|
1560
1691
|
|
1561
1692
|
Dropzone.getElements = function(els, name) {
|
1562
|
-
var e, el, elements,
|
1693
|
+
var e, el, elements, error1, j, k, len, len1, ref;
|
1563
1694
|
if (els instanceof Array) {
|
1564
1695
|
elements = [];
|
1565
1696
|
try {
|
1566
|
-
for (
|
1567
|
-
el = els[
|
1697
|
+
for (j = 0, len = els.length; j < len; j++) {
|
1698
|
+
el = els[j];
|
1568
1699
|
elements.push(this.getElement(el, name));
|
1569
1700
|
}
|
1570
|
-
} catch (
|
1571
|
-
e =
|
1701
|
+
} catch (error1) {
|
1702
|
+
e = error1;
|
1572
1703
|
elements = null;
|
1573
1704
|
}
|
1574
1705
|
} else if (typeof els === "string") {
|
1575
1706
|
elements = [];
|
1576
|
-
|
1577
|
-
for (
|
1578
|
-
el =
|
1707
|
+
ref = document.querySelectorAll(els);
|
1708
|
+
for (k = 0, len1 = ref.length; k < len1; k++) {
|
1709
|
+
el = ref[k];
|
1579
1710
|
elements.push(el);
|
1580
1711
|
}
|
1581
1712
|
} else if (els.nodeType != null) {
|
@@ -1596,15 +1727,15 @@
|
|
1596
1727
|
};
|
1597
1728
|
|
1598
1729
|
Dropzone.isValidFile = function(file, acceptedFiles) {
|
1599
|
-
var baseMimeType,
|
1730
|
+
var baseMimeType, j, len, mimeType, validType;
|
1600
1731
|
if (!acceptedFiles) {
|
1601
1732
|
return true;
|
1602
1733
|
}
|
1603
1734
|
acceptedFiles = acceptedFiles.split(",");
|
1604
1735
|
mimeType = file.type;
|
1605
1736
|
baseMimeType = mimeType.replace(/\/.*$/, "");
|
1606
|
-
for (
|
1607
|
-
validType = acceptedFiles[
|
1737
|
+
for (j = 0, len = acceptedFiles.length; j < len; j++) {
|
1738
|
+
validType = acceptedFiles[j];
|
1608
1739
|
validType = validType.trim();
|
1609
1740
|
if (validType.charAt(0) === ".") {
|
1610
1741
|
if (file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.length - validType.length) !== -1) {
|
@@ -1670,7 +1801,7 @@
|
|
1670
1801
|
canvas.height = ih;
|
1671
1802
|
ctx = canvas.getContext("2d");
|
1672
1803
|
ctx.drawImage(img, 0, 0);
|
1673
|
-
data = ctx.getImageData(
|
1804
|
+
data = ctx.getImageData(1, 0, 1, ih).data;
|
1674
1805
|
sy = 0;
|
1675
1806
|
ey = ih;
|
1676
1807
|
py = ih;
|
@@ -1697,6 +1828,160 @@
|
|
1697
1828
|
return ctx.drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh / vertSquashRatio);
|
1698
1829
|
};
|
1699
1830
|
|
1831
|
+
ExifRestore = (function() {
|
1832
|
+
function ExifRestore() {}
|
1833
|
+
|
1834
|
+
ExifRestore.KEY_STR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
1835
|
+
|
1836
|
+
ExifRestore.encode64 = function(input) {
|
1837
|
+
var chr1, chr2, chr3, enc1, enc2, enc3, enc4, i, output;
|
1838
|
+
output = '';
|
1839
|
+
chr1 = void 0;
|
1840
|
+
chr2 = void 0;
|
1841
|
+
chr3 = '';
|
1842
|
+
enc1 = void 0;
|
1843
|
+
enc2 = void 0;
|
1844
|
+
enc3 = void 0;
|
1845
|
+
enc4 = '';
|
1846
|
+
i = 0;
|
1847
|
+
while (true) {
|
1848
|
+
chr1 = input[i++];
|
1849
|
+
chr2 = input[i++];
|
1850
|
+
chr3 = input[i++];
|
1851
|
+
enc1 = chr1 >> 2;
|
1852
|
+
enc2 = (chr1 & 3) << 4 | chr2 >> 4;
|
1853
|
+
enc3 = (chr2 & 15) << 2 | chr3 >> 6;
|
1854
|
+
enc4 = chr3 & 63;
|
1855
|
+
if (isNaN(chr2)) {
|
1856
|
+
enc3 = enc4 = 64;
|
1857
|
+
} else if (isNaN(chr3)) {
|
1858
|
+
enc4 = 64;
|
1859
|
+
}
|
1860
|
+
output = output + this.KEY_STR.charAt(enc1) + this.KEY_STR.charAt(enc2) + this.KEY_STR.charAt(enc3) + this.KEY_STR.charAt(enc4);
|
1861
|
+
chr1 = chr2 = chr3 = '';
|
1862
|
+
enc1 = enc2 = enc3 = enc4 = '';
|
1863
|
+
if (!(i < input.length)) {
|
1864
|
+
break;
|
1865
|
+
}
|
1866
|
+
}
|
1867
|
+
return output;
|
1868
|
+
};
|
1869
|
+
|
1870
|
+
ExifRestore.restore = function(origFileBase64, resizedFileBase64) {
|
1871
|
+
var image, rawImage, segments;
|
1872
|
+
if (!origFileBase64.match('data:image/jpeg;base64,')) {
|
1873
|
+
return resizedFileBase64;
|
1874
|
+
}
|
1875
|
+
rawImage = this.decode64(origFileBase64.replace('data:image/jpeg;base64,', ''));
|
1876
|
+
segments = this.slice2Segments(rawImage);
|
1877
|
+
image = this.exifManipulation(resizedFileBase64, segments);
|
1878
|
+
return 'data:image/jpeg;base64,' + this.encode64(image);
|
1879
|
+
};
|
1880
|
+
|
1881
|
+
ExifRestore.exifManipulation = function(resizedFileBase64, segments) {
|
1882
|
+
var aBuffer, exifArray, newImageArray;
|
1883
|
+
exifArray = this.getExifArray(segments);
|
1884
|
+
newImageArray = this.insertExif(resizedFileBase64, exifArray);
|
1885
|
+
aBuffer = new Uint8Array(newImageArray);
|
1886
|
+
return aBuffer;
|
1887
|
+
};
|
1888
|
+
|
1889
|
+
ExifRestore.getExifArray = function(segments) {
|
1890
|
+
var seg, x;
|
1891
|
+
seg = void 0;
|
1892
|
+
x = 0;
|
1893
|
+
while (x < segments.length) {
|
1894
|
+
seg = segments[x];
|
1895
|
+
if (seg[0] === 255 & seg[1] === 225) {
|
1896
|
+
return seg;
|
1897
|
+
}
|
1898
|
+
x++;
|
1899
|
+
}
|
1900
|
+
return [];
|
1901
|
+
};
|
1902
|
+
|
1903
|
+
ExifRestore.insertExif = function(resizedFileBase64, exifArray) {
|
1904
|
+
var array, ato, buf, imageData, mae, separatePoint;
|
1905
|
+
imageData = resizedFileBase64.replace('data:image/jpeg;base64,', '');
|
1906
|
+
buf = this.decode64(imageData);
|
1907
|
+
separatePoint = buf.indexOf(255, 3);
|
1908
|
+
mae = buf.slice(0, separatePoint);
|
1909
|
+
ato = buf.slice(separatePoint);
|
1910
|
+
array = mae;
|
1911
|
+
array = array.concat(exifArray);
|
1912
|
+
array = array.concat(ato);
|
1913
|
+
return array;
|
1914
|
+
};
|
1915
|
+
|
1916
|
+
ExifRestore.slice2Segments = function(rawImageArray) {
|
1917
|
+
var endPoint, head, length, seg, segments;
|
1918
|
+
head = 0;
|
1919
|
+
segments = [];
|
1920
|
+
while (true) {
|
1921
|
+
if (rawImageArray[head] === 255 & rawImageArray[head + 1] === 218) {
|
1922
|
+
break;
|
1923
|
+
}
|
1924
|
+
if (rawImageArray[head] === 255 & rawImageArray[head + 1] === 216) {
|
1925
|
+
head += 2;
|
1926
|
+
} else {
|
1927
|
+
length = rawImageArray[head + 2] * 256 + rawImageArray[head + 3];
|
1928
|
+
endPoint = head + length + 2;
|
1929
|
+
seg = rawImageArray.slice(head, endPoint);
|
1930
|
+
segments.push(seg);
|
1931
|
+
head = endPoint;
|
1932
|
+
}
|
1933
|
+
if (head > rawImageArray.length) {
|
1934
|
+
break;
|
1935
|
+
}
|
1936
|
+
}
|
1937
|
+
return segments;
|
1938
|
+
};
|
1939
|
+
|
1940
|
+
ExifRestore.decode64 = function(input) {
|
1941
|
+
var base64test, buf, chr1, chr2, chr3, enc1, enc2, enc3, enc4, i, output;
|
1942
|
+
output = '';
|
1943
|
+
chr1 = void 0;
|
1944
|
+
chr2 = void 0;
|
1945
|
+
chr3 = '';
|
1946
|
+
enc1 = void 0;
|
1947
|
+
enc2 = void 0;
|
1948
|
+
enc3 = void 0;
|
1949
|
+
enc4 = '';
|
1950
|
+
i = 0;
|
1951
|
+
buf = [];
|
1952
|
+
base64test = /[^A-Za-z0-9\+\/\=]/g;
|
1953
|
+
if (base64test.exec(input)) {
|
1954
|
+
console.warning('There were invalid base64 characters in the input text.\n' + 'Valid base64 characters are A-Z, a-z, 0-9, \'+\', \'/\',and \'=\'\n' + 'Expect errors in decoding.');
|
1955
|
+
}
|
1956
|
+
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
|
1957
|
+
while (true) {
|
1958
|
+
enc1 = this.KEY_STR.indexOf(input.charAt(i++));
|
1959
|
+
enc2 = this.KEY_STR.indexOf(input.charAt(i++));
|
1960
|
+
enc3 = this.KEY_STR.indexOf(input.charAt(i++));
|
1961
|
+
enc4 = this.KEY_STR.indexOf(input.charAt(i++));
|
1962
|
+
chr1 = enc1 << 2 | enc2 >> 4;
|
1963
|
+
chr2 = (enc2 & 15) << 4 | enc3 >> 2;
|
1964
|
+
chr3 = (enc3 & 3) << 6 | enc4;
|
1965
|
+
buf.push(chr1);
|
1966
|
+
if (enc3 !== 64) {
|
1967
|
+
buf.push(chr2);
|
1968
|
+
}
|
1969
|
+
if (enc4 !== 64) {
|
1970
|
+
buf.push(chr3);
|
1971
|
+
}
|
1972
|
+
chr1 = chr2 = chr3 = '';
|
1973
|
+
enc1 = enc2 = enc3 = enc4 = '';
|
1974
|
+
if (!(i < input.length)) {
|
1975
|
+
break;
|
1976
|
+
}
|
1977
|
+
}
|
1978
|
+
return buf;
|
1979
|
+
};
|
1980
|
+
|
1981
|
+
return ExifRestore;
|
1982
|
+
|
1983
|
+
})();
|
1984
|
+
|
1700
1985
|
|
1701
1986
|
/*
|
1702
1987
|
* contentloaded.js
|
@@ -1731,11 +2016,11 @@
|
|
1731
2016
|
}
|
1732
2017
|
};
|
1733
2018
|
poll = function() {
|
1734
|
-
var e;
|
2019
|
+
var e, error1;
|
1735
2020
|
try {
|
1736
2021
|
root.doScroll("left");
|
1737
|
-
} catch (
|
1738
|
-
e =
|
2022
|
+
} catch (error1) {
|
2023
|
+
e = error1;
|
1739
2024
|
setTimeout(poll, 50);
|
1740
2025
|
return;
|
1741
2026
|
}
|
@@ -1745,7 +2030,7 @@
|
|
1745
2030
|
if (doc.createEventObject && root.doScroll) {
|
1746
2031
|
try {
|
1747
2032
|
top = !win.frameElement;
|
1748
|
-
} catch (
|
2033
|
+
} catch (undefined) {}
|
1749
2034
|
if (top) {
|
1750
2035
|
poll();
|
1751
2036
|
}
|