jquery.inputmask.bundle.js 179 KB

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