angular-dynamic-number
Advanced tools
Comparing version 1.2.0 to 1.2.1
{ | ||
"name": "angular-dynamic-number", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"homepage": "https://github.com/uhlryk/angular-dynamic-number", | ||
@@ -5,0 +5,0 @@ "authors": [ |
{ | ||
"name": "angular-dynamic-number", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Highly customizable angular directive for numbers", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -103,2 +103,4 @@ # Angular Dynamic Number [![Build Status](https://travis-ci.org/uhlryk/angular-dynamic-number.svg)](https://travis-ci.org/uhlryk/angular-dynamic-number) | ||
Define round method for fraction part when convert from model to view and for filter | ||
**numFixed** | ||
@@ -108,3 +110,2 @@ | ||
Define round method for fraction part when convert from model to view and for filter | ||
@@ -111,0 +112,0 @@ ## Example: |
@@ -95,3 +95,3 @@ /*jslint node: true */ | ||
function removeLeadingZero(value){ | ||
return value.replace(/^0+/g, "").replace(/^-00+/g, "-0").replace(/-0+\[\.,]/, "-0$&").replace(/^[\.,]/g, "0$&"); | ||
return String(value).replace(/^0+/g, "").replace(/^-00+/g, "-0").replace(/-0+\[\.,]/, "-0$&").replace(/^[\.,]/g, "0$&"); | ||
} | ||
@@ -146,3 +146,3 @@ function changeViewValue(ngModelController, value){ | ||
parsedValue = removeLeadingZero(parsedValue); | ||
if(parsedValue === '' && value.charAt(0)=== '0'){ | ||
if(parsedValue === '' && String(value).charAt(0)=== '0'){ | ||
changeViewValue(ngModelController, 0); | ||
@@ -149,0 +149,0 @@ return 0; |
@@ -1,1 +0,1 @@ | ||
!function(n,r,t){"use strict";function e(n,r){return","===r?String(n).replace(".",","):n}function u(n,r){return","===r?String(n).replace(",","."):n}function i(n,r){if(n>=0){var t=parseInt(n,10);if(isNaN(t)===!1&&isFinite(t)&&t>=0)return t}return r}function o(n,r){if(n>=0){var t=parseInt(n,10);if(isNaN(t)===!1&&isFinite(t)&&t>=0)return t}return r}function a(n,r){return","===n?",":"."===n?".":r}function c(n,r){return"false"===n?!1:"true"===n?!0:r}function f(n,r){return"false"===n?!1:"true"===n?!0:r}function s(n,r){return"floor"===n?Math.floor:"ceil"===n?Math.ceil:"round"===n?Math.round:r}function m(n,r){return"false"===n?!1:"true"===n?!0:r}function l(n,r,t,e,u){var i="-?";e===!1&&u===!0?i="-":e===!0&&u===!1&&(i="");var o="[0-9]{0,"+n+"}";0===n&&(o="0");var a="(\\"+t+"([0-9]){0,"+r+"})";return 0===r&&(a=""),new RegExp("^"+i+o+a+"?$")}function d(n){return n.replace(/^0+/g,"").replace(/^-00+/g,"-0").replace(/-0+\[\.,]/,"-0$&").replace(/^[\.,]/g,"0$&")}function p(n,r){n.$setViewValue(r),n.$render()}function g(n,r,t,u,i){if(n=Number(n),!isNaN(n)&&isFinite(n)){var o=Math.pow(10,r);return i?e((u(n*o)/o).toFixed(r),t):e(String(u(n*o)/o),t)}return i?0..toFixed(r):"0"}function v(){return{restrict:"A",require:"?ngModel",scope:{numInt:"@",numFract:"@",numSep:"@",numPos:"@",numNeg:"@",numRound:"@"},link:function(n,r,m,v){var h=i(n.numInt,6),w=o(n.numFract,2),N=a(n.numSep,"."),$=c(n.numPos,!0),F=f(n.numNeg,!0),M=s(n.numRound,Math.round);if($===!1&&F===!1)throw new Error("Number is set to not be positive and not be negative. Change num_pos attr or/and num_neg attr to true");var b=l(h,w,N,$,F);v.$parsers.unshift(function(n){var r=n;return r=d(r),""===r&&"0"===n.charAt(0)?(p(v,0),0):r===t||""===r?0:"-"===r?(p(v,r),0):b.test(r)===!1?(p(v,e(v.$modelValue,N)),v.$modelValue):(p(v,r),u(r,N))}),v.$formatters.push(function(n){return g(n,w,N,M)})}}}function h(){return function(n,r,t,e,u){var i=o(r,2),c=a(t,"."),f=s(e,Math.round),l=m(u,!1);return g(n,i,c,f,l)}}r.module("dynamicNumber",[]).directive("awnum",v).filter("awnum",h)}(window,window.angular); | ||
!function(n,r,t){"use strict";function e(n,r){return","===r?String(n).replace(".",","):n}function u(n,r){return","===r?String(n).replace(",","."):n}function i(n,r){if(n>=0){var t=parseInt(n,10);if(isNaN(t)===!1&&isFinite(t)&&t>=0)return t}return r}function o(n,r){if(n>=0){var t=parseInt(n,10);if(isNaN(t)===!1&&isFinite(t)&&t>=0)return t}return r}function a(n,r){return","===n?",":"."===n?".":r}function c(n,r){return"false"===n?!1:"true"===n?!0:r}function f(n,r){return"false"===n?!1:"true"===n?!0:r}function s(n,r){return"floor"===n?Math.floor:"ceil"===n?Math.ceil:"round"===n?Math.round:r}function m(n,r){return"false"===n?!1:"true"===n?!0:r}function l(n,r,t,e,u){var i="-?";e===!1&&u===!0?i="-":e===!0&&u===!1&&(i="");var o="[0-9]{0,"+n+"}";0===n&&(o="0");var a="(\\"+t+"([0-9]){0,"+r+"})";return 0===r&&(a=""),new RegExp("^"+i+o+a+"?$")}function d(n){return String(n).replace(/^0+/g,"").replace(/^-00+/g,"-0").replace(/-0+\[\.,]/,"-0$&").replace(/^[\.,]/g,"0$&")}function p(n,r){n.$setViewValue(r),n.$render()}function g(n,r,t,u,i){if(n=Number(n),!isNaN(n)&&isFinite(n)){var o=Math.pow(10,r);return i?e((u(n*o)/o).toFixed(r),t):e(String(u(n*o)/o),t)}return i?0..toFixed(r):"0"}function v(){return{restrict:"A",require:"?ngModel",scope:{numInt:"@",numFract:"@",numSep:"@",numPos:"@",numNeg:"@",numRound:"@"},link:function(n,r,m,v){var h=i(n.numInt,6),w=o(n.numFract,2),N=a(n.numSep,"."),$=c(n.numPos,!0),F=f(n.numNeg,!0),M=s(n.numRound,Math.round);if($===!1&&F===!1)throw new Error("Number is set to not be positive and not be negative. Change num_pos attr or/and num_neg attr to true");var S=l(h,w,N,$,F);v.$parsers.unshift(function(n){var r=n;return r=d(r),""===r&&"0"===String(n).charAt(0)?(p(v,0),0):r===t||""===r?0:"-"===r?(p(v,r),0):S.test(r)===!1?(p(v,e(v.$modelValue,N)),v.$modelValue):(p(v,r),u(r,N))}),v.$formatters.push(function(n){return g(n,w,N,M)})}}}function h(){return function(n,r,t,e,u){var i=o(r,2),c=a(t,"."),f=s(e,Math.round),l=m(u,!1);return g(n,i,c,f,l)}}r.module("dynamicNumber",[]).directive("awnum",v).filter("awnum",h)}(window,window.angular); |
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
15194
120