3333/******/ // expose the module cache
3434/******/ __webpack_require__ . c = installedModules ;
3535/******/
36- /******/ // identity function for calling harmony imports with the correct context
37- /******/ __webpack_require__ . i = function ( value ) { return value ; } ;
38- /******/
3936/******/ // define getter function for harmony exports
4037/******/ __webpack_require__ . d = function ( exports , name , getter ) {
4138/******/ if ( ! __webpack_require__ . o ( exports , name ) ) {
4744/******/ }
4845/******/ } ;
4946/******/
47+ /******/ // define __esModule on exports
48+ /******/ __webpack_require__ . r = function ( exports ) {
49+ /******/ Object . defineProperty ( exports , '__esModule' , { value : true } ) ;
50+ /******/ } ;
51+ /******/
5052/******/ // getDefaultExport function for compatibility with non-harmony modules
5153/******/ __webpack_require__ . n = function ( module ) {
5254/******/ var getter = module && module . __esModule ?
6264/******/ // __webpack_public_path__
6365/******/ __webpack_require__ . p = "" ;
6466/******/
67+ /******/
6568/******/ // Load entry module and return exports
66- /******/ return __webpack_require__ ( __webpack_require__ . s = 0 ) ;
69+ /******/ return __webpack_require__ ( __webpack_require__ . s = "./src/input-file.component.js" ) ;
6770/******/ } )
6871/************************************************************************/
69- /******/ ( [
70- /* 0 */
72+ /******/ ( {
73+
74+ /***/ "./src/input-file.component.js" :
75+ /*!*************************************!*\
76+ !*** ./src/input-file.component.js ***!
77+ \*************************************/
78+ /*! no static exports found */
7179/***/ ( function ( module , exports , __webpack_require__ ) {
7280
7381"use strict" ;
74-
75-
76- var _createClass = function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ( ) ;
77-
78- 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 ) ; } }
79-
80- function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
81-
82- var InputFileComponent = function ( ) {
83- /** @ngInject */
84- InputFileComponent . $inject = [ "$timeout" , "$element" , "$attrs" ] ;
85- function InputFileComponent ( $timeout , $element , $attrs ) {
86- _classCallCheck ( this , InputFileComponent ) ;
87-
88- this . $timeout = $timeout ;
89- this . $element = $element ;
90- this . $attrs = $attrs ;
91- }
92-
93- _createClass ( InputFileComponent , [ {
94- key : '$onInit' ,
95- value : function $onInit ( ) {
96- var _this = this ;
97-
98- var inputElement = this . $element [ 0 ] . getElementsByTagName ( 'input' ) [ 0 ] ;
99-
100- // If there is a multiple attribute different than "false"
101- if ( this . $attrs . multiple !== 'false' && ( this . $attrs . multiple === '' || this . $attrs . multiple ) ) {
102- inputElement . setAttribute ( 'multiple' , '' ) ;
103- }
104- inputElement . addEventListener ( 'change' , function ( event ) {
105- return _this . onInputChange ( event ) ;
106- } , false ) ;
107- }
108- } , {
109- key : 'onInputChange' ,
110- value : function onInputChange ( event ) {
111- var _this2 = this ;
112-
113- var inputFiles = event . target . files ;
114- var files = [ ] ;
115- var fileLoaded = [ ] . concat ( _toConsumableArray ( inputFiles ) ) . map ( function ( inputFile ) {
116- return new Promise ( function ( resolve , reject ) {
117- if ( ! _this2 . fileFormat ) {
118- resolve ( inputFile ) ;
119- return ;
120- }
121- var reader = new FileReader ( ) ;
122-
123- // See event handlers of `FileReader` here:
124- // https://developer.mozilla.org/en-US/docs/Web/API/FileReader#Properties
125-
126- // Catch errors to reject
127- reader . onabort = reject ;
128- reader . onerror = reject ;
129-
130- console . log ( inputFile ) ;
131-
132- // Encapsulatized function for contextualized file + $timeout for proper angularJs refresh
133- reader . onload = function ( infos ) {
134- return function ( readerEvent ) {
135- return _this2 . $timeout ( function ( ) {
136- var fileLoaded = {
137- infos : infos ,
138- file : readerEvent . target . result
139- } ;
140- files . push ( fileLoaded ) ;
141- resolve ( fileLoaded ) ;
142- } ) ;
143- } ;
144- } ( {
145- name : inputFile . name ,
146- size : inputFile . size ,
147- type : inputFile . type ,
148- lastModified : inputFile . lastModified
149- } ) ;
150-
151- switch ( _this2 . fileFormat ) {
152- case 'Text' :
153- reader . readAsText ( inputFile ) ;
154- break ;
155- case 'Base64' :
156- reader . readAsDataURL ( inputFile ) ;
157- break ;
158- case 'ArrayBuffer' :
159- default :
160- reader . readAsArrayBuffer ( inputFile ) ;
161- }
162- } ) ;
163- } ) ;
164-
165- return Promise . all ( fileLoaded ) . then ( function ( response ) {
166- if ( _this2 . filesLoaded ) {
167- _this2 . filesLoaded ( response ) ;
168- }
169- } ) ;
170- }
171- } ] ) ;
172-
173- return InputFileComponent ;
174- } ( ) ;
175-
176- angular . module ( 'angularjs-input-file' , [ ] ) . component ( 'inputFile' , {
177- template : '<input type="file" accept="{{ $ctrl.accept }}" />' ,
178- controller : InputFileComponent ,
179- bindings : {
180- accept : '@' ,
181- fileFormat : '@' ,
182- fileType : '@' ,
183- filesLoaded : '<'
184- }
185- } ) ;
82+ eval ( "\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar InputFileComponent =\n/*#__PURE__*/\nfunction () {\n InputFileComponent.$inject = [\"$timeout\", \"$element\", \"$attrs\"];\n\n /** @ngInject */\n function InputFileComponent($timeout, $element, $attrs) {\n _classCallCheck(this, InputFileComponent);\n\n this.$timeout = $timeout;\n this.$element = $element;\n this.$attrs = $attrs;\n }\n\n _createClass(InputFileComponent, [{\n key: \"$onInit\",\n value: function $onInit() {\n var _this = this;\n\n this.openSelectorRegister({\n handler: function handler() {\n return _this.openSelector();\n }\n });\n }\n }, {\n key: \"$postLink\",\n value: function $postLink() {\n var _this2 = this;\n\n var inputElement = this.$element[0].getElementsByTagName('input')[0]; // If there is a multiple attribute different than \"false\"\n\n if (this.$attrs.multiple !== 'false' && (this.$attrs.multiple === '' || this.$attrs.multiple)) {\n inputElement.setAttribute('multiple', '');\n }\n\n inputElement.addEventListener('change', function (event) {\n return _this2.onInputChange(event);\n }, false);\n }\n }, {\n key: \"openSelector\",\n value: function openSelector() {\n this.$element.find('input')[0].click();\n }\n }, {\n key: \"onInputChange\",\n value: function onInputChange(event) {\n var _this3 = this;\n\n var inputFiles = event.target.files;\n var files = [];\n\n var fileLoaded = _toConsumableArray(inputFiles).map(function (inputFile) {\n return new Promise(function (resolve, reject) {\n if (!_this3.fileFormat) {\n resolve(inputFile);\n return;\n }\n\n var reader = new FileReader(); // See event handlers of `FileReader` here:\n // https://developer.mozilla.org/en-US/docs/Web/API/FileReader#Properties\n // Catch errors to reject\n\n reader.onabort = reject;\n reader.onerror = reject; // Encapsulatized function for contextualized file + $timeout for proper angularJs refresh\n\n reader.onload = function (infos) {\n return function (readerEvent) {\n return _this3.$timeout(function () {\n var fileLoaded = {\n infos: infos,\n file: readerEvent.target.result\n };\n files.push(fileLoaded);\n resolve(fileLoaded);\n });\n };\n }({\n name: inputFile.name,\n size: inputFile.size,\n type: inputFile.type,\n lastModified: inputFile.lastModified\n });\n\n switch (_this3.fileFormat) {\n case 'Text':\n reader.readAsText(inputFile);\n break;\n\n case 'Base64':\n reader.readAsDataURL(inputFile);\n break;\n\n case 'ArrayBuffer':\n default:\n reader.readAsArrayBuffer(inputFile);\n }\n });\n });\n\n return Promise.all(fileLoaded).then(function (response) {\n if (_this3.filesLoaded) {\n _this3.filesLoaded(response);\n }\n });\n }\n }]);\n\n return InputFileComponent;\n}();\n\nangular.module('angularjs-input-file', []).component('inputFile', {\n template: \"\\n <input type=\\\"file\\\" \\n id=\\\"{{ $ctrl.id }}\\\"\\n accept=\\\"{{ $ctrl.accept }}\\\" />\",\n controller: InputFileComponent,\n bindings: {\n inputId: '@',\n accept: '@',\n fileFormat: '@',\n fileType: '@',\n filesLoaded: '<',\n openSelectorRegister: '&'\n }\n});\n\n//# sourceURL=webpack:///./src/input-file.component.js?" ) ;
18683
18784/***/ } )
188- /******/ ] ) ;
189- //# sourceMappingURL=angularjs-input-file.map
85+
86+ /******/ } ) ;
0 commit comments