Commit 8331ff01 by Kartik Visweswaran

Fix #3196: Masked input widget revamped to use new plugin

parent 62fdaeec
......@@ -51,6 +51,7 @@ Yii Framework 2 Change Log
- Enh #3108: Added `yii\debug\Module::enableDebugLogs` to disable logging debug logs by default (qiangxue)
- Enh #3132: `yii\rbac\PhpManager` now supports more compact data file format (qiangxue)
- Enh #3154: Added validation error display for `GridView` filters (ivan-kolmychek)
- Enh #3196: Masked input upgraded to use jquery.inputmask plugin with more features. (kartik-v)
- Enh #3222: Added `useTablePrefix` option to the model generator for Gii (horizons2)
- Enh #3230: Added `yii\filters\AccessControl::user` to support access control with different actors (qiangxue)
- Enh #3232: Added `export()` and `exportAsString()` methods to `yii\helpers\BaseVarDumper` (klimov-paul)
......
/*
Input Mask plugin for jquery
http://github.com/RobinHerbots/jquery.inputmask
Copyright (c) 2010 - 2014 Robin Herbots
Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
Version: 3.0.31
Input Mask plugin for jquery
http://github.com/RobinHerbots/jquery.inputmask
Copyright (c) 2010 - 2014 Robin Herbots
Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
Version: 3.0.31
*/
(function(d){if(void 0===d.fn.inputmask){var a=function(a){var d=document.createElement("input");a="on"+a;var f=a in d;f||(d.setAttribute(a,"return;"),f="function"==typeof d[a]);return f},c=function(a,n,f){return(a=f.aliases[a])?(a.alias&&c(a.alias,void 0,f),d.extend(!0,f,a),d.extend(!0,f,n),!0):!1},h=function(a){function c(d){function f(a,d,c,n){this.matches=[];this.isGroup=a||!1;this.isOptional=d||!1;this.isQuantifier=c||!1;this.isAlternator=n||!1;this.quantifier={min:1,max:1}}function n(d,f,c){var b=
a.definitions[f],e=0==d.matches.length;c=void 0!=c?c:d.matches.length;if(b&&!h){for(var g=b.prevalidator,k=g?g.length:0,m=1;m<b.cardinality;m++){var p=k>=m?g[m-1]:[],G=p.validator,p=p.cardinality;d.matches.splice(c++,0,{fn:G?"string"==typeof G?RegExp(G):new function(){this.test=G}:/./,cardinality:p?p:1,optionality:d.isOptional,newBlockMarker:e,casing:b.casing,def:b.definitionSymbol||f})}d.matches.splice(c++,0,{fn:b.validator?"string"==typeof b.validator?RegExp(b.validator):new function(){this.test=
b.validator}:/./,cardinality:b.cardinality,optionality:d.isOptional,newBlockMarker:e,casing:b.casing,def:b.definitionSymbol||f})}else d.matches.splice(c++,0,{fn:null,cardinality:0,optionality:d.isOptional,newBlockMarker:e,casing:null,def:f}),h=!1}for(var b=/(?:[?*+]|\{[0-9\+\*]+(?:,[0-9\+\*]*)?\})\??|[^.?*+^${[]()|\\]+|./g,h=!1,e=new f,g,p=[],u=[];g=b.exec(d);)switch(g=g[0],g.charAt(0)){case a.optionalmarker.end:case a.groupmarker.end:var q=p.pop();0<p.length?p[p.length-1].matches.push(q):e.matches.push(q);
break;case a.optionalmarker.start:p.push(new f(!1,!0));break;case a.groupmarker.start:p.push(new f(!0));break;case a.quantifiermarker.start:q=new f(!1,!1,!0);g=g.replace(/[{}]/g,"");var r=g.split(",");g=isNaN(r[0])?r[0]:parseInt(r[0]);r=1==r.length?g:isNaN(r[1])?r[1]:parseInt(r[1]);if("*"==r||"+"==r)g="*"==r?0:1;q.quantifier={min:g,max:r};if(0<p.length){r=p[p.length-1].matches;g=r.pop();if(!g.isGroup){var v=new f(!0);v.matches.push(g);g=v}r.push(g);r.push(q)}else g=e.matches.pop(),g.isGroup||(v=new f(!0),
v.matches.push(g),g=v),e.matches.push(g),e.matches.push(q);break;case a.escapeChar:h=!0;break;case a.alternatormarker:break;default:0<p.length?n(p[p.length-1],g):(0<e.matches.length&&(q=e.matches[e.matches.length-1],q.isGroup&&(q.isGroup=!1,n(q,a.groupmarker.start,0),n(q,a.groupmarker.end))),n(e,g))}0<e.matches.length&&u.push(e);return u}function f(f,b){if(a.numericInput&&!0!==a.multi){f=f.split("").reverse();for(var h=0;h<f.length;h++)f[h]==a.optionalmarker.start?f[h]=a.optionalmarker.end:f[h]==
a.optionalmarker.end?f[h]=a.optionalmarker.start:f[h]==a.groupmarker.start?f[h]=a.groupmarker.end:f[h]==a.groupmarker.end&&(f[h]=a.groupmarker.start);f=f.join("")}if(void 0!=f&&""!=f){if(0<a.repeat||"*"==a.repeat||"+"==a.repeat)f=a.groupmarker.start+f+a.groupmarker.end+a.quantifiermarker.start+("*"==a.repeat?0:"+"==a.repeat?1:a.repeat)+","+a.repeat+a.quantifiermarker.end;void 0==d.inputmask.masksCache[f]&&(d.inputmask.masksCache[f]={mask:f,maskToken:c(f),validPositions:{},_buffer:void 0,buffer:void 0,
tests:{},metadata:b});return d.extend(!0,{},d.inputmask.masksCache[f])}}var b=[];d.isFunction(a.mask)&&(a.mask=a.mask.call(this,a));d.isArray(a.mask)?d.each(a.mask,function(a,d){void 0!=d.mask?b.push(f(d.mask.toString(),d)):b.push(f(d.toString()))}):(1==a.mask.length&&!1==a.greedy&&0!=a.repeat&&(a.placeholder=""),b=void 0!=a.mask.mask?f(a.mask.mask.toString(),a.mask):f(a.mask.toString()));return b},e="function"===typeof ScriptEngineMajorVersion?ScriptEngineMajorVersion():10<=(new Function("/*@cc_on return @_jscript_version; @*/"))(),
b=navigator.userAgent,g=null!==b.match(/iphone/i),q=null!==b.match(/android.*safari.*/i),w=null!==b.match(/android.*chrome.*/i),r=null!==b.match(/android.*firefox.*/i),I=/Kindle/i.test(b)||/Silk/i.test(b)||/KFTT/i.test(b)||/KFOT/i.test(b)||/KFJWA/i.test(b)||/KFJWI/i.test(b)||/KFSOWI/i.test(b)||/KFTHWA/i.test(b)||/KFTHWI/i.test(b)||/KFAPWA/i.test(b)||/KFAPWI/i.test(b),J=a("paste")?"paste":a("input")?"input":"propertychange",v=function(a,c,f){function b(a,d,h){d=d||0;var e=[],g,t=0,k;do{if(!0===a&&
c.validPositions[t]){var l=c.validPositions[t];k=l.match;g=l.locator.slice();e.push(null==k.fn?k.def:!0===h?l.input:f.placeholder.charAt(t%f.placeholder.length))}else g=d>t?E(t,g,t-1)[0]:m(t,g,t-1),k=g.match,g=g.locator.slice(),e.push(null==k.fn?k.def:f.placeholder.charAt(t%f.placeholder.length));t++}while((void 0==K||t-1<K)&&null!=k.fn||null==k.fn&&""!=k.def||d>=t);e.pop();return e}function h(a){var d=c;d.buffer=void 0;d.tests={};!0!==a&&(d._buffer=void 0,d.validPositions={},d.p=-1)}function v(a){var C=
c,b=-1,h=C.validPositions;if(d.isFunction(f.getLastValidPosition))b=f.getLastValidPosition.call(s,C,a,f);else{void 0==a&&(a=-1);var C=b,g;for(g in h){var e=parseInt(g);if(-1==a||null!=h[e].match.fn)e<a&&(C=e),e>=a&&(b=e)}b=1<a-C||b<a?C:b}return b}function k(a,b,h){if(f.insertMode&&void 0!=c.validPositions[a]&&void 0==h){h=d.extend(!0,{},c.validPositions);var e=v(),g;for(g=a;g<=e;g++)delete c.validPositions[g];c.validPositions[a]=b;b=!0;for(g=a;g<=e;g++){a=h[g];if(void 0!=a){var t=null==a.match.fn?
g+1:z(g);b=Q(t,a.match.def)?b&&!1!==W(t,a.input,!0,!0):!1}if(!b)break}if(!b)return c.validPositions=d.extend(!0,{},h),!1}else c.validPositions[a]=b;return!0}function m(a,c,d){a=E(a,c,d);var b;for(c=0;c<a.length&&(b=a[c],!f.greedy&&(!b.match||!1!==b.match.optionality&&!1!==b.match.newBlockMarker||!0===b.match.optionalQuantifier));c++);return b}function H(a){return c.validPositions[a]?c.validPositions[a].match:E(a)[0].match}function Q(a,c){for(var d=!1,f=E(a),b=0;b<f.length;b++)if(f[b].match&&f[b].match.def==
c){d=!0;break}return d}function E(a,b,h){function g(c,b,h,e){function C(h,e,n){if(t==a&&void 0==h.matches)return k.push({match:h,locator:e.reverse()}),!0;if(void 0!=h.matches)if(h.isGroup&&!0!==n){if(h=C(c.matches[D+1],e))return!0}else if(h.isOptional){var m=h;if(h=g(h,b,e,n))h=k[k.length-1].match,(h=0==d.inArray(h,m.matches))&&(l=!0),t=a}else{if(!h.isAlternator)if(h.isQuantifier&&!0!==n)for(m=h,f.greedy=f.greedy&&!isNaN(m.quantifier.max),n=0<b.length&&!0!==n?b.shift():0;n<(isNaN(m.quantifier.max)?
n+1:m.quantifier.max)&&t<=a;n++){var p=c.matches[d.inArray(m,c.matches)-1];if(h=C(p,[n].concat(e),!0))if(h=k[k.length-1].match,h.optionalQuantifier=n>m.quantifier.min-1,h=0==d.inArray(h,p.matches))if(n>m.quantifier.min-1){l=!0;t=a;break}else return!0;else return!0}else if(h=g(h,b,e,n))return!0}else t++}for(var D=0<b.length?b.shift():0;D<c.matches.length;D++)if(!0!==c.matches[D].isQuantifier){var n=C(c.matches[D],[D].concat(h),e);if(n&&t==a)return n;if(t>a)break}}var e=c.maskToken,t=b?h:0;h=b||[0];
var k=[],l=!1;if(void 0==b){b=a-1;for(var m;void 0==(m=c.validPositions[b])&&-1<b;)b--;if(void 0!=m&&-1<b)t=b,h=m.locator.slice();else{for(b=a-1;void 0==(m=c.tests[b])&&-1<b;)b--;void 0!=m&&-1<b&&(t=b,h=m[0].locator.slice())}}for(b=h.shift();b<e.length&&!(g(e[b],h,[b])&&t==a||t>a);b++);(0==k.length||l)&&k.push({match:{fn:null,cardinality:0,optionality:!0,casing:null,def:""},locator:[]});return c.tests[a]=k}function A(){void 0==c._buffer&&(c._buffer=b(!1,1));return c._buffer}function u(){void 0==c.buffer&&
(c.buffer=b(!0,v(),!0));return c.buffer}function S(a,c){for(var d=u().slice(),b=a;b<c;b++)d[b]!=R(b)&&d[b]!=f.skipOptionalPartCharacter&&W(b,d[b],!0,!0)}function ha(a,c){switch(c.casing){case "upper":a=a.toUpperCase();break;case "lower":a=a.toLowerCase()}return a}function W(a,b,g,e){function m(a,b,aa,g){var e=!1;d.each(E(a),function(C,D){for(var t=D.match,l=b?1:0,m="",ia=u(),p=t.cardinality;p>l;p--)m+=void 0==c.validPositions[a-(p-1)]?R(a-(p-1)):c.validPositions[a-(p-1)].input;b&&(m+=b);e=null!=t.fn?
t.fn.test(m,ia,a,aa,f):b!=t.def&&b!=f.skipOptionalPartCharacter||""==t.def?!1:{c:t.def,pos:a};if(!1!==e){l=void 0!=e.c?e.c:b;l=l==f.skipOptionalPartCharacter&&null===t.fn?t.def:l;m=a;if(e.refreshFromBuffer){m=e.refreshFromBuffer;aa=!0;!0===m?(c.validPositions={},c.tests={},S(0,u().length)):S(m.start,m.end);if(void 0==e.pos&&void 0==e.c)return e.pos=v(),!1;m=void 0!=e.pos?e.pos:a;D=E(m)[0]}else!0!==e&&e.pos!=a&&(m=e.pos,S(a,m),D=E(m)[0]);0<C&&h(!0);k(m,d.extend({},D,{input:ha(l,t)}),g)||(e=!1);return!1}});
return e}g=!0===g;var t=m(a,b,g,e);if(!g&&!1===t){var l=c.validPositions[a];if(l&&null==l.match.fn&&(l.match.def==b||b==f.skipOptionalPartCharacter))t={caret:z(a)};else if((f.insertMode||void 0==c.validPositions[z(a)])&&!N(a))for(var l=a+1,p=z(a);l<=p;l++)if(t=m(l,b,g,e),!1!==t){a=l;break}}!0===t&&(t={pos:a});return t}function N(a){a=H(a);return null!=a.fn?a.fn:!1}function O(){var a;K=s.prop("maxLength");-1==K&&(K=void 0);if(!1==f.greedy){var b;b=v();a=c.validPositions[b];var d=void 0!=a?a.locator.slice():
void 0;for(b+=1;void 0==a||null!=a.match.fn||null==a.match.fn&&""!=a.match.def;b++)a=m(b,d,b-1),d=a.locator.slice();a=b}else a=u().length;return void 0==K||a<K?a:K}function z(a){var c=O();if(a>=c)return c;for(;++a<c&&!N(a)&&(!0!==f.nojumps||f.nojumpsThreshold>a););return a}function V(a){if(0>=a)return 0;for(;0<--a&&!N(a););return a}function B(a,c,b){a._valueSet(c.join(""));void 0!=b&&x(a,b)}function R(a,c){c=c||H(a);return null==c.fn?c.def:f.placeholder.charAt(a%f.placeholder.length)}function P(a,
b,f,e,g){e=void 0!=e?e.slice():ga(a._valueGet()).split("");h();b&&a._valueSet("");d.each(e,function(b,h){if(!0===g){var e=c.p,e=-1==e?e:V(e),k=-1==e?b:z(e);-1==d.inArray(h,A().slice(e+1,k))&&Y.call(a,void 0,!0,h.charCodeAt(0),!1,f,b)}else Y.call(a,void 0,!0,h.charCodeAt(0),!1,f,b),f=f||0<b&&b>c.p});b&&B(a,u(),d(a).is(":focus")?z(v(0)):void 0)}function $(a){return d.inputmask.escapeRegex.call(this,a)}function ga(a){return a.replace(RegExp("("+$(A().join(""))+")*$"),"")}function X(a){var b=u().slice(),
d,f=v(),h={},e=void 0!=c.validPositions[f]?c.validPositions[f].locator.slice():void 0,g;for(d=f+1;d<b.length;d++)g=m(d,e,d-1),e=g.locator.slice(),h[d]=g;for(d=b.length-1;d>f;d--)if(g=h[d].match,g.optionality&&b[d]==R(d,g))b.pop();else break;B(a,b)}function ba(a,b){if(!a.data("_inputmask")||!0!==b&&a.hasClass("hasDatepicker"))return a[0]._valueGet();var h=[],e=c.validPositions,g;for(g in e)e[g].match&&null!=e[g].match.fn&&h.push(e[g].input);h=(y?h.reverse():h).join("");e=(y?u().reverse():u()).join("");
return d.isFunction(f.onUnMask)?f.onUnMask.call(a,e,h,f):h}function M(a){!y||"number"!=typeof a||f.greedy&&""==f.placeholder||(a=u().length-a);return a}function x(a,c,b){a=a.jquery&&0<a.length?a[0]:a;if("number"==typeof c){c=M(c);b=M(b);b="number"==typeof b?b:c;var h=d(a).data("_inputmask")||{};h.caret={begin:c,end:b};d(a).data("_inputmask",h);d(a).is(":visible")&&(a.scrollLeft=a.scrollWidth,!1==f.insertMode&&c==b&&b++,a.setSelectionRange?(a.selectionStart=c,a.selectionEnd=b):a.createTextRange&&(a=
a.createTextRange(),a.collapse(!0),a.moveEnd("character",b),a.moveStart("character",c),a.select()))}else return h=d(a).data("_inputmask"),!d(a).is(":visible")&&h&&void 0!=h.caret?(c=h.caret.begin,b=h.caret.end):a.setSelectionRange?(c=a.selectionStart,b=a.selectionEnd):document.selection&&document.selection.createRange&&(a=document.selection.createRange(),c=0-a.duplicate().moveStart("character",-1E5),b=c+a.text.length),c=M(c),b=M(b),{begin:c,end:b}}function T(a){if(d.isFunction(f.isComplete))return f.isComplete.call(s,
a,f);if("*"!=f.repeat){var c=!1,b=V(O());if(v()==b)for(var c=!0,h=0;h<=b;h++){var e=N(h);if(e&&(void 0==a[h]||a[h]==R(h))||!e&&a[h]!=R(h)){c=!1;break}}return c}}function ja(a){a=d._data(a).events;d.each(a,function(a,c){d.each(c,function(a,c){if("inputmask"==c.namespace&&"setvalue"!=c.type){var b=c.handler;c.handler=function(a){if(this.readOnly||this.disabled)a.preventDefault;else return b.apply(this,arguments)}}})})}function ka(a){function c(a){if(void 0==d.valHooks[a]||!0!=d.valHooks[a].inputmaskpatch){var b=
d.valHooks[a]&&d.valHooks[a].get?d.valHooks[a].get:function(a){return a.value},h=d.valHooks[a]&&d.valHooks[a].set?d.valHooks[a].set:function(a,c){a.value=c;return a};d.valHooks[a]={get:function(a){var c=d(a);if(c.data("_inputmask")){if(c.data("_inputmask").opts.autoUnmask)return c.inputmask("unmaskedvalue");a=b(a);c=(c=c.data("_inputmask").maskset._buffer)?c.join(""):"";return a!=c?a:""}return b(a)},set:function(a,c){var b=d(a),f=h(a,c);b.data("_inputmask")&&b.triggerHandler("setvalue.inputmask");
return f},inputmaskpatch:!0}}}var b;Object.getOwnPropertyDescriptor&&(b=Object.getOwnPropertyDescriptor(a,"value"));if(b&&b.get){if(!a._valueGet){var h=b.get,f=b.set;a._valueGet=function(){return y?h.call(this).split("").reverse().join(""):h.call(this)};a._valueSet=function(a){f.call(this,y?a.split("").reverse().join(""):a)};Object.defineProperty(a,"value",{get:function(){var a=d(this),c=d(this).data("_inputmask");return c?c.opts.autoUnmask?a.inputmask("unmaskedvalue"):h.call(this)!=A().join("")?
h.call(this):"":h.call(this)},set:function(a){f.call(this,a);d(this).triggerHandler("setvalue.inputmask")}})}}else document.__lookupGetter__&&a.__lookupGetter__("value")?a._valueGet||(h=a.__lookupGetter__("value"),f=a.__lookupSetter__("value"),a._valueGet=function(){return y?h.call(this).split("").reverse().join(""):h.call(this)},a._valueSet=function(a){f.call(this,y?a.split("").reverse().join(""):a)},a.__defineGetter__("value",function(){var a=d(this),c=d(this).data("_inputmask");return c?c.opts.autoUnmask?
a.inputmask("unmaskedvalue"):h.call(this)!=A().join("")?h.call(this):"":h.call(this)}),a.__defineSetter__("value",function(a){f.call(this,a);d(this).triggerHandler("setvalue.inputmask")})):(a._valueGet||(a._valueGet=function(){return y?this.value.split("").reverse().join(""):this.value},a._valueSet=function(a){this.value=y?a.split("").reverse().join(""):a}),c(a.type))}function ca(a,b,d){if(f.numericInput||y){switch(b){case f.keyCode.BACKSPACE:b=f.keyCode.DELETE;break;case f.keyCode.DELETE:b=f.keyCode.BACKSPACE}y&&
(a=d.end,d.end=d.begin,d.begin=a)}d.begin==d.end?b==f.keyCode.BACKSPACE?d.begin=V(d.begin):b==f.keyCode.DELETE&&d.end++:1!=d.end-d.begin||f.insertMode||b==f.keyCode.BACKSPACE&&d.begin--;a=d.begin;var e=d.end;for(b=a;a<e;a++)delete c.validPositions[a];for(a=e;a<=v();){var e=c.validPositions[a],g=c.validPositions[b];void 0!=e&&void 0==g?(Q(b,e.match.def)&&!1!==W(b,e.input,!0)&&(delete c.validPositions[a],a++),b++):a++}for(b=v();0<b&&(void 0==c.validPositions[b]||null==c.validPositions[b].match.fn);)delete c.validPositions[b],
b--;h(!0);b=z(-1);v()<b?c.p=b:c.p=d.begin}function da(a){Z=!1;var b=this,e=d(b),k=a.keyCode,m=x(b);k==f.keyCode.BACKSPACE||k==f.keyCode.DELETE||g&&127==k||a.ctrlKey&&88==k?(a.preventDefault(),88==k&&(F=u().join("")),ca(b,k,m),B(b,u(),c.p),b._valueGet()==A().join("")&&e.trigger("cleared"),f.showTooltip&&e.prop("title",c.mask)):k==f.keyCode.END||k==f.keyCode.PAGE_DOWN?setTimeout(function(){var c=z(v());f.insertMode||c!=O()||a.shiftKey||c--;x(b,a.shiftKey?m.begin:c,c)},0):k==f.keyCode.HOME&&!a.shiftKey||
k==f.keyCode.PAGE_UP?x(b,0,a.shiftKey?m.begin:0):k==f.keyCode.ESCAPE||90==k&&a.ctrlKey?(P(b,!0,!1,F.split("")),e.click()):k!=f.keyCode.INSERT||a.shiftKey||a.ctrlKey?!1!=f.insertMode||a.shiftKey||(k==f.keyCode.RIGHT?setTimeout(function(){var a=x(b);x(b,a.begin)},0):k==f.keyCode.LEFT&&setTimeout(function(){var a=x(b);x(b,a.begin-1)},0)):(f.insertMode=!f.insertMode,x(b,f.insertMode||m.begin!=O()?m.begin:m.begin-1));var e=x(b),l=f.onKeyDown.call(this,a,u(),f);l&&!0===l.refreshFromBuffer&&(c.validPositions=
{},c.tests={},S(0,u().length),h(!0),B(b,u()),x(b,e.begin,e.end));ea=-1!=d.inArray(k,f.ignorables)}function Y(a,b,e,g,l,p){if(void 0==e&&Z)return!1;Z=!0;var Q=d(this);a=a||window.event;e=b?e:a.which||a.charCode||a.keyCode;if(!(!0===b||a.ctrlKey&&a.altKey)&&(a.ctrlKey||a.metaKey||ea))return!0;if(e){!0!==b&&46==e&&!1==a.shiftKey&&","==f.radixPoint&&(e=44);var H;e=String.fromCharCode(e);b?(p=l?p:v()+1,p={begin:p,end:p}):p=x(this);var q=y?1<p.begin-p.end||1==p.begin-p.end&&f.insertMode:1<p.end-p.begin||
1==p.end-p.begin&&f.insertMode;q&&(c.undoPositions=d.extend(!0,{},c.validPositions),ca(this,f.keyCode.DELETE,p),f.insertMode||(f.insertMode=!f.insertMode,k(p.begin,l),f.insertMode=!f.insertMode),q=!f.multi);c.writeOutBuffer=!0;var r=p.begin,s=W(r,e,l);!1!==s&&(!0!==s&&(r=void 0!=s.pos?s.pos:r,e=void 0!=s.c?s.c:e),h(!0),void 0!=s.caret?H=s.caret:(l=c.validPositions,H=void 0!=l[r+1]&&m(p+1,l[r].locator.slice(),r).match.def!=l[r+1].match.def?r+1:z(r)),c.p=H);if(!1!==g){var A=this;setTimeout(function(){f.onKeyValidation.call(A,
s,f)},0);if(c.writeOutBuffer&&!1!==s){var E=u();B(this,E,b?void 0:f.numericInput?V(H):H);!0!==b&&setTimeout(function(){!0===T(E)&&Q.trigger("complete");U=!0;Q.trigger("input")},0)}else q&&(c.buffer=void 0,c.validPositions=c.undoPositions)}else q&&(c.buffer=void 0,c.validPositions=c.undoPositions);f.showTooltip&&Q.prop("title",c.mask);a&&!0!=b&&(a.preventDefault?a.preventDefault():a.returnValue=!1)}}function la(a){var b=d(this),e=a.keyCode,g=u();(a=f.onKeyUp.call(this,a,g,f))&&!0===a.refreshFromBuffer&&
(c.validPositions={},c.tests={},S(0,u().length),h(!0),B(this,u()));e==f.keyCode.TAB&&f.showMaskOnFocus&&(b.hasClass("focus.inputmask")&&0==this._valueGet().length?(h(),g=u(),B(this,g),x(this,0),F=u().join("")):(B(this,g),x(this,M(0),M(O()))))}function fa(a){if(!0===U&&"input"==a.type)return U=!1,!0;var b=this,c=d(b);if("propertychange"==a.type&&b._valueGet().length<=O())return!0;setTimeout(function(){var a=d.isFunction(f.onBeforePaste)?f.onBeforePaste.call(b,b._valueGet(),f):b._valueGet();P(b,!0,
!1,a.split(""),!0);!0===T(u())&&c.trigger("complete");c.click()},0)}function ma(a){if(!0===U&&"input"==a.type)return U=!1,!0;var b=x(this),c=this._valueGet(),c=c.replace(RegExp("("+$(A().join(""))+")*"),"");b.begin>c.length&&(x(this,c.length),b=x(this));1!=u().length-c.length||c.charAt(b.begin)==u()[b.begin]||c.charAt(b.begin+1)==u()[b.begin]||N(b.begin)||(a.keyCode=f.keyCode.BACKSPACE,da.call(this,a));a.preventDefault()}function na(a){s=d(a);if(s.is(":input")){s.data("_inputmask",{maskset:c,opts:f,
isRTL:!1});f.showTooltip&&s.prop("title",c.mask);ka(a);("rtl"==a.dir||f.rightAlign)&&s.css("text-align","right");if("rtl"==a.dir||f.numericInput){a.dir="ltr";s.removeAttr("dir");var b=s.data("_inputmask");b.isRTL=!0;s.data("_inputmask",b);y=!0}s.unbind(".inputmask");s.removeClass("focus.inputmask");s.closest("form").bind("submit",function(){F!=u().join("")&&s.change()}).bind("reset",function(){setTimeout(function(){s.trigger("setvalue")},0)});s.bind("mouseenter.inputmask",function(){!d(this).hasClass("focus.inputmask")&&
f.showMaskOnHover&&this._valueGet()!=u().join("")&&B(this,u())}).bind("blur.inputmask",function(){var a=d(this);if(a.data("_inputmask")){var b=this._valueGet(),c=u();a.removeClass("focus.inputmask");F!=u().join("")&&a.change();f.clearMaskOnLostFocus&&""!=b&&(b==A().join("")?this._valueSet(""):X(this));!1===T(c)&&(a.trigger("incomplete"),f.clearIncomplete&&(h(),f.clearMaskOnLostFocus?this._valueSet(""):(c=A().slice(),B(this,c))))}}).bind("focus.inputmask",function(){var a=d(this),b=this._valueGet();
f.showMaskOnFocus&&!a.hasClass("focus.inputmask")&&(!f.showMaskOnHover||f.showMaskOnHover&&""==b)&&this._valueGet()!=u().join("")&&B(this,u(),z(v()));a.addClass("focus.inputmask");F=u().join("")}).bind("mouseleave.inputmask",function(){var a=d(this);f.clearMaskOnLostFocus&&(a.hasClass("focus.inputmask")||this._valueGet()==a.attr("placeholder")||(this._valueGet()==A().join("")||""==this._valueGet()?this._valueSet(""):X(this)))}).bind("click.inputmask",function(){var a=this;setTimeout(function(){var b=
x(a);u();if(b.begin==b.end){var b=y?M(b.begin):b.begin,c=v(b),c=z(c);b<c?N(b)?x(a,b):x(a,z(b)):x(a,c)}},0)}).bind("dblclick.inputmask",function(){var a=this;setTimeout(function(){x(a,0,z(v()))},0)}).bind(J+".inputmask dragdrop.inputmask drop.inputmask",fa).bind("setvalue.inputmask",function(){P(this,!0);F=u().join("");this._valueGet()==A().join("")&&this._valueSet("")}).bind("complete.inputmask",f.oncomplete).bind("incomplete.inputmask",f.onincomplete).bind("cleared.inputmask",f.oncleared);s.bind("keydown.inputmask",
da).bind("keypress.inputmask",Y).bind("keyup.inputmask",la);if(q||r||w||I)"input"==J&&s.unbind(J+".inputmask"),s.bind("input.inputmask",ma);e&&s.bind("input.inputmask",fa);b=d.isFunction(f.onBeforeMask)?f.onBeforeMask.call(a,a._valueGet(),f):a._valueGet();P(a,!0,!1,b.split(""),!0);F=u().join("");var g;try{g=document.activeElement}catch(k){}g===a?(s.addClass("focus.inputmask"),x(a,z(v()))):f.clearMaskOnLostFocus?u().join("")==A().join("")?a._valueSet(""):X(a):B(a,u());ja(a)}}var y=!1,F,s,Z=!1,U=!1,
ea=!1,K;if(void 0!=a)switch(a.action){case "isComplete":return s=d(a.el),c=s.data("_inputmask").maskset,f=s.data("_inputmask").opts,T(a.buffer);case "unmaskedvalue":return s=a.$input,c=s.data("_inputmask").maskset,f=s.data("_inputmask").opts,y=a.$input.data("_inputmask").isRTL,ba(a.$input,a.skipDatepickerCheck);case "mask":F=u().join("");na(a.el);break;case "format":s=d({});s.data("_inputmask",{maskset:c,opts:f,isRTL:f.numericInput});f.numericInput&&(y=!0);var L=a.value.split("");P(s,!1,!1,y?L.reverse():
L,!0);return y?u().reverse().join(""):u().join("");case "isValid":return s=d({}),s.data("_inputmask",{maskset:c,opts:f,isRTL:f.numericInput}),f.numericInput&&(y=!0),L=a.value.split(""),P(s,!1,!0,y?L.reverse():L),T(u());case "getemptymask":return s=d(a.el),c=s.data("_inputmask").maskset,f=s.data("_inputmask").opts,A();case "remove":a=a.el;s=d(a);c=s.data("_inputmask").maskset;f=s.data("_inputmask").opts;a._valueSet(ba(s));s.unbind(".inputmask");s.removeClass("focus.inputmask");s.removeData("_inputmask");
Object.getOwnPropertyDescriptor&&(L=Object.getOwnPropertyDescriptor(a,"value"));L&&L.get?a._valueGet&&Object.defineProperty(a,"value",{get:a._valueGet,set:a._valueSet}):document.__lookupGetter__&&a.__lookupGetter__("value")&&a._valueGet&&(a.__defineGetter__("value",a._valueGet),a.__defineSetter__("value",a._valueSet));try{delete a._valueGet,delete a._valueSet}catch(pa){a._valueGet=void 0,a._valueSet=void 0}}};d.inputmask={defaults:{placeholder:"_",optionalmarker:{start:"[",end:"]"},quantifiermarker:{start:"{",
end:"}"},groupmarker:{start:"(",end:")"},alternatormarker:"|",escapeChar:"\\",mask:null,oncomplete:d.noop,onincomplete:d.noop,oncleared:d.noop,repeat:0,greedy:!0,autoUnmask:!1,clearMaskOnLostFocus:!0,insertMode:!0,clearIncomplete:!1,aliases:{},onKeyUp:d.noop,onKeyDown:d.noop,onBeforeMask:void 0,onBeforePaste:void 0,onUnMask:void 0,showMaskOnFocus:!0,showMaskOnHover:!0,onKeyValidation:d.noop,skipOptionalPartCharacter:" ",showTooltip:!1,numericInput:!1,getLastValidPosition:void 0,rightAlign:!1,radixPoint:"",
definitions:{9:{validator:"[0-9]",cardinality:1,definitionSymbol:"*"},a:{validator:"[A-Za-z\u0410-\u044f\u0401\u0451]",cardinality:1,definitionSymbol:"*"},"*":{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:[8,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],isComplete:void 0},masksCache:{},escapeRegex:function(a){return a.replace(RegExp("(\\/|\\.|\\*|\\+|\\?|\\||\\(|\\)|\\[|\\]|\\{|\\}|\\\\)","gim"),"\\$1")},format:function(a,b){var f=d.extend(!0,{},d.inputmask.defaults,b);c(f.alias,b,f);return v({action:"format",value:a},h(f),f)},isValid:function(a,b){var f=d.extend(!0,
{},d.inputmask.defaults,b);c(f.alias,b,f);return v({action:"isValid",value:a},h(f),f)}};d.fn.inputmask=function(a,b,f,e,g){function q(a,b){var c=d(a),h;for(h in b){var f=c.data("inputmask-"+h.toLowerCase());void 0!=f&&(b[h]=f)}return b}f=f||v;e=e||"_inputmask";var k=d.extend(!0,{},d.inputmask.defaults,b),m;if("string"===typeof a)switch(a){case "mask":return c(k.alias,b,k),m=h(k),0==m.length?this:this.each(function(){f({action:"mask",el:this},d.extend(!0,{},m),q(this,k))});case "unmaskedvalue":return a=
d(this),a.data(e)?f({action:"unmaskedvalue",$input:a}):a.val();case "remove":return this.each(function(){d(this).data(e)&&f({action:"remove",el:this})});case "getemptymask":return this.data(e)?f({action:"getemptymask",el:this}):"";case "hasMaskedValue":return this.data(e)?!this.data(e).opts.autoUnmask:!1;case "isComplete":return this.data(e)?f({action:"isComplete",buffer:this[0]._valueGet().split(""),el:this}):!0;case "getmetadata":if(this.data(e))return m=this.data(e).maskset,m.metadata;break;case "_detectScope":return c(k.alias,
b,k),void 0==g||c(g,b,k)||-1!=d.inArray(g,"mask unmaskedvalue remove getemptymask hasMaskedValue isComplete getmetadata _detectScope".split(" "))||(k.mask=g),d.isFunction(k.mask)&&(k.mask=k.mask.call(this,k)),d.isArray(k.mask);default:return c(a,b,k)||(k.mask=a),m=h(k),void 0==m?this:this.each(function(){f({action:"mask",el:this},d.extend(!0,{},m),q(this,k))})}else{if("object"==typeof a)return k=d.extend(!0,{},d.inputmask.defaults,a),c(k.alias,a,k),m=h(k),void 0==m?this:this.each(function(){f({action:"mask",
el:this},d.extend(!0,{},m),q(this,k))});if(void 0==a)return this.each(function(){var a=d(this).attr("data-inputmask");if(a&&""!=a)try{var a=a.replace(RegExp("'","g"),'"'),h=d.parseJSON("{"+a+"}");d.extend(!0,h,b);k=d.extend(!0,{},d.inputmask.defaults,h);c(k.alias,h,k);k.alias=void 0;d(this).inputmask("mask",k,f)}catch(e){}})}}}})(jQuery);
(function(d){if(void 0!=d.fn.inputmask){var a=function(a,h,e){function b(a){var b=document.createElement("input");a="on"+a;var c=a in b;c||(b.setAttribute(a,"return;"),c="function"==typeof b[a]);return c}function g(a){if(void 0==d.valHooks[a]||!0!=d.valHooks[a].inputmaskmultipatch){var b=d.valHooks[a]&&d.valHooks[a].get?d.valHooks[a].get:function(a){return a.value},c=d.valHooks[a]&&d.valHooks[a].set?d.valHooks[a].set:function(a,b){a.value=b;return a};d.valHooks[a]={get:function(a){var c=d(a);return c.data("_inputmask-multi")?
(a=c.data("_inputmask-multi"),b(a.elmasks[a.activeMasksetIndex])):b(a)},set:function(a,b){var h=d(a),f=c(a,b);h.data("_inputmask-multi")&&h.triggerHandler("setvalue");return f},inputmaskmultipatch:!0}}}function q(a,b,c){a=a.jquery&&0<a.length?a[0]:a;if("number"==typeof b){b=w(b);c=w(c);c="number"==typeof c?c:b;if(a!=l){var h=d(a).data("_inputmask")||{};h.caret={begin:b,end:c};d(a).data("_inputmask",h)}d(a).is(":visible")&&(a.scrollLeft=a.scrollWidth,!1==e.insertMode&&b==c&&c++,a.setSelectionRange?
(a.selectionStart=b,a.selectionEnd=c):a.createTextRange&&(a=a.createTextRange(),a.collapse(!0),a.moveEnd("character",c),a.moveStart("character",b),a.select()))}else return h=d(a).data("_inputmask"),!d(a).is(":visible")&&h&&void 0!=h.caret?(b=h.caret.begin,c=h.caret.end):a.setSelectionRange?(b=a.selectionStart,c=a.selectionEnd):document.selection&&document.selection.createRange&&(a=document.selection.createRange(),b=0-a.duplicate().moveStart("character",-1E5),c=b+a.text.length),b=w(b),c=w(c),{begin:b,
end:c}}function w(a){!v||"number"!=typeof a||e.greedy&&""==e.placeholder||(a=l.value.length-a);return a}function r(a,b){if("multiMaskScope"!=a){if(d.isFunction(e.determineActiveMasksetIndex))p=e.determineActiveMasksetIndex.call(n,a,b);else{var c=-1,h=-1,f=-1;d.each(b,function(a,b){var e=d(b).data("_inputmask").maskset,g=-1,n=0,l=q(b).begin,m;for(m in e.validPositions)e=parseInt(m),e>g&&(g=e),n++;if(n>c||n==c&&h>l&&f>g||n==c&&h==l&&f<g)c=n,h=l,p=a,f=g})}var g=n.data("_inputmask-multi")||{activeMasksetIndex:0,
elmasks:b};g.activeMasksetIndex=p;n.data("_inputmask-multi",g)}-1==d.inArray(a,["focus"])&&l.value!=b[p]._valueGet()&&(g=""==d(b[p]).val()?b[p]._valueGet():d(b[p]).val(),l.value=g);-1==d.inArray(a,["blur","focus"])&&d(b[p]).hasClass("focus.inputmask")&&(g=q(b[p]),q(l,g.begin,g.end))}function I(a){l=a;n=d(l);v="rtl"==l.dir||e.numericInput;p=0;f=d.map(h,function(a,b){var c='<input type="text" ';n.attr("value")&&(c+='value="'+n.attr("value")+'" ');n.attr("dir")&&(c+='dir="'+n.attr("dir")+'" ');c=d(c+
"/>")[0];d(c).inputmask(d.extend({},e,{mask:a.mask}));return c});n.data("_inputmask-multi",{activeMasksetIndex:0,elmasks:f});("rtl"==l.dir||e.rightAlign)&&n.css("text-align","right");l.dir="ltr";n.removeAttr("dir");""!=n.attr("value")&&r("init",f);n.bind("mouseenter blur focus mouseleave click dblclick keydown keypress keypress",function(a){var b=q(l),c,h=!0;if("keydown"==a.type){c=a.keyCode;if(c==e.keyCode.DOWN&&p<f.length-1)return p++,r("multiMaskScope",f),!1;if(c==e.keyCode.UP&&0<p)return p--,
r("multiMaskScope",f),!1;if(a.ctrlKey||a.shiftKey||a.altKey)return!0}else if("keypress"==a.type&&(a.ctrlKey||a.shiftKey||a.altKey))return!0;d.each(f,function(f,g){if("keydown"==a.type){c=a.keyCode;if(c==e.keyCode.BACKSPACE&&g._valueGet().length<b.begin)return;if(c==e.keyCode.TAB)h=!1;else{if(c==e.keyCode.RIGHT){q(g,b.begin+1,b.end+1);h=!1;return}if(c==e.keyCode.LEFT){q(g,b.begin-1,b.end-1);h=!1;return}}}if(-1!=d.inArray(a.type,["click"])&&(q(g,w(b.begin),w(b.end)),b.begin!=b.end)){h=!1;return}-1!=
d.inArray(a.type,["keydown"])&&b.begin!=b.end&&q(g,b.begin,b.end);d(g).triggerHandler(a)});h&&setTimeout(function(){r(a.type,f)},0)});n.bind(J+" dragdrop drop setvalue",function(a){q(l);setTimeout(function(){d.each(f,function(b,c){c._valueSet(l.value);d(c).triggerHandler(a)});setTimeout(function(){r(a.type,f)},0)},0)});g(l.type)}var J=b("paste")?"paste":b("input")?"input":"propertychange",v,l,n,f,p;e.multi=!0;if(void 0!=a)switch(a.action){case "isComplete":return n=d(a.el),a=n.data("_inputmask-multi"),
a=a.elmasks[a.activeMasksetIndex],d(a).inputmask("isComplete");case "unmaskedvalue":return n=a.$input,a=n.data("_inputmask-multi"),a=a.elmasks[a.activeMasksetIndex],d(a).inputmask("unmaskedvalue");case "mask":I(a.el);break;case "format":return n=d({}),n.data("_inputmask",{maskset:maskset,opts:e,isRTL:e.numericInput}),e.numericInput&&(v=!0),a=a.value.split(""),checkVal(n,!1,!1,v?a.reverse():a,!0),v?getBuffer().reverse().join(""):getBuffer().join("");case "isValid":return n=d({}),n.data("_inputmask",
{maskset:maskset,opts:e,isRTL:e.numericInput}),e.numericInput&&(v=!0),a=a.value.split(""),checkVal(n,!1,!0,v?a.reverse():a),isComplete(getBuffer());case "getemptymask":return n=d(a.el),maskset=n.data("_inputmask").maskset,e=n.data("_inputmask").opts,getBufferTemplate();case "remove":l=a.el;n=d(l);maskset=n.data("_inputmask").maskset;e=n.data("_inputmask").opts;l._valueSet(unmaskedvalue(n));n.unbind(".inputmask");n.removeClass("focus.inputmask");n.removeData("_inputmask");var G;Object.getOwnPropertyDescriptor&&
(G=Object.getOwnPropertyDescriptor(l,"value"));G&&G.get?l._valueGet&&Object.defineProperty(l,"value",{get:l._valueGet,set:l._valueSet}):document.__lookupGetter__&&l.__lookupGetter__("value")&&l._valueGet&&(l.__defineGetter__("value",l._valueGet),l.__defineSetter__("value",l._valueSet));try{delete l._valueGet,delete l._valueSet}catch(oa){l._valueGet=void 0,l._valueSet=void 0}}};d.extend(d.inputmask.defaults,{multi:!1,nojumps:!1,nojumpsThreshold:0,determineActiveMasksetIndex:void 0});d.inputmask._fn=
d.fn.inputmask;d.fn.inputmask=function(c,h){if("string"===typeof c)return d.inputmask._fn("_detectScope",h,void 0,void 0,c)?d.inputmask._fn.call(this,c,h,a,"_inputmask-multi"):d.inputmask._fn.call(this,c,h);if("object"==typeof c)return opts=d.extend(!0,{},d.inputmask.defaults,c),d.inputmask._fn("_detectScope",c)?d.inputmask._fn.call(this,c,h,a,"_inputmask-multi"):d.inputmask._fn.call(this,c,h);if(void 0==c)return d.inputmask._fn.call(this,c,h)}}})(jQuery);
(function(d){d.extend(d.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"}});d.extend(d.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(a,c,h,d,b){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,d,q,w){if(w.regex["urlpre"+(a+1)]){var r=c;0<a+1-c.length&&(r=b.join("").substring(0,a+1-c.length)+""+r);c=w.regex["urlpre"+(a+1)].test(r);if(!q&&!c){d-=a;for(q=0;q<w.defaultPrefix.length;q++)b[d]=w.defaultPrefix[q],d++;for(q=0;q<r.length-1;q++)b[d]=r[q],d++;return{pos:d}}return c}return!1},
cardinality:a}}();return a}()},r:{validator:".",cardinality:50}},insertMode:!1,autoUnmask:!1},ip:{mask:"i[i[i]].i[i[i]].i[i[i]].i[i[i]]",definitions:{i:{validator:function(a,c,d,e,b){-1<d-1&&"."!=c[d-1]?(a=c[d-1]+a,a=-1<d-2&&"."!=c[d-2]?c[d-2]+a:"0"+a):a="00"+a;return/25[0-5]|2[0-4][0-9]|[01][0-9][0-9]/.test(a)},cardinality:1}}},email:{mask:"*{1,20}[.*{1,20}][.*{1,20}][.*{1,20}]@*{1,20}.*{2,6}[.*{1,2}]",greedy:!1}})})(jQuery);
(function(d){d.extend(d.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}]}});d.extend(d.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=d.inputmask.escapeRegex.call(this,a);return RegExp("((0[1-9]|[12][0-9]|3[01])"+a+"[01])")},val2:function(a){a=d.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){if(isNaN(a))return!1;var e=parseInt(a.concat(c.toString().slice(a.length)));a=parseInt(a.concat(d.toString().slice(a.length)));return(isNaN(e)?!1:c<=e&&e<=d)||(isNaN(a)?!1:c<=a&&a<=d)},determinebaseyear:function(a,c,d){var e=(new Date).getFullYear();if(a>e)return a;if(c<e){for(var e=c.toString().slice(0,2),b=c.toString().slice(2,4);c<e+d;)e--;c=e+b;return a>c?a:c}return e},onKeyUp:function(a,c,h){c=
d(this);a.ctrlKey&&a.keyCode==h.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 g=b.regex.val1.test(a);return e||g||a.charAt(1)!=b.separator&&-1=="-./".indexOf(a.charAt(1))||!(g=b.regex.val1.test("0"+a.charAt(0)))?g:(c[d-1]="0",{refreshFromBuffer:{start:d-1,end:d},pos:d,c:a.charAt(0)})},cardinality:2,prevalidator:[{validator:function(a,c,d,e,b){isNaN(c[d+1])||(a+=c[d+1]);var g=1==a.length?
b.regex.val1pre.test(a):b.regex.val1.test(a);return e||g||!(g=b.regex.val1.test("0"+a))?g:(c[d]="0",d++,{pos:d})},cardinality:1}]},2:{validator:function(a,c,d,e,b){var g=b.mask.indexOf("2")==b.mask.length-1?c.join("").substr(5,3):c.join("").substr(0,3);-1!=g.indexOf(b.placeholder[0])&&(g="01"+b.separator);var q=b.regex.val2(b.separator).test(g+a);if(!(e||q||a.charAt(1)!=b.separator&&-1=="-./".indexOf(a.charAt(1)))&&(q=b.regex.val2(b.separator).test(g+"0"+a.charAt(0))))return c[d-1]="0",{refreshFromBuffer:{start:d-
1,end:d},pos:d,c:a.charAt(0)};if(b.mask.indexOf("2")==b.mask.length-1&&q){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 q},cardinality:2,prevalidator:[{validator:function(a,c,d,e,b){isNaN(c[d+1])||(a+=c[d+1]);var g=b.mask.indexOf("2")==b.mask.length-1?c.join("").substr(5,3):c.join("").substr(0,3);-1!=g.indexOf(b.placeholder[0])&&(g="01"+b.separator);var q=1==a.length?b.regex.val2pre(b.separator).test(g+a):
b.regex.val2(b.separator).test(g+a);return e||q||!(q=b.regex.val2(b.separator).test(g+"0"+a))?q:(c[d]="0",d++,{pos:d})},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 g=b.isInYearRange(a,b.yearrange.minyear,b.yearrange.maxyear);if(!e&&!g){e=b.determinebaseyear(b.yearrange.minyear,
b.yearrange.maxyear,a+"0").toString().slice(0,1);if(g=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,a+"0").toString().slice(0,2);if(g=b.isInYearRange(e+a,b.yearrange.minyear,b.yearrange.maxyear))return c[d++]=e[0],c[d++]=e[1],{pos:d}}return g},cardinality:1},{validator:function(a,c,d,e,b){var g=b.isInYearRange(a,b.yearrange.minyear,b.yearrange.maxyear);if(!e&&!g){e=b.determinebaseyear(b.yearrange.minyear,
b.yearrange.maxyear,a).toString().slice(0,2);if(g=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,a).toString().slice(0,2);b.isInYearRange(e+a,b.yearrange.minyear,b.yearrange.maxyear)?c.join("").substr(0,6)!=b.leapday?g=!0:(b=parseInt(a,10),g=0===b%4?0===b%100?0===b%400?!0:!1:!0:!1):g=!1;if(g)return c[d-1]=e[0],c[d++]=e[1],c[d++]=a[0],{refreshFromBuffer:{start:d-3,end:d},pos:d}}return g},
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=d.inputmask.escapeRegex.call(this,a);return RegExp("((0[13-9]|1[012])"+a+"[0-3])|(02"+a+"[0-2])")},val2:function(a){a=d.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,h){c=d(this);a.ctrlKey&&a.keyCode==h.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,h){c=d(this);a.ctrlKey&&a.keyCode==h.keyCode.RIGHT&&(a=new Date,c.val(a.getFullYear().toString()+(a.getMonth()+1).toString()+a.getDate().toString()))}},"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-4]|1[3-9]/,hrs:/[01][0-9]|2[0-4]/,ampm:/^[a|p|A|P][m|M]/},timeseparator:":",hourFormat:"24",definitions:{h:{validator:function(a,c,d,e,b){if("24"==b.hourFormat&&24==parseInt(a,10))return c[d-1]="0",c[d]="0",{refreshFromBuffer:{start:d-1,end:d},c:"0"};var g=b.regex.hrs.test(a);return e||g||a.charAt(1)!=b.timeseparator&&
-1=="-.:".indexOf(a.charAt(1))||!(g=b.regex.hrs.test("0"+a.charAt(0)))?g&&"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)),{refreshFromBuffer:{start:d-1,end:d+6},c:c[d]}):g:(c[d-1]="0",c[d]=a.charAt(0),d++,{refreshFromBuffer:{start:d-2,end:d},pos:d,c:b.timeseparator})},cardinality:2,prevalidator:[{validator:function(a,c,d,e,b){var g=b.regex.hrspre.test(a);
return e||g||!(g=b.regex.hrs.test("0"+a))?g:(c[d]="0",d++,{pos:d})},cardinality:1}]},t:{validator:function(a,c,d,e,b){return b.regex.ampm.test(a+"m")},casing:"lower",cardinality:1}},insertMode:!1,autoUnmask:!1},datetime12:{mask:"1/2/y h:s t\\m",placeholder:"dd/mm/yyyy hh:mm xm",alias:"datetime",hourFormat:"12"},"hh:mm t":{mask:"h:s t\\m",placeholder:"hh:mm xm",alias:"datetime",hourFormat:"12"},"h:s t":{mask:"h:s t\\m",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"},"mm/yyyy":{mask:"1/y",placeholder:"mm/yyyy",leapday:"donotuse",separator:"/",alias:"mm/dd/yyyy"}})})(jQuery);
(function(d){d.extend(d.inputmask.defaults.aliases,{numeric:{mask:function(a){0!==a.repeat&&isNaN(a.integerDigits)&&(a.integerDigits=a.repeat);a.repeat=0;var c=a.prefix,c=c+"[+]"+("~{1,"+a.integerDigits+"}");void 0!=a.digits&&(isNaN(a.digits)||0<parseInt(a.digits))&&(c=a.digitsOptional?c+("["+a.radixPoint+"~{"+a.digits+"}]"):c+(a.radixPoint+"~{"+a.digits+"}"));return c+=a.suffix},placeholder:"",greedy:!1,digits:"*",digitsOptional:!0,groupSeparator:"",radixPoint:".",groupSize:3,autoGroup:!1,allowPlus:!0,
allowMinus:!0,integerDigits:"+",defaultValue:"",prefix:"",suffix:"",skipRadixDance:!1,getLastValidPosition:function(a,c,h){var e=-1,b=a.validPositions,g;for(g in b)b=parseInt(g),b>e&&(e=b);void 0!=c&&(a=a.buffer,!1===h.skipRadixDance&&""!=h.radixPoint&&-1!=d.inArray(h.radixPoint,a)&&(e=d.inArray(h.radixPoint,a)));return e},rightAlign:!0,postFormat:function(a,c,h,e){var b=!1;if(""==e.groupSeparator)return{pos:c};var g=a.slice();h||g.splice(c,0,"?");g=g.join("");if(e.autoGroup||h&&-1!=g.indexOf(e.groupSeparator)){var q=
d.inputmask.escapeRegex.call(this,e.groupSeparator),g=g.replace(RegExp(q,"g"),""),q=g.split(e.radixPoint),g=q[0];if(g!=e.prefix+"?0")for(var b=!0,w=RegExp("([-+]?[\\d?]+)([\\d?]{"+e.groupSize+"})");w.test(g);)g=g.replace(w,"$1"+e.groupSeparator+"$2"),g=g.replace(e.groupSeparator+e.groupSeparator,e.groupSeparator);1<q.length&&(g+=e.radixPoint+q[1])}a.length=g.length;e=0;for(q=g.length;e<q;e++)a[e]=g.charAt(e);g=d.inArray("?",a);h||a.splice(g,1);return{pos:h?c:g,refreshFromBuffer:b}},onKeyDown:function(a,
c,h){d(this);if(h.autoGroup&&a.keyCode==h.keyCode.DELETE||a.keyCode==h.keyCode.BACKSPACE)return h.postFormat(c,0,!0,h)},regex:{integerPart:function(a){return/[-+]?\d+/}},definitions:{"~":{validator:function(a,c,h,e,b){if(!e&&"-"===a){var g=c.join("").match(b.regex.integerPart(b));if(0<g.length)return"+"==c[g.index]?(c.splice(g.index,1),{pos:g.index,c:"-",refreshFromBuffer:!0,caret:h}):"-"==c[g.index]?(c.splice(g.index,1),{refreshFromBuffer:!0,caret:h-1}):{pos:g.index,c:"-",caret:h+1}}g=e?RegExp("[0-9"+
d.inputmask.escapeRegex.call(this,b.groupSeparator)+"]").test(a):/[0-9]/.test(a);return!1==g||e||a==b.radixPoint||!0!==b.autoGroup?g:b.postFormat(c,h,"-"==a||"+"==a?!0:!1,b)},cardinality:1,prevalidator:null},"+":{validator:function(a,c,d,e,b){c="[";!0===b.allowMinus&&(c+="-");!0===b.allowPlus&&(c+="+");return RegExp(c+"]").test(a)},cardinality:1,prevalidator:null}},insertMode:!0,autoUnmask:!1},decimal:{alias:"numeric"},integer:{alias:"numeric",digits:"0"}})})(jQuery);
(function(d){d.extend(d.inputmask.defaults.aliases,{Regex:{mask:"r",greedy:!1,repeat:"*",regex:null,regexTokens:null,tokenizer:/\[\^?]?(?:[^\\\]]+|\\[\S\s]?)*]?|\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9][0-9]*|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|c[A-Za-z]|[\S\s]?)|\((?:\?[:=!]?)?|(?:[?*+]|\{[0-9]+(?:,[0-9]*)?\})\??|[^.?*+^${[()|\\]+|./g,quantifierFilter:/[0-9]+[^,]/,isComplete:function(a,c){return RegExp(c.regex).test(a.join(""))},definitions:{r:{validator:function(a,c,h,e,b){function g(a,b){this.matches=
[];this.isGroup=a||!1;this.isQuantifier=b||!1;this.quantifier={min:1,max:1};this.repeaterPart=void 0}function q(){var a=new g,c,d=[];for(b.regexTokens=[];c=b.tokenizer.exec(b.regex);)switch(c=c[0],c.charAt(0)){case "(":d.push(new g(!0));break;case ")":var f=d.pop();0<d.length?d[d.length-1].matches.push(f):a.matches.push(f);break;case "{":case "+":case "*":var e=new g(!1,!0);c=c.replace(/[{}]/g,"");f=c.split(",");c=isNaN(f[0])?f[0]:parseInt(f[0]);f=1==f.length?c:isNaN(f[1])?f[1]:parseInt(f[1]);e.quantifier=
{min:c,max:f};if(0<d.length){var h=d[d.length-1].matches;c=h.pop();c.isGroup||(f=new g(!0),f.matches.push(c),c=f);h.push(c);h.push(e)}else c=a.matches.pop(),c.isGroup||(f=new g(!0),f.matches.push(c),c=f),a.matches.push(c),a.matches.push(e);break;default:0<d.length?d[d.length-1].matches.push(c):a.matches.push(c)}0<a.matches.length&&b.regexTokens.push(a)}function w(a,b){var c=!1;b&&(r+="(",I++);for(var f=0;f<a.matches.length;f++){var e=a.matches[f];if(!0==e.isGroup)c=w(e,!0);else if(!0==e.isQuantifier){var g=
d.inArray(e,a.matches),g=a.matches[g-1],h=r;if(isNaN(e.quantifier.max)){for(;e.repeaterPart&&e.repeaterPart!=r&&e.repeaterPart.length>r.length&&!(c=w(g,!0)););(c=c||w(g,!0))&&(e.repeaterPart=r);r=h+e.quantifier.max}else{for(var k=0,m=e.quantifier.max-1;k<m&&!(c=w(g,!0));k++);r=h+"{"+e.quantifier.min+","+e.quantifier.max+"}"}}else if(void 0!=e.matches)for(g=0;g<e.length&&!(c=w(e[g],b));g++);else{if("["==e[0]){c=r;c+=e;for(k=0;k<I;k++)c+=")";c=RegExp("^("+c+")$");c=c.test(J)}else for(g=0,h=e.length;g<
h;g++)if("\\"!=e[g]){c=r;c+=e.substr(0,g+1);c=c.replace(/\|$/,"");for(k=0;k<I;k++)c+=")";c=RegExp("^("+c+")$");if(c=c.test(J))break}r+=e}if(c)break}b&&(r+=")",I--);return c}null==b.regexTokens&&q();e=c.slice();var r="";c=!1;var I=0;e.splice(h,0,a);var J=e.join("");for(a=0;a<b.regexTokens.length&&!(g=b.regexTokens[a],c=w(g,g.isGroup));a++);return c},cardinality:1}}}})})(jQuery);
(function(d){d.extend(d.inputmask.defaults.aliases,{phone:{url:"phone-codes/phone-codes.json",mask:function(a){a.definitions={p:{validator:function(){return!1},cardinality:1},"#":{validator:"[0-9]",cardinality:1}};var c=[];d.ajax({url:a.url,async:!1,dataType:"json",success:function(a){c=a}});c.splice(0,0,"+p(ppp)ppp-pppp");return c},nojumps:!0,nojumpsThreshold:1},phonebe:{url:"phone-codes/phone-be.json",mask:function(a){a.definitions={p:{validator:function(){return!1},cardinality:1},"#":{validator:"[0-9]",
cardinality:1}};var c=[];d.ajax({url:a.url,async:!1,dataType:"json",success:function(a){c=a}});c.splice(0,0,"+32(ppp)ppp-pppp");return c},nojumps:!0,nojumpsThreshold:4}})})(jQuery);
/*
Masked Input plugin for jQuery
Copyright (c) 2007-2013 Josh Bush (digitalbush.com)
Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license)
Version: 1.3.1
*/
(function($) {
function getPasteEvent() {
var el = document.createElement('input'),
name = 'onpaste';
el.setAttribute(name, '');
return (typeof el[name] === 'function')?'paste':'input';
}
var pasteEventName = getPasteEvent() + ".mask",
ua = navigator.userAgent,
iPhone = /iphone/i.test(ua),
android=/android/i.test(ua),
caretTimeoutId;
$.mask = {
//Predefined character definitions
definitions: {
'9': "[0-9]",
'a': "[A-Za-z]",
'*': "[A-Za-z0-9]"
},
dataName: "rawMaskFn",
placeholder: '_',
};
$.fn.extend({
//Helper Function for Caret positioning
caret: function(begin, end) {
var range;
if (this.length === 0 || this.is(":hidden")) {
return;
}
if (typeof begin == 'number') {
end = (typeof end === 'number') ? end : begin;
return this.each(function() {
if (this.setSelectionRange) {
this.setSelectionRange(begin, end);
} else if (this.createTextRange) {
range = this.createTextRange();
range.collapse(true);
range.moveEnd('character', end);
range.moveStart('character', begin);
range.select();
}
});
} else {
if (this[0].setSelectionRange) {
begin = this[0].selectionStart;
end = this[0].selectionEnd;
} else if (document.selection && document.selection.createRange) {
range = document.selection.createRange();
begin = 0 - range.duplicate().moveStart('character', -100000);
end = begin + range.text.length;
}
return { begin: begin, end: end };
}
},
unmask: function() {
return this.trigger("unmask");
},
mask: function(mask, settings) {
var input,
defs,
tests,
partialPosition,
firstNonMaskPos,
len;
if (!mask && this.length > 0) {
input = $(this[0]);
return input.data($.mask.dataName)();
}
settings = $.extend({
placeholder: $.mask.placeholder, // Load default placeholder
completed: null
}, settings);
defs = $.mask.definitions;
tests = [];
partialPosition = len = mask.length;
firstNonMaskPos = null;
$.each(mask.split(""), function(i, c) {
if (c == '?') {
len--;
partialPosition = i;
} else if (defs[c]) {
tests.push(new RegExp(defs[c]));
if (firstNonMaskPos === null) {
firstNonMaskPos = tests.length - 1;
}
} else {
tests.push(null);
}
});
return this.trigger("unmask").each(function() {
var input = $(this),
buffer = $.map(
mask.split(""),
function(c, i) {
if (c != '?') {
return defs[c] ? settings.placeholder : c;
}
}),
focusText = input.val();
function seekNext(pos) {
while (++pos < len && !tests[pos]);
return pos;
}
function seekPrev(pos) {
while (--pos >= 0 && !tests[pos]);
return pos;
}
function shiftL(begin,end) {
var i,
j;
if (begin<0) {
return;
}
for (i = begin, j = seekNext(end); i < len; i++) {
if (tests[i]) {
if (j < len && tests[i].test(buffer[j])) {
buffer[i] = buffer[j];
buffer[j] = settings.placeholder;
} else {
break;
}
j = seekNext(j);
}
}
writeBuffer();
input.caret(Math.max(firstNonMaskPos, begin));
}
function shiftR(pos) {
var i,
c,
j,
t;
for (i = pos, c = settings.placeholder; i < len; i++) {
if (tests[i]) {
j = seekNext(i);
t = buffer[i];
buffer[i] = c;
if (j < len && tests[j].test(t)) {
c = t;
} else {
break;
}
}
}
}
function keydownEvent(e) {
var k = e.which,
pos,
begin,
end;
//backspace, delete, and escape get special treatment
if (k === 8 || k === 46 || (iPhone && k === 127)) {
pos = input.caret();
begin = pos.begin;
end = pos.end;
if (end - begin === 0) {
begin=k!==46?seekPrev(begin):(end=seekNext(begin-1));
end=k===46?seekNext(end):end;
}
clearBuffer(begin, end);
shiftL(begin, end - 1);
e.preventDefault();
} else if (k == 27) {//escape
input.val(focusText);
input.caret(0, checkVal());
e.preventDefault();
}
}
function keypressEvent(e) {
var k = e.which,
pos = input.caret(),
p,
c,
next;
if (e.ctrlKey || e.altKey || e.metaKey || k < 32) {//Ignore
return;
} else if (k) {
if (pos.end - pos.begin !== 0){
clearBuffer(pos.begin, pos.end);
shiftL(pos.begin, pos.end-1);
}
p = seekNext(pos.begin - 1);
if (p < len) {
c = String.fromCharCode(k);
if (tests[p].test(c)) {
shiftR(p);
buffer[p] = c;
writeBuffer();
next = seekNext(p);
if(android){
setTimeout($.proxy($.fn.caret,input,next),0);
}else{
input.caret(next);
}
if (settings.completed && next >= len) {
settings.completed.call(input);
}
}
}
e.preventDefault();
}
}
function clearBuffer(start, end) {
var i;
for (i = start; i < end && i < len; i++) {
if (tests[i]) {
buffer[i] = settings.placeholder;
}
}
}
function writeBuffer() { input.val(buffer.join('')); }
function checkVal(allow) {
//try to place characters where they belong
var test = input.val(),
lastMatch = -1,
i,
c;
for (i = 0, pos = 0; i < len; i++) {
if (tests[i]) {
buffer[i] = settings.placeholder;
while (pos++ < test.length) {
c = test.charAt(pos - 1);
if (tests[i].test(c)) {
buffer[i] = c;
lastMatch = i;
break;
}
}
if (pos > test.length) {
break;
}
} else if (buffer[i] === test.charAt(pos) && i !== partialPosition) {
pos++;
lastMatch = i;
}
}
if (allow) {
writeBuffer();
} else if (lastMatch + 1 < partialPosition) {
input.val("");
clearBuffer(0, len);
} else {
writeBuffer();
input.val(input.val().substring(0, lastMatch + 1));
}
return (partialPosition ? i : firstNonMaskPos);
}
input.data($.mask.dataName,function(){
return $.map(buffer, function(c, i) {
return tests[i]&&c!=settings.placeholder ? c : null;
}).join('');
});
if (!input.attr("readonly"))
input
.one("unmask", function() {
input
.unbind(".mask")
.removeData($.mask.dataName);
})
.bind("focus.mask", function() {
clearTimeout(caretTimeoutId);
var pos,
moveCaret;
focusText = input.val();
pos = checkVal();
caretTimeoutId = setTimeout(function(){
writeBuffer();
if (pos == mask.length) {
input.caret(0, pos);
} else {
input.caret(pos);
}
}, 10);
})
.bind("blur.mask", function() {
checkVal();
if (input.val() != focusText)
input.change();
})
.bind("keydown.mask", keydownEvent)
.bind("keypress.mask", keypressEvent)
.bind(pasteEventName, function() {
setTimeout(function() {
var pos=checkVal(true);
input.caret(pos);
if (settings.completed && pos == input.val().length)
settings.completed.call(input);
}, 0);
});
checkVal(); //Perform initial check for existing values
});
}
});
})(jQuery);
......@@ -11,13 +11,13 @@ use yii\base\InvalidConfigException;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\web\JsExpression;
use yii\web\View;
/**
* MaskedInput generates a masked text input.
*
* MaskedInput is similar to [[Html::textInput()]] except that
* an input mask will be used to force users to enter properly formatted data,
* such as phone numbers, social security numbers.
* MaskedInput is similar to [[Html::textInput()]] except that an input mask will be used to force users to enter
* properly formatted data, such as phone numbers, social security numbers.
*
* To use MaskedInput, you must set the [[mask]] property. The following example
* shows how to use MaskedInput to collect phone numbers:
......@@ -29,38 +29,54 @@ use yii\web\JsExpression;
* ]);
* ~~~
*
* The masked text field is implemented based on the [jQuery masked input plugin](http://digitalbush.com/projects/masked-input-plugin).
* The masked text field is implemented based on the
* [jQuery input mask plugin](https://github.com/RobinHerbots/jquery.inputmask).
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @since 2.0
*/
class MaskedInput extends InputWidget
{
const PLUGIN_NAME = 'inputmask';
/**
* @var string the input mask (e.g. '99/99/9999' for date input). The following characters are predefined:
* @var string|array|JsExpression the input mask (e.g. '99/99/9999' for date input). The following characters
* can be used in the mask and are predefined:
*
* - `a`: represents an alpha character (A-Z, a-z)
* - `9`: represents a numeric character (0-9)
* - `*`: represents an alphanumeric character (A-Z, a-z, 0-9)
* - `?`: anything listed after '?' within the mask is considered optional user input
* - `[` and `]`: anything entered between the square brackets is considered optional user input. This is
* based on the `optionalmarker` setting in `clientOptions`.
*
* Additional characters can be defined by specifying the [[charMap]] property.
* Additional definitions can be set through definitions property.
*/
public $mask;
/**
* @var array the mapping between mask characters and the corresponding patterns.
* For example, `['~' => '[+-]']` specifies that the '~' character expects '+' or '-' input.
* Defaults to null, meaning using the map as described in [[mask]].
* @var array custom mask definitions to use. Should be configured as `$maskSymbol => $settings`, where:
* - `maskSymbol`: string, a character to identify your mask definition
* - `settings`: array, consisiting of the following entries:
* - `validator`: string, a JS regular expression or a JS function.
* - `cardinality`: int, specifies how many characters are represented and validated for the definition.
* - `prevalidator`: array, validate the characters before the definition cardinality is reached.
* - `definitionSymbol`: string, allows shifting values from other definitions, with this `definitionSymbol`.
*/
public $charMap;
public $definitions;
/**
* @var string the character prompting for user input. Defaults to underscore '_'.
* @var array custom aliases to use. Should be configured as `$maskAlias` => $settings`, where:
* - `maskAlias`: string, a text to identify your mask alias definition (e.g. 'phone')
* - `settings`: array settings for the mask symbol, exactly similar to parameters as passed in `clientOptions`
*/
public $placeholder;
public $aliases;
/**
* @var string a JavaScript function callback that will be invoked when user finishes the input.
* @var array the JQuery plugin options for the input mask plugin.
* @see https://github.com/RobinHerbots/jquery.inputmask
*/
public $completed;
public $clientOptions = [];
/**
* @var array the HTML attributes for the input tag.
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
......@@ -68,19 +84,28 @@ class MaskedInput extends InputWidget
public $options = ['class' => 'form-control'];
/**
* @var string the hashed variable to store the pluginOptions
*/
protected $_hashVar;
/**
* Initializes the widget.
*
* @throws InvalidConfigException if the "mask" property is not set.
*/
public function init()
{
parent::init();
if (empty($this->mask)) {
throw new InvalidConfigException('The "mask" property must be set.');
if (empty($this->mask) && empty($this->clientOptions['alias'])) {
throw new InvalidConfigException("Either the 'mask' property or the 'clientOptions[\"alias\"]' property must be set.");
}
}
/**
*
* Runs the widget.
*
* @return string|void
*/
public function run()
{
......@@ -93,41 +118,60 @@ class MaskedInput extends InputWidget
}
/**
* Registers the needed JavaScript.
* Generates a hashed variable to store the plugin `clientOptions`. Helps in reusing the variable for similar
* options passed for other widgets on the same page. The following special data attributes will also be
* setup for the input widget, that can be accessed through javascript:
* - 'data-plugin-options' will store the hashed variable storing the plugin options.
* - 'data-plugin-name' the name of the plugin
*
* @param View $view the view instance
*/
public function registerClientScript()
protected function hashPluginOptions($view)
{
$options = $this->getClientOptions();
$options = empty($options) ? '' : ',' . Json::encode($options);
$js = '';
if (is_array($this->charMap) && !empty($this->charMap)) {
$js .= 'jQuery.mask.definitions=' . Json::encode($this->charMap) . ";\n";
}
$id = $this->options['id'];
$js .= "jQuery(\"#{$id}\").mask(\"{$this->mask}\"{$options});";
$view = $this->getView();
MaskedInputAsset::register($view);
$view->registerJs($js);
$encOptions = empty($this->clientOptions) ? '{}' : Json::encode($this->clientOptions);
$this->_hashVar = self::PLUGIN_NAME . '_' . hash('crc32', $encOptions);
$this->options['data-plugin-name'] = self::PLUGIN_NAME;
$this->options['data-plugin-options'] = $this->_hashVar;
$view->registerJs("var {$this->_hashVar} = {$encOptions};\n", View::POS_HEAD);
}
/**
* @return array the options for the text field
* Initializes client options
*/
protected function getClientOptions()
protected function initClientOptions()
{
$options = [];
if ($this->placeholder !== null) {
$options['placeholder'] = $this->placeholder;
}
if ($this->completed !== null) {
if ($this->completed instanceof JsExpression) {
$options['completed'] = $this->completed;
} else {
$options['completed'] = new JsExpression($this->completed);
$options = $this->clientOptions;
foreach ($options as $key => $value) {
if (in_array($key, ['oncomplete', 'onincomplete', 'oncleared', 'onKeyUp', 'onKeyDown', 'onBeforeMask',
'onBeforePaste', 'onUnMask', 'isComplete', 'determineActiveMasksetIndex']) && !$value instanceof JsExpression
) {
$options[$key] = new JsExpression($value);
}
}
$this->clientOptions = $options;
}
return $options;
/**
* Registers the needed client script and options.
*/
public function registerClientScript()
{
$js = '';
$view = $this->getView();
$this->initClientOptions();
if (!empty($this->mask)) {
$this->clientOptions['mask'] = $this->mask;
}
$this->hashPluginOptions($view);
if (is_array($this->definitions) && !empty($this->definitions)) {
$js .= '$.extend($.' . self::PLUGIN_NAME . '.defaults.definitions, ' . Json::encode($this->definitions) . ");\n";
}
if (is_array($this->aliases) && !empty($this->aliases)) {
$js .= '$.extend($.' . self::PLUGIN_NAME . '.defaults.aliases, ' . Json::encode($this->aliases) . ");\n";
}
$id = $this->options['id'];
$js .= '$("#' . $id . '").' . self::PLUGIN_NAME . "(" . $this->_hashVar . ");\n";
MaskedInputAsset::register($view);
$view->registerJs($js);
}
}
......@@ -10,16 +10,12 @@ namespace yii\widgets;
use yii\web\AssetBundle;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @since 2.0
*/
class MaskedInputAsset extends AssetBundle
{
public $sourcePath = '@yii/assets';
public $js = [
'jquery.maskedinput.js',
];
public $depends = [
'yii\web\YiiAsset',
];
public $js = ['jquery.inputmask.bundle.min.js'];
public $depends = ['yii\web\YiiAsset'];
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment