jquery.inputmask.bundle.js 162 KB

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