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.6.1 to 1.6.2

21

dist/mask.js
/*!
* angular-ui-mask
* https://github.com/angular-ui/ui-mask
* Version: 1.6.1 - 2015-11-14T14:48:38.974Z
* Version: 1.6.2 - 2015-11-28T04:12:02.429Z
* License: MIT

@@ -213,3 +213,2 @@ */

iElement.bind(linkOptions.eventsToHandle.join(' '), eventHandler);
iElement.bind('paste', onPasteHandler);
eventsBound = true;

@@ -229,3 +228,2 @@ }

iElement.unbind('focus', eventHandler);
iElement.unbind('paste', onPasteHandler);
eventsBound = false;

@@ -342,4 +340,4 @@ }

}
var prevValue = iElement.val();
var prevValue = iElement.val();
function blurHandler() {

@@ -364,3 +362,3 @@ if (linkOptions.clearOnBlur) {

}
function triggerChangeEvent(element) {

@@ -404,7 +402,2 @@ var change;

function onPasteHandler() {
/*jshint validthis: true */
setCaretPosition(this, iElement.val().length);
}
function eventHandler(e) {

@@ -481,3 +474,3 @@ /*jshint validthis: true */

oldValueUnmasked = valUnmasked;
//additional check to fix the problem where the viewValue is out of sync with the value of the element.

@@ -487,5 +480,5 @@ //better fix for commit 2a83b5fb8312e71d220a497545f999fc82503bd9 (I think)

valAltered = true;
iElement.val(valMasked);
//we need this check. What could happen if you don't have it is that you'll set the model value without the user

@@ -492,0 +485,0 @@ //actually doing anything. Meaning, things like pristine and touched will be set.

/*!
* angular-ui-mask
* https://github.com/angular-ui/ui-mask
* Version: 1.6.1 - 2015-11-14T14:48:38.974Z
* Version: 1.6.2 - 2015-11-28T04:12:02.429Z
* 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,i,r,a){function u(e){return angular.isDefined(e)?(k(e),q?(h(),d(),!0):f()):f()}function o(e){e&&(_=e,q&&i.val(m(p(i.val()))))}function l(){return u(r.uiMask)}function c(e){return q?(j=p(e||""),z=v(j),a.$setValidity("mask",z),z&&j.length?m(j):void 0):e}function s(e){return q?(j=p(e||""),z=v(j),a.$viewValue=j.length?m(j):"",a.$setValidity("mask",z),z?G?a.$viewValue:j:void 0):e}function f(){return q=!1,g(),angular.isDefined(K)?i.attr("placeholder",K):i.removeAttr("placeholder"),angular.isDefined(N)?i.attr("maxlength",N):i.removeAttr("maxlength"),i.val(a.$modelValue),a.$viewValue=a.$modelValue,!1}function h(){j=Z=p(a.$modelValue||""),H=F=m(j),z=v(j),r.maxlength&&i.attr("maxlength",2*S[S.length-1]),K||i.attr("placeholder",_);for(var e=a.$modelValue,n=a.$formatters.length;n--;)e=a.$formatters[n](e);a.$viewValue=e||"",a.$render()}function d(){I||(i.bind("blur",y),i.bind("mousedown mouseup",E),i.bind(J.eventsToHandle.join(" "),V),i.bind("paste",x),I=!0)}function g(){I&&(i.unbind("blur",y),i.unbind("mousedown",E),i.unbind("mouseup",E),i.unbind("input",V),i.unbind("keyup",V),i.unbind("click",V),i.unbind("focus",V),i.unbind("paste",x),I=!1)}function v(e){return e.length?e.length>=T:!0}function p(e){var n="",t=C.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 m(e){var n="",t=S.slice();return angular.forEach(_.split(""),function(i,r){e.length&&r===t[0]?(n+=e.charAt(0)||"_",e=e.substr(1),t.shift()):n+=i}),n}function b(e){var n,t=angular.isDefined(r.uiMaskPlaceholder)?r.uiMaskPlaceholder:r.placeholder;return angular.isDefined(t)&&t[e]?t[e]:(n=angular.isDefined(r.uiMaskPlaceholderChar)&&r.uiMaskPlaceholderChar?r.uiMaskPlaceholderChar:"_","space"===n.toLowerCase()?" ":n[0])}function $(){return _.replace(/[_]+/g,"_").replace(/([^_]+)([a-zA-Z0-9])([^_])/g,"$1$2_$3").split("_")}function k(e){var n=0;if(S=[],C=[],_="",angular.isString(e)){T=0;var t=!1,i=0,r=e.split("");angular.forEach(r,function(e,r){J.maskDefinitions[e]?(S.push(n),_+=b(r-i),C.push(J.maskDefinitions[e]),n++,t||T++,t=!1):"?"===e?(t=!0,i++):(_+=e,n++)})}S.push(S.slice().pop()+1),R=$(),q=S.length>1?!0:!1}function y(){J.clearOnBlur&&(B=0,L=0,z&&0!==j.length||(H="",i.val(""),e.$apply(function(){a.$viewValue=""}))),j!==Q&&w(i[0]),Q=j}function w(e){var n;angular.isFunction(window.Event)&&!e.fireEvent?(n=new Event("change",{view:window,bubbles:!0,cancelable:!1}),e.dispatchEvent(n)):"createEvent"in document?(n=document.createEvent("HTMLEvents"),n.initEvent("change",!1,!0),e.dispatchEvent(n)):e.fireEvent&&e.fireEvent("onchange")}function E(e){"mousedown"===e.type?i.bind("mouseout",M):i.unbind("mouseout",M)}function M(){L=P(this),i.unbind("mouseout",M)}function x(){D(this,i.val().length)}function V(n){n=n||{};var t=n.which,r=n.type;if(16!==t&&91!==t){var u,o=i.val(),l=F,c=!1,s=p(o),f=Z,h=A(this)||0,d=B||0,g=h-d,v=S[0],b=S[s.length]||S.slice().shift(),$=L||0,k=P(this)>0,y=$>0,w=o.length>l.length||$&&o.length>l.length-$,E=o.length<l.length||$&&o.length===l.length-$,M=t>=37&&40>=t&&n.shiftKey,x=37===t,V=8===t||"keyup"!==r&&E&&-1===g,C=46===t||"keyup"!==r&&E&&0===g&&!y,_=(x||V||"click"===r)&&h>v;if(L=P(this),!M&&(!k||"click"!==r&&"keyup"!==r)){if("input"===r&&E&&!y&&s===f){for(;V&&h>v&&!O(h);)h--;for(;C&&b>h&&-1===S.indexOf(h);)h++;var R=S.indexOf(h);s=s.substring(0,R)+s.substring(R+1),c=!0}for(u=m(s),F=u,Z=s,!c&&o.length>u.length&&(c=!0),i.val(u),c&&e.$apply(function(){a.$setViewValue(s)}),w&&v>=h&&(h=v+1),_&&h--,h=h>b?b:v>h?v:h;!O(h)&&h>v&&b>h;)h+=_?-1:1;(_&&b>h||w&&!O(d))&&h++,B=h,D(this,h)}}}function O(e){return S.indexOf(e)>-1}function A(e){if(!e)return 0;if(void 0!==e.selectionStart)return e.selectionStart;if(document.selection&&n(i[0])){e.focus();var t=document.selection.createRange();return t.moveStart("character",e.value?-e.value.length:0),t.text.length}return 0}function D(e,t){if(!e)return 0;if(0!==e.offsetWidth&&0!==e.offsetHeight)if(e.setSelectionRange)n(i[0])&&(e.focus(),e.setSelectionRange(t,t));else if(e.createTextRange){var r=e.createTextRange();r.collapse(!0),r.moveEnd("character",t),r.moveStart("character",t),r.select()}}function P(e){return e?void 0!==e.selectionStart?e.selectionEnd-e.selectionStart:document.selection?document.selection.createRange().text.length:0:0}var S,C,_,R,T,j,H,z,F,Z,B,L,q=!1,I=!1,K=r.placeholder,N=r.maxlength,W=a.$isEmpty;a.$isEmpty=function(e){return W(C?p(e||""):e)};var G=!1;r.$observe("modelViewValue",function(e){"true"===e&&(G=!0)});var J={};r.uiOptions?(J=e.$eval("["+r.uiOptions+"]"),J=angular.isObject(J[0])?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.isArray(n[t])&&(n[t]=angular.extend({},e[t],n[t])));return n}(t,J[0]):t):J=t,r.$observe("uiMask",u),angular.isDefined(r.uiMaskPlaceholder)?r.$observe("uiMaskPlaceholder",o):r.$observe("placeholder",o),angular.isDefined(r.uiMaskPlaceholderChar)&&r.$observe("uiMaskPlaceholderChar",l),a.$formatters.push(c),a.$parsers.push(s);var Q=i.val();i.bind("mousedown mouseup",E),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 i=0;if(arguments.length>1&&(i=Number(arguments[1]),i!==i?i=0:0!==i&&i!==1/0&&i!==-(1/0)&&(i=(i>0||-1)*Math.floor(Math.abs(i)))),i>=t)return-1;for(var r=i>=0?i:Math.max(t-Math.abs(i),0);t>r;r++)if(r in n&&n[r]===e)return r;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,a){function u(e){return angular.isDefined(e)?(k(e),L?(h(),d(),!0):f()):f()}function o(e){e&&(C=e,L&&r.val(m(p(r.val()))))}function l(){return u(i.uiMask)}function c(e){return L?(T=p(e||""),H=v(T),a.$setValidity("mask",H),H&&T.length?m(T):void 0):e}function s(e){return L?(T=p(e||""),H=v(T),a.$viewValue=T.length?m(T):"",a.$setValidity("mask",H),H?W?a.$viewValue:T:void 0):e}function f(){return L=!1,g(),angular.isDefined(I)?r.attr("placeholder",I):r.removeAttr("placeholder"),angular.isDefined(K)?r.attr("maxlength",K):r.removeAttr("maxlength"),r.val(a.$modelValue),a.$viewValue=a.$modelValue,!1}function h(){T=F=p(a.$modelValue||""),j=z=m(T),H=v(T),i.maxlength&&r.attr("maxlength",2*P[P.length-1]),I||r.attr("placeholder",C);for(var e=a.$modelValue,n=a.$formatters.length;n--;)e=a.$formatters[n](e);a.$viewValue=e||"",a.$render()}function d(){q||(r.bind("blur",y),r.bind("mousedown mouseup",E),r.bind(G.eventsToHandle.join(" "),x),q=!0)}function g(){q&&(r.unbind("blur",y),r.unbind("mousedown",E),r.unbind("mouseup",E),r.unbind("input",x),r.unbind("keyup",x),r.unbind("click",x),r.unbind("focus",x),q=!1)}function v(e){return e.length?e.length>=R:!0}function p(e){var n="",t=S.slice();return e=e.toString(),angular.forEach(_,function(n){e=e.replace(n,"")}),angular.forEach(e.split(""),function(e){t.length&&t[0].test(e)&&(n+=e,t.shift())}),n}function m(e){var n="",t=P.slice();return angular.forEach(C.split(""),function(r,i){e.length&&i===t[0]?(n+=e.charAt(0)||"_",e=e.substr(1),t.shift()):n+=r}),n}function b(e){var n,t=angular.isDefined(i.uiMaskPlaceholder)?i.uiMaskPlaceholder:i.placeholder;return angular.isDefined(t)&&t[e]?t[e]:(n=angular.isDefined(i.uiMaskPlaceholderChar)&&i.uiMaskPlaceholderChar?i.uiMaskPlaceholderChar:"_","space"===n.toLowerCase()?" ":n[0])}function $(){return C.replace(/[_]+/g,"_").replace(/([^_]+)([a-zA-Z0-9])([^_])/g,"$1$2_$3").split("_")}function k(e){var n=0;if(P=[],S=[],C="",angular.isString(e)){R=0;var t=!1,r=0,i=e.split("");angular.forEach(i,function(e,i){G.maskDefinitions[e]?(P.push(n),C+=b(i-r),S.push(G.maskDefinitions[e]),n++,t||R++,t=!1):"?"===e?(t=!0,r++):(C+=e,n++)})}P.push(P.slice().pop()+1),_=$(),L=P.length>1?!0:!1}function y(){G.clearOnBlur&&(Z=0,B=0,H&&0!==T.length||(j="",r.val(""),e.$apply(function(){a.$viewValue=""}))),T!==J&&w(r[0]),J=T}function w(e){var n;angular.isFunction(window.Event)&&!e.fireEvent?(n=new Event("change",{view:window,bubbles:!0,cancelable:!1}),e.dispatchEvent(n)):"createEvent"in document?(n=document.createEvent("HTMLEvents"),n.initEvent("change",!1,!0),e.dispatchEvent(n)):e.fireEvent&&e.fireEvent("onchange")}function E(e){"mousedown"===e.type?r.bind("mouseout",M):r.unbind("mouseout",M)}function M(){B=D(this),r.unbind("mouseout",M)}function x(n){n=n||{};var t=n.which,i=n.type;if(16!==t&&91!==t){var u,o=r.val(),l=z,c=!1,s=p(o),f=F,h=O(this)||0,d=Z||0,g=h-d,v=P[0],b=P[s.length]||P.slice().shift(),$=B||0,k=D(this)>0,y=$>0,w=o.length>l.length||$&&o.length>l.length-$,E=o.length<l.length||$&&o.length===l.length-$,M=t>=37&&40>=t&&n.shiftKey,x=37===t,S=8===t||"keyup"!==i&&E&&-1===g,C=46===t||"keyup"!==i&&E&&0===g&&!y,_=(x||S||"click"===i)&&h>v;if(B=D(this),!M&&(!k||"click"!==i&&"keyup"!==i)){if("input"===i&&E&&!y&&s===f){for(;S&&h>v&&!V(h);)h--;for(;C&&b>h&&-1===P.indexOf(h);)h++;var R=P.indexOf(h);s=s.substring(0,R)+s.substring(R+1),c=!0}for(u=m(s),z=u,F=s,!c&&o.length>u.length&&(c=!0),r.val(u),c&&e.$apply(function(){a.$setViewValue(s)}),w&&v>=h&&(h=v+1),_&&h--,h=h>b?b:v>h?v:h;!V(h)&&h>v&&b>h;)h+=_?-1:1;(_&&b>h||w&&!V(d))&&h++,Z=h,A(this,h)}}}function V(e){return P.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 D(e){return e?void 0!==e.selectionStart?e.selectionEnd-e.selectionStart:document.selection?document.selection.createRange().text.length:0:0}var P,S,C,_,R,T,j,H,z,F,Z,B,L=!1,q=!1,I=i.placeholder,K=i.maxlength,N=a.$isEmpty;a.$isEmpty=function(e){return N(S?p(e||""):e)};var W=!1;i.$observe("modelViewValue",function(e){"true"===e&&(W=!0)});var G={};i.uiOptions?(G=e.$eval("["+i.uiOptions+"]"),G=angular.isObject(G[0])?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.isArray(n[t])&&(n[t]=angular.extend({},e[t],n[t])));return n}(t,G[0]):t):G=t,i.$observe("uiMask",u),angular.isDefined(i.uiMaskPlaceholder)?i.$observe("uiMaskPlaceholder",o):i.$observe("placeholder",o),angular.isDefined(i.uiMaskPlaceholderChar)&&i.$observe("uiMaskPlaceholderChar",l),a.$formatters.push(c),a.$parsers.push(s);var J=r.val();r.bind("mousedown mouseup",E),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.6.1",
"version": "1.6.2",
"author": "https://github.com/angular-ui/ui-mask/graphs/contributors",

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

@@ -203,3 +203,2 @@ /*

iElement.bind(linkOptions.eventsToHandle.join(' '), eventHandler);
iElement.bind('paste', onPasteHandler);
eventsBound = true;

@@ -219,3 +218,2 @@ }

iElement.unbind('focus', eventHandler);
iElement.unbind('paste', onPasteHandler);
eventsBound = false;

@@ -332,4 +330,4 @@ }

}
var prevValue = iElement.val();
var prevValue = iElement.val();
function blurHandler() {

@@ -354,3 +352,3 @@ if (linkOptions.clearOnBlur) {

}
function triggerChangeEvent(element) {

@@ -394,7 +392,2 @@ var change;

function onPasteHandler() {
/*jshint validthis: true */
setCaretPosition(this, iElement.val().length);
}
function eventHandler(e) {

@@ -471,3 +464,3 @@ /*jshint validthis: true */

oldValueUnmasked = valUnmasked;
//additional check to fix the problem where the viewValue is out of sync with the value of the element.

@@ -477,5 +470,5 @@ //better fix for commit 2a83b5fb8312e71d220a497545f999fc82503bd9 (I think)

valAltered = true;
iElement.val(valMasked);
//we need this check. What could happen if you don't have it is that you'll set the model value without the user

@@ -482,0 +475,0 @@ //actually doing anything. Meaning, things like pristine and touched will be set.

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