UNPKG

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