vendor: 6,931 bytes, lines 1-198
1/* 2 angular-file-upload v2.6.1 3 https://github.com/nervgh/angular-file-upload 4*/ 5 6(function webpackUniversalModuleDefinition(root, factory) { 7 if(typeof exports === 'object' && typeof module === 'object') 8 module.exports = factory(); 9 else if(typeof define === 'function' && define.amd) 10 define([], factory); 11 else if(typeof exports === 'object') 12 exports["angular-file-upload"] = factory(); 13 else 14 root["angular-file-upload"] = factory(); 15})(this, function() { 16return /******/ (function(modules) { // webpackBootstrap 17/******/ // The module cache 18/******/ var installedModules = {}; 19/******/ 20/******/ // The require function 21/******/ function __webpack_require__(moduleId) { 22/******/ 23/******/ // Check if module is in cache 24/******/ if(installedModules[moduleId]) 25/******/ return installedModules[moduleId].exports; 26/******/ 27/******/ // Create a new module (and put it into the cache) 28/******/ var module = installedModules[moduleId] = { 29/******/ exports: {}, 30/******/ id: moduleId, 31/******/ loaded: false 32/******/ }; 33/******/ 34/******/ // Execute the module function 35/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 36/******/ 37/******/ // Flag the module as loaded 38/******/ module.loaded = true; 39/******/ 40/******/ // Return the exports of the module 41/******/ return module.exports; 42/******/ } 43/******/ 44/******/ 45/******/ // expose the modules object (__webpack_modules__) 46/******/ __webpack_require__.m = modules; 47/******/ 48/******/ // expose the module cache 49/******/ __webpack_require__.c = installedModules; 50/******/ 51/******/ // __webpack_public_path__ 52/******/ __webpack_require__.p = ""; 53/******/ 54/******/ // Load entry module and return exports 55/******/ return __webpack_require__(0); 56/******/ }) 57/************************************************************************/ 58/******/ ([ 59/* 0 */ 60/***/ (function(module, exports, __webpack_require__) { 61 62 'use strict'; 63 64 var _config = __webpack_require__(1); 65 66 var _config2 = _interopRequireDefault(_config); 67 68 var _options = __webpack_require__(2); 69 70 var _options2 = _interopRequireDefault(_options); 71 72 var _FileUploader = __webpack_require__(3); 73 74 var _FileUploader2 = _interopRequireDefault(_FileUploader); 75 76 var _FileLikeObject = __webpack_require__(4); 77 78 var _FileLikeObject2 = _interopRequireDefault(_FileLikeObject); 79 80 var _FileItem = __webpack_require__(5); 81 82 var _FileItem2 = _interopRequireDefault(_FileItem); 83 84 var _FileDirective = __webpack_require__(6); 85 86 var _FileDirective2 = _interopRequireDefault(_FileDirective); 87 88 var _FileSelect = __webpack_require__(7); 89 90 var _FileSelect2 = _interopRequireDefault(_FileSelect); 91 92 var _Pipeline = __webpack_require__(8); 93 94 var _Pipeline2 = _interopRequireDefault(_Pipeline); 95 96 var _FileDrop = __webpack_require__(9); 97 98 var _FileDrop2 = _interopRequireDefault(_FileDrop); 99 100 var _FileOver = __webpack_require__(10); 101 102 var _FileOver2 = _interopRequireDefault(_FileOver); 103 104 var _FileSelect3 = __webpack_require__(11); 105 106 var _FileSelect4 = _interopRequireDefault(_FileSelect3); 107 108 var _FileDrop3 = __webpack_require__(12); 109 110 var _FileDrop4 = _interopRequireDefault(_FileDrop3); 111 112 var _FileOver3 = __webpack_require__(13); 113 114 var _FileOver4 = _interopRequireDefault(_FileOver3); 115 116 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 117 118 angular.module(_config2.default.name, []).value('fileUploaderOptions', _options2.default).factory('FileUploader', _FileUploader2.default).factory('FileLikeObject', _FileLikeObject2.default).factory('FileItem', _FileItem2.default).factory('FileDirective', _FileDirective2.default).factory('FileSelect', _FileSelect2.default).factory('FileDrop', _FileDrop2.default).factory('FileOver', _FileOver2.default).factory('Pipeline', _Pipeline2.default).directive('nvFileSelect', _FileSelect4.default).directive('nvFileDrop', _FileDrop4.default).directive('nvFileOver', _FileOver4.default).run(['FileUploader', 'FileLikeObject', 'FileItem', 'FileDirective', 'FileSelect', 'FileDrop', 'FileOver', 'Pipeline', function (FileUploader, FileLikeObject, FileItem, FileDirective, FileSelect, FileDrop, FileOver, Pipeline) { 119 // only for compatibility 120 FileUploader.FileLikeObject = FileLikeObject; 121 FileUploader.FileItem = FileItem; 122 FileUploader.FileDirective = FileDirective; 123 FileUploader.FileSelect = FileSelect; 124 FileUploader.FileDrop = FileDrop; 125 FileUploader.FileOver = FileOver; 126 FileUploader.Pipeline = Pipeline; 127 }]); 128 129/***/ }), 130/* 1 */ 131/***/ (function(module, exports) { 132 133 module.exports = {"name":"angularFileUpload"} 134 135/***/ }), 136/* 2 */ 137/***/ (function(module, exports) { 138 139 'use strict'; 140 141 Object.defineProperty(exports, "__esModule", { 142 value: true 143 }); 144 exports.default = { 145 url: '/', 146 alias: 'file', 147 headers: {}, 148 queue: [], 149 progress: 0, 150 autoUpload: false, 151 removeAfterUpload: false, 152 method: 'POST', 153 filters: [], 154 formData: [], 155 queueLimit: Number.MAX_VALUE, 156 withCredentials: false, 157 disableMultipart: false 158 }; 159 160/***/ }), 161/* 3 */ 162/***/ (function(module, exports, __webpack_require__) { 163 164 'use strict'; 165 166 Object.defineProperty(exports, "__esModule", { 167 value: true 168 }); 169 170 var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); 171 172 exports.default = __identity; 173 174 var _config = __webpack_require__(1); 175 176 var _config2 = _interopRequireDefault(_config); 177 178 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 179 180 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 181 182 var _angular = angular, 183 bind = _angular.bind, 184 copy = _angular.copy, 185 extend = _angular.extend, 186 forEach = _angular.forEach, 187 isObject = _angular.isObject, 188 isNumber = _angular.isNumber, 189 isDefined = _angular.isDefined, 190 isArray = _angular.isArray, 191 isUndefined = _angular.isUndefined, 192 element = _angular.element; 193 function __identity(fileUploaderOptions, $rootScope, $http, $window, $timeout, FileLikeObject, FileItem, Pipeline) { 194 var File = $window.File, 195 FormData = $window.FormData; 196 197 var FileUploader = function () { 198 /**********************
vendor: 24,181 bytes, lines 198-909
198 199 * PUBLIC 200 **********************/ 201 /** 202 * Creates an instance of FileUploader 203 * @param {Object} [options] 204 * @constructor 205 */ 206 function FileUploader(options) { 207 _classCallCheck(this, FileUploader); 208 209 var settings = copy(fileUploaderOptions); 210 211 extend(this, settings, options, { 212 isUploading: false, 213 _nextIndex: 0, 214 _directives: { select: [], drop: [], over: [] } 215 }); 216 217 // add default filters 218 this.filters.unshift({ name: 'queueLimit', fn: this._queueLimitFilter }); 219 this.filters.unshift({ name: 'folder', fn: this._folderFilter }); 220 } 221 /** 222 * Adds items to the queue 223 * @param {File|HTMLInputElement|Object|FileList|Array<Object>} files 224 * @param {Object} [options] 225 * @param {Array<Function>|String} filters 226 */ 227 228 229 FileUploader.prototype.addToQueue = function addToQueue(files, options, filters) { 230 var _this = this; 231 232 var incomingQueue = this.isArrayLikeObject(files) ? Array.prototype.slice.call(files) : [files]; 233 var arrayOfFilters = this._getFilters(filters); 234 var count = this.queue.length; 235 var addedFileItems = []; 236 237 var next = function next() { 238 var something = incomingQueue.shift(); 239 240 if (isUndefined(something)) { 241 return done(); 242 } 243 244 var fileLikeObject = _this.isFile(something) ? something : new FileLikeObject(something); 245 var pipes = _this._convertFiltersToPipes(arrayOfFilters); 246 var pipeline = new Pipeline(pipes); 247 var onThrown = function onThrown(err) { 248 var originalFilter = err.pipe.originalFilter; 249 250 var _err$args = _slicedToArray(err.args, 2), 251 fileLikeObject = _err$args[0], 252 options = _err$args[1]; 253 254 _this._onWhenAddingFileFailed(fileLikeObject, originalFilter, options); 255 next(); 256 }; 257 var onSuccessful = function onSuccessful(fileLikeObject, options) { 258 var fileItem = new FileItem(_this, fileLikeObject, options); 259 addedFileItems.push(fileItem); 260 _this.queue.push(fileItem); 261 _this._onAfterAddingFile(fileItem); 262 next(); 263 }; 264 pipeline.onThrown = onThrown; 265 pipeline.onSuccessful = onSuccessful; 266 pipeline.exec(fileLikeObject, options); 267 }; 268 269 var done = function done() { 270 if (_this.queue.length !== count) { 271 _this._onAfterAddingAll(addedFileItems); 272 _this.progress = _this._getTotalProgress(); 273 } 274 275 _this._render(); 276 if (_this.autoUpload) _this.uploadAll(); 277 }; 278 279 next(); 280 }; 281 /** 282 * Remove items from the queue. Remove last: index = -1 283 * @param {FileItem|Number} value 284 */ 285 286 287 FileUploader.prototype.removeFromQueue = function removeFromQueue(value) { 288 var index = this.getIndexOfItem(value); 289 var item = this.queue[index]; 290 if (item.isUploading) item.cancel(); 291 this.queue.splice(index, 1); 292 item._destroy(); 293 this.progress = this._getTotalProgress(); 294 }; 295 /** 296 * Clears the queue 297 */ 298 299 300 FileUploader.prototype.clearQueue = function clearQueue() { 301 while (this.queue.length) { 302 this.queue[0].remove(); 303 } 304 this.progress = 0; 305 }; 306 /** 307 * Uploads a item from the queue 308 * @param {FileItem|Number} value 309 */ 310 311 312 FileUploader.prototype.uploadItem = function uploadItem(value) { 313 var index = this.getIndexOfItem(value); 314 var item = this.queue[index]; 315 var transport = this.isHTML5 ? '_xhrTransport' : '_iframeTransport'; 316 317 item._prepareToUploading(); 318 if (this.isUploading) return; 319 320 this._onBeforeUploadItem(item); 321 if (item.isCancel) return; 322 323 item.isUploading = true; 324 this.isUploading = true; 325 this[transport](item); 326 this._render(); 327 }; 328 /** 329 * Cancels uploading of item from the queue 330 * @param {FileItem|Number} value 331 */ 332 333 334 FileUploader.prototype.cancelItem = function cancelItem(value) { 335 var _this2 = this; 336 337 var index = this.getIndexOfItem(value); 338 var item = this.queue[index]; 339 var prop = this.isHTML5 ? '_xhr' : '_form'; 340 if (!item) return; 341 item.isCancel = true; 342 if (item.isUploading) { 343 // It will call this._onCancelItem() & this._onCompleteItem() asynchronously 344 item[prop].abort(); 345 } else { 346 var dummy = [undefined, 0, {}]; 347 var onNextTick = function onNextTick() { 348 _this2._onCancelItem.apply(_this2, [item].concat(dummy)); 349 _this2._onCompleteItem.apply(_this2, [item].concat(dummy)); 350 }; 351 $timeout(onNextTick); // Trigger callbacks asynchronously (setImmediate emulation) 352 } 353 }; 354 /** 355 * Uploads all not uploaded items of queue 356 */ 357 358 359 FileUploader.prototype.uploadAll = function uploadAll() { 360 var items = this.getNotUploadedItems().filter(function (item) { 361 return !item.isUploading; 362 }); 363 if (!items.length) return; 364 365 forEach(items, function (item) { 366 return item._prepareToUploading(); 367 }); 368 items[0].upload(); 369 }; 370 /** 371 * Cancels all uploads 372 */ 373 374 375 FileUploader.prototype.cancelAll = function cancelAll() { 376 var items = this.getNotUploadedItems(); 377 forEach(items, function (item) { 378 return item.cancel(); 379 }); 380 }; 381 /** 382 * Returns "true" if value an instance of File 383 * @param {*} value 384 * @returns {Boolean} 385 * @private 386 */ 387 388 389 FileUploader.prototype.isFile = function isFile(value) { 390 return this.constructor.isFile(value); 391 }; 392 /** 393 * Returns "true" if value an instance of FileLikeObject 394 * @param {*} value 395 * @returns {Boolean} 396 * @private 397 */ 398 399 400 FileUploader.prototype.isFileLikeObject = function isFileLikeObject(value) { 401 return this.constructor.isFileLikeObject(value); 402 }; 403 /** 404 * Returns "true" if value is array like object 405 * @param {*} value 406 * @returns {Boolean} 407 */ 408 409 410 FileUploader.prototype.isArrayLikeObject = function isArrayLikeObject(value) { 411 return this.constructor.isArrayLikeObject(value); 412 }; 413 /** 414 * Returns a index of item from the queue 415 * @param {Item|Number} value 416 * @returns {Number} 417 */ 418 419 420 FileUploader.prototype.getIndexOfItem = function getIndexOfItem(value) { 421 return isNumber(value) ? value : this.queue.indexOf(value); 422 }; 423 /** 424 * Returns not uploaded items 425 * @returns {Array} 426 */ 427 428 429 FileUploader.prototype.getNotUploadedItems = function getNotUploadedItems() { 430 return this.queue.filter(function (item) { 431 return !item.isUploaded; 432 }); 433 }; 434 /** 435 * Returns items ready for upload 436 * @returns {Array} 437 */ 438 439 440 FileUploader.prototype.getReadyItems = function getReadyItems() { 441 return this.queue.filter(function (item) { 442 return item.isReady && !item.isUploading; 443 }).sort(function (item1, item2) { 444 return item1.index - item2.index; 445 }); 446 }; 447 /** 448 * Destroys instance of FileUploader 449 */ 450 451 452 FileUploader.prototype.destroy = function destroy() { 453 var _this3 = this; 454 455 forEach(this._directives, function (key) { 456 forEach(_this3._directives[key], function (object) { 457 object.destroy(); 458 }); 459 }); 460 }; 461 /** 462 * Callback 463 * @param {Array} fileItems 464 */ 465 466 467 FileUploader.prototype.onAfterAddingAll = function onAfterAddingAll(fileItems) {}; 468 /** 469 * Callback 470 * @param {FileItem} fileItem 471 */ 472 473 474 FileUploader.prototype.onAfterAddingFile = function onAfterAddingFile(fileItem) {}; 475 /** 476 * Callback 477 * @param {File|Object} item 478 * @param {Object} filter 479 * @param {Object} options 480 */ 481 482 483 FileUploader.prototype.onWhenAddingFileFailed = function onWhenAddingFileFailed(item, filter, options) {}; 484 /** 485 * Callback 486 * @param {FileItem} fileItem 487 */ 488 489 490 FileUploader.prototype.onBeforeUploadItem = function onBeforeUploadItem(fileItem) {}; 491 /** 492 * Callback 493 * @param {FileItem} fileItem 494 * @param {Number} progress 495 */ 496 497 498 FileUploader.prototype.onProgressItem = function onProgressItem(fileItem, progress) {}; 499 /** 500 * Callback 501 * @param {Number} progress 502 */ 503 504 505 FileUploader.prototype.onProgressAll = function onProgressAll(progress) {}; 506 /** 507 * Callback 508 * @param {FileItem} item 509 * @param {*} response 510 * @param {Number} status 511 * @param {Object} headers 512 */ 513 514 515 FileUploader.prototype.onSuccessItem = function onSuccessItem(item, response, status, headers) {}; 516 /** 517 * Callback 518 * @param {FileItem} item 519 * @param {*} response 520 * @param {Number} status 521 * @param {Object} headers 522 */ 523 524 525 FileUploader.prototype.onErrorItem = function onErrorItem(item, response, status, headers) {}; 526 /** 527 * Callback 528 * @param {FileItem} item 529 * @param {*} response 530 * @param {Number} status 531 * @param {Object} headers 532 */ 533 534 535 FileUploader.prototype.onCancelItem = function onCancelItem(item, response, status, headers) {}; 536 /** 537 * Callback 538 * @param {FileItem} item 539 * @param {*} response 540 * @param {Number} status 541 * @param {Object} headers 542 */ 543 544 545 FileUploader.prototype.onCompleteItem = function onCompleteItem(item, response, status, headers) {}; 546 /** 547 * Callback 548 * @param {FileItem} item 549 */ 550 551 552 FileUploader.prototype.onTimeoutItem = function onTimeoutItem(item) {}; 553 /** 554 * Callback 555 */ 556 557 558 FileUploader.prototype.onCompleteAll = function onCompleteAll() {}; 559 /********************** 560 * PRIVATE 561 **********************/ 562 /** 563 * Returns the total progress 564 * @param {Number} [value] 565 * @returns {Number} 566 * @private 567 */ 568 569 570 FileUploader.prototype._getTotalProgress = function _getTotalProgress(value) { 571 if (this.removeAfterUpload) return value || 0; 572 573 var notUploaded = this.getNotUploadedItems().length; 574 var uploaded = notUploaded ? this.queue.length - notUploaded : this.queue.length; 575 var ratio = 100 / this.queue.length; 576 var current = (value || 0) * ratio / 100; 577 578 return Math.round(uploaded * ratio + current); 579 }; 580 /** 581 * Returns array of filters 582 * @param {Array<Function>|String} filters 583 * @returns {Array<Function>} 584 * @private 585 */ 586 587 588 FileUploader.prototype._getFilters = function _getFilters(filters) { 589 if (!filters) return this.filters; 590 if (isArray(filters)) return filters; 591 var names = filters.match(/[^\s,]+/g); 592 return this.filters.filter(function (filter) { 593 return names.indexOf(filter.name) !== -1; 594 }); 595 }; 596 /** 597 * @param {Array<Function>} filters 598 * @returns {Array<Function>} 599 * @private 600 */ 601 602 603 FileUploader.prototype._convertFiltersToPipes = function _convertFiltersToPipes(filters) { 604 var _this4 = this; 605 606 return filters.map(function (filter) { 607 var fn = bind(_this4, filter.fn); 608 fn.isAsync = filter.fn.length === 3; 609 fn.originalFilter = filter; 610 return fn; 611 }); 612 }; 613 /** 614 * Updates html 615 * @private 616 */ 617 618 619 FileUploader.prototype._render = function _render() { 620 if (!$rootScope.$$phase) $rootScope.$apply(); 621 }; 622 /** 623 * Returns "true" if item is a file (not folder) 624 * @param {File|FileLikeObject} item 625 * @returns {Boolean} 626 * @private 627 */ 628 629 630 FileUploader.prototype._folderFilter = function _folderFilter(item) { 631 return !!(item.size || item.type); 632 }; 633 /** 634 * Returns "true" if the limit has not been reached 635 * @returns {Boolean} 636 * @private 637 */ 638 639 640 FileUploader.prototype._queueLimitFilter = function _queueLimitFilter() { 641 return this.queue.length < this.queueLimit; 642 }; 643 /** 644 * Checks whether upload successful 645 * @param {Number} status 646 * @returns {Boolean} 647 * @private 648 */ 649 650 651 FileUploader.prototype._isSuccessCode = function _isSuccessCode(status) { 652 return status >= 200 && status < 300 || status === 304; 653 }; 654 /** 655 * Transforms the server response 656 * @param {*} response 657 * @param {Object} headers 658 * @returns {*} 659 * @private 660 */ 661 662 663 FileUploader.prototype._transformResponse = function _transformResponse(response, headers) { 664 var headersGetter = this._headersGetter(headers); 665 forEach($http.defaults.transformResponse, function (transformFn) { 666 response = transformFn(response, headersGetter); 667 }); 668 return response; 669 }; 670 /** 671 * Parsed response headers 672 * @param headers 673 * @returns {Object} 674 * @see https://github.com/angular/angular.js/blob/master/src/ng/http.js 675 * @private 676 */ 677 678 679 FileUploader.prototype._parseHeaders = function _parseHeaders(headers) { 680 var parsed = {}, 681 key, 682 val, 683 i; 684 685 if (!headers) return parsed; 686 687 forEach(headers.split('\n'), function (line) { 688 i = line.indexOf(':'); 689 key = line.slice(0, i).trim().toLowerCase(); 690 val = line.slice(i + 1).trim(); 691 692 if (key) { 693 parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; 694 } 695 }); 696 697 return parsed; 698 }; 699 /** 700 * Returns function that returns headers 701 * @param {Object} parsedHeaders 702 * @returns {Function} 703 * @private 704 */ 705 706 707 FileUploader.prototype._headersGetter = function _headersGetter(parsedHeaders) { 708 return function (name) { 709 if (name) { 710 return parsedHeaders[name.toLowerCase()] || null; 711 } 712 return parsedHeaders; 713 }; 714 }; 715 /** 716 * The XMLHttpRequest transport 717 * @param {FileItem} item 718 * @private 719 */ 720 721 722 FileUploader.prototype._xhrTransport = function _xhrTransport(item) { 723 var _this5 = this; 724 725 var xhr = item._xhr = new XMLHttpRequest(); 726 var sendable; 727 728 if (!item.disableMultipart) { 729 sendable = new FormData(); 730 forEach(item.formData, function (obj) { 731 forEach(obj, function (value, key) { 732 sendable.append(key, value); 733 }); 734 }); 735 736 sendable.append(item.alias, item._file, item.file.name); 737 } else { 738 sendable = item._file; 739 } 740 741 if (typeof item._file.size != 'number') { 742 throw new TypeError('The file specified is no longer valid'); 743 } 744 745 xhr.upload.onprogress = function (event) { 746 var progress = Math.round(event.lengthComputable ? event.loaded * 100 / event.total : 0); 747 _this5._onProgressItem(item, progress); 748 }; 749 750 xhr.onload = function () { 751 var headers = _this5._parseHeaders(xhr.getAllResponseHeaders()); 752 var response = _this5._transformResponse(xhr.response, headers); 753 var gist = _this5._isSuccessCode(xhr.status) ? 'Success' : 'Error'; 754 var method = '_on' + gist + 'Item'; 755 _this5[method](item, response, xhr.status, headers); 756 _this5._onCompleteItem(item, response, xhr.status, headers); 757 }; 758 759 xhr.onerror = function () { 760 var headers = _this5._parseHeaders(xhr.getAllResponseHeaders()); 761 var response = _this5._transformResponse(xhr.response, headers); 762 _this5._onErrorItem(item, response, xhr.status, headers); 763 _this5._onCompleteItem(item, response, xhr.status, headers); 764 }; 765 766 xhr.onabort = function () { 767 var headers = _this5._parseHeaders(xhr.getAllResponseHeaders()); 768 var response = _this5._transformResponse(xhr.response, headers); 769 _this5._onCancelItem(item, response, xhr.status, headers); 770 _this5._onCompleteItem(item, response, xhr.status, headers); 771 }; 772 773 xhr.ontimeout = function (e) { 774 var headers = _this5._parseHeaders(xhr.getAllResponseHeaders()); 775 var response = "Request Timeout."; 776 _this5._onTimeoutItem(item); 777 _this5._onCompleteItem(item, response, 408, headers); 778 }; 779 780 xhr.open(item.method, item.url, true); 781 782 xhr.timeout = item.timeout || 0; 783 xhr.withCredentials = item.withCredentials; 784 785 forEach(item.headers, function (value, name) { 786 xhr.setRequestHeader(name, value); 787 }); 788 789 xhr.send(sendable); 790 }; 791 /** 792 * The IFrame transport 793 * @param {FileItem} item 794 * @private 795 */ 796 797 798 FileUploader.prototype._iframeTransport = function _iframeTransport(item) { 799 var _this6 = this; 800 801 var form = element('<form style="display: none;" />'); 802 var iframe = element('<iframe name="iframeTransport' + Date.now() + '">'); 803 var input = item._input; 804 805 var timeout = 0; 806 var timer = null; 807 var isTimedOut = false; 808 809 if (item._form) item._form.replaceWith(input); // remove old form 810 item._form = form; // save link to new form 811 812 input.prop('name', item.alias); 813 814 forEach(item.formData, function (obj) { 815 forEach(obj, function (value, key) { 816 var element_ = element('<input type="hidden" name="' + key + '" />'); 817 element_.val(value); 818 form.append(element_); 819 }); 820 }); 821 822 form.prop({ 823 action: item.url, 824 method: 'POST', 825 target: iframe.prop('name'), 826 enctype: 'multipart/form-data', 827 encoding: 'multipart/form-data' // old IE 828 }); 829 830 iframe.bind('load', function () { 831 var html = ''; 832 var status = 200; 833 834 try { 835 // Fix for legacy IE browsers that loads internal error page 836 // when failed WS response received. In consequence iframe 837 // content access denied error is thrown becouse trying to 838 // access cross domain page. When such thing occurs notifying 839 // with empty response object. See more info at: 840 // http://stackoverflow.com/questions/151362/access-is-denied-error-on-accessing-iframe-document-object 841 // Note that if non standard 4xx or 5xx error code returned 842 // from WS then response content can be accessed without error 843 // but 'XHR' status becomes 200. In order to avoid confusion 844 // returning response via same 'success' event handler. 845 846 // fixed angular.contents() for iframes 847 html = iframe[0].contentDocument.body.innerHTML; 848 } catch (e) { 849 // in case we run into the access-is-denied error or we have another error on the server side 850 // (intentional 500,40... errors), we at least say 'something went wrong' -> 500 851 status = 500; 852 } 853 854 if (timer) { 855 clearTimeout(timer); 856 } 857 timer = null; 858 859 if (isTimedOut) { 860 return false; //throw 'Request Timeout' 861 } 862 863 var xhr = { response: html, status: status, dummy: true }; 864 var headers = {}; 865 var response = _this6._transformResponse(xhr.response, headers); 866 867 _this6._onSuccessItem(item, response, xhr.status, headers); 868 _this6._onCompleteItem(item, response, xhr.status, headers); 869 }); 870 871 form.abort = function () { 872 var xhr = { status: 0, dummy: true }; 873 var headers = {}; 874 var response; 875 876 iframe.unbind('load').prop('src', 'javascript:false;'); 877 form.replaceWith(input); 878 879 _this6._onCancelItem(item, response, xhr.status, headers); 880 _this6._onCompleteItem(item, response, xhr.status, headers); 881 }; 882 883 input.after(form); 884 form.append(input).append(iframe); 885 886 timeout = item.timeout || 0; 887 timer = null; 888 889 if (timeout) { 890 timer = setTimeout(function () { 891 isTimedOut = true; 892 893 item.isCancel = true; 894 if (item.isUploading) { 895 iframe.unbind('load').prop('src', 'javascript:false;'); 896 form.replaceWith(input); 897 } 898 899 var headers = {}; 900 var response = "Request Timeout."; 901 _this6._onTimeoutItem(item); 902 _this6._onCompleteItem(item, response, 408, headers); 903 }, timeout); 904 } 905 906 form[0].submit(); 907 }; 908 /** 909 * Inner callback
910 * @param {File|Object} item 911 * @param {Object} filter 912 * @param {Object} options 913 * @private 914 */ 915 916 917 FileUploader.prototype._onWhenAddingFileFailed = function _onWhenAddingFileFailed(item, filter, options) { 918 this.onWhenAddingFileFailed(item, filter, options); 919 }; 920 /** 921 * Inner callback 922 * @param {FileItem} item 923 */ 924 925 926 FileUploader.prototype._onAfterAddingFile = function _onAfterAddingFile(item) { 927 this.onAfterAddingFile(item); 928 }; 929 /** 930 * Inner callback 931 * @param {Array<FileItem>} items 932 */ 933 934 935 FileUploader.prototype._onAfterAddingAll = function _onAfterAddingAll(items) { 936 this.onAfterAddingAll(items); 937 }; 938 /** 939 * Inner callback 940 * @param {FileItem} item 941 * @private 942 */ 943 944 945 FileUploader.prototype._onBeforeUploadItem = function _onBeforeUploadItem(item) { 946 item._onBeforeUpload(); 947 this.onBeforeUploadItem(item); 948 }; 949 /** 950 * Inner callback 951 * @param {FileItem} item 952 * @param {Number} progress 953 * @private 954 */ 955 956 957 FileUploader.prototype._onProgressItem = function _onProgressItem(item, progress) { 958 var total = this._getTotalProgress(progress); 959 this.progress = total; 960 item._onProgress(progress); 961 this.onProgressItem(item, progress); 962 this.onProgressAll(total); 963 this._render(); 964 }; 965 /** 966 * Inner callback 967 * @param {FileItem} item 968 * @param {*} response 969 * @param {Number} status 970 * @param {Object} headers 971 * @private 972 */ 973 974 975 FileUploader.prototype._onSuccessItem = function _onSuccessItem(item, response, status, headers) { 976 item._onSuccess(response, status, headers); 977 this.onSuccessItem(item, response, status, headers); 978 }; 979 /** 980 * Inner callback 981 * @param {FileItem} item 982 * @param {*} response 983 * @param {Number} status 984 * @param {Object} headers 985 * @private 986 */ 987 988 989 FileUploader.prototype._onErrorItem = function _onErrorItem(item, response, status, headers) { 990 item._onError(response, status, headers); 991 this.onErrorItem(item, response, status, headers); 992 }; 993 /** 994 * Inner callback 995 * @param {FileItem} item 996 * @param {*} response 997 * @param {Number} status 998 * @param {Object} headers 999 * @private 1000 */ 1001 1002 1003 FileUploader.prototype._onCancelItem = function _onCancelItem(item, response, status, headers) { 1004 item._onCancel(response, status, headers); 1005 this.onCancelItem(item, response, status, headers); 1006 }; 1007 /** 1008 * Inner callback 1009 * @param {FileItem} item 1010 * @param {*} response 1011 * @param {Number} status 1012 * @param {Object} headers 1013 * @private 1014 */ 1015 1016 1017 FileUploader.prototype._onCompleteItem = function _onCompleteItem(item, response, status, headers) { 1018 item._onComplete(response, status, headers); 1019 this.onCompleteItem(item, response, status, headers); 1020 1021 var nextItem = this.getReadyItems()[0]; 1022 this.isUploading = false; 1023 1024 if (isDefined(nextItem)) { 1025 nextItem.upload(); 1026 return; 1027 } 1028 1029 this.onCompleteAll(); 1030 this.progress = this._getTotalProgress(); 1031 this._render(); 1032 }; 1033 /** 1034 * Inner callback 1035 * @param {FileItem} item 1036 * @private 1037 */ 1038 1039
vendor: 9,546 bytes, lines 1040-1389
1040 FileUploader.prototype._onTimeoutItem = function _onTimeoutItem(item) { 1041 item._onTimeout(); 1042 this.onTimeoutItem(item); 1043 }; 1044 /********************** 1045 * STATIC 1046 **********************/ 1047 /** 1048 * Returns "true" if value an instance of File 1049 * @param {*} value 1050 * @returns {Boolean} 1051 * @private 1052 */ 1053 1054 1055 FileUploader.isFile = function isFile(value) { 1056 return File && value instanceof File; 1057 }; 1058 /** 1059 * Returns "true" if value an instance of FileLikeObject 1060 * @param {*} value 1061 * @returns {Boolean} 1062 * @private 1063 */ 1064 1065 1066 FileUploader.isFileLikeObject = function isFileLikeObject(value) { 1067 return value instanceof FileLikeObject; 1068 }; 1069 /** 1070 * Returns "true" if value is array like object 1071 * @param {*} value 1072 * @returns {Boolean} 1073 */ 1074 1075 1076 FileUploader.isArrayLikeObject = function isArrayLikeObject(value) { 1077 return isObject(value) && 'length' in value; 1078 }; 1079 /** 1080 * Inherits a target (Class_1) by a source (Class_2) 1081 * @param {Function} target 1082 * @param {Function} source 1083 */ 1084 1085 1086 FileUploader.inherit = function inherit(target, source) { 1087 target.prototype = Object.create(source.prototype); 1088 target.prototype.constructor = target; 1089 target.super_ = source; 1090 }; 1091 1092 return FileUploader; 1093 }(); 1094 1095 /********************** 1096 * PUBLIC 1097 **********************/ 1098 /** 1099 * Checks a support the html5 uploader 1100 * @returns {Boolean} 1101 * @readonly 1102 */ 1103 1104 1105 FileUploader.prototype.isHTML5 = !!(File && FormData); 1106 /********************** 1107 * STATIC 1108 **********************/ 1109 /** 1110 * @borrows FileUploader.prototype.isHTML5 1111 */ 1112 FileUploader.isHTML5 = FileUploader.prototype.isHTML5; 1113 1114 return FileUploader; 1115 } 1116 1117 __identity.$inject = ['fileUploaderOptions', '$rootScope', '$http', '$window', '$timeout', 'FileLikeObject', 'FileItem', 'Pipeline']; 1118 1119/***/ }), 1120/* 4 */ 1121/***/ (function(module, exports, __webpack_require__) { 1122 1123 'use strict'; 1124 1125 Object.defineProperty(exports, "__esModule", { 1126 value: true 1127 }); 1128 exports.default = __identity; 1129 1130 var _config = __webpack_require__(1); 1131 1132 var _config2 = _interopRequireDefault(_config); 1133 1134 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1135 1136 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1137 1138 var _angular = angular, 1139 copy = _angular.copy, 1140 isElement = _angular.isElement, 1141 isString = _angular.isString; 1142 function __identity() { 1143 1144 return function () { 1145 /** 1146 * Creates an instance of FileLikeObject 1147 * @param {File|HTMLInputElement|Object} fileOrInput 1148 * @constructor 1149 */ 1150 function FileLikeObject(fileOrInput) { 1151 _classCallCheck(this, FileLikeObject); 1152 1153 var isInput = isElement(fileOrInput); 1154 var fakePathOrObject = isInput ? fileOrInput.value : fileOrInput; 1155 var postfix = isString(fakePathOrObject) ? 'FakePath' : 'Object'; 1156 var method = '_createFrom' + postfix; 1157 this[method](fakePathOrObject, fileOrInput); 1158 } 1159 /** 1160 * Creates file like object from fake path string 1161 * @param {String} path 1162 * @private 1163 */ 1164 1165 1166 FileLikeObject.prototype._createFromFakePath = function _createFromFakePath(path, input) { 1167 this.lastModifiedDate = null; 1168 this.size = null; 1169 this.type = 'like/' + path.slice(path.lastIndexOf('.') + 1).toLowerCase(); 1170 this.name = path.slice(path.lastIndexOf('/') + path.lastIndexOf('\\') + 2); 1171 this.input = input; 1172 }; 1173 /** 1174 * Creates file like object from object 1175 * @param {File|FileLikeObject} object 1176 * @private 1177 */ 1178 1179 1180 FileLikeObject.prototype._createFromObject = function _createFromObject(object) { 1181 this.lastModifiedDate = copy(object.lastModifiedDate); 1182 this.size = object.size; 1183 this.type = object.type; 1184 this.name = object.name; 1185 this.input = object.input; 1186 }; 1187 1188 return FileLikeObject; 1189 }(); 1190 } 1191 1192/***/ }), 1193/* 5 */ 1194/***/ (function(module, exports, __webpack_require__) { 1195 1196 'use strict'; 1197 1198 Object.defineProperty(exports, "__esModule", { 1199 value: true 1200 }); 1201 exports.default = __identity; 1202 1203 var _config = __webpack_require__(1); 1204 1205 var _config2 = _interopRequireDefault(_config); 1206 1207 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1208 1209 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1210 1211 var _angular = angular, 1212 copy = _angular.copy, 1213 extend = _angular.extend, 1214 element = _angular.element, 1215 isElement = _angular.isElement; 1216 function __identity($compile, FileLikeObject) { 1217 1218 return function () { 1219 /** 1220 * Creates an instance of FileItem 1221 * @param {FileUploader} uploader 1222 * @param {File|HTMLInputElement|Object} some 1223 * @param {Object} options 1224 * @constructor 1225 */ 1226 function FileItem(uploader, some, options) { 1227 _classCallCheck(this, FileItem); 1228 1229 var isInput = !!some.input; 1230 var input = isInput ? element(some.input) : null; 1231 var file = !isInput ? some : null; 1232 1233 extend(this, { 1234 url: uploader.url, 1235 alias: uploader.alias, 1236 headers: copy(uploader.headers), 1237 formData: copy(uploader.formData), 1238 removeAfterUpload: uploader.removeAfterUpload, 1239 withCredentials: uploader.withCredentials, 1240 disableMultipart: uploader.disableMultipart, 1241 method: uploader.method, 1242 timeout: uploader.timeout 1243 }, options, { 1244 uploader: uploader, 1245 file: new FileLikeObject(some), 1246 isReady: false, 1247 isUploading: false, 1248 isUploaded: false, 1249 isSuccess: false, 1250 isCancel: false, 1251 isError: false, 1252 progress: 0, 1253 index: null, 1254 _file: file, 1255 _input: input 1256 }); 1257 1258 if (input) this._replaceNode(input); 1259 } 1260 /********************** 1261 * PUBLIC 1262 **********************/ 1263 /** 1264 * Uploads a FileItem 1265 */ 1266 1267 1268 FileItem.prototype.upload = function upload() { 1269 try { 1270 this.uploader.uploadItem(this); 1271 } catch (e) { 1272 var message = e.name + ':' + e.message; 1273 this.uploader._onCompleteItem(this, message, e.code, []); 1274 this.uploader._onErrorItem(this, message, e.code, []); 1275 } 1276 }; 1277 /** 1278 * Cancels uploading of FileItem 1279 */ 1280 1281 1282 FileItem.prototype.cancel = function cancel() { 1283 this.uploader.cancelItem(this); 1284 }; 1285 /** 1286 * Removes a FileItem 1287 */ 1288 1289 1290 FileItem.prototype.remove = function remove() { 1291 this.uploader.removeFromQueue(this); 1292 }; 1293 /** 1294 * Callback 1295 * @private 1296 */ 1297 1298 1299 FileItem.prototype.onBeforeUpload = function onBeforeUpload() {}; 1300 /** 1301 * Callback 1302 * @param {Number} progress 1303 * @private 1304 */ 1305 1306 1307 FileItem.prototype.onProgress = function onProgress(progress) {}; 1308 /** 1309 * Callback 1310 * @param {*} response 1311 * @param {Number} status 1312 * @param {Object} headers 1313 */ 1314 1315 1316 FileItem.prototype.onSuccess = function onSuccess(response, status, headers) {}; 1317 /** 1318 * Callback 1319 * @param {*} response 1320 * @param {Number} status 1321 * @param {Object} headers 1322 */ 1323 1324 1325 FileItem.prototype.onError = function onError(response, status, headers) {}; 1326 /** 1327 * Callback 1328 * @param {*} response 1329 * @param {Number} status 1330 * @param {Object} headers 1331 */ 1332 1333 1334 FileItem.prototype.onCancel = function onCancel(response, status, headers) {}; 1335 /** 1336 * Callback 1337 * @param {*} response 1338 * @param {Number} status 1339 * @param {Object} headers 1340 */ 1341 1342 1343 FileItem.prototype.onComplete = function onComplete(response, status, headers) {}; 1344 /** 1345 * Callback 1346 */ 1347 1348 1349 FileItem.prototype.onTimeout = function onTimeout() {}; 1350 /********************** 1351 * PRIVATE 1352 **********************/ 1353 /** 1354 * Inner callback 1355 */ 1356 1357 1358 FileItem.prototype._onBeforeUpload = function _onBeforeUpload() { 1359 this.isReady = true; 1360 this.isUploading = false; 1361 this.isUploaded = false; 1362 this.isSuccess = false; 1363 this.isCancel = false; 1364 this.isError = false; 1365 this.progress = 0; 1366 this.onBeforeUpload(); 1367 }; 1368 /** 1369 * Inner callback 1370 * @param {Number} progress 1371 * @private 1372 */ 1373 1374 1375 FileItem.prototype._onProgress = function _onProgress(progress) { 1376 this.progress = progress; 1377 this.onProgress(progress); 1378 }; 1379 /** 1380 * Inner callback 1381 * @param {*} response 1382 * @param {Number} status 1383 * @param {Object} headers 1384 * @private 1385 */ 1386 1387 1388 FileItem.prototype._onSuccess = function _onSuccess(response, status, headers) { 1389 this.isReady = false;
1390 this.isUploading = false; 1391 this.isUploaded = true; 1392 this.isSuccess = true; 1393 this.isCancel = false; 1394 this.isError = false; 1395 this.progress = 100; 1396 this.index = null; 1397 this.onSuccess(response, status, headers); 1398 }; 1399 /** 1400 * Inner callback 1401 * @param {*} response 1402 * @param {Number} status 1403 * @param {Object} headers 1404 * @private 1405 */ 1406 1407 1408 FileItem.prototype._onError = function _onError(response, status, headers) { 1409 this.isReady = false; 1410 this.isUploading = false; 1411 this.isUploaded = true; 1412 this.isSuccess = false; 1413 this.isCancel = false; 1414 this.isError = true; 1415 this.progress = 0; 1416 this.index = null; 1417 this.onError(response, status, headers); 1418 }; 1419 /** 1420 * Inner callback 1421 * @param {*} response 1422 * @param {Number} status 1423 * @param {Object} headers 1424 * @private 1425 */ 1426 1427 1428 FileItem.prototype._onCancel = function _onCancel(response, status, headers) { 1429 this.isReady = false; 1430 this.isUploading = false; 1431 this.isUploaded = false; 1432 this.isSuccess = false; 1433 this.isCancel = true; 1434 this.isError = false; 1435 this.progress = 0; 1436 this.index = null; 1437 this.onCancel(response, status, headers); 1438 }; 1439 /** 1440 * Inner callback 1441 * @param {*} response 1442 * @param {Number} status 1443 * @param {Object} headers 1444 * @private 1445 */ 1446 1447 1448 FileItem.prototype._onComplete = function _onComplete(response, status, headers) { 1449 this.onComplete(response, status, headers); 1450 if (this.removeAfterUpload) this.remove(); 1451 }; 1452 /** 1453 * Inner callback 1454 * @private 1455 */ 1456 1457
vendor: 11,013 bytes, lines 1458-1808
1458 FileItem.prototype._onTimeout = function _onTimeout() { 1459 this.isReady = false; 1460 this.isUploading = false; 1461 this.isUploaded = false; 1462 this.isSuccess = false; 1463 this.isCancel = false; 1464 this.isError = true; 1465 this.progress = 0; 1466 this.index = null; 1467 this.onTimeout(); 1468 }; 1469 /** 1470 * Destroys a FileItem 1471 */ 1472 1473 1474 FileItem.prototype._destroy = function _destroy() { 1475 if (this._input) this._input.remove(); 1476 if (this._form) this._form.remove(); 1477 delete this._form; 1478 delete this._input; 1479 }; 1480 /** 1481 * Prepares to uploading 1482 * @private 1483 */ 1484 1485 1486 FileItem.prototype._prepareToUploading = function _prepareToUploading() { 1487 this.index = this.index || ++this.uploader._nextIndex; 1488 this.isReady = true; 1489 }; 1490 /** 1491 * Replaces input element on his clone 1492 * @param {JQLite|jQuery} input 1493 * @private 1494 */ 1495 1496 1497 FileItem.prototype._replaceNode = function _replaceNode(input) { 1498 var clone = $compile(input.clone())(input.scope()); 1499 clone.prop('value', null); // FF fix 1500 input.css('display', 'none'); 1501 input.after(clone); // remove jquery dependency 1502 }; 1503 1504 return FileItem; 1505 }(); 1506 } 1507 1508 __identity.$inject = ['$compile', 'FileLikeObject']; 1509 1510/***/ }), 1511/* 6 */ 1512/***/ (function(module, exports, __webpack_require__) { 1513 1514 'use strict'; 1515 1516 Object.defineProperty(exports, "__esModule", { 1517 value: true 1518 }); 1519 exports.default = __identity; 1520 1521 var _config = __webpack_require__(1); 1522 1523 var _config2 = _interopRequireDefault(_config); 1524 1525 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1526 1527 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1528 1529 var _angular = angular, 1530 extend = _angular.extend; 1531 function __identity() { 1532 var FileDirective = function () { 1533 /** 1534 * Creates instance of {FileDirective} object 1535 * @param {Object} options 1536 * @param {Object} options.uploader 1537 * @param {HTMLElement} options.element 1538 * @param {Object} options.events 1539 * @param {String} options.prop 1540 * @constructor 1541 */ 1542 function FileDirective(options) { 1543 _classCallCheck(this, FileDirective); 1544 1545 extend(this, options); 1546 this.uploader._directives[this.prop].push(this); 1547 this._saveLinks(); 1548 this.bind(); 1549 } 1550 /** 1551 * Binds events handles 1552 */ 1553 1554 1555 FileDirective.prototype.bind = function bind() { 1556 for (var key in this.events) { 1557 var prop = this.events[key]; 1558 this.element.bind(key, this[prop]); 1559 } 1560 }; 1561 /** 1562 * Unbinds events handles 1563 */ 1564 1565 1566 FileDirective.prototype.unbind = function unbind() { 1567 for (var key in this.events) { 1568 this.element.unbind(key, this.events[key]); 1569 } 1570 }; 1571 /** 1572 * Destroys directive 1573 */ 1574 1575 1576 FileDirective.prototype.destroy = function destroy() { 1577 var index = this.uploader._directives[this.prop].indexOf(this); 1578 this.uploader._directives[this.prop].splice(index, 1); 1579 this.unbind(); 1580 // this.element = null; 1581 }; 1582 /** 1583 * Saves links to functions 1584 * @private 1585 */ 1586 1587 1588 FileDirective.prototype._saveLinks = function _saveLinks() { 1589 for (var key in this.events) { 1590 var prop = this.events[key]; 1591 this[prop] = this[prop].bind(this); 1592 } 1593 }; 1594 1595 return FileDirective; 1596 }(); 1597 1598 /** 1599 * Map of events 1600 * @type {Object} 1601 */ 1602 1603 1604 FileDirective.prototype.events = {}; 1605 1606 return FileDirective; 1607 } 1608 1609/***/ }), 1610/* 7 */ 1611/***/ (function(module, exports, __webpack_require__) { 1612 1613 'use strict'; 1614 1615 Object.defineProperty(exports, "__esModule", { 1616 value: true 1617 }); 1618 exports.default = __identity; 1619 1620 var _config = __webpack_require__(1); 1621 1622 var _config2 = _interopRequireDefault(_config); 1623 1624 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1625 1626 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1627 1628 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 1629 1630 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 1631 1632 var _angular = angular, 1633 extend = _angular.extend; 1634 function __identity($compile, FileDirective) { 1635 1636 return function (_FileDirective) { 1637 _inherits(FileSelect, _FileDirective); 1638 1639 /** 1640 * Creates instance of {FileSelect} object 1641 * @param {Object} options 1642 * @constructor 1643 */ 1644 function FileSelect(options) { 1645 _classCallCheck(this, FileSelect); 1646 1647 var extendedOptions = extend(options, { 1648 // Map of events 1649 events: { 1650 $destroy: 'destroy', 1651 change: 'onChange' 1652 }, 1653 // Name of property inside uploader._directive object 1654 prop: 'select' 1655 }); 1656 1657 var _this = _possibleConstructorReturn(this, _FileDirective.call(this, extendedOptions)); 1658 1659 if (!_this.uploader.isHTML5) { 1660 _this.element.removeAttr('multiple'); 1661 } 1662 _this.element.prop('value', null); // FF fix 1663 return _this; 1664 } 1665 /** 1666 * Returns options 1667 * @return {Object|undefined} 1668 */ 1669 1670 1671 FileSelect.prototype.getOptions = function getOptions() {}; 1672 /** 1673 * Returns filters 1674 * @return {Array<Function>|String|undefined} 1675 */ 1676 1677 1678 FileSelect.prototype.getFilters = function getFilters() {}; 1679 /** 1680 * If returns "true" then HTMLInputElement will be cleared 1681 * @returns {Boolean} 1682 */ 1683 1684 1685 FileSelect.prototype.isEmptyAfterSelection = function isEmptyAfterSelection() { 1686 return !!this.element.attr('multiple'); 1687 }; 1688 /** 1689 * Event handler 1690 */ 1691 1692 1693 FileSelect.prototype.onChange = function onChange() { 1694 var files = this.uploader.isHTML5 ? this.element[0].files : this.element[0]; 1695 var options = this.getOptions(); 1696 var filters = this.getFilters(); 1697 1698 if (!this.uploader.isHTML5) this.destroy(); 1699 this.uploader.addToQueue(files, options, filters); 1700 if (this.isEmptyAfterSelection()) { 1701 this.element.prop('value', null); 1702 this.element.replaceWith($compile(this.element.clone())(this.scope)); // IE fix 1703 } 1704 }; 1705 1706 return FileSelect; 1707 }(FileDirective); 1708 } 1709 1710 __identity.$inject = ['$compile', 'FileDirective']; 1711 1712/***/ }), 1713/* 8 */ 1714/***/ (function(module, exports) { 1715 1716 'use strict'; 1717 1718 Object.defineProperty(exports, "__esModule", { 1719 value: true 1720 }); 1721 exports.default = __identity; 1722 1723 function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } 1724 1725 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1726 1727 var _angular = angular, 1728 bind = _angular.bind, 1729 isUndefined = _angular.isUndefined; 1730 function __identity($q) { 1731 1732 return function () { 1733 /** 1734 * @param {Array<Function>} pipes 1735 */ 1736 function Pipeline() { 1737 var pipes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; 1738 1739 _classCallCheck(this, Pipeline); 1740 1741 this.pipes = pipes; 1742 } 1743 1744 Pipeline.prototype.next = function next(args) { 1745 var pipe = this.pipes.shift(); 1746 if (isUndefined(pipe)) { 1747 this.onSuccessful.apply(this, _toConsumableArray(args)); 1748 return; 1749 } 1750 var err = new Error('The filter has not passed'); 1751 err.pipe = pipe; 1752 err.args = args; 1753 if (pipe.isAsync) { 1754 var deferred = $q.defer(); 1755 var onFulfilled = bind(this, this.next, args); 1756 var onRejected = bind(this, this.onThrown, err); 1757 deferred.promise.then(onFulfilled, onRejected); 1758 pipe.apply(undefined, _toConsumableArray(args).concat([deferred])); 1759 } else { 1760 var isDone = Boolean(pipe.apply(undefined, _toConsumableArray(args))); 1761 if (isDone) { 1762 this.next(args); 1763 } else { 1764 this.onThrown(err); 1765 } 1766 } 1767 }; 1768 1769 Pipeline.prototype.exec = function exec() { 1770 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { 1771 args[_key] = arguments[_key]; 1772 } 1773 1774 this.next(args); 1775 }; 1776 1777 Pipeline.prototype.onThrown = function onThrown(err) {}; 1778 1779 Pipeline.prototype.onSuccessful = function onSuccessful() {}; 1780 1781 return Pipeline; 1782 }(); 1783 } 1784 1785 __identity.$inject = ['$q']; 1786 1787/***/ }), 1788/* 9 */ 1789/***/ (function(module, exports, __webpack_require__) { 1790 1791 'use strict'; 1792 1793 Object.defineProperty(exports, "__esModule", { 1794 value: true 1795 }); 1796 exports.default = __identity; 1797 1798 var _config = __webpack_require__(1); 1799 1800 var _config2 = _interopRequireDefault(_config); 1801 1802 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1803 1804 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1805 1806 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 1807 1808 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { c
1808onstructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 1809 1810 var _angular = angular, 1811 extend = _angular.extend, 1812 forEach = _angular.forEach; 1813 function __identity(FileDirective) { 1814 1815 return function (_FileDirective) { 1816 _inherits(FileDrop, _FileDirective); 1817 1818 /** 1819 * Creates instance of {FileDrop} object 1820 * @param {Object} options 1821 * @constructor 1822 */ 1823 function FileDrop(options) { 1824 _classCallCheck(this, FileDrop); 1825 1826 var extendedOptions = extend(options, { 1827 // Map of events 1828 events: { 1829 $destroy: 'destroy', 1830 drop: 'onDrop', 1831 dragover: 'onDragOver', 1832 dragleave: 'onDragLeave' 1833 }, 1834 // Name of property inside uploader._directive object 1835 prop: 'drop'
vendor: 9,534 bytes, lines 1836-2161
1836 }); 1837 1838 return _possibleConstructorReturn(this, _FileDirective.call(this, extendedOptions)); 1839 } 1840 /** 1841 * Returns options 1842 * @return {Object|undefined} 1843 */ 1844 1845 1846 FileDrop.prototype.getOptions = function getOptions() {}; 1847 /** 1848 * Returns filters 1849 * @return {Array<Function>|String|undefined} 1850 */ 1851 1852 1853 FileDrop.prototype.getFilters = function getFilters() {}; 1854 /** 1855 * Event handler 1856 */ 1857 1858 1859 FileDrop.prototype.onDrop = function onDrop(event) { 1860 var transfer = this._getTransfer(event); 1861 if (!transfer) return; 1862 var options = this.getOptions(); 1863 var filters = this.getFilters(); 1864 this._preventAndStop(event); 1865 forEach(this.uploader._directives.over, this._removeOverClass, this); 1866 this.uploader.addToQueue(transfer.files, options, filters); 1867 }; 1868 /** 1869 * Event handler 1870 */ 1871 1872 1873 FileDrop.prototype.onDragOver = function onDragOver(event) { 1874 var transfer = this._getTransfer(event); 1875 if (!this._haveFiles(transfer.types)) return; 1876 transfer.dropEffect = 'copy'; 1877 this._preventAndStop(event); 1878 forEach(this.uploader._directives.over, this._addOverClass, this); 1879 }; 1880 /** 1881 * Event handler 1882 */ 1883 1884 1885 FileDrop.prototype.onDragLeave = function onDragLeave(event) { 1886 if (event.currentTarget === this.element[0]) return; 1887 this._preventAndStop(event); 1888 forEach(this.uploader._directives.over, this._removeOverClass, this); 1889 }; 1890 /** 1891 * Helper 1892 */ 1893 1894 1895 FileDrop.prototype._getTransfer = function _getTransfer(event) { 1896 return event.dataTransfer ? event.dataTransfer : event.originalEvent.dataTransfer; // jQuery fix; 1897 }; 1898 /** 1899 * Helper 1900 */ 1901 1902 1903 FileDrop.prototype._preventAndStop = function _preventAndStop(event) { 1904 event.preventDefault(); 1905 event.stopPropagation(); 1906 }; 1907 /** 1908 * Returns "true" if types contains files 1909 * @param {Object} types 1910 */ 1911 1912 1913 FileDrop.prototype._haveFiles = function _haveFiles(types) { 1914 if (!types) return false; 1915 if (types.indexOf) { 1916 return types.indexOf('Files') !== -1; 1917 } else if (types.contains) { 1918 return types.contains('Files'); 1919 } else { 1920 return false; 1921 } 1922 }; 1923 /** 1924 * Callback 1925 */ 1926 1927 1928 FileDrop.prototype._addOverClass = function _addOverClass(item) { 1929 item.addOverClass(); 1930 }; 1931 /** 1932 * Callback 1933 */ 1934 1935 1936 FileDrop.prototype._removeOverClass = function _removeOverClass(item) { 1937 item.removeOverClass(); 1938 }; 1939 1940 return FileDrop; 1941 }(FileDirective); 1942 } 1943 1944 __identity.$inject = ['FileDirective']; 1945 1946/***/ }), 1947/* 10 */ 1948/***/ (function(module, exports, __webpack_require__) { 1949 1950 'use strict'; 1951 1952 Object.defineProperty(exports, "__esModule", { 1953 value: true 1954 }); 1955 exports.default = __identity; 1956 1957 var _config = __webpack_require__(1); 1958 1959 var _config2 = _interopRequireDefault(_config); 1960 1961 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1962 1963 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1964 1965 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 1966 1967 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 1968 1969 var _angular = angular, 1970 extend = _angular.extend; 1971 function __identity(FileDirective) { 1972 1973 return function (_FileDirective) { 1974 _inherits(FileOver, _FileDirective); 1975 1976 /** 1977 * Creates instance of {FileDrop} object 1978 * @param {Object} options 1979 * @constructor 1980 */ 1981 function FileOver(options) { 1982 _classCallCheck(this, FileOver); 1983 1984 var extendedOptions = extend(options, { 1985 // Map of events 1986 events: { 1987 $destroy: 'destroy' 1988 }, 1989 // Name of property inside uploader._directive object 1990 prop: 'over', 1991 // Over class 1992 overClass: 'nv-file-over' 1993 }); 1994 1995 return _possibleConstructorReturn(this, _FileDirective.call(this, extendedOptions)); 1996 } 1997 /** 1998 * Adds over class 1999 */ 2000 2001 2002 FileOver.prototype.addOverClass = function addOverClass() { 2003 this.element.addClass(this.getOverClass()); 2004 }; 2005 /** 2006 * Removes over class 2007 */ 2008 2009 2010 FileOver.prototype.removeOverClass = function removeOverClass() { 2011 this.element.removeClass(this.getOverClass()); 2012 }; 2013 /** 2014 * Returns over class 2015 * @returns {String} 2016 */ 2017 2018 2019 FileOver.prototype.getOverClass = function getOverClass() { 2020 return this.overClass; 2021 }; 2022 2023 return FileOver; 2024 }(FileDirective); 2025 } 2026 2027 __identity.$inject = ['FileDirective']; 2028 2029/***/ }), 2030/* 11 */ 2031/***/ (function(module, exports, __webpack_require__) { 2032 2033 'use strict'; 2034 2035 Object.defineProperty(exports, "__esModule", { 2036 value: true 2037 }); 2038 exports.default = __identity; 2039 2040 var _config = __webpack_require__(1); 2041 2042 var _config2 = _interopRequireDefault(_config); 2043 2044 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2045 2046 function __identity($parse, FileUploader, FileSelect) { 2047 2048 return { 2049 link: function link(scope, element, attributes) { 2050 var uploader = scope.$eval(attributes.uploader); 2051 2052 if (!(uploader instanceof FileUploader)) { 2053 throw new TypeError('"Uploader" must be an instance of FileUploader'); 2054 } 2055 2056 var object = new FileSelect({ 2057 uploader: uploader, 2058 element: element, 2059 scope: scope 2060 }); 2061 2062 object.getOptions = $parse(attributes.options).bind(object, scope); 2063 object.getFilters = function () { 2064 return attributes.filters; 2065 }; 2066 } 2067 }; 2068 } 2069 2070 __identity.$inject = ['$parse', 'FileUploader', 'FileSelect']; 2071 2072/***/ }), 2073/* 12 */ 2074/***/ (function(module, exports, __webpack_require__) { 2075 2076 'use strict'; 2077 2078 Object.defineProperty(exports, "__esModule", { 2079 value: true 2080 }); 2081 exports.default = __identity; 2082 2083 var _config = __webpack_require__(1); 2084 2085 var _config2 = _interopRequireDefault(_config); 2086 2087 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2088 2089 function __identity($parse, FileUploader, FileDrop) { 2090 2091 return { 2092 link: function link(scope, element, attributes) { 2093 var uploader = scope.$eval(attributes.uploader); 2094 2095 if (!(uploader instanceof FileUploader)) { 2096 throw new TypeError('"Uploader" must be an instance of FileUploader'); 2097 } 2098 2099 if (!uploader.isHTML5) return; 2100 2101 var object = new FileDrop({ 2102 uploader: uploader, 2103 element: element 2104 }); 2105 2106 object.getOptions = $parse(attributes.options).bind(object, scope); 2107 object.getFilters = function () { 2108 return attributes.filters; 2109 }; 2110 } 2111 }; 2112 } 2113 2114 __identity.$inject = ['$parse', 'FileUploader', 'FileDrop']; 2115 2116/***/ }), 2117/* 13 */ 2118/***/ (function(module, exports, __webpack_require__) { 2119 2120 'use strict'; 2121 2122 Object.defineProperty(exports, "__esModule", { 2123 value: true 2124 }); 2125 exports.default = __identity; 2126 2127 var _config = __webpack_require__(1); 2128 2129 var _config2 = _interopRequireDefault(_config); 2130 2131 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2132 2133 function __identity(FileUploader, FileOver) { 2134 2135 return { 2136 link: function link(scope, element, attributes) { 2137 var uploader = scope.$eval(attributes.uploader); 2138 2139 if (!(uploader instanceof FileUploader)) { 2140 throw new TypeError('"Uploader" must be an instance of FileUploader'); 2141 } 2142 2143 var object = new FileOver({ 2144 uploader: uploader, 2145 element: element 2146 }); 2147 2148 object.getOverClass = function () { 2149 return attributes.overClass || object.overClass; 2150 }; 2151 } 2152 }; 2153 } 2154 2155 __identity.$inject = ['FileUploader', 'FileOver']; 2156 2157/***/ }) 2158/******/ ]) 2159}); 2160; 2161//# sourceMappingURL=angular-file-upload.js.map
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.