Skip to content

Commit

Permalink
BUGFIX: Pass the filemanager event through via $event in angular
Browse files Browse the repository at this point in the history
  • Loading branch information
curiosity26 committed Aug 10, 2017
1 parent 8224a14 commit 3dc39cb
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 18 deletions.
60 changes: 43 additions & 17 deletions ng-batchupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,33 @@ angular.module('batchUpload', [])
},
bindToController: true,
controller: ['$element', 'batchUploadManager', function($element, batchUploadManager) {
var settings = {};
var settings = {},
ctrl = this,
onComplete = function(e) {
ctrl.buOnComplete({$event: e});
},
onError = function(e) {
ctrl.buOnError({$event: e});
},
onFileStart = function(e) {
ctrl.buOnFileStart({$event: e});
},
onStart = function(e) {
ctrl.buOnStart({$event: e});
},
onPause = function(e) {
ctrl.buOnPause({$event: e});
},
onProgress = function(e) {
ctrl.buOnProgress({$event: e});
},
onInvalid = function(e) {
ctrl.buOnInvalid({$event: e});
},
onQueue = function(e) {
ctrl.buOnQueue({$event: e});
}
;

this.$onInit = function() {

Expand Down Expand Up @@ -111,69 +137,69 @@ angular.module('batchUpload', [])
this.dropzone = new FileDropZone($element[0], settings);

if (!!this.buOnComplete) {
settings.manager.on('complete', this.buOnComplete);
settings.manager.on('complete', onComplete);
}

if (!!this.buOnError) {
settings.manager.on('error', this.buOnError);
settings.manager.on('error', onError);
}

if (!!this.buOnFileStart) {
settings.manager.on('file_start', this.buOnFileStart);
settings.manager.on('file_start', onFileStart);
}

if (!!this.buOnStart) {
settings.manager.on('start', this.buOnStart);
settings.manager.on('start', onStart);
}

if (!!this.buOnPause) {
settings.manager.on('pause', this.buOnPause);
settings.manager.on('pause', onPause);
}

if (!!this.buOnProgress) {
settings.manager.on('progress', this.buOnProgress);
settings.manager.on('progress', onProgress);
}

if (!!this.buOnInvalid) {
settings.manager.on('invalud', this.buOnInvalid);
settings.manager.on('invalud', onInvalid);
}

if (!!this.buOnQueue) {
settings.manager.on('queue', this.buOnQueue);
settings.manager.on('queue', onQueue);
}
};

this.$onDestroy = function() {
if (!!this.buOnComplete) {
settings.manager.off('complete', this.buOnComplete);
settings.manager.off('complete', onComplete);
}

if (!!this.buOnError) {
settings.manager.off('error', this.buOnError);
settings.manager.off('error', onError);
}

if (!!this.buOnFileStart) {
settings.manager.off('file_start', this.buOnFileStart);
settings.manager.off('file_start', onFileStart);
}

if (!!this.buOnStart) {
settings.manager.off('start', this.buOnStart);
settings.manager.off('start', onStart);
}

if (!!this.buOnPause) {
settings.manager.off('pause', this.buOnPause);
settings.manager.off('pause', onPause);
}

if (!!this.buOnProgress) {
settings.manager.off('progress', this.buOnProgress);
settings.manager.off('progress', onProgress);
}

if (!!this.buOnInvalid) {
settings.manager.off('invalud', this.buOnInvalid);
settings.manager.off('invalud', onInvalid);
}

if (!!this.buOnQueue) {
settings.manager.off('queue', this.buOnQueue);
settings.manager.off('queue', onQueue);
}
};
}],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-batchupload",
"version": "1.1.2",
"version": "1.1.3",
"description": "A wrapper module to angular for the batchupload library",
"main": "ng-batchupload.js",
"scripts": {
Expand Down

0 comments on commit 3dc39cb

Please sign in to comment.