jquery.inputmask.bundle.js 189 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706
  1. /*!
  2. * jquery.inputmask.bundle.js
  3. * https://github.com/RobinHerbots/jquery.inputmask
  4. * Copyright (c) 2010 - 2017 Robin Herbots
  5. * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
  6. * Version: 3.3.5-223
  7. */
  8. !function(factory) {
  9. window.Inputmask = function($, window, document, undefined) {
  10. function Inputmask(alias, options, internal) {
  11. if (!(this instanceof Inputmask)) return new Inputmask(alias, options, internal);
  12. this.el = undefined, this.events = {}, this.maskset = undefined, this.refreshValue = !1,
  13. !0 !== internal && ($.isPlainObject(alias) ? options = alias : (options = options || {},
  14. options.alias = alias), this.opts = $.extend(!0, {}, this.defaults, options), this.noMasksCache = options && options.definitions !== undefined,
  15. this.userOptions = options || {}, this.isRTL = this.opts.numericInput, resolveAlias(this.opts.alias, options, this.opts));
  16. }
  17. function resolveAlias(aliasStr, options, opts) {
  18. var aliasDefinition = Inputmask.prototype.aliases[aliasStr];
  19. return aliasDefinition ? (aliasDefinition.alias && resolveAlias(aliasDefinition.alias, undefined, opts),
  20. $.extend(!0, opts, aliasDefinition), $.extend(!0, opts, options), !0) : (null === opts.mask && (opts.mask = aliasStr),
  21. !1);
  22. }
  23. function generateMaskSet(opts, nocache) {
  24. function generateMask(mask, metadata, opts) {
  25. var regexMask = !1;
  26. if (null !== mask && "" !== mask || (regexMask = null !== opts.regex, regexMask ? (mask = opts.regex,
  27. mask = mask.replace(/^(\^)(.*)(\$)$/, "$2")) : mask = "*{*}"), 1 === mask.length && !1 === opts.greedy && 0 !== opts.repeat && (opts.placeholder = ""),
  28. opts.repeat > 0 || "*" === opts.repeat || "+" === opts.repeat) {
  29. var repeatStart = "*" === opts.repeat ? 0 : "+" === opts.repeat ? 1 : opts.repeat;
  30. mask = opts.groupmarker.start + mask + opts.groupmarker.end + opts.quantifiermarker.start + repeatStart + "," + opts.repeat + opts.quantifiermarker.end;
  31. }
  32. var masksetDefinition;
  33. return Inputmask.prototype.masksCache[mask] === undefined || !0 === nocache ? (masksetDefinition = {
  34. mask: mask,
  35. maskToken: Inputmask.prototype.analyseMask(mask, regexMask, opts),
  36. validPositions: {},
  37. _buffer: undefined,
  38. buffer: undefined,
  39. tests: {},
  40. metadata: metadata,
  41. maskLength: undefined
  42. }, !0 !== nocache && (Inputmask.prototype.masksCache[opts.numericInput ? mask.split("").reverse().join("") : mask] = masksetDefinition,
  43. masksetDefinition = $.extend(!0, {}, Inputmask.prototype.masksCache[opts.numericInput ? mask.split("").reverse().join("") : mask]))) : masksetDefinition = $.extend(!0, {}, Inputmask.prototype.masksCache[opts.numericInput ? mask.split("").reverse().join("") : mask]),
  44. masksetDefinition;
  45. }
  46. if ($.isFunction(opts.mask) && (opts.mask = opts.mask(opts)), $.isArray(opts.mask)) {
  47. if (opts.mask.length > 1) {
  48. opts.keepStatic = null === opts.keepStatic || opts.keepStatic;
  49. var altMask = opts.groupmarker.start;
  50. return $.each(opts.numericInput ? opts.mask.reverse() : opts.mask, function(ndx, msk) {
  51. altMask.length > 1 && (altMask += opts.groupmarker.end + opts.alternatormarker + opts.groupmarker.start),
  52. msk.mask === undefined || $.isFunction(msk.mask) ? altMask += msk : altMask += msk.mask;
  53. }), altMask += opts.groupmarker.end, generateMask(altMask, opts.mask, opts);
  54. }
  55. opts.mask = opts.mask.pop();
  56. }
  57. return opts.mask && opts.mask.mask !== undefined && !$.isFunction(opts.mask.mask) ? generateMask(opts.mask.mask, opts.mask, opts) : generateMask(opts.mask, opts.mask, opts);
  58. }
  59. function maskScope(actionObj, maskset, opts) {
  60. function getMaskTemplate(baseOnInput, minimalPos, includeMode) {
  61. minimalPos = minimalPos || 0;
  62. var ndxIntlzr, test, testPos, maskTemplate = [], pos = 0, lvp = getLastValidPosition();
  63. -1 === (maxLength = el !== undefined ? el.maxLength : undefined) && (maxLength = undefined);
  64. do {
  65. !0 === baseOnInput && getMaskSet().validPositions[pos] ? (testPos = getMaskSet().validPositions[pos],
  66. test = testPos.match, ndxIntlzr = testPos.locator.slice(), maskTemplate.push(!0 === includeMode ? testPos.input : !1 === includeMode ? test.nativeDef : getPlaceholder(pos, test))) : (testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
  67. test = testPos.match, ndxIntlzr = testPos.locator.slice(), (!1 === opts.jitMasking || pos < lvp || "number" == typeof opts.jitMasking && isFinite(opts.jitMasking) && opts.jitMasking > pos) && maskTemplate.push(!1 === includeMode ? test.nativeDef : getPlaceholder(pos, test))),
  68. pos++;
  69. } while ((maxLength === undefined || pos < maxLength) && (null !== test.fn || "" !== test.def) || minimalPos > pos);
  70. return "" === maskTemplate[maskTemplate.length - 1] && maskTemplate.pop(), getMaskSet().maskLength = pos + 1,
  71. maskTemplate;
  72. }
  73. function getMaskSet() {
  74. return maskset;
  75. }
  76. function resetMaskSet(soft) {
  77. var maskset = getMaskSet();
  78. maskset.buffer = undefined, !0 !== soft && (maskset.validPositions = {}, maskset.p = 0);
  79. }
  80. function getLastValidPosition(closestTo, strict, validPositions) {
  81. var before = -1, after = -1, valids = validPositions || getMaskSet().validPositions;
  82. closestTo === undefined && (closestTo = -1);
  83. for (var posNdx in valids) {
  84. var psNdx = parseInt(posNdx);
  85. valids[psNdx] && (strict || !0 !== valids[psNdx].generatedInput) && (psNdx <= closestTo && (before = psNdx),
  86. psNdx >= closestTo && (after = psNdx));
  87. }
  88. return -1 !== before && closestTo - before > 1 || after < closestTo ? before : after;
  89. }
  90. function stripValidPositions(start, end, nocheck, strict) {
  91. var i, startPos = start, positionsClone = $.extend(!0, {}, getMaskSet().validPositions), needsValidation = !1;
  92. for (getMaskSet().p = start, i = end - 1; i >= startPos; i--) getMaskSet().validPositions[i] !== undefined && (!0 !== nocheck && (!getMaskSet().validPositions[i].match.optionality && function(pos) {
  93. var posMatch = getMaskSet().validPositions[pos];
  94. if (posMatch !== undefined && null === posMatch.match.fn) {
  95. var prevMatch = getMaskSet().validPositions[pos - 1], nextMatch = getMaskSet().validPositions[pos + 1];
  96. return prevMatch !== undefined && nextMatch !== undefined;
  97. }
  98. return !1;
  99. }(i) || !1 === opts.canClearPosition(getMaskSet(), i, getLastValidPosition(), strict, opts)) || delete getMaskSet().validPositions[i]);
  100. for (resetMaskSet(!0), i = startPos + 1; i <= getLastValidPosition(); ) {
  101. for (;getMaskSet().validPositions[startPos] !== undefined; ) startPos++;
  102. if (i < startPos && (i = startPos + 1), getMaskSet().validPositions[i] === undefined && isMask(i)) i++; else {
  103. var t = getTestTemplate(i);
  104. !1 === needsValidation && positionsClone[startPos] && positionsClone[startPos].match.def === t.match.def ? (getMaskSet().validPositions[startPos] = $.extend(!0, {}, positionsClone[startPos]),
  105. getMaskSet().validPositions[startPos].input = t.input, delete getMaskSet().validPositions[i],
  106. i++) : positionCanMatchDefinition(startPos, t.match.def) ? !1 !== isValid(startPos, t.input || getPlaceholder(i), !0) && (delete getMaskSet().validPositions[i],
  107. i++, needsValidation = !0) : isMask(i) || (i++, startPos--), startPos++;
  108. }
  109. }
  110. resetMaskSet(!0);
  111. }
  112. function determineTestTemplate(tests, guessNextBest) {
  113. for (var testPos, testPositions = tests, lvp = getLastValidPosition(), lvTest = getMaskSet().validPositions[lvp] || getTests(0)[0], lvTestAltArr = lvTest.alternation !== undefined ? lvTest.locator[lvTest.alternation].toString().split(",") : [], ndx = 0; ndx < testPositions.length && (testPos = testPositions[ndx],
  114. !(testPos.match && (opts.greedy && !0 !== testPos.match.optionalQuantifier || (!1 === testPos.match.optionality || !1 === testPos.match.newBlockMarker) && !0 !== testPos.match.optionalQuantifier) && (lvTest.alternation === undefined || lvTest.alternation !== testPos.alternation || testPos.locator[lvTest.alternation] !== undefined && checkAlternationMatch(testPos.locator[lvTest.alternation].toString().split(","), lvTestAltArr))) || !0 === guessNextBest && (null !== testPos.match.fn || /[0-9a-bA-Z]/.test(testPos.match.def))); ndx++) ;
  115. return testPos;
  116. }
  117. function getTestTemplate(pos, ndxIntlzr, tstPs) {
  118. return getMaskSet().validPositions[pos] || determineTestTemplate(getTests(pos, ndxIntlzr ? ndxIntlzr.slice() : ndxIntlzr, tstPs));
  119. }
  120. function getTest(pos) {
  121. return getMaskSet().validPositions[pos] ? getMaskSet().validPositions[pos] : getTests(pos)[0];
  122. }
  123. function positionCanMatchDefinition(pos, def) {
  124. for (var valid = !1, tests = getTests(pos), tndx = 0; tndx < tests.length; tndx++) if (tests[tndx].match && tests[tndx].match.def === def) {
  125. valid = !0;
  126. break;
  127. }
  128. return valid;
  129. }
  130. function getTests(pos, ndxIntlzr, tstPs) {
  131. function resolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) {
  132. function handleMatch(match, loopNdx, quantifierRecurse) {
  133. function isFirstMatch(latestMatch, tokenGroup) {
  134. var firstMatch = 0 === $.inArray(latestMatch, tokenGroup.matches);
  135. return firstMatch || $.each(tokenGroup.matches, function(ndx, match) {
  136. if (!0 === match.isQuantifier && (firstMatch = isFirstMatch(latestMatch, tokenGroup.matches[ndx - 1]))) return !1;
  137. }), firstMatch;
  138. }
  139. function resolveNdxInitializer(pos, alternateNdx, targetAlternation) {
  140. var bestMatch, indexPos;
  141. return (getMaskSet().tests[pos] || getMaskSet().validPositions[pos]) && $.each(getMaskSet().tests[pos] || [ getMaskSet().validPositions[pos] ], function(ndx, lmnt) {
  142. var alternation = targetAlternation !== undefined ? targetAlternation : lmnt.alternation, ndxPos = lmnt.locator[alternation] !== undefined ? lmnt.locator[alternation].toString().indexOf(alternateNdx) : -1;
  143. (indexPos === undefined || ndxPos < indexPos) && -1 !== ndxPos && (bestMatch = lmnt,
  144. indexPos = ndxPos);
  145. }), bestMatch ? bestMatch.locator.slice((targetAlternation !== undefined ? targetAlternation : bestMatch.alternation) + 1) : targetAlternation !== undefined ? resolveNdxInitializer(pos, alternateNdx) : undefined;
  146. }
  147. if (testPos > 1e4) throw "Inputmask: There is probably an error in your mask definition or in the code. Create an issue on github with an example of the mask you are using. " + getMaskSet().mask;
  148. if (testPos === pos && match.matches === undefined) return matches.push({
  149. match: match,
  150. locator: loopNdx.reverse(),
  151. cd: cacheDependency
  152. }), !0;
  153. if (match.matches !== undefined) {
  154. if (match.isGroup && quantifierRecurse !== match) {
  155. if (match = handleMatch(maskToken.matches[$.inArray(match, maskToken.matches) + 1], loopNdx)) return !0;
  156. } else if (match.isOptional) {
  157. var optionalToken = match;
  158. if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) {
  159. if (latestMatch = matches[matches.length - 1].match, !isFirstMatch(latestMatch, optionalToken)) return !0;
  160. insertStop = !0, testPos = pos;
  161. }
  162. } else if (match.isAlternator) {
  163. var maltMatches, alternateToken = match, malternateMatches = [], currentMatches = matches.slice(), loopNdxCnt = loopNdx.length, altIndex = ndxInitializer.length > 0 ? ndxInitializer.shift() : -1;
  164. if (-1 === altIndex || "string" == typeof altIndex) {
  165. var amndx, currentPos = testPos, ndxInitializerClone = ndxInitializer.slice(), altIndexArr = [];
  166. if ("string" == typeof altIndex) altIndexArr = altIndex.split(","); else for (amndx = 0; amndx < alternateToken.matches.length; amndx++) altIndexArr.push(amndx);
  167. for (var ndx = 0; ndx < altIndexArr.length; ndx++) {
  168. if (amndx = parseInt(altIndexArr[ndx]), matches = [], ndxInitializer = resolveNdxInitializer(testPos, amndx, loopNdxCnt) || ndxInitializerClone.slice(),
  169. !0 !== (match = handleMatch(alternateToken.matches[amndx] || maskToken.matches[amndx], [ amndx ].concat(loopNdx), quantifierRecurse) || match) && match !== undefined && altIndexArr[altIndexArr.length - 1] < alternateToken.matches.length) {
  170. var ntndx = $.inArray(match, maskToken.matches) + 1;
  171. maskToken.matches.length > ntndx && (match = handleMatch(maskToken.matches[ntndx], [ ntndx ].concat(loopNdx.slice(1, loopNdx.length)), quantifierRecurse)) && (altIndexArr.push(ntndx.toString()),
  172. $.each(matches, function(ndx, lmnt) {
  173. lmnt.alternation = loopNdx.length - 1;
  174. }));
  175. }
  176. maltMatches = matches.slice(), testPos = currentPos, matches = [];
  177. for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) {
  178. var altMatch = maltMatches[ndx1], dropMatch = !1;
  179. altMatch.alternation = altMatch.alternation || loopNdxCnt;
  180. for (var ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) {
  181. var altMatch2 = malternateMatches[ndx2];
  182. if ("string" != typeof altIndex || -1 !== $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr)) {
  183. if (altMatch.match.nativeDef === altMatch2.match.nativeDef || altMatch.match.def === altMatch2.match.nativeDef || altMatch.match.nativeDef === altMatch2.match.def) {
  184. dropMatch = !0, altMatch.alternation == altMatch2.alternation && -1 === altMatch2.locator[altMatch2.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) && (altMatch2.locator[altMatch2.alternation] = altMatch2.locator[altMatch2.alternation] + "," + altMatch.locator[altMatch.alternation],
  185. altMatch2.alternation = altMatch.alternation), altMatch.match.nativeDef === altMatch2.match.def && (altMatch.locator[altMatch.alternation] = altMatch2.locator[altMatch2.alternation],
  186. malternateMatches.splice(malternateMatches.indexOf(altMatch2), 1, altMatch));
  187. break;
  188. }
  189. if (altMatch.match.def === altMatch2.match.def) {
  190. dropMatch = !1;
  191. break;
  192. }
  193. if (function(source, target) {
  194. return null === source.match.fn && null !== target.match.fn && target.match.fn.test(source.match.def, getMaskSet(), pos, !1, opts, !1);
  195. }(altMatch, altMatch2)) {
  196. altMatch.alternation == altMatch2.alternation && -1 === altMatch.locator[altMatch.alternation].toString().indexOf(altMatch2.locator[altMatch2.alternation].toString().split("")[0]) && (altMatch.na = altMatch.na || altMatch.locator[altMatch.alternation].toString(),
  197. -1 === altMatch.na.indexOf(altMatch.locator[altMatch.alternation].toString().split("")[0]) && (altMatch.na = altMatch.na + "," + altMatch.locator[altMatch2.alternation].toString().split("")[0]),
  198. dropMatch = !0, altMatch.locator[altMatch.alternation] = altMatch2.locator[altMatch2.alternation].toString().split("")[0] + "," + altMatch.locator[altMatch.alternation],
  199. malternateMatches.splice(malternateMatches.indexOf(altMatch2), 0, altMatch));
  200. break;
  201. }
  202. }
  203. }
  204. dropMatch || malternateMatches.push(altMatch);
  205. }
  206. }
  207. "string" == typeof altIndex && (malternateMatches = $.map(malternateMatches, function(lmnt, ndx) {
  208. if (isFinite(ndx)) {
  209. var alternation = lmnt.alternation, altLocArr = lmnt.locator[alternation].toString().split(",");
  210. lmnt.locator[alternation] = undefined, lmnt.alternation = undefined;
  211. for (var alndx = 0; alndx < altLocArr.length; alndx++) -1 !== $.inArray(altLocArr[alndx], altIndexArr) && (lmnt.locator[alternation] !== undefined ? (lmnt.locator[alternation] += ",",
  212. lmnt.locator[alternation] += altLocArr[alndx]) : lmnt.locator[alternation] = parseInt(altLocArr[alndx]),
  213. lmnt.alternation = alternation);
  214. if (lmnt.locator[alternation] !== undefined) return lmnt;
  215. }
  216. })), matches = currentMatches.concat(malternateMatches), testPos = pos, insertStop = matches.length > 0,
  217. ndxInitializer = ndxInitializerClone.slice();
  218. } else match = handleMatch(alternateToken.matches[altIndex] || maskToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse);
  219. if (match) return !0;
  220. } else if (match.isQuantifier && quantifierRecurse !== maskToken.matches[$.inArray(match, maskToken.matches) - 1]) for (var qt = match, qndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max) && testPos <= pos; qndx++) {
  221. var tokenGroup = maskToken.matches[$.inArray(qt, maskToken.matches) - 1];
  222. if (match = handleMatch(tokenGroup, [ qndx ].concat(loopNdx), tokenGroup)) {
  223. if (latestMatch = matches[matches.length - 1].match, latestMatch.optionalQuantifier = qndx > qt.quantifier.min - 1,
  224. isFirstMatch(latestMatch, tokenGroup)) {
  225. if (qndx > qt.quantifier.min - 1) {
  226. insertStop = !0, testPos = pos;
  227. break;
  228. }
  229. return !0;
  230. }
  231. return !0;
  232. }
  233. } else if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) return !0;
  234. } else testPos++;
  235. }
  236. for (var tndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; tndx < maskToken.matches.length; tndx++) if (!0 !== maskToken.matches[tndx].isQuantifier) {
  237. var match = handleMatch(maskToken.matches[tndx], [ tndx ].concat(loopNdx), quantifierRecurse);
  238. if (match && testPos === pos) return match;
  239. if (testPos > pos) break;
  240. }
  241. }
  242. function filterTests(tests) {
  243. return opts.keepStatic && pos > 0 && tests.length > 1 + ("" === tests[tests.length - 1].match.def ? 1 : 0) && !0 !== tests[0].match.optionality && !0 !== tests[0].match.optionalQuantifier && null === tests[0].match.fn && !/[0-9a-bA-Z]/.test(tests[0].match.def) ? [ determineTestTemplate(tests) ] : tests;
  244. }
  245. var latestMatch, maskTokens = getMaskSet().maskToken, testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr ? ndxIntlzr.slice() : [ 0 ], matches = [], insertStop = !1, cacheDependency = ndxIntlzr ? ndxIntlzr.join("") : "";
  246. if (pos > -1) {
  247. if (ndxIntlzr === undefined) {
  248. for (var test, previousPos = pos - 1; (test = getMaskSet().validPositions[previousPos] || getMaskSet().tests[previousPos]) === undefined && previousPos > -1; ) previousPos--;
  249. test !== undefined && previousPos > -1 && (ndxInitializer = function(tests) {
  250. var locator = [];
  251. return $.isArray(tests) || (tests = [ tests ]), tests.length > 0 && (tests[0].alternation === undefined ? (locator = determineTestTemplate(tests.slice()).locator.slice(),
  252. 0 === locator.length && (locator = tests[0].locator.slice())) : $.each(tests, function(ndx, tst) {
  253. if ("" !== tst.def) if (0 === locator.length) locator = tst.locator.slice(); else for (var i = 0; i < locator.length; i++) tst.locator[i] && -1 === locator[i].toString().indexOf(tst.locator[i]) && (locator[i] += "," + tst.locator[i]);
  254. })), locator;
  255. }(test), cacheDependency = ndxInitializer.join(""), testPos = previousPos);
  256. }
  257. if (getMaskSet().tests[pos] && getMaskSet().tests[pos][0].cd === cacheDependency) return filterTests(getMaskSet().tests[pos]);
  258. for (var mtndx = ndxInitializer.shift(); mtndx < maskTokens.length; mtndx++) {
  259. if (resolveTestFromToken(maskTokens[mtndx], ndxInitializer, [ mtndx ]) && testPos === pos || testPos > pos) break;
  260. }
  261. }
  262. return (0 === matches.length || insertStop) && matches.push({
  263. match: {
  264. fn: null,
  265. cardinality: 0,
  266. optionality: !0,
  267. casing: null,
  268. def: "",
  269. placeholder: ""
  270. },
  271. locator: [],
  272. cd: cacheDependency
  273. }), ndxIntlzr !== undefined && getMaskSet().tests[pos] ? filterTests($.extend(!0, [], matches)) : (getMaskSet().tests[pos] = $.extend(!0, [], matches),
  274. filterTests(getMaskSet().tests[pos]));
  275. }
  276. function getBufferTemplate() {
  277. return getMaskSet()._buffer === undefined && (getMaskSet()._buffer = getMaskTemplate(!1, 1),
  278. getMaskSet().buffer === undefined && (getMaskSet().buffer = getMaskSet()._buffer.slice())),
  279. getMaskSet()._buffer;
  280. }
  281. function getBuffer(noCache) {
  282. return getMaskSet().buffer !== undefined && !0 !== noCache || (getMaskSet().buffer = getMaskTemplate(!0, getLastValidPosition(), !0)),
  283. getMaskSet().buffer;
  284. }
  285. function refreshFromBuffer(start, end, buffer) {
  286. var i, p;
  287. if (!0 === start) resetMaskSet(), start = 0, end = buffer.length; else for (i = start; i < end; i++) delete getMaskSet().validPositions[i];
  288. for (p = start, i = start; i < end; i++) if (resetMaskSet(!0), buffer[i] !== opts.skipOptionalPartCharacter) {
  289. var valResult = isValid(p, buffer[i], !0, !0);
  290. !1 !== valResult && (resetMaskSet(!0), p = valResult.caret !== undefined ? valResult.caret : valResult.pos + 1);
  291. }
  292. }
  293. function casing(elem, test, pos) {
  294. switch (opts.casing || test.casing) {
  295. case "upper":
  296. elem = elem.toUpperCase();
  297. break;
  298. case "lower":
  299. elem = elem.toLowerCase();
  300. break;
  301. case "title":
  302. var posBefore = getMaskSet().validPositions[pos - 1];
  303. elem = 0 === pos || posBefore && posBefore.input === String.fromCharCode(Inputmask.keyCode.SPACE) ? elem.toUpperCase() : elem.toLowerCase();
  304. }
  305. return elem;
  306. }
  307. function checkAlternationMatch(altArr1, altArr2, na) {
  308. for (var naNdx, altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1), isMatch = !1, naArr = na !== undefined ? na.split(",") : [], i = 0; i < naArr.length; i++) -1 !== (naNdx = altArr1.indexOf(naArr[i])) && altArr1.splice(naNdx, 1);
  309. for (var alndx = 0; alndx < altArr1.length; alndx++) if (-1 !== $.inArray(altArr1[alndx], altArrC)) {
  310. isMatch = !0;
  311. break;
  312. }
  313. return isMatch;
  314. }
  315. function isValid(pos, c, strict, fromSetValid, fromAlternate) {
  316. function isSelection(posObj) {
  317. var selection = isRTL ? posObj.begin - posObj.end > 1 || posObj.begin - posObj.end == 1 : posObj.end - posObj.begin > 1 || posObj.end - posObj.begin == 1;
  318. return selection && 0 === posObj.begin && posObj.end === getMaskSet().maskLength ? "full" : selection;
  319. }
  320. function _isValid(position, c, strict) {
  321. var rslt = !1;
  322. return $.each(getTests(position), function(ndx, tst) {
  323. for (var test = tst.match, loopend = c ? 1 : 0, chrs = "", i = test.cardinality; i > loopend; i--) chrs += getBufferElement(position - (i - 1));
  324. if (c && (chrs += c), getBuffer(!0), !1 !== (rslt = null != test.fn ? test.fn.test(chrs, getMaskSet(), position, strict, opts, isSelection(pos)) : (c === test.def || c === opts.skipOptionalPartCharacter) && "" !== test.def && {
  325. c: getPlaceholder(position, test, !0) || test.def,
  326. pos: position
  327. })) {
  328. var elem = rslt.c !== undefined ? rslt.c : c;
  329. elem = elem === opts.skipOptionalPartCharacter && null === test.fn ? getPlaceholder(position, test, !0) || test.def : elem;
  330. var validatedPos = position, possibleModifiedBuffer = getBuffer();
  331. if (rslt.remove !== undefined && ($.isArray(rslt.remove) || (rslt.remove = [ rslt.remove ]),
  332. $.each(rslt.remove.sort(function(a, b) {
  333. return b - a;
  334. }), function(ndx, lmnt) {
  335. stripValidPositions(lmnt, lmnt + 1, !0);
  336. })), rslt.insert !== undefined && ($.isArray(rslt.insert) || (rslt.insert = [ rslt.insert ]),
  337. $.each(rslt.insert.sort(function(a, b) {
  338. return a - b;
  339. }), function(ndx, lmnt) {
  340. isValid(lmnt.pos, lmnt.c, !0, fromSetValid);
  341. })), rslt.refreshFromBuffer) {
  342. var refresh = rslt.refreshFromBuffer;
  343. if (refreshFromBuffer(!0 === refresh ? refresh : refresh.start, refresh.end, possibleModifiedBuffer),
  344. rslt.pos === undefined && rslt.c === undefined) return rslt.pos = getLastValidPosition(),
  345. !1;
  346. if ((validatedPos = rslt.pos !== undefined ? rslt.pos : position) !== position) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0, fromSetValid)),
  347. !1;
  348. } else if (!0 !== rslt && rslt.pos !== undefined && rslt.pos !== position && (validatedPos = rslt.pos,
  349. refreshFromBuffer(position, validatedPos, getBuffer().slice()), validatedPos !== position)) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0)),
  350. !1;
  351. return (!0 === rslt || rslt.pos !== undefined || rslt.c !== undefined) && (ndx > 0 && resetMaskSet(!0),
  352. setValidPosition(validatedPos, $.extend({}, tst, {
  353. input: casing(elem, test, validatedPos)
  354. }), fromSetValid, isSelection(pos)) || (rslt = !1), !1);
  355. }
  356. }), rslt;
  357. }
  358. function setValidPosition(pos, validTest, fromSetValid, isSelection) {
  359. if (isSelection || opts.insertMode && getMaskSet().validPositions[pos] !== undefined && fromSetValid === undefined) {
  360. var i, positionsClone = $.extend(!0, {}, getMaskSet().validPositions), lvp = getLastValidPosition(undefined, !0);
  361. for (i = pos; i <= lvp; i++) delete getMaskSet().validPositions[i];
  362. getMaskSet().validPositions[pos] = $.extend(!0, {}, validTest);
  363. var j, valid = !0, vps = getMaskSet().validPositions, needsValidation = !1, initialLength = getMaskSet().maskLength;
  364. for (i = j = pos; i <= lvp; i++) {
  365. var t = positionsClone[i];
  366. if (t !== undefined) for (var posMatch = j; posMatch < getMaskSet().maskLength && (null === t.match.fn && vps[i] && (!0 === vps[i].match.optionalQuantifier || !0 === vps[i].match.optionality) || null != t.match.fn); ) {
  367. if (posMatch++, !1 === needsValidation && positionsClone[posMatch] && positionsClone[posMatch].match.def === t.match.def) getMaskSet().validPositions[posMatch] = $.extend(!0, {}, positionsClone[posMatch]),
  368. getMaskSet().validPositions[posMatch].input = t.input, fillMissingNonMask(posMatch),
  369. j = posMatch, valid = !0; else if (positionCanMatchDefinition(posMatch, t.match.def)) {
  370. var result = isValid(posMatch, t.input, !0, !0);
  371. valid = !1 !== result, j = result.caret || result.insert ? getLastValidPosition() : posMatch,
  372. needsValidation = !0;
  373. } else if (!(valid = !0 === t.generatedInput) && posMatch >= getMaskSet().maskLength - 1) break;
  374. if (getMaskSet().maskLength < initialLength && (getMaskSet().maskLength = initialLength),
  375. valid) break;
  376. }
  377. if (!valid) break;
  378. }
  379. if (!valid) return getMaskSet().validPositions = $.extend(!0, {}, positionsClone),
  380. resetMaskSet(!0), !1;
  381. } else getMaskSet().validPositions[pos] = $.extend(!0, {}, validTest);
  382. return resetMaskSet(!0), !0;
  383. }
  384. function fillMissingNonMask(maskPos) {
  385. for (var pndx = maskPos - 1; pndx > -1 && !getMaskSet().validPositions[pndx]; pndx--) ;
  386. var testTemplate, testsFromPos;
  387. for (pndx++; pndx < maskPos; pndx++) getMaskSet().validPositions[pndx] === undefined && (!1 === opts.jitMasking || opts.jitMasking > pndx) && (testsFromPos = getTests(pndx, getTestTemplate(pndx - 1).locator, pndx - 1).slice(),
  388. "" === testsFromPos[testsFromPos.length - 1].match.def && testsFromPos.pop(), (testTemplate = determineTestTemplate(testsFromPos)) && (testTemplate.match.def === opts.radixPointDefinitionSymbol || !isMask(pndx, !0) || $.inArray(opts.radixPoint, getBuffer()) < pndx && testTemplate.match.fn && testTemplate.match.fn.test(getPlaceholder(pndx), getMaskSet(), pndx, !1, opts)) && !1 !== (result = _isValid(pndx, getPlaceholder(pndx, testTemplate.match, !0) || (null == testTemplate.match.fn ? testTemplate.match.def : "" !== getPlaceholder(pndx) ? getPlaceholder(pndx) : getBuffer()[pndx]), !0)) && (getMaskSet().validPositions[result.pos || pndx].generatedInput = !0));
  389. }
  390. strict = !0 === strict;
  391. var maskPos = pos;
  392. pos.begin !== undefined && (maskPos = isRTL && !isSelection(pos) ? pos.end : pos.begin);
  393. var result = !0, positionsClone = $.extend(!0, {}, getMaskSet().validPositions);
  394. if ($.isFunction(opts.preValidation) && !strict && !0 !== fromSetValid && (result = opts.preValidation(getBuffer(), maskPos, c, isSelection(pos), opts)),
  395. !0 === result) {
  396. if (fillMissingNonMask(maskPos), isSelection(pos) && (handleRemove(undefined, Inputmask.keyCode.DELETE, pos),
  397. maskPos = getMaskSet().p), maskPos < getMaskSet().maskLength && (result = _isValid(maskPos, c, strict),
  398. (!strict || !0 === fromSetValid) && !1 === result)) {
  399. var currentPosValid = getMaskSet().validPositions[maskPos];
  400. if (!currentPosValid || null !== currentPosValid.match.fn || currentPosValid.match.def !== c && c !== opts.skipOptionalPartCharacter) {
  401. if ((opts.insertMode || getMaskSet().validPositions[seekNext(maskPos)] === undefined) && !isMask(maskPos, !0)) for (var nPos = maskPos + 1, snPos = seekNext(maskPos); nPos <= snPos; nPos++) if (!1 !== (result = _isValid(nPos, c, strict))) {
  402. !function(originalPos, newPos) {
  403. var vp = getMaskSet().validPositions[newPos];
  404. if (vp) for (var targetLocator = vp.locator, tll = targetLocator.length, ps = originalPos; ps < newPos; ps++) if (getMaskSet().validPositions[ps] === undefined && !isMask(ps, !0)) {
  405. var tests = getTests(ps).slice(), bestMatch = determineTestTemplate(tests, !0), equality = -1;
  406. "" === tests[tests.length - 1].match.def && tests.pop(), $.each(tests, function(ndx, tst) {
  407. for (var i = 0; i < tll; i++) {
  408. if (tst.locator[i] === undefined || !checkAlternationMatch(tst.locator[i].toString().split(","), targetLocator[i].toString().split(","), tst.na)) {
  409. var targetAI = targetLocator[i], bestMatchAI = bestMatch.locator[i], tstAI = tst.locator[i];
  410. targetAI - bestMatchAI > Math.abs(targetAI - tstAI) && (bestMatch = tst);
  411. break;
  412. }
  413. equality < i && (equality = i, bestMatch = tst);
  414. }
  415. }), bestMatch = $.extend({}, bestMatch, {
  416. input: getPlaceholder(ps, bestMatch.match, !0) || bestMatch.match.def
  417. }), bestMatch.generatedInput = !0, setValidPosition(ps, bestMatch, !0), getMaskSet().validPositions[newPos] = undefined,
  418. _isValid(newPos, vp.input, !0);
  419. }
  420. }(maskPos, result.pos !== undefined ? result.pos : nPos), maskPos = nPos;
  421. break;
  422. }
  423. } else result = {
  424. caret: seekNext(maskPos)
  425. };
  426. }
  427. !1 === result && opts.keepStatic && !strict && !0 !== fromAlternate && (result = function(pos, c, strict) {
  428. var lastAlt, alternation, altPos, prevAltPos, i, validPos, altNdxs, decisionPos, validPsClone = $.extend(!0, {}, getMaskSet().validPositions), isValidRslt = !1, lAltPos = getLastValidPosition();
  429. for (prevAltPos = getMaskSet().validPositions[lAltPos]; lAltPos >= 0; lAltPos--) if ((altPos = getMaskSet().validPositions[lAltPos]) && altPos.alternation !== undefined) {
  430. if (lastAlt = lAltPos, alternation = getMaskSet().validPositions[lastAlt].alternation,
  431. prevAltPos.locator[altPos.alternation] !== altPos.locator[altPos.alternation]) break;
  432. prevAltPos = altPos;
  433. }
  434. if (alternation !== undefined) {
  435. decisionPos = parseInt(lastAlt);
  436. var decisionTaker = prevAltPos.locator[prevAltPos.alternation || alternation] !== undefined ? prevAltPos.locator[prevAltPos.alternation || alternation] : altNdxs[0];
  437. decisionTaker.length > 0 && (decisionTaker = decisionTaker.split(",")[0]);
  438. var possibilityPos = getMaskSet().validPositions[decisionPos], prevPos = getMaskSet().validPositions[decisionPos - 1];
  439. $.each(getTests(decisionPos, prevPos ? prevPos.locator : undefined, decisionPos - 1), function(ndx, test) {
  440. altNdxs = test.locator[alternation] ? test.locator[alternation].toString().split(",") : [];
  441. for (var mndx = 0; mndx < altNdxs.length; mndx++) {
  442. var validInputs = [], staticInputsBeforePos = 0, staticInputsBeforePosAlternate = 0, verifyValidInput = !1;
  443. if (decisionTaker < altNdxs[mndx] && (test.na === undefined || -1 === $.inArray(altNdxs[mndx], test.na.split(",")) || -1 === $.inArray(decisionTaker.toString(), altNdxs))) {
  444. getMaskSet().validPositions[decisionPos] = $.extend(!0, {}, test);
  445. var possibilities = getMaskSet().validPositions[decisionPos].locator;
  446. for (getMaskSet().validPositions[decisionPos].locator[alternation] = parseInt(altNdxs[mndx]),
  447. null == test.match.fn ? (possibilityPos.input !== test.match.def && (verifyValidInput = !0,
  448. !0 !== possibilityPos.generatedInput && validInputs.push(possibilityPos.input)),
  449. staticInputsBeforePosAlternate++, getMaskSet().validPositions[decisionPos].generatedInput = !/[0-9a-bA-Z]/.test(test.match.def),
  450. getMaskSet().validPositions[decisionPos].input = test.match.def) : getMaskSet().validPositions[decisionPos].input = possibilityPos.input,
  451. i = decisionPos + 1; i < getLastValidPosition(undefined, !0) + 1; i++) validPos = getMaskSet().validPositions[i],
  452. validPos && !0 !== validPos.generatedInput && /[0-9a-bA-Z]/.test(validPos.input) ? validInputs.push(validPos.input) : i < pos && staticInputsBeforePos++,
  453. delete getMaskSet().validPositions[i];
  454. for (verifyValidInput && validInputs[0] === test.match.def && validInputs.shift(),
  455. resetMaskSet(!0), isValidRslt = !0; validInputs.length > 0; ) {
  456. var input = validInputs.shift();
  457. if (input !== opts.skipOptionalPartCharacter && !(isValidRslt = isValid(getLastValidPosition(undefined, !0) + 1, input, !1, fromSetValid, !0))) break;
  458. }
  459. if (isValidRslt) {
  460. getMaskSet().validPositions[decisionPos].locator = possibilities;
  461. var targetLvp = getLastValidPosition(pos) + 1;
  462. for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) ((validPos = getMaskSet().validPositions[i]) === undefined || null == validPos.match.fn) && i < pos + (staticInputsBeforePosAlternate - staticInputsBeforePos) && staticInputsBeforePosAlternate++;
  463. pos += staticInputsBeforePosAlternate - staticInputsBeforePos, isValidRslt = isValid(pos > targetLvp ? targetLvp : pos, c, strict, fromSetValid, !0);
  464. }
  465. if (isValidRslt) return !1;
  466. resetMaskSet(), getMaskSet().validPositions = $.extend(!0, {}, validPsClone);
  467. }
  468. }
  469. });
  470. }
  471. return isValidRslt;
  472. }(maskPos, c, strict)), !0 === result && (result = {
  473. pos: maskPos
  474. });
  475. }
  476. if ($.isFunction(opts.postValidation) && !1 !== result && !strict && !0 !== fromSetValid) {
  477. var postResult = opts.postValidation(getBuffer(!0), result, opts);
  478. if (postResult.refreshFromBuffer && postResult.buffer) {
  479. var refresh = postResult.refreshFromBuffer;
  480. refreshFromBuffer(!0 === refresh ? refresh : refresh.start, refresh.end, postResult.buffer);
  481. }
  482. result = !0 === postResult ? result : postResult;
  483. }
  484. return result.pos === undefined && (result.pos = maskPos), !1 === result && (resetMaskSet(!0),
  485. getMaskSet().validPositions = $.extend(!0, {}, positionsClone)), result;
  486. }
  487. function isMask(pos, strict) {
  488. var test = getTestTemplate(pos).match;
  489. if ("" === test.def && (test = getTest(pos).match), null != test.fn) return test.fn;
  490. if (!0 !== strict && pos > -1) {
  491. var tests = getTests(pos);
  492. return tests.length > 1 + ("" === tests[tests.length - 1].match.def ? 1 : 0);
  493. }
  494. return !1;
  495. }
  496. function seekNext(pos, newBlock) {
  497. var maskL = getMaskSet().maskLength;
  498. if (pos >= maskL) return maskL;
  499. for (var position = pos; ++position < maskL && (!0 === newBlock && (!0 !== getTest(position).match.newBlockMarker || !isMask(position)) || !0 !== newBlock && !isMask(position)); ) ;
  500. return position;
  501. }
  502. function seekPrevious(pos, newBlock) {
  503. var tests, position = pos;
  504. if (position <= 0) return 0;
  505. for (;--position > 0 && (!0 === newBlock && !0 !== getTest(position).match.newBlockMarker || !0 !== newBlock && !isMask(position) && (tests = getTests(position),
  506. tests.length < 2 || 2 === tests.length && "" === tests[1].match.def)); ) ;
  507. return position;
  508. }
  509. function getBufferElement(position) {
  510. return getMaskSet().validPositions[position] === undefined ? getPlaceholder(position) : getMaskSet().validPositions[position].input;
  511. }
  512. function writeBuffer(input, buffer, caretPos, event, triggerInputEvent) {
  513. if (event && $.isFunction(opts.onBeforeWrite)) {
  514. var result = opts.onBeforeWrite(event, buffer, caretPos, opts);
  515. if (result) {
  516. if (result.refreshFromBuffer) {
  517. var refresh = result.refreshFromBuffer;
  518. refreshFromBuffer(!0 === refresh ? refresh : refresh.start, refresh.end, result.buffer || buffer),
  519. buffer = getBuffer(!0);
  520. }
  521. caretPos !== undefined && (caretPos = result.caret !== undefined ? result.caret : caretPos);
  522. }
  523. }
  524. input !== undefined && (input.inputmask._valueSet(buffer.join("")), caretPos === undefined || event !== undefined && "blur" === event.type ? renderColorMask(input, buffer, caretPos) : android && "input" === event.type ? setTimeout(function() {
  525. caret(input, caretPos);
  526. }, 0) : caret(input, caretPos), !0 === triggerInputEvent && (skipInputEvent = !0,
  527. $(input).trigger("input")));
  528. }
  529. function getPlaceholder(pos, test, returnPL) {
  530. if (test = test || getTest(pos).match, test.placeholder !== undefined || !0 === returnPL) return $.isFunction(test.placeholder) ? test.placeholder(opts) : test.placeholder;
  531. if (null === test.fn) {
  532. if (pos > -1 && getMaskSet().validPositions[pos] === undefined) {
  533. var prevTest, tests = getTests(pos), staticAlternations = [];
  534. if (tests.length > 1 + ("" === tests[tests.length - 1].match.def ? 1 : 0)) for (var i = 0; i < tests.length; i++) if (!0 !== tests[i].match.optionality && !0 !== tests[i].match.optionalQuantifier && (null === tests[i].match.fn || prevTest === undefined || !1 !== tests[i].match.fn.test(prevTest.match.def, getMaskSet(), pos, !0, opts)) && (staticAlternations.push(tests[i]),
  535. null === tests[i].match.fn && (prevTest = tests[i]), staticAlternations.length > 1 && /[0-9a-bA-Z]/.test(staticAlternations[0].match.def))) return opts.placeholder.charAt(pos % opts.placeholder.length);
  536. }
  537. return test.def;
  538. }
  539. return opts.placeholder.charAt(pos % opts.placeholder.length);
  540. }
  541. function checkVal(input, writeOut, strict, nptvl, initiatingEvent) {
  542. function isTemplateMatch(ndx, charCodes) {
  543. return -1 !== getBufferTemplate().slice(ndx, seekNext(ndx)).join("").indexOf(charCodes) && !isMask(ndx) && getTest(ndx).match.nativeDef === charCodes.charAt(charCodes.length - 1);
  544. }
  545. var inputValue = nptvl.slice(), charCodes = "", initialNdx = 0, result = undefined;
  546. if (resetMaskSet(), getMaskSet().p = seekNext(-1), !strict) if (!0 !== opts.autoUnmask) {
  547. var staticInput = getBufferTemplate().slice(0, seekNext(-1)).join(""), matches = inputValue.join("").match(new RegExp("^" + Inputmask.escapeRegex(staticInput), "g"));
  548. matches && matches.length > 0 && (inputValue.splice(0, matches.length * staticInput.length),
  549. initialNdx = seekNext(initialNdx));
  550. } else initialNdx = seekNext(initialNdx);
  551. if ($.each(inputValue, function(ndx, charCode) {
  552. if (charCode !== undefined) {
  553. var keypress = new $.Event("_checkval");
  554. keypress.which = charCode.charCodeAt(0), charCodes += charCode;
  555. var lvp = getLastValidPosition(undefined, !0), lvTest = getMaskSet().validPositions[lvp], nextTest = getTestTemplate(lvp + 1, lvTest ? lvTest.locator.slice() : undefined, lvp);
  556. if (!isTemplateMatch(initialNdx, charCodes) || strict || opts.autoUnmask) {
  557. var pos = strict ? ndx : null == nextTest.match.fn && nextTest.match.optionality && lvp + 1 < getMaskSet().p ? lvp + 1 : getMaskSet().p;
  558. result = EventHandlers.keypressEvent.call(input, keypress, !0, !1, strict, pos),
  559. initialNdx = pos + 1, charCodes = "";
  560. } else result = EventHandlers.keypressEvent.call(input, keypress, !0, !1, !0, lvp + 1);
  561. if (!strict && $.isFunction(opts.onBeforeWrite)) {
  562. var fp = result.forwardPosition;
  563. if (result = opts.onBeforeWrite(keypress, getBuffer(), result.forwardPosition, opts),
  564. result.forwardPosition = fp, result && result.refreshFromBuffer) {
  565. var refresh = result.refreshFromBuffer;
  566. refreshFromBuffer(!0 === refresh ? refresh : refresh.start, refresh.end, result.buffer),
  567. resetMaskSet(!0), result.caret && (getMaskSet().p = result.caret, result.forwardPosition = result.caret);
  568. }
  569. }
  570. }
  571. }), writeOut) {
  572. var caretPos = undefined;
  573. document.activeElement === input && result && (caretPos = opts.numericInput ? seekPrevious(result.forwardPosition) : result.forwardPosition),
  574. writeBuffer(input, getBuffer(), caretPos, initiatingEvent || new $.Event("checkval"), initiatingEvent && "input" === initiatingEvent.type);
  575. }
  576. }
  577. function unmaskedvalue(input) {
  578. if (input) {
  579. if (input.inputmask === undefined) return input.value;
  580. input.inputmask && input.inputmask.refreshValue && EventHandlers.setValueEvent.call(input);
  581. }
  582. var umValue = [], vps = getMaskSet().validPositions;
  583. for (var pndx in vps) vps[pndx].match && null != vps[pndx].match.fn && umValue.push(vps[pndx].input);
  584. var unmaskedValue = 0 === umValue.length ? "" : (isRTL ? umValue.reverse() : umValue).join("");
  585. if ($.isFunction(opts.onUnMask)) {
  586. var bufferValue = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join("");
  587. unmaskedValue = opts.onUnMask(bufferValue, unmaskedValue, opts);
  588. }
  589. return unmaskedValue;
  590. }
  591. function caret(input, begin, end, notranslate) {
  592. function translatePosition(pos) {
  593. if (!0 !== notranslate && isRTL && "number" == typeof pos && (!opts.greedy || "" !== opts.placeholder)) {
  594. pos = getBuffer().join("").length - pos;
  595. }
  596. return pos;
  597. }
  598. var range;
  599. if ("number" != typeof begin) return input.setSelectionRange ? (begin = input.selectionStart,
  600. end = input.selectionEnd) : window.getSelection ? (range = window.getSelection().getRangeAt(0),
  601. range.commonAncestorContainer.parentNode !== input && range.commonAncestorContainer !== input || (begin = range.startOffset,
  602. end = range.endOffset)) : document.selection && document.selection.createRange && (range = document.selection.createRange(),
  603. begin = 0 - range.duplicate().moveStart("character", -input.inputmask._valueGet().length),
  604. end = begin + range.text.length), {
  605. begin: translatePosition(begin),
  606. end: translatePosition(end)
  607. };
  608. begin = translatePosition(begin), end = translatePosition(end), end = "number" == typeof end ? end : begin;
  609. var scrollCalc = parseInt(((input.ownerDocument.defaultView || window).getComputedStyle ? (input.ownerDocument.defaultView || window).getComputedStyle(input, null) : input.currentStyle).fontSize) * end;
  610. if (input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0, mobile || !1 !== opts.insertMode || begin !== end || end++,
  611. input.setSelectionRange) input.selectionStart = begin, input.selectionEnd = end; else if (window.getSelection) {
  612. if (range = document.createRange(), input.firstChild === undefined || null === input.firstChild) {
  613. var textNode = document.createTextNode("");
  614. input.appendChild(textNode);
  615. }
  616. range.setStart(input.firstChild, begin < input.inputmask._valueGet().length ? begin : input.inputmask._valueGet().length),
  617. range.setEnd(input.firstChild, end < input.inputmask._valueGet().length ? end : input.inputmask._valueGet().length),
  618. range.collapse(!0);
  619. var sel = window.getSelection();
  620. sel.removeAllRanges(), sel.addRange(range);
  621. } else input.createTextRange && (range = input.createTextRange(), range.collapse(!0),
  622. range.moveEnd("character", end), range.moveStart("character", begin), range.select());
  623. renderColorMask(input, undefined, {
  624. begin: begin,
  625. end: end
  626. });
  627. }
  628. function determineLastRequiredPosition(returnDefinition) {
  629. var pos, testPos, buffer = getBuffer(), bl = buffer.length, lvp = getLastValidPosition(), positions = {}, lvTest = getMaskSet().validPositions[lvp], ndxIntlzr = lvTest !== undefined ? lvTest.locator.slice() : undefined;
  630. for (pos = lvp + 1; pos < buffer.length; pos++) testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
  631. ndxIntlzr = testPos.locator.slice(), positions[pos] = $.extend(!0, {}, testPos);
  632. var lvTestAlt = lvTest && lvTest.alternation !== undefined ? lvTest.locator[lvTest.alternation] : undefined;
  633. for (pos = bl - 1; pos > lvp && (testPos = positions[pos], (testPos.match.optionality || testPos.match.optionalQuantifier || lvTestAlt && (lvTestAlt !== positions[pos].locator[lvTest.alternation] && null != testPos.match.fn || null === testPos.match.fn && testPos.locator[lvTest.alternation] && checkAlternationMatch(testPos.locator[lvTest.alternation].toString().split(","), lvTestAlt.toString().split(",")) && "" !== getTests(pos)[0].def)) && buffer[pos] === getPlaceholder(pos, testPos.match)); pos--) bl--;
  634. return returnDefinition ? {
  635. l: bl,
  636. def: positions[bl] ? positions[bl].match : undefined
  637. } : bl;
  638. }
  639. function clearOptionalTail(buffer) {
  640. for (var validPos, rl = determineLastRequiredPosition(), bl = buffer.length; rl < bl && !isMask(rl + 1) && (validPos = getTest(rl + 1)) && !0 !== validPos.match.optionality && !0 !== validPos.match.optionalQuantifier; ) rl++;
  641. for (;(validPos = getTest(rl - 1)) && validPos.match.optionality && validPos.input === opts.skipOptionalPartCharacter; ) rl--;
  642. return buffer.splice(rl), buffer;
  643. }
  644. function isComplete(buffer) {
  645. if ($.isFunction(opts.isComplete)) return opts.isComplete(buffer, opts);
  646. if ("*" === opts.repeat) return undefined;
  647. var complete = !1, lrp = determineLastRequiredPosition(!0), aml = seekPrevious(lrp.l);
  648. if (lrp.def === undefined || lrp.def.newBlockMarker || lrp.def.optionality || lrp.def.optionalQuantifier) {
  649. complete = !0;
  650. for (var i = 0; i <= aml; i++) {
  651. var test = getTestTemplate(i).match;
  652. if (null !== test.fn && getMaskSet().validPositions[i] === undefined && !0 !== test.optionality && !0 !== test.optionalQuantifier || null === test.fn && buffer[i] !== getPlaceholder(i, test)) {
  653. complete = !1;
  654. break;
  655. }
  656. }
  657. }
  658. return complete;
  659. }
  660. function handleRemove(input, k, pos, strict) {
  661. if ((opts.numericInput || isRTL) && (k === Inputmask.keyCode.BACKSPACE ? k = Inputmask.keyCode.DELETE : k === Inputmask.keyCode.DELETE && (k = Inputmask.keyCode.BACKSPACE),
  662. isRTL)) {
  663. var pend = pos.end;
  664. pos.end = pos.begin, pos.begin = pend;
  665. }
  666. k === Inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || !1 === opts.insertMode) ? (pos.begin = seekPrevious(pos.begin),
  667. getMaskSet().validPositions[pos.begin] === undefined || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.begin--) : k === Inputmask.keyCode.DELETE && pos.begin === pos.end && (pos.end = isMask(pos.end, !0) ? pos.end + 1 : seekNext(pos.end) + 1,
  668. getMaskSet().validPositions[pos.begin] === undefined || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.end++),
  669. stripValidPositions(pos.begin, pos.end, !1, strict), !0 !== strict && function() {
  670. if (opts.keepStatic) {
  671. for (var validInputs = [], lastAlt = getLastValidPosition(-1, !0), positionsClone = $.extend(!0, {}, getMaskSet().validPositions), prevAltPos = getMaskSet().validPositions[lastAlt]; lastAlt >= 0; lastAlt--) {
  672. var altPos = getMaskSet().validPositions[lastAlt];
  673. if (altPos) {
  674. if (!0 !== altPos.generatedInput && /[0-9a-bA-Z]/.test(altPos.input) && validInputs.push(altPos.input),
  675. delete getMaskSet().validPositions[lastAlt], altPos.alternation !== undefined && altPos.locator[altPos.alternation] !== prevAltPos.locator[altPos.alternation]) break;
  676. prevAltPos = altPos;
  677. }
  678. }
  679. if (lastAlt > -1) for (getMaskSet().p = seekNext(getLastValidPosition(-1, !0)); validInputs.length > 0; ) {
  680. var keypress = new $.Event("keypress");
  681. keypress.which = validInputs.pop().charCodeAt(0), EventHandlers.keypressEvent.call(input, keypress, !0, !1, !1, getMaskSet().p);
  682. } else getMaskSet().validPositions = $.extend(!0, {}, positionsClone);
  683. }
  684. }();
  685. var lvp = getLastValidPosition(pos.begin, !0);
  686. lvp < pos.begin ? getMaskSet().p = seekNext(lvp) : !0 !== strict && (getMaskSet().p = pos.begin);
  687. }
  688. function initializeColorMask(input) {
  689. function findCaretPos(clientx) {
  690. var caretPos, e = document.createElement("span");
  691. for (var style in computedStyle) isNaN(style) && -1 !== style.indexOf("font") && (e.style[style] = computedStyle[style]);
  692. e.style.textTransform = computedStyle.textTransform, e.style.letterSpacing = computedStyle.letterSpacing,
  693. e.style.position = "absolute", e.style.height = "auto", e.style.width = "auto",
  694. e.style.visibility = "hidden", e.style.whiteSpace = "nowrap", document.body.appendChild(e);
  695. var itl, inputText = input.inputmask._valueGet(), previousWidth = 0;
  696. for (caretPos = 0, itl = inputText.length; caretPos <= itl; caretPos++) {
  697. if (e.innerHTML += inputText.charAt(caretPos) || "_", e.offsetWidth >= clientx) {
  698. var offset1 = clientx - previousWidth, offset2 = e.offsetWidth - clientx;
  699. e.innerHTML = inputText.charAt(caretPos), offset1 -= e.offsetWidth / 3, caretPos = offset1 < offset2 ? caretPos - 1 : caretPos;
  700. break;
  701. }
  702. previousWidth = e.offsetWidth;
  703. }
  704. return document.body.removeChild(e), caretPos;
  705. }
  706. function position() {
  707. colorMask.style.position = "absolute", colorMask.style.top = offset.top + "px",
  708. colorMask.style.left = offset.left + "px", colorMask.style.width = parseInt(input.offsetWidth) - parseInt(computedStyle.paddingLeft) - parseInt(computedStyle.paddingRight) - parseInt(computedStyle.borderLeftWidth) - parseInt(computedStyle.borderRightWidth) + "px",
  709. colorMask.style.height = parseInt(input.offsetHeight) - parseInt(computedStyle.paddingTop) - parseInt(computedStyle.paddingBottom) - parseInt(computedStyle.borderTopWidth) - parseInt(computedStyle.borderBottomWidth) + "px",
  710. colorMask.style.lineHeight = colorMask.style.height, colorMask.style.zIndex = isNaN(computedStyle.zIndex) ? -1 : computedStyle.zIndex - 1,
  711. colorMask.style.webkitAppearance = "textfield", colorMask.style.mozAppearance = "textfield",
  712. colorMask.style.Appearance = "textfield";
  713. }
  714. var offset = $(input).position(), computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null);
  715. input.parentNode;
  716. colorMask = document.createElement("div"), document.body.appendChild(colorMask);
  717. for (var style in computedStyle) computedStyle.hasOwnProperty(style) && isNaN(style) && "cssText" !== style && -1 == style.indexOf("webkit") && (colorMask.style[style] = computedStyle[style]);
  718. input.style.backgroundColor = "transparent", input.style.color = "transparent",
  719. input.style.webkitAppearance = "caret", input.style.mozAppearance = "caret", input.style.Appearance = "caret",
  720. position(), $(window).on("resize", function(e) {
  721. offset = $(input).position(), computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null),
  722. position();
  723. }), $(input).on("click", function(e) {
  724. return caret(input, findCaretPos(e.clientX)), EventHandlers.clickEvent.call(this, [ e ]);
  725. }), $(input).on("keydown", function(e) {
  726. e.shiftKey || !1 === opts.insertMode || setTimeout(function() {
  727. renderColorMask(input);
  728. }, 0);
  729. });
  730. }
  731. function renderColorMask(input, buffer, caretPos) {
  732. function handleStatic() {
  733. isStatic || null !== test.fn && testPos.input !== undefined ? isStatic && null !== test.fn && testPos.input !== undefined && (isStatic = !1,
  734. maskTemplate += "</span>") : (isStatic = !0, maskTemplate += "<span class='im-static''>");
  735. }
  736. if (colorMask !== undefined) {
  737. buffer = buffer || getBuffer(), caretPos === undefined ? caretPos = caret(input) : caretPos.begin === undefined && (caretPos = {
  738. begin: caretPos,
  739. end: caretPos
  740. });
  741. var maskTemplate = "", isStatic = !1;
  742. if ("" != buffer) {
  743. var ndxIntlzr, test, testPos, pos = 0, lvp = getLastValidPosition();
  744. do {
  745. pos === caretPos.begin && document.activeElement === input && (maskTemplate += "<span class='im-caret' style='border-right-width: 1px;border-right-style: solid;'></span>"),
  746. getMaskSet().validPositions[pos] ? (testPos = getMaskSet().validPositions[pos],
  747. test = testPos.match, ndxIntlzr = testPos.locator.slice(), handleStatic(), maskTemplate += testPos.input) : (testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
  748. test = testPos.match, ndxIntlzr = testPos.locator.slice(), (!1 === opts.jitMasking || pos < lvp || "number" == typeof opts.jitMasking && isFinite(opts.jitMasking) && opts.jitMasking > pos) && (handleStatic(),
  749. maskTemplate += getPlaceholder(pos, test))), pos++;
  750. } while ((maxLength === undefined || pos < maxLength) && (null !== test.fn || "" !== test.def) || lvp > pos);
  751. }
  752. colorMask.innerHTML = maskTemplate;
  753. }
  754. }
  755. maskset = maskset || this.maskset, opts = opts || this.opts;
  756. var undoValue, $el, maxLength, colorMask, valueBuffer, el = this.el, isRTL = this.isRTL, skipKeyPressEvent = !1, skipInputEvent = !1, ignorable = !1, mouseEnter = !1, EventRuler = {
  757. on: function(input, eventName, eventHandler) {
  758. var ev = function(e) {
  759. if (this.inputmask === undefined && "FORM" !== this.nodeName) {
  760. var imOpts = $.data(this, "_inputmask_opts");
  761. imOpts ? new Inputmask(imOpts).mask(this) : EventRuler.off(this);
  762. } else {
  763. if ("setvalue" === e.type || "FORM" === this.nodeName || !(this.disabled || this.readOnly && !("keydown" === e.type && e.ctrlKey && 67 === e.keyCode || !1 === opts.tabThrough && e.keyCode === Inputmask.keyCode.TAB))) {
  764. switch (e.type) {
  765. case "input":
  766. if (!0 === skipInputEvent) return skipInputEvent = !1, e.preventDefault();
  767. break;
  768. case "keydown":
  769. skipKeyPressEvent = !1, skipInputEvent = !1;
  770. break;
  771. case "keypress":
  772. if (!0 === skipKeyPressEvent) return e.preventDefault();
  773. skipKeyPressEvent = !0;
  774. break;
  775. case "click":
  776. var that = this, args = arguments;
  777. return setTimeout(function() {
  778. eventHandler.apply(that, args);
  779. }, 0), !1;
  780. }
  781. var returnVal = eventHandler.apply(this, arguments);
  782. return !1 === returnVal && (e.preventDefault(), e.stopPropagation()), returnVal;
  783. }
  784. e.preventDefault();
  785. }
  786. };
  787. input.inputmask.events[eventName] = input.inputmask.events[eventName] || [], input.inputmask.events[eventName].push(ev),
  788. -1 !== $.inArray(eventName, [ "submit", "reset" ]) ? null != input.form && $(input.form).on(eventName, ev) : $(input).on(eventName, ev);
  789. },
  790. off: function(input, event) {
  791. if (input.inputmask && input.inputmask.events) {
  792. var events;
  793. event ? (events = [], events[event] = input.inputmask.events[event]) : events = input.inputmask.events,
  794. $.each(events, function(eventName, evArr) {
  795. for (;evArr.length > 0; ) {
  796. var ev = evArr.pop();
  797. -1 !== $.inArray(eventName, [ "submit", "reset" ]) ? null != input.form && $(input.form).off(eventName, ev) : $(input).off(eventName, ev);
  798. }
  799. delete input.inputmask.events[eventName];
  800. });
  801. }
  802. }
  803. }, EventHandlers = {
  804. keydownEvent: function(e) {
  805. var input = this, $input = $(input), k = e.keyCode, pos = caret(input);
  806. if (k === Inputmask.keyCode.BACKSPACE || k === Inputmask.keyCode.DELETE || iphone && k === Inputmask.keyCode.BACKSPACE_SAFARI || e.ctrlKey && k === Inputmask.keyCode.X && !function(eventName) {
  807. var el = document.createElement("input"), evName = "on" + eventName, isSupported = evName in el;
  808. return isSupported || (el.setAttribute(evName, "return;"), isSupported = "function" == typeof el[evName]),
  809. el = null, isSupported;
  810. }("cut")) e.preventDefault(), handleRemove(input, k, pos), writeBuffer(input, getBuffer(!0), getMaskSet().p, e, input.inputmask._valueGet() !== getBuffer().join("")),
  811. input.inputmask._valueGet() === getBufferTemplate().join("") ? $input.trigger("cleared") : !0 === isComplete(getBuffer()) && $input.trigger("complete"); else if (k === Inputmask.keyCode.END || k === Inputmask.keyCode.PAGE_DOWN) {
  812. e.preventDefault();
  813. var caretPos = seekNext(getLastValidPosition());
  814. opts.insertMode || caretPos !== getMaskSet().maskLength || e.shiftKey || caretPos--,
  815. caret(input, e.shiftKey ? pos.begin : caretPos, caretPos, !0);
  816. } else k === Inputmask.keyCode.HOME && !e.shiftKey || k === Inputmask.keyCode.PAGE_UP ? (e.preventDefault(),
  817. caret(input, 0, e.shiftKey ? pos.begin : 0, !0)) : (opts.undoOnEscape && k === Inputmask.keyCode.ESCAPE || 90 === k && e.ctrlKey) && !0 !== e.altKey ? (checkVal(input, !0, !1, undoValue.split("")),
  818. $input.trigger("click")) : k !== Inputmask.keyCode.INSERT || e.shiftKey || e.ctrlKey ? !0 === opts.tabThrough && k === Inputmask.keyCode.TAB ? (!0 === e.shiftKey ? (null === getTest(pos.begin).match.fn && (pos.begin = seekNext(pos.begin)),
  819. pos.end = seekPrevious(pos.begin, !0), pos.begin = seekPrevious(pos.end, !0)) : (pos.begin = seekNext(pos.begin, !0),
  820. pos.end = seekNext(pos.begin, !0), pos.end < getMaskSet().maskLength && pos.end--),
  821. pos.begin < getMaskSet().maskLength && (e.preventDefault(), caret(input, pos.begin, pos.end))) : e.shiftKey || !1 === opts.insertMode && (k === Inputmask.keyCode.RIGHT ? setTimeout(function() {
  822. var caretPos = caret(input);
  823. caret(input, caretPos.begin);
  824. }, 0) : k === Inputmask.keyCode.LEFT && setTimeout(function() {
  825. var caretPos = caret(input);
  826. caret(input, isRTL ? caretPos.begin + 1 : caretPos.begin - 1);
  827. }, 0)) : (opts.insertMode = !opts.insertMode, caret(input, opts.insertMode || pos.begin !== getMaskSet().maskLength ? pos.begin : pos.begin - 1));
  828. opts.onKeyDown.call(this, e, getBuffer(), caret(input).begin, opts), ignorable = -1 !== $.inArray(k, opts.ignorables);
  829. },
  830. keypressEvent: function(e, checkval, writeOut, strict, ndx) {
  831. var input = this, $input = $(input), k = e.which || e.charCode || e.keyCode;
  832. if (!(!0 === checkval || e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable)) return k === Inputmask.keyCode.ENTER && undoValue !== getBuffer().join("") && (undoValue = getBuffer().join(""),
  833. setTimeout(function() {
  834. $input.trigger("change");
  835. }, 0)), !0;
  836. if (k) {
  837. 46 === k && !1 === e.shiftKey && "" !== opts.radixPoint && (k = opts.radixPoint.charCodeAt(0));
  838. var forwardPosition, pos = checkval ? {
  839. begin: ndx,
  840. end: ndx
  841. } : caret(input), c = String.fromCharCode(k);
  842. getMaskSet().writeOutBuffer = !0;
  843. var valResult = isValid(pos, c, strict);
  844. if (!1 !== valResult && (resetMaskSet(!0), forwardPosition = valResult.caret !== undefined ? valResult.caret : checkval ? valResult.pos + 1 : seekNext(valResult.pos),
  845. getMaskSet().p = forwardPosition), !1 !== writeOut) {
  846. var self = this;
  847. if (setTimeout(function() {
  848. opts.onKeyValidation.call(self, k, valResult, opts);
  849. }, 0), getMaskSet().writeOutBuffer && !1 !== valResult) {
  850. var buffer = getBuffer();
  851. writeBuffer(input, buffer, opts.numericInput && valResult.caret === undefined ? seekPrevious(forwardPosition) : forwardPosition, e, !0 !== checkval),
  852. !0 !== checkval && setTimeout(function() {
  853. !0 === isComplete(buffer) && $input.trigger("complete");
  854. }, 0);
  855. }
  856. }
  857. if (e.preventDefault(), checkval) return valResult.forwardPosition = forwardPosition,
  858. valResult;
  859. }
  860. },
  861. pasteEvent: function(e) {
  862. var tempValue, input = this, ev = e.originalEvent || e, $input = $(input), inputValue = input.inputmask._valueGet(!0), caretPos = caret(input);
  863. isRTL && (tempValue = caretPos.end, caretPos.end = caretPos.begin, caretPos.begin = tempValue);
  864. var valueBeforeCaret = inputValue.substr(0, caretPos.begin), valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length);
  865. if (valueBeforeCaret === (isRTL ? getBufferTemplate().reverse() : getBufferTemplate()).slice(0, caretPos.begin).join("") && (valueBeforeCaret = ""),
  866. valueAfterCaret === (isRTL ? getBufferTemplate().reverse() : getBufferTemplate()).slice(caretPos.end).join("") && (valueAfterCaret = ""),
  867. isRTL && (tempValue = valueBeforeCaret, valueBeforeCaret = valueAfterCaret, valueAfterCaret = tempValue),
  868. window.clipboardData && window.clipboardData.getData) inputValue = valueBeforeCaret + window.clipboardData.getData("Text") + valueAfterCaret; else {
  869. if (!ev.clipboardData || !ev.clipboardData.getData) return !0;
  870. inputValue = valueBeforeCaret + ev.clipboardData.getData("text/plain") + valueAfterCaret;
  871. }
  872. var pasteValue = inputValue;
  873. if ($.isFunction(opts.onBeforePaste)) {
  874. if (!1 === (pasteValue = opts.onBeforePaste(inputValue, opts))) return e.preventDefault();
  875. pasteValue || (pasteValue = inputValue);
  876. }
  877. return checkVal(input, !1, !1, isRTL ? pasteValue.split("").reverse() : pasteValue.toString().split("")),
  878. writeBuffer(input, getBuffer(), seekNext(getLastValidPosition()), e, undoValue !== getBuffer().join("")),
  879. !0 === isComplete(getBuffer()) && $input.trigger("complete"), e.preventDefault();
  880. },
  881. inputFallBackEvent: function(e) {
  882. var input = this, inputValue = input.inputmask._valueGet();
  883. if (getBuffer().join("") !== inputValue) {
  884. var caretPos = caret(input);
  885. if ("." === inputValue.charAt(caretPos.begin - 1) && "" !== opts.radixPoint && (inputValue = inputValue.split(""),
  886. inputValue[caretPos.begin - 1] = opts.radixPoint.charAt(0), inputValue = inputValue.join("")),
  887. inputValue.charAt(caretPos.begin - 1) === opts.radixPoint && inputValue.length > getBuffer().length) {
  888. var keypress = new $.Event("keypress");
  889. return keypress.which = opts.radixPoint.charCodeAt(0), EventHandlers.keypressEvent.call(input, keypress, !0, !0, !1, caretPos.begin),
  890. !1;
  891. }
  892. if (inputValue = inputValue.replace(new RegExp("(" + Inputmask.escapeRegex(getBufferTemplate().join("")) + ")*"), ""),
  893. iemobile) {
  894. var inputChar = inputValue.replace(getBuffer().join(""), "");
  895. if (1 === inputChar.length) {
  896. var keypress = new $.Event("keypress");
  897. return keypress.which = inputChar.charCodeAt(0), EventHandlers.keypressEvent.call(input, keypress, !0, !0, !1, getMaskSet().validPositions[caretPos.begin - 1] ? caretPos.begin : caretPos.begin - 1),
  898. !1;
  899. }
  900. }
  901. if (caretPos.begin > inputValue.length && (caret(input, inputValue.length), caretPos = caret(input)),
  902. getBuffer().length - inputValue.length != 1 || inputValue.charAt(caretPos.begin) === getBuffer()[caretPos.begin] || inputValue.charAt(caretPos.begin + 1) === getBuffer()[caretPos.begin] || isMask(caretPos.begin)) {
  903. var stickyParts = [], bufferTemplate = getMaskTemplate(!0, 1).join("");
  904. for (stickyParts.push(inputValue.substr(0, caretPos.begin)), stickyParts.push(inputValue.substr(caretPos.begin)); null === inputValue.match(Inputmask.escapeRegex(bufferTemplate) + "$"); ) bufferTemplate = bufferTemplate.slice(1);
  905. inputValue = inputValue.replace(bufferTemplate, ""), $.isFunction(opts.onBeforeMask) && (inputValue = opts.onBeforeMask(inputValue, opts) || inputValue),
  906. checkVal(input, !0, !1, inputValue.split(""), e);
  907. var currentPos = caret(input).begin, currentValue = input.inputmask._valueGet(), pos1 = currentValue.indexOf(stickyParts[0]);
  908. if (0 === pos1 && currentPos !== stickyParts[0].length) caret(input, stickyParts[0].length),
  909. android && setTimeout(function() {
  910. caret(input, stickyParts[0].length);
  911. }, 0); else {
  912. for (;null === currentValue.match(Inputmask.escapeRegex(stickyParts[1]) + "$"); ) stickyParts[1] = stickyParts[1].substr(1);
  913. var pos2 = currentValue.indexOf(stickyParts[1]);
  914. -1 !== pos2 && "" !== stickyParts[1] && currentPos > pos2 && pos2 > pos1 && (caret(input, pos2),
  915. android && setTimeout(function() {
  916. caret(input, pos2);
  917. }, 0));
  918. }
  919. !0 === isComplete(getBuffer()) && $(input).trigger("complete");
  920. } else e.keyCode = Inputmask.keyCode.BACKSPACE, EventHandlers.keydownEvent.call(input, e);
  921. e.preventDefault();
  922. }
  923. },
  924. setValueEvent: function(e) {
  925. this.inputmask.refreshValue = !1;
  926. var input = this, value = input.inputmask._valueGet(!0);
  927. $.isFunction(opts.onBeforeMask) && (value = opts.onBeforeMask(value, opts) || value),
  928. value = value.split(""), checkVal(input, !0, !1, isRTL ? value.reverse() : value),
  929. undoValue = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() === getBufferTemplate().join("") && input.inputmask._valueSet("");
  930. },
  931. focusEvent: function(e) {
  932. var input = this, nptValue = input.inputmask._valueGet();
  933. opts.showMaskOnFocus && (!opts.showMaskOnHover || opts.showMaskOnHover && "" === nptValue) && (input.inputmask._valueGet() !== getBuffer().join("") ? writeBuffer(input, getBuffer(), seekNext(getLastValidPosition())) : !1 === mouseEnter && caret(input, seekNext(getLastValidPosition()))),
  934. !0 === opts.positionCaretOnTab && !1 === mouseEnter && EventHandlers.clickEvent.apply(input, [ e, !0 ]),
  935. undoValue = getBuffer().join("");
  936. },
  937. mouseleaveEvent: function(e) {
  938. var input = this;
  939. if (mouseEnter = !1, opts.clearMaskOnLostFocus && document.activeElement !== input) {
  940. var buffer = getBuffer().slice(), nptValue = input.inputmask._valueGet();
  941. nptValue !== input.getAttribute("placeholder") && "" !== nptValue && (-1 === getLastValidPosition() && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer),
  942. writeBuffer(input, buffer));
  943. }
  944. },
  945. clickEvent: function(e, tabbed) {
  946. var input = this;
  947. if (document.activeElement === input) {
  948. var selectedCaret = caret(input);
  949. if (tabbed && (isRTL ? selectedCaret.end = selectedCaret.begin : selectedCaret.begin = selectedCaret.end),
  950. selectedCaret.begin === selectedCaret.end) switch (opts.positionCaretOnClick) {
  951. case "none":
  952. break;
  953. case "radixFocus":
  954. if (function(clickPos) {
  955. if ("" !== opts.radixPoint) {
  956. var vps = getMaskSet().validPositions;
  957. if (vps[clickPos] === undefined || vps[clickPos].input === getPlaceholder(clickPos)) {
  958. if (clickPos < seekNext(-1)) return !0;
  959. var radixPos = $.inArray(opts.radixPoint, getBuffer());
  960. if (-1 !== radixPos) {
  961. for (var vp in vps) if (radixPos < vp && vps[vp].input !== getPlaceholder(vp)) return !1;
  962. return !0;
  963. }
  964. }
  965. }
  966. return !1;
  967. }(selectedCaret.begin)) {
  968. var radixPos = getBuffer().join("").indexOf(opts.radixPoint);
  969. caret(input, opts.numericInput ? seekNext(radixPos) : radixPos);
  970. break;
  971. }
  972. default:
  973. var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition, !0), lastPosition = seekNext(lvclickPosition);
  974. if (clickPosition < lastPosition) caret(input, isMask(clickPosition) || isMask(clickPosition - 1) ? clickPosition : seekNext(clickPosition)); else {
  975. var placeholder = getPlaceholder(lastPosition);
  976. ("" !== placeholder && getBuffer()[lastPosition] !== placeholder && !0 !== getTest(lastPosition).match.optionalQuantifier || !isMask(lastPosition) && getTest(lastPosition).match.def === placeholder) && (lastPosition = seekNext(lastPosition)),
  977. caret(input, lastPosition);
  978. }
  979. }
  980. }
  981. },
  982. dblclickEvent: function(e) {
  983. var input = this;
  984. setTimeout(function() {
  985. caret(input, 0, seekNext(getLastValidPosition()));
  986. }, 0);
  987. },
  988. cutEvent: function(e) {
  989. var input = this, $input = $(input), pos = caret(input), ev = e.originalEvent || e, clipboardData = window.clipboardData || ev.clipboardData, clipData = isRTL ? getBuffer().slice(pos.end, pos.begin) : getBuffer().slice(pos.begin, pos.end);
  990. clipboardData.setData("text", isRTL ? clipData.reverse().join("") : clipData.join("")),
  991. document.execCommand && document.execCommand("copy"), handleRemove(input, Inputmask.keyCode.DELETE, pos),
  992. writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")),
  993. input.inputmask._valueGet() === getBufferTemplate().join("") && $input.trigger("cleared");
  994. },
  995. blurEvent: function(e) {
  996. var $input = $(this), input = this;
  997. if (input.inputmask) {
  998. var nptValue = input.inputmask._valueGet(), buffer = getBuffer().slice();
  999. undoValue !== buffer.join("") && setTimeout(function() {
  1000. $input.trigger("change"), undoValue = buffer.join("");
  1001. }, 0), "" !== nptValue && (opts.clearMaskOnLostFocus && (-1 === getLastValidPosition() && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
  1002. !1 === isComplete(buffer) && (setTimeout(function() {
  1003. $input.trigger("incomplete");
  1004. }, 0), opts.clearIncomplete && (resetMaskSet(), buffer = opts.clearMaskOnLostFocus ? [] : getBufferTemplate().slice())),
  1005. writeBuffer(input, buffer, undefined, e));
  1006. }
  1007. },
  1008. mouseenterEvent: function(e) {
  1009. var input = this;
  1010. mouseEnter = !0, document.activeElement !== input && opts.showMaskOnHover && input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer());
  1011. },
  1012. submitEvent: function(e) {
  1013. undoValue !== getBuffer().join("") && $el.trigger("change"), opts.clearMaskOnLostFocus && -1 === getLastValidPosition() && el.inputmask._valueGet && el.inputmask._valueGet() === getBufferTemplate().join("") && el.inputmask._valueSet(""),
  1014. opts.removeMaskOnSubmit && (el.inputmask._valueSet(el.inputmask.unmaskedvalue(), !0),
  1015. setTimeout(function() {
  1016. writeBuffer(el, getBuffer());
  1017. }, 0));
  1018. },
  1019. resetEvent: function(e) {
  1020. el.inputmask.refreshValue = !0, setTimeout(function() {
  1021. $el.trigger("setvalue");
  1022. }, 0);
  1023. }
  1024. };
  1025. if (actionObj !== undefined) switch (actionObj.action) {
  1026. case "isComplete":
  1027. return el = actionObj.el, isComplete(getBuffer());
  1028. case "unmaskedvalue":
  1029. return el !== undefined && actionObj.value === undefined || (valueBuffer = actionObj.value,
  1030. valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(valueBuffer, opts) || valueBuffer : valueBuffer).split(""),
  1031. checkVal(undefined, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite(undefined, getBuffer(), 0, opts)),
  1032. unmaskedvalue(el);
  1033. case "mask":
  1034. !function(elem) {
  1035. EventRuler.off(elem);
  1036. var isSupported = function(input, opts) {
  1037. var elementType = input.getAttribute("type"), isSupported = "INPUT" === input.tagName && -1 !== $.inArray(elementType, opts.supportsInputType) || input.isContentEditable || "TEXTAREA" === input.tagName;
  1038. if (!isSupported) if ("INPUT" === input.tagName) {
  1039. var el = document.createElement("input");
  1040. el.setAttribute("type", elementType), isSupported = "text" === el.type, el = null;
  1041. } else isSupported = "partial";
  1042. return !1 !== isSupported && function(npt) {
  1043. function getter() {
  1044. return this.inputmask ? this.inputmask.opts.autoUnmask ? this.inputmask.unmaskedvalue() : -1 !== getLastValidPosition() || !0 !== opts.nullable ? document.activeElement === this && opts.clearMaskOnLostFocus ? (isRTL ? clearOptionalTail(getBuffer().slice()).reverse() : clearOptionalTail(getBuffer().slice())).join("") : valueGet.call(this) : "" : valueGet.call(this);
  1045. }
  1046. function setter(value) {
  1047. valueSet.call(this, value), this.inputmask && $(this).trigger("setvalue");
  1048. }
  1049. var valueGet, valueSet;
  1050. if (!npt.inputmask.__valueGet) {
  1051. if (!0 !== opts.noValuePatching) {
  1052. if (Object.getOwnPropertyDescriptor) {
  1053. "function" != typeof Object.getPrototypeOf && (Object.getPrototypeOf = "object" == typeof "test".__proto__ ? function(object) {
  1054. return object.__proto__;
  1055. } : function(object) {
  1056. return object.constructor.prototype;
  1057. });
  1058. var valueProperty = Object.getPrototypeOf ? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(npt), "value") : undefined;
  1059. valueProperty && valueProperty.get && valueProperty.set ? (valueGet = valueProperty.get,
  1060. valueSet = valueProperty.set, Object.defineProperty(npt, "value", {
  1061. get: getter,
  1062. set: setter,
  1063. configurable: !0
  1064. })) : "INPUT" !== npt.tagName && (valueGet = function() {
  1065. return this.textContent;
  1066. }, valueSet = function(value) {
  1067. this.textContent = value;
  1068. }, Object.defineProperty(npt, "value", {
  1069. get: getter,
  1070. set: setter,
  1071. configurable: !0
  1072. }));
  1073. } else document.__lookupGetter__ && npt.__lookupGetter__("value") && (valueGet = npt.__lookupGetter__("value"),
  1074. valueSet = npt.__lookupSetter__("value"), npt.__defineGetter__("value", getter),
  1075. npt.__defineSetter__("value", setter));
  1076. npt.inputmask.__valueGet = valueGet, npt.inputmask.__valueSet = valueSet;
  1077. }
  1078. npt.inputmask._valueGet = function(overruleRTL) {
  1079. return isRTL && !0 !== overruleRTL ? valueGet.call(this.el).split("").reverse().join("") : valueGet.call(this.el);
  1080. }, npt.inputmask._valueSet = function(value, overruleRTL) {
  1081. valueSet.call(this.el, null === value || value === undefined ? "" : !0 !== overruleRTL && isRTL ? value.split("").reverse().join("") : value);
  1082. }, valueGet === undefined && (valueGet = function() {
  1083. return this.value;
  1084. }, valueSet = function(value) {
  1085. this.value = value;
  1086. }, function(type) {
  1087. if ($.valHooks && ($.valHooks[type] === undefined || !0 !== $.valHooks[type].inputmaskpatch)) {
  1088. var valhookGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function(elem) {
  1089. return elem.value;
  1090. }, valhookSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function(elem, value) {
  1091. return elem.value = value, elem;
  1092. };
  1093. $.valHooks[type] = {
  1094. get: function(elem) {
  1095. if (elem.inputmask) {
  1096. if (elem.inputmask.opts.autoUnmask) return elem.inputmask.unmaskedvalue();
  1097. var result = valhookGet(elem);
  1098. return -1 !== getLastValidPosition(undefined, undefined, elem.inputmask.maskset.validPositions) || !0 !== opts.nullable ? result : "";
  1099. }
  1100. return valhookGet(elem);
  1101. },
  1102. set: function(elem, value) {
  1103. var result, $elem = $(elem);
  1104. return result = valhookSet(elem, value), elem.inputmask && $elem.trigger("setvalue"),
  1105. result;
  1106. },
  1107. inputmaskpatch: !0
  1108. };
  1109. }
  1110. }(npt.type), function(npt) {
  1111. EventRuler.on(npt, "mouseenter", function(event) {
  1112. var $input = $(this);
  1113. this.inputmask._valueGet() !== getBuffer().join("") && $input.trigger("setvalue");
  1114. });
  1115. }(npt));
  1116. }
  1117. }(input), isSupported;
  1118. }(elem, opts);
  1119. if (!1 !== isSupported && (el = elem, $el = $(el), ("rtl" === el.dir || opts.rightAlign) && (el.style.textAlign = "right"),
  1120. ("rtl" === el.dir || opts.numericInput) && (el.dir = "ltr", el.removeAttribute("dir"),
  1121. el.inputmask.isRTL = !0, isRTL = !0), !0 === opts.colorMask && initializeColorMask(el),
  1122. android && (el.hasOwnProperty("inputmode") && (el.inputmode = opts.inputmode, el.setAttribute("inputmode", opts.inputmode)),
  1123. "rtfm" === opts.androidHack && (!0 !== opts.colorMask && initializeColorMask(el),
  1124. el.type = "password")), !0 === isSupported && (EventRuler.on(el, "submit", EventHandlers.submitEvent),
  1125. EventRuler.on(el, "reset", EventHandlers.resetEvent), EventRuler.on(el, "mouseenter", EventHandlers.mouseenterEvent),
  1126. EventRuler.on(el, "blur", EventHandlers.blurEvent), EventRuler.on(el, "focus", EventHandlers.focusEvent),
  1127. EventRuler.on(el, "mouseleave", EventHandlers.mouseleaveEvent), !0 !== opts.colorMask && EventRuler.on(el, "click", EventHandlers.clickEvent),
  1128. EventRuler.on(el, "dblclick", EventHandlers.dblclickEvent), EventRuler.on(el, "paste", EventHandlers.pasteEvent),
  1129. EventRuler.on(el, "dragdrop", EventHandlers.pasteEvent), EventRuler.on(el, "drop", EventHandlers.pasteEvent),
  1130. EventRuler.on(el, "cut", EventHandlers.cutEvent), EventRuler.on(el, "complete", opts.oncomplete),
  1131. EventRuler.on(el, "incomplete", opts.onincomplete), EventRuler.on(el, "cleared", opts.oncleared),
  1132. android || !0 === opts.inputEventOnly || (EventRuler.on(el, "keydown", EventHandlers.keydownEvent),
  1133. EventRuler.on(el, "keypress", EventHandlers.keypressEvent)), EventRuler.on(el, "compositionstart", $.noop),
  1134. EventRuler.on(el, "compositionupdate", $.noop), EventRuler.on(el, "compositionend", $.noop),
  1135. EventRuler.on(el, "keyup", $.noop), EventRuler.on(el, "input", EventHandlers.inputFallBackEvent),
  1136. EventRuler.on(el, "beforeinput", $.noop)), EventRuler.on(el, "setvalue", EventHandlers.setValueEvent),
  1137. getBufferTemplate(), "" !== el.inputmask._valueGet(!0) || !1 === opts.clearMaskOnLostFocus || document.activeElement === el)) {
  1138. var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(el.inputmask._valueGet(!0), opts) || el.inputmask._valueGet(!0) : el.inputmask._valueGet(!0);
  1139. "" !== initialValue && checkVal(el, !0, !1, isRTL ? initialValue.split("").reverse() : initialValue.split(""));
  1140. var buffer = getBuffer().slice();
  1141. undoValue = buffer.join(""), !1 === isComplete(buffer) && opts.clearIncomplete && resetMaskSet(),
  1142. opts.clearMaskOnLostFocus && document.activeElement !== el && (-1 === getLastValidPosition() ? buffer = [] : clearOptionalTail(buffer)),
  1143. writeBuffer(el, buffer), document.activeElement === el && caret(el, seekNext(getLastValidPosition()));
  1144. }
  1145. }(el);
  1146. break;
  1147. case "format":
  1148. return valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(actionObj.value, opts) || actionObj.value : actionObj.value).split(""),
  1149. checkVal(undefined, !0, !1, isRTL ? valueBuffer.reverse() : valueBuffer), actionObj.metadata ? {
  1150. value: isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join(""),
  1151. metadata: maskScope.call(this, {
  1152. action: "getmetadata"
  1153. }, maskset, opts)
  1154. } : isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join("");
  1155. case "isValid":
  1156. actionObj.value ? (valueBuffer = actionObj.value.split(""), checkVal(undefined, !0, !0, isRTL ? valueBuffer.reverse() : valueBuffer)) : actionObj.value = getBuffer().join("");
  1157. for (var buffer = getBuffer(), rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
  1158. return buffer.splice(rl, lmib + 1 - rl), isComplete(buffer) && actionObj.value === getBuffer().join("");
  1159. case "getemptymask":
  1160. return getBufferTemplate().join("");
  1161. case "remove":
  1162. if (el && el.inputmask) {
  1163. $el = $(el), el.inputmask._valueSet(opts.autoUnmask ? unmaskedvalue(el) : el.inputmask._valueGet(!0)),
  1164. EventRuler.off(el);
  1165. Object.getOwnPropertyDescriptor && Object.getPrototypeOf ? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(el), "value") && el.inputmask.__valueGet && Object.defineProperty(el, "value", {
  1166. get: el.inputmask.__valueGet,
  1167. set: el.inputmask.__valueSet,
  1168. configurable: !0
  1169. }) : document.__lookupGetter__ && el.__lookupGetter__("value") && el.inputmask.__valueGet && (el.__defineGetter__("value", el.inputmask.__valueGet),
  1170. el.__defineSetter__("value", el.inputmask.__valueSet)), el.inputmask = undefined;
  1171. }
  1172. return el;
  1173. case "getmetadata":
  1174. if ($.isArray(maskset.metadata)) {
  1175. var maskTarget = getMaskTemplate(!0, 0, !1).join("");
  1176. return $.each(maskset.metadata, function(ndx, mtdt) {
  1177. if (mtdt.mask === maskTarget) return maskTarget = mtdt, !1;
  1178. }), maskTarget;
  1179. }
  1180. return maskset.metadata;
  1181. }
  1182. }
  1183. var ua = navigator.userAgent, mobile = /mobile/i.test(ua), iemobile = /iemobile/i.test(ua), iphone = /iphone/i.test(ua) && !iemobile, android = /android/i.test(ua) && !iemobile;
  1184. return Inputmask.prototype = {
  1185. dataAttribute: "data-inputmask",
  1186. defaults: {
  1187. placeholder: "_",
  1188. optionalmarker: {
  1189. start: "[",
  1190. end: "]"
  1191. },
  1192. quantifiermarker: {
  1193. start: "{",
  1194. end: "}"
  1195. },
  1196. groupmarker: {
  1197. start: "(",
  1198. end: ")"
  1199. },
  1200. alternatormarker: "|",
  1201. escapeChar: "\\",
  1202. mask: null,
  1203. regex: null,
  1204. oncomplete: $.noop,
  1205. onincomplete: $.noop,
  1206. oncleared: $.noop,
  1207. repeat: 0,
  1208. greedy: !0,
  1209. autoUnmask: !1,
  1210. removeMaskOnSubmit: !1,
  1211. clearMaskOnLostFocus: !0,
  1212. insertMode: !0,
  1213. clearIncomplete: !1,
  1214. alias: null,
  1215. onKeyDown: $.noop,
  1216. onBeforeMask: null,
  1217. onBeforePaste: function(pastedValue, opts) {
  1218. return $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(pastedValue, opts) : pastedValue;
  1219. },
  1220. onBeforeWrite: null,
  1221. onUnMask: null,
  1222. showMaskOnFocus: !0,
  1223. showMaskOnHover: !0,
  1224. onKeyValidation: $.noop,
  1225. skipOptionalPartCharacter: " ",
  1226. numericInput: !1,
  1227. rightAlign: !1,
  1228. undoOnEscape: !0,
  1229. radixPoint: "",
  1230. radixPointDefinitionSymbol: undefined,
  1231. groupSeparator: "",
  1232. keepStatic: null,
  1233. positionCaretOnTab: !0,
  1234. tabThrough: !1,
  1235. supportsInputType: [ "text", "tel", "password" ],
  1236. 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, 0, 229 ],
  1237. isComplete: null,
  1238. canClearPosition: $.noop,
  1239. preValidation: null,
  1240. postValidation: null,
  1241. staticDefinitionSymbol: undefined,
  1242. jitMasking: !1,
  1243. nullable: !0,
  1244. inputEventOnly: !1,
  1245. noValuePatching: !1,
  1246. positionCaretOnClick: "lvp",
  1247. casing: null,
  1248. inputmode: "verbatim",
  1249. colorMask: !1,
  1250. androidHack: !1
  1251. },
  1252. definitions: {
  1253. "9": {
  1254. validator: "[0-9]",
  1255. cardinality: 1,
  1256. definitionSymbol: "*"
  1257. },
  1258. a: {
  1259. validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  1260. cardinality: 1,
  1261. definitionSymbol: "*"
  1262. },
  1263. "*": {
  1264. validator: function() {
  1265. return !0;
  1266. },
  1267. cardinality: 1
  1268. }
  1269. },
  1270. aliases: {},
  1271. masksCache: {},
  1272. mask: function(elems) {
  1273. function importAttributeOptions(npt, opts, userOptions, dataAttribute) {
  1274. function importOption(option, optionData) {
  1275. null !== (optionData = optionData !== undefined ? optionData : npt.getAttribute(dataAttribute + "-" + option)) && ("string" == typeof optionData && (0 === option.indexOf("on") ? optionData = window[optionData] : "false" === optionData ? optionData = !1 : "true" === optionData && (optionData = !0)),
  1276. userOptions[option] = optionData);
  1277. }
  1278. var option, dataoptions, optionData, p, attrOptions = npt.getAttribute(dataAttribute);
  1279. if (attrOptions && "" !== attrOptions && (attrOptions = attrOptions.replace(new RegExp("'", "g"), '"'),
  1280. dataoptions = JSON.parse("{" + attrOptions + "}")), dataoptions) {
  1281. optionData = undefined;
  1282. for (p in dataoptions) if ("alias" === p.toLowerCase()) {
  1283. optionData = dataoptions[p];
  1284. break;
  1285. }
  1286. }
  1287. importOption("alias", optionData), userOptions.alias && resolveAlias(userOptions.alias, userOptions, opts);
  1288. for (option in opts) {
  1289. if (dataoptions) {
  1290. optionData = undefined;
  1291. for (p in dataoptions) if (p.toLowerCase() === option.toLowerCase()) {
  1292. optionData = dataoptions[p];
  1293. break;
  1294. }
  1295. }
  1296. importOption(option, optionData);
  1297. }
  1298. return $.extend(!0, opts, userOptions), opts;
  1299. }
  1300. var that = this;
  1301. return "string" == typeof elems && (elems = document.getElementById(elems) || document.querySelectorAll(elems)),
  1302. elems = elems.nodeName ? [ elems ] : elems, $.each(elems, function(ndx, el) {
  1303. var scopedOpts = $.extend(!0, {}, that.opts);
  1304. importAttributeOptions(el, scopedOpts, $.extend(!0, {}, that.userOptions), that.dataAttribute);
  1305. var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
  1306. maskset !== undefined && (el.inputmask !== undefined && el.inputmask.remove(), el.inputmask = new Inputmask(undefined, undefined, !0),
  1307. el.inputmask.opts = scopedOpts, el.inputmask.noMasksCache = that.noMasksCache, el.inputmask.userOptions = $.extend(!0, {}, that.userOptions),
  1308. el.inputmask.isRTL = that.isRTL, el.inputmask.el = el, el.inputmask.maskset = maskset,
  1309. $.data(el, "_inputmask_opts", scopedOpts), maskScope.call(el.inputmask, {
  1310. action: "mask"
  1311. }));
  1312. }), elems && elems[0] ? elems[0].inputmask || this : this;
  1313. },
  1314. option: function(options, noremask) {
  1315. return "string" == typeof options ? this.opts[options] : "object" == typeof options ? ($.extend(this.userOptions, options),
  1316. this.el && !0 !== noremask && this.mask(this.el), this) : void 0;
  1317. },
  1318. unmaskedvalue: function(value) {
  1319. return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
  1320. maskScope.call(this, {
  1321. action: "unmaskedvalue",
  1322. value: value
  1323. });
  1324. },
  1325. remove: function() {
  1326. return maskScope.call(this, {
  1327. action: "remove"
  1328. });
  1329. },
  1330. getemptymask: function() {
  1331. return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
  1332. maskScope.call(this, {
  1333. action: "getemptymask"
  1334. });
  1335. },
  1336. hasMaskedValue: function() {
  1337. return !this.opts.autoUnmask;
  1338. },
  1339. isComplete: function() {
  1340. return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
  1341. maskScope.call(this, {
  1342. action: "isComplete"
  1343. });
  1344. },
  1345. getmetadata: function() {
  1346. return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
  1347. maskScope.call(this, {
  1348. action: "getmetadata"
  1349. });
  1350. },
  1351. isValid: function(value) {
  1352. return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
  1353. maskScope.call(this, {
  1354. action: "isValid",
  1355. value: value
  1356. });
  1357. },
  1358. format: function(value, metadata) {
  1359. return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
  1360. maskScope.call(this, {
  1361. action: "format",
  1362. value: value,
  1363. metadata: metadata
  1364. });
  1365. },
  1366. analyseMask: function(mask, regexMask, opts) {
  1367. function MaskToken(isGroup, isOptional, isQuantifier, isAlternator) {
  1368. this.matches = [], this.openGroup = isGroup || !1, this.isGroup = isGroup || !1,
  1369. this.isOptional = isOptional || !1, this.isQuantifier = isQuantifier || !1, this.isAlternator = isAlternator || !1,
  1370. this.quantifier = {
  1371. min: 1,
  1372. max: 1
  1373. };
  1374. }
  1375. function insertTestDefinition(mtoken, element, position) {
  1376. if (position = position !== undefined ? position : mtoken.matches.length, regexMask) 0 === element.indexOf("[") || escaped ? mtoken.matches.splice(position++, 0, {
  1377. fn: new RegExp(element, opts.casing ? "i" : ""),
  1378. cardinality: 0,
  1379. optionality: mtoken.isOptional,
  1380. newBlockMarker: prevMatch === undefined || prevMatch.def !== element,
  1381. casing: null,
  1382. def: opts.staticDefinitionSymbol || element,
  1383. placeholder: opts.staticDefinitionSymbol !== undefined ? element : undefined,
  1384. nativeDef: element
  1385. }) : mtoken.matches.splice(position++, 0, {
  1386. fn: null,
  1387. cardinality: 0,
  1388. optionality: mtoken.isOptional,
  1389. newBlockMarker: prevMatch === undefined || prevMatch.def !== element,
  1390. casing: null,
  1391. def: opts.staticDefinitionSymbol || element,
  1392. placeholder: opts.staticDefinitionSymbol !== undefined ? element : undefined,
  1393. nativeDef: element
  1394. }), escaped = !1; else {
  1395. var maskdef = (opts.definitions ? opts.definitions[element] : undefined) || Inputmask.prototype.definitions[element], prevMatch = mtoken.matches[position - 1];
  1396. if (maskdef && !escaped) {
  1397. for (var prevalidators = maskdef.prevalidator, prevalidatorsL = prevalidators ? prevalidators.length : 0, i = 1; i < maskdef.cardinality; i++) {
  1398. var prevalidator = prevalidatorsL >= i ? prevalidators[i - 1] : [], validator = prevalidator.validator, cardinality = prevalidator.cardinality;
  1399. mtoken.matches.splice(position++, 0, {
  1400. fn: validator ? "string" == typeof validator ? new RegExp(validator, opts.casing ? "i" : "") : new function() {
  1401. this.test = validator;
  1402. }() : new RegExp("."),
  1403. cardinality: cardinality || 1,
  1404. optionality: mtoken.isOptional,
  1405. newBlockMarker: prevMatch === undefined || prevMatch.def !== (maskdef.definitionSymbol || element),
  1406. casing: maskdef.casing,
  1407. def: maskdef.definitionSymbol || element,
  1408. placeholder: maskdef.placeholder,
  1409. nativeDef: element
  1410. }), prevMatch = mtoken.matches[position - 1];
  1411. }
  1412. mtoken.matches.splice(position++, 0, {
  1413. fn: maskdef.validator ? "string" == typeof maskdef.validator ? new RegExp(maskdef.validator, opts.casing ? "i" : "") : new function() {
  1414. this.test = maskdef.validator;
  1415. }() : new RegExp("."),
  1416. cardinality: maskdef.cardinality,
  1417. optionality: mtoken.isOptional,
  1418. newBlockMarker: prevMatch === undefined || prevMatch.def !== (maskdef.definitionSymbol || element),
  1419. casing: maskdef.casing,
  1420. def: maskdef.definitionSymbol || element,
  1421. placeholder: maskdef.placeholder,
  1422. nativeDef: element
  1423. });
  1424. } else mtoken.matches.splice(position++, 0, {
  1425. fn: null,
  1426. cardinality: 0,
  1427. optionality: mtoken.isOptional,
  1428. newBlockMarker: prevMatch === undefined || prevMatch.def !== element,
  1429. casing: null,
  1430. def: opts.staticDefinitionSymbol || element,
  1431. placeholder: opts.staticDefinitionSymbol !== undefined ? element : undefined,
  1432. nativeDef: element
  1433. }), escaped = !1;
  1434. }
  1435. }
  1436. function verifyGroupMarker(maskToken) {
  1437. maskToken && maskToken.matches && $.each(maskToken.matches, function(ndx, token) {
  1438. var nextToken = maskToken.matches[ndx + 1];
  1439. (nextToken === undefined || nextToken.matches === undefined || !1 === nextToken.isQuantifier) && token && token.isGroup && (token.isGroup = !1,
  1440. regexMask || (insertTestDefinition(token, opts.groupmarker.start, 0), !0 !== token.openGroup && insertTestDefinition(token, opts.groupmarker.end))),
  1441. verifyGroupMarker(token);
  1442. });
  1443. }
  1444. function defaultCase() {
  1445. if (openenings.length > 0) {
  1446. if (currentOpeningToken = openenings[openenings.length - 1], insertTestDefinition(currentOpeningToken, m),
  1447. currentOpeningToken.isAlternator) {
  1448. alternator = openenings.pop();
  1449. for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
  1450. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  1451. currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
  1452. }
  1453. } else insertTestDefinition(currentToken, m);
  1454. }
  1455. function reverseTokens(maskToken) {
  1456. maskToken.matches = maskToken.matches.reverse();
  1457. for (var match in maskToken.matches) if (maskToken.matches.hasOwnProperty(match)) {
  1458. var intMatch = parseInt(match);
  1459. if (maskToken.matches[match].isQuantifier && maskToken.matches[intMatch + 1] && maskToken.matches[intMatch + 1].isGroup) {
  1460. var qt = maskToken.matches[match];
  1461. maskToken.matches.splice(match, 1), maskToken.matches.splice(intMatch + 1, 0, qt);
  1462. }
  1463. maskToken.matches[match].matches !== undefined ? maskToken.matches[match] = reverseTokens(maskToken.matches[match]) : maskToken.matches[match] = function(st) {
  1464. return st === opts.optionalmarker.start ? st = opts.optionalmarker.end : st === opts.optionalmarker.end ? st = opts.optionalmarker.start : st === opts.groupmarker.start ? st = opts.groupmarker.end : st === opts.groupmarker.end && (st = opts.groupmarker.start),
  1465. st;
  1466. }(maskToken.matches[match]);
  1467. }
  1468. return maskToken;
  1469. }
  1470. var match, m, openingToken, currentOpeningToken, alternator, lastMatch, groupToken, tokenizer = /(?:[?*+]|\{[0-9\+\*]+(?:,[0-9\+\*]*)?\})|[^.?*+^${[]()|\\]+|./g, regexTokenizer = /\[\^?]?(?:[^\\\]]+|\\[\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, escaped = !1, currentToken = new MaskToken(), openenings = [], maskTokens = [];
  1471. for (regexMask && (opts.optionalmarker.start = undefined, opts.optionalmarker.end = undefined); match = regexMask ? regexTokenizer.exec(mask) : tokenizer.exec(mask); ) {
  1472. if (m = match[0], regexMask) switch (m.charAt(0)) {
  1473. case "?":
  1474. m = "{+}";
  1475. break;
  1476. case "+":
  1477. case "*":
  1478. m = "{" + m + "}";
  1479. }
  1480. if (escaped) defaultCase(); else switch (m.charAt(0)) {
  1481. case opts.escapeChar:
  1482. escaped = !0, regexMask && defaultCase();
  1483. break;
  1484. case opts.optionalmarker.end:
  1485. case opts.groupmarker.end:
  1486. if (openingToken = openenings.pop(), openingToken.openGroup = !1, openingToken !== undefined) if (openenings.length > 0) {
  1487. if (currentOpeningToken = openenings[openenings.length - 1], currentOpeningToken.matches.push(openingToken),
  1488. currentOpeningToken.isAlternator) {
  1489. alternator = openenings.pop();
  1490. for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
  1491. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  1492. currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
  1493. }
  1494. } else currentToken.matches.push(openingToken); else defaultCase();
  1495. break;
  1496. case opts.optionalmarker.start:
  1497. openenings.push(new MaskToken(!1, !0));
  1498. break;
  1499. case opts.groupmarker.start:
  1500. openenings.push(new MaskToken(!0));
  1501. break;
  1502. case opts.quantifiermarker.start:
  1503. var quantifier = new MaskToken(!1, !1, !0);
  1504. m = m.replace(/[{}]/g, "");
  1505. var mq = m.split(","), mq0 = isNaN(mq[0]) ? mq[0] : parseInt(mq[0]), mq1 = 1 === mq.length ? mq0 : isNaN(mq[1]) ? mq[1] : parseInt(mq[1]);
  1506. if ("*" !== mq1 && "+" !== mq1 || (mq0 = "*" === mq1 ? 0 : 1), quantifier.quantifier = {
  1507. min: mq0,
  1508. max: mq1
  1509. }, openenings.length > 0) {
  1510. var matches = openenings[openenings.length - 1].matches;
  1511. match = matches.pop(), match.isGroup || (groupToken = new MaskToken(!0), groupToken.matches.push(match),
  1512. match = groupToken), matches.push(match), matches.push(quantifier);
  1513. } else match = currentToken.matches.pop(), match.isGroup || (groupToken = new MaskToken(!0),
  1514. groupToken.matches.push(match), match = groupToken), currentToken.matches.push(match),
  1515. currentToken.matches.push(quantifier);
  1516. break;
  1517. case opts.alternatormarker:
  1518. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  1519. lastMatch = currentOpeningToken.matches.pop()) : lastMatch = currentToken.matches.pop(),
  1520. lastMatch.isAlternator ? openenings.push(lastMatch) : (alternator = new MaskToken(!1, !1, !1, !0),
  1521. alternator.matches.push(lastMatch), openenings.push(alternator));
  1522. break;
  1523. default:
  1524. defaultCase();
  1525. }
  1526. }
  1527. for (;openenings.length > 0; ) openingToken = openenings.pop(), currentToken.matches.push(openingToken);
  1528. return currentToken.matches.length > 0 && (verifyGroupMarker(currentToken), maskTokens.push(currentToken)),
  1529. opts.numericInput && reverseTokens(maskTokens[0]), maskTokens;
  1530. }
  1531. }, Inputmask.extendDefaults = function(options) {
  1532. $.extend(!0, Inputmask.prototype.defaults, options);
  1533. }, Inputmask.extendDefinitions = function(definition) {
  1534. $.extend(!0, Inputmask.prototype.definitions, definition);
  1535. }, Inputmask.extendAliases = function(alias) {
  1536. $.extend(!0, Inputmask.prototype.aliases, alias);
  1537. }, Inputmask.format = function(value, options, metadata) {
  1538. return Inputmask(options).format(value, metadata);
  1539. }, Inputmask.unmask = function(value, options) {
  1540. return Inputmask(options).unmaskedvalue(value);
  1541. }, Inputmask.isValid = function(value, options) {
  1542. return Inputmask(options).isValid(value);
  1543. }, Inputmask.remove = function(elems) {
  1544. $.each(elems, function(ndx, el) {
  1545. el.inputmask && el.inputmask.remove();
  1546. });
  1547. }, Inputmask.escapeRegex = function(str) {
  1548. var specials = [ "/", ".", "*", "+", "?", "|", "(", ")", "[", "]", "{", "}", "\\", "$", "^" ];
  1549. return str.replace(new RegExp("(\\" + specials.join("|\\") + ")", "gim"), "\\$1");
  1550. }, Inputmask.keyCode = {
  1551. ALT: 18,
  1552. BACKSPACE: 8,
  1553. BACKSPACE_SAFARI: 127,
  1554. CAPS_LOCK: 20,
  1555. COMMA: 188,
  1556. COMMAND: 91,
  1557. COMMAND_LEFT: 91,
  1558. COMMAND_RIGHT: 93,
  1559. CONTROL: 17,
  1560. DELETE: 46,
  1561. DOWN: 40,
  1562. END: 35,
  1563. ENTER: 13,
  1564. ESCAPE: 27,
  1565. HOME: 36,
  1566. INSERT: 45,
  1567. LEFT: 37,
  1568. MENU: 93,
  1569. NUMPAD_ADD: 107,
  1570. NUMPAD_DECIMAL: 110,
  1571. NUMPAD_DIVIDE: 111,
  1572. NUMPAD_ENTER: 108,
  1573. NUMPAD_MULTIPLY: 106,
  1574. NUMPAD_SUBTRACT: 109,
  1575. PAGE_DOWN: 34,
  1576. PAGE_UP: 33,
  1577. PERIOD: 190,
  1578. RIGHT: 39,
  1579. SHIFT: 16,
  1580. SPACE: 32,
  1581. TAB: 9,
  1582. UP: 38,
  1583. WINDOWS: 91,
  1584. X: 88
  1585. }, Inputmask;
  1586. }(window.dependencyLib || jQuery, window, document);
  1587. }(), function(factory) {
  1588. !function($, Inputmask) {
  1589. void 0 === $.fn.inputmask && ($.fn.inputmask = function(fn, options) {
  1590. var nptmask, input = this[0];
  1591. if (void 0 === options && (options = {}), "string" == typeof fn) switch (fn) {
  1592. case "unmaskedvalue":
  1593. return input && input.inputmask ? input.inputmask.unmaskedvalue() : $(input).val();
  1594. case "remove":
  1595. return this.each(function() {
  1596. this.inputmask && this.inputmask.remove();
  1597. });
  1598. case "getemptymask":
  1599. return input && input.inputmask ? input.inputmask.getemptymask() : "";
  1600. case "hasMaskedValue":
  1601. return !(!input || !input.inputmask) && input.inputmask.hasMaskedValue();
  1602. case "isComplete":
  1603. return !input || !input.inputmask || input.inputmask.isComplete();
  1604. case "getmetadata":
  1605. return input && input.inputmask ? input.inputmask.getmetadata() : void 0;
  1606. case "setvalue":
  1607. $(input).val(options), input && void 0 === input.inputmask && $(input).triggerHandler("setvalue");
  1608. break;
  1609. case "option":
  1610. if ("string" != typeof options) return this.each(function() {
  1611. if (void 0 !== this.inputmask) return this.inputmask.option(options);
  1612. });
  1613. if (input && void 0 !== input.inputmask) return input.inputmask.option(options);
  1614. break;
  1615. default:
  1616. return options.alias = fn, nptmask = new Inputmask(options), this.each(function() {
  1617. nptmask.mask(this);
  1618. });
  1619. } else {
  1620. if ("object" == typeof fn) return nptmask = new Inputmask(fn), void 0 === fn.mask && void 0 === fn.alias ? this.each(function() {
  1621. if (void 0 !== this.inputmask) return this.inputmask.option(fn);
  1622. nptmask.mask(this);
  1623. }) : this.each(function() {
  1624. nptmask.mask(this);
  1625. });
  1626. if (void 0 === fn) return this.each(function() {
  1627. nptmask = new Inputmask(options), nptmask.mask(this);
  1628. });
  1629. }
  1630. }), $.fn.inputmask;
  1631. }(jQuery, window.Inputmask);
  1632. }(), function(factory) {
  1633. !function($, Inputmask) {
  1634. function isLeapYear(year) {
  1635. return isNaN(year) || 29 === new Date(year, 2, 0).getDate();
  1636. }
  1637. Inputmask.extendAliases({
  1638. "dd/mm/yyyy": {
  1639. mask: "1/2/y",
  1640. placeholder: "dd/mm/yyyy",
  1641. regex: {
  1642. val1pre: new RegExp("[0-3]"),
  1643. val1: new RegExp("0[1-9]|[12][0-9]|3[01]"),
  1644. val2pre: function(separator) {
  1645. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1646. return new RegExp("((0[1-9]|[12][0-9]|3[01])" + escapedSeparator + "[01])");
  1647. },
  1648. val2: function(separator) {
  1649. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1650. return new RegExp("((0[1-9]|[12][0-9])" + escapedSeparator + "(0[1-9]|1[012]))|(30" + escapedSeparator + "(0[13-9]|1[012]))|(31" + escapedSeparator + "(0[13578]|1[02]))");
  1651. }
  1652. },
  1653. leapday: "29/02/",
  1654. separator: "/",
  1655. yearrange: {
  1656. minyear: 1900,
  1657. maxyear: 2099
  1658. },
  1659. isInYearRange: function(chrs, minyear, maxyear) {
  1660. if (isNaN(chrs)) return !1;
  1661. var enteredyear = parseInt(chrs.concat(minyear.toString().slice(chrs.length))), enteredyear2 = parseInt(chrs.concat(maxyear.toString().slice(chrs.length)));
  1662. return !isNaN(enteredyear) && (minyear <= enteredyear && enteredyear <= maxyear) || !isNaN(enteredyear2) && (minyear <= enteredyear2 && enteredyear2 <= maxyear);
  1663. },
  1664. determinebaseyear: function(minyear, maxyear, hint) {
  1665. var currentyear = new Date().getFullYear();
  1666. if (minyear > currentyear) return minyear;
  1667. if (maxyear < currentyear) {
  1668. for (var maxYearPrefix = maxyear.toString().slice(0, 2), maxYearPostfix = maxyear.toString().slice(2, 4); maxyear < maxYearPrefix + hint; ) maxYearPrefix--;
  1669. var maxxYear = maxYearPrefix + maxYearPostfix;
  1670. return minyear > maxxYear ? minyear : maxxYear;
  1671. }
  1672. if (minyear <= currentyear && currentyear <= maxyear) {
  1673. for (var currentYearPrefix = currentyear.toString().slice(0, 2); maxyear < currentYearPrefix + hint; ) currentYearPrefix--;
  1674. var currentYearAndHint = currentYearPrefix + hint;
  1675. return currentYearAndHint < minyear ? minyear : currentYearAndHint;
  1676. }
  1677. return currentyear;
  1678. },
  1679. onKeyDown: function(e, buffer, caretPos, opts) {
  1680. var $input = $(this);
  1681. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  1682. var today = new Date();
  1683. $input.val(today.getDate().toString() + (today.getMonth() + 1).toString() + today.getFullYear().toString()),
  1684. $input.trigger("setvalue");
  1685. }
  1686. },
  1687. getFrontValue: function(mask, buffer, opts) {
  1688. for (var start = 0, length = 0, i = 0; i < mask.length && "2" !== mask.charAt(i); i++) {
  1689. var definition = opts.definitions[mask.charAt(i)];
  1690. definition ? (start += length, length = definition.cardinality) : length++;
  1691. }
  1692. return buffer.join("").substr(start, length);
  1693. },
  1694. postValidation: function(buffer, currentResult, opts) {
  1695. var dayMonthValue, year, bufferStr = buffer.join("");
  1696. return 0 === opts.mask.indexOf("y") ? (year = bufferStr.substr(0, 4), dayMonthValue = bufferStr.substr(4, 11)) : (year = bufferStr.substr(6, 11),
  1697. dayMonthValue = bufferStr.substr(0, 6)), currentResult && (dayMonthValue !== opts.leapday || isLeapYear(year));
  1698. },
  1699. definitions: {
  1700. "1": {
  1701. validator: function(chrs, maskset, pos, strict, opts) {
  1702. var isValid = opts.regex.val1.test(chrs);
  1703. return strict || isValid || chrs.charAt(1) !== opts.separator && -1 === "-./".indexOf(chrs.charAt(1)) || !(isValid = opts.regex.val1.test("0" + chrs.charAt(0))) ? isValid : (maskset.buffer[pos - 1] = "0",
  1704. {
  1705. refreshFromBuffer: {
  1706. start: pos - 1,
  1707. end: pos
  1708. },
  1709. pos: pos,
  1710. c: chrs.charAt(0)
  1711. });
  1712. },
  1713. cardinality: 2,
  1714. prevalidator: [ {
  1715. validator: function(chrs, maskset, pos, strict, opts) {
  1716. var pchrs = chrs;
  1717. isNaN(maskset.buffer[pos + 1]) || (pchrs += maskset.buffer[pos + 1]);
  1718. var isValid = 1 === pchrs.length ? opts.regex.val1pre.test(pchrs) : opts.regex.val1.test(pchrs);
  1719. if (!strict && !isValid) {
  1720. if (isValid = opts.regex.val1.test(chrs + "0")) return maskset.buffer[pos] = chrs,
  1721. maskset.buffer[++pos] = "0", {
  1722. pos: pos,
  1723. c: "0"
  1724. };
  1725. if (isValid = opts.regex.val1.test("0" + chrs)) return maskset.buffer[pos] = "0",
  1726. pos++, {
  1727. pos: pos
  1728. };
  1729. }
  1730. return isValid;
  1731. },
  1732. cardinality: 1
  1733. } ]
  1734. },
  1735. "2": {
  1736. validator: function(chrs, maskset, pos, strict, opts) {
  1737. var frontValue = opts.getFrontValue(maskset.mask, maskset.buffer, opts);
  1738. -1 !== frontValue.indexOf(opts.placeholder[0]) && (frontValue = "01" + opts.separator);
  1739. var isValid = opts.regex.val2(opts.separator).test(frontValue + chrs);
  1740. return strict || isValid || chrs.charAt(1) !== opts.separator && -1 === "-./".indexOf(chrs.charAt(1)) || !(isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs.charAt(0))) ? isValid : (maskset.buffer[pos - 1] = "0",
  1741. {
  1742. refreshFromBuffer: {
  1743. start: pos - 1,
  1744. end: pos
  1745. },
  1746. pos: pos,
  1747. c: chrs.charAt(0)
  1748. });
  1749. },
  1750. cardinality: 2,
  1751. prevalidator: [ {
  1752. validator: function(chrs, maskset, pos, strict, opts) {
  1753. isNaN(maskset.buffer[pos + 1]) || (chrs += maskset.buffer[pos + 1]);
  1754. var frontValue = opts.getFrontValue(maskset.mask, maskset.buffer, opts);
  1755. -1 !== frontValue.indexOf(opts.placeholder[0]) && (frontValue = "01" + opts.separator);
  1756. var isValid = 1 === chrs.length ? opts.regex.val2pre(opts.separator).test(frontValue + chrs) : opts.regex.val2(opts.separator).test(frontValue + chrs);
  1757. return strict || isValid || !(isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
  1758. pos++, {
  1759. pos: pos
  1760. });
  1761. },
  1762. cardinality: 1
  1763. } ]
  1764. },
  1765. y: {
  1766. validator: function(chrs, maskset, pos, strict, opts) {
  1767. return opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1768. },
  1769. cardinality: 4,
  1770. prevalidator: [ {
  1771. validator: function(chrs, maskset, pos, strict, opts) {
  1772. var isValid = opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1773. if (!strict && !isValid) {
  1774. var yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs + "0").toString().slice(0, 1);
  1775. if (isValid = opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) return maskset.buffer[pos++] = yearPrefix.charAt(0),
  1776. {
  1777. pos: pos
  1778. };
  1779. if (yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs + "0").toString().slice(0, 2),
  1780. isValid = opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) return maskset.buffer[pos++] = yearPrefix.charAt(0),
  1781. maskset.buffer[pos++] = yearPrefix.charAt(1), {
  1782. pos: pos
  1783. };
  1784. }
  1785. return isValid;
  1786. },
  1787. cardinality: 1
  1788. }, {
  1789. validator: function(chrs, maskset, pos, strict, opts) {
  1790. var isValid = opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1791. if (!strict && !isValid) {
  1792. var yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs).toString().slice(0, 2);
  1793. if (isValid = opts.isInYearRange(chrs[0] + yearPrefix[1] + chrs[1], opts.yearrange.minyear, opts.yearrange.maxyear)) return maskset.buffer[pos++] = yearPrefix.charAt(1),
  1794. {
  1795. pos: pos
  1796. };
  1797. if (yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs).toString().slice(0, 2),
  1798. isValid = opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) return maskset.buffer[pos - 1] = yearPrefix.charAt(0),
  1799. maskset.buffer[pos++] = yearPrefix.charAt(1), maskset.buffer[pos++] = chrs.charAt(0),
  1800. {
  1801. refreshFromBuffer: {
  1802. start: pos - 3,
  1803. end: pos
  1804. },
  1805. pos: pos
  1806. };
  1807. }
  1808. return isValid;
  1809. },
  1810. cardinality: 2
  1811. }, {
  1812. validator: function(chrs, maskset, pos, strict, opts) {
  1813. return opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1814. },
  1815. cardinality: 3
  1816. } ]
  1817. }
  1818. },
  1819. insertMode: !1,
  1820. autoUnmask: !1
  1821. },
  1822. "mm/dd/yyyy": {
  1823. placeholder: "mm/dd/yyyy",
  1824. alias: "dd/mm/yyyy",
  1825. regex: {
  1826. val2pre: function(separator) {
  1827. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1828. return new RegExp("((0[13-9]|1[012])" + escapedSeparator + "[0-3])|(02" + escapedSeparator + "[0-2])");
  1829. },
  1830. val2: function(separator) {
  1831. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1832. return new RegExp("((0[1-9]|1[012])" + escapedSeparator + "(0[1-9]|[12][0-9]))|((0[13-9]|1[012])" + escapedSeparator + "30)|((0[13578]|1[02])" + escapedSeparator + "31)");
  1833. },
  1834. val1pre: new RegExp("[01]"),
  1835. val1: new RegExp("0[1-9]|1[012]")
  1836. },
  1837. leapday: "02/29/",
  1838. onKeyDown: function(e, buffer, caretPos, opts) {
  1839. var $input = $(this);
  1840. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  1841. var today = new Date();
  1842. $input.val((today.getMonth() + 1).toString() + today.getDate().toString() + today.getFullYear().toString()),
  1843. $input.trigger("setvalue");
  1844. }
  1845. }
  1846. },
  1847. "yyyy/mm/dd": {
  1848. mask: "y/1/2",
  1849. placeholder: "yyyy/mm/dd",
  1850. alias: "mm/dd/yyyy",
  1851. leapday: "/02/29",
  1852. onKeyDown: function(e, buffer, caretPos, opts) {
  1853. var $input = $(this);
  1854. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  1855. var today = new Date();
  1856. $input.val(today.getFullYear().toString() + (today.getMonth() + 1).toString() + today.getDate().toString()),
  1857. $input.trigger("setvalue");
  1858. }
  1859. }
  1860. },
  1861. "dd.mm.yyyy": {
  1862. mask: "1.2.y",
  1863. placeholder: "dd.mm.yyyy",
  1864. leapday: "29.02.",
  1865. separator: ".",
  1866. alias: "dd/mm/yyyy"
  1867. },
  1868. "dd-mm-yyyy": {
  1869. mask: "1-2-y",
  1870. placeholder: "dd-mm-yyyy",
  1871. leapday: "29-02-",
  1872. separator: "-",
  1873. alias: "dd/mm/yyyy"
  1874. },
  1875. "mm.dd.yyyy": {
  1876. mask: "1.2.y",
  1877. placeholder: "mm.dd.yyyy",
  1878. leapday: "02.29.",
  1879. separator: ".",
  1880. alias: "mm/dd/yyyy"
  1881. },
  1882. "mm-dd-yyyy": {
  1883. mask: "1-2-y",
  1884. placeholder: "mm-dd-yyyy",
  1885. leapday: "02-29-",
  1886. separator: "-",
  1887. alias: "mm/dd/yyyy"
  1888. },
  1889. "yyyy.mm.dd": {
  1890. mask: "y.1.2",
  1891. placeholder: "yyyy.mm.dd",
  1892. leapday: ".02.29",
  1893. separator: ".",
  1894. alias: "yyyy/mm/dd"
  1895. },
  1896. "yyyy-mm-dd": {
  1897. mask: "y-1-2",
  1898. placeholder: "yyyy-mm-dd",
  1899. leapday: "-02-29",
  1900. separator: "-",
  1901. alias: "yyyy/mm/dd"
  1902. },
  1903. datetime: {
  1904. mask: "1/2/y h:s",
  1905. placeholder: "dd/mm/yyyy hh:mm",
  1906. alias: "dd/mm/yyyy",
  1907. regex: {
  1908. hrspre: new RegExp("[012]"),
  1909. hrs24: new RegExp("2[0-4]|1[3-9]"),
  1910. hrs: new RegExp("[01][0-9]|2[0-4]"),
  1911. ampm: new RegExp("^[a|p|A|P][m|M]"),
  1912. mspre: new RegExp("[0-5]"),
  1913. ms: new RegExp("[0-5][0-9]")
  1914. },
  1915. timeseparator: ":",
  1916. hourFormat: "24",
  1917. definitions: {
  1918. h: {
  1919. validator: function(chrs, maskset, pos, strict, opts) {
  1920. if ("24" === opts.hourFormat && 24 === parseInt(chrs, 10)) return maskset.buffer[pos - 1] = "0",
  1921. maskset.buffer[pos] = "0", {
  1922. refreshFromBuffer: {
  1923. start: pos - 1,
  1924. end: pos
  1925. },
  1926. c: "0"
  1927. };
  1928. var isValid = opts.regex.hrs.test(chrs);
  1929. if (!strict && !isValid && (chrs.charAt(1) === opts.timeseparator || -1 !== "-.:".indexOf(chrs.charAt(1))) && (isValid = opts.regex.hrs.test("0" + chrs.charAt(0)))) return maskset.buffer[pos - 1] = "0",
  1930. maskset.buffer[pos] = chrs.charAt(0), pos++, {
  1931. refreshFromBuffer: {
  1932. start: pos - 2,
  1933. end: pos
  1934. },
  1935. pos: pos,
  1936. c: opts.timeseparator
  1937. };
  1938. if (isValid && "24" !== opts.hourFormat && opts.regex.hrs24.test(chrs)) {
  1939. var tmp = parseInt(chrs, 10);
  1940. return 24 === tmp ? (maskset.buffer[pos + 5] = "a", maskset.buffer[pos + 6] = "m") : (maskset.buffer[pos + 5] = "p",
  1941. maskset.buffer[pos + 6] = "m"), tmp -= 12, tmp < 10 ? (maskset.buffer[pos] = tmp.toString(),
  1942. maskset.buffer[pos - 1] = "0") : (maskset.buffer[pos] = tmp.toString().charAt(1),
  1943. maskset.buffer[pos - 1] = tmp.toString().charAt(0)), {
  1944. refreshFromBuffer: {
  1945. start: pos - 1,
  1946. end: pos + 6
  1947. },
  1948. c: maskset.buffer[pos]
  1949. };
  1950. }
  1951. return isValid;
  1952. },
  1953. cardinality: 2,
  1954. prevalidator: [ {
  1955. validator: function(chrs, maskset, pos, strict, opts) {
  1956. var isValid = opts.regex.hrspre.test(chrs);
  1957. return strict || isValid || !(isValid = opts.regex.hrs.test("0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
  1958. pos++, {
  1959. pos: pos
  1960. });
  1961. },
  1962. cardinality: 1
  1963. } ]
  1964. },
  1965. s: {
  1966. validator: "[0-5][0-9]",
  1967. cardinality: 2,
  1968. prevalidator: [ {
  1969. validator: function(chrs, maskset, pos, strict, opts) {
  1970. var isValid = opts.regex.mspre.test(chrs);
  1971. return strict || isValid || !(isValid = opts.regex.ms.test("0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
  1972. pos++, {
  1973. pos: pos
  1974. });
  1975. },
  1976. cardinality: 1
  1977. } ]
  1978. },
  1979. t: {
  1980. validator: function(chrs, maskset, pos, strict, opts) {
  1981. return opts.regex.ampm.test(chrs + "m");
  1982. },
  1983. casing: "lower",
  1984. cardinality: 1
  1985. }
  1986. },
  1987. insertMode: !1,
  1988. autoUnmask: !1
  1989. },
  1990. datetime12: {
  1991. mask: "1/2/y h:s t\\m",
  1992. placeholder: "dd/mm/yyyy hh:mm xm",
  1993. alias: "datetime",
  1994. hourFormat: "12"
  1995. },
  1996. "mm/dd/yyyy hh:mm xm": {
  1997. mask: "1/2/y h:s t\\m",
  1998. placeholder: "mm/dd/yyyy hh:mm xm",
  1999. alias: "datetime12",
  2000. regex: {
  2001. val2pre: function(separator) {
  2002. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2003. return new RegExp("((0[13-9]|1[012])" + escapedSeparator + "[0-3])|(02" + escapedSeparator + "[0-2])");
  2004. },
  2005. val2: function(separator) {
  2006. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2007. return new RegExp("((0[1-9]|1[012])" + escapedSeparator + "(0[1-9]|[12][0-9]))|((0[13-9]|1[012])" + escapedSeparator + "30)|((0[13578]|1[02])" + escapedSeparator + "31)");
  2008. },
  2009. val1pre: new RegExp("[01]"),
  2010. val1: new RegExp("0[1-9]|1[012]")
  2011. },
  2012. leapday: "02/29/",
  2013. onKeyDown: function(e, buffer, caretPos, opts) {
  2014. var $input = $(this);
  2015. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  2016. var today = new Date();
  2017. $input.val((today.getMonth() + 1).toString() + today.getDate().toString() + today.getFullYear().toString()),
  2018. $input.trigger("setvalue");
  2019. }
  2020. }
  2021. },
  2022. "hh:mm t": {
  2023. mask: "h:s t\\m",
  2024. placeholder: "hh:mm xm",
  2025. alias: "datetime",
  2026. hourFormat: "12"
  2027. },
  2028. "h:s t": {
  2029. mask: "h:s t\\m",
  2030. placeholder: "hh:mm xm",
  2031. alias: "datetime",
  2032. hourFormat: "12"
  2033. },
  2034. "hh:mm:ss": {
  2035. mask: "h:s:s",
  2036. placeholder: "hh:mm:ss",
  2037. alias: "datetime",
  2038. autoUnmask: !1
  2039. },
  2040. "hh:mm": {
  2041. mask: "h:s",
  2042. placeholder: "hh:mm",
  2043. alias: "datetime",
  2044. autoUnmask: !1
  2045. },
  2046. date: {
  2047. alias: "dd/mm/yyyy"
  2048. },
  2049. "mm/yyyy": {
  2050. mask: "1/y",
  2051. placeholder: "mm/yyyy",
  2052. leapday: "donotuse",
  2053. separator: "/",
  2054. alias: "mm/dd/yyyy"
  2055. },
  2056. shamsi: {
  2057. regex: {
  2058. val2pre: function(separator) {
  2059. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2060. return new RegExp("((0[1-9]|1[012])" + escapedSeparator + "[0-3])");
  2061. },
  2062. val2: function(separator) {
  2063. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2064. return new RegExp("((0[1-9]|1[012])" + escapedSeparator + "(0[1-9]|[12][0-9]))|((0[1-9]|1[012])" + escapedSeparator + "30)|((0[1-6])" + escapedSeparator + "31)");
  2065. },
  2066. val1pre: new RegExp("[01]"),
  2067. val1: new RegExp("0[1-9]|1[012]")
  2068. },
  2069. yearrange: {
  2070. minyear: 1300,
  2071. maxyear: 1499
  2072. },
  2073. mask: "y/1/2",
  2074. leapday: "/12/30",
  2075. placeholder: "yyyy/mm/dd",
  2076. alias: "mm/dd/yyyy",
  2077. clearIncomplete: !0
  2078. },
  2079. "yyyy-mm-dd hh:mm:ss": {
  2080. mask: "y-1-2 h:s:s",
  2081. placeholder: "yyyy-mm-dd hh:mm:ss",
  2082. alias: "datetime",
  2083. separator: "-",
  2084. leapday: "-02-29",
  2085. regex: {
  2086. val2pre: function(separator) {
  2087. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2088. return new RegExp("((0[13-9]|1[012])" + escapedSeparator + "[0-3])|(02" + escapedSeparator + "[0-2])");
  2089. },
  2090. val2: function(separator) {
  2091. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2092. return new RegExp("((0[1-9]|1[012])" + escapedSeparator + "(0[1-9]|[12][0-9]))|((0[13-9]|1[012])" + escapedSeparator + "30)|((0[13578]|1[02])" + escapedSeparator + "31)");
  2093. },
  2094. val1pre: new RegExp("[01]"),
  2095. val1: new RegExp("0[1-9]|1[012]")
  2096. },
  2097. onKeyDown: function(e, buffer, caretPos, opts) {}
  2098. }
  2099. });
  2100. }(window.dependencyLib || jQuery, window.Inputmask);
  2101. }(), function(factory) {
  2102. !function($, Inputmask) {
  2103. Inputmask.extendDefinitions({
  2104. A: {
  2105. validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  2106. cardinality: 1,
  2107. casing: "upper"
  2108. },
  2109. "&": {
  2110. validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  2111. cardinality: 1,
  2112. casing: "upper"
  2113. },
  2114. "#": {
  2115. validator: "[0-9A-Fa-f]",
  2116. cardinality: 1,
  2117. casing: "upper"
  2118. }
  2119. }), Inputmask.extendAliases({
  2120. url: {
  2121. definitions: {
  2122. i: {
  2123. validator: ".",
  2124. cardinality: 1
  2125. }
  2126. },
  2127. mask: "(\\http://)|(\\http\\s://)|(ftp://)|(ftp\\s://)i{+}",
  2128. insertMode: !1,
  2129. autoUnmask: !1,
  2130. inputmode: "url"
  2131. },
  2132. ip: {
  2133. mask: "i[i[i]].i[i[i]].i[i[i]].i[i[i]]",
  2134. definitions: {
  2135. i: {
  2136. validator: function(chrs, maskset, pos, strict, opts) {
  2137. return pos - 1 > -1 && "." !== maskset.buffer[pos - 1] ? (chrs = maskset.buffer[pos - 1] + chrs,
  2138. chrs = pos - 2 > -1 && "." !== maskset.buffer[pos - 2] ? maskset.buffer[pos - 2] + chrs : "0" + chrs) : chrs = "00" + chrs,
  2139. new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]").test(chrs);
  2140. },
  2141. cardinality: 1
  2142. }
  2143. },
  2144. onUnMask: function(maskedValue, unmaskedValue, opts) {
  2145. return maskedValue;
  2146. },
  2147. inputmode: "numeric"
  2148. },
  2149. email: {
  2150. mask: "*{1,64}[.*{1,64}][.*{1,64}][.*{1,63}]@-{1,63}.-{1,63}[.-{1,63}][.-{1,63}]",
  2151. greedy: !1,
  2152. onBeforePaste: function(pastedValue, opts) {
  2153. return pastedValue = pastedValue.toLowerCase(), pastedValue.replace("mailto:", "");
  2154. },
  2155. definitions: {
  2156. "*": {
  2157. validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~-]",
  2158. cardinality: 1,
  2159. casing: "lower"
  2160. },
  2161. "-": {
  2162. validator: "[0-9A-Za-z-]",
  2163. cardinality: 1,
  2164. casing: "lower"
  2165. }
  2166. },
  2167. onUnMask: function(maskedValue, unmaskedValue, opts) {
  2168. return maskedValue;
  2169. },
  2170. inputmode: "email"
  2171. },
  2172. mac: {
  2173. mask: "##:##:##:##:##:##"
  2174. },
  2175. vin: {
  2176. mask: "V{13}9{4}",
  2177. definitions: {
  2178. V: {
  2179. validator: "[A-HJ-NPR-Za-hj-npr-z\\d]",
  2180. cardinality: 1,
  2181. casing: "upper"
  2182. }
  2183. },
  2184. clearIncomplete: !0,
  2185. autoUnmask: !0
  2186. }
  2187. });
  2188. }(window.dependencyLib || jQuery, window.Inputmask);
  2189. }(), function(factory) {
  2190. !function($, Inputmask, undefined) {
  2191. function autoEscape(txt, opts) {
  2192. for (var escapedTxt = "", i = 0; i < txt.length; i++) opts.definitions[txt.charAt(i)] || opts.optionalmarker.start === txt.charAt(i) || opts.optionalmarker.end === txt.charAt(i) || opts.quantifiermarker.start === txt.charAt(i) || opts.quantifiermarker.end === txt.charAt(i) || opts.groupmarker.start === txt.charAt(i) || opts.groupmarker.end === txt.charAt(i) || opts.alternatormarker === txt.charAt(i) ? escapedTxt += "\\" + txt.charAt(i) : escapedTxt += txt.charAt(i);
  2193. return escapedTxt;
  2194. }
  2195. Inputmask.extendAliases({
  2196. numeric: {
  2197. mask: function(opts) {
  2198. if (0 !== opts.repeat && isNaN(opts.integerDigits) && (opts.integerDigits = opts.repeat),
  2199. opts.repeat = 0, opts.groupSeparator === opts.radixPoint && ("." === opts.radixPoint ? opts.groupSeparator = "," : "," === opts.radixPoint ? opts.groupSeparator = "." : opts.groupSeparator = ""),
  2200. " " === opts.groupSeparator && (opts.skipOptionalPartCharacter = undefined), opts.autoGroup = opts.autoGroup && "" !== opts.groupSeparator,
  2201. opts.autoGroup && ("string" == typeof opts.groupSize && isFinite(opts.groupSize) && (opts.groupSize = parseInt(opts.groupSize)),
  2202. isFinite(opts.integerDigits))) {
  2203. var seps = Math.floor(opts.integerDigits / opts.groupSize), mod = opts.integerDigits % opts.groupSize;
  2204. opts.integerDigits = parseInt(opts.integerDigits) + (0 === mod ? seps - 1 : seps),
  2205. opts.integerDigits < 1 && (opts.integerDigits = "*");
  2206. }
  2207. opts.placeholder.length > 1 && (opts.placeholder = opts.placeholder.charAt(0)),
  2208. "radixFocus" === opts.positionCaretOnClick && "" === opts.placeholder && !1 === opts.integerOptional && (opts.positionCaretOnClick = "lvp"),
  2209. opts.definitions[";"] = opts.definitions["~"], opts.definitions[";"].definitionSymbol = "~",
  2210. !0 === opts.numericInput && (opts.positionCaretOnClick = "radixFocus" === opts.positionCaretOnClick ? "lvp" : opts.positionCaretOnClick,
  2211. opts.digitsOptional = !1, isNaN(opts.digits) && (opts.digits = 2), opts.decimalProtect = !1);
  2212. var mask = "[+]";
  2213. if (mask += autoEscape(opts.prefix, opts), !0 === opts.integerOptional ? mask += "~{1," + opts.integerDigits + "}" : mask += "~{" + opts.integerDigits + "}",
  2214. opts.digits !== undefined) {
  2215. opts.radixPointDefinitionSymbol = opts.decimalProtect ? ":" : opts.radixPoint;
  2216. var dq = opts.digits.toString().split(",");
  2217. isFinite(dq[0] && dq[1] && isFinite(dq[1])) ? mask += opts.radixPointDefinitionSymbol + ";{" + opts.digits + "}" : (isNaN(opts.digits) || parseInt(opts.digits) > 0) && (opts.digitsOptional ? mask += "[" + opts.radixPointDefinitionSymbol + ";{1," + opts.digits + "}]" : mask += opts.radixPointDefinitionSymbol + ";{" + opts.digits + "}");
  2218. }
  2219. return mask += autoEscape(opts.suffix, opts), mask += "[-]", opts.greedy = !1, mask;
  2220. },
  2221. placeholder: "",
  2222. greedy: !1,
  2223. digits: "*",
  2224. digitsOptional: !0,
  2225. radixPoint: ".",
  2226. positionCaretOnClick: "radixFocus",
  2227. groupSize: 3,
  2228. groupSeparator: "",
  2229. autoGroup: !1,
  2230. allowMinus: !0,
  2231. negationSymbol: {
  2232. front: "-",
  2233. back: ""
  2234. },
  2235. integerDigits: "+",
  2236. integerOptional: !0,
  2237. prefix: "",
  2238. suffix: "",
  2239. rightAlign: !0,
  2240. decimalProtect: !0,
  2241. min: null,
  2242. max: null,
  2243. step: 1,
  2244. insertMode: !0,
  2245. autoUnmask: !1,
  2246. unmaskAsNumber: !1,
  2247. inputmode: "numeric",
  2248. preValidation: function(buffer, pos, c, isSelection, opts) {
  2249. if ("-" === c || c == opts.negationSymbol.front) return !0 === opts.allowMinus && (opts.isNegative = opts.isNegative === undefined || !opts.isNegative,
  2250. "" === buffer.join("") || {
  2251. caret: pos,
  2252. dopost: !0
  2253. });
  2254. if (!1 === isSelection && c === opts.radixPoint && opts.digits !== undefined && (isNaN(opts.digits) || parseInt(opts.digits) > 0)) {
  2255. var radixPos = $.inArray(opts.radixPoint, buffer);
  2256. if (-1 !== radixPos) return !0 === opts.numericInput ? pos === radixPos : {
  2257. caret: radixPos + 1
  2258. };
  2259. }
  2260. return !0;
  2261. },
  2262. postValidation: function(buffer, currentResult, opts) {
  2263. var suffix = opts.suffix.split(""), prefix = opts.prefix.split("");
  2264. if (currentResult.pos == undefined && currentResult.caret !== undefined && !0 !== currentResult.dopost) return currentResult;
  2265. var caretPos = currentResult.caret != undefined ? currentResult.caret : currentResult.pos, maskedValue = buffer.slice();
  2266. opts.numericInput && (caretPos = maskedValue.length - caretPos - 1, maskedValue = maskedValue.reverse());
  2267. var charAtPos = maskedValue[caretPos];
  2268. if (charAtPos === opts.groupSeparator && (caretPos += 1, charAtPos = maskedValue[caretPos]),
  2269. caretPos == maskedValue.length - opts.suffix.length - 1 && charAtPos === opts.radixPoint) return currentResult;
  2270. charAtPos !== undefined && charAtPos !== opts.radixPoint && charAtPos !== opts.negationSymbol.front && charAtPos !== opts.negationSymbol.back && (maskedValue[caretPos] = "?",
  2271. opts.prefix.length > 0 && caretPos >= (!1 === opts.isNegative ? 1 : 0) && caretPos < opts.prefix.length - 1 + (!1 === opts.isNegative ? 1 : 0) ? prefix[caretPos - (!1 === opts.isNegative ? 1 : 0)] = "?" : opts.suffix.length > 0 && caretPos >= maskedValue.length - opts.suffix.length - (!1 === opts.isNegative ? 1 : 0) && (suffix[caretPos - (maskedValue.length - opts.suffix.length - (!1 === opts.isNegative ? 1 : 0))] = "?")),
  2272. prefix = prefix.join(""), suffix = suffix.join("");
  2273. var processValue = maskedValue.join("").replace(prefix, "");
  2274. if (processValue = processValue.replace(suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2275. processValue = processValue.replace(new RegExp("[-" + Inputmask.escapeRegex(opts.negationSymbol.front) + "]", "g"), ""),
  2276. processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), ""),
  2277. isNaN(opts.placeholder) && (processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.placeholder), "g"), "")),
  2278. processValue.length > 1 && 1 !== processValue.indexOf(opts.radixPoint) && ("0" == charAtPos && (processValue = processValue.replace(/^\?/g, "")),
  2279. processValue = processValue.replace(/^0/g, "")), processValue.charAt(0) === opts.radixPoint && !0 !== opts.numericInput && (processValue = "0" + processValue),
  2280. "" !== processValue) {
  2281. if (processValue = processValue.split(""), !opts.digitsOptional && isFinite(opts.digits)) {
  2282. var radixPosition = $.inArray(opts.radixPoint, processValue), rpb = $.inArray(opts.radixPoint, maskedValue);
  2283. -1 === radixPosition && (processValue.push(opts.radixPoint), radixPosition = processValue.length - 1);
  2284. for (var i = 1; i <= opts.digits; i++) opts.digitsOptional || processValue[radixPosition + i] !== undefined && processValue[radixPosition + i] !== opts.placeholder.charAt(0) ? -1 !== rpb && maskedValue[rpb + i] !== undefined && (processValue[radixPosition + i] = processValue[radixPosition + i] || maskedValue[rpb + i]) : processValue[radixPosition + i] = currentResult.placeholder || opts.placeholder.charAt(0);
  2285. }
  2286. !0 !== opts.autoGroup || "" === opts.groupSeparator || charAtPos === opts.radixPoint && currentResult.pos === undefined && !currentResult.dopost ? processValue = processValue.join("") : (processValue = Inputmask(function(buffer, opts) {
  2287. var postMask = "";
  2288. if (postMask += "(" + opts.groupSeparator + "*{" + opts.groupSize + "}){*}", "" !== opts.radixPoint) {
  2289. var radixSplit = buffer.join("").split(opts.radixPoint);
  2290. radixSplit[1] && (postMask += opts.radixPoint + "*{" + radixSplit[1].match(/^\d*\??\d*/)[0].length + "}");
  2291. }
  2292. return postMask;
  2293. }(processValue, opts), {
  2294. numericInput: !0,
  2295. jitMasking: !0,
  2296. definitions: {
  2297. "*": {
  2298. validator: "[0-9?]",
  2299. cardinality: 1
  2300. }
  2301. }
  2302. }).format(processValue.join("")), processValue.charAt(0) === opts.groupSeparator && processValue.substr(1));
  2303. }
  2304. if (opts.isNegative && "blur" === currentResult.event && (opts.isNegative = "0" !== processValue),
  2305. processValue = prefix + processValue, processValue += suffix, opts.isNegative && (processValue = opts.negationSymbol.front + processValue,
  2306. processValue += opts.negationSymbol.back), processValue = processValue.split(""),
  2307. charAtPos !== undefined) if (charAtPos !== opts.radixPoint && charAtPos !== opts.negationSymbol.front && charAtPos !== opts.negationSymbol.back) caretPos = $.inArray("?", processValue),
  2308. caretPos > -1 ? processValue[caretPos] = charAtPos : caretPos = currentResult.caret || 0; else if (charAtPos === opts.radixPoint || charAtPos === opts.negationSymbol.front || charAtPos === opts.negationSymbol.back) {
  2309. var newCaretPos = $.inArray(charAtPos, processValue);
  2310. -1 !== newCaretPos && (caretPos = newCaretPos);
  2311. }
  2312. opts.numericInput && (caretPos = processValue.length - caretPos - 1, processValue = processValue.reverse());
  2313. var rslt = {
  2314. caret: charAtPos === undefined || currentResult.pos !== undefined ? caretPos + (opts.numericInput ? -1 : 1) : caretPos,
  2315. buffer: processValue,
  2316. refreshFromBuffer: currentResult.dopost || buffer.join("") !== processValue.join("")
  2317. };
  2318. return rslt.refreshFromBuffer ? rslt : currentResult;
  2319. },
  2320. onBeforeWrite: function(e, buffer, caretPos, opts) {
  2321. if (e) switch (e.type) {
  2322. case "keydown":
  2323. return opts.postValidation(buffer, {
  2324. caret: caretPos,
  2325. dopost: !0
  2326. }, opts);
  2327. case "blur":
  2328. case "checkval":
  2329. var unmasked;
  2330. if (function(opts) {
  2331. opts.parseMinMaxOptions === undefined && (null !== opts.min && (opts.min = opts.min.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2332. "," === opts.radixPoint && (opts.min = opts.min.replace(opts.radixPoint, ".")),
  2333. opts.min = isFinite(opts.min) ? parseFloat(opts.min) : NaN, isNaN(opts.min) && (opts.min = Number.MIN_VALUE)),
  2334. null !== opts.max && (opts.max = opts.max.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2335. "," === opts.radixPoint && (opts.max = opts.max.replace(opts.radixPoint, ".")),
  2336. opts.max = isFinite(opts.max) ? parseFloat(opts.max) : NaN, isNaN(opts.max) && (opts.max = Number.MAX_VALUE)),
  2337. opts.parseMinMaxOptions = "done");
  2338. }(opts), null !== opts.min || null !== opts.max) {
  2339. if (unmasked = opts.onUnMask(buffer.join(""), undefined, $.extend({}, opts, {
  2340. unmaskAsNumber: !0
  2341. })), null !== opts.min && unmasked < opts.min) return opts.isNegative = opts.min < 0,
  2342. opts.postValidation(opts.min.toString().replace(".", opts.radixPoint).split(""), {
  2343. caret: caretPos,
  2344. dopost: !0,
  2345. placeholder: "0"
  2346. }, opts);
  2347. if (null !== opts.max && unmasked > opts.max) return opts.isNegative = opts.max < 0,
  2348. opts.postValidation(opts.max.toString().replace(".", opts.radixPoint).split(""), {
  2349. caret: caretPos,
  2350. dopost: !0,
  2351. placeholder: "0"
  2352. }, opts);
  2353. }
  2354. return opts.postValidation(buffer, {
  2355. caret: caretPos,
  2356. dopost: !0,
  2357. placeholder: "0",
  2358. event: "blur"
  2359. }, opts);
  2360. case "_checkval":
  2361. return {
  2362. caret: caretPos
  2363. };
  2364. }
  2365. },
  2366. regex: {
  2367. integerPart: function(opts, emptyCheck) {
  2368. return emptyCheck ? new RegExp("[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "+]?") : new RegExp("[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "+]?\\d+");
  2369. },
  2370. integerNPart: function(opts) {
  2371. return new RegExp("[\\d" + Inputmask.escapeRegex(opts.groupSeparator) + Inputmask.escapeRegex(opts.placeholder.charAt(0)) + "]+");
  2372. }
  2373. },
  2374. definitions: {
  2375. "~": {
  2376. validator: function(chrs, maskset, pos, strict, opts, isSelection) {
  2377. var isValid = strict ? new RegExp("[0-9" + Inputmask.escapeRegex(opts.groupSeparator) + "]").test(chrs) : new RegExp("[0-9]").test(chrs);
  2378. if (!0 === isValid) {
  2379. if (!0 !== opts.numericInput && maskset.validPositions[pos] !== undefined && "~" === maskset.validPositions[pos].match.def && !isSelection) {
  2380. var processValue = maskset.buffer.join("");
  2381. processValue = processValue.replace(new RegExp("[-" + Inputmask.escapeRegex(opts.negationSymbol.front) + "]", "g"), ""),
  2382. processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), ""),
  2383. processValue = processValue.replace(/0/g, opts.placeholder.charAt(0));
  2384. var bufferTemplate = maskset._buffer.join("");
  2385. for (processValue === opts.radixPoint && (processValue = bufferTemplate); null === processValue.match(Inputmask.escapeRegex(bufferTemplate) + "$"); ) bufferTemplate = bufferTemplate.slice(1);
  2386. processValue = processValue.replace(bufferTemplate, ""), processValue = processValue.split(""),
  2387. isValid = processValue[pos] === undefined ? {
  2388. pos: pos,
  2389. remove: pos
  2390. } : {
  2391. pos: pos
  2392. };
  2393. }
  2394. } else strict || chrs !== opts.radixPoint || maskset.validPositions[pos - 1] !== undefined || (maskset.buffer[pos] = "0",
  2395. isValid = {
  2396. pos: pos + 1
  2397. });
  2398. return isValid;
  2399. },
  2400. cardinality: 1
  2401. },
  2402. "+": {
  2403. validator: function(chrs, maskset, pos, strict, opts) {
  2404. return opts.allowMinus && ("-" === chrs || chrs === opts.negationSymbol.front);
  2405. },
  2406. cardinality: 1,
  2407. placeholder: ""
  2408. },
  2409. "-": {
  2410. validator: function(chrs, maskset, pos, strict, opts) {
  2411. return opts.allowMinus && chrs === opts.negationSymbol.back;
  2412. },
  2413. cardinality: 1,
  2414. placeholder: ""
  2415. },
  2416. ":": {
  2417. validator: function(chrs, maskset, pos, strict, opts) {
  2418. var radix = "[" + Inputmask.escapeRegex(opts.radixPoint) + "]", isValid = new RegExp(radix).test(chrs);
  2419. return isValid && maskset.validPositions[pos] && maskset.validPositions[pos].match.placeholder === opts.radixPoint && (isValid = {
  2420. caret: pos + 1
  2421. }), isValid;
  2422. },
  2423. cardinality: 1,
  2424. placeholder: function(opts) {
  2425. return opts.radixPoint;
  2426. }
  2427. }
  2428. },
  2429. onUnMask: function(maskedValue, unmaskedValue, opts) {
  2430. if ("" === unmaskedValue && !0 === opts.nullable) return unmaskedValue;
  2431. var processValue = maskedValue.replace(opts.prefix, "");
  2432. return processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2433. "" !== opts.placeholder.charAt(0) && (processValue = processValue.replace(new RegExp(opts.placeholder.charAt(0), "g"), "0")),
  2434. opts.unmaskAsNumber ? ("" !== opts.radixPoint && -1 !== processValue.indexOf(opts.radixPoint) && (processValue = processValue.replace(Inputmask.escapeRegex.call(this, opts.radixPoint), ".")),
  2435. Number(processValue)) : processValue;
  2436. },
  2437. isComplete: function(buffer, opts) {
  2438. var maskedValue = buffer.join("");
  2439. if (buffer.slice().join("") !== maskedValue) return !1;
  2440. var processValue = maskedValue.replace(opts.prefix, "");
  2441. return processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2442. "," === opts.radixPoint && (processValue = processValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".")),
  2443. isFinite(processValue);
  2444. },
  2445. onBeforeMask: function(initialValue, opts) {
  2446. if (opts.isNegative = undefined, initialValue = initialValue.toString().charAt(initialValue.length - 1) === opts.radixPoint ? initialValue.toString().substr(0, initialValue.length - 1) : initialValue.toString(),
  2447. "" !== opts.radixPoint && isFinite(initialValue)) {
  2448. var vs = initialValue.split("."), groupSize = "" !== opts.groupSeparator ? parseInt(opts.groupSize) : 0;
  2449. 2 === vs.length && (vs[0].length > groupSize || vs[1].length > groupSize || vs[0].length <= groupSize && vs[1].length < groupSize) && (initialValue = initialValue.replace(".", opts.radixPoint));
  2450. }
  2451. var kommaMatches = initialValue.match(/,/g), dotMatches = initialValue.match(/\./g);
  2452. if (dotMatches && kommaMatches ? dotMatches.length > kommaMatches.length ? (initialValue = initialValue.replace(/\./g, ""),
  2453. initialValue = initialValue.replace(",", opts.radixPoint)) : kommaMatches.length > dotMatches.length ? (initialValue = initialValue.replace(/,/g, ""),
  2454. initialValue = initialValue.replace(".", opts.radixPoint)) : initialValue = initialValue.indexOf(".") < initialValue.indexOf(",") ? initialValue.replace(/\./g, "") : initialValue = initialValue.replace(/,/g, "") : initialValue = initialValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2455. 0 === opts.digits && (-1 !== initialValue.indexOf(".") ? initialValue = initialValue.substring(0, initialValue.indexOf(".")) : -1 !== initialValue.indexOf(",") && (initialValue = initialValue.substring(0, initialValue.indexOf(",")))),
  2456. "" !== opts.radixPoint && isFinite(opts.digits) && -1 !== initialValue.indexOf(opts.radixPoint)) {
  2457. var valueParts = initialValue.split(opts.radixPoint), decPart = valueParts[1].match(new RegExp("\\d*"))[0];
  2458. if (parseInt(opts.digits) < decPart.toString().length) {
  2459. var digitsFactor = Math.pow(10, parseInt(opts.digits));
  2460. initialValue = initialValue.replace(Inputmask.escapeRegex(opts.radixPoint), "."),
  2461. initialValue = Math.round(parseFloat(initialValue) * digitsFactor) / digitsFactor,
  2462. initialValue = initialValue.toString().replace(".", opts.radixPoint);
  2463. }
  2464. }
  2465. return initialValue;
  2466. },
  2467. canClearPosition: function(maskset, position, lvp, strict, opts) {
  2468. var vp = maskset.validPositions[position], canClear = vp.input !== opts.radixPoint || null !== maskset.validPositions[position].match.fn && !1 === opts.decimalProtect || vp.input === opts.radixPoint && maskset.validPositions[position + 1] && null === maskset.validPositions[position + 1].match.fn || isFinite(vp.input) || position === lvp || vp.input === opts.groupSeparator || vp.input === opts.negationSymbol.front || vp.input === opts.negationSymbol.back;
  2469. return !canClear || "+" != vp.match.nativeDef && "-" != vp.match.nativeDef || (opts.isNegative = !1),
  2470. canClear;
  2471. },
  2472. onKeyDown: function(e, buffer, caretPos, opts) {
  2473. var $input = $(this);
  2474. if (e.ctrlKey) switch (e.keyCode) {
  2475. case Inputmask.keyCode.UP:
  2476. $input.val(parseFloat(this.inputmask.unmaskedvalue()) + parseInt(opts.step)), $input.trigger("setvalue");
  2477. break;
  2478. case Inputmask.keyCode.DOWN:
  2479. $input.val(parseFloat(this.inputmask.unmaskedvalue()) - parseInt(opts.step)), $input.trigger("setvalue");
  2480. }
  2481. }
  2482. },
  2483. currency: {
  2484. prefix: "$ ",
  2485. groupSeparator: ",",
  2486. alias: "numeric",
  2487. placeholder: "0",
  2488. autoGroup: !0,
  2489. digits: 2,
  2490. digitsOptional: !1,
  2491. clearMaskOnLostFocus: !1
  2492. },
  2493. decimal: {
  2494. alias: "numeric"
  2495. },
  2496. integer: {
  2497. alias: "numeric",
  2498. digits: 0,
  2499. radixPoint: ""
  2500. },
  2501. percentage: {
  2502. alias: "numeric",
  2503. digits: 2,
  2504. digitsOptional: !0,
  2505. radixPoint: ".",
  2506. placeholder: "0",
  2507. autoGroup: !1,
  2508. min: 0,
  2509. max: 100,
  2510. suffix: " %",
  2511. allowMinus: !1
  2512. }
  2513. });
  2514. }(window.dependencyLib || jQuery, window.Inputmask);
  2515. }(), function(factory) {
  2516. !function($, Inputmask) {
  2517. function maskSort(a, b) {
  2518. var maska = (a.mask || a).replace(/#/g, "9").replace(/\)/, "9").replace(/[+()#-]/g, ""), maskb = (b.mask || b).replace(/#/g, "9").replace(/\)/, "9").replace(/[+()#-]/g, ""), maskas = (a.mask || a).split("#")[0], maskbs = (b.mask || b).split("#")[0];
  2519. return 0 === maskbs.indexOf(maskas) ? -1 : 0 === maskas.indexOf(maskbs) ? 1 : maska.localeCompare(maskb);
  2520. }
  2521. var analyseMaskBase = Inputmask.prototype.analyseMask;
  2522. Inputmask.prototype.analyseMask = function(mask, regexMask, opts) {
  2523. function reduceVariations(masks, previousVariation, previousmaskGroup) {
  2524. previousVariation = previousVariation || "", previousmaskGroup = previousmaskGroup || maskGroups,
  2525. "" !== previousVariation && (previousmaskGroup[previousVariation] = {});
  2526. for (var variation = "", maskGroup = previousmaskGroup[previousVariation] || previousmaskGroup, i = masks.length - 1; i >= 0; i--) mask = masks[i].mask || masks[i],
  2527. variation = mask.substr(0, 1), maskGroup[variation] = maskGroup[variation] || [],
  2528. maskGroup[variation].unshift(mask.substr(1)), masks.splice(i, 1);
  2529. for (var ndx in maskGroup) maskGroup[ndx].length > 500 && reduceVariations(maskGroup[ndx].slice(), ndx, maskGroup);
  2530. }
  2531. function rebuild(maskGroup) {
  2532. var mask = "", submasks = [];
  2533. for (var ndx in maskGroup) $.isArray(maskGroup[ndx]) ? 1 === maskGroup[ndx].length ? submasks.push(ndx + maskGroup[ndx]) : submasks.push(ndx + opts.groupmarker.start + maskGroup[ndx].join(opts.groupmarker.end + opts.alternatormarker + opts.groupmarker.start) + opts.groupmarker.end) : submasks.push(ndx + rebuild(maskGroup[ndx]));
  2534. return 1 === submasks.length ? mask += submasks[0] : mask += opts.groupmarker.start + submasks.join(opts.groupmarker.end + opts.alternatormarker + opts.groupmarker.start) + opts.groupmarker.end,
  2535. mask;
  2536. }
  2537. var maskGroups = {};
  2538. return opts.phoneCodes && (opts.phoneCodes && opts.phoneCodes.length > 1e3 && (mask = mask.substr(1, mask.length - 2),
  2539. reduceVariations(mask.split(opts.groupmarker.end + opts.alternatormarker + opts.groupmarker.start)),
  2540. mask = rebuild(maskGroups)), mask = mask.replace(/9/g, "\\9")), analyseMaskBase.call(this, mask, regexMask, opts);
  2541. }, Inputmask.extendAliases({
  2542. abstractphone: {
  2543. groupmarker: {
  2544. start: "<",
  2545. end: ">"
  2546. },
  2547. countrycode: "",
  2548. phoneCodes: [],
  2549. mask: function(opts) {
  2550. return opts.definitions = {
  2551. "#": Inputmask.prototype.definitions[9]
  2552. }, opts.phoneCodes.sort(maskSort);
  2553. },
  2554. keepStatic: !0,
  2555. onBeforeMask: function(value, opts) {
  2556. var processedValue = value.replace(/^0{1,2}/, "").replace(/[\s]/g, "");
  2557. return (processedValue.indexOf(opts.countrycode) > 1 || -1 === processedValue.indexOf(opts.countrycode)) && (processedValue = "+" + opts.countrycode + processedValue),
  2558. processedValue;
  2559. },
  2560. onUnMask: function(maskedValue, unmaskedValue, opts) {
  2561. return unmaskedValue;
  2562. },
  2563. inputmode: "tel"
  2564. }
  2565. });
  2566. }(window.dependencyLib || jQuery, window.Inputmask);
  2567. }(), function(factory) {
  2568. !function($, Inputmask) {
  2569. Inputmask.extendAliases({
  2570. Regex: {
  2571. mask: "r",
  2572. greedy: !1,
  2573. repeat: "*",
  2574. regex: null,
  2575. regexTokens: null,
  2576. 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,
  2577. quantifierFilter: /[0-9]+[^,]/,
  2578. isComplete: function(buffer, opts) {
  2579. return new RegExp(opts.regex, opts.casing ? "i" : "").test(buffer.join(""));
  2580. },
  2581. definitions: {
  2582. r: {
  2583. validator: function(chrs, maskset, pos, strict, opts) {
  2584. function RegexToken(isGroup, isQuantifier) {
  2585. this.matches = [], this.isGroup = isGroup || !1, this.isQuantifier = isQuantifier || !1,
  2586. this.quantifier = {
  2587. min: 1,
  2588. max: 1
  2589. }, this.repeaterPart = void 0;
  2590. }
  2591. function validateRegexToken(token, fromGroup) {
  2592. var isvalid = !1;
  2593. fromGroup && (regexPart += "(", openGroupCount++);
  2594. for (var mndx = 0; mndx < token.matches.length; mndx++) {
  2595. var matchToken = token.matches[mndx];
  2596. if (!0 === matchToken.isGroup) isvalid = validateRegexToken(matchToken, !0); else if (!0 === matchToken.isQuantifier) {
  2597. var crrntndx = $.inArray(matchToken, token.matches), matchGroup = token.matches[crrntndx - 1], regexPartBak = regexPart;
  2598. if (isNaN(matchToken.quantifier.max)) {
  2599. for (;matchToken.repeaterPart && matchToken.repeaterPart !== regexPart && matchToken.repeaterPart.length > regexPart.length && !(isvalid = validateRegexToken(matchGroup, !0)); ) ;
  2600. isvalid = isvalid || validateRegexToken(matchGroup, !0), isvalid && (matchToken.repeaterPart = regexPart),
  2601. regexPart = regexPartBak + matchToken.quantifier.max;
  2602. } else {
  2603. for (var i = 0, qm = matchToken.quantifier.max - 1; i < qm && !(isvalid = validateRegexToken(matchGroup, !0)); i++) ;
  2604. regexPart = regexPartBak + "{" + matchToken.quantifier.min + "," + matchToken.quantifier.max + "}";
  2605. }
  2606. } else if (void 0 !== matchToken.matches) for (var k = 0; k < matchToken.length && !(isvalid = validateRegexToken(matchToken[k], fromGroup)); k++) ; else {
  2607. var testExp;
  2608. if ("[" == matchToken.charAt(0)) {
  2609. testExp = regexPart, testExp += matchToken;
  2610. for (var j = 0; j < openGroupCount; j++) testExp += ")";
  2611. var exp = new RegExp("^(" + testExp + ")$", opts.casing ? "i" : "");
  2612. isvalid = exp.test(bufferStr);
  2613. } else for (var l = 0, tl = matchToken.length; l < tl; l++) if ("\\" !== matchToken.charAt(l)) {
  2614. testExp = regexPart, testExp += matchToken.substr(0, l + 1), testExp = testExp.replace(/\|$/, "");
  2615. for (var j = 0; j < openGroupCount; j++) testExp += ")";
  2616. var exp = new RegExp("^(" + testExp + ")$", opts.casing ? "i" : "");
  2617. if (isvalid = exp.test(bufferStr)) break;
  2618. }
  2619. regexPart += matchToken;
  2620. }
  2621. if (isvalid) break;
  2622. }
  2623. return fromGroup && (regexPart += ")", openGroupCount--), isvalid;
  2624. }
  2625. var bufferStr, groupToken, cbuffer = maskset.buffer.slice(), regexPart = "", isValid = !1, openGroupCount = 0;
  2626. null === opts.regexTokens && function() {
  2627. var match, m, currentToken = new RegexToken(), opengroups = [];
  2628. for (opts.regexTokens = []; match = opts.tokenizer.exec(opts.regex); ) switch (m = match[0],
  2629. m.charAt(0)) {
  2630. case "(":
  2631. opengroups.push(new RegexToken(!0));
  2632. break;
  2633. case ")":
  2634. groupToken = opengroups.pop(), opengroups.length > 0 ? opengroups[opengroups.length - 1].matches.push(groupToken) : currentToken.matches.push(groupToken);
  2635. break;
  2636. case "{":
  2637. case "+":
  2638. case "*":
  2639. var quantifierToken = new RegexToken(!1, !0);
  2640. m = m.replace(/[{}]/g, "");
  2641. var mq = m.split(","), mq0 = isNaN(mq[0]) ? mq[0] : parseInt(mq[0]), mq1 = 1 === mq.length ? mq0 : isNaN(mq[1]) ? mq[1] : parseInt(mq[1]);
  2642. if (quantifierToken.quantifier = {
  2643. min: mq0,
  2644. max: mq1
  2645. }, opengroups.length > 0) {
  2646. var matches = opengroups[opengroups.length - 1].matches;
  2647. match = matches.pop(), match.isGroup || (groupToken = new RegexToken(!0), groupToken.matches.push(match),
  2648. match = groupToken), matches.push(match), matches.push(quantifierToken);
  2649. } else match = currentToken.matches.pop(), match.isGroup || (groupToken = new RegexToken(!0),
  2650. groupToken.matches.push(match), match = groupToken), currentToken.matches.push(match),
  2651. currentToken.matches.push(quantifierToken);
  2652. break;
  2653. default:
  2654. opengroups.length > 0 ? opengroups[opengroups.length - 1].matches.push(m) : currentToken.matches.push(m);
  2655. }
  2656. currentToken.matches.length > 0 && opts.regexTokens.push(currentToken);
  2657. }(), cbuffer.splice(pos, 0, chrs), bufferStr = cbuffer.join("");
  2658. for (var i = 0; i < opts.regexTokens.length; i++) {
  2659. var regexToken = opts.regexTokens[i];
  2660. if (isValid = validateRegexToken(regexToken, regexToken.isGroup)) break;
  2661. }
  2662. return isValid;
  2663. },
  2664. cardinality: 1
  2665. }
  2666. }
  2667. }
  2668. });
  2669. }(window.dependencyLib || jQuery, window.Inputmask);
  2670. }();