diff --git a/dist/angular-file-dnd.js b/dist/angular-file-dnd.js index a694707..738f35a 100644 --- a/dist/angular-file-dnd.js +++ b/dist/angular-file-dnd.js @@ -60,6 +60,7 @@ } }); return scope.$emit('file-dropzone-drop-event', { + unencodedFile: file, file: scope.file, type: type, name: name, diff --git a/dist/angular-file-dnd.min.js b/dist/angular-file-dnd.min.js index 8ff22bf..920d051 100644 --- a/dist/angular-file-dnd.min.js +++ b/dist/angular-file-dnd.min.js @@ -1 +1 @@ -!function(){"use strict";angular.module("omr.angularFileDnD",[]).directive("fileDropzone",function(){return{restrict:"A",scope:{file:"=",fileName:"="},link:function(a,b,c){var d,e,f,g,h;return e=function(a){var b;return b=a.dataTransfer||a.originalEvent.dataTransfer},g=function(a){return a&&(a.preventDefault&&a.preventDefault(),a.stopPropagation)?!1:(e(a).effectAllowed="copy",!1)},h=c.fileDropzone,d=function(a){var b;return void 0===(b=c.maxFileSize)||""===b||a/1024/1024-1?!0:(alert("Invalid file type. File must be one of following types "+h),!1)},b.bind("dragover",g),b.bind("dragenter",g),b.bind("drop",function(b){var c,g,h,i,j;return null!=b&&b.preventDefault(),h=new FileReader,h.onload=function(b){return d(i)&&f(j)?(a.$apply(function(){return a.file=b.target.result,angular.isString(a.fileName)?a.fileName=g:void 0}),a.$emit("file-dropzone-drop-event",{file:a.file,type:j,name:g,size:i})):void 0},c=e(b).files[0],g=c.name,j=c.type,i=c.size,h.readAsDataURL(c),!1})}}})}.call(this); \ No newline at end of file +(function(){"use strict";angular.module("omr.angularFileDnD",[]).directive("fileDropzone",function(){return{restrict:"A",scope:{file:"=",fileName:"="},link:function(a,b,c){var d,e,f,g,h;return e=function(a){var b;return b=a.dataTransfer||a.originalEvent.dataTransfer},g=function(a){return a&&(a.preventDefault&&a.preventDefault(),a.stopPropagation)?!1:(e(a).effectAllowed="copy",!1)},h=c.fileDropzone,d=function(a){var b;return void 0===(b=c.maxFileSize)||""===b||a/1024/1024-1?!0:(alert("Invalid file type. File must be one of following types "+h),!1)},b.bind("dragover",g),b.bind("dragenter",g),b.bind("drop",function(b){var c,g,h,i,j;return null!=b&&b.preventDefault(),h=new FileReader,h.onload=function(b){return d(i)&&f(j)?(a.$apply(function(){return a.file=b.target.result,angular.isString(a.fileName)?a.fileName=g:void 0}),a.$emit("file-dropzone-drop-event",{unencodedFile:c,file:a.file,type:j,name:g,size:i})):void 0},c=e(b).files[0],g=c.name,j=c.type,i=c.size,h.readAsDataURL(c),!1})}}})}).call(this); \ No newline at end of file diff --git a/src/directive/file_dropzone.coffee b/src/directive/file_dropzone.coffee index 5ab1a9e..a1611d0 100644 --- a/src/directive/file_dropzone.coffee +++ b/src/directive/file_dropzone.coffee @@ -55,7 +55,7 @@ angular.module('omr.angularFileDnD', []) scope.$apply -> scope.file = evt.target.result scope.fileName = name if angular.isString scope.fileName - scope.$emit 'file-dropzone-drop-event', {file: scope.file, type: type, name: name, size: size} + scope.$emit 'file-dropzone-drop-event', {unencodedFile: file, file: scope.file, type: type, name: name, size: size} file = getDataTransfer(event).files[0] name = file.name @@ -63,4 +63,4 @@ angular.module('omr.angularFileDnD', []) size = file.size reader.readAsDataURL file false - ) \ No newline at end of file + )