1 2;(function(){ 3 4/** 5 * Require the module at `name`. 6 * 7 * @param {String} name 8 * @return {Object} exports 9 * @api public 10 */ 11 12function require(name) { 13 var module = require.modules[name]; 14 if (!module) throw new Error('failed to require "' + name + '"'); 15 16 if (!('exports' in module) && typeof module.definition === 'function') { 17 module.client = module.component = true; 18 module.definition.call(this, module.exports = {}, module); 19 delete module.definition; 20 } 21 22 return module.exports; 23} 24 25/** 26 * Registered modules. 27 */ 28 29require.modules = {}; 30 31/** 32 * Register module at `name` with callback `definition`. 33 * 34 * @param {String} name 35 * @param {Function} definition 36 * @api private 37 */ 38 39require.register = function (name, definition) { 40 require.modules[name] = { 41 definition: definition 42 }; 43}; 44 45/** 46 * Define a module's exports immediately with `exports`. 47 * 48 * @param {String} name 49 * @param {Generic} exports 50 * @api private 51 */ 52 53require.define = function (name, exports) { 54 require.modules[name] = { 55 exports: exports 56 }; 57}; 58require.register("[email protected]", function (exports, module) { 59 60/** 61 * Expose `Emitter`. 62 */ 63 64module.exports = Emitter; 65 66/** 67 * Initialize a new `Emitter`. 68 * 69 * @api public 70 */ 71 72function Emitter(obj) { 73 if (obj) return mixin(obj); 74}; 75 76/** 77 * Mixin the emitter properties. 78 * 79 * @param {Object} obj 80 * @return {Object} 81 * @api private 82 */ 83 84function mixin(obj) { 85 for (var key in Emitter.prototype) { 86 obj[key] = Emitter.prototype[key]; 87 } 88 return obj; 89} 90 91/** 92 * Listen on the given `event` with `fn`. 93 * 94 * @param {String} event 95 * @param {Function} fn 96 * @return {Emitter} 97 * @api public 98 */ 99 100Emitter.prototype.on = 101Emitter.prototype.addEventListener = function(event, fn){ 102 this._callbacks = this._callbacks || {}; 103 (this._callbacks[event] = this._callbacks[event] || []) 104 .push(fn); 105 return this; 106}; 107 108/** 109 * Adds an `event` listener that will be invoked a single 110 * time then automatically removed. 111 * 112 * @param {String} event 113 * @param {Function} fn 114 * @return {Emitter} 115 * @api public 116 */ 117 118Emitter.prototype.once = function(event, fn){ 119 var self = this; 120 this._callbacks = this._callbacks || {}; 121 122 function on() { 123 self.off(event, on); 124 fn.apply(this, arguments); 125 } 126 127 on.fn = fn; 128 this.on(event, on); 129 return this; 130}; 131 132/** 133 * Remove the given callback for `event` or all 134 * registered callbacks. 135 * 136 * @param {String} event 137 * @param {Function} fn 138 * @return {Emitter} 139 * @api public 140 */ 141 142Emitter.prototype.off = 143Emitter.prototype.removeListener = 144Emitter.prototype.removeAllListeners = 145Emitter.prototype.removeEventListener = function(event, fn){ 146 this._callbacks = this._callbacks || {}; 147 148 // all 149 if (0 == arguments.length) { 150 this._callbacks = {}; 151 return this; 152 } 153 154 // specific event 155 var callbacks = this._callbacks[event]; 156 if (!callbacks) return this; 157 158 // remove all handlers 159 if (1 == arguments.length) { 160 delete this._callbacks[event]; 161 return this; 162 } 163 164 // remove specific handler 165 var cb; 166 for (var i = 0; i < callbacks.length; i++) { 167 cb = callbacks[i]; 168 if (cb === fn || cb.fn === fn) { 169 callbacks.splice(i, 1); 170 break; 171 } 172 } 173 return this; 174}; 175 176/** 177 * Emit `event` with the given args. 178 * 179 * @param {String} event 180 * @param {Mixed} ... 181 * @return {Emitter} 182 */ 183 184Emitter.prototype.emit = function(event){ 185 this._callbacks = this._callbacks || {}; 186 var args = [].slice.call(arguments, 1) 187 , callbacks = this._callbacks[event]; 188 189 if (callbacks) { 190 callbacks = callbacks.slice(0); 191 for (var i = 0, len = callbacks.length; i < len; ++i) { 192 callbacks[i].apply(this, args); 193 } 194 } 195 196 return this; 197}; 198 199/** 200 * Return array of callbacks for `event`. 201 * 202 * @param {String} event 203 * @return {Array} 204 * @api public 205 */ 206 207Emitter.prototype.listeners = function(event){ 208 this._callbacks = this._callbacks || {}; 209 return this._callbacks[event] || []; 210}; 211 212/** 213 * Check if this emitter has `event` handlers. 214 * 215 * @param {String} event 216 * @return {Boolean} 217 * @api public 218 */ 219 220Emitter.prototype.hasListeners = function(event){ 221 return !! this.listeners(event).length; 222}; 223 224}); 225 226require.register("dropzone", function (exports, module) { 227 228 229/** 230 * Exposing dropzone 231 */ 232module.exports = require("dropzone/lib/dropzone.js"); 233 234}); 235 236require.register("dropzone/lib/dropzone.js", function (exports, module) { 237 238/* 239 * 240 * More info at [www.dropzonejs.com](http://www.dropzonejs.com) 241 * 242 * Copyright (c) 2012, Matias Meno 243 * 244 * Permission is hereby granted, free of charge, to any person obtaining a copy 245 * of this software and associated documentation files (the "Software"), to deal 246 * in the Software without restriction, including without limitation the rights 247 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 248 * copies of the Software, and to permit persons to whom the Software is 249 * furnished to do so, subject to the following conditions: 250 * 251 * The above copyright notice and this permission notice shall be included in 252 * all copies or substantial portions of the Software. 253 * 254 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 255 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 256 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 257 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 258 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 259 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 260 * THE SOFTWARE. 261 * 262 */ 263 264(function() { 265 var Dropzone, Em, camelize, contentLoaded, detectVerticalSquash, drawImageIOSFix, noop, without, 266 __hasProp = {}.hasOwnProperty, 267 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, 268 __slice = [].slice; 269 270 Em = typeof Emitter !== "undefined" && Emitter !== null ? Emitter : require("[email protected]"); 271 272 noop = function() {}; 273 274 Dropzone = (function(_super) { 275 var extend; 276 277 __extends(Dropzone, _super); 278 279 280 /* 281 This is a list of all available events you can register on a dropzone object. 282 283 You can register an event handler like this: 284 285 dropzone.on("dragEnter", function() { }); 286 */ 287 288 Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "addedfile", "removedfile", "thumbnail", "error", "errormultiple", "processing", "processingmultiple", "uploadprogress", "totaluploadprogress", "sending", "sendingmultiple", "success", "successmultiple", "canceled", "canceledmultiple", "complete", "completemultiple", "reset", "maxfilesexceeded", "maxfilesreached"]; 289 290 Dropzone.prototype.defaultOptions = { 291 url: null, 292 method: "post", 293 withCredentials: false, 294 parallelUploads: 2, 295 uploadMultiple: false, 296 maxFilesize: 256, 297 paramName: "file", 298 createImageThumbnails: true, 299 maxThumbnailFilesize: 10, 300 thumbnailWidth: 100, 301 thumbnailHeight: 100, 302 maxFiles: null, 303 params: {}, 304 clickable: true, 305 ignoreHiddenFiles: true, 306 acceptedFiles: null, 307 acceptedMimeTypes: null, 308 autoProcessQueue: true, 309 autoQueue: true, 310 addRemoveLinks: false, 311 previewsContainer: null, 312 dictDefaultMessage: "Drop files here to upload", 313 dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.", 314 dictFallbackText: "Please use the fallback form below to upload your files like in the olde
314n days.", 315 dictFileTooBig: "File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.", 316 dictInvalidFileType: "You can't upload files of this type.", 317 dictResponseError: "Server responded with {{statusCode}} code.", 318 dictCancelUpload: "Cancel upload", 319 dictCancelUploadConfirmation: "Are you sure you want to cancel this upload?", 320 dictRemoveFile: "Remove file", 321 dictRemoveFileConfirmation: null, 322 dictMaxFilesExceeded: "You can not upload any more files.", 323 accept: function(file, done) { 324 return done(); 325 }, 326 init: function() { 327 return noop; 328 }, 329 forceFallback: false, 330 fallback: function() { 331 var child, messageElement, span, _i, _len, _ref; 332 this.element.className = "" + this.element.className + " dz-browser-not-supported"; 333 _ref = this.element.getElementsByTagName("div"); 334 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 335 child = _ref[_i]; 336 if (/(^| )dz-message($| )/.test(child.className)) { 337 messageElement = child; 338 child.className = "dz-message"; 339 continue; 340 } 341 } 342 if (!messageElement) { 343 messageElement = Dropzone.createElement("<div class=\"dz-message\"><span></span></div>"); 344 this.element.appendChild(messageElement); 345 } 346 span = messageElement.getElementsByTagName("span")[0]; 347 if (span) { 348 span.textContent = this.options.dictFallbackMessage; 349 } 350 return this.element.appendChild(this.getFallbackForm()); 351 }, 352 resize: function(file) { 353 var info, srcRatio, trgRatio; 354 info = { 355 srcX: 0, 356 srcY: 0, 357 srcWidth: file.width, 358 srcHeight: file.height 359 }; 360 srcRatio = file.width / file.height; 361 info.optWidth = this.options.thumbnailWidth; 362 info.optHeight = this.options.thumbnailHeight; 363 if ((info.optWidth == null) && (info.optHeight == null)) { 364 info.optWidth = info.srcWidth; 365 info.optHeight = info.srcHeight; 366 } else if (info.optWidth == null) { 367 info.optWidth = srcRatio * info.optHeight; 368 } else if (info.optHeight == null) { 369 info.optHeight = (1 / srcRatio) * info.optWidth; 370 } 371 trgRatio = info.optWidth / info.optHeight; 372 if (file.height < info.optHeight || file.width < info.optWidth) { 373 info.trgHeight = info.srcHeight; 374 info.trgWidth = info.srcWidth; 375 } else { 376 if (srcRatio > trgRatio) { 377 info.srcHeight = file.height; 378 info.srcWidth = info.srcHeight * trgRatio; 379 } else { 380 info.srcWidth = file.width; 381 info.srcHeight = info.srcWidth / trgRatio; 382 } 383 } 384 info.srcX = (file.width - info.srcWidth) / 2; 385 info.srcY = (file.height - info.srcHeight) / 2; 386 return info; 387 }, 388 389 /* 390 Those functions register themselves to the events on init and handle all 391 the user interface specific stuff. Overwriting them won't break the upload 392 but can break the way it's displayed. 393 You can overwrite them if you don't like the default behavior. If you just 394 want to add an additional event handler, register it on the dropzone object 395 and don't overwrite those options. 396 */ 397 drop: function(e) { 398 return this.element.classList.remove("dz-drag-hover"); 399 }, 400 dragstart: noop, 401 dragend: function(e) { 402 return this.element.classList.remove("dz-drag-hover"); 403 }, 404 dragenter: function(e) { 405 return this.element.classList.add("dz-drag-hover"); 406 }, 407 dragover: function(e) { 408 return this.element.classList.add("dz-drag-hover"); 409 }, 410 dragleave: function(e) { 411 return this.element.classList.remove("dz-drag-hover"); 412 }, 413 paste: noop, 414 reset: function() { 415 return this.element.classList.remove("dz-started"); 416 }, 417 addedfile: function(file) { 418 var node, removeFileEvent, removeLink, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _results; 419 if (this.element === this.previewsContainer) { 420 this.element.classList.add("dz-started"); 421 } 422 if (this.previewsContainer) { 423 424 file.previewElement = Dropzone.createElement(this.options.previewTemplate.trim()); 425 file.previewTemplate = file.previewElement; 426 this.previewsContainer.appendChild(file.previewElement); 427 _ref = file.previewElement.querySelectorAll("[data-dz-name]"); 428 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 429 node = _ref[_i]; 430 node.textContent = file.name; 431 } 432 _ref1 = file.previewElement.querySelectorAll("[data-dz-size]"); 433 for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { 434 node = _ref1[_j]; 435 node.innerHTML = this.filesize(file.size); 436 } 437 if (this.options.addRemoveLinks) { 438 file._removeLink = Dropzone.createElement("<a class=\"dz-remove\" href=\"javascript:undefined;\" data-dz-remove>" + this.options.dictRemoveFile + "</a>"); 439 file.previewElement.appendChild(file._removeLink); 440 } 441 removeFileEvent = (function(_this) { 442 return function(e) { 443 e.preventDefault(); 444 e.stopPropagation(); 445 if (file.status === Dropzone.UPLOADING) { 446 return Dropzone.confirm(_this.options.dictCancelUploadConfirmation, function() { 447 return _this.removeFile(file); 448 }); 449 } else { 450 if (_this.options.dictRemoveFileConfirmation) { 451 return Dropzone.confirm(_this.options.dictRemoveFileConfirmation, function() { 452 return _this.removeFile(file); 453 }); 454 } else { 455 return _this.removeFile(file); 456 } 457 } 458 }; 459 })(this); 460 _ref2 = file.previewElement.querySelectorAll("[data-dz-remove]"); 461 _results = []; 462 for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { 463 removeLink = _ref2[_k]; 464 _results.push(removeLink.addEventListener("click", removeFileEvent)); 465 } 466 return _results; 467 } 468 }, 469 removedfile: function(file) { 470 var _ref; 471 if (file.previewElement) { 472 if ((_ref = file.previewElement) != null) { 473 _ref.parentNode.removeChild(file.previewElement); 474 } 475 } 476 return this._updateMaxFilesReachedClass(); 477 }, 478 thumbnail: function(file, dataUrl) { 479 var thumbnailElement, _i, _len, _ref, _results; 480 if (file.previewElement) { 481 file.previewElement.classList.remove("dz-file-preview"); 482 file.previewElement.classList.add("dz-image-preview"); 483 _ref = file.previewElement.querySelectorAll("[data-dz-thumbnail]"); 484 _results = []; 485 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 486 thumbnailElement = _ref[_i]; 487 thumbnailElement.alt = file.name; 488 _results.push(thumbnailElement.src = dataUrl); 489 } 490 return _results; 491 } 492 }, 493 error: function(file, message) { 494 var node, _i, _len, _ref, _results; 495 if (file.previewElement) { 496 file.previewElement.classList.add("dz-error"); 497 if (typeof message !== "String" && message.error) { 498 message = message.error; 499 } 500 _ref = file.previewElement.querySelectorAll("[data-dz-errormessage]"); 501 _results = []; 502 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 503 node = _ref[_i]; 504 _results.push(node.innerHTML = message); 505 } 506 return _results; 507 } 508 }, 509 errormultiple: noop, 510 processing: function(file) { 511 if (file.previewElement) { 512 file.previewElement.classList.add("dz-processing"); 513 if (file._removeLink) { 514 return file._removeLink.textContent = this.options.dictCancelUpload; 515 } 516 } 517 }, 518 processingmultiple: noop, 519 uploadprogress: function(file, progress, bytesSent) { 520 var node, _i, _len, _ref, _results; 521 if (file.previewElement) { 522 _ref = file.previewElement.querySelectorAll("[data-dz-uploadprogress]"); 523 _results = []; 524 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 525 node = _ref[_i]; 526 _results.push(node.style.width = "" + progress + "%"); 527 } 528 return _results; 529 } 530 }, 531 totaluploadprogress: noop, 532 sending: noop, 533 sendingmultiple: noop, 534 success: function(file) { 535 if (file.previewElement) { 536 return file.previewElement.classList.add("dz-success"); 537 } 538 }, 539 successmultiple: noop, 540 canceled: function(file) {
541 return this.emit("error", file, "Upload canceled."); 542 }, 543 canceledmultiple: noop, 544 complete: function(file) { 545 if (file._removeLink) { 546 return file._removeLink.textContent = this.options.dictRemoveFile; 547 } 548 }, 549 completemultiple: noop, 550 maxfilesexceeded: noop, 551 maxfilesreached: noop, 552 previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n <div class=\"dz-details\">\n <div class=\"dz-filename\"><span data-dz-name></span></div>\n <div class=\"dz-size\" data-dz-size></div>\n <img data-dz-thumbnail />\n </div>\n <div class=\"dz-progress\"><span class=\"dz-upload\" data-dz-uploadprogress></span></div>\n <div class=\"dz-success-mark\"><span>✔</span></div>\n <div class=\"dz-error-mark\"><span>✘</span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>" 553 }; 554 555 extend = function() { 556 var key, object, objects, target, val, _i, _len; 557 target = arguments[0], objects = 2 <= arguments.length ? __slice.call(arguments, 1) : []; 558 for (_i = 0, _len = objects.length; _i < _len; _i++) { 559 object = objects[_i]; 560 for (key in object) { 561 val = object[key]; 562 target[key] = val; 563 } 564 } 565 return target; 566 }; 567 568 function Dropzone(element, options) { 569 var elementOptions, fallback, _ref; 570 this.element = element; 571 this.version = Dropzone.version; 572 this.defaultOptions.previewTemplate = this.defaultOptions.previewTemplate.replace(/\n*/g, ""); 573 this.clickableElements = []; 574 this.listeners = []; 575 this.files = []; 576 if (typeof this.element === "string") { 577 this.element = document.querySelector(this.element); 578 } 579 if (!(this.element && (this.element.nodeType != null))) { 580 throw new Error("Invalid dropzone element."); 581 } 582 if (this.element.dropzone) { 583 throw new Error("Dropzone already attached."); 584 } 585 Dropzone.instances.push(this); 586 this.element.dropzone = this; 587 elementOptions = (_ref = Dropzone.optionsForElement(this.element)) != null ? _ref : {}; 588 this.options = extend({}, this.defaultOptions, elementOptions, options != null ? options : {}); 589 if (this.options.forceFallback || !Dropzone.isBrowserSupported()) { 590 return this.options.fallback.call(this); 591 } 592 if (this.options.url == null) { 593 this.options.url = this.element.getAttribute("action"); 594 } 595 if (!this.options.url) { 596 throw new Error("No URL provided."); 597 } 598 if (this.options.acceptedFiles && this.options.acceptedMimeTypes) { 599 throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated."); 600 } 601 if (this.options.acceptedMimeTypes) { 602 this.options.acceptedFiles = this.options.acceptedMimeTypes; 603 delete this.options.acceptedMimeTypes; 604 } 605 this.options.method = this.options.method.toUpperCase(); 606 if ((fallback = this.getExistingFallback()) && fallback.parentNode) { 607 fallback.parentNode.removeChild(fallback); 608 } 609 if (this.options.previewsContainer !== false) { 610 if (this.options.previewsContainer) { 611 this.previewsContainer = Dropzone.getElement(this.options.previewsContainer, "previewsContainer"); 612 } else { 613 this.previewsContainer = this.element; 614 } 615 } 616 if (this.options.clickable) { 617 if (this.options.clickable === true) { 618 this.clickableElements = [this.element]; 619 } else { 620 this.clickableElements = Dropzone.getElements(this.options.clickable, "clickable"); 621 } 622 } 623 this.init(); 624 } 625 626 Dropzone.prototype.getAcceptedFiles = function() { 627 var file, _i, _len, _ref, _results; 628 _ref = this.files; 629 _results = []; 630 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 631 file = _ref[_i]; 632 if (file.accepted) { 633 _results.push(file); 634 } 635 } 636 return _results; 637 }; 638 639 Dropzone.prototype.getRejectedFiles = function() { 640 var file, _i, _len, _ref, _results; 641 _ref = this.files; 642 _results = []; 643 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 644 file = _ref[_i]; 645 if (!file.accepted) { 646 _results.push(file); 647 } 648 } 649 return _results; 650 }; 651 652 Dropzone.prototype.getFilesWithStatus = function(status) { 653 var file, _i, _len, _ref, _results; 654 _ref = this.files; 655 _results = []; 656 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 657 file = _ref[_i]; 658 if (file.status === status) { 659 _results.push(file); 660 } 661 } 662 return _results; 663 }; 664 665 Dropzone.prototype.getQueuedFiles = function() { 666 return this.getFilesWithStatus(Dropzone.QUEUED); 667 }; 668 669 Dropzone.prototype.getUploadingFiles = function() { 670 return this.getFilesWithStatus(Dropzone.UPLOADING); 671 }; 672 673 Dropzone.prototype.getActiveFiles = function() { 674 var file, _i, _len, _ref, _results; 675 _ref = this.files; 676 _results = []; 677 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 678 file = _ref[_i]; 679 if (file.status === Dropzone.UPLOADING || file.status === Dropzone.QUEUED) { 680 _results.push(file); 681 } 682 } 683 return _results; 684 }; 685 686 Dropzone.prototype.init = function() { 687 var eventName, noPropagation, setupHiddenFileInput, _i, _len, _ref, _ref1; 688 if (this.element.tagName === "form") { 689 this.element.setAttribute("enctype", "multipart/form-data"); 690 } 691 if (this.element.classList.contains("dropzone") && !this.element.querySelector(".dz-message")) { 692 this.element.appendChild(Dropzone.createElement("<div class=\"dz-default dz-message\"><span>" + this.options.dictDefaultMessage + "</span></div>")); 693 } 694 if (this.clickableElements.length) { 695 setupHiddenFileInput = (function(_this) { 696 return function() { 697 if (_this.hiddenFileInput) { 698 document.body.removeChild(_this.hiddenFileInput); 699 } 700 _this.hiddenFileInput = document.createElement("input"); 701 _this.hiddenFileInput.setAttribute("type", "file"); 702 if ((_this.options.maxFiles == null) || _this.options.maxFiles > 1) { 703 _this.hiddenFileInput.setAttribute("multiple", "multiple"); 704 } 705 _this.hiddenFileInput.className = "dz-hidden-input"; 706 if (_this.options.acceptedFiles != null) { 707 _this.hiddenFileInput.setAttribute("accept", _this.options.acceptedFiles); 708 } 709 _this.hiddenFileInput.style.visibility = "hidden"; 710 _this.hiddenFileInput.style.position = "absolute"; 711 _this.hiddenFileInput.style.top = "0"; 712 _this.hiddenFileInput.style.left = "0"; 713 _this.hiddenFileInput.style.height = "0"; 714 _this.hiddenFileInput.style.width = "0"; 715 document.body.appendChild(_this.hiddenFileInput); 716 return _this.hiddenFileInput.addEventListener("change", function() { 717 var file, files, _i, _len; 718 files = _this.hiddenFileInput.files; 719 if (files.length) { 720 for (_i = 0, _len = files.length; _i < _len; _i++) { 721 file = files[_i]; 722 _this.addFile(file); 723 } 724 } 725 return setupHiddenFileInput(); 726 }); 727 }; 728 })(this); 729 setupHiddenFileInput(); 730 } 731 this.URL = (_ref = window.URL) != null ? _ref : window.webkitURL; 732 _ref1 = this.events; 733 for (_i = 0, _len = _ref1.length; _i < _len; _i++) { 734 eventName = _ref1[_i]; 735 this.on(eventName, this.options[eventName]); 736 } 737 this.on("uploadprogress", (function(_this) { 738 return function() { 739 return _this.updateTotalUploadProgress(); 740 }; 741 })(this)); 742 this.on("removedfile", (function(_this) { 743 return function() { 744 return _this.updateTotalUploadProgress(); 745 }; 746 })(this)); 747 this.on("canceled", (function(_this) { 748 return function(file) {
749 return _this.emit("complete", file); 750 }; 751 })(this)); 752 this.on("complete", (function(_this) { 753 return function(file) { 754 if (_this.getUploadingFiles().length === 0 && _this.getQueuedFiles().length === 0) { 755 return setTimeout((function() { 756 return _this.emit("queuecomplete"); 757 }), 0); 758 } 759 }; 760 })(this)); 761 noPropagation = function(e) { 762 e.stopPropagation(); 763 if (e.preventDefault) { 764 return e.preventDefault(); 765 } else { 766 return e.returnValue = false; 767 } 768 }; 769 this.listeners = [ 770 { 771 element: this.element, 772 events: { 773 "dragstart": (function(_this) { 774 return function(e) { 775 return _this.emit("dragstart", e); 776 }; 777 })(this), 778 "dragenter": (function(_this) { 779 return function(e) { 780 noPropagation(e); 781 return _this.emit("dragenter", e); 782 }; 783 })(this), 784 "dragover": (function(_this) { 785 return function(e) { 786 var efct; 787 try { 788 efct = e.dataTransfer.effectAllowed; 789 } catch (_error) {} 790 e.dataTransfer.dropEffect = 'move' === efct || 'linkMove' === efct ? 'move' : 'copy'; 791 noPropagation(e); 792 return _this.emit("dragover", e); 793 }; 794 })(this), 795 "dragleave": (function(_this) { 796 return function(e) { 797 return _this.emit("dragleave", e); 798 }; 799 })(this), 800 "drop": (function(_this) { 801 return function(e) { 802 noPropagation(e); 803 return _this.drop(e); 804 }; 805 })(this), 806 "dragend": (function(_this) { 807 return function(e) { 808 return _this.emit("dragend", e); 809 }; 810 })(this) 811 } 812 } 813 ]; 814 this.clickableElements.forEach((function(_this) { 815 return function(clickableElement) { 816 return _this.listeners.push({ 817 element: clickableElement, 818 events: { 819 "click": function(evt) { 820 if ((clickableElement !== _this.element) || (evt.target === _this.element || Dropzone.elementInside(evt.target, _this.element.querySelector(".dz-message")))) { 821 return _this.hiddenFileInput.click(); 822 } 823 } 824 } 825 }); 826 }; 827 })(this)); 828 this.enable(); 829 return this.options.init.call(this); 830 }; 831 832 Dropzone.prototype.destroy = function() { 833 var _ref; 834 this.disable(); 835 this.removeAllFiles(true); 836 if ((_ref = this.hiddenFileInput) != null ? _ref.parentNode : void 0) { 837 this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput); 838 this.hiddenFileInput = null; 839 } 840 delete this.element.dropzone; 841 return Dropzone.instances.splice(Dropzone.instances.indexOf(this), 1); 842 }; 843 844 Dropzone.prototype.updateTotalUploadProgress = function() { 845 var activeFiles, file, totalBytes, totalBytesSent, totalUploadProgress, _i, _len, _ref; 846 totalBytesSent = 0; 847 totalBytes = 0; 848 activeFiles = this.getActiveFiles(); 849 if (activeFiles.length) { 850 _ref = this.getActiveFiles(); 851 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 852 file = _ref[_i]; 853 totalBytesSent += file.upload.bytesSent; 854 totalBytes += file.upload.total; 855 } 856 totalUploadProgress = 100 * totalBytesSent / totalBytes; 857 } else { 858 totalUploadProgress = 100; 859 } 860 return this.emit("totaluploadprogress", totalUploadProgress, totalBytes, totalBytesSent); 861 }; 862 863 Dropzone.prototype._getParamName = function(n) { 864 if (typeof this.options.paramName === "function") { 865 return this.options.paramName(n); 866 } else { 867 return "" + this.options.paramName + (this.options.uploadMultiple ? "[" + n + "]" : ""); 868 } 869 }; 870 871 Dropzone.prototype.getFallbackForm = function() { 872 var existingFallback, fields, fieldsString, form; 873 if (existingFallback = this.getExistingFallback()) { 874 return existingFallback; 875 } 876 fieldsString = "<div class=\"dz-fallback\">"; 877 if (this.options.dictFallbackText) { 878 fieldsString += "<p>" + this.options.dictFallbackText + "</p>"; 879 } 880 fieldsString += "<input type=\"file\" name=\"" + (this._getParamName(0)) + "\" " + (this.options.uploadMultiple ? 'multiple="multiple"' : void 0) + " /><input type=\"submit\" value=\"Upload!\"></div>"; 881 fields = Dropzone.createElement(fieldsString); 882 if (this.element.tagName !== "FORM") { 883 form = Dropzone.createElement("<form action=\"" + this.options.url + "\" enctype=\"multipart/form-data\" method=\"" + this.options.method + "\"></form>"); 884 form.appendChild(fields); 885 } else { 886 this.element.setAttribute("enctype", "multipart/form-data"); 887 this.element.setAttribute("method", this.options.method); 888 } 889 return form != null ? form : fields; 890 }; 891 892 Dropzone.prototype.getExistingFallback = function() { 893 var fallback, getFallback, tagName, _i, _len, _ref; 894 getFallback = function(elements) { 895 var el, _i, _len; 896 for (_i = 0, _len = elements.length; _i < _len; _i++) { 897 el = elements[_i]; 898 if (/(^| )fallback($| )/.test(el.className)) { 899 return el; 900 } 901 } 902 }; 903 _ref = ["div", "form"]; 904 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 905 tagName = _ref[_i]; 906 if (fallback = getFallback(this.element.getElementsByTagName(tagName))) { 907 return fallback; 908 } 909 } 910 }; 911 912 Dropzone.prototype.setupEventListeners = function() { 913 var elementListeners, event, listener, _i, _len, _ref, _results; 914 _ref = this.listeners; 915 _results = []; 916 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 917 elementListeners = _ref[_i]; 918 _results.push((function() { 919 var _ref1, _results1; 920 _ref1 = elementListeners.events; 921 _results1 = []; 922 for (event in _ref1) { 923 listener = _ref1[event]; 924 _results1.push(elementListeners.element.addEventListener(event, listener, false)); 925 } 926 return _results1; 927 })()); 928 } 929 return _results; 930 }; 931 932 Dropzone.prototype.removeEventListeners = function() { 933 var elementListeners, event, listener, _i, _len, _ref, _results; 934 _ref = this.listeners; 935 _results = []; 936 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 937 elementListeners = _ref[_i]; 938 _results.push((function() { 939 var _ref1, _results1; 940 _ref1 = elementListeners.events; 941 _results1 = []; 942 for (event in _ref1) { 943 listener = _ref1[event]; 944 _results1.push(elementListeners.element.removeEventListener(event, listener, false)); 945 } 946 return _results1; 947 })()); 948 } 949 return _results; 950 }; 951 952 Dropzone.prototype.disable = function() { 953 var file, _i, _len, _ref, _results;
954 this.clickableElements.forEach(function(element) { 955 return element.classList.remove("dz-clickable"); 956 }); 957 this.removeEventListeners(); 958 _ref = this.files; 959 _results = []; 960 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 961 file = _ref[_i]; 962 _results.push(this.cancelUpload(file)); 963 } 964 return _results; 965 }; 966 967 Dropzone.prototype.enable = function() { 968 this.clickableElements.forEach(function(element) { 969 return element.classList.add("dz-clickable"); 970 }); 971 return this.setupEventListeners(); 972 }; 973 974 Dropzone.prototype.filesize = function(size) { 975 var string; 976 if (size >= 1024 * 1024 * 1024 * 1024 / 10) { 977 size = size / (1024 * 1024 * 1024 * 1024 / 10); 978 string = "TiB"; 979 } else if (size >= 1024 * 1024 * 1024 / 10) { 980 size = size / (1024 * 1024 * 1024 / 10); 981 string = "GiB"; 982 } else if (size >= 1024 * 1024 / 10) { 983 size = size / (1024 * 1024 / 10); 984 string = "MiB"; 985 } else if (size >= 1024 / 10) { 986 size = size / (1024 / 10); 987 string = "KiB"; 988 } else { 989 size = size * 10; 990 string = "b"; 991 } 992 return "<strong>" + (Math.round(size) / 10) + "</strong> " + string; 993 }; 994 995 Dropzone.prototype._updateMaxFilesReachedClass = function() { 996 if ((this.options.maxFiles != null) && this.getAcceptedFiles().length >= this.options.maxFiles) { 997 if (this.getAcceptedFiles().length === this.options.maxFiles) { 998 this.emit('maxfilesreached', this.files); 999 } 1000 return this.element.classList.add("dz-max-files-reached"); 1001 } else { 1002 return this.element.classList.remove("dz-max-files-reached"); 1003 } 1004 }; 1005 1006 Dropzone.prototype.drop = function(e) { 1007 var files, items; 1008 if (!e.dataTransfer) { 1009 return; 1010 } 1011 this.emit("drop", e); 1012 files = e.dataTransfer.files; 1013 if (files.length) { 1014 items = e.dataTransfer.items; 1015 if (items && items.length && (items[0].webkitGetAsEntry != null)) { 1016 this._addFilesFromItems(items); 1017 } else { 1018 this.handleFiles(files); 1019 } 1020 } 1021 }; 1022 1023 Dropzone.prototype.paste = function(e) { 1024 var items, _ref; 1025 if ((e != null ? (_ref = e.clipboardData) != null ? _ref.items : void 0 : void 0) == null) { 1026 return; 1027 } 1028 this.emit("paste", e); 1029 items = e.clipboardData.items; 1030 if (items.length) { 1031 return this._addFilesFromItems(items); 1032 } 1033 }; 1034 1035 Dropzone.prototype.handleFiles = function(files) { 1036 var file, _i, _len, _results; 1037 _results = []; 1038 for (_i = 0, _len = files.length; _i < _len; _i++) { 1039 file = files[_i]; 1040 _results.push(this.addFile(file)); 1041 } 1042 return _results; 1043 }; 1044 1045 Dropzone.prototype._addFilesFromItems = function(items) { 1046 var entry, item, _i, _len, _results; 1047 _results = []; 1048 for (_i = 0, _len = items.length; _i < _len; _i++) { 1049 item = items[_i]; 1050 if ((item.webkitGetAsEntry != null) && (entry = item.webkitGetAsEntry())) { 1051 if (entry.isFile) { 1052 _results.push(this.addFile(item.getAsFile())); 1053 } else if (entry.isDirectory) { 1054 _results.push(this._addFilesFromDirectory(entry, entry.name)); 1055 } else { 1056 _results.push(void 0); 1057 } 1058 } else if (item.getAsFile != null) { 1059 if ((item.kind == null) || item.kind === "file") { 1060 _results.push(this.addFile(item.getAsFile())); 1061 } else { 1062 _results.push(void 0); 1063 } 1064 } else { 1065 _results.push(void 0); 1066 } 1067 } 1068 return _results; 1069 }; 1070 1071 Dropzone.prototype._addFilesFromDirectory = function(directory, path) { 1072 var dirReader, entriesReader; 1073 dirReader = directory.createReader(); 1074 entriesReader = (function(_this) { 1075 return function(entries) { 1076 var entry, _i, _len; 1077 for (_i = 0, _len = entries.length; _i < _len; _i++) { 1078 entry = entries[_i]; 1079 if (entry.isFile) { 1080 entry.file(function(file) { 1081 if (_this.options.ignoreHiddenFiles && file.name.substring(0, 1) === '.') { 1082 return; 1083 } 1084 file.fullPath = "" + path + "/" + file.name; 1085 return _this.addFile(file); 1086 }); 1087 } else if (entry.isDirectory) { 1088 _this._addFilesFromDirectory(entry, "" + path + "/" + entry.name); 1089 } 1090 } 1091 }; 1092 })(this); 1093 return dirReader.readEntries(entriesReader, function(error) { 1094 return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log(error) : void 0 : void 0; 1095 }); 1096 }; 1097 1098 Dropzone.prototype.accept = function(file, done) { 1099 if (file.size > this.options.maxFilesize * 1024 * 1024) { 1100 return done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize)); 1101 } else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) { 1102 return done(this.options.dictInvalidFileType); 1103 } else if ((this.options.maxFiles != null) && this.getAcceptedFiles().length >= this.options.maxFiles) { 1104 done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}", this.options.maxFiles));
1105 return this.emit("maxfilesexceeded", file); 1106 } else { 1107 return this.options.accept.call(this, file, done); 1108 } 1109 }; 1110 1111 Dropzone.prototype.addFile = function(file) { 1112 file.upload = { 1113 progress: 0, 1114 total: file.size, 1115 bytesSent: 0 1116 }; 1117 this.files.push(file); 1118 file.status = Dropzone.ADDED; 1119 this.emit("addedfile", file); 1120 this._enqueueThumbnail(file); 1121 return this.accept(file, (function(_this) { 1122 return function(error) { 1123 if (error) { 1124 file.accepted = false; 1125 _this._errorProcessing([file], error); 1126 } else { 1127 file.accepted = true; 1128 if (_this.options.autoQueue) { 1129 _this.enqueueFile(file); 1130 } 1131 } 1132 return _this._updateMaxFilesReachedClass(); 1133 }; 1134 })(this)); 1135 }; 1136 1137 Dropzone.prototype.enqueueFiles = function(files) { 1138 var file, _i, _len; 1139 for (_i = 0, _len = files.length; _i < _len; _i++) { 1140 file = files[_i]; 1141 this.enqueueFile(file); 1142 } 1143 return null; 1144 }; 1145 1146 Dropzone.prototype.enqueueFile = function(file) { 1147 if (file.status === Dropzone.ADDED && file.accepted === true) { 1148 file.status = Dropzone.QUEUED; 1149 if (this.options.autoProcessQueue) { 1150 return setTimeout(((function(_this) { 1151 return function() { 1152 return _this.processQueue(); 1153 }; 1154 })(this)), 0); 1155 } 1156 } else { 1157 throw new Error("This file can't be queued because it has already been processed or was rejected."); 1158 } 1159 }; 1160 1161 Dropzone.prototype._thumbnailQueue = []; 1162 1163 Dropzone.prototype._processingThumbnail = false; 1164 1165 Dropzone.prototype._enqueueThumbnail = function(file) { 1166 if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1024 * 1024) { 1167 this._thumbnailQueue.push(file); 1168 return setTimeout(((function(_this) { 1169 return function() { 1170 return _this._processThumbnailQueue(); 1171 }; 1172 })(this)), 0); 1173 } 1174 }; 1175 1176 Dropzone.prototype._processThumbnailQueue = function() { 1177 if (this._processingThumbnail || this._thumbnailQueue.length === 0) { 1178 return; 1179 } 1180 this._processingThumbnail = true; 1181 return this.createThumbnail(this._thumbnailQueue.shift(), (function(_this) { 1182 return function() { 1183 _this._processingThumbnail = false; 1184 return _this._processThumbnailQueue(); 1185 }; 1186 })(this)); 1187 }; 1188 1189 Dropzone.prototype.removeFile = function(file) { 1190 if (file.status === Dropzone.UPLOADING) { 1191 this.cancelUpload(file); 1192 } 1193 this.files = without(this.files, file); 1194 this.emit("removedfile", file); 1195 if (this.files.length === 0) { 1196 return this.emit("reset"); 1197 } 1198 }; 1199 1200 Dropzone.prototype.removeAllFiles = function(cancelIfNecessary) { 1201 var file, _i, _len, _ref; 1202 if (cancelIfNecessary == null) { 1203 cancelIfNecessary = false; 1204 } 1205 _ref = this.files.slice(); 1206 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 1207 file = _ref[_i]; 1208 if (file.status !== Dropzone.UPLOADING || cancelIfNecessary) { 1209 this.removeFile(file); 1210 } 1211 } 1212 return null; 1213 }; 1214 1215 Dropzone.prototype.createThumbnail = function(file, callback) { 1216 var fileReader; 1217 fileReader = new FileReader; 1218 fileReader.onload = (function(_this) { 1219 return function() { 1220 var img; 1221 img = document.createElement("img"); 1222 img.onload = function() { 1223 var canvas, ctx, resizeInfo, thumbnail, _ref, _ref1, _ref2, _ref3; 1224 file.width = img.width; 1225 file.height = img.height; 1226 resizeInfo = _this.options.resize.call(_this, file); 1227 if (resizeInfo.trgWidth == null) { 1228 resizeInfo.trgWidth = resizeInfo.optWidth; 1229 } 1230 if (resizeInfo.trgHeight == null) { 1231 resizeInfo.trgHeight = resizeInfo.optHeight; 1232 } 1233 canvas = document.createElement("canvas"); 1234 ctx = canvas.getContext("2d"); 1235 canvas.width = resizeInfo.trgWidth; 1236 canvas.height = resizeInfo.trgHeight; 1237 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); 1238 thumbnail = canvas.toDataURL("image/png");
1239 _this.emit("thumbnail", file, thumbnail); 1240 if (callback != null) { 1241 return callback(); 1242 } 1243 }; 1244 return img.src = fileReader.result; 1245 }; 1246 })(this); 1247 return fileReader.readAsDataURL(file); 1248 }; 1249 1250 Dropzone.prototype.processQueue = function() { 1251 var i, parallelUploads, processingLength, queuedFiles; 1252 parallelUploads = this.options.parallelUploads; 1253 processingLength = this.getUploadingFiles().length; 1254 i = processingLength; 1255 if (processingLength >= parallelUploads) { 1256 return; 1257 } 1258 queuedFiles = this.getQueuedFiles(); 1259 if (!(queuedFiles.length > 0)) { 1260 return; 1261 } 1262 if (this.options.uploadMultiple) { 1263 return this.processFiles(queuedFiles.slice(0, parallelUploads - processingLength)); 1264 } else { 1265 while (i < parallelUploads) { 1266 if (!queuedFiles.length) { 1267 return; 1268 } 1269 this.processFile(queuedFiles.shift()); 1270 i++; 1271 } 1272 } 1273 }; 1274 1275 Dropzone.prototype.processFile = function(file) { 1276 return this.processFiles([file]); 1277 }; 1278 1279 Dropzone.prototype.processFiles = function(files) { 1280 var file, _i, _len; 1281 for (_i = 0, _len = files.length; _i < _len; _i++) { 1282 file = files[_i]; 1283 file.processing = true; 1284 file.status = Dropzone.UPLOADING; 1285 this.emit("processing", file); 1286 } 1287 if (this.options.uploadMultiple) { 1288 this.emit("processingmultiple", files); 1289 } 1290 return this.uploadFiles(files); 1291 }; 1292 1293 Dropzone.prototype._getFilesWithXhr = function(xhr) { 1294 var file, files; 1295 return files = (function() { 1296 var _i, _len, _ref, _results; 1297 _ref = this.files; 1298 _results = []; 1299 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 1300 file = _ref[_i]; 1301 if (file.xhr === xhr) { 1302 _results.push(file); 1303 } 1304 } 1305 return _results; 1306 }).call(this); 1307 }; 1308 1309 Dropzone.prototype.cancelUpload = function(file) { 1310 var groupedFile, groupedFiles, _i, _j, _len, _len1, _ref; 1311 if (file.status === Dropzone.UPLOADING) { 1312 groupedFiles = this._getFilesWithXhr(file.xhr); 1313 for (_i = 0, _len = groupedFiles.length; _i < _len; _i++) { 1314 groupedFile = groupedFiles[_i]; 1315 groupedFile.status = Dropzone.CANCELED; 1316 } 1317 file.xhr.abort(); 1318 for (_j = 0, _len1 = groupedFiles.length; _j < _len1; _j++) { 1319 groupedFile = groupedFiles[_j]; 1320 this.emit("canceled", groupedFile); 1321 } 1322 if (this.options.uploadMultiple) { 1323 this.emit("canceledmultiple", groupedFiles); 1324 } 1325 } else if ((_ref = file.status) === Dropzone.ADDED || _ref === Dropzone.QUEUED) { 1326 file.status = Dropzone.CANCELED; 1327 this.emit("canceled", file); 1328 if (this.options.uploadMultiple) { 1329 this.emit("canceledmultiple", [file]); 1330 } 1331 } 1332 if (this.options.autoProcessQueue) { 1333 return this.processQueue(); 1334 } 1335 }; 1336 1337 Dropzone.prototype.uploadFile = function(file) { 1338 return this.uploadFiles([file]); 1339 }; 1340 1341 Dropzone.prototype.uploadFiles = function(files) { 1342 var file, formData, handleError, headerName, headerValue, headers, i, input, inputName, inputType, key, option, progressObj, response, updateProgress, value, xhr, _i, _j, _k, _l, _len, _len1, _len2, _len3, _m, _ref, _ref1, _ref2, _ref3, _ref4, _ref5; 1343 xhr = new XMLHttpRequest(); 1344 for (_i = 0, _len = files.length; _i < _len; _i++) { 1345 file = files[_i]; 1346 file.xhr = xhr; 1347 } 1348 xhr.open(this.options.method, this.options.url, true); 1349 xhr.withCredentials = !!this.options.withCredentials; 1350 response = null; 1351 handleError = (function(_this) { 1352 return function() { 1353 var _j, _len1, _results; 1354 _results = []; 1355 for (_j = 0, _len1 = files.length; _j < _len1; _j++) { 1356 file = files[_j]; 1357 _results.push(_this._errorProcessing(files, response || _this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr)); 1358 } 1359 return _results; 1360 }; 1361 })(this); 1362 updateProgress = (function(_this) { 1363 return function(e) { 1364 var allFilesFinished, progress, _j, _k, _l, _len1, _len2, _len3, _results; 1365 if (e != null) { 1366 progress = 100 * e.loaded / e.total; 1367 for (_j = 0, _len1 = files.length; _j < _len1; _j++) { 1368 file = files[_j]; 1369 file.upload = { 1370 progress: progress, 1371 total: e.total, 1372 bytesSent: e.loaded 1373 }; 1374 } 1375 } else { 1376 allFilesFinished = true; 1377 progress = 100; 1378 for (_k = 0, _len2 = files.length; _k < _len2; _k++) { 1379 file = files[_k]; 1380 if (!(file.upload.progress === 100 && file.upload.b
1380ytesSent === file.upload.total)) { 1381 allFilesFinished = false; 1382 } 1383 file.upload.progress = progress; 1384 file.upload.bytesSent = file.upload.total; 1385 } 1386 if (allFilesFinished) { 1387 return; 1388 } 1389 } 1390 _results = []; 1391 for (_l = 0, _len3 = files.length; _l < _len3; _l++) { 1392 file = files[_l]; 1393 _results.push(_this.emit("uploadprogress", file, progress, file.upload.bytesSent)); 1394 } 1395 return _results; 1396 }; 1397 })(this); 1398 xhr.onload = (function(_this) { 1399 return function(e) { 1400 var _ref; 1401 if (files[0].status === Dropzone.CANCELED) { 1402 return; 1403 } 1404 if (xhr.readyState !== 4) { 1405 return; 1406 } 1407 response = xhr.responseText; 1408 if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) { 1409 try { 1410 response = JSON.parse(response); 1411 } catch (_error) { 1412 e = _error; 1413 response = "Invalid JSON response from server."; 1414 } 1415 } 1416 updateProgress(); 1417 if (!((200 <= (_ref = xhr.status) && _ref < 300))) { 1418 return handleError(); 1419 } else { 1420 return _this._finished(files, response, e); 1421 } 1422 }; 1423 })(this); 1424 xhr.onerror = (function(_this) { 1425 return function() { 1426 if (files[0].status === Dropzone.CANCELED) { 1427 return; 1428 } 1429 return handleError(); 1430 }; 1431 })(this); 1432 progressObj = (_ref = xhr.upload) != null ? _ref : xhr; 1433 progressObj.onprogress = updateProgress; 1434 headers = { 1435 "Accept": "application/json", 1436 "Cache-Control": "no-cache", 1437 "X-Requested-With": "XMLHttpRequest" 1438 }; 1439 if (this.options.headers) { 1440 extend(headers, this.options.headers); 1441 } 1442 for (headerName in headers) { 1443 headerValue = headers[headerName]; 1444 xhr.setRequestHeader(headerName, headerValue); 1445 } 1446 formData = new FormData(); 1447 if (this.options.params) { 1448 _ref1 = this.options.params; 1449 for (key in _ref1) { 1450 value = _ref1[key]; 1451 formData.append(key, value); 1452 } 1453 } 1454 for (_j = 0, _len1 = files.length; _j < _len1; _j++) { 1455 file = files[_j]; 1456 this.emit("sending", file, xhr, formData); 1457 } 1458 if (this.options.uploadMultiple) { 1459 this.emit("sendingmultiple", files, xhr, formData); 1460 } 1461 if (this.element.tagName === "FORM") { 1462 _ref2 = this.element.querySelectorAll("input, textarea, select, button"); 1463 for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { 1464 input = _ref2[_k]; 1465 inputName = input.getAttribute("name"); 1466 inputType = input.getAttribute("type"); 1467 if (input.tagName === "SELECT" && input.hasAttribute("multiple")) { 1468 _ref3 = input.options; 1469 for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) { 1470 option = _ref3[_l]; 1471 if (option.selected) { 1472 formData.append(inputName, option.value); 1473 } 1474 } 1475 } else if (!inputType || ((_ref4 = inputType.toLowerCase()) !== "checkbox" && _ref4 !== "radio") || input.checked) { 1476 formData.append(inputName, input.value); 1477 } 1478 } 1479 } 1480 for (i = _m = 0, _ref5 = files.length - 1; 0 <= _ref5 ? _m <= _ref5 : _m >= _ref5; i = 0 <= _ref5 ? ++_m : --_m) { 1481 formData.append(this._getParamName(i), files[i], files[i].name); 1482 } 1483 return xhr.send(formData); 1484 }; 1485 1486 Dropzone.prototype._finished = function(files, responseText, e) { 1487 var file, _i, _len; 1488 for (_i = 0, _len = files.length; _i < _len; _i++) { 1489 file = files[_i]; 1490 file.status = Dropzone.SUCCESS; 1491 this.emit("success", file, responseText, e); 1492 this.emit("complete", file); 1493 } 1494 if (this.options.uploadMultiple) {
1495 this.emit("successmultiple", files, responseText, e); 1496 this.emit("completemultiple", files); 1497 } 1498 if (this.options.autoProcessQueue) { 1499 return this.processQueue(); 1500 } 1501 }; 1502 1503 Dropzone.prototype._errorProcessing = function(files, message, xhr) { 1504 var file, _i, _len; 1505 for (_i = 0, _len = files.length; _i < _len; _i++) { 1506 file = files[_i]; 1507 file.status = Dropzone.ERROR; 1508 this.emit("error", file, message, xhr); 1509 this.emit("complete", file); 1510 } 1511 if (this.options.uploadMultiple) { 1512 this.emit("errormultiple", files, message, xhr); 1513 this.emit("completemultiple", files); 1514 } 1515 if (this.options.autoProcessQueue) { 1516 return this.processQueue(); 1517 } 1518 }; 1519 1520 return Dropzone; 1521 1522 })(Em); 1523 1524 Dropzone.version = "3.10.2"; 1525 1526 Dropzone.options = {}; 1527 1528 Dropzone.optionsForElement = function(element) { 1529 if (element.getAttribute("id")) { 1530 return Dropzone.options[camelize(element.getAttribute("id"))]; 1531 } else { 1532 return void 0; 1533 } 1534 }; 1535 1536 Dropzone.instances = []; 1537 1538 Dropzone.forElement = function(element) { 1539 if (typeof element === "string") { 1540 element = document.querySelector(element); 1541 } 1542 if ((element != null ? element.dropzone : void 0) == null) { 1543 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."); 1544 } 1545 return element.dropzone; 1546 }; 1547 1548 Dropzone.autoDiscover = true; 1549 1550 Dropzone.discover = function() { 1551 var checkElements, dropzone, dropzones, _i, _len, _results; 1552 if (document.querySelectorAll) { 1553 dropzones = document.querySelectorAll(".dropzone"); 1554 } else { 1555 dropzones = []; 1556 checkElements = function(elements) { 1557 var el, _i, _len, _results; 1558 _results = []; 1559 for (_i = 0, _len = elements.length; _i < _len; _i++) { 1560 el = elements[_i]; 1561 if (/(^| )dropzone($| )/.test(el.className)) { 1562 _results.push(dropzones.push(el)); 1563 } else { 1564 _results.push(void 0); 1565 } 1566 } 1567 return _results; 1568 }; 1569 checkElements(document.getElementsByTagName("div")); 1570 checkElements(document.getElementsByTagName("form")); 1571 } 1572 _results = []; 1573 for (_i = 0, _len = dropzones.length; _i < _len; _i++) { 1574 dropzone = dropzones[_i]; 1575 if (Dropzone.optionsForElement(dropzone) !== false) { 1576 _results.push(new Dropzone(dropzone)); 1577 } else { 1578 _results.push(void 0); 1579 } 1580 } 1581 return _results; 1582 }; 1583 1584 Dropzone.blacklistedBrowsers = [/opera.*Macintosh.*version\/12/i]; 1585 1586 Dropzone.isBrowserSupported = function() { 1587 var capableBrowser, regex, _i, _len, _ref; 1588 capableBrowser = true; 1589 if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) { 1590 if (!("classList" in document.createElement("a"))) { 1591 capableBrowser = false; 1592 } else { 1593 _ref = Dropzone.blacklistedBrowsers; 1594 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 1595 regex = _ref[_i]; 1596 if (regex.test(navigator.userAgent)) { 1597 capableBrowser = false; 1598 continue; 1599 } 1600 } 1601 } 1602 } else { 1603 capableBrowser = false; 1604 } 1605 return capableBrowser; 1606 }; 1607 1608 without = function(list, rejectedItem) { 1609 var item, _i, _len, _results; 1610 _results = []; 1611 for (_i = 0, _len = list.length; _i < _len; _i++) { 1612 item = list[_i]; 1613 if (item !== rejectedItem) { 1614 _results.push(item); 1615 } 1616 } 1617 return _results; 1618 }; 1619 1620 camelize = function(str) { 1621 return str.replace(/[\-_](\w)/g, function(match) { 1622 return match.charAt(1).toUpperCase(); 1623 }); 1624 }; 1625 1626 Dropzone.createElement = function(string) { 1627 var div; 1628 div = document.createElement("div"); 1629 div.innerHTML = string; 1630 return div.childNodes[0]; 1631 }; 1632 1633 Dropzone.elementInside = function(element, container) { 1634 if (element === container) { 1635 return true; 1636 } 1637 while (element = element.parentNode) { 1638 if (element === container) { 1639 return true; 1640 } 1641 } 1642 return false;
1643 }; 1644 1645 Dropzone.getElement = function(el, name) { 1646 var element; 1647 if (typeof el === "string") { 1648 element = document.querySelector(el); 1649 } else if (el.nodeType != null) { 1650 element = el; 1651 } 1652 if (element == null) { 1653 throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector or a plain HTML element."); 1654 } 1655 return element; 1656 }; 1657 1658 Dropzone.getElements = function(els, name) { 1659 var e, el, elements, _i, _j, _len, _len1, _ref; 1660 if (els instanceof Array) { 1661 elements = []; 1662 try { 1663 for (_i = 0, _len = els.length; _i < _len; _i++) { 1664 el = els[_i]; 1665 elements.push(this.getElement(el, name)); 1666 } 1667 } catch (_error) { 1668 e = _error; 1669 elements = null; 1670 } 1671 } else if (typeof els === "string") { 1672 elements = []; 1673 _ref = document.querySelectorAll(els); 1674 for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { 1675 el = _ref[_j]; 1676 elements.push(el); 1677 } 1678 } else if (els.nodeType != null) { 1679 elements = [els]; 1680 } 1681 if (!((elements != null) && elements.length)) { 1682 throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector, a plain HTML element or a list of those."); 1683 } 1684 return elements; 1685 }; 1686 1687 Dropzone.confirm = function(question, accepted, rejected) { 1688 if (window.confirm(question)) { 1689 return accepted(); 1690 } else if (rejected != null) { 1691 return rejected(); 1692 } 1693 }; 1694 1695 Dropzone.isValidFile = function(file, acceptedFiles) { 1696 var baseMimeType, mimeType, validType, _i, _len; 1697 if (!acceptedFiles) { 1698 return true; 1699 } 1700 acceptedFiles = acceptedFiles.split(","); 1701 mimeType = file.type; 1702 baseMimeType = mimeType.replace(/\/.*$/, ""); 1703 for (_i = 0, _len = acceptedFiles.length; _i < _len; _i++) { 1704 validType = acceptedFiles[_i]; 1705 validType = validType.trim(); 1706 if (validType.charAt(0) === ".") { 1707 if (file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.length - validType.length) !== -1) { 1708 return true; 1709 } 1710 } else if (/\/\*$/.test(validType)) { 1711 if (baseMimeType === validType.replace(/\/.*$/, "")) { 1712 return true; 1713 } 1714 } else { 1715 if (mimeType === validType) { 1716 return true; 1717 } 1718 } 1719 } 1720 return false; 1721 }; 1722 1723 if (typeof jQuery !== "undefined" && jQuery !== null) { 1724 jQuery.fn.dropzone = function(options) { 1725 return this.each(function() { 1726 return new Dropzone(this, options); 1727 }); 1728 }; 1729 } 1730 1731 if (typeof module !== "undefined" && module !== null) { 1732 module.exports = Dropzone; 1733 } else { 1734 window.Dropzone = Dropzone; 1735 } 1736 1737 Dropzone.ADDED = "added"; 1738 1739 Dropzone.QUEUED = "queued"; 1740 1741 Dropzone.ACCEPTED = Dropzone.QUEUED; 1742 1743 Dropzone.UPLOADING = "uploading"; 1744 1745 Dropzone.PROCESSING = Dropzone.UPLOADING; 1746 1747 Dropzone.CANCELED = "canceled"; 1748 1749 Dropzone.ERROR = "error"; 1750 1751 Dropzone.SUCCESS = "success"; 1752 1753 1754 /* 1755 1756 Bugfix for iOS 6 and 7 1757 Source: http://stackoverflow.com/questions/11929099/html5-canvas-drawimage-ratio-bug-ios 1758 based on the work of https://github.com/stomita/ios-imagefile-megapixel 1759 */ 1760 1761 detectVerticalSquash = function(img) { 1762 var alpha, canvas, ctx, data, ey, ih, iw, py, ratio, sy; 1763 iw = img.naturalWidth; 1764 ih = img.naturalHeight; 1765 canvas = document.createElement("canvas"); 1766 canvas.width = 1; 1767 canvas.height = ih; 1768 ctx = canvas.getContext("2d"); 1769 ctx.drawImage(img, 0, 0); 1770 data = ctx.getImageData(0, 0, 1, ih).data; 1771 sy = 0; 1772 ey = ih; 1773 py = ih; 1774 while (py > sy) { 1775 alpha = data[(py - 1) * 4 + 3]; 1776 if (alpha === 0) { 1777 ey = py; 1778 } else { 1779 sy = py; 1780 } 1781 py = (ey + sy) >> 1; 1782 } 1783 ratio = py / ih; 1784 if (ratio === 0) { 1785 return 1; 1786 } else { 1787 return ratio; 1788 } 1789 }; 1790 1791 drawImageIOSFix = function(ctx, img, sx, sy, sw, sh, dx, dy, dw, dh) { 1792 var vertSquashRatio; 1793 vertSquashRatio = detectVerticalSquash(img); 1794 return ctx.drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh / vertSquashRatio); 1795 }; 1796 1797 1798 /* 1799 * contentloaded.js 1800 * 1801 * Author: Diego Perini (diego.perini at gmail.com) 1802 * Summary: cross-browser wrapper for DOMContentLoaded 1803 * Updated: 20101020 1804 * License: MIT 1805 * Version: 1.2 1806 * 1807 * URL: 1808 * http://javascript.nwbox.com/ContentLoaded/ 1809 * http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE 1810 */ 1811 1812 contentLoaded = function(win, fn) { 1813 var add, doc, done, init, poll, pre, rem, root, top; 1814 done = false;
1815 top = true; 1816 doc = win.document; 1817 root = doc.documentElement; 1818 add = (doc.addEventListener ? "addEventListener" : "attachEvent"); 1819 rem = (doc.addEventListener ? "removeEventListener" : "detachEvent"); 1820 pre = (doc.addEventListener ? "" : "on"); 1821 init = function(e) { 1822 if (e.type === "readystatechange" && doc.readyState !== "complete") { 1823 return; 1824 } 1825 (e.type === "load" ? win : doc)[rem](pre + e.type, init, false); 1826 if (!done && (done = true)) { 1827 return fn.call(win, e.type || e); 1828 } 1829 }; 1830 poll = function() { 1831 var e; 1832 try { 1833 root.doScroll("left"); 1834 } catch (_error) { 1835 e = _error; 1836 setTimeout(poll, 50); 1837 return; 1838 } 1839 return init("poll"); 1840 }; 1841 if (doc.readyState !== "complete") { 1842 if (doc.createEventObject && root.doScroll) { 1843 try { 1844 top = !win.frameElement; 1845 } catch (_error) {} 1846 if (top) { 1847 poll(); 1848 } 1849 } 1850 doc[add](pre + "DOMContentLoaded", init, false); 1851 doc[add](pre + "readystatechange", init, false); 1852 return win[add](pre + "load", init, false); 1853 } 1854 }; 1855 1856 Dropzone._autoDiscoverFunction = function() { 1857 if (Dropzone.autoDiscover) { 1858 return Dropzone.discover(); 1859 } 1860 }; 1861 1862 contentLoaded(window, Dropzone._autoDiscoverFunction); 1863 1864}).call(this); 1865 1866}); 1867 1868if (typeof exports == "object") { 1869 module.exports = require("dropzone"); 1870} else if (typeof define == "function" && define.amd) { 1871 define([], function(){ return require("dropzone"); }); 1872} else { 1873 this["Dropzone"] = require("dropzone"); 1874} 1875})()
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.