angular-unit-converter
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -1,2 +0,2 @@ | ||
/*! angular-unit-converter 0.0.3 */ | ||
var auc=angular.module("angular-unit-converter",[]);auc.directive("angularUnitConverter",function(a){return{require:"ngModel",scope:{convertFrom:"@",convertTo:"@"},link:function(a,b,c,d){Decimal.config({precision:10,errors:!1});var e={mm:.001,cm:.01,m:1,km:1e3,"in":.0254,ft:.3048,yd:.9144,mi:1609.344,mg:.001,g:1,kg:1e3,oz:28.3495231,lb:453.59237};a.do_convertFrom=function(b){var c=new Decimal(e[a.convertFrom]),d=new Decimal(e[a.convertTo]);return new Decimal(b).dividedBy(c.dividedBy(d)).toNumber()},a.do_convertTo=function(b){var c=new Decimal(e[a.convertFrom]),d=new Decimal(e[a.convertTo]);return new Decimal(b).times(c.dividedBy(d)).toNumber()};var f=function(b){var c=b.match(/^\-?\d+((\.|\,)\d+)?$/g);return null!==c?a.do_convertFrom(parseFloat(b)):void 0},g=function(b){return a.do_convertTo(parseFloat(b))};d.$parsers.push(f),d.$formatters.push(g),a.$watch("[convertFrom, convertTo]",function(a){d.$modelValue=""})}}}); | ||
/*! angular-unit-converter 0.0.4 */ | ||
var auc=angular.module("angular-unit-converter",[]);auc.directive("angularUnitConverter",function(a){return{require:"ngModel",scope:{convertFrom:"@",convertTo:"@"},link:function(a,b,c,d){Decimal.config({precision:10,errors:!1});var e={mm:.001,cm:.01,m:1,km:1e3,"in":.0254,ft:.3048,yd:.9144,mi:1609.344,mg:.001,g:1,kg:1e3,oz:28.3495231,lb:453.59237};a.do_convertFrom=function(b){if(!a.convertFrom||""===a.convertFrom)return b;var c=new Decimal(e[a.convertFrom]),d=new Decimal(e[a.convertTo]);return new Decimal(b).dividedBy(c.dividedBy(d)).toNumber()},a.do_convertTo=function(b){if(!a.convertTo||""===a.convertTo)return b;var c=new Decimal(e[a.convertFrom]),d=new Decimal(e[a.convertTo]);return new Decimal(b).times(c.dividedBy(d)).toNumber()};var f=function(b){var c=b.match(/^\-?\d+((\.|\,)\d+)?$/g);return null!==c?a.do_convertFrom(parseFloat(b)):void 0},g=function(b){return a.do_convertTo(parseFloat(b))};d.$parsers.push(f),d.$formatters.push(g),a.$watch("[convertFrom, convertTo]",function(a){d.$modelValue=""})}}}); |
{ | ||
"name": "angular-unit-converter", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "AngularJS directive that converts to/from metric units using $parser and $formatters", | ||
@@ -5,0 +5,0 @@ "main": [ |
@@ -37,2 +37,4 @@ var auc = angular.module('angular-unit-converter', []); | ||
scope.do_convertFrom = function(value) { | ||
if(!scope.convertFrom || scope.convertFrom === "") return value; | ||
var from = new Decimal(units[scope.convertFrom]); | ||
@@ -44,2 +46,4 @@ var to = new Decimal(units[scope.convertTo]); | ||
scope.do_convertTo = function(value) { | ||
if(!scope.convertTo || scope.convertTo === "") return value; | ||
var from = new Decimal(units[scope.convertFrom]); | ||
@@ -46,0 +50,0 @@ var to = new Decimal(units[scope.convertTo]); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5326
60