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.6 to 1.6.7

8

dist/mask.js
/*!
* angular-ui-mask
* https://github.com/angular-ui/ui-mask
* Version: 1.6.6 - 2015-12-17T04:07:08.253Z
* Version: 1.6.7 - 2015-12-30T03:35:19.510Z
* License: MIT

@@ -78,3 +78,7 @@ */

// If the mask is processed, then we need to update the value
if (maskProcessed) {
// but don't set the value if there is nothing entered into the element
// and there is a placeholder attribute on the element because that
// will only set the value as the blank maskPlaceholder
// and override the placeholder on the element
if (maskProcessed && !(iElement.val().length === 0 && angular.isDefined(iAttrs.placeholder))) {
iElement.val(maskValue(unmaskValue(iElement.val())));

@@ -81,0 +85,0 @@ }

/*!
* angular-ui-mask
* https://github.com/angular-ui/ui-mask
* Version: 1.6.6 - 2015-12-17T04:07:08.253Z
* Version: 1.6.7 - 2015-12-30T03:35:19.510Z
* 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),B?(h(),d(),!0):f()):f()}function o(e){e&&(_=e,B&&i.val(m(p(i.val()))))}function l(){return u(r.uiMask)}function c(e){return B?(R=p(e||""),H=v(R),a.$setValidity("mask",H),H&&R.length?m(R):void 0):e}function s(e){return B?(R=p(e||""),H=v(R),a.$viewValue=R.length?m(R):"",a.$setValidity("mask",H),H?W?a.$viewValue:R:void 0):e}function f(){return B=!1,g(),angular.isDefined(q)?i.attr("placeholder",q):i.removeAttr("placeholder"),angular.isDefined(I)?i.attr("maxlength",I):i.removeAttr("maxlength"),i.val(a.$modelValue),a.$viewValue=a.$modelValue,!1}function h(){R=F=p(a.$modelValue||""),T=z=m(R),H=v(R),r.maxlength&&i.attr("maxlength",2*P[P.length-1]),q||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(){L||(i.bind("blur",y),i.bind("mousedown mouseup",E),i.bind(G.eventsToHandle.join(" "),x),L=!0)}function g(){L&&(i.unbind("blur",y),i.unbind("mousedown",E),i.unbind("mouseup",E),i.unbind("input",x),i.unbind("keyup",x),i.unbind("click",x),i.unbind("focus",x),L=!1)}function v(e){return e.length?e.length>=j:!0}function p(e){var n="",t=S.slice();return e=e.toString(),angular.forEach(C,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(_.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 $(){var e,n=_.split("");return P&&!isNaN(P[0])&&angular.forEach(P,function(e){n[e]="_"}),e=n.join(""),e.replace(/[_]+/g,"_").replace(/([^_]+)([a-zA-Z0-9])([^_])/g,"$1$2_$3").split("_")}function k(e){var n=0;if(P=[],S=[],_="",angular.isString(e)){j=0;var t=!1,i=0,r=e.split("");angular.forEach(r,function(e,r){G.maskDefinitions[e]?(P.push(n),_+=b(r-i),S.push(G.maskDefinitions[e]),n++,t||j++,t=!1):"?"===e?(t=!0,i++):(_+=e,n++)})}P.push(P.slice().pop()+1),C=$(),B=P.length>1?!0:!1}function y(){G.clearOnBlur&&(N=0,Z=0,H&&0!==R.length||(T="",i.val(""),e.$apply(function(){a.$viewValue=""}))),R!==J&&w(i[0]),J=R}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(){Z=D(this),i.unbind("mouseout",M)}function x(n){n=n||{};var t=n.which,r=n.type;if(16!==t&&91!==t){var u,o=i.val(),l=z,c=!1,s=p(o),f=F,h=O(this)||0,d=N||0,g=h-d,v=P[0],b=P[s.length]||P.slice().shift(),$=Z||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"!==r&&E&&-1===g,_=46===t||"keyup"!==r&&E&&0===g&&!y,C=(x||S||"click"===r)&&h>v;if(Z=D(this),!M&&(!k||"click"!==r&&"keyup"!==r)){if("input"===r&&E&&!y&&s===f){for(;S&&h>v&&!V(h);)h--;for(;_&&b>h&&-1===P.indexOf(h);)h++;var j=P.indexOf(h);s=s.substring(0,j)+s.substring(j+1),c=!0}for(u=m(s),z=u,F=s,!c&&o.length>u.length&&(c=!0),i.val(u),c&&e.$apply(function(){a.$setViewValue(s)}),w&&v>=h&&(h=v+1),C&&h--,h=h>b?b:v>h?v:h;!V(h)&&h>v&&b>h;)h+=C?-1:1;(C&&b>h||w&&!V(d))&&h++,N=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(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 A(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 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,j,R,T,H,z,F,N,Z,B=!1,L=!1,q=r.placeholder,I=r.maxlength,K=a.$isEmpty;a.$isEmpty=function(e){return K(B?p(e||""):e)};var W=!1;r.$observe("modelViewValue",function(e){"true"===e&&(W=!0)});var G={};r.uiOptions?(G=e.$eval("["+r.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,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.unshift(s);var J=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,i,r,a){function u(e){return angular.isDefined(e)?(k(e),B?(h(),d(),!0):f()):f()}function o(e){e&&(_=e,!B||0===i.val().length&&angular.isDefined(r.placeholder)||i.val(m(p(i.val()))))}function l(){return u(r.uiMask)}function c(e){return B?(R=p(e||""),H=v(R),a.$setValidity("mask",H),H&&R.length?m(R):void 0):e}function s(e){return B?(R=p(e||""),H=v(R),a.$viewValue=R.length?m(R):"",a.$setValidity("mask",H),H?W?a.$viewValue:R:void 0):e}function f(){return B=!1,g(),angular.isDefined(q)?i.attr("placeholder",q):i.removeAttr("placeholder"),angular.isDefined(I)?i.attr("maxlength",I):i.removeAttr("maxlength"),i.val(a.$modelValue),a.$viewValue=a.$modelValue,!1}function h(){R=F=p(a.$modelValue||""),T=z=m(R),H=v(R),r.maxlength&&i.attr("maxlength",2*P[P.length-1]),q||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(){L||(i.bind("blur",y),i.bind("mousedown mouseup",E),i.bind(G.eventsToHandle.join(" "),x),L=!0)}function g(){L&&(i.unbind("blur",y),i.unbind("mousedown",E),i.unbind("mouseup",E),i.unbind("input",x),i.unbind("keyup",x),i.unbind("click",x),i.unbind("focus",x),L=!1)}function v(e){return e.length?e.length>=j:!0}function p(e){var n="",t=S.slice();return e=e.toString(),angular.forEach(C,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(_.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 $(){var e,n=_.split("");return P&&!isNaN(P[0])&&angular.forEach(P,function(e){n[e]="_"}),e=n.join(""),e.replace(/[_]+/g,"_").replace(/([^_]+)([a-zA-Z0-9])([^_])/g,"$1$2_$3").split("_")}function k(e){var n=0;if(P=[],S=[],_="",angular.isString(e)){j=0;var t=!1,i=0,r=e.split("");angular.forEach(r,function(e,r){G.maskDefinitions[e]?(P.push(n),_+=b(r-i),S.push(G.maskDefinitions[e]),n++,t||j++,t=!1):"?"===e?(t=!0,i++):(_+=e,n++)})}P.push(P.slice().pop()+1),C=$(),B=P.length>1?!0:!1}function y(){G.clearOnBlur&&(N=0,Z=0,H&&0!==R.length||(T="",i.val(""),e.$apply(function(){a.$viewValue=""}))),R!==J&&w(i[0]),J=R}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(){Z=A(this),i.unbind("mouseout",M)}function x(n){n=n||{};var t=n.which,r=n.type;if(16!==t&&91!==t){var u,o=i.val(),l=z,c=!1,s=p(o),f=F,h=O(this)||0,d=N||0,g=h-d,v=P[0],b=P[s.length]||P.slice().shift(),$=Z||0,k=A(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"!==r&&E&&-1===g,_=46===t||"keyup"!==r&&E&&0===g&&!y,C=(x||S||"click"===r)&&h>v;if(Z=A(this),!M&&(!k||"click"!==r&&"keyup"!==r)){if("input"===r&&E&&!y&&s===f){for(;S&&h>v&&!V(h);)h--;for(;_&&b>h&&-1===P.indexOf(h);)h++;var j=P.indexOf(h);s=s.substring(0,j)+s.substring(j+1),c=!0}for(u=m(s),z=u,F=s,!c&&o.length>u.length&&(c=!0),i.val(u),c&&e.$apply(function(){a.$setViewValue(s)}),w&&v>=h&&(h=v+1),C&&h--,h=h>b?b:v>h?v:h;!V(h)&&h>v&&b>h;)h+=C?-1:1;(C&&b>h||w&&!V(d))&&h++,N=h,D(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(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 A(e){return e?void 0!==e.selectionStart?e.selectionEnd-e.selectionStart:document.selection?document.selection.createRange().text.length:0:0}var P,S,_,C,j,R,T,H,z,F,N,Z,B=!1,L=!1,q=r.placeholder,I=r.maxlength,K=a.$isEmpty;a.$isEmpty=function(e){return K(B?p(e||""):e)};var W=!1;r.$observe("modelViewValue",function(e){"true"===e&&(W=!0)});var G={};r.uiOptions?(G=e.$eval("["+r.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,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.unshift(s);var J=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})}}}}])}();
{
"name": "angular-ui-mask",
"version": "1.6.6",
"version": "1.6.7",
"author": "https://github.com/angular-ui/ui-mask/graphs/contributors",

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

@@ -68,3 +68,7 @@ /*

// If the mask is processed, then we need to update the value
if (maskProcessed) {
// but don't set the value if there is nothing entered into the element
// and there is a placeholder attribute on the element because that
// will only set the value as the blank maskPlaceholder
// and override the placeholder on the element
if (maskProcessed && !(iElement.val().length === 0 && angular.isDefined(iAttrs.placeholder))) {
iElement.val(maskValue(unmaskValue(iElement.val())));

@@ -71,0 +75,0 @@ }

@@ -92,2 +92,3 @@ describe("uiMask", function () {

});
describe("with other directives", function() {

@@ -120,2 +121,11 @@ beforeEach(function () {

});
describe("nested inside another directive", function() {
it("should have the correct placeholder value inside ng-if", function() {
var input = compileElement('<div><div ng-if="showMe"><input type="text" ng-model="x" ui-mask="99/99/9999" ui-mask-placeholder="__/__/____" placeholder="date" /></div></div>');
scope.$apply("showMe = true");
input = input.find('input');
expect(input.val()).toBe("");
})
});
});

@@ -122,0 +132,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