Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-dynamic-number

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-dynamic-number - npm Package Compare versions

Comparing version 1.5.2 to 1.5.3-g

.idea/.name

5

package.json
{
"name": "angular-dynamic-number",
"version": "1.5.2",
"version": "1.5.3g",
"description": "Highly customizable angular directive for numbers",

@@ -28,3 +28,4 @@ "keywords": [

"scripts": {
"test": "gulp test"
"test": "gulp test",
"build": "gulp script"
},

@@ -31,0 +32,0 @@ "devDependencies": {

9

release/dynamic-number.js
/*jslint node: true */
(function(window, angular, undefined) {"use strict";
function convModelToView(modelValue, viewSeparator){
if(modelValue === undefined) {
return '';
}
if(viewSeparator === ',') {

@@ -107,3 +110,3 @@ return String(modelValue).replace(".",",");

.replace(/^-0(\d+)/g, "-$1")//change -013212 to -0
.replace(/^-([\.,])/, "-0$1")//change -. to -0.
.replace(/^-([\.,])/g, "-0$1")//change -. to -0.
.replace(/^[\.,]/g, "0$&");//change . to 0.

@@ -232,2 +235,6 @@ }

var parsedValue = String(value);
if(/^[\.,]{2,}/.test(parsedValue)) {
changeViewValue(ngModelController, 0);
return 0;
}
var cursorPosition = getCaretPosition(element[0]);

@@ -234,0 +241,0 @@ var valBeforeCursor = parsedValue.slice(0,cursorPosition);

@@ -1,1 +0,1 @@

!function(n,e,t){"use strict";function r(n,e){return","===e?String(n).replace(".",","):String(n)}function u(n,e){return","===e?String(n).replace(/\./g,"").replace(",","."):String(n).replace(/,/g,"")}function i(n,e){if(n>=0){var t=parseInt(n,10);if(isNaN(t)===!1&&isFinite(t)&&t>=0)return t}return e}function a(n,e){if(n>=0){var t=parseInt(n,10);if(isNaN(t)===!1&&isFinite(t)&&t>=0)return t}return e}function o(n,e){return","===n?",":"."===n?".":e}function c(n,e){return"false"===n?!1:"true"===n?!0:e}function f(n,e){return"false"===n?!1:"true"===n?!0:e}function l(n,e){return"floor"===n?Math.floor:"ceil"===n?Math.ceil:"round"===n?Math.round:e}function s(n,e){return"false"===n?!1:"true"===n?!0:e}function g(n,e){return"false"===n?!1:"true"===n?!0:e}function m(n,e,t,r,u){var i="-?";r===!1&&u===!0?i="-":r===!0&&u===!1&&(i="");var a="[0-9]{0,"+n+"}";0===n&&(a="0");var o="(\\"+t+"([0-9]){0,"+e+"})";return 0===e&&(o=""),new RegExp("^"+i+a+o+"?$")}function d(n){return String(n).replace(/^0+/g,"").replace(/^-0(\d+)/g,"-$1").replace(/^-([\.,])/,"-0$1").replace(/^[\.,]/g,"0$&")}function v(n,e){return"."===e?String(n).replace(/\./g,""):String(n).replace(/,/g,"")}function p(n,e){return String(n).replace(/\B(?=(\d{3})+(?!\d))/g,e)}function h(n,e){n.$setViewValue(e),n.$render()}function S(n,e,t,u,i,a){if(n=Number(n),!isNaN(n)&&isFinite(n)){var o=Math.pow(10,e);return n=i?r((u(n*o)/o).toFixed(e),t):r(String(u(n*o)/o),t),a&&(n=p(n,"."===t?",":".")),n}return i?0..toFixed(e):"0"}function w(n){var e=0;if(document.selection){n.focus();var t=document.selection.createRange();t.moveStart("character",-n.value.length),e=t.text.length}else(n.selectionStart||"0"==n.selectionStart)&&(e=n.selectionStart);return e}function N(n,e){if(null!==n)if(n.createTextRange){var t=n.createTextRange();t.move("character",e),t.select()}else n.selectionStart?(n.focus(),n.setSelectionRange(e,e)):n.focus()}function y(n,e,t){for(var r=0,u=0,i=0;i<n.length;i++)if(n[i]!==e){if(r++,r>=t)break}else u++;return u}function b(n){return{restrict:"A",require:"?ngModel",scope:{awnum:"@",numInt:"@",numFract:"@",numSep:"@",numPos:"@",numNeg:"@",numRound:"@",numThousand:"@"},link:function(n,e,s,b){if(!e[0]||"INPUT"!==e[0].tagName||"text"!==e[0].type)return void console.warn("Directive angular-dynamic-number works only for 'input' tag with type = 'text'");if(!b)return void console.warn("Directive angular-dynamic-number need ngModel attribute");var $=i(n.numInt,6),x=a(n.numFract,2),M=o(n.numSep,"."),F=c(n.numPos,!0),R=f(n.numNeg,!0),I=l(n.numRound,Math.round),T=g(n.numThousand,!1);if(F===!1&&R===!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 V=m($,x,M,F,R);b.$parsers.unshift(function(n){var i=String(n),a=w(e[0]),o=i.slice(0,a),c=o.length;if(o=v(o,"."===M?",":"."),i=v(i,"."===M?",":"."),o=d(o),i=d(i),""===i&&"0"===String(n).charAt(0))return h(b,0),0;if(i===t||""===i)return 0;if("-"===i)return h(b,"-"),0;if(V.test(i)===!1){var f=r(b.$modelValue,M);return T&&(f=p(f,"."===M?",":".")),h(b,f),N(e[0],a-1),b.$modelValue}var l=0,s=a-c+o.length;return T&&(i=p(i,"."===M?",":"."),l=y(i,"."===M?",":".",s)),h(b,i),N(e[0],s+l),u(i,M)}),b.$formatters.push(function(n){return S(n,x,M,I,!1,T)})}}}e.module("dynamicNumber",[]).provider("dynamicNumberStrategy",function(){var n={};this.addStrategy=function(e,t){n[e]=t},this.getStrategy=function(e){return n[e]},this.$get=function(){return{getStrategy:function(e){return n[e]}}}}).filter("awnum",function(){return function(n,e,t,r,u,i){var c=a(e,2),f=o(t,"."),m=l(r,Math.round),d=s(u,!1),v=g(i,!1);return S(n,c,f,m,d,v)}}).directive("awnum",["dynamicNumberStrategy",b])}(window,window.angular);
!function(e,n,t){"use strict";function r(e,n){return e===t?"":","===n?String(e).replace(".",","):String(e)}function u(e,n){return","===n?String(e).replace(/\./g,"").replace(",","."):String(e).replace(/,/g,"")}function i(e,n){if(e>=0){var t=parseInt(e,10);if(isNaN(t)===!1&&isFinite(t)&&t>=0)return t}return n}function a(e,n){if(e>=0){var t=parseInt(e,10);if(isNaN(t)===!1&&isFinite(t)&&t>=0)return t}return n}function o(e,n){return","===e?",":"."===e?".":n}function c(e,n){return"false"===e?!1:"true"===e?!0:n}function f(e,n){return"false"===e?!1:"true"===e?!0:n}function l(e,n){return"floor"===e?Math.floor:"ceil"===e?Math.ceil:"round"===e?Math.round:n}function s(e,n){return"false"===e?!1:"true"===e?!0:n}function g(e,n){return"false"===e?!1:"true"===e?!0:n}function m(e,n,t,r,u){var i="-?";r===!1&&u===!0?i="-":r===!0&&u===!1&&(i="");var a="[0-9]{0,"+e+"}";0===e&&(a="0");var o="(\\"+t+"([0-9]){0,"+n+"})";return 0===n&&(o=""),new RegExp("^"+i+a+o+"?$")}function d(e){return String(e).replace(/^0+/g,"").replace(/^-0(\d+)/g,"-$1").replace(/^-([\.,])/g,"-0$1").replace(/^[\.,]/g,"0$&")}function v(e,n){return"."===n?String(e).replace(/\./g,""):String(e).replace(/,/g,"")}function p(e,n){return String(e).replace(/\B(?=(\d{3})+(?!\d))/g,n)}function h(e,n){e.$setViewValue(n),e.$render()}function S(e,n,t,u,i,a){if(e=Number(e),!isNaN(e)&&isFinite(e)){var o=Math.pow(10,n);return e=i?r((u(e*o)/o).toFixed(n),t):r(String(u(e*o)/o),t),a&&(e=p(e,"."===t?",":".")),e}return i?0..toFixed(n):"0"}function w(e){var n=0;if(document.selection){e.focus();var t=document.selection.createRange();t.moveStart("character",-e.value.length),n=t.text.length}else(e.selectionStart||"0"==e.selectionStart)&&(n=e.selectionStart);return n}function N(e,n){if(null!==e)if(e.createTextRange){var t=e.createTextRange();t.move("character",n),t.select()}else e.selectionStart?(e.focus(),e.setSelectionRange(n,n)):e.focus()}function y(e,n,t){for(var r=0,u=0,i=0;i<e.length;i++)if(e[i]!==n){if(r++,r>=t)break}else u++;return u}function b(e){return{restrict:"A",require:"?ngModel",scope:{awnum:"@",numInt:"@",numFract:"@",numSep:"@",numPos:"@",numNeg:"@",numRound:"@",numThousand:"@"},link:function(e,n,s,b){if(!n[0]||"INPUT"!==n[0].tagName||"text"!==n[0].type)return void console.warn("Directive angular-dynamic-number works only for 'input' tag with type = 'text'");if(!b)return void console.warn("Directive angular-dynamic-number need ngModel attribute");var $=i(e.numInt,6),x=a(e.numFract,2),M=o(e.numSep,"."),F=c(e.numPos,!0),R=f(e.numNeg,!0),I=l(e.numRound,Math.round),T=g(e.numThousand,!1);if(F===!1&&R===!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 V=m($,x,M,F,R);b.$parsers.unshift(function(e){var i=String(e);if(/^[\.,]{2,}/.test(i))return h(b,0),0;var a=w(n[0]),o=i.slice(0,a),c=o.length;if(o=v(o,"."===M?",":"."),i=v(i,"."===M?",":"."),o=d(o),i=d(i),""===i&&"0"===String(e).charAt(0))return h(b,0),0;if(i===t||""===i)return 0;if("-"===i)return h(b,"-"),0;if(V.test(i)===!1){var f=r(b.$modelValue,M);return T&&(f=p(f,"."===M?",":".")),h(b,f),N(n[0],a-1),b.$modelValue}var l=0,s=a-c+o.length;return T&&(i=p(i,"."===M?",":"."),l=y(i,"."===M?",":".",s)),h(b,i),N(n[0],s+l),u(i,M)}),b.$formatters.push(function(e){return S(e,x,M,I,!1,T)})}}}n.module("dynamicNumber",[]).provider("dynamicNumberStrategy",function(){var e={};this.addStrategy=function(n,t){e[n]=t},this.getStrategy=function(n){return e[n]},this.$get=function(){return{getStrategy:function(n){return e[n]}}}}).filter("awnum",function(){return function(e,n,t,r,u,i){var c=a(n,2),f=o(t,"."),m=l(r,Math.round),d=s(u,!1),v=g(i,!1);return S(e,c,f,m,d,v)}}).directive("awnum",["dynamicNumberStrategy",b])}(window,window.angular);
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc