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

angular-ui-mask

Package Overview
Dependencies
Maintainers
2
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-ui-mask - npm Package Compare versions

Comparing version 1.4.4 to 1.4.5

6

dist/mask.js
/*!
* angular-ui-mask
* https://github.com/angular-ui/ui-mask
* Version: 1.4.4 - 2015-08-27T04:31:02.989Z
* Version: 1.4.5 - 2015-09-04T09:07:09.797Z
* License: MIT

@@ -124,3 +124,5 @@ */

} else {
angular.extend(current[i], original[i]);
if (angular.isObject(current[i])) {
angular.extend(current[i], original[i]);
}
}

@@ -127,0 +129,0 @@ }

/*!
* angular-ui-mask
* https://github.com/angular-ui/ui-mask
* Version: 1.4.4 - 2015-08-27T04:31:02.989Z
* Version: 1.4.5 - 2015-09-04T09:07:09.797Z
* License: MIT
*/
!function(){"use strict";angular.module("ui.mask",[]).value("uiMaskConfig",{maskDefinitions:{9:/\d/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},clearOnBlur:!0,eventsToHandle:["input","keyup","click","focus"]}).directive("uiMask",["uiMaskConfig",function(e){function n(e){return e===document.activeElement&&(!document.hasFocus||document.hasFocus())&&!!(e.type||e.href||~e.tabIndex)}return{priority:100,require:"ngModel",restrict:"A",compile:function(){var t=e;return function(e,r,i,u){function a(e){return angular.isDefined(e)?($(e),C?(f(),h(),!0):c()):c()}function o(e){e&&(_=e,C&&r.val(v(p(r.val()))))}function l(e){return C?(T=p(e||""),q=g(T),u.$setValidity("mask",q),q&&T.length?v(T):void 0):e}function s(e){return C?(T=p(e||""),q=g(T),u.$viewValue=T.length?v(T):"",u.$setValidity("mask",q),""===T&&i.required&&u.$setValidity("required",!u.$error.required),q?N?u.$viewValue:T:void 0):e}function c(){return C=!1,d(),angular.isDefined(I)?r.attr("placeholder",I):r.removeAttr("placeholder"),angular.isDefined(K)?r.attr("maxlength",K):r.removeAttr("maxlength"),r.val(u.$modelValue),u.$viewValue=u.$modelValue,!1}function f(){T=H=p(u.$modelValue||""),j=z=v(T),q=g(T),i.maxlength&&r.attr("maxlength",2*D[D.length-1]),I||r.attr("placeholder",_);for(var e=u.$modelValue,n=u.$formatters.length;n--;)e=u.$formatters[n](e);u.$viewValue=e||"",u.$render()}function h(){F||(r.bind("blur",y),r.bind("mousedown mouseup",k),r.bind(W.eventsToHandle.join(" "),w),r.bind("paste",V),F=!0)}function d(){F&&(r.unbind("blur",y),r.unbind("mousedown",k),r.unbind("mouseup",k),r.unbind("input",w),r.unbind("keyup",w),r.unbind("click",w),r.unbind("focus",w),r.unbind("paste",V),F=!1)}function g(e){return e.length?e.length>=P:!0}function p(e){var n="",t=E.slice();return e=e.toString(),angular.forEach(R,function(n){e=e.replace(n,"")}),angular.forEach(e.split(""),function(e){t.length&&t[0].test(e)&&(n+=e,t.shift())}),n}function v(e){var n="",t=D.slice();return angular.forEach(_.split(""),function(r,i){e.length&&i===t[0]?(n+=e.charAt(0)||"_",e=e.substr(1),t.shift()):n+=r}),n}function m(e){var n=angular.isDefined(i.uiMaskPlaceholder)?i.uiMaskPlaceholder:i.placeholder;return"undefined"!=typeof n&&n[e]?n[e]:"_"}function b(){return _.replace(/[_]+/g,"_").replace(/([^_]+)([a-zA-Z0-9])([^_])/g,"$1$2_$3").split("_")}function $(e){var n=0;if(D=[],E=[],_="","string"==typeof e){P=0;var t=!1,r=0,i=e.split("");angular.forEach(i,function(e,i){W.maskDefinitions[e]?(D.push(n),_+=m(i-r),E.push(W.maskDefinitions[e]),n++,t||P++):"?"===e?(t=!0,r++):(_+=e,n++)})}D.push(D.slice().pop()+1),R=b(),C=D.length>1?!0:!1}function y(){W.clearOnBlur&&(Z=0,B=0,q&&0!==T.length||(j="",r.val(""),e.$apply(function(){u.$setViewValue("")})))}function k(e){"mousedown"===e.type?r.bind("mouseout",x):r.unbind("mouseout",x)}function x(){B=S(this),r.unbind("mouseout",x)}function V(){A(this,r.val().length)}function w(e){e=e||{};var n=e.which,t=e.type;if(16!==n&&91!==n){var i,a=r.val(),o=z,l=p(a),s=H,c=O(this)||0,f=Z||0,h=c-f,d=D[0],g=D[l.length]||D.slice().shift(),m=B||0,b=S(this)>0,$=m>0,y=a.length>o.length||m&&a.length>o.length-m,k=a.length<o.length||m&&a.length===o.length-m,x=n>=37&&40>=n&&e.shiftKey,V=37===n,w=8===n||"keyup"!==t&&k&&-1===h,E=46===n||"keyup"!==t&&k&&0===h&&!$,_=(V||w||"click"===t)&&c>d;if(B=S(this),!x&&(!b||"click"!==t&&"keyup"!==t)){if("input"===t&&k&&!$&&l===s){for(;w&&c>d&&!M(c);)c--;for(;E&&g>c&&-1===D.indexOf(c);)c++;var R=D.indexOf(c);l=l.substring(0,R)+l.substring(R+1)}for(i=v(l),z=i,H=l,r.val(i),u.$setViewValue(l),y&&d>=c&&(c=d+1),_&&c--,c=c>g?g:d>c?d:c;!M(c)&&c>d&&g>c;)c+=_?-1:1;(_&&g>c||y&&!M(f))&&c++,Z=c,A(this,c)}}}function M(e){return D.indexOf(e)>-1}function O(e){if(!e)return 0;if(void 0!==e.selectionStart)return e.selectionStart;if(document.selection&&n(r[0])){e.focus();var t=document.selection.createRange();return t.moveStart("character",e.value?-e.value.length:0),t.text.length}return 0}function A(e,t){if(!e)return 0;if(0!==e.offsetWidth&&0!==e.offsetHeight)if(e.setSelectionRange)n(r[0])&&(e.focus(),e.setSelectionRange(t,t));else if(e.createTextRange){var i=e.createTextRange();i.collapse(!0),i.moveEnd("character",t),i.moveStart("character",t),i.select()}}function S(e){return e?void 0!==e.selectionStart?e.selectionEnd-e.selectionStart:document.selection?document.selection.createRange().text.length:0:0}var D,E,_,R,P,T,j,q,z,H,Z,B,C=!1,F=!1,I=i.placeholder,K=i.maxlength,N=!1;i.$observe("modelViewValue",function(e){"true"===e&&(N=!0)});var W={};i.uiOptions?(W=e.$eval("["+i.uiOptions+"]"),angular.isObject(W[0])&&(W=function(e,n){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(void 0===n[t]?n[t]=angular.copy(e[t]):angular.extend(n[t],e[t]));return n}(t,W[0]))):W=t,i.$observe("uiMask",a),angular.isDefined(i.uiMaskPlaceholder)?i.$observe("uiMaskPlaceholder",o):i.$observe("placeholder",o),u.$formatters.push(l),u.$parsers.push(s),r.bind("mousedown mouseup",k),Array.prototype.indexOf||(Array.prototype.indexOf=function(e){if(null===this)throw new TypeError;var n=Object(this),t=n.length>>>0;if(0===t)return-1;var r=0;if(arguments.length>1&&(r=Number(arguments[1]),r!==r?r=0:0!==r&&r!==1/0&&r!==-(1/0)&&(r=(r>0||-1)*Math.floor(Math.abs(r)))),r>=t)return-1;for(var i=r>=0?r:Math.max(t-Math.abs(r),0);t>i;i++)if(i in n&&n[i]===e)return i;return-1})}}}}])}();
!function(){"use strict";angular.module("ui.mask",[]).value("uiMaskConfig",{maskDefinitions:{9:/\d/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},clearOnBlur:!0,eventsToHandle:["input","keyup","click","focus"]}).directive("uiMask",["uiMaskConfig",function(e){function n(e){return e===document.activeElement&&(!document.hasFocus||document.hasFocus())&&!!(e.type||e.href||~e.tabIndex)}return{priority:100,require:"ngModel",restrict:"A",compile:function(){var t=e;return function(e,r,i,u){function a(e){return angular.isDefined(e)?($(e),C?(f(),h(),!0):c()):c()}function o(e){e&&(_=e,C&&r.val(v(p(r.val()))))}function l(e){return C?(P=p(e||""),q=g(P),u.$setValidity("mask",q),q&&P.length?v(P):void 0):e}function s(e){return C?(P=p(e||""),q=g(P),u.$viewValue=P.length?v(P):"",u.$setValidity("mask",q),""===P&&i.required&&u.$setValidity("required",!u.$error.required),q?N?u.$viewValue:P:void 0):e}function c(){return C=!1,d(),angular.isDefined(I)?r.attr("placeholder",I):r.removeAttr("placeholder"),angular.isDefined(K)?r.attr("maxlength",K):r.removeAttr("maxlength"),r.val(u.$modelValue),u.$viewValue=u.$modelValue,!1}function f(){P=H=p(u.$modelValue||""),T=z=v(P),q=g(P),i.maxlength&&r.attr("maxlength",2*D[D.length-1]),I||r.attr("placeholder",_);for(var e=u.$modelValue,n=u.$formatters.length;n--;)e=u.$formatters[n](e);u.$viewValue=e||"",u.$render()}function h(){F||(r.bind("blur",y),r.bind("mousedown mouseup",k),r.bind(W.eventsToHandle.join(" "),w),r.bind("paste",V),F=!0)}function d(){F&&(r.unbind("blur",y),r.unbind("mousedown",k),r.unbind("mouseup",k),r.unbind("input",w),r.unbind("keyup",w),r.unbind("click",w),r.unbind("focus",w),r.unbind("paste",V),F=!1)}function g(e){return e.length?e.length>=j:!0}function p(e){var n="",t=E.slice();return e=e.toString(),angular.forEach(R,function(n){e=e.replace(n,"")}),angular.forEach(e.split(""),function(e){t.length&&t[0].test(e)&&(n+=e,t.shift())}),n}function v(e){var n="",t=D.slice();return angular.forEach(_.split(""),function(r,i){e.length&&i===t[0]?(n+=e.charAt(0)||"_",e=e.substr(1),t.shift()):n+=r}),n}function m(e){var n=angular.isDefined(i.uiMaskPlaceholder)?i.uiMaskPlaceholder:i.placeholder;return"undefined"!=typeof n&&n[e]?n[e]:"_"}function b(){return _.replace(/[_]+/g,"_").replace(/([^_]+)([a-zA-Z0-9])([^_])/g,"$1$2_$3").split("_")}function $(e){var n=0;if(D=[],E=[],_="","string"==typeof e){j=0;var t=!1,r=0,i=e.split("");angular.forEach(i,function(e,i){W.maskDefinitions[e]?(D.push(n),_+=m(i-r),E.push(W.maskDefinitions[e]),n++,t||j++):"?"===e?(t=!0,r++):(_+=e,n++)})}D.push(D.slice().pop()+1),R=b(),C=D.length>1?!0:!1}function y(){W.clearOnBlur&&(Z=0,B=0,q&&0!==P.length||(T="",r.val(""),e.$apply(function(){u.$setViewValue("")})))}function k(e){"mousedown"===e.type?r.bind("mouseout",x):r.unbind("mouseout",x)}function x(){B=S(this),r.unbind("mouseout",x)}function V(){A(this,r.val().length)}function w(e){e=e||{};var n=e.which,t=e.type;if(16!==n&&91!==n){var i,a=r.val(),o=z,l=p(a),s=H,c=M(this)||0,f=Z||0,h=c-f,d=D[0],g=D[l.length]||D.slice().shift(),m=B||0,b=S(this)>0,$=m>0,y=a.length>o.length||m&&a.length>o.length-m,k=a.length<o.length||m&&a.length===o.length-m,x=n>=37&&40>=n&&e.shiftKey,V=37===n,w=8===n||"keyup"!==t&&k&&-1===h,E=46===n||"keyup"!==t&&k&&0===h&&!$,_=(V||w||"click"===t)&&c>d;if(B=S(this),!x&&(!b||"click"!==t&&"keyup"!==t)){if("input"===t&&k&&!$&&l===s){for(;w&&c>d&&!O(c);)c--;for(;E&&g>c&&-1===D.indexOf(c);)c++;var R=D.indexOf(c);l=l.substring(0,R)+l.substring(R+1)}for(i=v(l),z=i,H=l,r.val(i),u.$setViewValue(l),y&&d>=c&&(c=d+1),_&&c--,c=c>g?g:d>c?d:c;!O(c)&&c>d&&g>c;)c+=_?-1:1;(_&&g>c||y&&!O(f))&&c++,Z=c,A(this,c)}}}function O(e){return D.indexOf(e)>-1}function M(e){if(!e)return 0;if(void 0!==e.selectionStart)return e.selectionStart;if(document.selection&&n(r[0])){e.focus();var t=document.selection.createRange();return t.moveStart("character",e.value?-e.value.length:0),t.text.length}return 0}function A(e,t){if(!e)return 0;if(0!==e.offsetWidth&&0!==e.offsetHeight)if(e.setSelectionRange)n(r[0])&&(e.focus(),e.setSelectionRange(t,t));else if(e.createTextRange){var i=e.createTextRange();i.collapse(!0),i.moveEnd("character",t),i.moveStart("character",t),i.select()}}function S(e){return e?void 0!==e.selectionStart?e.selectionEnd-e.selectionStart:document.selection?document.selection.createRange().text.length:0:0}var D,E,_,R,j,P,T,q,z,H,Z,B,C=!1,F=!1,I=i.placeholder,K=i.maxlength,N=!1;i.$observe("modelViewValue",function(e){"true"===e&&(N=!0)});var W={};i.uiOptions?(W=e.$eval("["+i.uiOptions+"]"),angular.isObject(W[0])&&(W=function(e,n){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(void 0===n[t]?n[t]=angular.copy(e[t]):angular.isObject(n[t])&&angular.extend(n[t],e[t]));return n}(t,W[0]))):W=t,i.$observe("uiMask",a),angular.isDefined(i.uiMaskPlaceholder)?i.$observe("uiMaskPlaceholder",o):i.$observe("placeholder",o),u.$formatters.push(l),u.$parsers.push(s),r.bind("mousedown mouseup",k),Array.prototype.indexOf||(Array.prototype.indexOf=function(e){if(null===this)throw new TypeError;var n=Object(this),t=n.length>>>0;if(0===t)return-1;var r=0;if(arguments.length>1&&(r=Number(arguments[1]),r!==r?r=0:0!==r&&r!==1/0&&r!==-(1/0)&&(r=(r>0||-1)*Math.floor(Math.abs(r)))),r>=t)return-1;for(var i=r>=0?r:Math.max(t-Math.abs(r),0);t>i;i++)if(i in n&&n[i]===e)return i;return-1})}}}}])}();
{
"name": "angular-ui-mask",
"version": "1.4.4",
"version": "1.4.5",
"author": "https://github.com/angular-ui/ui-mask/graphs/contributors",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -31,2 +31,23 @@ # ui-mask [![Build Status](https://travis-ci.org/angular-ui/ui-mask.svg?branch=master)](https://travis-ci.org/angular-ui/ui-mask) [![npm version](https://badge.fury.io/js/angular-ui-mask.svg)](http://badge.fury.io/js/angular-ui-mask) [![Bower version](https://badge.fury.io/bo/angular-ui-mask.svg)](http://badge.fury.io/bo/angular-ui-mask) [![Join the chat at https://gitter.im/angular-ui/ui-mask](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/angular-ui/ui-mask?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

### Customizing
You can customize several behaviors of ui-mask by taking advantage of the `ui-options` object. Declare `ui-options` as an additional attribute on the same element where you declare `ui-mask`.
Inside of `ui-options`, you can customize these three properties:
* `maskDefinitions` - default: `{
'9': /\d/,
'A': /[a-zA-Z]/,
'*': /[a-zA-Z0-9]/
}`,
* `clearOnBlur` - default: `true`,
* `eventsToHandle` - default: `['input', 'keyup', 'click', 'focus']`
When customizing `eventsToHandle` or `clearOnBlur`, the value you supply will replace the default. To customize `eventsToHandle`, be sure to replace the entire array.
Whereas, `maskDefinitions` is an object, so any custom object you supply will be merged together with the defaults using `angular.extend()`. This allows you to override the defaults selectively, if you wish.
#### maskDefinitions
The keys in `maskDefinitions` represent the special tokens/characters used in your mask declaration to delimit acceptable ranges of inputs. For example, we use '9' here to accept any numeric values for a phone number: `ui-mask="(999) 999-9999"`. The values associated with each token are regexen. Each regex defines the ranges of values that will be acceptable as inputs in the position of that token.
## Development

@@ -33,0 +54,0 @@

@@ -114,3 +114,5 @@ /*

} else {
angular.extend(current[i], original[i]);
if (angular.isObject(current[i])) {
angular.extend(current[i], original[i]);
}
}

@@ -117,0 +119,0 @@ }

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