Skip to content

Commit

Permalink
[TASK] Adjust typings and ES flaws
Browse files Browse the repository at this point in the history
  • Loading branch information
ohader committed Jul 25, 2016
1 parent c352e7d commit 7bd71ed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/directives/ng-file-drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class NgFileDrop {
}

initEvents(): void {
this.el.nativeElement.addEventListener('drop', (e) => {
this.el.nativeElement.addEventListener('drop', (e: DragEvent) => {
e.stopPropagation();
e.preventDefault();

Expand All @@ -38,12 +38,12 @@ export class NgFileDrop {
}
}, false);

this.el.nativeElement.addEventListener('dragenter', (e) => {
this.el.nativeElement.addEventListener('dragenter', (e: DragEvent) => {
e.stopPropagation();
e.preventDefault();
}, false);

this.el.nativeElement.addEventListener('dragover', (e) => {
this.el.nativeElement.addEventListener('dragover', (e: DragEvent) => {
e.stopPropagation();
e.preventDefault();
}, false);
Expand Down
21 changes: 12 additions & 9 deletions src/services/ng2-uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class Ng2Uploader {

let queueIndex = this._queue.indexOf(file);

xhr.upload.onprogress = (e) => {
xhr.upload.onprogress = (e: ProgressEvent) => {
if (e.lengthComputable) {
let percent = Math.round(e.loaded / e.total * 100);
uploadingFile.setProgres({
Expand All @@ -129,17 +129,17 @@ export class Ng2Uploader {

this._emitter.emit(uploadingFile);
}
}
};

xhr.upload.onabort = (e) => {
xhr.upload.onabort = (e: Event) => {
uploadingFile.setAbort();
this._emitter.emit(uploadingFile);
}
};

xhr.upload.onerror = (e) => {
xhr.upload.onerror = (e: Event) => {
uploadingFile.setError();
this._emitter.emit(uploadingFile);
}
};

xhr.onreadystatechange = () => {
if (xhr.readyState === XMLHttpRequest.DONE) {
Expand All @@ -151,7 +151,7 @@ export class Ng2Uploader {
this.removeFileFromQueue(queueIndex);
this._emitter.emit(uploadingFile);
}
}
};

xhr.open(this.method, this.url, true);
xhr.withCredentials = this.withCredentials;
Expand All @@ -169,8 +169,11 @@ export class Ng2Uploader {
xhr.send(form);
}

addFilesToQueue(files: FileList[]): void {
for (let file of files) {
addFilesToQueue(files: FileList): void {
let index: number, file: File;

for (index = 0; index < files.length; index++) {
file = files.item(index);
if (this.isFile(file) && !this.inQueue(file)) {
this._queue.push(file);
}
Expand Down

0 comments on commit 7bd71ed

Please sign in to comment.