forked from assisrafael/bower-angular-input-masks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular-input-masks.us.min.js
1 lines (1 loc) · 10.3 KB
/
angular-input-masks.us.min.js
1
require=function e(r,i,a){function n(u,s){if(!i[u]){if(!r[u]){var o="function"==typeof require&&require;if(!s&&o)return o(u,!0);if(t)return t(u,!0);var l=new Error("Cannot find module '"+u+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[u]={exports:{}};r[u][0].call(c.exports,function(e){var i=r[u][1][e];return n(i?i:e)},c,c.exports,e,r,i,a)}return i[u].exports}for(var t="function"==typeof require&&require,u=0;u<a.length;u++)n(a[u]);return n}({1:[function(e,r,i){r.exports=angular.module("ui.utils.masks",[e("./global/global-masks"),e("./us/us-masks")]).name},{"./global/global-masks":3,"./us/us-masks":11}],2:[function(e,r,i){function a(e){var r={"pt-br":"DD/MM/YYYY"},i=r[e.id]||"YYYY-MM-DD";return{restrict:"A",require:"ngModel",link:function(e,r,a,u){function s(e){if(u.$isEmpty(e))return e;var r=e;"object"==typeof e&&(r=n(e).format(i)),r=r.replace(/[^0-9]/g,"");var a=o.apply(r)||"";return a.trim().replace(/[^0-9]$/,"")}var o=new t(i.replace(/[YMD]/g,"0"));u.$formatters.push(s),u.$parsers.push(function(e){if(u.$isEmpty(e))return e;var r=s(e);return u.$viewValue!==r&&(u.$setViewValue(r),u.$render()),n(r,i).toDate()}),u.$validators.date=function(e,r){return u.$isEmpty(e)?!0:n(r,i).isValid()&&r.length===i.length}}}}var n=e("moment"),t=e("string-mask");a.$inject=["$locale"],r.exports=a},{moment:void 0,"string-mask":void 0}],3:[function(e,r,i){var a=angular.module("ui.utils.masks.global",[e("../helpers")]).directive("uiDateMask",e("./date/date")).directive("uiMoneyMask",e("./money/money")).directive("uiNumberMask",e("./number/number")).directive("uiPercentageMask",e("./percentage/percentage")).directive("uiScientificNotationMask",e("./scientific-notation/scientific-notation")).directive("uiTimeMask",e("./time/time"));r.exports=a.name},{"../helpers":9,"./date/date":2,"./money/money":4,"./number/number":5,"./percentage/percentage":6,"./scientific-notation/scientific-notation":7,"./time/time":8}],4:[function(e,r,i){function a(e,r,i){return{restrict:"A",require:"ngModel",link:function(a,u,s,o){function l(e){var r=e>0?m+new Array(e+1).join("0"):"",i=v+" #"+p+"##0"+r;return new n(i,{reverse:!0})}function c(e){if(o.$isEmpty(e))return e;var r=angular.isDefined(s.uiNegativeNumber)&&0>e?"-":"",a=i.prepareNumberToFormatter(e,d);return r+$.apply(a)}function f(e){if(o.$isEmpty(e))return e;var r=e.replace(/[^\d]+/g,"");r=r.replace(/^[0]+([1-9])/,"$1");var i=$.apply(r);if(angular.isDefined(s.uiNegativeNumber)){var a="-"===e[0],n="-"===e.slice(-1);n^a&&r&&(r*=-1,i="-"+i)}return e!==i&&(o.$setViewValue(i),o.$render()),i?parseInt(i.replace(/[^\d\-]+/g,""))/Math.pow(10,d):null}var m=e.NUMBER_FORMATS.DECIMAL_SEP,p=e.NUMBER_FORMATS.GROUP_SEP,v=e.NUMBER_FORMATS.CURRENCY_SYM,d=r(s.uiMoneyMask)(a);angular.isDefined(s.uiHideGroupSep)&&(p=""),isNaN(d)&&(d=2);var $=l(d);if(o.$formatters.push(c),o.$parsers.push(f),s.uiMoneyMask&&a.$watch(s.uiMoneyMask,function(e){d=isNaN(e)?2:e,$=l(d),f(o.$viewValue)}),s.min){var g;o.$validators.min=function(e){return t.minNumber(o,e,g)},a.$watch(s.min,function(e){g=e,o.$validate()})}if(s.max){var M;o.$validators.max=function(e){return t.maxNumber(o,e,M)},a.$watch(s.max,function(e){M=e,o.$validate()})}}}}var n=e("string-mask"),t=e("validators");a.$inject=["$locale","$parse","PreFormatters"],r.exports=a},{"string-mask":void 0,validators:"validators"}],5:[function(e,r,i){function a(e,r,i,a){return{restrict:"A",require:"ngModel",link:function(t,u,s,o){function l(e){if(o.$isEmpty(e))return e;var r=i.clearDelimitersAndLeadingZeros(e)||"0",a=v.apply(r),n=parseFloat(d.apply(r));if(angular.isDefined(s.uiNegativeNumber)){var t="-"===e[0],u="-"===e.slice(-1);u^t&&n&&(n*=-1,a="-"+a)}return o.$viewValue!==a&&(o.$setViewValue(a),o.$render()),n}function c(e){if(o.$isEmpty(e))return e;var r=angular.isDefined(s.uiNegativeNumber)&&0>e?"-":"",a=i.prepareNumberToFormatter(e,p);return r+v.apply(a)}var f=e.NUMBER_FORMATS.DECIMAL_SEP,m=e.NUMBER_FORMATS.GROUP_SEP,p=r(s.uiNumberMask)(t);angular.isDefined(s.uiHideGroupSep)&&(m=""),isNaN(p)&&(p=2);var v=a.viewMask(p,f,m),d=a.modelMask(p);if(o.$formatters.push(c),o.$parsers.push(l),s.uiNumberMask&&t.$watch(s.uiNumberMask,function(e){p=isNaN(e)?2:e,v=a.viewMask(p,f,m),d=a.modelMask(p),l(o.$viewValue)}),s.min){var $;o.$validators.min=function(e){return n.minNumber(o,e,$)},t.$watch(s.min,function(e){$=e,o.$validate()})}if(s.max){var g;o.$validators.max=function(e){return n.maxNumber(o,e,g)},t.$watch(s.max,function(e){g=e,o.$validate()})}}}}var n=e("validators");a.$inject=["$locale","$parse","PreFormatters","NumberMasks"],r.exports=a},{validators:"validators"}],6:[function(e,r,i){function a(e,r,i,a){function t(e,r,a){return i.clearDelimitersAndLeadingZeros((parseFloat(e)*a).toFixed(r))}return{restrict:"A",require:"ngModel",link:function(r,u,s,o){function l(e){if(o.$isEmpty(e))return e;var r=t(e,p,v.multiplier);return $.apply(r)+" %"}function c(e){if(o.$isEmpty(e))return e;var r=i.clearDelimitersAndLeadingZeros(e)||"0";e.length>1&&-1===e.indexOf("%")&&(r=r.slice(0,r.length-1));var a=$.apply(r)+" %",n=parseFloat(g.apply(r));return o.$viewValue!==a&&(o.$setViewValue(a),o.$render()),n}var f=e.NUMBER_FORMATS.DECIMAL_SEP,m=e.NUMBER_FORMATS.GROUP_SEP,p=parseInt(s.uiPercentageMask),v={multiplier:100,decimalMask:2};angular.isDefined(s.uiHideGroupSep)&&(m=""),angular.isDefined(s.uiPercentageValue)&&(v.multiplier=1,v.decimalMask=0),isNaN(p)&&(p=2);var d=p+v.decimalMask,$=a.viewMask(p,f,m),g=a.modelMask(d);if(o.$formatters.push(l),o.$parsers.push(c),s.uiPercentageMask&&r.$watch(s.uiPercentageMask,function(e){p=isNaN(e)?2:e,angular.isDefined(s.uiPercentageValue)&&(v.multiplier=1,v.decimalMask=0),d=p+v.decimalMask,$=a.viewMask(p,f,m),g=a.modelMask(d),c(o.$viewValue)}),s.min){var M;o.$validators.min=function(e){return n.minNumber(o,e,M)},r.$watch(s.min,function(e){M=e,o.$validate()})}if(s.max){var k;o.$validators.max=function(e){return n.maxNumber(o,e,k)},r.$watch(s.max,function(e){k=e,o.$validate()})}}}}var n=e("validators");a.$inject=["$locale","$parse","PreFormatters","NumberMasks"],r.exports=a},{validators:"validators"}],7:[function(e,r,i){function a(e,r){function i(e){var r="0";if(e>0){r+=a;for(var i=0;e>i;i++)r+="0"}return new n(r,{reverse:!0})}var a=e.NUMBER_FORMATS.DECIMAL_SEP,t=2;return{restrict:"A",require:"ngModel",link:function(e,n,u,s){function o(e){var r=e.toString(),i=r.match(/(-?[0-9]*)[\.]?([0-9]*)?[Ee]?([\+-]?[0-9]*)?/);return{integerPartOfSignificand:i[1],decimalPartOfSignificand:i[2],exponent:0|i[3]}}function l(e){if(s.$isEmpty(e))return e;"string"==typeof e?e=e.replace(a,"."):"number"==typeof e&&(e=e.toExponential(f));var r,i,n=o(e),t=n.integerPartOfSignificand||0,u=t.toString();angular.isDefined(n.decimalPartOfSignificand)&&(u+=n.decimalPartOfSignificand);var l=(t>=1||-1>=t)&&(angular.isDefined(n.decimalPartOfSignificand)&&n.decimalPartOfSignificand.length>f||0===f&&u.length>=2);return l&&(i=u.slice(f+1,u.length),u=u.slice(0,f+1)),r=m.apply(u),0!==n.exponent&&(i=n.exponent),angular.isDefined(i)&&(r+="e"+i),r}function c(e){if(s.$isEmpty(e))return e;var r=l(e),i=parseFloat(r.replace(a,"."));return s.$viewValue!==r&&(s.$setViewValue(r),s.$render()),i}var f=r(u.uiScientificNotationMask)(e);isNaN(f)&&(f=t);var m=i(f);s.$formatters.push(l),s.$parsers.push(c),s.$validators.max=function(e){return s.$isEmpty(e)||e<Number.MAX_VALUE}}}}var n=e("string-mask");a.$inject=["$locale","$parse"],r.exports=a},{"string-mask":void 0}],8:[function(e,r,i){var a=e("string-mask");r.exports=function(){return{restrict:"A",require:"ngModel",link:function(e,r,i,n){function t(e){if(n.$isEmpty(e))return e;var r=e.replace(/[^0-9]/g,"").slice(0,o)||"";return(l.apply(r)||"").replace(/[^0-9]$/,"")}var u="00:00:00";angular.isDefined(i.uiTimeMask)&&"short"===i.uiTimeMask&&(u="00:00");var s=u.length,o=u.replace(":","").length,l=new a(u);n.$formatters.push(t),n.$parsers.push(function(e){if(n.$isEmpty(e))return e;var r=t(e),i=r;return n.$viewValue!==r&&(n.$setViewValue(r),n.$render()),i}),n.$validators.time=function(e){if(n.$isEmpty(e))return!0;var r=e.toString().split(/:/).filter(function(e){return!!e}),i=parseInt(r[0]),a=parseInt(r[1]),t=parseInt(r[2]||0);return e.toString().length===s&&24>i&&60>a&&60>t}}}}},{"string-mask":void 0}],9:[function(e,r,i){var a=e("string-mask"),n=angular.module("ui.utils.masks.helpers",[]);r.exports=n.name,n.factory("PreFormatters",[function(){function e(e){var r=e.replace(/^-/,"").replace(/^0*/,"");return r=r.replace(/[^0-9]/g,"")}function r(r,i){return e(parseFloat(r).toFixed(i))}return{clearDelimitersAndLeadingZeros:e,prepareNumberToFormatter:r}}]).factory("NumberValidators",[function(){return{maxNumber:function(e,r,i){var a=parseFloat(i),n=e.$isEmpty(r)||isNaN(a)||a>=r;return e.$setValidity("max",n),r},minNumber:function(e,r,i){var a=parseFloat(i),n=e.$isEmpty(r)||isNaN(a)||r>=a;return e.$setValidity("min",n),r}}}]).factory("NumberMasks",[function(){return{viewMask:function(e,r,i){var n="#"+i+"##0";if(e>0){n+=r;for(var t=0;e>t;t++)n+="0"}return new a(n,{reverse:!0})},modelMask:function(e){var r="###0";if(e>0){r+=".";for(var i=0;e>i;i++)r+="0"}return new a(r,{reverse:!0})}}}])},{"string-mask":void 0}],10:[function(e,r,i){var a=e("string-mask"),n=e("mask-factory"),t=new a("(000) 000-0000"),u=new a("+00-00-000-000000");r.exports=n({clearValue:function(e){return e.toString().replace(/[^0-9]/g,"")},format:function(e){var r;return r=e.length<11?t.apply(e)||"":u.apply(e),r.trim().replace(/[^0-9]$/,"")},validations:{usPhoneNumber:function(e){return e.length>9}}})},{"mask-factory":"mask-factory","string-mask":void 0}],11:[function(e,r,i){var a=angular.module("ui.utils.masks.us",[e("../helpers")]).directive("uiUsPhoneNumber",e("./phone/us-phone"));r.exports=a.name},{"../helpers":9,"./phone/us-phone":10}],"mask-factory":[function(e,r,i){r.exports=function(e){return function(){return{restrict:"A",require:"ngModel",link:function(r,i,a,n){n.$formatters.push(function(r){if(n.$isEmpty(r))return r;var i=e.clearValue(r);return e.format(i)}),n.$parsers.push(function(r){if(n.$isEmpty(r))return r;var i=e.clearValue(r),a=e.format(i);if(n.$viewValue!==a&&(n.$setViewValue(a),n.$render()),angular.isUndefined(e.getModelValue))return i;var t=typeof n.$modelValue;return e.getModelValue(a,t)}),angular.forEach(e.validations,function(e,r){n.$validators[r]=function(r,i){return n.$isEmpty(r)||e(r,i)}})}}}}},{}],validators:[function(e,r,i){r.exports={maxNumber:function(e,r,i){var a=parseFloat(i,10);return e.$isEmpty(r)||isNaN(a)||a>=r},minNumber:function(e,r,i){var a=parseFloat(i,10);return e.$isEmpty(r)||isNaN(a)||r>=a}}},{}]},{},[1]);