UNPKG

ngx-upload-steroids

Version:
56 lines (55 loc) 2.46 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { Directive, ElementRef, EventEmitter, Input, Output } from '@angular/core'; import { NgUploaderService } from '../classes/ngx-uploader.class'; var NgFileSelectDirective = (function () { function NgFileSelectDirective(elementRef) { var _this = this; this.elementRef = elementRef; this.fileListener = function () { _this.upload.handleFiles(_this.el.files); }; this.upload = new NgUploaderService(); this.uploadOutput = new EventEmitter(); } NgFileSelectDirective.prototype.ngOnInit = function () { var _this = this; this.el = this.elementRef.nativeElement; this.el.addEventListener('change', this.fileListener, false); this.upload.serviceEvents.subscribe(function (event) { _this.uploadOutput.emit(event); }); if (this.uploadInput instanceof EventEmitter) { this.upload.initInputEvents(this.uploadInput); } }; NgFileSelectDirective.prototype.ngOnDestroy = function () { this.el.removeEventListener('change', this.fileListener, false); if (this.uploadInput) { this.uploadInput.unsubscribe(); } }; return NgFileSelectDirective; }()); __decorate([ Input(), __metadata("design:type", EventEmitter) ], NgFileSelectDirective.prototype, "uploadInput", void 0); __decorate([ Output(), __metadata("design:type", EventEmitter) ], NgFileSelectDirective.prototype, "uploadOutput", void 0); NgFileSelectDirective = __decorate([ Directive({ selector: '[ngFileSelect]' }), __metadata("design:paramtypes", [ElementRef]) ], NgFileSelectDirective); export { NgFileSelectDirective };