'+
'
Seperator
'+
@@ -84,9 +84,9 @@ csvImport.directive('ngCsvImport', function() {
scope.result = csvToJSON(content);
scope.$apply();
if ( typeof scope.callback === 'function' ) {
- if ( scope.callback != null) {
- scope.callback(e);
- }
+ if ( scope.callback != null) {
+ scope.callback(e);
+ }
}
}
});
@@ -117,9 +117,9 @@ csvImport.directive('ngCsvImport', function() {
scope.result.filename = scope.filename;
scope.$$postDigest(function(){
if ( typeof scope.callback === 'function' ) {
- if ( scope.callback != null) {
- scope.callback(onChangeEvent);
- }
+ if ( scope.callback != null) {
+ scope.callback(onChangeEvent);
+ }
}
});
});
@@ -137,14 +137,13 @@ csvImport.directive('ngCsvImport', function() {
scope.result = csvToJSON(content);
scope.$$postDigest(function(){
if ( typeof scope.callback === 'function' ) {
- if ( scope.callback != null) {
- scope.callback(onChangeEvent);
- }
+ if ( scope.callback != null) {
+ scope.callback(onChangeEvent);
+ }
}
});
}
}
-
if(!scope.lockImportSameFile){
angular.element(document).find('.ng-csv-import.ng-isolate-scope input[type="file"]')[0].value = null;
}
diff --git a/dist/angular-csv-import.min.js b/dist/angular-csv-import.min.js
index fceda0a..7982c1b 100644
--- a/dist/angular-csv-import.min.js
+++ b/dist/angular-csv-import.min.js
@@ -1,3 +1,3 @@
-/*! angular-csv-import - v0.0.37 - 2017-05-19
-* Copyright (c) 2017 ; Licensed */
-"use strict";var csvImport=angular.module("ngCsvImport",[]);csvImport.directive("ngCsvImport",function(){return{restrict:"E",transclude:!0,replace:!0,scope:{content:"=?",header:"=?",headerVisible:"=?",separator:"=?",separatorVisible:"=?",result:"=?",encoding:"=?",encodingVisible:"=?",accept:"=?",acceptSize:"=?",acceptSizeExceedCallback:"=?",callback:"=?",mdButtonClass:"@?",mdInputClass:"@?",mdButtonTitle:"@?",mdSvgIcon:"@?",uploadButtonLabel:"="},template:function(a,b){var c=angular.isDefined(b.material),d=angular.isDefined(b.multiple);return'
"},link:function(a,b,c){if(a.separatorVisible=!!a.separatorVisible,a.headerVisible=!!a.headerVisible,a.acceptSize=a.acceptSize||Number.POSITIVE_INFINITY,a.material=angular.isDefined(c.material),a.multiple=angular.isDefined(c.multiple),a.multiple)throw new Error("Multiple attribute is not supported yet.");var d=angular.element(b[0].querySelector('input[type="file"]')),e=angular.element(b[0].querySelector("md-input-container"));if(a.material&&d){if(d.removeClass("ng-show"),d.addClass("ng-hide"),e){var f=angular.element(e[0].querySelector("div.md-errors-spacer"));f&&f.remove()}a.onClick=function(){d.click()}}angular.element(b[0].querySelector(".separator-input")).on("keyup",function(b){if(null!=a.content){var c={csv:a.content,header:a.header,separator:b.target.value,encoding:a.encoding};a.result=g(c),a.$apply(),"function"==typeof a.callback&&null!=a.callback&&a.callback(b)}}),b.on("change",function(b){if(b.target.files.length){if(b.target.files[0].size>a.acceptSize)return void("function"==typeof a.acceptSizeExceedCallback&&a.acceptSizeExceedCallback(b.target.files[0]));a.filename=b.target.files[0].name;var c=new FileReader;if(c.onload=function(c){a.$apply(function(){var d={csv:c.target.result.replace(/\r\n|\r/g,"\n"),header:a.header,separator:a.separator};a.content=d.csv,a.result=g(d),a.result.filename=a.filename,a.$$postDigest(function(){"function"==typeof a.callback&&null!=a.callback&&a.callback(b)})})},"file"!==b.target.type||null==b.target.files&&null==b.srcElement.files){if(null!=a.content){var d={csv:a.content,header:!a.header,separator:a.separator};a.result=g(d),a.$$postDigest(function(){"function"==typeof a.callback&&null!=a.callback&&a.callback(b)})}}else c.readAsText((b.srcElement||b.target).files[0],a.encoding)}});var g=function(a){var b=a.csv.split(new RegExp('\n(?![^"]*"(?:(?:[^"]*"){2})*[^"]*$)')),c=[],d=0,e=b[0].split(a.separator).length,f=[];a.header&&(f=b[0].split(a.separator),d=1);for(var g=d;g
'+(c?' {{mdButtonTitle}}':"")+"
"},link:function(a,b,c){if(a.separatorVisible=!!a.separatorVisible,a.headerVisible=!!a.headerVisible,a.acceptSize=a.acceptSize||Number.POSITIVE_INFINITY,a.material=angular.isDefined(c.material),a.multiple=angular.isDefined(c.multiple),a.multiple)throw new Error("Multiple attribute is not supported yet.");var d=angular.element(b[0].querySelector('input[type="file"]')),e=angular.element(b[0].querySelector("md-input-container"));if(a.material&&d){if(d.removeClass("ng-show"),d.addClass("ng-hide"),e){var f=angular.element(e[0].querySelector("div.md-errors-spacer"));f&&f.remove()}a.onClick=function(){d.click()}}angular.element(b[0].querySelector(".separator-input")).on("keyup",function(b){if(null!=a.content){var c={csv:a.content,header:a.header,separator:b.target.value,encoding:a.encoding};a.result=g(c),a.$apply(),"function"==typeof a.callback&&null!=a.callback&&a.callback(b)}}),b.on("change",function(b){if(b.target.files.length){if(b.target.files[0].size>a.acceptSize)return void("function"==typeof a.acceptSizeExceedCallback&&a.acceptSizeExceedCallback(b.target.files[0]));a.filename=b.target.files[0].name;var c=new FileReader;if(c.onload=function(c){a.$apply(function(){var d={csv:c.target.result.replace(/\r\n|\r/g,"\n"),header:a.header,separator:a.separator};a.content=d.csv,a.result=g(d),a.result.filename=a.filename,a.$$postDigest(function(){"function"==typeof a.callback&&null!=a.callback&&a.callback(b)})})},"file"!==b.target.type||null==b.target.files&&null==b.srcElement.files){if(null!=a.content){var d={csv:a.content,header:!a.header,separator:a.separator};a.result=g(d),a.$$postDigest(function(){"function"==typeof a.callback&&null!=a.callback&&a.callback(b)})}}else c.readAsText((b.srcElement||b.target).files[0],a.encoding);a.lockImportSameFile||(angular.element(document).find('.ng-csv-import.ng-isolate-scope input[type="file"]')[0].value=null)}});var g=function(a){var b=a.csv.split(new RegExp('\n(?![^"]*"(?:(?:[^"]*"){2})*[^"]*$)')),c=[],d=0,e=b[0].split(a.separator).length,f=[];a.header&&(f=b[0].split(a.separator),d=1);for(var g=d;g