Skip to content

Commit

Permalink
Merge pull request bleenco#50 from ohader/master
Browse files Browse the repository at this point in the history
[TASK] Resolve typing flaws
  • Loading branch information
jkuri authored Jul 26, 2016
2 parents 16b1325 + 7bd71ed commit d7e82cb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
"license": "MIT",
"main": "./ng2-uploader.ts",
"author": "Jan Kuri <[email protected]>",
"scripts": {
"postinstall": "typings install"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jkuri/ng2-uploader.git"
Expand All @@ -32,7 +29,6 @@
"zone.js": "^0.6.12"
},
"devDependencies": {
"typescript": "1.8.10",
"typings": "^1.3.1"
"typescript": "1.8.10"
}
}
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
1 change: 0 additions & 1 deletion src/services/ng2-uploader.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference path="../../typings/index.d.ts" />
import { EventEmitter } from '@angular/core';
export declare class Ng2Uploader {
url: string;
Expand Down
22 changes: 12 additions & 10 deletions src/services/ng2-uploader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference path="../../typings/index.d.ts"/>
import {Injectable, EventEmitter} from '@angular/core';

class UploadedFile {
Expand Down Expand Up @@ -119,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 @@ -130,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 @@ -152,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 @@ -170,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 d7e82cb

Please sign in to comment.