74 lines
32 KiB
JavaScript
Executable File
74 lines
32 KiB
JavaScript
Executable File
/*
|
|
Input Mask plugin for jquery
|
|
http://github.com/RobinHerbots/jquery.inputmask
|
|
Copyright (c) 2010 - 2013 Robin Herbots
|
|
Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
Version: 2.2.18
|
|
*/
|
|
|
|
(function(h){void 0==h.fn.inputmask&&(h.inputmask={defaults:{placeholder:"_",optionalmarker:{start:"[",end:"]"},escapeChar:"\\",mask:null,oncomplete:h.noop,onincomplete:h.noop,oncleared:h.noop,repeat:0,greedy:!0,autoUnmask:!1,clearMaskOnLostFocus:!0,insertMode:!0,clearIncomplete:!1,aliases:{},onKeyUp:h.noop,onKeyDown:h.noop,showMaskOnFocus:!0,showMaskOnHover:!0,onKeyValidation:h.noop,skipOptionalPartCharacter:" ",showTooltip:!1,numericInput:!1,radixPoint:"",rightAlignNumerics:!0,definitions:{9:{validator:"[0-9]",
|
|
cardinality:1},a:{validator:"[A-Za-z\u0410-\u044f\u0401\u0451]",cardinality:1},"*":{validator:"[A-Za-z\u0410-\u044f\u0401\u04510-9]",cardinality:1}},keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,
|
|
TAB:9,UP:38,WINDOWS:91},ignorables:[9,13,19,27,33,34,35,36,37,38,39,40,45,46,93,112,113,114,115,116,117,118,119,120,121,122,123],getMaskLength:function(a,c,d){var e=a.length;!c&&1<d&&(e+=a.length*(d-1));return e}},val:h.fn.val,escapeRegex:function(a){return a.replace(RegExp("(\\/|\\.|\\*|\\+|\\?|\\||\\(|\\)|\\[|\\]|\\{|\\}|\\\\)","gim"),"\\$1")}},h.fn.inputmask=function(a,c){var d,e;function b(a,d){var c=j.aliases[a];return c?(c.alias&&b(c.alias),h.extend(!0,j,c),h.extend(!0,j,d),!0):!1}function f(a){var b=
|
|
!1,d=0,c=j.greedy,e=j.repeat;1==a.length&&!1==c&&(j.placeholder="");for(var a=h.map(a.split(""),function(a){var u=[];if(a==j.escapeChar)b=true;else if(a!=j.optionalmarker.start&&a!=j.optionalmarker.end||b){var c=j.definitions[a];if(c&&!b)for(a=0;a<c.cardinality;a++)u.push(F(d+a));else{u.push(a);b=false}d=d+u.length;return u}}),f=a.slice(),v=1;v<e&&c;v++)f=f.concat(a.slice());return{mask:f,repeat:e,greedy:c}}function o(a){var b=!1,d=!1,c=!1;return h.map(a.split(""),function(a){var u=[];if(a==j.escapeChar)d=
|
|
!0;else if(a==j.optionalmarker.start&&!d)c=b=!0;else if(a==j.optionalmarker.end&&!d)b=!1,c=!0;else{var e=j.definitions[a];if(e&&!d){for(var h=e.prevalidator,f=h?h.length:0,k=1;k<e.cardinality;k++){var g=f>=k?h[k-1]:[],o=g.validator,g=g.cardinality;u.push({fn:o?"string"==typeof o?RegExp(o):new function(){this.test=o}:/./,cardinality:g?g:1,optionality:b,newBlockMarker:!0==b?c:!1,offset:0,casing:e.casing,def:e.definitionSymbol|a});!0==b&&(c=!1)}u.push({fn:e.validator?"string"==typeof e.validator?RegExp(e.validator):
|
|
new function(){this.test=e.validator}:/./,cardinality:e.cardinality,optionality:b,newBlockMarker:c,offset:0,casing:e.casing,def:e.definitionSymbol|a})}else u.push({fn:null,cardinality:0,optionality:b,newBlockMarker:c,offset:0,casing:null,def:a}),d=!1;c=!1;return u}})}function I(){function a(b){var d=b.length;for(i=0;i<d&&b.charAt(i)!=j.optionalmarker.start;i++);var c=[b.substring(0,i)];i<d&&c.push(b.substring(i+1,d));return c}function b(e,H){var v=0,m=0,l=H.length;for(i=0;i<l&&!(H.charAt(i)==j.optionalmarker.start&&
|
|
v++,H.charAt(i)==j.optionalmarker.end&&m++,0<v&&v==m);i++);v=[H.substring(0,i)];i<l&&v.push(H.substring(i+1,l));var k=a(v[0]);if(1<k.length){if(l=e+k[0]+(j.optionalmarker.start+k[1]+j.optionalmarker.end)+(1<v.length?v[1]:""),-1==h.inArray(l,c)&&(c.push(l),m=f(l),d.push({mask:l,_buffer:m.mask,tests:o(l),lastValidPosition:void 0,greedy:m.greedy,repeat:m.repeat})),l=e+k[0]+(1<v.length?v[1]:""),-1==h.inArray(l,c)&&(c.push(l),m=f(l),d.push({mask:l,_buffer:m.mask,tests:o(l),lastValidPosition:void 0,greedy:m.greedy,
|
|
repeat:m.repeat})),1<a(k[1]).length&&b(e+k[0],k[1]+v[1]),1<v.length&&1<a(v[1]).length)b(e+k[0]+(j.optionalmarker.start+k[1]+j.optionalmarker.end),v[1]),b(e+k[0],v[1])}else l=e+v,-1==h.inArray(l,c)&&(c.push(l),m=f(l),d.push({mask:l,_buffer:m.mask,tests:o(l),lastValidPosition:void 0,greedy:m.greedy,repeat:m.repeat}))}var d=[],c=[];h.isArray(j.mask)?h.each(j.mask,function(a,d){b("",d.toString())}):b("",j.mask.toString());return d}function r(){return w[q]}function G(){return r().tests}function m(){return r()._buffer}
|
|
function J(a,b,d,c,e,f){function o(a,e){for(var g=D(a),u=b?1:0,h="",f=e.tests[g].cardinality;f>u;f--)h+=C(d,g-(f-1));b&&(h+=b);return null!=e.tests[g].fn?e.tests[g].fn.test(h,d,a,c,j):!1}if(c||f){f=o(a,r());if(!1!==f){!0===f&&(f={pos:a});var m=r(),l=f.pos||a;if(void 0==m.lastValidPosition||m.lastValidPosition<l)m.lastValidPosition=l}return f}var k=[],g=!1,p=q;h.each(w,function(c){q=c;var g=a;if(p!=q&&!A(a)){if(b==this._buffer[g]||b==j.skipOptionalPartCharacter)return k[c]={refresh:!0},this.lastValidPosition=
|
|
g,!1;g=e?K(d,a):x(d,a)}if((void 0==this.lastValidPosition&&g==(e?K(d,t(d)):x(d,-1))||e||j.numericInput?this.lastValidPosition<=j.numericInput?t(d):x(d,g):this.lastValidPosition>=K(d,g))&&0<=g&&g<t(d))if(k[c]=o(g,this),!1!==k[c]){if(!0===k[c]&&(k[c]={pos:g}),c=k[c].pos||g,void 0==this.lastValidPosition||this.lastValidPosition<c)this.lastValidPosition=c}else this.lastValidPosition=e?a==t(d)?void 0:x(d,a):0==a?void 0:K(d,a)});q=p;S(d,a,p,e,b);g=k[q]||g;setTimeout(function(){j.onKeyValidation.call(this,
|
|
g,j)},0);return g}function S(a,b,d,c){h.each(w,function(d){if(void 0!=this.lastValidPosition&&(c||j.numericInput?this.lastValidPosition<=b:this.lastValidPosition>=b))return q=d,z(void 0,a,!1,!0,!1,a.join(""),c),!1})}function A(a){a=D(a);a=G()[a];return void 0!=a?a.fn:!1}function D(a){return a%G().length}function F(a){return j.placeholder.charAt(a%j.placeholder.length)}function t(a){return j.getMaskLength(m(),r().greedy,r().repeat,a,j)}function x(a,b){var d=t(a);if(b>=d)return d;for(var c=b;++c<d&&
|
|
!A(c););return c}function K(a,b){var d=b;if(0>=d)return 0;for(;0<--d&&!A(d););return d}function M(a,b,d,c,e){c&&(b=W(a,b,e));c=G()[D(b)];e=d;if(void 0!=e)switch(c.casing){case "upper":e=d.toUpperCase();break;case "lower":e=d.toLowerCase()}a[b]=e}function C(a,b,d){d&&(b=W(a,b));return a[b]}function W(a,b,d){if(d)for(;0>b&&a.length<t(a);){d=m().length-1;for(b=m().length;void 0!==m()[d];)a.unshift(m()[d--])}else for(;void 0==a[b]&&a.length<t(a);)for(d=0;void 0!==m()[d];)a.push(m()[d++]);return b}function E(a,
|
|
b,d){a._valueSet(b.join(""));void 0!=d&&p(a,d)}function T(a,b,d){for(var c=t(a);b<d&&b<c;b++)M(a,b,C(m().slice(),b))}function O(a,b){var d=D(b);M(a,b,C(m(),d))}function z(a,b,d,c,e,f,o){var o=void 0!=o?o:h(a).data("inputmask").isRTL,p=U(void 0!=f?f:a._valueGet(),o).split(""),c=void 0!=c?c:!0,f=t(b);if(o){var l=p.reverse();l.length=f;for(var k=0;k<f;k++){var g=D(f-(k+1));null==G()[g].fn&&l[k]!=C(m(),g)?(l.splice(k,0,C(m(),g)),l.length=f):l[k]=l[k]||C(m(),g)}p=l.reverse()}T(b,0,b.length);b.length=m().length;
|
|
for(var q=l=-1,w,z=p.length,g=0==z?f:-1,k=0;k<z;k++)for(var y=q+1;y<f;y++)if(A(y)){var B=p[k];!1!==(w=J(y,B,b,c,o,!0))?(!0!==w&&(y=void 0!=w.pos?w.pos:y,B=void 0!=w.c?w.c:B),M(b,y,B,!0,o),l=q=y):(O(b,y),B==F(y)&&(g=q=y));break}else if(O(b,y),l==q&&(l=y),q=y,p[k]==C(b,y))break;if(!1==r().greedy&&b.length>m().length){c=U(b.join(""),o).split("");k=c.length;for(p=0;p<k;p++)b[p]=c[p];b.length=c.length}d&&E(a,b);return o?j.numericInput?""!=j.radixPoint&&-1!=h.inArray(j.radixPoint,b)&&!0!==e?h.inArray(j.radixPoint,
|
|
b):x(b,f):x(b,g):x(b,l)}function Q(a){return h.inputmask.escapeRegex.call(this,a)}function U(a,b){return b?a.replace(RegExp("^("+Q(m().join(""))+")*"),""):a.replace(RegExp("("+Q(m().join(""))+")*$"),"")}function X(a,b){z(a,b,!1);var d=b.slice(),c,e;if(h(a).data("inputmask").isRTL)for(e=0;e<=d.length-1;e++)if(c=D(e),G()[c].optionality)if(!A(e)||!J(e,b[e],b,!0))d.splice(0,1);else break;else break;else for(e=d.length-1;0<=e;e--)if(c=D(e),G()[c].optionality)if(!A(e)||!J(e,b[e],b,!0))d.pop();else break;
|
|
else break;E(a,d)}function Y(a,b){var d=a[0];if(G()&&(!0===b||!a.hasClass("hasDatepicker"))){var c=m().slice();z(d,c,!1);return h.map(c,function(a,b){return A(b)&&J(b,a,c,!0)?a:null}).join("")}return d._valueGet()}function p(a,b,c){var f=a.jquery&&0<a.length?a[0]:a;if("number"==typeof b)h(a).is(":visible")&&(c="number"==typeof c?c:b,!1==j.insertMode&&b==c&&c++,f.setSelectionRange?V?(setTimeout(function(){f.selectionStart=b;f.selectionEnd=V?b:c},10),d=b,e=c):(f.selectionStart=b,f.selectionEnd=c):f.createTextRange&&
|
|
(a=f.createTextRange(),a.collapse(!0),a.moveEnd("character",c),a.moveStart("character",b),a.select()));else{if(!h(a).is(":visible"))return{begin:0,end:0};f.setSelectionRange?(b=f.selectionStart,c=f.selectionEnd):document.selection&&document.selection.createRange&&(a=document.selection.createRange(),b=0-a.duplicate().moveStart("character",-1E5),c=b+a.text.length);return{begin:b,end:c}}}function R(a){var b=!1,d=0,c=q;h.each(w,function(c,e){q=c;var f=K(a,t(a));if(void 0!=e.lastValidPosition&&e.lastValidPosition>=
|
|
d&&e.lastValidPosition==f){for(var h=!0,j=0;j<=f;j++){var o=A(j),g=D(j);if(o&&(void 0==a[j]||a[j]==F(j))||!o&&a[j]!=m()[g]){h=!1;break}}if(b=b||h)return!1}d=e.lastValidPosition});q=c;return b}function N(a){function b(a){a=h._data(a).events;h.each(a,function(a,b){h.each(b,function(a,b){if("inputmask"==b.namespace){var d=b.handler;b.handler=function(a){if(this.readOnly||this.disabled)a.preventDefault;else return d.apply(this,arguments)}}})})}function c(a){var b;Object.getOwnPropertyDescriptor&&(b=Object.getOwnPropertyDescriptor(a,
|
|
"value"));if(b&&b.get)a._valueGet||(a._valueGet=b.get,a._valueSet=b.set,Object.defineProperty(a,"value",{get:function(){var a=h(this),b=h(this).data("inputmask"),d=b.masksets,c=b.activeMasksetIndex;return b&&b.opts.autoUnmask?a.inputmask("unmaskedvalue"):this._valueGet()!=d[c]._buffer.join("")?this._valueGet():""},set:function(a){this._valueSet(a);h(this).triggerHandler("setvalue.inputmask")}}));else if(document.__lookupGetter__&&a.__lookupGetter__("value"))a._valueGet||(a._valueGet=a.__lookupGetter__("value"),
|
|
a._valueSet=a.__lookupSetter__("value"),a.__defineGetter__("value",function(){var a=h(this),b=h(this).data("inputmask"),d=b.masksets,c=b.activeMasksetIndex;return b&&b.opts.autoUnmask?a.inputmask("unmaskedvalue"):this._valueGet()!=d[c]._buffer.join("")?this._valueGet():""}),a.__defineSetter__("value",function(a){this._valueSet(a);h(this).triggerHandler("setvalue.inputmask")}));else if(a._valueGet||(a._valueGet=function(){return this.value},a._valueSet=function(a){this.value=a}),!0!=h.fn.val.inputmaskpatch)h.fn.val=
|
|
function(){if(arguments.length==0){var a=h(this);if(a.data("inputmask")){if(a.data("inputmask").opts.autoUnmask)return a.inputmask("unmaskedvalue");var a=h.inputmask.val.apply(a),b=h(this).data("inputmask");return a!=b.masksets[b.activeMasksetIndex]._buffer.join("")?a:""}return h.inputmask.val.apply(a)}var d=arguments;return this.each(function(){var a=h(this),b=h.inputmask.val.apply(a,d);a.data("inputmask")&&a.triggerHandler("setvalue.inputmask");return b})},h.extend(h.fn.val,{inputmaskpatch:!0})}
|
|
function f(a,b){if(j.numericInput&&""!=j.radixPoint){var d=a._valueGet().indexOf(j.radixPoint);s=b.begin<=d||b.end<=d||-1==d}}function o(a,b,d){for(;!A(a)&&0<=a-1;)a--;for(var c=a;c<b&&c<t(g);c++)if(A(c)){O(g,c);var e=x(g,c),f=C(g,e);if(f!=F(e))if(e<t(g)&&!1!==J(c,f,g,!0,s)&&G()[D(c)].def==G()[D(e)].def)M(g,c,C(g,e),!0,s),O(g,e);else{if(A(c))break}else if(void 0==d)break}else O(g,c);void 0!=d&&M(g,s?b:K(g,b),d);g=U(g.join(""),s).split("");0==g.length&&(g=m().slice());return a}function H(a,b,d,c){for(;a<=
|
|
b&&a<t(g);a++)if(A(a)){var e=C(g,a);M(g,a,d,!0,s);if(e!=F(a))if(d=x(g,a),d<t(g))if(!1!==J(d,e,g,!0,s)&&G()[D(a)].def==G()[D(d)].def)d=e;else if(A(d))break;else d=e;else break;else if(!0!==c)break}else O(g,a);c=g.length;g=U(g.join(""),s).split("");0==g.length&&(g=m().slice());return b-(c-g.length)}function v(a){N=!1;var b=this,d=a.keyCode,c=p(b);f(b,c);if(d==j.keyCode.BACKSPACE||d==j.keyCode.DELETE||$&&127==d){var e=t(g),l=x(g,-1);if(0==c.begin&&c.end==e)q=0,g=m().slice(),E(b,g),p(b,z(b,g,!1));else if(1<
|
|
c.end-c.begin||1==c.end-c.begin&&j.insertMode)T(g,c.begin,c.end),S(g,c.begin,q,s),E(b,g),e=s?z(b,g,!1):c.begin,r().lastValidPosition=e,p(b,e);else{var n=Z?c.end:c.begin;d==j.keyCode.DELETE?(n<l&&(n=l),n<e&&(j.numericInput&&""!=j.radixPoint&&g[n]==j.radixPoint?(n=g.length-1==n?n:x(g,n),n=o(n,e)):s?(n=H(l,n,F(n),!0),n=x(g,n)):n=o(n,e),S(g,n,q,s),r().lastValidPosition=n,E(b,g,n))):d==j.keyCode.BACKSPACE&&(n>l?(n-=1,j.numericInput&&""!=j.radixPoint&&g[n]==j.radixPoint?(n=H(l,g.length-1==n?n:n-1,F(n),
|
|
!0),n++):s?(n=H(l,n,F(n),!0),n=g[n+1]==j.radixPoint?n+1:x(g,n)):n=o(n,e),S(g,n,q,s),r().lastValidPosition=n,E(b,g,n)):0<q&&(q=0,T(g,0,l),l=x(g,-1),E(b,m(),s?e:l)))}b._valueGet()==m().join("")&&h(b).trigger("cleared");j.showTooltip&&k.prop("title",r().mask);a.preventDefault()}else d==j.keyCode.END||d==j.keyCode.PAGE_DOWN?setTimeout(function(){var d=z(b,g,!1);!j.insertMode&&(d==t(g)&&!a.shiftKey)&&d--;p(b,a.shiftKey?c.begin:d,d)},0):d==j.keyCode.HOME&&!a.shiftKey||d==j.keyCode.PAGE_UP?p(b,0,a.shiftKey?
|
|
c.begin:0):d==j.keyCode.ESCAPE?(b._valueSet(P),p(b,0,z(b,g,!1))):d==j.keyCode.INSERT?(j.insertMode=!j.insertMode,p(b,!j.insertMode&&c.begin==t(g)?c.begin-1:c.begin)):a.ctrlKey&&88==d?setTimeout(function(){p(b,z(b,g,!0))},0):j.insertMode||(d==j.keyCode.RIGHT?(e=c.begin==c.end?c.end+1:c.end,e=e<t(g)?e:c.end,p(b,a.shiftKey?c.begin:e,a.shiftKey?e+1:e)):d==j.keyCode.LEFT&&(e=c.begin-1,e=0<e?e:0,p(b,e,a.shiftKey?c.end:e)));j.onKeyDown.call(this,a,g,j);y=-1!=h.inArray(d,j.ignorables)}function I(a){if(N)return!1;
|
|
N=!0;var b=h(this),a=a||window.event,c=a.which||a.charCode||a.keyCode,f=String.fromCharCode(c);if(j.numericInput&&f==j.radixPoint){var k=this._valueGet().indexOf(j.radixPoint);p(this,x(g,-1!=k?k:t(g)))}if(a.ctrlKey||a.metaKey||y)return!0;if(c){var m=p(this),n=t(g),c=!0;1<m.end-m.begin&&T(g,m.begin,m.end);if(s){var k=K(g,m.end),l;if(!1!==(l=J(k==n||C(g,k)==j.radixPoint?K(g,k):k,f,g,!1,s))){var u=!1;!0!==l&&(u=l.refresh,k=void 0!=l.pos?l.pos:k,f=void 0!=l.c?l.c:f);if(!0!==u){var n=t(g),q=x(g,-1);l=
|
|
q;if(!0==j.insertMode){if(!0==r().greedy)for(u=g.slice();C(u,l,!0)!=F(l)&&l<=k;)l=l==n?n+1:x(g,l);l<=k&&(r().greedy||g.length<n)?(g[q]!=F(q)&&g.length<n&&(u=W(g,-1,s),0!=m.end&&(k+=u),n=g.length),o(l,k,f)):c=!1}else M(g,k,f,!0,s)}c&&(E(this,g,j.numericInput?k+1:k),setTimeout(function(){R(g)&&b.trigger("complete")},0))}}else if(k=x(g,m.begin-1),!1!==(l=J(k,f,g,!1,s))){u=!1;!0!==l&&(u=l.refresh,k=void 0!=l.pos?l.pos:k,f=void 0!=l.c?l.c:f);if(!0!==u)if(!0==j.insertMode){m=t(g);for(u=g.slice();C(u,m,
|
|
!0)!=F(m)&&m>=k;)m=0==m?-1:K(g,m);m>=k?H(k,g.length,f):c=!1}else M(g,k,f,!0,s);c&&(f=x(g,k),E(this,g,f),setTimeout(function(){R(g)&&b.trigger("complete")},0))}V&&p(this,d,e);j.showTooltip&&b.prop("title",r().mask);a.preventDefault()}}function l(a){var b=h(this),c=a.keyCode;j.onKeyUp.call(this,a,g,j);c==j.keyCode.TAB&&(b.hasClass("focus.inputmask")&&0==this._valueGet().length&&j.showMaskOnFocus)&&(g=m().slice(),E(this,g),s||p(this,0),P=this._valueGet())}var k=h(a);if(k.is(":input")){j.showTooltip&&
|
|
k.prop("title",r().mask);var g=m().slice();r().greedy=r().greedy?r().greedy:0==r().repeat;var L=k.prop("maxLength");t(g)>L&&-1<L&&(L<m().length&&(m().length=L),!1==r().greedy&&(r().repeat=Math.round(L/m().length)),k.prop("maxLength",2*t(g)));k.data("inputmask",{masksets:w,activeMasksetIndex:q,opts:j,isRTL:!1});c(a);var P=a._valueGet(),N=!1,y=!1,B=-1,s=!1;if("rtl"==a.dir||j.numericInput)("rtl"==a.dir||j.numericInput&&j.rightAlignNumerics)&&k.css("text-align","right"),a.dir="ltr",k.removeAttr("dir"),
|
|
L=k.data("inputmask"),L.isRTL=!0,k.data("inputmask",L),s=!0;k.unbind(".inputmask");k.removeClass("focus.inputmask");k.bind("mouseenter.inputmask",function(){if(!h(this).hasClass("focus.inputmask")&&j.showMaskOnHover){var a=this._valueGet().length;if(a<g.length){a==0&&(g=m().slice());E(this,g)}}}).bind("blur.inputmask",function(){var a=h(this),b=this._valueGet();a.removeClass("focus.inputmask");b!=P&&a.change();j.clearMaskOnLostFocus&&b!=""&&(b==m().join("")?this._valueSet(""):X(this,g));if(!R(g)){a.trigger("incomplete");
|
|
if(j.clearIncomplete)if(j.clearMaskOnLostFocus)this._valueSet("");else{g=m().slice();E(this,g)}}}).bind("focus.inputmask",function(){var a=h(this),b=this._valueGet();if(j.showMaskOnFocus&&!a.hasClass("focus.inputmask")&&(!j.showMaskOnHover||j.showMaskOnHover&&b=="")){b=b.length;if(b<g.length){b==0&&(g=m().slice());p(this,z(this,g,true))}}a.addClass("focus.inputmask");P=this._valueGet()}).bind("mouseleave.inputmask",function(){var a=h(this);j.clearMaskOnLostFocus&&(a.hasClass("focus.inputmask")||(this._valueGet()==
|
|
m().join("")||this._valueGet()==""?this._valueSet(""):X(this,g)))}).bind("click.inputmask",function(){var a=this;setTimeout(function(){var b=p(a);if(b.begin==b.end){var c=b.begin;B=z(a,g,false);f(a,b);s?p(a,c>B&&(J(c,g[c],g,true,s)!==false||!A(c))?c:B):p(a,c<B&&(J(c,g[c],g,true,s)!==false||!A(c))?c:B)}},0)}).bind("dblclick.inputmask",function(){var a=this;setTimeout(function(){p(a,0,B)},0)}).bind("keydown.inputmask",v).bind("keypress.inputmask",I).bind("keyup.inputmask",l).bind(aa+".inputmask dragdrop.inputmask drop.inputmask",
|
|
function(){var a=this;setTimeout(function(){p(a,z(a,g,true,false));R(g)&&k.trigger("complete")},0)}).bind("setvalue.inputmask",function(){P=this._valueGet();z(this,g,true,false);this._valueGet()==m().join("")&&this._valueSet("")}).bind("complete.inputmask",j.oncomplete).bind("incomplete.inputmask",j.onincomplete).bind("cleared.inputmask",j.oncleared);var B=z(a,g,!0),Q;try{Q=document.activeElement}catch(Y){}Q===a?(k.addClass("focus.inputmask"),p(a,B)):j.clearMaskOnLostFocus&&(a._valueGet()==m().join("")?
|
|
a._valueSet(""):X(a,g));b(a)}}var j=h.extend(!0,{},h.inputmask.defaults,c),aa=function(a){var b=document.createElement("input"),a="on"+a,c=a in b;c||(b.setAttribute(a,"return;"),c="function"==typeof b[a]);return c}("paste")?"paste":"input",$=null!=navigator.userAgent.match(/iphone/i),V=null!=navigator.userAgent.match(/android.*safari.*/i),Z;if(V){var ba=navigator.userAgent.match(/safari.*/i);Z=533>=parseInt(RegExp(/[0-9]+/).exec(ba))}var w,q=0;if("string"==typeof a)switch(a){case "mask":return b(j.alias,
|
|
c),w=I(),this.each(function(){N(this)});case "unmaskedvalue":return w=this.data("inputmask").masksets,q=this.data("inputmask").activeMasksetIndex,j=this.data("inputmask").opts,Y(this);case "remove":return this.each(function(){var a=h(this),b=this;setTimeout(function(){if(a.data("inputmask")){w=a.data("inputmask").masksets;q=a.data("inputmask").activeMasksetIndex;j=a.data("inputmask").opts;b._valueSet(Y(a,!0));a.removeData("inputmask");a.unbind(".inputmask");a.removeClass("focus.inputmask");var c;
|
|
Object.getOwnPropertyDescriptor&&(c=Object.getOwnPropertyDescriptor(b,"value"));c&&c.get?b._valueGet&&Object.defineProperty(b,"value",{get:b._valueGet,set:b._valueSet}):document.__lookupGetter__&&b.__lookupGetter__("value")&&b._valueGet&&(b.__defineGetter__("value",b._valueGet),b.__defineSetter__("value",b._valueSet));delete b._valueGet;delete b._valueSet}},0)});case "getemptymask":return this.data("inputmask")?(w=this.data("inputmask").masksets,q=this.data("inputmask").activeMasksetIndex,w[q]._buffer.join("")):
|
|
"";case "hasMaskedValue":return this.data("inputmask")?!this.data("inputmask").opts.autoUnmask:!1;case "isComplete":return w=this.data("inputmask").masksets,q=this.data("inputmask").activeMasksetIndex,j=this.data("inputmask").opts,R(this[0]._valueGet().split(""));default:return b(a,c)||(j.mask=a),w=I(),this.each(function(){N(this)})}else{if("object"==typeof a)return j=h.extend(!0,{},h.inputmask.defaults,a),b(j.alias,a),w=I(),this.each(function(){N(this)});if(void 0==a)return this.each(function(){var a=
|
|
h(this).attr("data-inputmask");if(a&&""!=a)try{var a=a.replace(RegExp("'","g"),'"'),c=h.parseJSON("{"+a+"}");j=h.extend(!0,{},h.inputmask.defaults,c);b(j.alias,c);j.alias=void 0;h(this).inputmask(j)}catch(d){}})}return this})})(jQuery);
|
|
(function(h){h.extend(h.inputmask.defaults.definitions,{A:{validator:"[A-Za-z]",cardinality:1,casing:"upper"},"#":{validator:"[A-Za-z\u0410-\u044f\u0401\u04510-9]",cardinality:1,casing:"upper"}});h.extend(h.inputmask.defaults.aliases,{url:{mask:"ir",placeholder:"",separator:"",defaultPrefix:"http://",regex:{urlpre1:/[fh]/,urlpre2:/(ft|ht)/,urlpre3:/(ftp|htt)/,urlpre4:/(ftp:|http|ftps)/,urlpre5:/(ftp:\/|ftps:|http:|https)/,urlpre6:/(ftp:\/\/|ftps:\/|http:\/|https:)/,urlpre7:/(ftp:\/\/|ftps:\/\/|http:\/\/|https:\/)/,
|
|
urlpre8:/(ftp:\/\/|ftps:\/\/|http:\/\/|https:\/\/)/},definitions:{i:{validator:function(){return!0},cardinality:8,prevalidator:function(){for(var a=[],c=0;8>c;c++)a[c]=function(){var a=c;return{validator:function(c,b,f,h,I){if(I.regex["urlpre"+(a+1)]){var r=c;0<a+1-c.length&&(r=b.join("").substring(0,a+1-c.length)+""+r);c=I.regex["urlpre"+(a+1)].test(r);if(!h&&!c){f-=a;for(h=0;h<I.defaultPrefix.length;h++)b[f]=I.defaultPrefix[h],f++;for(h=0;h<r.length-1;h++)b[f]=r[h],f++;return{pos:f}}return c}return!1},
|
|
cardinality:a}}();return a}()}},insertMode:!1,autoUnmask:!1},ip:{mask:"i.i.i.i",definitions:{i:{validator:"25[0-5]|2[0-4][0-9]|[01][0-9][0-9]",cardinality:3,prevalidator:[{validator:"[0-2]",cardinality:1},{validator:"2[0-5]|[01][0-9]",cardinality:2}]}}}})})(jQuery);
|
|
(function(h){h.extend(h.inputmask.defaults.definitions,{h:{validator:"[01][0-9]|2[0-3]",cardinality:2,prevalidator:[{validator:"[0-2]",cardinality:1}]},s:{validator:"[0-5][0-9]",cardinality:2,prevalidator:[{validator:"[0-5]",cardinality:1}]},d:{validator:"0[1-9]|[12][0-9]|3[01]",cardinality:2,prevalidator:[{validator:"[0-3]",cardinality:1}]},m:{validator:"0[1-9]|1[012]",cardinality:2,prevalidator:[{validator:"[01]",cardinality:1}]},y:{validator:"(19|20)\\d{2}",cardinality:4,prevalidator:[{validator:"[12]",
|
|
cardinality:1},{validator:"(19|20)",cardinality:2},{validator:"(19|20)\\d",cardinality:3}]}});h.extend(h.inputmask.defaults.aliases,{"dd/mm/yyyy":{mask:"1/2/y",placeholder:"dd/mm/yyyy",regex:{val1pre:/[0-3]/,val1:/0[1-9]|[12][0-9]|3[01]/,val2pre:function(a){a=h.inputmask.escapeRegex.call(this,a);return RegExp("((0[1-9]|[12][0-9]|3[01])"+a+"[01])")},val2:function(a){a=h.inputmask.escapeRegex.call(this,a);return RegExp("((0[1-9]|[12][0-9])"+a+"(0[1-9]|1[012]))|(30"+a+"(0[13-9]|1[012]))|(31"+a+"(0[13578]|1[02]))")}},
|
|
leapday:"29/02/",separator:"/",yearrange:{minyear:1900,maxyear:2099},isInYearRange:function(a,c,d){var e=parseInt(a.concat(c.toString().slice(a.length))),a=parseInt(a.concat(d.toString().slice(a.length)));return(NaN!=e?c<=e&&e<=d:!1)||(NaN!=a?c<=a&&a<=d:!1)},determinebaseyear:function(a,c){var d=(new Date).getFullYear();return a>d?a:c<d?c:d},onKeyUp:function(a,c,d){c=h(this);a.ctrlKey&&a.keyCode==d.keyCode.RIGHT&&(a=new Date,c.val(a.getDate().toString()+(a.getMonth()+1).toString()+a.getFullYear().toString()))},
|
|
definitions:{1:{validator:function(a,c,d,e,b){var f=b.regex.val1.test(a);if(!e&&!f&&(a.charAt(1)==b.separator||-1!="-./".indexOf(a.charAt(1))))if(f=b.regex.val1.test("0"+a.charAt(0)))return c[d-1]="0",{pos:d,c:a.charAt(0)};return f},cardinality:2,prevalidator:[{validator:function(a,c,d,e,b){var f=b.regex.val1pre.test(a);return!e&&!f&&(f=b.regex.val1.test("0"+a))?(c[d]="0",d++,{pos:d}):f},cardinality:1}]},2:{validator:function(a,c,d,e,b){var f=c.join("").substr(0,3),h=b.regex.val2(b.separator).test(f+
|
|
a);if(!e&&!h&&(a.charAt(1)==b.separator||-1!="-./".indexOf(a.charAt(1))))if(h=b.regex.val2(b.separator).test(f+"0"+a.charAt(0)))return c[d-1]="0",{pos:d,c:a.charAt(0)};return h},cardinality:2,prevalidator:[{validator:function(a,c,d,e,b){var f=c.join("").substr(0,3),h=b.regex.val2pre(b.separator).test(f+a);return!e&&!h&&(h=b.regex.val2(b.separator).test(f+"0"+a))?(c[d]="0",d++,{pos:d}):h},cardinality:1}]},y:{validator:function(a,c,d,e,b){if(b.isInYearRange(a,b.yearrange.minyear,b.yearrange.maxyear)){if(c.join("").substr(0,
|
|
6)!=b.leapday)return!0;a=parseInt(a,10);return 0===a%4?0===a%100?0===a%400?!0:!1:!0:!1}return!1},cardinality:4,prevalidator:[{validator:function(a,c,d,e,b){var f=b.isInYearRange(a,b.yearrange.minyear,b.yearrange.maxyear);if(!e&&!f){e=b.determinebaseyear(b.yearrange.minyear,b.yearrange.maxyear).toString().slice(0,1);if(f=b.isInYearRange(e+a,b.yearrange.minyear,b.yearrange.maxyear))return c[d++]=e[0],{pos:d};e=b.determinebaseyear(b.yearrange.minyear,b.yearrange.maxyear).toString().slice(0,2);if(f=b.isInYearRange(e+
|
|
a,b.yearrange.minyear,b.yearrange.maxyear))return c[d++]=e[0],c[d++]=e[1],{pos:d}}return f},cardinality:1},{validator:function(a,c,d,e,b){var f=b.isInYearRange(a,b.yearrange.minyear,b.yearrange.maxyear);if(!e&&!f){e=b.determinebaseyear(b.yearrange.minyear,b.yearrange.maxyear).toString().slice(0,2);if(f=b.isInYearRange(a[0]+e[1]+a[1],b.yearrange.minyear,b.yearrange.maxyear))return c[d++]=e[1],{pos:d};e=b.determinebaseyear(b.yearrange.minyear,b.yearrange.maxyear).toString().slice(0,2);b.isInYearRange(e+
|
|
a,b.yearrange.minyear,b.yearrange.maxyear)?c.join("").substr(0,6)!=b.leapday?f=!0:(b=parseInt(a,10),f=0===b%4?0===b%100?0===b%400?!0:!1:!0:!1):f=!1;if(f)return c[d-1]=e[0],c[d++]=e[1],c[d++]=a[0],{pos:d}}return f},cardinality:2},{validator:function(a,c,d,e,b){return b.isInYearRange(a,b.yearrange.minyear,b.yearrange.maxyear)},cardinality:3}]}},insertMode:!1,autoUnmask:!1},"mm/dd/yyyy":{placeholder:"mm/dd/yyyy",alias:"dd/mm/yyyy",regex:{val2pre:function(a){a=h.inputmask.escapeRegex.call(this,a);return RegExp("((0[13-9]|1[012])"+
|
|
a+"[0-3])|(02"+a+"[0-2])")},val2:function(a){a=h.inputmask.escapeRegex.call(this,a);return RegExp("((0[1-9]|1[012])"+a+"(0[1-9]|[12][0-9]))|((0[13-9]|1[012])"+a+"30)|((0[13578]|1[02])"+a+"31)")},val1pre:/[01]/,val1:/0[1-9]|1[012]/},leapday:"02/29/",onKeyUp:function(a,c,d){c=h(this);a.ctrlKey&&a.keyCode==d.keyCode.RIGHT&&(a=new Date,c.val((a.getMonth()+1).toString()+a.getDate().toString()+a.getFullYear().toString()))}},"yyyy/mm/dd":{mask:"y/1/2",placeholder:"yyyy/mm/dd",alias:"mm/dd/yyyy",leapday:"/02/29",
|
|
onKeyUp:function(a,c,d){c=h(this);a.ctrlKey&&a.keyCode==d.keyCode.RIGHT&&(a=new Date,c.val(a.getFullYear().toString()+(a.getMonth()+1).toString()+a.getDate().toString()))},definitions:{2:{validator:function(a,c,d,e,b){var f=c.join("").substr(5,3),h=b.regex.val2(b.separator).test(f+a);if(!e&&!h&&(a.charAt(1)==b.separator||-1!="-./".indexOf(a.charAt(1))))if(h=b.regex.val2(b.separator).test(f+"0"+a.charAt(0)))return c[d-1]="0",{pos:d,c:a.charAt(0)};if(h){if(c.join("").substr(4,4)+a!=b.leapday)return!0;
|
|
a=parseInt(c.join("").substr(0,4),10);return 0===a%4?0===a%100?0===a%400?!0:!1:!0:!1}return h},cardinality:2,prevalidator:[{validator:function(a,c,d,e,b){var f=c.join("").substr(5,3),h=b.regex.val2pre(b.separator).test(f+a);return!e&&!h&&(h=b.regex.val2(b.separator).test(f+"0"+a))?(c[d]="0",d++,{pos:d}):h},cardinality:1}]}}},"dd.mm.yyyy":{mask:"1.2.y",placeholder:"dd.mm.yyyy",leapday:"29.02.",separator:".",alias:"dd/mm/yyyy"},"dd-mm-yyyy":{mask:"1-2-y",placeholder:"dd-mm-yyyy",leapday:"29-02-",separator:"-",
|
|
alias:"dd/mm/yyyy"},"mm.dd.yyyy":{mask:"1.2.y",placeholder:"mm.dd.yyyy",leapday:"02.29.",separator:".",alias:"mm/dd/yyyy"},"mm-dd-yyyy":{mask:"1-2-y",placeholder:"mm-dd-yyyy",leapday:"02-29-",separator:"-",alias:"mm/dd/yyyy"},"yyyy.mm.dd":{mask:"y.1.2",placeholder:"yyyy.mm.dd",leapday:".02.29",separator:".",alias:"yyyy/mm/dd"},"yyyy-mm-dd":{mask:"y-1-2",placeholder:"yyyy-mm-dd",leapday:"-02-29",separator:"-",alias:"yyyy/mm/dd"},datetime:{mask:"1/2/y h:s",placeholder:"dd/mm/yyyy hh:mm",alias:"dd/mm/yyyy",
|
|
regex:{hrspre:/[012]/,hrs24:/2[0-9]|1[3-9]/,hrs:/[01][0-9]|2[0-3]/,ampmpre:/[apAP]/,ampm:/^[a|p|A|P][m|M]/},timeseparator:":",hourFormat:"24",definitions:{h:{validator:function(a,c,d,e,b){var f=b.regex.hrs.test(a);if(!e&&!f&&(a.charAt(1)==b.timeseparator||-1!="-.:".indexOf(a.charAt(1))))if(f=b.regex.hrs.test("0"+a.charAt(0)))return c[d-1]="0",c[d]=a.charAt(0),d++,{pos:d};return f&&"24"!==b.hourFormat&&b.regex.hrs24.test(a)?(a=parseInt(a,10),c[d+5]=24==a?"a":"p",c[d+6]="m",a-=12,10>a?(c[d]=a.toString(),
|
|
c[d-1]="0"):(c[d]=a.toString().charAt(1),c[d-1]=a.toString().charAt(0)),{pos:d,c:c[d]}):f},cardinality:2,prevalidator:[{validator:function(a,c,d,e,b){var f=b.regex.hrspre.test(a);return!e&&!f&&(f=b.regex.hrs.test("0"+a))?(c[d]="0",d++,{pos:d}):f},cardinality:1}]},t:{validator:function(a,c,d,e,b){var f=b.regex.ampm.test(a);return!e&&!f&&(f=b.regex.ampm.test(a+"m"))?(c[d-1]=a.charAt(0),c[d]="m",d++,d):f},casing:"lower",cardinality:2,prevalidator:[{validator:function(a,c,d,e,b){if(e=b.regex.ampmpre.test(a))if(e=
|
|
b.regex.ampm.test(a+"m"))return c[d]=a,c[d+1]="m",d;return e},cardinality:1}]}},insertMode:!1,autoUnmask:!1},datetime12:{mask:"1/2/y h:s t",placeholder:"dd/mm/yyyy hh:mm xm",alias:"datetime",hourFormat:"12"},"hh:mm t":{mask:"h:s t",placeholder:"hh:mm xm",alias:"datetime",hourFormat:"12"},"h:s t":{mask:"h:s t",placeholder:"hh:mm xm",alias:"datetime",hourFormat:"12"},"hh:mm:ss":{mask:"h:s:s",autoUnmask:!1},"hh:mm":{mask:"h:s",autoUnmask:!1},date:{alias:"dd/mm/yyyy"}})})(jQuery);
|
|
(function(h){h.extend(h.inputmask.defaults.aliases,{decimal:{mask:"~",placeholder:"",repeat:10,greedy:!1,numericInput:!0,digits:"*",groupSeparator:"",radixPoint:".",groupSize:3,autoGroup:!1,getMaskLength:function(a,c,d,e,b){var f=a.length;!c&&1<d&&(f+=a.length*(d-1));a=h.inputmask.escapeRegex.call(this,b.groupSeparator);b=h.inputmask.escapeRegex.call(this,b.radixPoint);e=e.join("");b=e.replace(RegExp(a,"g"),"").replace(RegExp(b),"");return f+(e.length-b.length)},postFormat:function(a,c,d,e){if(""==
|
|
e.groupSeparator)return c-1;var b=a.slice();d||b.splice(c,0,"?");b=b.join("");if(e.autoGroup||d&&-1!=b.indexOf(e.groupSeparator)){for(var f=h.inputmask.escapeRegex.call(this,e.groupSeparator),b=b.replace(RegExp(f,"g"),""),f=b.split(e.radixPoint),b=f[0],o=RegExp("([-+]?[\\d?]+)([\\d?]{"+e.groupSize+"})");o.test(b);)b=b.replace(o,"$1"+e.groupSeparator+"$2"),b=b.replace(e.groupSeparator+e.groupSeparator,e.groupSeparator);1<f.length&&(b+=e.radixPoint+f[1])}a.length=b.length;e=0;for(f=b.length;e<f;e++)a[e]=
|
|
b.charAt(e);c=d?c:h.inArray("?",a);d||a.splice(c,1);return c},regex:{number:function(a,c,d,e){a=h.inputmask.escapeRegex.call(this,a);d=h.inputmask.escapeRegex.call(this,d);e=isNaN(e)?e:"{0,"+e+"}";return RegExp("^[+-]?(\\d+|\\d{1,"+c+"}(("+a+"\\d{"+c+"})?)+)("+d+"\\d"+e+")?$")}},onKeyDown:function(a,c,d){var e=h(this);if(a.keyCode==d.keyCode.TAB){if(a=h.inArray(d.radixPoint,c),-1!=a){for(var b=e.data("inputmask").masksets,e=e.data("inputmask").activeMasksetIndex,f=1;f<=d.digits&&f<d.getMaskLength(b[e]._buffer,
|
|
b[e].greedy,b[e].repeat,c,d);f++)void 0==c[a+f]&&(c[a+f]="0");this._valueSet(c.join(""))}}else if(a.keyCode==d.keyCode.DELETE||a.keyCode==d.keyCode.BACKSPACE)d.postFormat(c,0,!0,d),this._valueSet(c.join(""))},definitions:{"~":{validator:function(a,c,d,e,b){if(""==a)return!1;if(1>=d&&"0"===c[0]&&/[\d-]/.test(a))return c[0]="",{pos:0};var f=e?c.slice(0,d):c.slice();f.splice(d+1,0,a);f=f.join("");if(b.autoGroup&&!e)var o=h.inputmask.escapeRegex.call(this,b.groupSeparator),f=f.replace(RegExp(o,"g"),"");
|
|
o=b.regex.number(b.groupSeparator,b.groupSize,b.radixPoint,b.digits).test(f);if(!o&&(f+="0",o=b.regex.number(b.groupSeparator,b.groupSize,b.radixPoint,b.digits).test(f),!o)){o=f.lastIndexOf(b.groupSeparator);for(i=f.length-o;3>=i;i++)f+="0";o=b.regex.number(b.groupSeparator,b.groupSize,b.radixPoint,b.digits).test(f);if(!o&&!e&&a==b.radixPoint&&(o=b.regex.number(b.groupSeparator,b.groupSize,b.radixPoint,b.digits).test("0"+f+"0")))return c[d]="0",d++,{pos:d}}return!1!=o&&!e&&a!=b.radixPoint?{pos:b.postFormat(c,
|
|
d+1,!1,b)}:o},cardinality:1,prevalidator:null}},insertMode:!0,autoUnmask:!1},"non-negative-decimal":{regex:{number:function(a,c,d,e){a=h.inputmask.escapeRegex.call(this,a);d=h.inputmask.escapeRegex.call(this,d);e=isNaN(e)?e:"{0,"+e+"}";return RegExp("^[+]?(\\d+|\\d{1,"+c+"}(("+a+"\\d{"+c+"})?)+)("+d+"\\d"+e+")?$")}},alias:"decimal"},integer:{regex:{number:function(a,c){var d=h.inputmask.escapeRegex.call(this,a);return RegExp("^[+-]?(\\d+|\\d{1,"+c+"}(("+d+"\\d{"+c+"})?)+)$")}},alias:"decimal"},"non-negative-integer":{regex:{number:function(a,
|
|
c){var d=h.inputmask.escapeRegex.call(this,a);return RegExp("^[+]?(\\d+|\\d{1,"+c+"}(("+d+"\\d{"+c+"})?)+)$")}},alias:"integer"}})})(jQuery);
|
|
(function(h){h.extend(h.inputmask.defaults.aliases,{Regex:{mask:"r",greedy:!1,repeat:10,regex:null,regexSplit:null,definitions:{r:{validator:function(a,c,d,e,b){null==b.regexSplit&&(b.regexSplit=b.regex.match(RegExp("\\[.*?]\\*","g")));var f=c.slice(),c="",e=!1;f.splice(d,0,a);a=f.join("");for(d=0;d<b.regexSplit.length&&!(c+=b.regexSplit[d],e=RegExp("^"+c+"$").test(a),console.log(a+" "+e+" "+c),e);d++);return e},cardinality:1}}}})})(jQuery);
|