From 5b8d6fff3b7dddc600f5f8d8f890d06a151fc0c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikko=20Ka=CC=88rkka=CC=88inen?= Date: Mon, 22 Feb 2016 09:53:32 +0200 Subject: [PATCH 1/5] first version of new hooks --- dist/ng-paste-from-latest.js | 28 ++++++++++++++++++---------- dist/ng-paste-from-latest.js.map | 2 +- dist/ng-paste-from-latest.min.js | 2 +- dist/ng-paste-from-latest.min.js.map | 2 +- src/ng-paste-from.coffee | 8 ++++++++ 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/dist/ng-paste-from-latest.js b/dist/ng-paste-from-latest.js index a38ae4d..e7e25b2 100644 --- a/dist/ng-paste-from-latest.js +++ b/dist/ng-paste-from-latest.js @@ -15,7 +15,9 @@ ngPasteFromColumnSeparator: "=", ngPasteFromPasteOnly: "=", ngPasteFromBeforeParse: "=", + ngPasteFromAfterParseRow: "=", ngPasteFromOnValidate: "=", + ngPasteFromOnSuccessBeforeApply: "=", ngPasteFromOnError: "=" }, link: function($scope, element, attrs) { @@ -23,7 +25,7 @@ console.error("Missing required attribute ngPasteFromColumns."); } $scope.pasteEvent = function(event) { - var data, _ref; + var data, ref; if ((event.clipboardData != null) && (event.clipboardData.getData != null)) { data = event.clipboardData.getData("text/plain"); } else if ((event.originalEvent != null) && (event.originalEvent.clipboardData != null) && (event.originalEvent.clipboardData.getData != null)) { @@ -35,13 +37,13 @@ data = $scope.ngPasteFromBeforeParse(data); } $scope.processPasteData(data); - if ((_ref = $scope.ngPasteFromPasteOnly) != null ? _ref : true) { + if ((ref = $scope.ngPasteFromPasteOnly) != null ? ref : true) { return event.preventDefault(); } }; $scope.changeEvent = function() { - var data, _ref; - if ((_ref = $scope.ngPasteFromPasteOnly) != null ? _ref : true) { + var data, ref; + if ((ref = $scope.ngPasteFromPasteOnly) != null ? ref : true) { return element.val(""); } else { data = element.val(); @@ -57,10 +59,10 @@ }, controller: function($scope, $filter, ngPasteFromErrors, ngPasteFromSeparators) { $scope.columnsToObject = function(columns) { - var column, format, index, obj, _i, _len; + var column, format, i, index, len, obj; obj = {}; format = $scope.ngPasteFromColumns; - for (index = _i = 0, _len = columns.length; _i < _len; index = ++_i) { + for (index = i = 0, len = columns.length; i < len; index = ++i) { column = columns[index]; obj[format[index]] = column; } @@ -74,19 +76,19 @@ } }; return $scope.processPasteData = function(data) { - var columns, expectedColumnsLength, index, result, row, rowData, rowResult, rows, _i, _len, _ref, _ref1; + var columns, expectedColumnsLength, i, index, len, ref, ref1, result, row, rowData, rowResult, rows; if (!(data && data.length)) { return; } - rows = data.split((_ref = $scope.ngPasteFromRowSeparator) != null ? _ref : ngPasteFromSeparators.row); + rows = data.split((ref = $scope.ngPasteFromRowSeparator) != null ? ref : ngPasteFromSeparators.row); result = []; expectedColumnsLength = $scope.getExpectedColumnsLength(); - for (index = _i = 0, _len = rows.length; _i < _len; index = ++_i) { + for (index = i = 0, len = rows.length; i < len; index = ++i) { row = rows[index]; if (row === "") { continue; } - columns = row.split((_ref1 = $scope.ngPasteFromColumnSeparator) != null ? _ref1 : ngPasteFromSeparators.column); + columns = row.split((ref1 = $scope.ngPasteFromColumnSeparator) != null ? ref1 : ngPasteFromSeparators.column); rowData = { index: index, source: row, @@ -105,11 +107,17 @@ rowResult = $scope.columnsToObject(columns); } if (typeof $scope.ngPasteFromOnValidate !== "function" || $scope.ngPasteFromOnValidate(rowResult, rowData)) { + if (typeof $scope.ngPasteFromAfterParseRow === "function") { + rowResult = $scope.ngPasteFromAfterParseRow(rowResult); + } result.push(rowResult); } else if (typeof $scope.ngPasteFromOnError === "function") { $scope.ngPasteFromOnError(ngPasteFromErrors.failedValidation, rowData); } } + if (typeof $scope.ngPasteFromOnSuccessBeforeApply === "function") { + $scope.ngPasteFromOnSuccessBeforeApply(result); + } return $scope.$apply(function() { return $scope.ngPasteFrom = result; }); diff --git a/dist/ng-paste-from-latest.js.map b/dist/ng-paste-from-latest.js.map index 0eb2522..41c86b7 100755 --- a/dist/ng-paste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gBAAA,MAAM,CAAC,kBAAP,CAA0B,iBAAiB,CAAC,mBAA5C,EAAiE,OAAjE,CAAA,CADD;eAAA;AAEA,uBAHD;aAXA;AAgBA,YAAA,IAAG,MAAA,CAAA,MAAa,CAAC,kBAAd,KAAoC,QAAvC;AACC,cAAA,SAAA,GAAY,OAAZ,CADD;aAAA,MAAA;AAGC,cAAA,SAAA,GAAY,MAAM,CAAC,eAAP,CAAuB,OAAvB,CAAZ,CAHD;aAhBA;AAqBA,YAAA,IAAG,MAAA,CAAA,MAAa,CAAC,qBAAd,KAAyC,UAAzC,IAAuD,MAAM,CAAC,qBAAP,CAA6B,SAA7B,EAAwC,OAAxC,CAA1D;AACC,cAAA,MAAM,CAAC,IAAP,CAAY,SAAZ,CAAA,CADD;aAAA,MAEK,IAAG,MAAA,CAAA,MAAa,CAAC,kBAAd,KAAoC,UAAvC;AACJ,cAAA,MAAM,CAAC,kBAAP,CAA0B,iBAAiB,CAAC,gBAA5C,EAA8D,OAA9D,CAAA,CADI;aAxBN;AAAA,WAPA;iBAkCA,MAAM,CAAC,MAAP,CAAc,SAAA,GAAA;mBACb,MAAM,CAAC,WAAP,GAAqB,OADR;UAAA,CAAd,EAnCyB;QAAA,EAdf;MAAA,CA1CZ;MADyB;EAAA,CAT3B,CAAA,CAAA;AAAA","file":"ng-paste-from-latest.js","sourceRoot":"/source/","sourcesContent":["angular.module \"ngPasteFrom\", []\n\t.constant \"ngPasteFromErrors\",\n\t\tinvalidColumnLength: \"NGPASTEFROM_INVALID_COLUMN_LENGTH\"\n\t\tfailedValidation: \"NGPASTEFROM_FAILED_VALIDATION\"\n\n\t.constant \"ngPasteFromSeparators\",\n\t\trow: /\\r\\n|\\n\\r|\\n|\\r/g\n\t\tcolumn: \"\\t\"\n\n\t.directive \"ngPasteFrom\", ->\n\t\trestrict: \"A\"\n\t\tscope: \n\t\t\tngPasteFrom: \"=\"\n\t\t\tngPasteFromColumns: \"=\"\n\t\t\tngPasteFromRowSeparator: \"=\"\n\t\t\tngPasteFromColumnSeparator: \"=\"\n\t\t\tngPasteFromPasteOnly: \"=\"\n\t\t\tngPasteFromBeforeParse: \"=\"\n\t\t\tngPasteFromOnValidate: \"=\"\n\t\t\tngPasteFromOnError: \"=\"\n\n\t\tlink: ($scope, element, attrs) ->\n\t\t\tif not $scope.ngPasteFromColumns?\n\t\t\t\tconsole.error \"Missing required attribute ngPasteFromColumns.\"\n\n\t\t\t$scope.pasteEvent = (event) ->\n\t\t\t\tif event.clipboardData? && event.clipboardData.getData? # Standard\n\t\t\t\t\tdata = event.clipboardData.getData \"text/plain\"\n\t\t\t\telse if event.originalEvent? && event.originalEvent.clipboardData? && event.originalEvent.clipboardData.getData? # jQuery\n\t\t\t\t\tdata = event.originalEvent.clipboardData.getData \"text/plain\"\n\t\t\t\telse if window.clipboardData? && window.clipboardData.getData? # Internet Explorer\n\t\t\t\t\tdata = window.clipboardData.getData \"Text\"\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t$scope.processPasteData data\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\tevent.preventDefault()\n\n\t\t\t$scope.changeEvent = ->\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\telement.val \"\"\n\t\t\t\telse\n\t\t\t\t\tdata = element.val()\n\t\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t\t$scope.processPasteData data\n\n\t\t\telement.on \"paste\", $scope.pasteEvent\n\t\t\telement.on \"keyup\", $scope.changeEvent\n\t\t\telement.on \"change\", $scope.changeEvent\n\n\t\tcontroller: ($scope, $filter, ngPasteFromErrors, ngPasteFromSeparators) ->\n\t\t\t$scope.columnsToObject = (columns) ->\n\t\t\t\tobj = {}\n\t\t\t\tformat = $scope.ngPasteFromColumns\n\t\t\t\tfor column, index in columns\n\t\t\t\t\tobj[format[index]] = column\n\t\t\t\tobj\n\n\t\t\t$scope.getExpectedColumnsLength = ->\n\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t$scope.ngPasteFromColumns\n\t\t\t\telse\n\t\t\t\t\t$scope.ngPasteFromColumns.length\n\n\t\t\t$scope.processPasteData = (data) ->\n\t\t\t\tif not (data and data.length)\n\t\t\t\t\treturn\n\n\t\t\t\trows = data.split $scope.ngPasteFromRowSeparator ? ngPasteFromSeparators.row\n\t\t\t\tresult = []\n\t\t\t\texpectedColumnsLength = $scope.getExpectedColumnsLength()\n\n\t\t\t\tfor row, index in rows\n\t\t\t\t\tif row is \"\"\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tcolumns = row.split $scope.ngPasteFromColumnSeparator ? ngPasteFromSeparators.column\n\n\t\t\t\t\trowData =\n\t\t\t\t\t\tindex: index\n\t\t\t\t\t\tsource: row\n\t\t\t\t\t\texpectedLength: expectedColumnsLength\n\t\t\t\t\t\tactualLength: columns.length\n\n\t\t\t\t\tif columns.length isnt expectedColumnsLength\n\t\t\t\t\t\tif typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.invalidColumnLength, rowData\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t\trowResult = columns\n\t\t\t\t\telse\n\t\t\t\t\t\trowResult = $scope.columnsToObject columns\n\n\t\t\t\t\tif typeof $scope.ngPasteFromOnValidate isnt \"function\" or $scope.ngPasteFromOnValidate rowResult, rowData\n\t\t\t\t\t\tresult.push rowResult\n\t\t\t\t\telse if typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.failedValidation, rowData\n\n\t\t\t\t$scope.$apply ->\n\t\t\t\t\t$scope.ngPasteFrom = result\n"]} \ No newline at end of file +{"version":3,"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,MAAP,CAAc,SAAA;mBACb,MAAM,CAAC,WAAP,GAAqB;UADR,CAAd;QAzCyB;MAdf,CA5CZ;;EADyB,CAT3B;AAAA","file":"ng-paste-from-latest.js","sourceRoot":"/source/","sourcesContent":["angular.module \"ngPasteFrom\", []\n\t.constant \"ngPasteFromErrors\",\n\t\tinvalidColumnLength: \"NGPASTEFROM_INVALID_COLUMN_LENGTH\"\n\t\tfailedValidation: \"NGPASTEFROM_FAILED_VALIDATION\"\n\n\t.constant \"ngPasteFromSeparators\",\n\t\trow: /\\r\\n|\\n\\r|\\n|\\r/g\n\t\tcolumn: \"\\t\"\n\n\t.directive \"ngPasteFrom\", ->\n\t\trestrict: \"A\"\n\t\tscope: \n\t\t\tngPasteFrom: \"=\"\n\t\t\tngPasteFromColumns: \"=\"\n\t\t\tngPasteFromRowSeparator: \"=\"\n\t\t\tngPasteFromColumnSeparator: \"=\"\n\t\t\tngPasteFromPasteOnly: \"=\"\n\t\t\tngPasteFromBeforeParse: \"=\"\n\t\t\tngPasteFromAfterParseRow: \"=\"\n\t\t\tngPasteFromOnValidate: \"=\"\n\t\t\tngPasteFromOnSuccessBeforeApply: \"=\"\n\t\t\tngPasteFromOnError: \"=\"\n\n\t\tlink: ($scope, element, attrs) ->\n\t\t\tif not $scope.ngPasteFromColumns?\n\t\t\t\tconsole.error \"Missing required attribute ngPasteFromColumns.\"\n\n\t\t\t$scope.pasteEvent = (event) ->\n\t\t\t\tif event.clipboardData? && event.clipboardData.getData? # Standard\n\t\t\t\t\tdata = event.clipboardData.getData \"text/plain\"\n\t\t\t\telse if event.originalEvent? && event.originalEvent.clipboardData? && event.originalEvent.clipboardData.getData? # jQuery\n\t\t\t\t\tdata = event.originalEvent.clipboardData.getData \"text/plain\"\n\t\t\t\telse if window.clipboardData? && window.clipboardData.getData? # Internet Explorer\n\t\t\t\t\tdata = window.clipboardData.getData \"Text\"\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t$scope.processPasteData data\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\tevent.preventDefault()\n\n\t\t\t$scope.changeEvent = ->\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\telement.val \"\"\n\t\t\t\telse\n\t\t\t\t\tdata = element.val()\n\t\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t\t$scope.processPasteData data\n\n\t\t\telement.on \"paste\", $scope.pasteEvent\n\t\t\telement.on \"keyup\", $scope.changeEvent\n\t\t\telement.on \"change\", $scope.changeEvent\n\n\t\tcontroller: ($scope, $filter, ngPasteFromErrors, ngPasteFromSeparators) ->\n\t\t\t$scope.columnsToObject = (columns) ->\n\t\t\t\tobj = {}\n\t\t\t\tformat = $scope.ngPasteFromColumns\n\t\t\t\tfor column, index in columns\n\t\t\t\t\tobj[format[index]] = column\n\t\t\t\tobj\n\n\t\t\t$scope.getExpectedColumnsLength = ->\n\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t$scope.ngPasteFromColumns\n\t\t\t\telse\n\t\t\t\t\t$scope.ngPasteFromColumns.length\n\n\t\t\t$scope.processPasteData = (data) ->\n\t\t\t\tif not (data and data.length)\n\t\t\t\t\treturn\n\n\t\t\t\trows = data.split $scope.ngPasteFromRowSeparator ? ngPasteFromSeparators.row\n\t\t\t\tresult = []\n\t\t\t\texpectedColumnsLength = $scope.getExpectedColumnsLength()\n\n\t\t\t\tfor row, index in rows\n\t\t\t\t\tif row is \"\"\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tcolumns = row.split $scope.ngPasteFromColumnSeparator ? ngPasteFromSeparators.column\n\n\t\t\t\t\trowData =\n\t\t\t\t\t\tindex: index\n\t\t\t\t\t\tsource: row\n\t\t\t\t\t\texpectedLength: expectedColumnsLength\n\t\t\t\t\t\tactualLength: columns.length\n\n\t\t\t\t\tif columns.length isnt expectedColumnsLength\n\t\t\t\t\t\tif typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.invalidColumnLength, rowData\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t\trowResult = columns\n\t\t\t\t\telse\n\t\t\t\t\t\trowResult = $scope.columnsToObject columns\n\n\t\t\t\t\tif typeof $scope.ngPasteFromOnValidate isnt \"function\" or $scope.ngPasteFromOnValidate rowResult, rowData\n\t\t\t\t\t\tif typeof $scope.ngPasteFromAfterParseRow is \"function\"\n\t\t\t\t\t\t\trowResult = $scope.ngPasteFromAfterParseRow rowResult\n\n\t\t\t\t\t\tresult.push rowResult\n\t\t\t\t\telse if typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.failedValidation, rowData\n\n\t\t\t\tif typeof $scope.ngPasteFromOnSuccessBeforeApply is \"function\"\n\t\t\t\t\t$scope.ngPasteFromOnSuccessBeforeApply result\n\n\t\t\t\t$scope.$apply ->\n\t\t\t\t\t$scope.ngPasteFrom = result\n"]} \ No newline at end of file diff --git a/dist/ng-paste-from-latest.min.js b/dist/ng-paste-from-latest.min.js index 1b7037a..23e4a06 100644 --- a/dist/ng-paste-from-latest.min.js +++ b/dist/ng-paste-from-latest.min.js @@ -1,2 +1,2 @@ -(function(){angular.module("ngPasteFrom",[]).constant("ngPasteFromErrors",{invalidColumnLength:"NGPASTEFROM_INVALID_COLUMN_LENGTH",failedValidation:"NGPASTEFROM_FAILED_VALIDATION"}).constant("ngPasteFromSeparators",{row:/\r\n|\n\r|\n|\r/g,column:" "}).directive("ngPasteFrom",function(){return{restrict:"A",scope:{ngPasteFrom:"=",ngPasteFromColumns:"=",ngPasteFromRowSeparator:"=",ngPasteFromColumnSeparator:"=",ngPasteFromPasteOnly:"=",ngPasteFromBeforeParse:"=",ngPasteFromOnValidate:"=",ngPasteFromOnError:"="},link:function($scope,element){return null==$scope.ngPasteFromColumns&&console.error("Missing required attribute ngPasteFromColumns."),$scope.pasteEvent=function(event){var data,_ref;return null!=event.clipboardData&&null!=event.clipboardData.getData?data=event.clipboardData.getData("text/plain"):null!=event.originalEvent&&null!=event.originalEvent.clipboardData&&null!=event.originalEvent.clipboardData.getData?data=event.originalEvent.clipboardData.getData("text/plain"):null!=window.clipboardData&&null!=window.clipboardData.getData&&(data=window.clipboardData.getData("Text")),"function"==typeof $scope.ngPasteFromBeforeParse&&(data=$scope.ngPasteFromBeforeParse(data)),$scope.processPasteData(data),(null!=(_ref=$scope.ngPasteFromPasteOnly)?_ref:!0)?event.preventDefault():void 0},$scope.changeEvent=function(){var data,_ref;return(null!=(_ref=$scope.ngPasteFromPasteOnly)?_ref:!0)?element.val(""):(data=element.val(),"function"==typeof $scope.ngPasteFromBeforeParse&&(data=$scope.ngPasteFromBeforeParse(data)),$scope.processPasteData(data))},element.on("paste",$scope.pasteEvent),element.on("keyup",$scope.changeEvent),element.on("change",$scope.changeEvent)},controller:function($scope,$filter,ngPasteFromErrors,ngPasteFromSeparators){return $scope.columnsToObject=function(columns){var column,format,index,obj,_i,_len;for(obj={},format=$scope.ngPasteFromColumns,index=_i=0,_len=columns.length;_len>_i;index=++_i)column=columns[index],obj[format[index]]=column;return obj},$scope.getExpectedColumnsLength=function(){return"number"==typeof $scope.ngPasteFromColumns?$scope.ngPasteFromColumns:$scope.ngPasteFromColumns.length},$scope.processPasteData=function(data){var columns,expectedColumnsLength,index,result,row,rowData,rowResult,rows,_i,_len,_ref,_ref1;if(data&&data.length){for(rows=data.split(null!=(_ref=$scope.ngPasteFromRowSeparator)?_ref:ngPasteFromSeparators.row),result=[],expectedColumnsLength=$scope.getExpectedColumnsLength(),index=_i=0,_len=rows.length;_len>_i;index=++_i)row=rows[index],""!==row&&(columns=row.split(null!=(_ref1=$scope.ngPasteFromColumnSeparator)?_ref1:ngPasteFromSeparators.column),rowData={index:index,source:row,expectedLength:expectedColumnsLength,actualLength:columns.length},columns.length===expectedColumnsLength?(rowResult="number"==typeof $scope.ngPasteFromColumns?columns:$scope.columnsToObject(columns),"function"!=typeof $scope.ngPasteFromOnValidate||$scope.ngPasteFromOnValidate(rowResult,rowData)?result.push(rowResult):"function"==typeof $scope.ngPasteFromOnError&&$scope.ngPasteFromOnError(ngPasteFromErrors.failedValidation,rowData)):"function"==typeof $scope.ngPasteFromOnError&&$scope.ngPasteFromOnError(ngPasteFromErrors.invalidColumnLength,rowData));return $scope.$apply(function(){return $scope.ngPasteFrom=result})}}}}})}).call(this); +(function(){angular.module("ngPasteFrom",[]).constant("ngPasteFromErrors",{invalidColumnLength:"NGPASTEFROM_INVALID_COLUMN_LENGTH",failedValidation:"NGPASTEFROM_FAILED_VALIDATION"}).constant("ngPasteFromSeparators",{row:/\r\n|\n\r|\n|\r/g,column:" "}).directive("ngPasteFrom",function(){return{restrict:"A",scope:{ngPasteFrom:"=",ngPasteFromColumns:"=",ngPasteFromRowSeparator:"=",ngPasteFromColumnSeparator:"=",ngPasteFromPasteOnly:"=",ngPasteFromBeforeParse:"=",ngPasteFromAfterParseRow:"=",ngPasteFromOnValidate:"=",ngPasteFromOnSuccessBeforeApply:"=",ngPasteFromOnError:"="},link:function($scope,element){return null==$scope.ngPasteFromColumns&&console.error("Missing required attribute ngPasteFromColumns."),$scope.pasteEvent=function(event){var data,ref;return null!=event.clipboardData&&null!=event.clipboardData.getData?data=event.clipboardData.getData("text/plain"):null!=event.originalEvent&&null!=event.originalEvent.clipboardData&&null!=event.originalEvent.clipboardData.getData?data=event.originalEvent.clipboardData.getData("text/plain"):null!=window.clipboardData&&null!=window.clipboardData.getData&&(data=window.clipboardData.getData("Text")),"function"==typeof $scope.ngPasteFromBeforeParse&&(data=$scope.ngPasteFromBeforeParse(data)),$scope.processPasteData(data),(null!=(ref=$scope.ngPasteFromPasteOnly)?ref:!0)?event.preventDefault():void 0},$scope.changeEvent=function(){var data,ref;return(null!=(ref=$scope.ngPasteFromPasteOnly)?ref:!0)?element.val(""):(data=element.val(),"function"==typeof $scope.ngPasteFromBeforeParse&&(data=$scope.ngPasteFromBeforeParse(data)),$scope.processPasteData(data))},element.on("paste",$scope.pasteEvent),element.on("keyup",$scope.changeEvent),element.on("change",$scope.changeEvent)},controller:function($scope,$filter,ngPasteFromErrors,ngPasteFromSeparators){return $scope.columnsToObject=function(columns){var column,format,i,index,len,obj;for(obj={},format=$scope.ngPasteFromColumns,index=i=0,len=columns.length;len>i;index=++i)column=columns[index],obj[format[index]]=column;return obj},$scope.getExpectedColumnsLength=function(){return"number"==typeof $scope.ngPasteFromColumns?$scope.ngPasteFromColumns:$scope.ngPasteFromColumns.length},$scope.processPasteData=function(data){var columns,expectedColumnsLength,i,index,len,ref,ref1,result,row,rowData,rowResult,rows;if(data&&data.length){for(rows=data.split(null!=(ref=$scope.ngPasteFromRowSeparator)?ref:ngPasteFromSeparators.row),result=[],expectedColumnsLength=$scope.getExpectedColumnsLength(),index=i=0,len=rows.length;len>i;index=++i)row=rows[index],""!==row&&(columns=row.split(null!=(ref1=$scope.ngPasteFromColumnSeparator)?ref1:ngPasteFromSeparators.column),rowData={index:index,source:row,expectedLength:expectedColumnsLength,actualLength:columns.length},columns.length===expectedColumnsLength?(rowResult="number"==typeof $scope.ngPasteFromColumns?columns:$scope.columnsToObject(columns),"function"!=typeof $scope.ngPasteFromOnValidate||$scope.ngPasteFromOnValidate(rowResult,rowData)?("function"==typeof $scope.ngPasteFromAfterParseRow&&(rowResult=$scope.ngPasteFromAfterParseRow(rowResult)),result.push(rowResult)):"function"==typeof $scope.ngPasteFromOnError&&$scope.ngPasteFromOnError(ngPasteFromErrors.failedValidation,rowData)):"function"==typeof $scope.ngPasteFromOnError&&$scope.ngPasteFromOnError(ngPasteFromErrors.invalidColumnLength,rowData));return"function"==typeof $scope.ngPasteFromOnSuccessBeforeApply&&$scope.ngPasteFromOnSuccessBeforeApply(result),$scope.$apply(function(){return $scope.ngPasteFrom=result})}}}}})}).call(this); //# sourceMappingURL=ng-paste-from-latest.min.js.map \ No newline at end of file diff --git a/dist/ng-paste-from-latest.min.js.map b/dist/ng-paste-from-latest.min.js.map index 826e41e..488f2e8 100755 --- a/dist/ng-paste-from-latest.min.js.map +++ b/dist/ng-paste-from-latest.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ng-paste-from-latest.min.js","sources":["ng-paste-from.coffee"],"names":[],"mappings":"CAAA,WAAA,QAAQ,OAAO,kBACb,SAAS,qBACT,oBAAqB,oCACrB,iBAAkB,kCAElB,SAAS,yBACT,IAAK,mBACL,OAAQ,MAER,UAAU,cAAe,kBACzB,SAAU,IACV,OACC,YAAa,IACb,mBAAoB,IACpB,wBAAyB,IACzB,2BAA4B,IAC5B,qBAAsB,IACtB,uBAAwB,IACxB,sBAAuB,IACvB,mBAAoB,KAErB,KAAM,SAAC,OAAQ,eACP,OAAA,OAAA,oBACN,QAAQ,MAAM,kDAEf,OAAO,WAAa,SAAC,OACpB,GAAA,MAAA,IAUA,OAVG,OAAA,MAAA,eAAwB,MAAA,MAAA,cAAA,QAC1B,KAAO,MAAM,cAAc,QAAQ,cAC5B,MAAA,MAAA,eAAwB,MAAA,MAAA,cAAA,eAAsC,MAAA,MAAA,cAAA,cAAA,QACrE,KAAO,MAAM,cAAc,cAAc,QAAQ,cAC1C,MAAA,OAAA,eAAyB,MAAA,OAAA,cAAA,UAChC,KAAO,OAAO,cAAc,QAAQ,SAEM,kBAAxC,QAAc,yBAChB,KAAO,OAAO,uBAAuB,OACtC,OAAO,iBAAiB,OACxB,OAAA,KAAA,OAAA,sBAAA,MAAiC,GAChC,MAAM,iBADP,QAGD,OAAO,YAAc,WACpB,GAAA,MAAA,IAAA,QAAA,OAAA,KAAA,OAAA,sBAAA,MAAiC,GAChC,QAAQ,IAAI,KAEZ,KAAO,QAAQ,MAC4B,kBAAxC,QAAc,yBAChB,KAAO,OAAO,uB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n\t\tinvalidColumnLength: \"NGPASTEFROM_INVALID_COLUMN_LENGTH\"\n\t\tfailedValidation: \"NGPASTEFROM_FAILED_VALIDATION\"\n\n\t.constant \"ngPasteFromSeparators\",\n\t\trow: /\\r\\n|\\n\\r|\\n|\\r/g\n\t\tcolumn: \"\\t\"\n\n\t.directive \"ngPasteFrom\", ->\n\t\trestrict: \"A\"\n\t\tscope: \n\t\t\tngPasteFrom: \"=\"\n\t\t\tngPasteFromColumns: \"=\"\n\t\t\tngPasteFromRowSeparator: \"=\"\n\t\t\tngPasteFromColumnSeparator: \"=\"\n\t\t\tngPasteFromPasteOnly: \"=\"\n\t\t\tngPasteFromBeforeParse: \"=\"\n\t\t\tngPasteFromOnValidate: \"=\"\n\t\t\tngPasteFromOnError: \"=\"\n\n\t\tlink: ($scope, element, attrs) ->\n\t\t\tif not $scope.ngPasteFromColumns?\n\t\t\t\tconsole.error \"Missing required attribute ngPasteFromColumns.\"\n\n\t\t\t$scope.pasteEvent = (event) ->\n\t\t\t\tif event.clipboardData? && event.clipboardData.getData? # Standard\n\t\t\t\t\tdata = event.clipboardData.getData \"text/plain\"\n\t\t\t\telse if event.originalEvent? && event.originalEvent.clipboardData? && event.originalEvent.clipboardData.getData? # jQuery\n\t\t\t\t\tdata = event.originalEvent.clipboardData.getData \"text/plain\"\n\t\t\t\telse if window.clipboardData? && window.clipboardData.getData? # Internet Explorer\n\t\t\t\t\tdata = window.clipboardData.getData \"Text\"\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t$scope.processPasteData data\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\tevent.preventDefault()\n\n\t\t\t$scope.changeEvent = ->\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\telement.val \"\"\n\t\t\t\telse\n\t\t\t\t\tdata = element.val()\n\t\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t\t$scope.processPasteData data\n\n\t\t\telement.on \"paste\", $scope.pasteEvent\n\t\t\telement.on \"keyup\", $scope.changeEvent\n\t\t\telement.on \"change\", $scope.changeEvent\n\n\t\tcontroller: ($scope, $filter, ngPasteFromErrors, ngPasteFromSeparators) ->\n\t\t\t$scope.columnsToObject = (columns) ->\n\t\t\t\tobj = {}\n\t\t\t\tformat = $scope.ngPasteFromColumns\n\t\t\t\tfor column, index in columns\n\t\t\t\t\tobj[format[index]] = column\n\t\t\t\tobj\n\n\t\t\t$scope.getExpectedColumnsLength = ->\n\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t$scope.ngPasteFromColumns\n\t\t\t\telse\n\t\t\t\t\t$scope.ngPasteFromColumns.length\n\n\t\t\t$scope.processPasteData = (data) ->\n\t\t\t\tif not (data and data.length)\n\t\t\t\t\treturn\n\n\t\t\t\trows = data.split $scope.ngPasteFromRowSeparator ? ngPasteFromSeparators.row\n\t\t\t\tresult = []\n\t\t\t\texpectedColumnsLength = $scope.getExpectedColumnsLength()\n\n\t\t\t\tfor row, index in rows\n\t\t\t\t\tif row is \"\"\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tcolumns = row.split $scope.ngPasteFromColumnSeparator ? ngPasteFromSeparators.column\n\n\t\t\t\t\trowData =\n\t\t\t\t\t\tindex: index\n\t\t\t\t\t\tsource: row\n\t\t\t\t\t\texpectedLength: expectedColumnsLength\n\t\t\t\t\t\tactualLength: columns.length\n\n\t\t\t\t\tif columns.length isnt expectedColumnsLength\n\t\t\t\t\t\tif typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.invalidColumnLength, rowData\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t\trowResult = columns\n\t\t\t\t\telse\n\t\t\t\t\t\trowResult = $scope.columnsToObject columns\n\n\t\t\t\t\tif typeof $scope.ngPasteFromOnValidate isnt \"function\" or $scope.ngPasteFromOnValidate rowResult, rowData\n\t\t\t\t\t\tresult.push rowResult\n\t\t\t\t\telse if typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.failedValidation, rowData\n\n\t\t\t\t$scope.$apply ->\n\t\t\t\t\t$scope.ngPasteFrom = result\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["ng-paste-from.coffee","ng-paste-from.js"],"names":["angular","module","constant","invalidColumnLength","failedValidation","row","column","directive","restrict","scope","ngPasteFrom","ngPasteFromColumns","ngPasteFromRowSeparator","ngPasteFromColumnSeparator","ngPasteFromPasteOnly","ngPasteFromBeforeParse","ngPasteFromAfterParseRow","ngPasteFromOnValidate","ngPasteFromOnSuccessBeforeApply","ngPasteFromOnError","link","$scope","element","console","error","pasteEvent","event","data","ref","clipboardData","getData","originalEvent","window","processPasteData","preventDefault","changeEvent","val","on","controller","$filter","ngPasteFromErrors","ngPasteFromSeparators","columnsToObject","columns","format","i","index","len","obj","length","getExpectedColumnsLength","expectedColumnsLength","ref1","result","rowData","rowResult","rows","split","source","expectedLength","actualLength","push","$apply","call","this"],"mappings":"CAAA,WAAAA,QAAQC,OAAO,kBACbC,SAAS,qBACTC,oBAAqB,oCACrBC,iBAAkB,kCAElBF,SAAS,yBACTG,IAAK,mBACLC,OAAQ,MAERC,UAAU,cAAe,WCDvB,ODEFC,SAAU,IACVC,OACCC,YAAa,IACbC,mBAAoB,IACpBC,wBAAyB,IACzBC,2BAA4B,IAC5BC,qBAAsB,IACtBC,uBAAwB,IACxBC,yBAA0B,IAC1BC,sBAAuB,IACvBC,gCAAiC,IACjCC,mBAAoB,KAErBC,KAAM,SAACC,OAAQC,SCkCT,MDjCE,OAAAD,OAAAV,oBACNY,QAAQC,MAAM,kDAEfH,OAAOI,WAAa,S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AmB,SAACN,MAC1B,GAAAgB,SAAAQ,sBAAAN,EAAAC,MAAAC,IAAAnB,IAAAwB,KAAAC,OAAAhD,IAAAiD,QAAAC,UAAAC,IAAA,IAAQ7B,MAASA,KAAKsB,OAAtB,CAOA,IAJAO,KAAO7B,KAAK8B,MAAL,OAAA7B,IAAAP,OAAAT,yBAAAgB,IAA4Ca,sBAAsBpC,KACzEgD,UACAF,sBAAwB9B,OAAO6B,2BAE/BJ,MAAAD,EAAA,EAAAE,IAAAS,KAAAP,OAAAF,IAAAF,EAAAC,QAAAD,ECUQxC,IAAMmD,KAAKV,ODTR,KAAPzC,MAGHsC,QAAUtC,IAAIoD,MAAJ,OAAAL,KAAA/B,OAAAR,4BAAAuC,KAA8CX,sBAAsBnC,QAE9EgD,SACCR,MAAOA,MACPY,OAAQrD,IACRsD,eAAgBR,sBAChBS,aAAcjB,QAAQM,QAEpBN,QAAQM,SAAYE,uBAMtBI,UADsC,gBAA7BlC,QAAOV,mBACJgC,QAEAtB,OAAOqB,gBAAgBC,SAEQ,kBAAlCtB,QAAOJ,uBAAyCI,OAAOJ,sBAAsBsC,UAAWD,UACpD,kBAAnCjC,QAAOL,2BAChBuC,UAAYlC,OAAOL,yBAAyBuC,YAE7CF,OAAOQ,KAAKN,YAC+B,kBAA7BlC,QAAOF,oBACrBE,OAAOF,mBAAmBqB,kBAAkBpC,iBAAkBkD,UAfvB,kBAA7BjC,QAAOF,oBAChBE,OAAOF,mBAAmBqB,kBAAkBrC,oBAAqBmD,SC8B9D,ODd8C,kBAA1CjC,QAAOH,iCAChBG,OAAOH,gCAAgCmC,QAExChC,OAAOyC,OAAO,WCYN,MDXPzC,QAAOX,YAAc2C,iBCkBvBU,KAAKC","file":"ng-paste-from-latest.min.js","sourcesContent":["angular.module \"ngPasteFrom\", []\n\t.constant \"ngPasteFromErrors\",\n\t\tinvalidColumnLength: \"NGPASTEFROM_INVALID_COLUMN_LENGTH\"\n\t\tfailedValidation: \"NGPASTEFROM_FAILED_VALIDATION\"\n\n\t.constant \"ngPasteFromSeparators\",\n\t\trow: /\\r\\n|\\n\\r|\\n|\\r/g\n\t\tcolumn: \"\\t\"\n\n\t.directive \"ngPasteFrom\", ->\n\t\trestrict: \"A\"\n\t\tscope: \n\t\t\tngPasteFrom: \"=\"\n\t\t\tngPasteFromColumns: \"=\"\n\t\t\tngPasteFromRowSeparator: \"=\"\n\t\t\tngPasteFromColumnSeparator: \"=\"\n\t\t\tngPasteFromPasteOnly: \"=\"\n\t\t\tngPasteFromBeforeParse: \"=\"\n\t\t\tngPasteFromAfterParseRow: \"=\"\n\t\t\tngPasteFromOnValidate: \"=\"\n\t\t\tngPasteFromOnSuccessBeforeApply: \"=\"\n\t\t\tngPasteFromOnError: \"=\"\n\n\t\tlink: ($scope, element, attrs) ->\n\t\t\tif not $scope.ngPasteFromColumns?\n\t\t\t\tconsole.error \"Missing required attribute ngPasteFromColumns.\"\n\n\t\t\t$scope.pasteEvent = (event) ->\n\t\t\t\tif event.clipboardData? && event.clipboardData.getData? # Standard\n\t\t\t\t\tdata = event.clipboardData.getData \"text/plain\"\n\t\t\t\telse if event.originalEvent? && event.originalEvent.clipboardData? && event.originalEvent.clipboardData.getData? # jQuery\n\t\t\t\t\tdata = event.originalEvent.clipboardData.getData \"text/plain\"\n\t\t\t\telse if window.clipboardData? && window.clipboardData.getData? # Internet Explorer\n\t\t\t\t\tdata = window.clipboardData.getData \"Text\"\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t$scope.processPasteData data\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\tevent.preventDefault()\n\n\t\t\t$scope.changeEvent = ->\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\telement.val \"\"\n\t\t\t\telse\n\t\t\t\t\tdata = element.val()\n\t\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t\t$scope.processPasteData data\n\n\t\t\telement.on \"paste\", $scope.pasteEvent\n\t\t\telement.on \"keyup\", $scope.changeEvent\n\t\t\telement.on \"change\", $scope.changeEvent\n\n\t\tcontroller: ($scope, $filter, ngPasteFromErrors, ngPasteFromSeparators) ->\n\t\t\t$scope.columnsToObject = (columns) ->\n\t\t\t\tobj = {}\n\t\t\t\tformat = $scope.ngPasteFromColumns\n\t\t\t\tfor column, index in columns\n\t\t\t\t\tobj[format[index]] = column\n\t\t\t\tobj\n\n\t\t\t$scope.getExpectedColumnsLength = ->\n\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t$scope.ngPasteFromColumns\n\t\t\t\telse\n\t\t\t\t\t$scope.ngPasteFromColumns.length\n\n\t\t\t$scope.processPasteData = (data) ->\n\t\t\t\tif not (data and data.length)\n\t\t\t\t\treturn\n\n\t\t\t\trows = data.split $scope.ngPasteFromRowSeparator ? ngPasteFromSeparators.row\n\t\t\t\tresult = []\n\t\t\t\texpectedColumnsLength = $scope.getExpectedColumnsLength()\n\n\t\t\t\tfor row, index in rows\n\t\t\t\t\tif row is \"\"\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tcolumns = row.split $scope.ngPasteFromColumnSeparator ? ngPasteFromSeparators.column\n\n\t\t\t\t\trowData =\n\t\t\t\t\t\tindex: index\n\t\t\t\t\t\tsource: row\n\t\t\t\t\t\texpectedLength: expectedColumnsLength\n\t\t\t\t\t\tactualLength: columns.length\n\n\t\t\t\t\tif columns.length isnt expectedColumnsLength\n\t\t\t\t\t\tif typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.invalidColumnLength, rowData\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t\trowResult = columns\n\t\t\t\t\telse\n\t\t\t\t\t\trowResult = $scope.columnsToObject columns\n\n\t\t\t\t\tif typeof $scope.ngPasteFromOnValidate isnt \"function\" or $scope.ngPasteFromOnValidate rowResult, rowData\n\t\t\t\t\t\tif typeof $scope.ngPasteFromAfterParseRow is \"function\"\n\t\t\t\t\t\t\trowResult = $scope.ngPasteFromAfterParseRow rowResult\n\n\t\t\t\t\t\tresult.push rowResult\n\t\t\t\t\telse if typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.failedValidation, rowData\n\n\t\t\t\tif typeof $scope.ngPasteFromOnSuccessBeforeApply is \"function\"\n\t\t\t\t\t$scope.ngPasteFromOnSuccessBeforeApply result\n\n\t\t\t\t$scope.$apply ->\n\t\t\t\t\t$scope.ngPasteFrom = result\n",null],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/ng-paste-from.coffee b/src/ng-paste-from.coffee index 6114bf5..0c3dacb 100644 --- a/src/ng-paste-from.coffee +++ b/src/ng-paste-from.coffee @@ -16,7 +16,9 @@ angular.module "ngPasteFrom", [] ngPasteFromColumnSeparator: "=" ngPasteFromPasteOnly: "=" ngPasteFromBeforeParse: "=" + ngPasteFromAfterParseRow: "=" ngPasteFromOnValidate: "=" + ngPasteFromOnSuccessBeforeApply: "=" ngPasteFromOnError: "=" link: ($scope, element, attrs) -> @@ -95,9 +97,15 @@ angular.module "ngPasteFrom", [] rowResult = $scope.columnsToObject columns if typeof $scope.ngPasteFromOnValidate isnt "function" or $scope.ngPasteFromOnValidate rowResult, rowData + if typeof $scope.ngPasteFromAfterParseRow is "function" + rowResult = $scope.ngPasteFromAfterParseRow rowResult + result.push rowResult else if typeof $scope.ngPasteFromOnError is "function" $scope.ngPasteFromOnError ngPasteFromErrors.failedValidation, rowData + if typeof $scope.ngPasteFromOnSuccessBeforeApply is "function" + $scope.ngPasteFromOnSuccessBeforeApply result + $scope.$apply -> $scope.ngPasteFrom = result From c5fa44a12f5aacbc6aa6c099ff185d0fd7081008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikko=20Ka=CC=88rkka=CC=88inen?= Date: Tue, 23 Feb 2016 10:47:25 +0200 Subject: [PATCH 2/5] changed the success hook name, added rowData param to after parse hook --- dist/ng-paste-from-latest.js | 8 ++++---- dist/ng-paste-from-latest.js.map | 2 +- dist/ng-paste-from-latest.min.js | 2 +- dist/ng-paste-from-latest.min.js.map | 2 +- src/ng-paste-from.coffee | 8 ++++---- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dist/ng-paste-from-latest.js b/dist/ng-paste-from-latest.js index e7e25b2..76ba987 100644 --- a/dist/ng-paste-from-latest.js +++ b/dist/ng-paste-from-latest.js @@ -17,7 +17,7 @@ ngPasteFromBeforeParse: "=", ngPasteFromAfterParseRow: "=", ngPasteFromOnValidate: "=", - ngPasteFromOnSuccessBeforeApply: "=", + ngPasteFromBeforeApply: "=", ngPasteFromOnError: "=" }, link: function($scope, element, attrs) { @@ -108,15 +108,15 @@ } if (typeof $scope.ngPasteFromOnValidate !== "function" || $scope.ngPasteFromOnValidate(rowResult, rowData)) { if (typeof $scope.ngPasteFromAfterParseRow === "function") { - rowResult = $scope.ngPasteFromAfterParseRow(rowResult); + rowResult = $scope.ngPasteFromAfterParseRow(rowResult(rowData)); } result.push(rowResult); } else if (typeof $scope.ngPasteFromOnError === "function") { $scope.ngPasteFromOnError(ngPasteFromErrors.failedValidation, rowData); } } - if (typeof $scope.ngPasteFromOnSuccessBeforeApply === "function") { - $scope.ngPasteFromOnSuccessBeforeApply(result); + if (typeof $scope.ngPasteFromBeforeApply === "function") { + $scope.ngPasteFromBeforeApply(result); } return $scope.$apply(function() { return $scope.ngPasteFrom = result; diff --git a/dist/ng-paste-from-latest.js.map b/dist/ng-paste-from-latest.js.map index 41c86b7..adf8cb2 100755 --- a/dist/ng-paste-from-latest.js.map +++ b/dist/ng-paste-from-latest.js.map @@ -1 +1 @@ -{"version":3,"sources":["ng-paste-from.coffee"],"names":[],"mappings":"AAAA;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AP,GAAqB;UADR,CAAd;QAzCyB;MAdf,CA5CZ;;EADyB,CAT3B;AAAA","file":"ng-paste-from-latest.js","sourceRoot":"/source/","sourcesContent":["angular.module \"ngPasteFrom\", []\n\t.constant \"ngPasteFromErrors\",\n\t\tinvalidColumnLength: \"NGPASTEFROM_INVALID_COLUMN_LENGTH\"\n\t\tfailedValidation: \"NGPASTEFROM_FAILED_VALIDATION\"\n\n\t.constant \"ngPasteFromSeparators\",\n\t\trow: /\\r\\n|\\n\\r|\\n|\\r/g\n\t\tcolumn: \"\\t\"\n\n\t.directive \"ngPasteFrom\", ->\n\t\trestrict: \"A\"\n\t\tscope: \n\t\t\tngPasteFrom: \"=\"\n\t\t\tngPasteFromColumns: \"=\"\n\t\t\tngPasteFromRowSeparator: \"=\"\n\t\t\tngPasteFromColumnSeparator: \"=\"\n\t\t\tngPasteFromPasteOnly: \"=\"\n\t\t\tngPasteFromBeforeParse: \"=\"\n\t\t\tngPasteFromAfterParseRow: \"=\"\n\t\t\tngPasteFromOnValidate: \"=\"\n\t\t\tngPasteFromOnSuccessBeforeApply: \"=\"\n\t\t\tngPasteFromOnError: \"=\"\n\n\t\tlink: ($scope, element, attrs) ->\n\t\t\tif not $scope.ngPasteFromColumns?\n\t\t\t\tconsole.error \"Missing required attribute ngPasteFromColumns.\"\n\n\t\t\t$scope.pasteEvent = (event) ->\n\t\t\t\tif event.clipboardData? && event.clipboardData.getData? # Standard\n\t\t\t\t\tdata = event.clipboardData.getData \"text/plain\"\n\t\t\t\telse if event.originalEvent? && event.originalEvent.clipboardData? && event.originalEvent.clipboardData.getData? # jQuery\n\t\t\t\t\tdata = event.originalEvent.clipboardData.getData \"text/plain\"\n\t\t\t\telse if window.clipboardData? && window.clipboardData.getData? # Internet Explorer\n\t\t\t\t\tdata = window.clipboardData.getData \"Text\"\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t$scope.processPasteData data\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\tevent.preventDefault()\n\n\t\t\t$scope.changeEvent = ->\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\telement.val \"\"\n\t\t\t\telse\n\t\t\t\t\tdata = element.val()\n\t\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t\t$scope.processPasteData data\n\n\t\t\telement.on \"paste\", $scope.pasteEvent\n\t\t\telement.on \"keyup\", $scope.changeEvent\n\t\t\telement.on \"change\", $scope.changeEvent\n\n\t\tcontroller: ($scope, $filter, ngPasteFromErrors, ngPasteFromSeparators) ->\n\t\t\t$scope.columnsToObject = (columns) ->\n\t\t\t\tobj = {}\n\t\t\t\tformat = $scope.ngPasteFromColumns\n\t\t\t\tfor column, index in columns\n\t\t\t\t\tobj[format[index]] = column\n\t\t\t\tobj\n\n\t\t\t$scope.getExpectedColumnsLength = ->\n\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t$scope.ngPasteFromColumns\n\t\t\t\telse\n\t\t\t\t\t$scope.ngPasteFromColumns.length\n\n\t\t\t$scope.processPasteData = (data) ->\n\t\t\t\tif not (data and data.length)\n\t\t\t\t\treturn\n\n\t\t\t\trows = data.split $scope.ngPasteFromRowSeparator ? ngPasteFromSeparators.row\n\t\t\t\tresult = []\n\t\t\t\texpectedColumnsLength = $scope.getExpectedColumnsLength()\n\n\t\t\t\tfor row, index in rows\n\t\t\t\t\tif row is \"\"\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tcolumns = row.split $scope.ngPasteFromColumnSeparator ? ngPasteFromSeparators.column\n\n\t\t\t\t\trowData =\n\t\t\t\t\t\tindex: index\n\t\t\t\t\t\tsource: row\n\t\t\t\t\t\texpectedLength: expectedColumnsLength\n\t\t\t\t\t\tactualLength: columns.length\n\n\t\t\t\t\tif columns.length isnt expectedColumnsLength\n\t\t\t\t\t\tif typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.invalidColumnLength, rowData\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t\trowResult = columns\n\t\t\t\t\telse\n\t\t\t\t\t\trowResult = $scope.columnsToObject columns\n\n\t\t\t\t\tif typeof $scope.ngPasteFromOnValidate isnt \"function\" or $scope.ngPasteFromOnValidate rowResult, rowData\n\t\t\t\t\t\tif typeof $scope.ngPasteFromAfterParseRow is \"function\"\n\t\t\t\t\t\t\trowResult = $scope.ngPasteFromAfterParseRow rowResult\n\n\t\t\t\t\t\tresult.push rowResult\n\t\t\t\t\telse if typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.failedValidation, rowData\n\n\t\t\t\tif typeof $scope.ngPasteFromOnSuccessBeforeApply is \"function\"\n\t\t\t\t\t$scope.ngPasteFromOnSuccessBeforeApply result\n\n\t\t\t\t$scope.$apply ->\n\t\t\t\t\t$scope.ngPasteFrom = result\n"]} \ No newline at end of file +{"version":3,"sources":["ng-paste-from.coffee"],"names":[],"mappings":"AAAA;EAAA,OAAO,CAAC,MAAR,CAAe,aAAf,EAA8B,EAA9B,CACC,CAAC,QADF,CACW,mBADX,EAEE;IAAA,mBAAA,EAAqB,mCAArB;IACA,gBAAA,EAAkB,+BADlB;GAFF,CAKC,CAAC,QALF,CAKW,uBALX,EAME;IAAA,GAAA,EAAK,kBAAL;IACA,MAAA,EAAQ,IADR;GANF,CASC,CAAC,SATF,CASY,aATZ,EAS2B,SAAA;WACzB;MAAA,QAAA,EAAU,GAAV;MACA,KAAA,EACC;QAAA,WAAA,EAAa,GAAb;QACA,kBAAA,EAAoB,GADpB;QAEA,uBAAA,EAAyB,GAFzB;QAGA,0BAAA,EAA4B,GAH5B;QAIA,oBAAA,E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vC;gBACC,MAAM,CAAC,kBAAP,CAA0B,iBAAiB,CAAC,mBAA5C,EAAiE,OAAjE,EADD;;AAEA,uBAHD;;YAKA,IAAG,OAAO,MAAM,CAAC,kBAAd,KAAoC,QAAvC;cACC,SAAA,GAAY,QADb;aAAA,MAAA;cAGC,SAAA,GAAY,MAAM,CAAC,eAAP,CAAuB,OAAvB,EAHb;;YAKA,IAAG,OAAO,MAAM,CAAC,qBAAd,KAAyC,UAAzC,IAAuD,MAAM,CAAC,qBAAP,CAA6B,SAA7B,EAAwC,OAAxC,CAA1D;cACC,IAAG,OAAO,MAAM,CAAC,wBAAd,KAA0C,UAA7C;gBACC,SAAA,GAAY,MAAM,CAAC,wBAAP,CAAgC,SAAA,CAAU,OAAV,CAAhC,EADb;;cAGA,MAAM,CAAC,IAAP,CAAY,SAAZ,EAJD;aAAA,MAKK,IAAG,OAAO,MAAM,CAAC,kBAAd,KAAoC,UAAvC;cACJ,MAAM,CAAC,kBAAP,CAA0B,iBAAiB,CAAC,gBAA5C,EAA8D,OAA9D,EADI;;AA3BN;UA8BA,IAAG,OAAO,MAAM,CAAC,sBAAd,KAAwC,UAA3C;YACC,MAAM,CAAC,sBAAP,CAA8B,MAA9B,EADD;;iBAGA,MAAM,CAAC,MAAP,CAAc,SAAA;mBACb,MAAM,CAAC,WAAP,GAAqB;UADR,CAAd;QAzCyB;MAdf,CA5CZ;;EADyB,CAT3B;AAAA","file":"ng-paste-from-latest.js","sourceRoot":"/source/","sourcesContent":["angular.module \"ngPasteFrom\", []\n\t.constant \"ngPasteFromErrors\",\n\t\tinvalidColumnLength: \"NGPASTEFROM_INVALID_COLUMN_LENGTH\"\n\t\tfailedValidation: \"NGPASTEFROM_FAILED_VALIDATION\"\n\n\t.constant \"ngPasteFromSeparators\",\n\t\trow: /\\r\\n|\\n\\r|\\n|\\r/g\n\t\tcolumn: \"\\t\"\n\n\t.directive \"ngPasteFrom\", ->\n\t\trestrict: \"A\"\n\t\tscope: \n\t\t\tngPasteFrom: \"=\"\n\t\t\tngPasteFromColumns: \"=\"\n\t\t\tngPasteFromRowSeparator: \"=\"\n\t\t\tngPasteFromColumnSeparator: \"=\"\n\t\t\tngPasteFromPasteOnly: \"=\"\n\t\t\tngPasteFromBeforeParse: \"=\"\n\t\t\tngPasteFromAfterParseRow: \"=\"\n\t\t\tngPasteFromOnValidate: \"=\"\n\t\t\tngPasteFromBeforeApply: \"=\"\n\t\t\tngPasteFromOnError: \"=\"\n\n\t\tlink: ($scope, element, attrs) ->\n\t\t\tif not $scope.ngPasteFromColumns?\n\t\t\t\tconsole.error \"Missing required attribute ngPasteFromColumns.\"\n\n\t\t\t$scope.pasteEvent = (event) ->\n\t\t\t\tif event.clipboardData? && event.clipboardData.getData? # Standard\n\t\t\t\t\tdata = event.clipboardData.getData \"text/plain\"\n\t\t\t\telse if event.originalEvent? && event.originalEvent.clipboardData? && event.originalEvent.clipboardData.getData? # jQuery\n\t\t\t\t\tdata = event.originalEvent.clipboardData.getData \"text/plain\"\n\t\t\t\telse if window.clipboardData? && window.clipboardData.getData? # Internet Explorer\n\t\t\t\t\tdata = window.clipboardData.getData \"Text\"\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t$scope.processPasteData data\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\tevent.preventDefault()\n\n\t\t\t$scope.changeEvent = ->\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\telement.val \"\"\n\t\t\t\telse\n\t\t\t\t\tdata = element.val()\n\t\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t\t$scope.processPasteData data\n\n\t\t\telement.on \"paste\", $scope.pasteEvent\n\t\t\telement.on \"keyup\", $scope.changeEvent\n\t\t\telement.on \"change\", $scope.changeEvent\n\n\t\tcontroller: ($scope, $filter, ngPasteFromErrors, ngPasteFromSeparators) ->\n\t\t\t$scope.columnsToObject = (columns) ->\n\t\t\t\tobj = {}\n\t\t\t\tformat = $scope.ngPasteFromColumns\n\t\t\t\tfor column, index in columns\n\t\t\t\t\tobj[format[index]] = column\n\t\t\t\tobj\n\n\t\t\t$scope.getExpectedColumnsLength = ->\n\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t$scope.ngPasteFromColumns\n\t\t\t\telse\n\t\t\t\t\t$scope.ngPasteFromColumns.length\n\n\t\t\t$scope.processPasteData = (data) ->\n\t\t\t\tif not (data and data.length)\n\t\t\t\t\treturn\n\n\t\t\t\trows = data.split $scope.ngPasteFromRowSeparator ? ngPasteFromSeparators.row\n\t\t\t\tresult = []\n\t\t\t\texpectedColumnsLength = $scope.getExpectedColumnsLength()\n\n\t\t\t\tfor row, index in rows\n\t\t\t\t\tif row is \"\"\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tcolumns = row.split $scope.ngPasteFromColumnSeparator ? ngPasteFromSeparators.column\n\n\t\t\t\t\trowData =\n\t\t\t\t\t\tindex: index\n\t\t\t\t\t\tsource: row\n\t\t\t\t\t\texpectedLength: expectedColumnsLength\n\t\t\t\t\t\tactualLength: columns.length\n\n\t\t\t\t\tif columns.length isnt expectedColumnsLength\n\t\t\t\t\t\tif typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.invalidColumnLength, rowData\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t\trowResult = columns\n\t\t\t\t\telse\n\t\t\t\t\t\trowResult = $scope.columnsToObject columns\n\n\t\t\t\t\tif typeof $scope.ngPasteFromOnValidate isnt \"function\" or $scope.ngPasteFromOnValidate rowResult, rowData\n\t\t\t\t\t\tif typeof $scope.ngPasteFromAfterParseRow is \"function\"\n\t\t\t\t\t\t\trowResult = $scope.ngPasteFromAfterParseRow rowResult rowData\n\n\t\t\t\t\t\tresult.push rowResult\n\t\t\t\t\telse if typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.failedValidation, rowData\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeApply is \"function\"\n\t\t\t\t\t$scope.ngPasteFromBeforeApply result\n\n\t\t\t\t$scope.$apply ->\n\t\t\t\t\t$scope.ngPasteFrom = result\n"]} \ No newline at end of file diff --git a/dist/ng-paste-from-latest.min.js b/dist/ng-paste-from-latest.min.js index 23e4a06..c60ffd4 100644 --- a/dist/ng-paste-from-latest.min.js +++ b/dist/ng-paste-from-latest.min.js @@ -1,2 +1,2 @@ -(function(){angular.module("ngPasteFrom",[]).constant("ngPasteFromErrors",{invalidColumnLength:"NGPASTEFROM_INVALID_COLUMN_LENGTH",failedValidation:"NGPASTEFROM_FAILED_VALIDATION"}).constant("ngPasteFromSeparators",{row:/\r\n|\n\r|\n|\r/g,column:" "}).directive("ngPasteFrom",function(){return{restrict:"A",scope:{ngPasteFrom:"=",ngPasteFromColumns:"=",ngPasteFromRowSeparator:"=",ngPasteFromColumnSeparator:"=",ngPasteFromPasteOnly:"=",ngPasteFromBeforeParse:"=",ngPasteFromAfterParseRow:"=",ngPasteFromOnValidate:"=",ngPasteFromOnSuccessBeforeApply:"=",ngPasteFromOnError:"="},link:function($scope,element){return null==$scope.ngPasteFromColumns&&console.error("Missing required attribute ngPasteFromColumns."),$scope.pasteEvent=function(event){var data,ref;return null!=event.clipboardData&&null!=event.clipboardData.getData?data=event.clipboardData.getData("text/plain"):null!=event.originalEvent&&null!=event.originalEvent.clipboardData&&null!=event.originalEvent.clipboardData.getData?data=event.originalEvent.clipboardData.getData("text/plain"):null!=window.clipboardData&&null!=window.clipboardData.getData&&(data=window.clipboardData.getData("Text")),"function"==typeof $scope.ngPasteFromBeforeParse&&(data=$scope.ngPasteFromBeforeParse(data)),$scope.processPasteData(data),(null!=(ref=$scope.ngPasteFromPasteOnly)?ref:!0)?event.preventDefault():void 0},$scope.changeEvent=function(){var data,ref;return(null!=(ref=$scope.ngPasteFromPasteOnly)?ref:!0)?element.val(""):(data=element.val(),"function"==typeof $scope.ngPasteFromBeforeParse&&(data=$scope.ngPasteFromBeforeParse(data)),$scope.processPasteData(data))},element.on("paste",$scope.pasteEvent),element.on("keyup",$scope.changeEvent),element.on("change",$scope.changeEvent)},controller:function($scope,$filter,ngPasteFromErrors,ngPasteFromSeparators){return $scope.columnsToObject=function(columns){var column,format,i,index,len,obj;for(obj={},format=$scope.ngPasteFromColumns,index=i=0,len=columns.length;len>i;index=++i)column=columns[index],obj[format[index]]=column;return obj},$scope.getExpectedColumnsLength=function(){return"number"==typeof $scope.ngPasteFromColumns?$scope.ngPasteFromColumns:$scope.ngPasteFromColumns.length},$scope.processPasteData=function(data){var columns,expectedColumnsLength,i,index,len,ref,ref1,result,row,rowData,rowResult,rows;if(data&&data.length){for(rows=data.split(null!=(ref=$scope.ngPasteFromRowSeparator)?ref:ngPasteFromSeparators.row),result=[],expectedColumnsLength=$scope.getExpectedColumnsLength(),index=i=0,len=rows.length;len>i;index=++i)row=rows[index],""!==row&&(columns=row.split(null!=(ref1=$scope.ngPasteFromColumnSeparator)?ref1:ngPasteFromSeparators.column),rowData={index:index,source:row,expectedLength:expectedColumnsLength,actualLength:columns.length},columns.length===expectedColumnsLength?(rowResult="number"==typeof $scope.ngPasteFromColumns?columns:$scope.columnsToObject(columns),"function"!=typeof $scope.ngPasteFromOnValidate||$scope.ngPasteFromOnValidate(rowResult,rowData)?("function"==typeof $scope.ngPasteFromAfterParseRow&&(rowResult=$scope.ngPasteFromAfterParseRow(rowResult)),result.push(rowResult)):"function"==typeof $scope.ngPasteFromOnError&&$scope.ngPasteFromOnError(ngPasteFromErrors.failedValidation,rowData)):"function"==typeof $scope.ngPasteFromOnError&&$scope.ngPasteFromOnError(ngPasteFromErrors.invalidColumnLength,rowData));return"function"==typeof $scope.ngPasteFromOnSuccessBeforeApply&&$scope.ngPasteFromOnSuccessBeforeApply(result),$scope.$apply(function(){return $scope.ngPasteFrom=result})}}}}})}).call(this); +(function(){angular.module("ngPasteFrom",[]).constant("ngPasteFromErrors",{invalidColumnLength:"NGPASTEFROM_INVALID_COLUMN_LENGTH",failedValidation:"NGPASTEFROM_FAILED_VALIDATION"}).constant("ngPasteFromSeparators",{row:/\r\n|\n\r|\n|\r/g,column:" "}).directive("ngPasteFrom",function(){return{restrict:"A",scope:{ngPasteFrom:"=",ngPasteFromColumns:"=",ngPasteFromRowSeparator:"=",ngPasteFromColumnSeparator:"=",ngPasteFromPasteOnly:"=",ngPasteFromBeforeParse:"=",ngPasteFromAfterParseRow:"=",ngPasteFromOnValidate:"=",ngPasteFromBeforeApply:"=",ngPasteFromOnError:"="},link:function($scope,element){return null==$scope.ngPasteFromColumns&&console.error("Missing required attribute ngPasteFromColumns."),$scope.pasteEvent=function(event){var data,ref;return null!=event.clipboardData&&null!=event.clipboardData.getData?data=event.clipboardData.getData("text/plain"):null!=event.originalEvent&&null!=event.originalEvent.clipboardData&&null!=event.originalEvent.clipboardData.getData?data=event.originalEvent.clipboardData.getData("text/plain"):null!=window.clipboardData&&null!=window.clipboardData.getData&&(data=window.clipboardData.getData("Text")),"function"==typeof $scope.ngPasteFromBeforeParse&&(data=$scope.ngPasteFromBeforeParse(data)),$scope.processPasteData(data),(null!=(ref=$scope.ngPasteFromPasteOnly)?ref:!0)?event.preventDefault():void 0},$scope.changeEvent=function(){var data,ref;return(null!=(ref=$scope.ngPasteFromPasteOnly)?ref:!0)?element.val(""):(data=element.val(),"function"==typeof $scope.ngPasteFromBeforeParse&&(data=$scope.ngPasteFromBeforeParse(data)),$scope.processPasteData(data))},element.on("paste",$scope.pasteEvent),element.on("keyup",$scope.changeEvent),element.on("change",$scope.changeEvent)},controller:function($scope,$filter,ngPasteFromErrors,ngPasteFromSeparators){return $scope.columnsToObject=function(columns){var column,format,i,index,len,obj;for(obj={},format=$scope.ngPasteFromColumns,index=i=0,len=columns.length;len>i;index=++i)column=columns[index],obj[format[index]]=column;return obj},$scope.getExpectedColumnsLength=function(){return"number"==typeof $scope.ngPasteFromColumns?$scope.ngPasteFromColumns:$scope.ngPasteFromColumns.length},$scope.processPasteData=function(data){var columns,expectedColumnsLength,i,index,len,ref,ref1,result,row,rowData,rowResult,rows;if(data&&data.length){for(rows=data.split(null!=(ref=$scope.ngPasteFromRowSeparator)?ref:ngPasteFromSeparators.row),result=[],expectedColumnsLength=$scope.getExpectedColumnsLength(),index=i=0,len=rows.length;len>i;index=++i)row=rows[index],""!==row&&(columns=row.split(null!=(ref1=$scope.ngPasteFromColumnSeparator)?ref1:ngPasteFromSeparators.column),rowData={index:index,source:row,expectedLength:expectedColumnsLength,actualLength:columns.length},columns.length===expectedColumnsLength?(rowResult="number"==typeof $scope.ngPasteFromColumns?columns:$scope.columnsToObject(columns),"function"!=typeof $scope.ngPasteFromOnValidate||$scope.ngPasteFromOnValidate(rowResult,rowData)?("function"==typeof $scope.ngPasteFromAfterParseRow&&(rowResult=$scope.ngPasteFromAfterParseRow(rowResult(rowData))),result.push(rowResult)):"function"==typeof $scope.ngPasteFromOnError&&$scope.ngPasteFromOnError(ngPasteFromErrors.failedValidation,rowData)):"function"==typeof $scope.ngPasteFromOnError&&$scope.ngPasteFromOnError(ngPasteFromErrors.invalidColumnLength,rowData));return"function"==typeof $scope.ngPasteFromBeforeApply&&$scope.ngPasteFromBeforeApply(result),$scope.$apply(function(){return $scope.ngPasteFrom=result})}}}}})}).call(this); //# sourceMappingURL=ng-paste-from-latest.min.js.map \ No newline at end of file diff --git a/dist/ng-paste-from-latest.min.js.map b/dist/ng-paste-from-latest.min.js.map index 488f2e8..33e7761 100755 --- a/dist/ng-paste-from-latest.min.js.map +++ b/dist/ng-paste-from-latest.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["ng-paste-from.coffee","ng-paste-from.js"],"names":["angular","module","constant","invalidColumnLength","failedValidation","row","column","directive","restrict","scope","ngPasteFrom","ngPasteFromColumns","ngPasteFromRowSeparator","ngPasteFromColumnSeparator","ngPasteFromPasteOnly","ngPasteFromBeforeParse","ngPasteFromAfterParseRow","ngPasteFromOnValidate","ngPasteFromOnSuccessBeforeApply","ngPasteFromOnError","link","$scope","element","console","error","pasteEvent","event","data","ref","clipboardData","getData","originalEvent","window","processPasteData","preventDefault","changeEvent","val","on","controller","$filter","ngPasteFromErrors","ngPasteFromSeparators","columnsToObject","columns","format","i","index","len","obj","length","getExpectedColumnsLength","expectedColumnsLength","ref1","result","rowData","rowResult","rows","split","source","expectedLength","actualLength","push","$apply","call","this"],"mappings":"CAAA,WAAAA,QAAQC,OAAO,kBACbC,SAAS,qBACTC,oBAAqB,oCACrBC,iBAAkB,kCAElBF,SAAS,yBACTG,IAAK,mBACLC,OAAQ,MAERC,UAAU,cAAe,WCDvB,ODEFC,SAAU,IACVC,OACCC,YAAa,IACbC,mBAAoB,IACpBC,wBAAyB,IACzBC,2BAA4B,IAC5BC,qBAAsB,IACtBC,uBAAwB,IACxBC,yBAA0B,IAC1BC,sBAAuB,IACvBC,gCAAiC,IACjCC,mBAAoB,KAErBC,KAAM,SAACC,OAAQC,SCkCT,MDjCE,OAAAD,OAAAV,oBACNY,QAAQC,MAAM,kDAEfH,OAAOI,WAAa,SAACC,OACpB,GAAAC,MAAAC,GAUA,OAVG,OAAAF,MAAAG,eAAwB,MAAAH,MAAAG,cAAAC,QAC1BH,KAAOD,MAAMG,cAAcC,QAAQ,cAC5B,MAAAJ,MAAAK,eAAwB,MAAAL,MAAAK,cAAAF,eAAsC,MAAAH,MAAAK,cAAAF,cAAAC,QACrEH,KAAOD,MAAMK,cAAcF,cAAcC,QAAQ,cAC1C,MAAAE,OAAAH,eAAyB,MAAAG,OAAAH,cAAAC,UAChCH,KAAOK,OAAOH,cAAcC,QAAQ,SAEM,kBAAjCT,QAAON,yBAChBY,KAAON,OAAON,uBAAuBY,OACtCN,OAAOY,iBAAiBN,OACxB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,OAAAL,KAAA/B,OAAAR,4BAAAuC,KAA8CX,sBAAsBnC,QAE9EgD,SACCR,MAAOA,MACPY,OAAQrD,IACRsD,eAAgBR,sBAChBS,aAAcjB,QAAQM,QAEpBN,QAAQM,SAAYE,uBAMtBI,UADsC,gBAA7BlC,QAAOV,mBACJgC,QAEAtB,OAAOqB,gBAAgBC,SAEQ,kBAAlCtB,QAAOJ,uBAAyCI,OAAOJ,sBAAsBsC,UAAWD,UACpD,kBAAnCjC,QAAOL,2BAChBuC,UAAYlC,OAAOL,yBAAyBuC,YAE7CF,OAAOQ,KAAKN,YAC+B,kBAA7BlC,QAAOF,oBACrBE,OAAOF,mBAAmBqB,kBAAkBpC,iBAAkBkD,UAfvB,kBAA7BjC,QAAOF,oBAChBE,OAAOF,mBAAmBqB,kBAAkBrC,oBAAqBmD,SC8B9D,ODd8C,kBAA1CjC,QAAOH,iCAChBG,OAAOH,gCAAgCmC,QAExChC,OAAOyC,OAAO,WCYN,MDXPzC,QAAOX,YAAc2C,iBCkBvBU,KAAKC","file":"ng-paste-from-latest.min.js","sourcesContent":["angular.module \"ngPasteFrom\", []\n\t.constant \"ngPasteFromErrors\",\n\t\tinvalidColumnLength: \"NGPASTEFROM_INVALID_COLUMN_LENGTH\"\n\t\tfailedValidation: \"NGPASTEFROM_FAILED_VALIDATION\"\n\n\t.constant \"ngPasteFromSeparators\",\n\t\trow: /\\r\\n|\\n\\r|\\n|\\r/g\n\t\tcolumn: \"\\t\"\n\n\t.directive \"ngPasteFrom\", ->\n\t\trestrict: \"A\"\n\t\tscope: \n\t\t\tngPasteFrom: \"=\"\n\t\t\tngPasteFromColumns: \"=\"\n\t\t\tngPasteFromRowSeparator: \"=\"\n\t\t\tngPasteFromColumnSeparator: \"=\"\n\t\t\tngPasteFromPasteOnly: \"=\"\n\t\t\tngPasteFromBeforeParse: \"=\"\n\t\t\tngPasteFromAfterParseRow: \"=\"\n\t\t\tngPasteFromOnValidate: \"=\"\n\t\t\tngPasteFromOnSuccessBeforeApply: \"=\"\n\t\t\tngPasteFromOnError: \"=\"\n\n\t\tlink: ($scope, element, attrs) ->\n\t\t\tif not $scope.ngPasteFromColumns?\n\t\t\t\tconsole.error \"Missing required attribute ngPasteFromColumns.\"\n\n\t\t\t$scope.pasteEvent = (event) ->\n\t\t\t\tif event.clipboardData? && event.clipboardData.getData? # Standard\n\t\t\t\t\tdata = event.clipboardData.getData \"text/plain\"\n\t\t\t\telse if event.originalEvent? && event.originalEvent.clipboardData? && event.originalEvent.clipboardData.getData? # jQuery\n\t\t\t\t\tdata = event.originalEvent.clipboardData.getData \"text/plain\"\n\t\t\t\telse if window.clipboardData? && window.clipboardData.getData? # Internet Explorer\n\t\t\t\t\tdata = window.clipboardData.getData \"Text\"\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t$scope.processPasteData data\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\tevent.preventDefault()\n\n\t\t\t$scope.changeEvent = ->\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\telement.val \"\"\n\t\t\t\telse\n\t\t\t\t\tdata = element.val()\n\t\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t\t$scope.processPasteData data\n\n\t\t\telement.on \"paste\", $scope.pasteEvent\n\t\t\telement.on \"keyup\", $scope.changeEvent\n\t\t\telement.on \"change\", $scope.changeEvent\n\n\t\tcontroller: ($scope, $filter, ngPasteFromErrors, ngPasteFromSeparators) ->\n\t\t\t$scope.columnsToObject = (columns) ->\n\t\t\t\tobj = {}\n\t\t\t\tformat = $scope.ngPasteFromColumns\n\t\t\t\tfor column, index in columns\n\t\t\t\t\tobj[format[index]] = column\n\t\t\t\tobj\n\n\t\t\t$scope.getExpectedColumnsLength = ->\n\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t$scope.ngPasteFromColumns\n\t\t\t\telse\n\t\t\t\t\t$scope.ngPasteFromColumns.length\n\n\t\t\t$scope.processPasteData = (data) ->\n\t\t\t\tif not (data and data.length)\n\t\t\t\t\treturn\n\n\t\t\t\trows = data.split $scope.ngPasteFromRowSeparator ? ngPasteFromSeparators.row\n\t\t\t\tresult = []\n\t\t\t\texpectedColumnsLength = $scope.getExpectedColumnsLength()\n\n\t\t\t\tfor row, index in rows\n\t\t\t\t\tif row is \"\"\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tcolumns = row.split $scope.ngPasteFromColumnSeparator ? ngPasteFromSeparators.column\n\n\t\t\t\t\trowData =\n\t\t\t\t\t\tindex: index\n\t\t\t\t\t\tsource: row\n\t\t\t\t\t\texpectedLength: expectedColumnsLength\n\t\t\t\t\t\tactualLength: columns.length\n\n\t\t\t\t\tif columns.length isnt expectedColumnsLength\n\t\t\t\t\t\tif typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.invalidColumnLength, rowData\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t\trowResult = columns\n\t\t\t\t\telse\n\t\t\t\t\t\trowResult = $scope.columnsToObject columns\n\n\t\t\t\t\tif typeof $scope.ngPasteFromOnValidate isnt \"function\" or $scope.ngPasteFromOnValidate rowResult, rowData\n\t\t\t\t\t\tif typeof $scope.ngPasteFromAfterParseRow is \"function\"\n\t\t\t\t\t\t\trowResult = $scope.ngPasteFromAfterParseRow rowResult\n\n\t\t\t\t\t\tresult.push rowResult\n\t\t\t\t\telse if typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.failedValidation, rowData\n\n\t\t\t\tif typeof $scope.ngPasteFromOnSuccessBeforeApply is \"function\"\n\t\t\t\t\t$scope.ngPasteFromOnSuccessBeforeApply result\n\n\t\t\t\t$scope.$apply ->\n\t\t\t\t\t$scope.ngPasteFrom = result\n",null],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["ng-paste-from.coffee","ng-paste-from.js"],"names":["angular","module","constant","invalidColumnLength","failedValidation","row","column","directive","restrict","scope","ngPasteFrom","ngPasteFromColumns","ngPasteFromRowSeparator","ngPasteFromColumnSeparator","ngPasteFromPasteOnly","ngPasteFromBeforeParse","ngPasteFromAfterParseRow","ngPasteFromOnValidate","ngPasteFromBeforeApply","ngPasteFromOnError","link","$scope","element","console","error","pasteEvent","event","data","ref","clipboardData","getData","originalEvent","window","processPasteData","preventDefault","changeEvent","val","on","controller","$filter","ngPasteFromErrors","ngPasteFromSeparators","columnsToObject","columns","format","i","index","len","obj","length","getExpectedColumnsLength","expectedColumnsLength","ref1","result","rowData","rowResult","rows","split","source","expectedLength","actualLength","push","$apply","call","this"],"mappings":"CAAA,WAAAA,QAAQC,OAAO,kBACbC,SAAS,qBACTC,oBAAqB,oCACrBC,iBAAkB,kCAElBF,SAAS,yBACTG,IAAK,mBACLC,OAAQ,MAERC,UAAU,cAAe,WCDvB,ODEFC,SAAU,IACVC,OACCC,YAAa,IACbC,mBAAoB,IACpBC,wBAAyB,IACzBC,2BAA4B,IAC5BC,qBAAsB,IACtBC,uBAAwB,IACxBC,yBAA0B,IAC1BC,sBAAuB,IACvBC,uBAAwB,IACxBC,mBAAoB,KAErBC,KAAM,SAACC,OAAQC,SCkCT,MDjCE,OAAAD,OAAAV,oBACNY,QAAQC,MAAM,kDAEfH,OAAOI,WAAa,SAACC,OACpB,GAAAC,MAAAC,GAUA,OAVG,OAAAF,MAAAG,eAAwB,MAAAH,MAAAG,cAAAC,QAC1BH,KAAOD,MAAMG,cAAcC,QAAQ,cAC5B,MAAAJ,MAAAK,eAAwB,MAAAL,MAAAK,cAAAF,eAAsC,MAAAH,MAAAK,cAAAF,cAAAC,QACrEH,KAAOD,MAAMK,cAAcF,cAAcC,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zEgD,UACAF,sBAAwB9B,OAAO6B,2BAE/BJ,MAAAD,EAAA,EAAAE,IAAAS,KAAAP,OAAAF,IAAAF,EAAAC,QAAAD,ECUQxC,IAAMmD,KAAKV,ODTR,KAAPzC,MAGHsC,QAAUtC,IAAIoD,MAAJ,OAAAL,KAAA/B,OAAAR,4BAAAuC,KAA8CX,sBAAsBnC,QAE9EgD,SACCR,MAAOA,MACPY,OAAQrD,IACRsD,eAAgBR,sBAChBS,aAAcjB,QAAQM,QAEpBN,QAAQM,SAAYE,uBAMtBI,UADsC,gBAA7BlC,QAAOV,mBACJgC,QAEAtB,OAAOqB,gBAAgBC,SAEQ,kBAAlCtB,QAAOJ,uBAAyCI,OAAOJ,sBAAsBsC,UAAWD,UACpD,kBAAnCjC,QAAOL,2BAChBuC,UAAYlC,OAAOL,yBAAyBuC,UAAUD,WAEvDD,OAAOQ,KAAKN,YAC+B,kBAA7BlC,QAAOF,oBACrBE,OAAOF,mBAAmBqB,kBAAkBpC,iBAAkBkD,UAfvB,kBAA7BjC,QAAOF,oBAChBE,OAAOF,mBAAmBqB,kBAAkBrC,oBAAqBmD,SC8B9D,ODdqC,kBAAjCjC,QAAOH,wBAChBG,OAAOH,uBAAuBmC,QAE/BhC,OAAOyC,OAAO,WCYN,MDXPzC,QAAOX,YAAc2C,iBCkBvBU,KAAKC","file":"ng-paste-from-latest.min.js","sourcesContent":["angular.module \"ngPasteFrom\", []\n\t.constant \"ngPasteFromErrors\",\n\t\tinvalidColumnLength: \"NGPASTEFROM_INVALID_COLUMN_LENGTH\"\n\t\tfailedValidation: \"NGPASTEFROM_FAILED_VALIDATION\"\n\n\t.constant \"ngPasteFromSeparators\",\n\t\trow: /\\r\\n|\\n\\r|\\n|\\r/g\n\t\tcolumn: \"\\t\"\n\n\t.directive \"ngPasteFrom\", ->\n\t\trestrict: \"A\"\n\t\tscope: \n\t\t\tngPasteFrom: \"=\"\n\t\t\tngPasteFromColumns: \"=\"\n\t\t\tngPasteFromRowSeparator: \"=\"\n\t\t\tngPasteFromColumnSeparator: \"=\"\n\t\t\tngPasteFromPasteOnly: \"=\"\n\t\t\tngPasteFromBeforeParse: \"=\"\n\t\t\tngPasteFromAfterParseRow: \"=\"\n\t\t\tngPasteFromOnValidate: \"=\"\n\t\t\tngPasteFromBeforeApply: \"=\"\n\t\t\tngPasteFromOnError: \"=\"\n\n\t\tlink: ($scope, element, attrs) ->\n\t\t\tif not $scope.ngPasteFromColumns?\n\t\t\t\tconsole.error \"Missing required attribute ngPasteFromColumns.\"\n\n\t\t\t$scope.pasteEvent = (event) ->\n\t\t\t\tif event.clipboardData? && event.clipboardData.getData? # Standard\n\t\t\t\t\tdata = event.clipboardData.getData \"text/plain\"\n\t\t\t\telse if event.originalEvent? && event.originalEvent.clipboardData? && event.originalEvent.clipboardData.getData? # jQuery\n\t\t\t\t\tdata = event.originalEvent.clipboardData.getData \"text/plain\"\n\t\t\t\telse if window.clipboardData? && window.clipboardData.getData? # Internet Explorer\n\t\t\t\t\tdata = window.clipboardData.getData \"Text\"\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t$scope.processPasteData data\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\tevent.preventDefault()\n\n\t\t\t$scope.changeEvent = ->\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\telement.val \"\"\n\t\t\t\telse\n\t\t\t\t\tdata = element.val()\n\t\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t\t$scope.processPasteData data\n\n\t\t\telement.on \"paste\", $scope.pasteEvent\n\t\t\telement.on \"keyup\", $scope.changeEvent\n\t\t\telement.on \"change\", $scope.changeEvent\n\n\t\tcontroller: ($scope, $filter, ngPasteFromErrors, ngPasteFromSeparators) ->\n\t\t\t$scope.columnsToObject = (columns) ->\n\t\t\t\tobj = {}\n\t\t\t\tformat = $scope.ngPasteFromColumns\n\t\t\t\tfor column, index in columns\n\t\t\t\t\tobj[format[index]] = column\n\t\t\t\tobj\n\n\t\t\t$scope.getExpectedColumnsLength = ->\n\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t$scope.ngPasteFromColumns\n\t\t\t\telse\n\t\t\t\t\t$scope.ngPasteFromColumns.length\n\n\t\t\t$scope.processPasteData = (data) ->\n\t\t\t\tif not (data and data.length)\n\t\t\t\t\treturn\n\n\t\t\t\trows = data.split $scope.ngPasteFromRowSeparator ? ngPasteFromSeparators.row\n\t\t\t\tresult = []\n\t\t\t\texpectedColumnsLength = $scope.getExpectedColumnsLength()\n\n\t\t\t\tfor row, index in rows\n\t\t\t\t\tif row is \"\"\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tcolumns = row.split $scope.ngPasteFromColumnSeparator ? ngPasteFromSeparators.column\n\n\t\t\t\t\trowData =\n\t\t\t\t\t\tindex: index\n\t\t\t\t\t\tsource: row\n\t\t\t\t\t\texpectedLength: expectedColumnsLength\n\t\t\t\t\t\tactualLength: columns.length\n\n\t\t\t\t\tif columns.length isnt expectedColumnsLength\n\t\t\t\t\t\tif typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.invalidColumnLength, rowData\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t\trowResult = columns\n\t\t\t\t\telse\n\t\t\t\t\t\trowResult = $scope.columnsToObject columns\n\n\t\t\t\t\tif typeof $scope.ngPasteFromOnValidate isnt \"function\" or $scope.ngPasteFromOnValidate rowResult, rowData\n\t\t\t\t\t\tif typeof $scope.ngPasteFromAfterParseRow is \"function\"\n\t\t\t\t\t\t\trowResult = $scope.ngPasteFromAfterParseRow rowResult rowData\n\n\t\t\t\t\t\tresult.push rowResult\n\t\t\t\t\telse if typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.failedValidation, rowData\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeApply is \"function\"\n\t\t\t\t\t$scope.ngPasteFromBeforeApply result\n\n\t\t\t\t$scope.$apply ->\n\t\t\t\t\t$scope.ngPasteFrom = result\n",null],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/ng-paste-from.coffee b/src/ng-paste-from.coffee index 0c3dacb..a9b86fb 100644 --- a/src/ng-paste-from.coffee +++ b/src/ng-paste-from.coffee @@ -18,7 +18,7 @@ angular.module "ngPasteFrom", [] ngPasteFromBeforeParse: "=" ngPasteFromAfterParseRow: "=" ngPasteFromOnValidate: "=" - ngPasteFromOnSuccessBeforeApply: "=" + ngPasteFromBeforeApply: "=" ngPasteFromOnError: "=" link: ($scope, element, attrs) -> @@ -98,14 +98,14 @@ angular.module "ngPasteFrom", [] if typeof $scope.ngPasteFromOnValidate isnt "function" or $scope.ngPasteFromOnValidate rowResult, rowData if typeof $scope.ngPasteFromAfterParseRow is "function" - rowResult = $scope.ngPasteFromAfterParseRow rowResult + rowResult = $scope.ngPasteFromAfterParseRow rowResult rowData result.push rowResult else if typeof $scope.ngPasteFromOnError is "function" $scope.ngPasteFromOnError ngPasteFromErrors.failedValidation, rowData - if typeof $scope.ngPasteFromOnSuccessBeforeApply is "function" - $scope.ngPasteFromOnSuccessBeforeApply result + if typeof $scope.ngPasteFromBeforeApply is "function" + $scope.ngPasteFromBeforeApply result $scope.$apply -> $scope.ngPasteFrom = result From 3a3adc085dbaa1b5f13abc84c81f7a08c5343bda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikko=20Ka=CC=88rkka=CC=88inen?= Date: Tue, 23 Feb 2016 10:52:21 +0200 Subject: [PATCH 3/5] bug fix --- src/ng-paste-from.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ng-paste-from.coffee b/src/ng-paste-from.coffee index a9b86fb..d59c355 100644 --- a/src/ng-paste-from.coffee +++ b/src/ng-paste-from.coffee @@ -98,7 +98,7 @@ angular.module "ngPasteFrom", [] if typeof $scope.ngPasteFromOnValidate isnt "function" or $scope.ngPasteFromOnValidate rowResult, rowData if typeof $scope.ngPasteFromAfterParseRow is "function" - rowResult = $scope.ngPasteFromAfterParseRow rowResult rowData + rowResult = $scope.ngPasteFromAfterParseRow rowResult, rowData result.push rowResult else if typeof $scope.ngPasteFromOnError is "function" From e79f603b2cfb213ee9f57ed10450912e3216e2bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikko=20Ka=CC=88rkka=CC=88inen?= Date: Tue, 23 Feb 2016 10:56:37 +0200 Subject: [PATCH 4/5] missed the compiled files --- dist/ng-paste-from-latest.js | 2 +- dist/ng-paste-from-latest.js.map | 2 +- dist/ng-paste-from-latest.min.js | 2 +- dist/ng-paste-from-latest.min.js.map | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/ng-paste-from-latest.js b/dist/ng-paste-from-latest.js index 76ba987..af49488 100644 --- a/dist/ng-paste-from-latest.js +++ b/dist/ng-paste-from-latest.js @@ -108,7 +108,7 @@ } if (typeof $scope.ngPasteFromOnValidate !== "function" || $scope.ngPasteFromOnValidate(rowResult, rowData)) { if (typeof $scope.ngPasteFromAfterParseRow === "function") { - rowResult = $scope.ngPasteFromAfterParseRow(rowResult(rowData)); + rowResult = $scope.ngPasteFromAfterParseRow(rowResult, rowData); } result.push(rowResult); } else if (typeof $scope.ngPasteFromOnError === "function") { diff --git a/dist/ng-paste-from-latest.js.map b/dist/ng-paste-from-latest.js.map index adf8cb2..7cacb5d 100755 --- a/dist/ng-paste-from-latest.js.map +++ b/dist/ng-paste-from-latest.js.map @@ -1 +1 @@ -{"version":3,"sources":["ng-paste-from.coffee"],"names":[],"mappings":"AAAA;EAAA,OAAO,CAAC,MAAR,CAAe,aAAf,EAA8B,EAA9B,CACC,CAAC,QADF,CACW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,CAT3B;AAAA","file":"ng-paste-from-latest.js","sourceRoot":"/source/","sourcesContent":["angular.module \"ngPasteFrom\", []\n\t.constant \"ngPasteFromErrors\",\n\t\tinvalidColumnLength: \"NGPASTEFROM_INVALID_COLUMN_LENGTH\"\n\t\tfailedValidation: \"NGPASTEFROM_FAILED_VALIDATION\"\n\n\t.constant \"ngPasteFromSeparators\",\n\t\trow: /\\r\\n|\\n\\r|\\n|\\r/g\n\t\tcolumn: \"\\t\"\n\n\t.directive \"ngPasteFrom\", ->\n\t\trestrict: \"A\"\n\t\tscope: \n\t\t\tngPasteFrom: \"=\"\n\t\t\tngPasteFromColumns: \"=\"\n\t\t\tngPasteFromRowSeparator: \"=\"\n\t\t\tngPasteFromColumnSeparator: \"=\"\n\t\t\tngPasteFromPasteOnly: \"=\"\n\t\t\tngPasteFromBeforeParse: \"=\"\n\t\t\tngPasteFromAfterParseRow: \"=\"\n\t\t\tngPasteFromOnValidate: \"=\"\n\t\t\tngPasteFromBeforeApply: \"=\"\n\t\t\tngPasteFromOnError: \"=\"\n\n\t\tlink: ($scope, element, attrs) ->\n\t\t\tif not $scope.ngPasteFromColumns?\n\t\t\t\tconsole.error \"Missing required attribute ngPasteFromColumns.\"\n\n\t\t\t$scope.pasteEvent = (event) ->\n\t\t\t\tif event.clipboardData? && event.clipboardData.getData? # Standard\n\t\t\t\t\tdata = event.clipboardData.getData \"text/plain\"\n\t\t\t\telse if event.originalEvent? && event.originalEvent.clipboardData? && event.originalEvent.clipboardData.getData? # jQuery\n\t\t\t\t\tdata = event.originalEvent.clipboardData.getData \"text/plain\"\n\t\t\t\telse if window.clipboardData? && window.clipboardData.getData? # Internet Explorer\n\t\t\t\t\tdata = window.clipboardData.getData \"Text\"\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t$scope.processPasteData data\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\tevent.preventDefault()\n\n\t\t\t$scope.changeEvent = ->\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\telement.val \"\"\n\t\t\t\telse\n\t\t\t\t\tdata = element.val()\n\t\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t\t$scope.processPasteData data\n\n\t\t\telement.on \"paste\", $scope.pasteEvent\n\t\t\telement.on \"keyup\", $scope.changeEvent\n\t\t\telement.on \"change\", $scope.changeEvent\n\n\t\tcontroller: ($scope, $filter, ngPasteFromErrors, ngPasteFromSeparators) ->\n\t\t\t$scope.columnsToObject = (columns) ->\n\t\t\t\tobj = {}\n\t\t\t\tformat = $scope.ngPasteFromColumns\n\t\t\t\tfor column, index in columns\n\t\t\t\t\tobj[format[index]] = column\n\t\t\t\tobj\n\n\t\t\t$scope.getExpectedColumnsLength = ->\n\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t$scope.ngPasteFromColumns\n\t\t\t\telse\n\t\t\t\t\t$scope.ngPasteFromColumns.length\n\n\t\t\t$scope.processPasteData = (data) ->\n\t\t\t\tif not (data and data.length)\n\t\t\t\t\treturn\n\n\t\t\t\trows = data.split $scope.ngPasteFromRowSeparator ? ngPasteFromSeparators.row\n\t\t\t\tresult = []\n\t\t\t\texpectedColumnsLength = $scope.getExpectedColumnsLength()\n\n\t\t\t\tfor row, index in rows\n\t\t\t\t\tif row is \"\"\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tcolumns = row.split $scope.ngPasteFromColumnSeparator ? ngPasteFromSeparators.column\n\n\t\t\t\t\trowData =\n\t\t\t\t\t\tindex: index\n\t\t\t\t\t\tsource: row\n\t\t\t\t\t\texpectedLength: expectedColumnsLength\n\t\t\t\t\t\tactualLength: columns.length\n\n\t\t\t\t\tif columns.length isnt expectedColumnsLength\n\t\t\t\t\t\tif typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.invalidColumnLength, rowData\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t\trowResult = columns\n\t\t\t\t\telse\n\t\t\t\t\t\trowResult = $scope.columnsToObject columns\n\n\t\t\t\t\tif typeof $scope.ngPasteFromOnValidate isnt \"function\" or $scope.ngPasteFromOnValidate rowResult, rowData\n\t\t\t\t\t\tif typeof $scope.ngPasteFromAfterParseRow is \"function\"\n\t\t\t\t\t\t\trowResult = $scope.ngPasteFromAfterParseRow rowResult rowData\n\n\t\t\t\t\t\tresult.push rowResult\n\t\t\t\t\telse if typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.failedValidation, rowData\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeApply is \"function\"\n\t\t\t\t\t$scope.ngPasteFromBeforeApply result\n\n\t\t\t\t$scope.$apply ->\n\t\t\t\t\t$scope.ngPasteFrom = result\n"]} \ No newline at end of file +{"version":3,"sources":["ng-paste-from.coffee"],"names":[],"mappings":"AAAA;EAAA,OAAO,CAAC,MAAR,CAAe,aAAf,EAA8B,EAA9B,CACC,CAAC,QADF,CACW,mBADX,EAEE;IAAA,mBAAA,EAAqB,mCAArB;IACA,gBAAA,EAAkB,+BADlB;GAFF,CAKC,CAAC,QALF,CAKW,uBALX,EAME;IAAA,GAAA,EAAK,kBAAL;IACA,MAAA,EAAQ,IADR;GANF,CASC,CAAC,SATF,CASY,aATZ,EAS2B,SAAA;WACzB;MAAA,QAAA,EAAU,GAAV;MACA,KAAA,EACC;QAAA,WAAA,EAAa,GAAb;QACA,kBAAA,EAAoB,GADpB;QAEA,uBAAA,EAAyB,GAFzB;QAGA,0BAAA,EAA4B,GAH5B;QAIA,oBAAA,EAAsB,GAJtB;QAKA,sBAAA,EAAwB,GALxB;QAMA,wBAAA,EAA0B,GAN1B;Q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AjE,EADD;;AAEA,uBAHD;;YAKA,IAAG,OAAO,MAAM,CAAC,kBAAd,KAAoC,QAAvC;cACC,SAAA,GAAY,QADb;aAAA,MAAA;cAGC,SAAA,GAAY,MAAM,CAAC,eAAP,CAAuB,OAAvB,EAHb;;YAKA,IAAG,OAAO,MAAM,CAAC,qBAAd,KAAyC,UAAzC,IAAuD,MAAM,CAAC,qBAAP,CAA6B,SAA7B,EAAwC,OAAxC,CAA1D;cACC,IAAG,OAAO,MAAM,CAAC,wBAAd,KAA0C,UAA7C;gBACC,SAAA,GAAY,MAAM,CAAC,wBAAP,CAAgC,SAAhC,EAA2C,OAA3C,EADb;;cAGA,MAAM,CAAC,IAAP,CAAY,SAAZ,EAJD;aAAA,MAKK,IAAG,OAAO,MAAM,CAAC,kBAAd,KAAoC,UAAvC;cACJ,MAAM,CAAC,kBAAP,CAA0B,iBAAiB,CAAC,gBAA5C,EAA8D,OAA9D,EADI;;AA3BN;UA8BA,IAAG,OAAO,MAAM,CAAC,sBAAd,KAAwC,UAA3C;YACC,MAAM,CAAC,sBAAP,CAA8B,MAA9B,EADD;;iBAGA,MAAM,CAAC,MAAP,CAAc,SAAA;mBACb,MAAM,CAAC,WAAP,GAAqB;UADR,CAAd;QAzCyB;MAdf,CA5CZ;;EADyB,CAT3B;AAAA","file":"ng-paste-from-latest.js","sourceRoot":"/source/","sourcesContent":["angular.module \"ngPasteFrom\", []\n\t.constant \"ngPasteFromErrors\",\n\t\tinvalidColumnLength: \"NGPASTEFROM_INVALID_COLUMN_LENGTH\"\n\t\tfailedValidation: \"NGPASTEFROM_FAILED_VALIDATION\"\n\n\t.constant \"ngPasteFromSeparators\",\n\t\trow: /\\r\\n|\\n\\r|\\n|\\r/g\n\t\tcolumn: \"\\t\"\n\n\t.directive \"ngPasteFrom\", ->\n\t\trestrict: \"A\"\n\t\tscope: \n\t\t\tngPasteFrom: \"=\"\n\t\t\tngPasteFromColumns: \"=\"\n\t\t\tngPasteFromRowSeparator: \"=\"\n\t\t\tngPasteFromColumnSeparator: \"=\"\n\t\t\tngPasteFromPasteOnly: \"=\"\n\t\t\tngPasteFromBeforeParse: \"=\"\n\t\t\tngPasteFromAfterParseRow: \"=\"\n\t\t\tngPasteFromOnValidate: \"=\"\n\t\t\tngPasteFromBeforeApply: \"=\"\n\t\t\tngPasteFromOnError: \"=\"\n\n\t\tlink: ($scope, element, attrs) ->\n\t\t\tif not $scope.ngPasteFromColumns?\n\t\t\t\tconsole.error \"Missing required attribute ngPasteFromColumns.\"\n\n\t\t\t$scope.pasteEvent = (event) ->\n\t\t\t\tif event.clipboardData? && event.clipboardData.getData? # Standard\n\t\t\t\t\tdata = event.clipboardData.getData \"text/plain\"\n\t\t\t\telse if event.originalEvent? && event.originalEvent.clipboardData? && event.originalEvent.clipboardData.getData? # jQuery\n\t\t\t\t\tdata = event.originalEvent.clipboardData.getData \"text/plain\"\n\t\t\t\telse if window.clipboardData? && window.clipboardData.getData? # Internet Explorer\n\t\t\t\t\tdata = window.clipboardData.getData \"Text\"\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t$scope.processPasteData data\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\tevent.preventDefault()\n\n\t\t\t$scope.changeEvent = ->\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\telement.val \"\"\n\t\t\t\telse\n\t\t\t\t\tdata = element.val()\n\t\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t\t$scope.processPasteData data\n\n\t\t\telement.on \"paste\", $scope.pasteEvent\n\t\t\telement.on \"keyup\", $scope.changeEvent\n\t\t\telement.on \"change\", $scope.changeEvent\n\n\t\tcontroller: ($scope, $filter, ngPasteFromErrors, ngPasteFromSeparators) ->\n\t\t\t$scope.columnsToObject = (columns) ->\n\t\t\t\tobj = {}\n\t\t\t\tformat = $scope.ngPasteFromColumns\n\t\t\t\tfor column, index in columns\n\t\t\t\t\tobj[format[index]] = column\n\t\t\t\tobj\n\n\t\t\t$scope.getExpectedColumnsLength = ->\n\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t$scope.ngPasteFromColumns\n\t\t\t\telse\n\t\t\t\t\t$scope.ngPasteFromColumns.length\n\n\t\t\t$scope.processPasteData = (data) ->\n\t\t\t\tif not (data and data.length)\n\t\t\t\t\treturn\n\n\t\t\t\trows = data.split $scope.ngPasteFromRowSeparator ? ngPasteFromSeparators.row\n\t\t\t\tresult = []\n\t\t\t\texpectedColumnsLength = $scope.getExpectedColumnsLength()\n\n\t\t\t\tfor row, index in rows\n\t\t\t\t\tif row is \"\"\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tcolumns = row.split $scope.ngPasteFromColumnSeparator ? ngPasteFromSeparators.column\n\n\t\t\t\t\trowData =\n\t\t\t\t\t\tindex: index\n\t\t\t\t\t\tsource: row\n\t\t\t\t\t\texpectedLength: expectedColumnsLength\n\t\t\t\t\t\tactualLength: columns.length\n\n\t\t\t\t\tif columns.length isnt expectedColumnsLength\n\t\t\t\t\t\tif typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.invalidColumnLength, rowData\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t\trowResult = columns\n\t\t\t\t\telse\n\t\t\t\t\t\trowResult = $scope.columnsToObject columns\n\n\t\t\t\t\tif typeof $scope.ngPasteFromOnValidate isnt \"function\" or $scope.ngPasteFromOnValidate rowResult, rowData\n\t\t\t\t\t\tif typeof $scope.ngPasteFromAfterParseRow is \"function\"\n\t\t\t\t\t\t\trowResult = $scope.ngPasteFromAfterParseRow rowResult, rowData\n\n\t\t\t\t\t\tresult.push rowResult\n\t\t\t\t\telse if typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.failedValidation, rowData\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeApply is \"function\"\n\t\t\t\t\t$scope.ngPasteFromBeforeApply result\n\n\t\t\t\t$scope.$apply ->\n\t\t\t\t\t$scope.ngPasteFrom = result\n"]} \ No newline at end of file diff --git a/dist/ng-paste-from-latest.min.js b/dist/ng-paste-from-latest.min.js index c60ffd4..9e6cf38 100644 --- a/dist/ng-paste-from-latest.min.js +++ b/dist/ng-paste-from-latest.min.js @@ -1,2 +1,2 @@ -(function(){angular.module("ngPasteFrom",[]).constant("ngPasteFromErrors",{invalidColumnLength:"NGPASTEFROM_INVALID_COLUMN_LENGTH",failedValidation:"NGPASTEFROM_FAILED_VALIDATION"}).constant("ngPasteFromSeparators",{row:/\r\n|\n\r|\n|\r/g,column:" "}).directive("ngPasteFrom",function(){return{restrict:"A",scope:{ngPasteFrom:"=",ngPasteFromColumns:"=",ngPasteFromRowSeparator:"=",ngPasteFromColumnSeparator:"=",ngPasteFromPasteOnly:"=",ngPasteFromBeforeParse:"=",ngPasteFromAfterParseRow:"=",ngPasteFromOnValidate:"=",ngPasteFromBeforeApply:"=",ngPasteFromOnError:"="},link:function($scope,element){return null==$scope.ngPasteFromColumns&&console.error("Missing required attribute ngPasteFromColumns."),$scope.pasteEvent=function(event){var data,ref;return null!=event.clipboardData&&null!=event.clipboardData.getData?data=event.clipboardData.getData("text/plain"):null!=event.originalEvent&&null!=event.originalEvent.clipboardData&&null!=event.originalEvent.clipboardData.getData?data=event.originalEvent.clipboardData.getData("text/plain"):null!=window.clipboardData&&null!=window.clipboardData.getData&&(data=window.clipboardData.getData("Text")),"function"==typeof $scope.ngPasteFromBeforeParse&&(data=$scope.ngPasteFromBeforeParse(data)),$scope.processPasteData(data),(null!=(ref=$scope.ngPasteFromPasteOnly)?ref:!0)?event.preventDefault():void 0},$scope.changeEvent=function(){var data,ref;return(null!=(ref=$scope.ngPasteFromPasteOnly)?ref:!0)?element.val(""):(data=element.val(),"function"==typeof $scope.ngPasteFromBeforeParse&&(data=$scope.ngPasteFromBeforeParse(data)),$scope.processPasteData(data))},element.on("paste",$scope.pasteEvent),element.on("keyup",$scope.changeEvent),element.on("change",$scope.changeEvent)},controller:function($scope,$filter,ngPasteFromErrors,ngPasteFromSeparators){return $scope.columnsToObject=function(columns){var column,format,i,index,len,obj;for(obj={},format=$scope.ngPasteFromColumns,index=i=0,len=columns.length;len>i;index=++i)column=columns[index],obj[format[index]]=column;return obj},$scope.getExpectedColumnsLength=function(){return"number"==typeof $scope.ngPasteFromColumns?$scope.ngPasteFromColumns:$scope.ngPasteFromColumns.length},$scope.processPasteData=function(data){var columns,expectedColumnsLength,i,index,len,ref,ref1,result,row,rowData,rowResult,rows;if(data&&data.length){for(rows=data.split(null!=(ref=$scope.ngPasteFromRowSeparator)?ref:ngPasteFromSeparators.row),result=[],expectedColumnsLength=$scope.getExpectedColumnsLength(),index=i=0,len=rows.length;len>i;index=++i)row=rows[index],""!==row&&(columns=row.split(null!=(ref1=$scope.ngPasteFromColumnSeparator)?ref1:ngPasteFromSeparators.column),rowData={index:index,source:row,expectedLength:expectedColumnsLength,actualLength:columns.length},columns.length===expectedColumnsLength?(rowResult="number"==typeof $scope.ngPasteFromColumns?columns:$scope.columnsToObject(columns),"function"!=typeof $scope.ngPasteFromOnValidate||$scope.ngPasteFromOnValidate(rowResult,rowData)?("function"==typeof $scope.ngPasteFromAfterParseRow&&(rowResult=$scope.ngPasteFromAfterParseRow(rowResult(rowData))),result.push(rowResult)):"function"==typeof $scope.ngPasteFromOnError&&$scope.ngPasteFromOnError(ngPasteFromErrors.failedValidation,rowData)):"function"==typeof $scope.ngPasteFromOnError&&$scope.ngPasteFromOnError(ngPasteFromErrors.invalidColumnLength,rowData));return"function"==typeof $scope.ngPasteFromBeforeApply&&$scope.ngPasteFromBeforeApply(result),$scope.$apply(function(){return $scope.ngPasteFrom=result})}}}}})}).call(this); +(function(){angular.module("ngPasteFrom",[]).constant("ngPasteFromErrors",{invalidColumnLength:"NGPASTEFROM_INVALID_COLUMN_LENGTH",failedValidation:"NGPASTEFROM_FAILED_VALIDATION"}).constant("ngPasteFromSeparators",{row:/\r\n|\n\r|\n|\r/g,column:" "}).directive("ngPasteFrom",function(){return{restrict:"A",scope:{ngPasteFrom:"=",ngPasteFromColumns:"=",ngPasteFromRowSeparator:"=",ngPasteFromColumnSeparator:"=",ngPasteFromPasteOnly:"=",ngPasteFromBeforeParse:"=",ngPasteFromAfterParseRow:"=",ngPasteFromOnValidate:"=",ngPasteFromBeforeApply:"=",ngPasteFromOnError:"="},link:function($scope,element){return null==$scope.ngPasteFromColumns&&console.error("Missing required attribute ngPasteFromColumns."),$scope.pasteEvent=function(event){var data,ref;return null!=event.clipboardData&&null!=event.clipboardData.getData?data=event.clipboardData.getData("text/plain"):null!=event.originalEvent&&null!=event.originalEvent.clipboardData&&null!=event.originalEvent.clipboardData.getData?data=event.originalEvent.clipboardData.getData("text/plain"):null!=window.clipboardData&&null!=window.clipboardData.getData&&(data=window.clipboardData.getData("Text")),"function"==typeof $scope.ngPasteFromBeforeParse&&(data=$scope.ngPasteFromBeforeParse(data)),$scope.processPasteData(data),(null!=(ref=$scope.ngPasteFromPasteOnly)?ref:!0)?event.preventDefault():void 0},$scope.changeEvent=function(){var data,ref;return(null!=(ref=$scope.ngPasteFromPasteOnly)?ref:!0)?element.val(""):(data=element.val(),"function"==typeof $scope.ngPasteFromBeforeParse&&(data=$scope.ngPasteFromBeforeParse(data)),$scope.processPasteData(data))},element.on("paste",$scope.pasteEvent),element.on("keyup",$scope.changeEvent),element.on("change",$scope.changeEvent)},controller:function($scope,$filter,ngPasteFromErrors,ngPasteFromSeparators){return $scope.columnsToObject=function(columns){var column,format,i,index,len,obj;for(obj={},format=$scope.ngPasteFromColumns,index=i=0,len=columns.length;len>i;index=++i)column=columns[index],obj[format[index]]=column;return obj},$scope.getExpectedColumnsLength=function(){return"number"==typeof $scope.ngPasteFromColumns?$scope.ngPasteFromColumns:$scope.ngPasteFromColumns.length},$scope.processPasteData=function(data){var columns,expectedColumnsLength,i,index,len,ref,ref1,result,row,rowData,rowResult,rows;if(data&&data.length){for(rows=data.split(null!=(ref=$scope.ngPasteFromRowSeparator)?ref:ngPasteFromSeparators.row),result=[],expectedColumnsLength=$scope.getExpectedColumnsLength(),index=i=0,len=rows.length;len>i;index=++i)row=rows[index],""!==row&&(columns=row.split(null!=(ref1=$scope.ngPasteFromColumnSeparator)?ref1:ngPasteFromSeparators.column),rowData={index:index,source:row,expectedLength:expectedColumnsLength,actualLength:columns.length},columns.length===expectedColumnsLength?(rowResult="number"==typeof $scope.ngPasteFromColumns?columns:$scope.columnsToObject(columns),"function"!=typeof $scope.ngPasteFromOnValidate||$scope.ngPasteFromOnValidate(rowResult,rowData)?("function"==typeof $scope.ngPasteFromAfterParseRow&&(rowResult=$scope.ngPasteFromAfterParseRow(rowResult,rowData)),result.push(rowResult)):"function"==typeof $scope.ngPasteFromOnError&&$scope.ngPasteFromOnError(ngPasteFromErrors.failedValidation,rowData)):"function"==typeof $scope.ngPasteFromOnError&&$scope.ngPasteFromOnError(ngPasteFromErrors.invalidColumnLength,rowData));return"function"==typeof $scope.ngPasteFromBeforeApply&&$scope.ngPasteFromBeforeApply(result),$scope.$apply(function(){return $scope.ngPasteFrom=result})}}}}})}).call(this); //# sourceMappingURL=ng-paste-from-latest.min.js.map \ No newline at end of file diff --git a/dist/ng-paste-from-latest.min.js.map b/dist/ng-paste-from-latest.min.js.map index 33e7761..971d536 100755 --- a/dist/ng-paste-from-latest.min.js.map +++ b/dist/ng-paste-from-latest.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["ng-paste-from.coffee","ng-paste-from.js"],"names":["angular","module","constant","invalidColumnLength","failedValidation","row","column","directive","restrict","scope","ngPasteFrom","ngPasteFromColumns","ngPasteFromRowSeparator","ngPasteFromColumnSeparator","ngPasteFromPasteOnly","ngPasteFromBeforeParse","ngPasteFromAfterParseRow","ngPasteFromOnValidate","ngPasteFromBeforeApply","ngPasteFromOnError","link","$scope","element","console","error","pasteEvent","event","data","ref","clipboardData","getData","originalEvent","window","processPasteData","preventDefault","changeEvent","val","on","controller","$filter","ngPasteFromErrors","ngPasteFromSeparators","columnsToObject","columns","format","i","index","len","obj","length","getExpectedColumnsLength","expectedColumnsLength","ref1","result","rowData","rowResult","rows","split","source","expectedLength","actualLength","push","$apply","call","this"],"mappings":"CAAA,WAAAA,QAAQC,OAAO,kBACbC,SAAS,qBACTC,oBAAqB,oCACrBC,iBAAkB,kCAElBF,SAAS,yBACTG,IAAK,mBACLC,OAAQ,MAERC,UAAU,cAAe,WCDvB,ODEFC,SAAU,IACVC,OACCC,YAAa,IACbC,mBAAoB,IACpBC,wBAAyB,IACzBC,2BAA4B,IAC5BC,qBAAsB,IACtBC,uBAAwB,IACxBC,yBAA0B,IAC1BC,sBAAuB,IACvBC,uBAAwB,IACxBC,mBAAoB,KAErBC,KAAM,SAACC,OAAQC,SCkCT,MDjCE,OAAAD,OAAAV,oBACNY,QAAQC,MAAM,kDAEfH,OAAOI,WAAa,SAACC,OACpB,GAAAC,MAAAC,GAUA,OAVG,OAAAF,MAAAG,eAAwB,MAAAH,MAAAG,cAAAC,QAC1BH,KAAOD,MAAMG,cAAcC,QAAQ,cAC5B,MAAAJ,MAAAK,eAAwB,MAAAL,MAAAK,cAAAF,eAAsC,MAAAH,MAAAK,cAAAF,cAAAC,QACrEH,KAAOD,MAAMK,cAAcF,cAAcC,QAAQ,cAC1C,MAAAE,OAAAH,eAAyB,MAAAG,OAAAH,cAAAC,UAChCH,KAAOK,OAAOH,cAAcC,QAAQ,SAEM,kBAAjCT,QAAON,yBAChBY,KAAON,OAAON,uBAAuBY,OACtCN,OAAOY,iBAAiBN,OACxB,OAAAC,IAAAP,OAAAP,sBAAAc,KAAiC,GAChCF,MAAMQ,iBADP,QAGDb,OAAOc,YAAc,WACpB,GAAAR,MAA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,eAAgBR,sBAChBS,aAAcjB,QAAQM,QAEpBN,QAAQM,SAAYE,uBAMtBI,UADsC,gBAA7BlC,QAAOV,mBACJgC,QAEAtB,OAAOqB,gBAAgBC,SAEQ,kBAAlCtB,QAAOJ,uBAAyCI,OAAOJ,sBAAsBsC,UAAWD,UACpD,kBAAnCjC,QAAOL,2BAChBuC,UAAYlC,OAAOL,yBAAyBuC,UAAUD,WAEvDD,OAAOQ,KAAKN,YAC+B,kBAA7BlC,QAAOF,oBACrBE,OAAOF,mBAAmBqB,kBAAkBpC,iBAAkBkD,UAfvB,kBAA7BjC,QAAOF,oBAChBE,OAAOF,mBAAmBqB,kBAAkBrC,oBAAqBmD,SC8B9D,ODdqC,kBAAjCjC,QAAOH,wBAChBG,OAAOH,uBAAuBmC,QAE/BhC,OAAOyC,OAAO,WCYN,MDXPzC,QAAOX,YAAc2C,iBCkBvBU,KAAKC","file":"ng-paste-from-latest.min.js","sourcesContent":["angular.module \"ngPasteFrom\", []\n\t.constant \"ngPasteFromErrors\",\n\t\tinvalidColumnLength: \"NGPASTEFROM_INVALID_COLUMN_LENGTH\"\n\t\tfailedValidation: \"NGPASTEFROM_FAILED_VALIDATION\"\n\n\t.constant \"ngPasteFromSeparators\",\n\t\trow: /\\r\\n|\\n\\r|\\n|\\r/g\n\t\tcolumn: \"\\t\"\n\n\t.directive \"ngPasteFrom\", ->\n\t\trestrict: \"A\"\n\t\tscope: \n\t\t\tngPasteFrom: \"=\"\n\t\t\tngPasteFromColumns: \"=\"\n\t\t\tngPasteFromRowSeparator: \"=\"\n\t\t\tngPasteFromColumnSeparator: \"=\"\n\t\t\tngPasteFromPasteOnly: \"=\"\n\t\t\tngPasteFromBeforeParse: \"=\"\n\t\t\tngPasteFromAfterParseRow: \"=\"\n\t\t\tngPasteFromOnValidate: \"=\"\n\t\t\tngPasteFromBeforeApply: \"=\"\n\t\t\tngPasteFromOnError: \"=\"\n\n\t\tlink: ($scope, element, attrs) ->\n\t\t\tif not $scope.ngPasteFromColumns?\n\t\t\t\tconsole.error \"Missing required attribute ngPasteFromColumns.\"\n\n\t\t\t$scope.pasteEvent = (event) ->\n\t\t\t\tif event.clipboardData? && event.clipboardData.getData? # Standard\n\t\t\t\t\tdata = event.clipboardData.getData \"text/plain\"\n\t\t\t\telse if event.originalEvent? && event.originalEvent.clipboardData? && event.originalEvent.clipboardData.getData? # jQuery\n\t\t\t\t\tdata = event.originalEvent.clipboardData.getData \"text/plain\"\n\t\t\t\telse if window.clipboardData? && window.clipboardData.getData? # Internet Explorer\n\t\t\t\t\tdata = window.clipboardData.getData \"Text\"\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t$scope.processPasteData data\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\tevent.preventDefault()\n\n\t\t\t$scope.changeEvent = ->\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\telement.val \"\"\n\t\t\t\telse\n\t\t\t\t\tdata = element.val()\n\t\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t\t$scope.processPasteData data\n\n\t\t\telement.on \"paste\", $scope.pasteEvent\n\t\t\telement.on \"keyup\", $scope.changeEvent\n\t\t\telement.on \"change\", $scope.changeEvent\n\n\t\tcontroller: ($scope, $filter, ngPasteFromErrors, ngPasteFromSeparators) ->\n\t\t\t$scope.columnsToObject = (columns) ->\n\t\t\t\tobj = {}\n\t\t\t\tformat = $scope.ngPasteFromColumns\n\t\t\t\tfor column, index in columns\n\t\t\t\t\tobj[format[index]] = column\n\t\t\t\tobj\n\n\t\t\t$scope.getExpectedColumnsLength = ->\n\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t$scope.ngPasteFromColumns\n\t\t\t\telse\n\t\t\t\t\t$scope.ngPasteFromColumns.length\n\n\t\t\t$scope.processPasteData = (data) ->\n\t\t\t\tif not (data and data.length)\n\t\t\t\t\treturn\n\n\t\t\t\trows = data.split $scope.ngPasteFromRowSeparator ? ngPasteFromSeparators.row\n\t\t\t\tresult = []\n\t\t\t\texpectedColumnsLength = $scope.getExpectedColumnsLength()\n\n\t\t\t\tfor row, index in rows\n\t\t\t\t\tif row is \"\"\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tcolumns = row.split $scope.ngPasteFromColumnSeparator ? ngPasteFromSeparators.column\n\n\t\t\t\t\trowData =\n\t\t\t\t\t\tindex: index\n\t\t\t\t\t\tsource: row\n\t\t\t\t\t\texpectedLength: expectedColumnsLength\n\t\t\t\t\t\tactualLength: columns.length\n\n\t\t\t\t\tif columns.length isnt expectedColumnsLength\n\t\t\t\t\t\tif typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.invalidColumnLength, rowData\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t\trowResult = columns\n\t\t\t\t\telse\n\t\t\t\t\t\trowResult = $scope.columnsToObject columns\n\n\t\t\t\t\tif typeof $scope.ngPasteFromOnValidate isnt \"function\" or $scope.ngPasteFromOnValidate rowResult, rowData\n\t\t\t\t\t\tif typeof $scope.ngPasteFromAfterParseRow is \"function\"\n\t\t\t\t\t\t\trowResult = $scope.ngPasteFromAfterParseRow rowResult rowData\n\n\t\t\t\t\t\tresult.push rowResult\n\t\t\t\t\telse if typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.failedValidation, rowData\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeApply is \"function\"\n\t\t\t\t\t$scope.ngPasteFromBeforeApply result\n\n\t\t\t\t$scope.$apply ->\n\t\t\t\t\t$scope.ngPasteFrom = result\n",null],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["ng-paste-from.coffee","ng-paste-from.js"],"names":["angular","module","constant","invalidColumnLength","failedValidation","row","column","directive","restrict","scope","ngPasteFrom","ngPasteFromColumns","ngPasteFromRowSeparator","ngPasteFromColumnSeparator","ngPasteFromPasteOnly","ngPasteFromBeforeParse","ngPasteFromAfterParseRow","ngPasteFromOnValidate","ngPasteFromBeforeApply","ngPasteFromOnError","link","$scope","element","console","error","pasteEvent","event","data","ref","clipboardData","getData","originalEvent","window","processPasteData","preventDefault","changeEvent","val","on","controller","$filter","ngPasteFromErrors","ngPasteFromSeparators","columnsToObject","columns","format","i","index","len","obj","length","getExpectedColumnsLength","expectedColumnsLength","ref1","result","rowData","rowResult","rows","split","source","expectedLength","actualLength","push","$apply","call","this"],"mappings":"CAAA,WAAAA,QAAQC,OAAO,kBACbC,SAAS,qBACTC,oBAAqB,oCACrBC,iBAAkB,kCAElBF,SAAS,yBACTG,IAAK,mBACLC,OAAQ,MAERC,UAAU,cAAe,WCDvB,ODEFC,SAAU,IACVC,OACCC,YAAa,IACbC,mBAAoB,IACpBC,wBAAyB,IACzBC,2BAA4B,IAC5BC,qBAAsB,IACtBC,uBAAwB,IACxBC,yBAA0B,IAC1BC,sBAAuB,IACvBC,uBAAwB,IACxBC,mBAAoB,KAErBC,KAAM,SAACC,OAAQC,SCkCT,MDjCE,OAAAD,OAAAV,oBACNY,QAAQC,MAAM,kDAEfH,OAAOI,WAAa,SAACC,OACpB,GAAAC,MAAAC,GAUA,OAVG,OAAAF,MAAAG,eAAwB,MAAAH,MAAAG,cAAAC,QAC1BH,KAAOD,MAAMG,cAAcC,QAAQ,cAC5B,MAAAJ,MAAAK,eAAwB,MAAAL,MAAAK,cAAAF,eAAsC,MAAAH,MAAAK,cAAAF,cAAAC,QACrEH,KAAOD,MAAMK,cAAcF,cAAcC,QAAQ,cAC1C,MAAAE,OAAAH,eAAyB,MAAAG,OAAAH,cAAAC,UAChCH,KAAOK,OAAOH,cAAcC,QAAQ,SAEM,kBAAj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ECUQxC,IAAMmD,KAAKV,ODTR,KAAPzC,MAGHsC,QAAUtC,IAAIoD,MAAJ,OAAAL,KAAA/B,OAAAR,4BAAAuC,KAA8CX,sBAAsBnC,QAE9EgD,SACCR,MAAOA,MACPY,OAAQrD,IACRsD,eAAgBR,sBAChBS,aAAcjB,QAAQM,QAEpBN,QAAQM,SAAYE,uBAMtBI,UADsC,gBAA7BlC,QAAOV,mBACJgC,QAEAtB,OAAOqB,gBAAgBC,SAEQ,kBAAlCtB,QAAOJ,uBAAyCI,OAAOJ,sBAAsBsC,UAAWD,UACpD,kBAAnCjC,QAAOL,2BAChBuC,UAAYlC,OAAOL,yBAAyBuC,UAAWD,UAExDD,OAAOQ,KAAKN,YAC+B,kBAA7BlC,QAAOF,oBACrBE,OAAOF,mBAAmBqB,kBAAkBpC,iBAAkBkD,UAfvB,kBAA7BjC,QAAOF,oBAChBE,OAAOF,mBAAmBqB,kBAAkBrC,oBAAqBmD,SC8B9D,ODdqC,kBAAjCjC,QAAOH,wBAChBG,OAAOH,uBAAuBmC,QAE/BhC,OAAOyC,OAAO,WCYN,MDXPzC,QAAOX,YAAc2C,iBCkBvBU,KAAKC","file":"ng-paste-from-latest.min.js","sourcesContent":["angular.module \"ngPasteFrom\", []\n\t.constant \"ngPasteFromErrors\",\n\t\tinvalidColumnLength: \"NGPASTEFROM_INVALID_COLUMN_LENGTH\"\n\t\tfailedValidation: \"NGPASTEFROM_FAILED_VALIDATION\"\n\n\t.constant \"ngPasteFromSeparators\",\n\t\trow: /\\r\\n|\\n\\r|\\n|\\r/g\n\t\tcolumn: \"\\t\"\n\n\t.directive \"ngPasteFrom\", ->\n\t\trestrict: \"A\"\n\t\tscope: \n\t\t\tngPasteFrom: \"=\"\n\t\t\tngPasteFromColumns: \"=\"\n\t\t\tngPasteFromRowSeparator: \"=\"\n\t\t\tngPasteFromColumnSeparator: \"=\"\n\t\t\tngPasteFromPasteOnly: \"=\"\n\t\t\tngPasteFromBeforeParse: \"=\"\n\t\t\tngPasteFromAfterParseRow: \"=\"\n\t\t\tngPasteFromOnValidate: \"=\"\n\t\t\tngPasteFromBeforeApply: \"=\"\n\t\t\tngPasteFromOnError: \"=\"\n\n\t\tlink: ($scope, element, attrs) ->\n\t\t\tif not $scope.ngPasteFromColumns?\n\t\t\t\tconsole.error \"Missing required attribute ngPasteFromColumns.\"\n\n\t\t\t$scope.pasteEvent = (event) ->\n\t\t\t\tif event.clipboardData? && event.clipboardData.getData? # Standard\n\t\t\t\t\tdata = event.clipboardData.getData \"text/plain\"\n\t\t\t\telse if event.originalEvent? && event.originalEvent.clipboardData? && event.originalEvent.clipboardData.getData? # jQuery\n\t\t\t\t\tdata = event.originalEvent.clipboardData.getData \"text/plain\"\n\t\t\t\telse if window.clipboardData? && window.clipboardData.getData? # Internet Explorer\n\t\t\t\t\tdata = window.clipboardData.getData \"Text\"\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t$scope.processPasteData data\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\tevent.preventDefault()\n\n\t\t\t$scope.changeEvent = ->\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\telement.val \"\"\n\t\t\t\telse\n\t\t\t\t\tdata = element.val()\n\t\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t\t$scope.processPasteData data\n\n\t\t\telement.on \"paste\", $scope.pasteEvent\n\t\t\telement.on \"keyup\", $scope.changeEvent\n\t\t\telement.on \"change\", $scope.changeEvent\n\n\t\tcontroller: ($scope, $filter, ngPasteFromErrors, ngPasteFromSeparators) ->\n\t\t\t$scope.columnsToObject = (columns) ->\n\t\t\t\tobj = {}\n\t\t\t\tformat = $scope.ngPasteFromColumns\n\t\t\t\tfor column, index in columns\n\t\t\t\t\tobj[format[index]] = column\n\t\t\t\tobj\n\n\t\t\t$scope.getExpectedColumnsLength = ->\n\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t$scope.ngPasteFromColumns\n\t\t\t\telse\n\t\t\t\t\t$scope.ngPasteFromColumns.length\n\n\t\t\t$scope.processPasteData = (data) ->\n\t\t\t\tif not (data and data.length)\n\t\t\t\t\treturn\n\n\t\t\t\trows = data.split $scope.ngPasteFromRowSeparator ? ngPasteFromSeparators.row\n\t\t\t\tresult = []\n\t\t\t\texpectedColumnsLength = $scope.getExpectedColumnsLength()\n\n\t\t\t\tfor row, index in rows\n\t\t\t\t\tif row is \"\"\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tcolumns = row.split $scope.ngPasteFromColumnSeparator ? ngPasteFromSeparators.column\n\n\t\t\t\t\trowData =\n\t\t\t\t\t\tindex: index\n\t\t\t\t\t\tsource: row\n\t\t\t\t\t\texpectedLength: expectedColumnsLength\n\t\t\t\t\t\tactualLength: columns.length\n\n\t\t\t\t\tif columns.length isnt expectedColumnsLength\n\t\t\t\t\t\tif typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.invalidColumnLength, rowData\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t\trowResult = columns\n\t\t\t\t\telse\n\t\t\t\t\t\trowResult = $scope.columnsToObject columns\n\n\t\t\t\t\tif typeof $scope.ngPasteFromOnValidate isnt \"function\" or $scope.ngPasteFromOnValidate rowResult, rowData\n\t\t\t\t\t\tif typeof $scope.ngPasteFromAfterParseRow is \"function\"\n\t\t\t\t\t\t\trowResult = $scope.ngPasteFromAfterParseRow rowResult, rowData\n\n\t\t\t\t\t\tresult.push rowResult\n\t\t\t\t\telse if typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.failedValidation, rowData\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeApply is \"function\"\n\t\t\t\t\t$scope.ngPasteFromBeforeApply result\n\n\t\t\t\t$scope.$apply ->\n\t\t\t\t\t$scope.ngPasteFrom = result\n",null],"sourceRoot":"/source/"} \ No newline at end of file From 4b6addb221d21837a351907aa5981b0686ecff54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikko=20Ka=CC=88rkka=CC=88inen?= Date: Wed, 20 Apr 2016 10:52:48 +0300 Subject: [PATCH 5/5] Enable bypassing column count check --- dist/ng-paste-from-latest.js | 3 ++- dist/ng-paste-from-latest.js.map | 2 +- dist/ng-paste-from-latest.min.js | 2 +- dist/ng-paste-from-latest.min.js.map | 2 +- src/ng-paste-from.coffee | 3 ++- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dist/ng-paste-from-latest.js b/dist/ng-paste-from-latest.js index af49488..a195718 100644 --- a/dist/ng-paste-from-latest.js +++ b/dist/ng-paste-from-latest.js @@ -11,6 +11,7 @@ scope: { ngPasteFrom: "=", ngPasteFromColumns: "=", + ngPasteFromEnforceColumnCount: "=", ngPasteFromRowSeparator: "=", ngPasteFromColumnSeparator: "=", ngPasteFromPasteOnly: "=", @@ -95,7 +96,7 @@ expectedLength: expectedColumnsLength, actualLength: columns.length }; - if (columns.length !== expectedColumnsLength) { + if ($scope.ngPasteFromEnforceColumnCount && columns.length !== expectedColumnsLength) { if (typeof $scope.ngPasteFromOnError === "function") { $scope.ngPasteFromOnError(ngPasteFromErrors.invalidColumnLength, rowData); } diff --git a/dist/ng-paste-from-latest.js.map b/dist/ng-paste-from-latest.js.map index 7cacb5d..6d27b12 100755 --- a/dist/ng-paste-from-latest.js.map +++ b/dist/ng-paste-from-latest.js.map @@ -1 +1 @@ -{"version":3,"sources":["ng-paste-from.coffee"],"names":[],"mappings":"AAAA;EAAA,OAAO,CAAC,MAAR,CAAe,aAAf,EAA8B,EAA9B,CACC,CAAC,QADF,CACW,mBADX,EAEE;IAAA,mBAAA,EAAq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ourceRoot":"/source/","sourcesContent":["angular.module \"ngPasteFrom\", []\n\t.constant \"ngPasteFromErrors\",\n\t\tinvalidColumnLength: \"NGPASTEFROM_INVALID_COLUMN_LENGTH\"\n\t\tfailedValidation: \"NGPASTEFROM_FAILED_VALIDATION\"\n\n\t.constant \"ngPasteFromSeparators\",\n\t\trow: /\\r\\n|\\n\\r|\\n|\\r/g\n\t\tcolumn: \"\\t\"\n\n\t.directive \"ngPasteFrom\", ->\n\t\trestrict: \"A\"\n\t\tscope: \n\t\t\tngPasteFrom: \"=\"\n\t\t\tngPasteFromColumns: \"=\"\n\t\t\tngPasteFromRowSeparator: \"=\"\n\t\t\tngPasteFromColumnSeparator: \"=\"\n\t\t\tngPasteFromPasteOnly: \"=\"\n\t\t\tngPasteFromBeforeParse: \"=\"\n\t\t\tngPasteFromAfterParseRow: \"=\"\n\t\t\tngPasteFromOnValidate: \"=\"\n\t\t\tngPasteFromBeforeApply: \"=\"\n\t\t\tngPasteFromOnError: \"=\"\n\n\t\tlink: ($scope, element, attrs) ->\n\t\t\tif not $scope.ngPasteFromColumns?\n\t\t\t\tconsole.error \"Missing required attribute ngPasteFromColumns.\"\n\n\t\t\t$scope.pasteEvent = (event) ->\n\t\t\t\tif event.clipboardData? && event.clipboardData.getData? # Standard\n\t\t\t\t\tdata = event.clipboardData.getData \"text/plain\"\n\t\t\t\telse if event.originalEvent? && event.originalEvent.clipboardData? && event.originalEvent.clipboardData.getData? # jQuery\n\t\t\t\t\tdata = event.originalEvent.clipboardData.getData \"text/plain\"\n\t\t\t\telse if window.clipboardData? && window.clipboardData.getData? # Internet Explorer\n\t\t\t\t\tdata = window.clipboardData.getData \"Text\"\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t$scope.processPasteData data\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\tevent.preventDefault()\n\n\t\t\t$scope.changeEvent = ->\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\telement.val \"\"\n\t\t\t\telse\n\t\t\t\t\tdata = element.val()\n\t\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t\t$scope.processPasteData data\n\n\t\t\telement.on \"paste\", $scope.pasteEvent\n\t\t\telement.on \"keyup\", $scope.changeEvent\n\t\t\telement.on \"change\", $scope.changeEvent\n\n\t\tcontroller: ($scope, $filter, ngPasteFromErrors, ngPasteFromSeparators) ->\n\t\t\t$scope.columnsToObject = (columns) ->\n\t\t\t\tobj = {}\n\t\t\t\tformat = $scope.ngPasteFromColumns\n\t\t\t\tfor column, index in columns\n\t\t\t\t\tobj[format[index]] = column\n\t\t\t\tobj\n\n\t\t\t$scope.getExpectedColumnsLength = ->\n\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t$scope.ngPasteFromColumns\n\t\t\t\telse\n\t\t\t\t\t$scope.ngPasteFromColumns.length\n\n\t\t\t$scope.processPasteData = (data) ->\n\t\t\t\tif not (data and data.length)\n\t\t\t\t\treturn\n\n\t\t\t\trows = data.split $scope.ngPasteFromRowSeparator ? ngPasteFromSeparators.row\n\t\t\t\tresult = []\n\t\t\t\texpectedColumnsLength = $scope.getExpectedColumnsLength()\n\n\t\t\t\tfor row, index in rows\n\t\t\t\t\tif row is \"\"\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tcolumns = row.split $scope.ngPasteFromColumnSeparator ? ngPasteFromSeparators.column\n\n\t\t\t\t\trowData =\n\t\t\t\t\t\tindex: index\n\t\t\t\t\t\tsource: row\n\t\t\t\t\t\texpectedLength: expectedColumnsLength\n\t\t\t\t\t\tactualLength: columns.length\n\n\t\t\t\t\tif columns.length isnt expectedColumnsLength\n\t\t\t\t\t\tif typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.invalidColumnLength, rowData\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t\trowResult = columns\n\t\t\t\t\telse\n\t\t\t\t\t\trowResult = $scope.columnsToObject columns\n\n\t\t\t\t\tif typeof $scope.ngPasteFromOnValidate isnt \"function\" or $scope.ngPasteFromOnValidate rowResult, rowData\n\t\t\t\t\t\tif typeof $scope.ngPasteFromAfterParseRow is \"function\"\n\t\t\t\t\t\t\trowResult = $scope.ngPasteFromAfterParseRow rowResult, rowData\n\n\t\t\t\t\t\tresult.push rowResult\n\t\t\t\t\telse if typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.failedValidation, rowData\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeApply is \"function\"\n\t\t\t\t\t$scope.ngPasteFromBeforeApply result\n\n\t\t\t\t$scope.$apply ->\n\t\t\t\t\t$scope.ngPasteFrom = result\n"]} \ No newline at end of file +{"version":3,"sources":["ng-paste-from.coffee"],"names":[],"mappings":"AAAA;EAAA,OAAO,CAAC,MAAR,CAAe,aAAf,EAA8B,EAA9B,CACC,CAAC,QADF,CACW,mBADX,EAEE;IAAA,mBAAA,EAAqB,mCAArB;IACA,gBAAA,EAAkB,+BADlB;GAFF,CAKC,CAAC,QALF,CAKW,uBALX,EAME;IAAA,GAAA,EAAK,kBAAL;IACA,MAAA,EAAQ,IADR;GANF,CASC,CAAC,SATF,CASY,aATZ,EAS2B,SAAA;WACzB;MAAA,QAAA,EAAU,GAAV;MACA,KAAA,EACC;QAAA,WAAA,EAAa,GAAb;QACA,kBAAA,EAAoB,GADpB;QAEA,6BAAA,EAA+B,GAF/B;QAGA,uBAAA,EAAyB,GAHzB;QAIA,0BAAA,EAA4B,GAJ5B;QAKA,oBAAA,EAAsB,GALtB;QAMA,sBAAA,EAAwB,GANxB;QAOA,wBAAA,EAA0B,GAP1B;QAQA,q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C,mBAA5C,EAAiE,OAAjE,EADD;;AAEA,uBAHD;;YAKA,IAAG,OAAO,MAAM,CAAC,kBAAd,KAAoC,QAAvC;cACC,SAAA,GAAY,QADb;aAAA,MAAA;cAGC,SAAA,GAAY,MAAM,CAAC,eAAP,CAAuB,OAAvB,EAHb;;YAKA,IAAG,OAAO,MAAM,CAAC,qBAAd,KAAyC,UAAzC,IAAuD,MAAM,CAAC,qBAAP,CAA6B,SAA7B,EAAwC,OAAxC,CAA1D;cACC,IAAG,OAAO,MAAM,CAAC,wBAAd,KAA0C,UAA7C;gBACC,SAAA,GAAY,MAAM,CAAC,wBAAP,CAAgC,SAAhC,EAA2C,OAA3C,EADb;;cAGA,MAAM,CAAC,IAAP,CAAY,SAAZ,EAJD;aAAA,MAKK,IAAG,OAAO,MAAM,CAAC,kBAAd,KAAoC,UAAvC;cACJ,MAAM,CAAC,kBAAP,CAA0B,iBAAiB,CAAC,gBAA5C,EAA8D,OAA9D,EADI;;AA3BN;UA8BA,IAAG,OAAO,MAAM,CAAC,sBAAd,KAAwC,UAA3C;YACC,MAAM,CAAC,sBAAP,CAA8B,MAA9B,EADD;;iBAGA,MAAM,CAAC,MAAP,CAAc,SAAA;mBACb,MAAM,CAAC,WAAP,GAAqB;UADR,CAAd;QAzCyB;MAdf,CA7CZ;;EADyB,CAT3B;AAAA","file":"ng-paste-from-latest.js","sourceRoot":"/source/","sourcesContent":["angular.module \"ngPasteFrom\", []\n\t.constant \"ngPasteFromErrors\",\n\t\tinvalidColumnLength: \"NGPASTEFROM_INVALID_COLUMN_LENGTH\"\n\t\tfailedValidation: \"NGPASTEFROM_FAILED_VALIDATION\"\n\n\t.constant \"ngPasteFromSeparators\",\n\t\trow: /\\r\\n|\\n\\r|\\n|\\r/g\n\t\tcolumn: \"\\t\"\n\n\t.directive \"ngPasteFrom\", ->\n\t\trestrict: \"A\"\n\t\tscope: \n\t\t\tngPasteFrom: \"=\"\n\t\t\tngPasteFromColumns: \"=\"\n\t\t\tngPasteFromEnforceColumnCount: \"=\"\n\t\t\tngPasteFromRowSeparator: \"=\"\n\t\t\tngPasteFromColumnSeparator: \"=\"\n\t\t\tngPasteFromPasteOnly: \"=\"\n\t\t\tngPasteFromBeforeParse: \"=\"\n\t\t\tngPasteFromAfterParseRow: \"=\"\n\t\t\tngPasteFromOnValidate: \"=\"\n\t\t\tngPasteFromBeforeApply: \"=\"\n\t\t\tngPasteFromOnError: \"=\"\n\n\t\tlink: ($scope, element, attrs) ->\n\t\t\tif not $scope.ngPasteFromColumns?\n\t\t\t\tconsole.error \"Missing required attribute ngPasteFromColumns.\"\n\n\t\t\t$scope.pasteEvent = (event) ->\n\t\t\t\tif event.clipboardData? && event.clipboardData.getData? # Standard\n\t\t\t\t\tdata = event.clipboardData.getData \"text/plain\"\n\t\t\t\telse if event.originalEvent? && event.originalEvent.clipboardData? && event.originalEvent.clipboardData.getData? # jQuery\n\t\t\t\t\tdata = event.originalEvent.clipboardData.getData \"text/plain\"\n\t\t\t\telse if window.clipboardData? && window.clipboardData.getData? # Internet Explorer\n\t\t\t\t\tdata = window.clipboardData.getData \"Text\"\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t$scope.processPasteData data\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\tevent.preventDefault()\n\n\t\t\t$scope.changeEvent = ->\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\telement.val \"\"\n\t\t\t\telse\n\t\t\t\t\tdata = element.val()\n\t\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t\t$scope.processPasteData data\n\n\t\t\telement.on \"paste\", $scope.pasteEvent\n\t\t\telement.on \"keyup\", $scope.changeEvent\n\t\t\telement.on \"change\", $scope.changeEvent\n\n\t\tcontroller: ($scope, $filter, ngPasteFromErrors, ngPasteFromSeparators) ->\n\t\t\t$scope.columnsToObject = (columns) ->\n\t\t\t\tobj = {}\n\t\t\t\tformat = $scope.ngPasteFromColumns\n\t\t\t\tfor column, index in columns\n\t\t\t\t\tobj[format[index]] = column\n\t\t\t\tobj\n\n\t\t\t$scope.getExpectedColumnsLength = ->\n\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t$scope.ngPasteFromColumns\n\t\t\t\telse\n\t\t\t\t\t$scope.ngPasteFromColumns.length\n\n\t\t\t$scope.processPasteData = (data) ->\n\t\t\t\tif not (data and data.length)\n\t\t\t\t\treturn\n\n\t\t\t\trows = data.split $scope.ngPasteFromRowSeparator ? ngPasteFromSeparators.row\n\t\t\t\tresult = []\n\t\t\t\texpectedColumnsLength = $scope.getExpectedColumnsLength()\n\n\t\t\t\tfor row, index in rows\n\t\t\t\t\tif row is \"\"\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tcolumns = row.split $scope.ngPasteFromColumnSeparator ? ngPasteFromSeparators.column\n\n\t\t\t\t\trowData =\n\t\t\t\t\t\tindex: index\n\t\t\t\t\t\tsource: row\n\t\t\t\t\t\texpectedLength: expectedColumnsLength\n\t\t\t\t\t\tactualLength: columns.length\n\n\t\t\t\t\tif $scope.ngPasteFromEnforceColumnCount && columns.length isnt expectedColumnsLength\n\t\t\t\t\t\tif typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.invalidColumnLength, rowData\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t\trowResult = columns\n\t\t\t\t\telse\n\t\t\t\t\t\trowResult = $scope.columnsToObject columns\n\n\t\t\t\t\tif typeof $scope.ngPasteFromOnValidate isnt \"function\" or $scope.ngPasteFromOnValidate rowResult, rowData\n\t\t\t\t\t\tif typeof $scope.ngPasteFromAfterParseRow is \"function\"\n\t\t\t\t\t\t\trowResult = $scope.ngPasteFromAfterParseRow rowResult, rowData\n\n\t\t\t\t\t\tresult.push rowResult\n\t\t\t\t\telse if typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.failedValidation, rowData\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeApply is \"function\"\n\t\t\t\t\t$scope.ngPasteFromBeforeApply result\n\n\t\t\t\t$scope.$apply ->\n\t\t\t\t\t$scope.ngPasteFrom = result\n"]} \ No newline at end of file diff --git a/dist/ng-paste-from-latest.min.js b/dist/ng-paste-from-latest.min.js index 9e6cf38..9d99a8a 100644 --- a/dist/ng-paste-from-latest.min.js +++ b/dist/ng-paste-from-latest.min.js @@ -1,2 +1,2 @@ -(function(){angular.module("ngPasteFrom",[]).constant("ngPasteFromErrors",{invalidColumnLength:"NGPASTEFROM_INVALID_COLUMN_LENGTH",failedValidation:"NGPASTEFROM_FAILED_VALIDATION"}).constant("ngPasteFromSeparators",{row:/\r\n|\n\r|\n|\r/g,column:" "}).directive("ngPasteFrom",function(){return{restrict:"A",scope:{ngPasteFrom:"=",ngPasteFromColumns:"=",ngPasteFromRowSeparator:"=",ngPasteFromColumnSeparator:"=",ngPasteFromPasteOnly:"=",ngPasteFromBeforeParse:"=",ngPasteFromAfterParseRow:"=",ngPasteFromOnValidate:"=",ngPasteFromBeforeApply:"=",ngPasteFromOnError:"="},link:function($scope,element){return null==$scope.ngPasteFromColumns&&console.error("Missing required attribute ngPasteFromColumns."),$scope.pasteEvent=function(event){var data,ref;return null!=event.clipboardData&&null!=event.clipboardData.getData?data=event.clipboardData.getData("text/plain"):null!=event.originalEvent&&null!=event.originalEvent.clipboardData&&null!=event.originalEvent.clipboardData.getData?data=event.originalEvent.clipboardData.getData("text/plain"):null!=window.clipboardData&&null!=window.clipboardData.getData&&(data=window.clipboardData.getData("Text")),"function"==typeof $scope.ngPasteFromBeforeParse&&(data=$scope.ngPasteFromBeforeParse(data)),$scope.processPasteData(data),(null!=(ref=$scope.ngPasteFromPasteOnly)?ref:!0)?event.preventDefault():void 0},$scope.changeEvent=function(){var data,ref;return(null!=(ref=$scope.ngPasteFromPasteOnly)?ref:!0)?element.val(""):(data=element.val(),"function"==typeof $scope.ngPasteFromBeforeParse&&(data=$scope.ngPasteFromBeforeParse(data)),$scope.processPasteData(data))},element.on("paste",$scope.pasteEvent),element.on("keyup",$scope.changeEvent),element.on("change",$scope.changeEvent)},controller:function($scope,$filter,ngPasteFromErrors,ngPasteFromSeparators){return $scope.columnsToObject=function(columns){var column,format,i,index,len,obj;for(obj={},format=$scope.ngPasteFromColumns,index=i=0,len=columns.length;len>i;index=++i)column=columns[index],obj[format[index]]=column;return obj},$scope.getExpectedColumnsLength=function(){return"number"==typeof $scope.ngPasteFromColumns?$scope.ngPasteFromColumns:$scope.ngPasteFromColumns.length},$scope.processPasteData=function(data){var columns,expectedColumnsLength,i,index,len,ref,ref1,result,row,rowData,rowResult,rows;if(data&&data.length){for(rows=data.split(null!=(ref=$scope.ngPasteFromRowSeparator)?ref:ngPasteFromSeparators.row),result=[],expectedColumnsLength=$scope.getExpectedColumnsLength(),index=i=0,len=rows.length;len>i;index=++i)row=rows[index],""!==row&&(columns=row.split(null!=(ref1=$scope.ngPasteFromColumnSeparator)?ref1:ngPasteFromSeparators.column),rowData={index:index,source:row,expectedLength:expectedColumnsLength,actualLength:columns.length},columns.length===expectedColumnsLength?(rowResult="number"==typeof $scope.ngPasteFromColumns?columns:$scope.columnsToObject(columns),"function"!=typeof $scope.ngPasteFromOnValidate||$scope.ngPasteFromOnValidate(rowResult,rowData)?("function"==typeof $scope.ngPasteFromAfterParseRow&&(rowResult=$scope.ngPasteFromAfterParseRow(rowResult,rowData)),result.push(rowResult)):"function"==typeof $scope.ngPasteFromOnError&&$scope.ngPasteFromOnError(ngPasteFromErrors.failedValidation,rowData)):"function"==typeof $scope.ngPasteFromOnError&&$scope.ngPasteFromOnError(ngPasteFromErrors.invalidColumnLength,rowData));return"function"==typeof $scope.ngPasteFromBeforeApply&&$scope.ngPasteFromBeforeApply(result),$scope.$apply(function(){return $scope.ngPasteFrom=result})}}}}})}).call(this); +(function(){angular.module("ngPasteFrom",[]).constant("ngPasteFromErrors",{invalidColumnLength:"NGPASTEFROM_INVALID_COLUMN_LENGTH",failedValidation:"NGPASTEFROM_FAILED_VALIDATION"}).constant("ngPasteFromSeparators",{row:/\r\n|\n\r|\n|\r/g,column:" "}).directive("ngPasteFrom",function(){return{restrict:"A",scope:{ngPasteFrom:"=",ngPasteFromColumns:"=",ngPasteFromEnforceColumnCount:"=",ngPasteFromRowSeparator:"=",ngPasteFromColumnSeparator:"=",ngPasteFromPasteOnly:"=",ngPasteFromBeforeParse:"=",ngPasteFromAfterParseRow:"=",ngPasteFromOnValidate:"=",ngPasteFromBeforeApply:"=",ngPasteFromOnError:"="},link:function($scope,element){return null==$scope.ngPasteFromColumns&&console.error("Missing required attribute ngPasteFromColumns."),$scope.pasteEvent=function(event){var data,ref;return null!=event.clipboardData&&null!=event.clipboardData.getData?data=event.clipboardData.getData("text/plain"):null!=event.originalEvent&&null!=event.originalEvent.clipboardData&&null!=event.originalEvent.clipboardData.getData?data=event.originalEvent.clipboardData.getData("text/plain"):null!=window.clipboardData&&null!=window.clipboardData.getData&&(data=window.clipboardData.getData("Text")),"function"==typeof $scope.ngPasteFromBeforeParse&&(data=$scope.ngPasteFromBeforeParse(data)),$scope.processPasteData(data),(null!=(ref=$scope.ngPasteFromPasteOnly)?ref:!0)?event.preventDefault():void 0},$scope.changeEvent=function(){var data,ref;return(null!=(ref=$scope.ngPasteFromPasteOnly)?ref:!0)?element.val(""):(data=element.val(),"function"==typeof $scope.ngPasteFromBeforeParse&&(data=$scope.ngPasteFromBeforeParse(data)),$scope.processPasteData(data))},element.on("paste",$scope.pasteEvent),element.on("keyup",$scope.changeEvent),element.on("change",$scope.changeEvent)},controller:function($scope,$filter,ngPasteFromErrors,ngPasteFromSeparators){return $scope.columnsToObject=function(columns){var column,format,i,index,len,obj;for(obj={},format=$scope.ngPasteFromColumns,index=i=0,len=columns.length;len>i;index=++i)column=columns[index],obj[format[index]]=column;return obj},$scope.getExpectedColumnsLength=function(){return"number"==typeof $scope.ngPasteFromColumns?$scope.ngPasteFromColumns:$scope.ngPasteFromColumns.length},$scope.processPasteData=function(data){var columns,expectedColumnsLength,i,index,len,ref,ref1,result,row,rowData,rowResult,rows;if(data&&data.length){for(rows=data.split(null!=(ref=$scope.ngPasteFromRowSeparator)?ref:ngPasteFromSeparators.row),result=[],expectedColumnsLength=$scope.getExpectedColumnsLength(),index=i=0,len=rows.length;len>i;index=++i)row=rows[index],""!==row&&(columns=row.split(null!=(ref1=$scope.ngPasteFromColumnSeparator)?ref1:ngPasteFromSeparators.column),rowData={index:index,source:row,expectedLength:expectedColumnsLength,actualLength:columns.length},$scope.ngPasteFromEnforceColumnCount&&columns.length!==expectedColumnsLength?"function"==typeof $scope.ngPasteFromOnError&&$scope.ngPasteFromOnError(ngPasteFromErrors.invalidColumnLength,rowData):(rowResult="number"==typeof $scope.ngPasteFromColumns?columns:$scope.columnsToObject(columns),"function"!=typeof $scope.ngPasteFromOnValidate||$scope.ngPasteFromOnValidate(rowResult,rowData)?("function"==typeof $scope.ngPasteFromAfterParseRow&&(rowResult=$scope.ngPasteFromAfterParseRow(rowResult,rowData)),result.push(rowResult)):"function"==typeof $scope.ngPasteFromOnError&&$scope.ngPasteFromOnError(ngPasteFromErrors.failedValidation,rowData)));return"function"==typeof $scope.ngPasteFromBeforeApply&&$scope.ngPasteFromBeforeApply(result),$scope.$apply(function(){return $scope.ngPasteFrom=result})}}}}})}).call(this); //# sourceMappingURL=ng-paste-from-latest.min.js.map \ No newline at end of file diff --git a/dist/ng-paste-from-latest.min.js.map b/dist/ng-paste-from-latest.min.js.map index 971d536..9079866 100755 --- a/dist/ng-paste-from-latest.min.js.map +++ b/dist/ng-paste-from-latest.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["ng-paste-from.coffee","ng-paste-from.js"],"names":["angular","module","constant","invalidColumnLength","failedValidation","row","column","directive","restrict","scope","ngPasteFrom","ngPasteFromColumns","ngPasteFromRowSeparator","ngPasteFromColumnSeparator","ngPasteFromPasteOnly","ngPasteFromBeforeParse","ngPasteFromAfterParseRow","ngPasteFromOnValidate","ngPasteFromBeforeApply","ngPasteFromOnError","link","$scope","element","console","error","pasteEvent","event","data","ref","clipboardData","getData","originalEvent","window","processPasteData","preventDefault","changeEvent","val","on","controller","$filter","ngPasteFromErrors","ngPasteFromSeparators","columnsToObject","columns","format","i","index","len","obj","length","getExpectedColumnsLength","expectedColumnsLength","ref1","result","rowData","rowResult","rows","split","source","expectedLength","actualLength","push","$apply","call","this"],"mappings":"CAAA,WAAAA,QAAQC,OAAO,kBACbC,SAAS,qBACTC,oBAAqB,oCACrBC,iBAAkB,kCAElBF,SAAS,yBACTG,IAAK,mBACLC,OAAQ,MAERC,UAAU,cAAe,WCDvB,ODEFC,SAAU,IACVC,OACCC,YAAa,IACbC,mBAAoB,IACpBC,wBAAyB,IACzBC,2BAA4B,IAC5BC,qBAAsB,IACtBC,uBAAwB,IACxBC,yBAA0B,IAC1BC,sBAAuB,IACvBC,uBAAwB,IACxBC,mBAAoB,KAErBC,KAAM,SAACC,OAAQC,SCkCT,MDjCE,OAAAD,OAAAV,oBACNY,QAAQC,MAAM,kDAEfH,OAAOI,WAAa,SAACC,OACpB,GAAAC,MAAAC,GAUA,OAVG,OAAAF,MAAAG,eAAwB,MAAAH,MAAAG,cAAAC,QAC1BH,KAAOD,MAAMG,cAAcC,QAAQ,cAC5B,MAAAJ,MAAAK,eAAwB,MAAAL,MAAAK,cAAAF,eAAsC,MAAAH,MAAAK,cAAAF,cAAAC,QACrEH,KAAOD,MAAMK,cAAcF,cAAcC,QAAQ,cAC1C,MAAAE,OAAAH,eAAyB,MAAAG,OAAAH,cAAAC,UAChCH,KAAOK,OAAOH,cAAcC,QAAQ,SAEM,kBAAjCT,QAAON,yBAChBY,KAAON,OAAON,uBA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PzC,MAGHsC,QAAUtC,IAAIoD,MAAJ,OAAAL,KAAA/B,OAAAR,4BAAAuC,KAA8CX,sBAAsBnC,QAE9EgD,SACCR,MAAOA,MACPY,OAAQrD,IACRsD,eAAgBR,sBAChBS,aAAcjB,QAAQM,QAEpBN,QAAQM,SAAYE,uBAMtBI,UADsC,gBAA7BlC,QAAOV,mBACJgC,QAEAtB,OAAOqB,gBAAgBC,SAEQ,kBAAlCtB,QAAOJ,uBAAyCI,OAAOJ,sBAAsBsC,UAAWD,UACpD,kBAAnCjC,QAAOL,2BAChBuC,UAAYlC,OAAOL,yBAAyBuC,UAAWD,UAExDD,OAAOQ,KAAKN,YAC+B,kBAA7BlC,QAAOF,oBACrBE,OAAOF,mBAAmBqB,kBAAkBpC,iBAAkBkD,UAfvB,kBAA7BjC,QAAOF,oBAChBE,OAAOF,mBAAmBqB,kBAAkBrC,oBAAqBmD,SC8B9D,ODdqC,kBAAjCjC,QAAOH,wBAChBG,OAAOH,uBAAuBmC,QAE/BhC,OAAOyC,OAAO,WCYN,MDXPzC,QAAOX,YAAc2C,iBCkBvBU,KAAKC","file":"ng-paste-from-latest.min.js","sourcesContent":["angular.module \"ngPasteFrom\", []\n\t.constant \"ngPasteFromErrors\",\n\t\tinvalidColumnLength: \"NGPASTEFROM_INVALID_COLUMN_LENGTH\"\n\t\tfailedValidation: \"NGPASTEFROM_FAILED_VALIDATION\"\n\n\t.constant \"ngPasteFromSeparators\",\n\t\trow: /\\r\\n|\\n\\r|\\n|\\r/g\n\t\tcolumn: \"\\t\"\n\n\t.directive \"ngPasteFrom\", ->\n\t\trestrict: \"A\"\n\t\tscope: \n\t\t\tngPasteFrom: \"=\"\n\t\t\tngPasteFromColumns: \"=\"\n\t\t\tngPasteFromRowSeparator: \"=\"\n\t\t\tngPasteFromColumnSeparator: \"=\"\n\t\t\tngPasteFromPasteOnly: \"=\"\n\t\t\tngPasteFromBeforeParse: \"=\"\n\t\t\tngPasteFromAfterParseRow: \"=\"\n\t\t\tngPasteFromOnValidate: \"=\"\n\t\t\tngPasteFromBeforeApply: \"=\"\n\t\t\tngPasteFromOnError: \"=\"\n\n\t\tlink: ($scope, element, attrs) ->\n\t\t\tif not $scope.ngPasteFromColumns?\n\t\t\t\tconsole.error \"Missing required attribute ngPasteFromColumns.\"\n\n\t\t\t$scope.pasteEvent = (event) ->\n\t\t\t\tif event.clipboardData? && event.clipboardData.getData? # Standard\n\t\t\t\t\tdata = event.clipboardData.getData \"text/plain\"\n\t\t\t\telse if event.originalEvent? && event.originalEvent.clipboardData? && event.originalEvent.clipboardData.getData? # jQuery\n\t\t\t\t\tdata = event.originalEvent.clipboardData.getData \"text/plain\"\n\t\t\t\telse if window.clipboardData? && window.clipboardData.getData? # Internet Explorer\n\t\t\t\t\tdata = window.clipboardData.getData \"Text\"\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t$scope.processPasteData data\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\tevent.preventDefault()\n\n\t\t\t$scope.changeEvent = ->\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\telement.val \"\"\n\t\t\t\telse\n\t\t\t\t\tdata = element.val()\n\t\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t\t$scope.processPasteData data\n\n\t\t\telement.on \"paste\", $scope.pasteEvent\n\t\t\telement.on \"keyup\", $scope.changeEvent\n\t\t\telement.on \"change\", $scope.changeEvent\n\n\t\tcontroller: ($scope, $filter, ngPasteFromErrors, ngPasteFromSeparators) ->\n\t\t\t$scope.columnsToObject = (columns) ->\n\t\t\t\tobj = {}\n\t\t\t\tformat = $scope.ngPasteFromColumns\n\t\t\t\tfor column, index in columns\n\t\t\t\t\tobj[format[index]] = column\n\t\t\t\tobj\n\n\t\t\t$scope.getExpectedColumnsLength = ->\n\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t$scope.ngPasteFromColumns\n\t\t\t\telse\n\t\t\t\t\t$scope.ngPasteFromColumns.length\n\n\t\t\t$scope.processPasteData = (data) ->\n\t\t\t\tif not (data and data.length)\n\t\t\t\t\treturn\n\n\t\t\t\trows = data.split $scope.ngPasteFromRowSeparator ? ngPasteFromSeparators.row\n\t\t\t\tresult = []\n\t\t\t\texpectedColumnsLength = $scope.getExpectedColumnsLength()\n\n\t\t\t\tfor row, index in rows\n\t\t\t\t\tif row is \"\"\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tcolumns = row.split $scope.ngPasteFromColumnSeparator ? ngPasteFromSeparators.column\n\n\t\t\t\t\trowData =\n\t\t\t\t\t\tindex: index\n\t\t\t\t\t\tsource: row\n\t\t\t\t\t\texpectedLength: expectedColumnsLength\n\t\t\t\t\t\tactualLength: columns.length\n\n\t\t\t\t\tif columns.length isnt expectedColumnsLength\n\t\t\t\t\t\tif typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.invalidColumnLength, rowData\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t\trowResult = columns\n\t\t\t\t\telse\n\t\t\t\t\t\trowResult = $scope.columnsToObject columns\n\n\t\t\t\t\tif typeof $scope.ngPasteFromOnValidate isnt \"function\" or $scope.ngPasteFromOnValidate rowResult, rowData\n\t\t\t\t\t\tif typeof $scope.ngPasteFromAfterParseRow is \"function\"\n\t\t\t\t\t\t\trowResult = $scope.ngPasteFromAfterParseRow rowResult, rowData\n\n\t\t\t\t\t\tresult.push rowResult\n\t\t\t\t\telse if typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.failedValidation, rowData\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeApply is \"function\"\n\t\t\t\t\t$scope.ngPasteFromBeforeApply result\n\n\t\t\t\t$scope.$apply ->\n\t\t\t\t\t$scope.ngPasteFrom = result\n",null],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["ng-paste-from.coffee","ng-paste-from.js"],"names":["angular","module","constant","invalidColumnLength","failedValidation","row","column","directive","restrict","scope","ngPasteFrom","ngPasteFromColumns","ngPasteFromEnforceColumnCount","ngPasteFromRowSeparator","ngPasteFromColumnSeparator","ngPasteFromPasteOnly","ngPasteFromBeforeParse","ngPasteFromAfterParseRow","ngPasteFromOnValidate","ngPasteFromBeforeApply","ngPasteFromOnError","link","$scope","element","console","error","pasteEvent","event","data","ref","clipboardData","getData","originalEvent","window","processPasteData","preventDefault","changeEvent","val","on","controller","$filter","ngPasteFromErrors","ngPasteFromSeparators","columnsToObject","columns","format","i","index","len","obj","length","getExpectedColumnsLength","expectedColumnsLength","ref1","result","rowData","rowResult","rows","split","source","expectedLength","actualLength","push","$apply","call","this"],"mappings":"CAAA,WAAAA,QAAQC,OAAO,kBACbC,SAAS,qBACTC,oBAAqB,oCACrBC,iBAAkB,kCAElBF,SAAS,yBACTG,IAAK,mBACLC,OAAQ,MAERC,UAAU,cAAe,WCDvB,ODEFC,SAAU,IACVC,OACCC,YAAa,IACbC,mBAAoB,IACpBC,8BAA+B,IAC/BC,wBAAyB,IACzBC,2BAA4B,IAC5BC,qBAAsB,IACtBC,uBAAwB,IACxBC,yBAA0B,IAC1BC,sBAAuB,IACvBC,uBAAwB,IACxBC,mBAAoB,KAErBC,KAAM,SAACC,OAAQC,SCkCT,MDjCE,OAAAD,OAAAX,oBACNa,QAAQC,MAAM,kDAEfH,OAAOI,WAAa,SAACC,OACpB,GAAAC,MAAAC,GAUA,OAVG,OAAAF,MAAAG,eAAwB,MAAAH,MAAAG,cAAAC,QAC1BH,KAAOD,MAAMG,cAAcC,QAAQ,cAC5B,MAAAJ,MAAAK,eAAwB,MAAAL,MAAAK,cAAAF,eAAsC,M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8B,MAAL,OAAA7B,IAAAP,OAAAT,yBAAAgB,IAA4Ca,sBAAsBrC,KACzEiD,UACAF,sBAAwB9B,OAAO6B,2BAE/BJ,MAAAD,EAAA,EAAAE,IAAAS,KAAAP,OAAAF,IAAAF,EAAAC,QAAAD,ECUQzC,IAAMoD,KAAKV,ODTR,KAAP1C,MAGHuC,QAAUvC,IAAIqD,MAAJ,OAAAL,KAAA/B,OAAAR,4BAAAuC,KAA8CX,sBAAsBpC,QAE9EiD,SACCR,MAAOA,MACPY,OAAQtD,IACRuD,eAAgBR,sBAChBS,aAAcjB,QAAQM,QAEpB5B,OAAOV,+BAAiCgC,QAAQM,SAAYE,sBACvB,kBAA7B9B,QAAOF,oBAChBE,OAAOF,mBAAmBqB,kBAAkBtC,oBAAqBoD,UAIlEC,UADsC,gBAA7BlC,QAAOX,mBACJiC,QAEAtB,OAAOqB,gBAAgBC,SAEQ,kBAAlCtB,QAAOJ,uBAAyCI,OAAOJ,sBAAsBsC,UAAWD,UACpD,kBAAnCjC,QAAOL,2BAChBuC,UAAYlC,OAAOL,yBAAyBuC,UAAWD,UAExDD,OAAOQ,KAAKN,YAC+B,kBAA7BlC,QAAOF,oBACrBE,OAAOF,mBAAmBqB,kBAAkBrC,iBAAkBmD,UCgB1D,ODdqC,kBAAjCjC,QAAOH,wBAChBG,OAAOH,uBAAuBmC,QAE/BhC,OAAOyC,OAAO,WCYN,MDXPzC,QAAOZ,YAAc4C,iBCkBvBU,KAAKC","file":"ng-paste-from-latest.min.js","sourcesContent":["angular.module \"ngPasteFrom\", []\n\t.constant \"ngPasteFromErrors\",\n\t\tinvalidColumnLength: \"NGPASTEFROM_INVALID_COLUMN_LENGTH\"\n\t\tfailedValidation: \"NGPASTEFROM_FAILED_VALIDATION\"\n\n\t.constant \"ngPasteFromSeparators\",\n\t\trow: /\\r\\n|\\n\\r|\\n|\\r/g\n\t\tcolumn: \"\\t\"\n\n\t.directive \"ngPasteFrom\", ->\n\t\trestrict: \"A\"\n\t\tscope: \n\t\t\tngPasteFrom: \"=\"\n\t\t\tngPasteFromColumns: \"=\"\n\t\t\tngPasteFromEnforceColumnCount: \"=\"\n\t\t\tngPasteFromRowSeparator: \"=\"\n\t\t\tngPasteFromColumnSeparator: \"=\"\n\t\t\tngPasteFromPasteOnly: \"=\"\n\t\t\tngPasteFromBeforeParse: \"=\"\n\t\t\tngPasteFromAfterParseRow: \"=\"\n\t\t\tngPasteFromOnValidate: \"=\"\n\t\t\tngPasteFromBeforeApply: \"=\"\n\t\t\tngPasteFromOnError: \"=\"\n\n\t\tlink: ($scope, element, attrs) ->\n\t\t\tif not $scope.ngPasteFromColumns?\n\t\t\t\tconsole.error \"Missing required attribute ngPasteFromColumns.\"\n\n\t\t\t$scope.pasteEvent = (event) ->\n\t\t\t\tif event.clipboardData? && event.clipboardData.getData? # Standard\n\t\t\t\t\tdata = event.clipboardData.getData \"text/plain\"\n\t\t\t\telse if event.originalEvent? && event.originalEvent.clipboardData? && event.originalEvent.clipboardData.getData? # jQuery\n\t\t\t\t\tdata = event.originalEvent.clipboardData.getData \"text/plain\"\n\t\t\t\telse if window.clipboardData? && window.clipboardData.getData? # Internet Explorer\n\t\t\t\t\tdata = window.clipboardData.getData \"Text\"\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t$scope.processPasteData data\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\tevent.preventDefault()\n\n\t\t\t$scope.changeEvent = ->\n\t\t\t\tif $scope.ngPasteFromPasteOnly ? true\n\t\t\t\t\telement.val \"\"\n\t\t\t\telse\n\t\t\t\t\tdata = element.val()\n\t\t\t\t\tif typeof $scope.ngPasteFromBeforeParse is \"function\"\n\t\t\t\t\t\tdata = $scope.ngPasteFromBeforeParse data\n\t\t\t\t\t$scope.processPasteData data\n\n\t\t\telement.on \"paste\", $scope.pasteEvent\n\t\t\telement.on \"keyup\", $scope.changeEvent\n\t\t\telement.on \"change\", $scope.changeEvent\n\n\t\tcontroller: ($scope, $filter, ngPasteFromErrors, ngPasteFromSeparators) ->\n\t\t\t$scope.columnsToObject = (columns) ->\n\t\t\t\tobj = {}\n\t\t\t\tformat = $scope.ngPasteFromColumns\n\t\t\t\tfor column, index in columns\n\t\t\t\t\tobj[format[index]] = column\n\t\t\t\tobj\n\n\t\t\t$scope.getExpectedColumnsLength = ->\n\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t$scope.ngPasteFromColumns\n\t\t\t\telse\n\t\t\t\t\t$scope.ngPasteFromColumns.length\n\n\t\t\t$scope.processPasteData = (data) ->\n\t\t\t\tif not (data and data.length)\n\t\t\t\t\treturn\n\n\t\t\t\trows = data.split $scope.ngPasteFromRowSeparator ? ngPasteFromSeparators.row\n\t\t\t\tresult = []\n\t\t\t\texpectedColumnsLength = $scope.getExpectedColumnsLength()\n\n\t\t\t\tfor row, index in rows\n\t\t\t\t\tif row is \"\"\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tcolumns = row.split $scope.ngPasteFromColumnSeparator ? ngPasteFromSeparators.column\n\n\t\t\t\t\trowData =\n\t\t\t\t\t\tindex: index\n\t\t\t\t\t\tsource: row\n\t\t\t\t\t\texpectedLength: expectedColumnsLength\n\t\t\t\t\t\tactualLength: columns.length\n\n\t\t\t\t\tif $scope.ngPasteFromEnforceColumnCount && columns.length isnt expectedColumnsLength\n\t\t\t\t\t\tif typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.invalidColumnLength, rowData\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\tif typeof $scope.ngPasteFromColumns is \"number\"\n\t\t\t\t\t\trowResult = columns\n\t\t\t\t\telse\n\t\t\t\t\t\trowResult = $scope.columnsToObject columns\n\n\t\t\t\t\tif typeof $scope.ngPasteFromOnValidate isnt \"function\" or $scope.ngPasteFromOnValidate rowResult, rowData\n\t\t\t\t\t\tif typeof $scope.ngPasteFromAfterParseRow is \"function\"\n\t\t\t\t\t\t\trowResult = $scope.ngPasteFromAfterParseRow rowResult, rowData\n\n\t\t\t\t\t\tresult.push rowResult\n\t\t\t\t\telse if typeof $scope.ngPasteFromOnError is \"function\"\n\t\t\t\t\t\t$scope.ngPasteFromOnError ngPasteFromErrors.failedValidation, rowData\n\n\t\t\t\tif typeof $scope.ngPasteFromBeforeApply is \"function\"\n\t\t\t\t\t$scope.ngPasteFromBeforeApply result\n\n\t\t\t\t$scope.$apply ->\n\t\t\t\t\t$scope.ngPasteFrom = result\n",null],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/ng-paste-from.coffee b/src/ng-paste-from.coffee index d59c355..5b90ddd 100644 --- a/src/ng-paste-from.coffee +++ b/src/ng-paste-from.coffee @@ -12,6 +12,7 @@ angular.module "ngPasteFrom", [] scope: ngPasteFrom: "=" ngPasteFromColumns: "=" + ngPasteFromEnforceColumnCount: "=" ngPasteFromRowSeparator: "=" ngPasteFromColumnSeparator: "=" ngPasteFromPasteOnly: "=" @@ -86,7 +87,7 @@ angular.module "ngPasteFrom", [] expectedLength: expectedColumnsLength actualLength: columns.length - if columns.length isnt expectedColumnsLength + if $scope.ngPasteFromEnforceColumnCount && columns.length isnt expectedColumnsLength if typeof $scope.ngPasteFromOnError is "function" $scope.ngPasteFromOnError ngPasteFromErrors.invalidColumnLength, rowData continue