jquery.inputmask.bundle.js 161 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609
  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-16
  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 isInputTypeSupported(inputType) {
  21. var isSupported = "text" === inputType || "tel" === inputType || "password" === inputType;
  22. if (!isSupported) {
  23. var el = document.createElement("input");
  24. el.setAttribute("type", inputType), 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;
  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(), 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.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 (!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.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)) for (var nPos = maskPos + 1, snPos = seekNext(maskPos); snPos >= nPos; nPos++) if (result = _isValid(nPos, c, strict, fromSetValid),
  596. result !== !1) {
  597. trackbackAlternations(maskPos, nPos), maskPos = nPos;
  598. break;
  599. }
  600. } else result = {
  601. caret: seekNext(maskPos)
  602. };
  603. }
  604. if (result === !1 && opts.keepStatic && (result = alternate(pos, c, strict, fromSetValid)),
  605. result === !0 && (result = {
  606. pos: maskPos
  607. }), $.isFunction(opts.postValidation) && result !== !1 && !strict) {
  608. var postValidResult = opts.postValidation(getBuffer(!0), opts);
  609. if (postValidResult) {
  610. if (postValidResult.refreshFromBuffer) {
  611. var refresh = postValidResult.refreshFromBuffer;
  612. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, postValidResult.buffer),
  613. resetMaskSet(!0), result = postValidResult;
  614. }
  615. } else resetMaskSet(!0), getMaskSet().validPositions = $.extend(!0, {}, positionsClone),
  616. result = !1;
  617. }
  618. return result;
  619. }
  620. function isMask(pos, strict) {
  621. var test = getTest(pos);
  622. if (null != test.fn) return test.fn;
  623. if (strict !== !0 && pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
  624. var tests = getTests(pos, void 0, void 0, !0);
  625. return tests.length > 2;
  626. }
  627. return !1;
  628. }
  629. function getMaskLength() {
  630. var maskLength;
  631. maxLength = void 0 !== el ? el.maxLength : void 0, -1 === maxLength && (maxLength = void 0);
  632. var pos, lvp = getLastValidPosition(), testPos = getMaskSet().validPositions[lvp], ndxIntlzr = void 0 !== testPos ? testPos.locator.slice() : void 0;
  633. 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),
  634. ndxIntlzr = testPos.locator.slice();
  635. var lastTest = getTest(pos - 1);
  636. return maskLength = "" !== lastTest.def ? pos : pos - 1, void 0 === maxLength || maxLength > maskLength ? maskLength : maxLength;
  637. }
  638. function seekNext(pos, newBlock) {
  639. var maskL = getMaskLength();
  640. if (pos >= maskL) return maskL;
  641. for (var position = pos; ++position < maskL && (newBlock === !0 && (getTest(position).newBlockMarker !== !0 || !isMask(position)) || newBlock !== !0 && !isMask(position) && (opts.nojumps !== !0 || opts.nojumpsThreshold > position)); ) ;
  642. return position;
  643. }
  644. function seekPrevious(pos, newBlock) {
  645. var position = pos;
  646. if (0 >= position) return 0;
  647. for (;--position > 0 && (newBlock === !0 && getTest(position).newBlockMarker !== !0 || newBlock !== !0 && !isMask(position)); ) ;
  648. return position;
  649. }
  650. function getBufferElement(position) {
  651. return void 0 === getMaskSet().validPositions[position] ? getPlaceholder(position) : getMaskSet().validPositions[position].input;
  652. }
  653. function writeBuffer(input, buffer, caretPos, event, triggerInputEvent) {
  654. if (event && $.isFunction(opts.onBeforeWrite)) {
  655. var result = opts.onBeforeWrite(event, buffer, caretPos, opts);
  656. if (result) {
  657. if (result.refreshFromBuffer) {
  658. var refresh = result.refreshFromBuffer;
  659. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, result.buffer || buffer),
  660. buffer = getBuffer(!0);
  661. }
  662. void 0 !== caretPos && (caretPos = void 0 !== result.caret ? result.caret : caretPos);
  663. }
  664. }
  665. input.inputmask._valueSet(buffer.join("")), void 0 === caretPos || void 0 !== event && "blur" === event.type || caret(input, caretPos),
  666. triggerInputEvent === !0 && (skipInputEvent = !0, $(input).trigger("input"));
  667. }
  668. function getPlaceholder(pos, test) {
  669. if (test = test || getTest(pos), void 0 !== test.placeholder) return test.placeholder;
  670. if (null === test.fn) {
  671. if (pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
  672. var prevTest, tests = getTests(pos), staticAlternations = 0;
  673. 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++,
  674. null === tests[i].match.fn && (prevTest = tests[i]), staticAlternations > 1)) return opts.placeholder.charAt(pos % opts.placeholder.length);
  675. }
  676. return test.def;
  677. }
  678. return opts.placeholder.charAt(pos % opts.placeholder.length);
  679. }
  680. function checkVal(input, writeOut, strict, nptvl) {
  681. function isTemplateMatch() {
  682. var isMatch = !1, charCodeNdx = getBufferTemplate().slice(initialNdx, seekNext(initialNdx)).join("").indexOf(charCodes);
  683. if (-1 !== charCodeNdx && !isMask(initialNdx)) {
  684. isMatch = !0;
  685. for (var bufferTemplateArr = getBufferTemplate().slice(initialNdx, initialNdx + charCodeNdx), i = 0; i < bufferTemplateArr.length; i++) if (" " !== bufferTemplateArr[i]) {
  686. isMatch = !1;
  687. break;
  688. }
  689. }
  690. return isMatch;
  691. }
  692. var inputValue = nptvl.slice(), charCodes = "", initialNdx = 0;
  693. if (resetMaskSet(), getMaskSet().p = seekNext(-1), !strict) if (opts.autoUnmask !== !0) {
  694. var staticInput = getBufferTemplate().slice(0, seekNext(-1)).join(""), matches = inputValue.join("").match(new RegExp("^" + Inputmask.escapeRegex(staticInput), "g"));
  695. matches && matches.length > 0 && (inputValue.splice(0, matches.length * staticInput.length),
  696. initialNdx = seekNext(initialNdx));
  697. } else initialNdx = seekNext(initialNdx);
  698. $.each(inputValue, function(ndx, charCode) {
  699. var keypress = new Event("keypress");
  700. keypress.which = charCode.charCodeAt(0), charCodes += charCode;
  701. var lvp = getLastValidPosition(void 0, !0), lvTest = getMaskSet().validPositions[lvp], nextTest = getTestTemplate(lvp + 1, lvTest ? lvTest.locator.slice() : void 0, lvp);
  702. if (!isTemplateMatch() || strict || opts.autoUnmask) {
  703. var pos = strict ? ndx : null == nextTest.match.fn && nextTest.match.optionality && lvp + 1 < getMaskSet().p ? lvp + 1 : getMaskSet().p;
  704. keypressEvent.call(input, keypress, !0, !1, strict, pos), initialNdx = pos + 1,
  705. charCodes = "";
  706. } else keypressEvent.call(input, keypress, !0, !1, !0, lvp + 1);
  707. }), writeOut && writeBuffer(input, getBuffer(), document.activeElement === input ? seekNext(getLastValidPosition(0)) : void 0, new Event("checkval"));
  708. }
  709. function unmaskedvalue(input) {
  710. if (input && void 0 === input.inputmask) return input.value;
  711. var umValue = [], vps = getMaskSet().validPositions;
  712. for (var pndx in vps) vps[pndx].match && null != vps[pndx].match.fn && umValue.push(vps[pndx].input);
  713. var unmaskedValue = 0 === umValue.length ? null : (isRTL ? umValue.reverse() : umValue).join("");
  714. if (null !== unmaskedValue) {
  715. var bufferValue = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join("");
  716. $.isFunction(opts.onUnMask) && (unmaskedValue = opts.onUnMask(bufferValue, unmaskedValue, opts) || unmaskedValue);
  717. }
  718. return unmaskedValue;
  719. }
  720. function caret(input, begin, end) {
  721. function translatePosition(pos) {
  722. if (isRTL && "number" == typeof pos && (!opts.greedy || "" !== opts.placeholder)) {
  723. var bffrLght = getBuffer().join("").length;
  724. pos = bffrLght - pos;
  725. }
  726. return pos;
  727. }
  728. var range;
  729. if ("number" != typeof begin) return input.setSelectionRange ? (begin = input.selectionStart,
  730. end = input.selectionEnd) : window.getSelection ? (range = window.getSelection().getRangeAt(0),
  731. (range.commonAncestorContainer.parentNode === input || range.commonAncestorContainer === input) && (begin = range.startOffset,
  732. end = range.endOffset)) : document.selection && document.selection.createRange && (range = document.selection.createRange(),
  733. begin = 0 - range.duplicate().moveStart("character", -1e5), end = begin + range.text.length),
  734. {
  735. begin: translatePosition(begin),
  736. end: translatePosition(end)
  737. };
  738. begin = translatePosition(begin), end = translatePosition(end), end = "number" == typeof end ? end : begin;
  739. var scrollCalc = parseInt(((input.ownerDocument.defaultView || window).getComputedStyle ? (input.ownerDocument.defaultView || window).getComputedStyle(input, null) : input.currentStyle).fontSize) * end;
  740. if (input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0, androidchrome || opts.insertMode !== !1 || begin !== end || end++,
  741. input.setSelectionRange) input.selectionStart = begin, input.selectionEnd = end; else if (window.getSelection) {
  742. if (range = document.createRange(), void 0 === input.firstChild) {
  743. var textNode = document.createTextNode("");
  744. input.appendChild(textNode);
  745. }
  746. range.setStart(input.firstChild, begin < input.inputmask._valueGet().length ? begin : input.inputmask._valueGet().length),
  747. range.setEnd(input.firstChild, end < input.inputmask._valueGet().length ? end : input.inputmask._valueGet().length),
  748. range.collapse(!0);
  749. var sel = window.getSelection();
  750. sel.removeAllRanges(), sel.addRange(range);
  751. } else input.createTextRange && (range = input.createTextRange(), range.collapse(!0),
  752. range.moveEnd("character", end), range.moveStart("character", begin), range.select());
  753. }
  754. function determineLastRequiredPosition(returnDefinition) {
  755. var pos, testPos, buffer = getBuffer(), bl = buffer.length, lvp = getLastValidPosition(), positions = {}, lvTest = getMaskSet().validPositions[lvp], ndxIntlzr = void 0 !== lvTest ? lvTest.locator.slice() : void 0;
  756. for (pos = lvp + 1; pos < buffer.length; pos++) testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
  757. ndxIntlzr = testPos.locator.slice(), positions[pos] = $.extend(!0, {}, testPos);
  758. var lvTestAlt = lvTest && void 0 !== lvTest.alternation ? lvTest.locator[lvTest.alternation] : void 0;
  759. 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--;
  760. return returnDefinition ? {
  761. l: bl,
  762. def: positions[bl] ? positions[bl].match : void 0
  763. } : bl;
  764. }
  765. function clearOptionalTail(buffer) {
  766. for (var rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
  767. return buffer.splice(rl, lmib + 1 - rl), buffer;
  768. }
  769. function isComplete(buffer) {
  770. if ($.isFunction(opts.isComplete)) return opts.isComplete(buffer, opts);
  771. if ("*" === opts.repeat) return void 0;
  772. var complete = !1, lrp = determineLastRequiredPosition(!0), aml = seekPrevious(lrp.l);
  773. if (void 0 === lrp.def || lrp.def.newBlockMarker || lrp.def.optionality || lrp.def.optionalQuantifier) {
  774. complete = !0;
  775. for (var i = 0; aml >= i; i++) {
  776. var test = getTestTemplate(i).match;
  777. if (null !== test.fn && void 0 === getMaskSet().validPositions[i] && test.optionality !== !0 && test.optionalQuantifier !== !0 || null === test.fn && buffer[i] !== getPlaceholder(i, test)) {
  778. complete = !1;
  779. break;
  780. }
  781. }
  782. }
  783. return complete;
  784. }
  785. function isSelection(begin, end) {
  786. return isRTL ? begin - end > 1 || begin - end === 1 && opts.insertMode : end - begin > 1 || end - begin === 1 && opts.insertMode;
  787. }
  788. function patchValueProperty(npt) {
  789. function patchValhook(type) {
  790. if ($.valHooks && (void 0 === $.valHooks[type] || $.valHooks[type].inputmaskpatch !== !0)) {
  791. var valhookGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function(elem) {
  792. return elem.value;
  793. }, valhookSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function(elem, value) {
  794. return elem.value = value, elem;
  795. };
  796. $.valHooks[type] = {
  797. get: function(elem) {
  798. if (elem.inputmask) {
  799. if (elem.inputmask.opts.autoUnmask) return elem.inputmask.unmaskedvalue();
  800. var result = valhookGet(elem), maskset = elem.inputmask.maskset, bufferTemplate = maskset._buffer;
  801. return bufferTemplate = bufferTemplate ? bufferTemplate.join("") : "", result !== bufferTemplate ? result : "";
  802. }
  803. return valhookGet(elem);
  804. },
  805. set: function(elem, value) {
  806. var result, $elem = $(elem);
  807. return result = valhookSet(elem, value), elem.inputmask && $elem.trigger("setvalue"),
  808. result;
  809. },
  810. inputmaskpatch: !0
  811. };
  812. }
  813. }
  814. function getter() {
  815. 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);
  816. }
  817. function setter(value) {
  818. valueSet.call(this, value), this.inputmask && $(this).trigger("setvalue");
  819. }
  820. function installNativeValueSetFallback(npt) {
  821. EventRuler.on(npt, "mouseenter", function(event) {
  822. var $input = $(this), input = this, value = input.inputmask._valueGet();
  823. "" !== value && value !== getBuffer().join("") && $input.trigger("setvalue");
  824. });
  825. }
  826. var valueGet, valueSet;
  827. npt.inputmask.__valueGet || (Object.getOwnPropertyDescriptor && void 0 === npt.value ? (valueGet = function() {
  828. return this.textContent;
  829. }, valueSet = function(value) {
  830. this.textContent = value;
  831. }, Object.defineProperty(npt, "value", {
  832. get: getter,
  833. set: setter
  834. })) : document.__lookupGetter__ && npt.__lookupGetter__("value") ? (valueGet = npt.__lookupGetter__("value"),
  835. valueSet = npt.__lookupSetter__("value"), npt.__defineGetter__("value", getter),
  836. npt.__defineSetter__("value", setter)) : (valueGet = function() {
  837. return npt.value;
  838. }, valueSet = function(value) {
  839. npt.value = value;
  840. }, patchValhook(npt.type), installNativeValueSetFallback(npt)), npt.inputmask.__valueGet = valueGet,
  841. npt.inputmask._valueGet = function(overruleRTL) {
  842. return isRTL && overruleRTL !== !0 ? valueGet.call(this.el).split("").reverse().join("") : valueGet.call(this.el);
  843. }, npt.inputmask.__valueSet = valueSet, npt.inputmask._valueSet = function(value, overruleRTL) {
  844. valueSet.call(this.el, null === value || void 0 === value ? "" : overruleRTL !== !0 && isRTL ? value.split("").reverse().join("") : value);
  845. });
  846. }
  847. function handleRemove(input, k, pos, strict) {
  848. function generalize() {
  849. if (opts.keepStatic) {
  850. resetMaskSet(!0);
  851. var lastAlt, validInputs = [], positionsClone = $.extend(!0, {}, getMaskSet().validPositions);
  852. for (lastAlt = getLastValidPosition(); lastAlt >= 0; lastAlt--) {
  853. var validPos = getMaskSet().validPositions[lastAlt];
  854. if (validPos && (null != validPos.match.fn && validInputs.push(validPos.input),
  855. delete getMaskSet().validPositions[lastAlt], void 0 !== validPos.alternation && validPos.locator[validPos.alternation] === getTestTemplate(lastAlt).locator[validPos.alternation])) break;
  856. }
  857. if (lastAlt > -1) for (;validInputs.length > 0; ) {
  858. getMaskSet().p = seekNext(getLastValidPosition());
  859. var keypress = new Event("keypress");
  860. keypress.which = validInputs.pop().charCodeAt(0), keypressEvent.call(input, keypress, !0, !1, !1, getMaskSet().p);
  861. } else getMaskSet().validPositions = $.extend(!0, {}, positionsClone);
  862. }
  863. }
  864. if ((opts.numericInput || isRTL) && (k === Inputmask.keyCode.BACKSPACE ? k = Inputmask.keyCode.DELETE : k === Inputmask.keyCode.DELETE && (k = Inputmask.keyCode.BACKSPACE),
  865. isRTL)) {
  866. var pend = pos.end;
  867. pos.end = pos.begin, pos.begin = pend;
  868. }
  869. k === Inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || opts.insertMode === !1) ? (pos.begin = seekPrevious(pos.begin),
  870. 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,
  871. void 0 === getMaskSet().validPositions[pos.begin] || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.end++),
  872. stripValidPositions(pos.begin, pos.end, !1, strict), strict !== !0 && generalize();
  873. var lvp = getLastValidPosition(pos.begin);
  874. lvp < pos.begin ? (-1 === lvp && resetMaskSet(), getMaskSet().p = seekNext(lvp)) : strict !== !0 && (getMaskSet().p = pos.begin);
  875. }
  876. function keydownEvent(e) {
  877. var input = this, $input = $(input), k = e.keyCode, pos = caret(input);
  878. k === Inputmask.keyCode.BACKSPACE || k === Inputmask.keyCode.DELETE || iphone && 127 === k || e.ctrlKey && 88 === k && !isInputEventSupported("cut") ? (e.preventDefault(),
  879. 88 === k && (undoValue = getBuffer().join("")), handleRemove(input, k, pos), writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")),
  880. input.inputmask._valueGet() === getBufferTemplate().join("") ? $input.trigger("cleared") : isComplete(getBuffer()) === !0 && $input.trigger("complete"),
  881. opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask)) : k === Inputmask.keyCode.END || k === Inputmask.keyCode.PAGE_DOWN ? setTimeout(function() {
  882. var caretPos = seekNext(getLastValidPosition());
  883. opts.insertMode || caretPos !== getMaskLength() || e.shiftKey || caretPos--, caret(input, e.shiftKey ? pos.begin : caretPos, caretPos);
  884. }, 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("")),
  885. $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)),
  886. pos.end = seekPrevious(pos.begin, !0), pos.begin = seekPrevious(pos.end, !0)) : (pos.begin = seekNext(pos.begin, !0),
  887. pos.end = seekNext(pos.begin, !0), pos.end < getMaskLength() && pos.end--), pos.begin < getMaskLength() && (e.preventDefault(),
  888. caret(input, pos.begin, pos.end))) : opts.insertMode !== !1 || e.shiftKey || (k === Inputmask.keyCode.RIGHT ? setTimeout(function() {
  889. var caretPos = caret(input);
  890. caret(input, caretPos.begin);
  891. }, 0) : k === Inputmask.keyCode.LEFT && setTimeout(function() {
  892. var caretPos = caret(input);
  893. caret(input, isRTL ? caretPos.begin + 1 : caretPos.begin - 1);
  894. }, 0)) : (opts.insertMode = !opts.insertMode, caret(input, opts.insertMode || pos.begin !== getMaskLength() ? pos.begin : pos.begin - 1)),
  895. opts.onKeyDown.call(this, e, getBuffer(), caret(input).begin, opts), ignorable = -1 !== $.inArray(k, opts.ignorables);
  896. }
  897. function keypressEvent(e, checkval, writeOut, strict, ndx) {
  898. var input = this, $input = $(input), k = e.which || e.charCode || e.keyCode;
  899. if (!(checkval === !0 || e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable)) return k === Inputmask.keyCode.ENTER && undoValue !== getBuffer().join("") && (undoValue = getBuffer().join(""),
  900. setTimeout(function() {
  901. $input.trigger("change");
  902. }, 0)), !0;
  903. if (k) {
  904. 46 === k && e.shiftKey === !1 && "," === opts.radixPoint && (k = 44);
  905. var forwardPosition, pos = checkval ? {
  906. begin: ndx,
  907. end: ndx
  908. } : caret(input), c = String.fromCharCode(k), isSlctn = isSelection(pos.begin, pos.end);
  909. isSlctn && (getMaskSet().undoPositions = $.extend(!0, {}, getMaskSet().validPositions),
  910. handleRemove(input, Inputmask.keyCode.DELETE, pos, !0), pos.begin = getMaskSet().p,
  911. opts.insertMode || (opts.insertMode = !opts.insertMode, setValidPosition(pos.begin, strict),
  912. opts.insertMode = !opts.insertMode), isSlctn = !opts.multi), getMaskSet().writeOutBuffer = !0;
  913. var p = isRTL && !isSlctn ? pos.end : pos.begin, valResult = isValid(p, c, strict);
  914. if (valResult !== !1) {
  915. if (valResult !== !0 && (p = void 0 !== valResult.pos ? valResult.pos : p, c = void 0 !== valResult.c ? valResult.c : c),
  916. resetMaskSet(!0), void 0 !== valResult.caret) forwardPosition = valResult.caret; else {
  917. var vps = getMaskSet().validPositions;
  918. 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);
  919. }
  920. getMaskSet().p = forwardPosition;
  921. }
  922. if (writeOut !== !1) {
  923. var self = this;
  924. if (setTimeout(function() {
  925. opts.onKeyValidation.call(self, k, valResult, opts);
  926. }, 0), getMaskSet().writeOutBuffer && valResult !== !1) {
  927. var buffer = getBuffer();
  928. writeBuffer(input, buffer, checkval ? void 0 : opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition, e, checkval !== !0),
  929. checkval !== !0 && setTimeout(function() {
  930. isComplete(buffer) === !0 && $input.trigger("complete");
  931. }, 0);
  932. } else isSlctn && (getMaskSet().buffer = void 0, getMaskSet().validPositions = getMaskSet().undoPositions);
  933. } else isSlctn && (getMaskSet().buffer = void 0, getMaskSet().validPositions = getMaskSet().undoPositions);
  934. if (opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask), checkval && $.isFunction(opts.onBeforeWrite)) {
  935. var result = opts.onBeforeWrite(e, getBuffer(), forwardPosition, opts);
  936. if (result && result.refreshFromBuffer) {
  937. var refresh = result.refreshFromBuffer;
  938. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, result.buffer),
  939. resetMaskSet(!0), result.caret && (getMaskSet().p = result.caret);
  940. }
  941. }
  942. if (e.preventDefault(), checkval) return valResult;
  943. }
  944. }
  945. function pasteEvent(e) {
  946. var input = this, ev = e.originalEvent || e, $input = $(input), inputValue = input.inputmask._valueGet(!0), caretPos = caret(input);
  947. if ("propertychange" === e.type && input.inputmask._valueGet().length <= getMaskLength()) return !0;
  948. if ("paste" === e.type) {
  949. var valueBeforeCaret = inputValue.substr(0, caretPos.begin), valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length);
  950. valueBeforeCaret === getBufferTemplate().slice(0, caretPos.begin).join("") && (valueBeforeCaret = ""),
  951. valueAfterCaret === getBufferTemplate().slice(caretPos.end).join("") && (valueAfterCaret = ""),
  952. 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);
  953. }
  954. var pasteValue = inputValue;
  955. if ($.isFunction(opts.onBeforePaste)) {
  956. if (pasteValue = opts.onBeforePaste(inputValue, opts), pasteValue === !1) return e.preventDefault(),
  957. !1;
  958. pasteValue || (pasteValue = inputValue);
  959. }
  960. return checkVal(input, !1, !1, isRTL ? pasteValue.split("").reverse() : pasteValue.toString().split("")),
  961. writeBuffer(input, getBuffer(), void 0, e, !0), $input.trigger("click"), isComplete(getBuffer()) === !0 && $input.trigger("complete"),
  962. !1;
  963. }
  964. function inputFallBackEvent(e) {
  965. var input = this;
  966. checkVal(input, !0, !1, input.inputmask._valueGet().split("")), isComplete(getBuffer()) === !0 && $(input).trigger("complete"),
  967. e.preventDefault();
  968. }
  969. function mobileInputEvent(e) {
  970. var input = this, caretPos = caret(input), currentValue = input.inputmask._valueGet();
  971. currentValue = currentValue.replace(new RegExp("(" + Inputmask.escapeRegex(getBufferTemplate().join("")) + ")*"), ""),
  972. caretPos.begin > currentValue.length && (caret(input, currentValue.length), caretPos = caret(input)),
  973. 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,
  974. keydownEvent.call(input, e)), e.preventDefault();
  975. }
  976. function compositionStartEvent(e) {
  977. var ev = e.originalEvent || e;
  978. undoValue = getBuffer().join(""), "" === compositionData || 0 !== ev.data.indexOf(compositionData);
  979. }
  980. function compositionUpdateEvent(e) {
  981. var input = this, ev = e.originalEvent || e;
  982. 0 === ev.data.indexOf(compositionData) && (resetMaskSet(), getMaskSet().p = seekNext(-1),
  983. skipInputEvent = !0);
  984. for (var newData = ev.data, i = 0; i < newData.length; i++) {
  985. var keypress = new Event("keypress");
  986. keypress.which = newData.charCodeAt(i), skipKeyPressEvent = !1, ignorable = !1,
  987. keypressEvent.call(input, keypress, !0, !1, !1, getMaskSet().p);
  988. }
  989. setTimeout(function() {
  990. var forwardPosition = getMaskSet().p;
  991. writeBuffer(input, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
  992. }, 0), compositionData = ev.data;
  993. }
  994. function compositionEndEvent(e) {}
  995. function setValueEvent(e) {
  996. var input = this, value = input.inputmask._valueGet();
  997. checkVal(input, !0, !1, ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(value, opts) || value : value).split("")),
  998. undoValue = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() === getBufferTemplate().join("") && input.inputmask._valueSet("");
  999. }
  1000. function focusEvent(e) {
  1001. var input = this, nptValue = input.inputmask._valueGet();
  1002. opts.showMaskOnFocus && (!opts.showMaskOnHover || opts.showMaskOnHover && "" === nptValue) ? input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer(), seekNext(getLastValidPosition())) : mouseEnter === !1 && caret(input, seekNext(getLastValidPosition())),
  1003. opts.positionCaretOnTab === !0 && setTimeout(function() {
  1004. caret(input, seekNext(getLastValidPosition()));
  1005. }, 0), undoValue = getBuffer().join("");
  1006. }
  1007. function mouseleaveEvent(e) {
  1008. var input = this;
  1009. if (mouseEnter = !1, opts.clearMaskOnLostFocus) {
  1010. var buffer = getBuffer().slice(), nptValue = input.inputmask._valueGet();
  1011. document.activeElement !== input && nptValue !== input.getAttribute("placeholder") && "" !== nptValue && (-1 === getLastValidPosition() && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer),
  1012. writeBuffer(input, buffer));
  1013. }
  1014. }
  1015. function clickEvent(e) {
  1016. function doRadixFocus(clickPos) {
  1017. if (opts.radixFocus && "" !== opts.radixPoint) {
  1018. var vps = getMaskSet().validPositions;
  1019. if (void 0 === vps[clickPos] || vps[clickPos].input === getPlaceholder(clickPos)) {
  1020. if (clickPos < seekNext(-1)) return !0;
  1021. var radixPos = $.inArray(opts.radixPoint, getBuffer());
  1022. if (-1 !== radixPos) {
  1023. for (var vp in vps) if (vp > radixPos && vps[vp].input !== getPlaceholder(vp)) return !1;
  1024. return !0;
  1025. }
  1026. }
  1027. }
  1028. return !1;
  1029. }
  1030. var input = this;
  1031. if (document.activeElement === input) {
  1032. var selectedCaret = caret(input);
  1033. if (selectedCaret.begin === selectedCaret.end) if (doRadixFocus(selectedCaret.begin)) caret(input, $.inArray(opts.radixPoint, getBuffer())); else {
  1034. var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition), lastPosition = seekNext(lvclickPosition);
  1035. 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)),
  1036. caret(input, lastPosition));
  1037. }
  1038. }
  1039. }
  1040. function dblclickEvent(e) {
  1041. var input = this;
  1042. setTimeout(function() {
  1043. caret(input, 0, seekNext(getLastValidPosition()));
  1044. }, 0);
  1045. }
  1046. function cutEvent(e) {
  1047. 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);
  1048. clipboardData.setData("text", isRTL ? clipData.reverse().join("") : clipData.join("")),
  1049. document.execCommand && document.execCommand("copy"), handleRemove(input, Inputmask.keyCode.DELETE, pos),
  1050. writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")),
  1051. input.inputmask._valueGet() === getBufferTemplate().join("") && $input.trigger("cleared"),
  1052. opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask);
  1053. }
  1054. function blurEvent(e) {
  1055. var $input = $(this), input = this;
  1056. if (input.inputmask) {
  1057. var nptValue = input.inputmask._valueGet(), buffer = getBuffer().slice();
  1058. undoValue !== buffer.join("") && setTimeout(function() {
  1059. $input.trigger("change"), undoValue = buffer.join("");
  1060. }, 0), "" !== nptValue && (opts.clearMaskOnLostFocus && (-1 === getLastValidPosition() && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
  1061. isComplete(buffer) === !1 && (setTimeout(function() {
  1062. $input.trigger("incomplete");
  1063. }, 0), opts.clearIncomplete && (resetMaskSet(), buffer = opts.clearMaskOnLostFocus ? [] : getBufferTemplate().slice())),
  1064. writeBuffer(input, buffer, void 0, e));
  1065. }
  1066. }
  1067. function mouseenterEvent(e) {
  1068. var input = this;
  1069. mouseEnter = !0, document.activeElement !== input && opts.showMaskOnHover && input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer());
  1070. }
  1071. function submitEvent(e) {
  1072. undoValue !== getBuffer().join("") && $el.trigger("change"), opts.clearMaskOnLostFocus && -1 === getLastValidPosition() && el.inputmask._valueGet && el.inputmask._valueGet() === getBufferTemplate().join("") && el.inputmask._valueSet(""),
  1073. opts.removeMaskOnSubmit && (el.inputmask._valueSet(el.inputmask.unmaskedvalue(), !0),
  1074. setTimeout(function() {
  1075. writeBuffer(el, getBuffer());
  1076. }, 0));
  1077. }
  1078. function mask(elem) {
  1079. if (el = elem, $el = $(el), opts.showTooltip && (el.title = opts.tooltip || getMaskSet().mask),
  1080. ("rtl" === el.dir || opts.rightAlign) && (el.style.textAlign = "right"), ("rtl" === el.dir || opts.numericInput) && (el.dir = "ltr",
  1081. el.removeAttribute("dir"), el.inputmask.isRTL = !0, isRTL = !0), EventRuler.off(el),
  1082. patchValueProperty(el), ("INPUT" === el.tagName && isInputTypeSupported(el.getAttribute("type")) || el.isContentEditable || "TEXTAREA" === el.tagName) && (EventRuler.on(el, "submit", submitEvent),
  1083. EventRuler.on(el, "reset", submitEvent), EventRuler.on(el, "mouseenter", mouseenterEvent),
  1084. EventRuler.on(el, "blur", blurEvent), EventRuler.on(el, "focus", focusEvent), EventRuler.on(el, "mouseleave", mouseleaveEvent),
  1085. EventRuler.on(el, "click", clickEvent), EventRuler.on(el, "dblclick", dblclickEvent),
  1086. EventRuler.on(el, PasteEventType, pasteEvent), EventRuler.on(el, "dragdrop", pasteEvent),
  1087. EventRuler.on(el, "drop", pasteEvent), EventRuler.on(el, "cut", cutEvent), EventRuler.on(el, "complete", opts.oncomplete),
  1088. EventRuler.on(el, "incomplete", opts.onincomplete), EventRuler.on(el, "cleared", opts.oncleared),
  1089. EventRuler.on(el, "keydown", keydownEvent), EventRuler.on(el, "keypress", keypressEvent),
  1090. androidfirefox || (EventRuler.on(el, "compositionstart", compositionStartEvent),
  1091. EventRuler.on(el, "compositionupdate", compositionUpdateEvent), EventRuler.on(el, "compositionend", compositionEndEvent)),
  1092. "paste" === PasteEventType && EventRuler.on(el, "input", inputFallBackEvent), (android || androidfirefox || androidchrome || kindle) && (EventRuler.off(el, "input"),
  1093. EventRuler.on(el, "input", mobileInputEvent))), EventRuler.on(el, "setvalue", setValueEvent),
  1094. "" !== el.inputmask._valueGet() || opts.clearMaskOnLostFocus === !1) {
  1095. var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(el.inputmask._valueGet(), opts) || el.inputmask._valueGet() : el.inputmask._valueGet();
  1096. checkVal(el, !0, !1, initialValue.split(""));
  1097. var buffer = getBuffer().slice();
  1098. undoValue = buffer.join(""), isComplete(buffer) === !1 && opts.clearIncomplete && resetMaskSet(),
  1099. opts.clearMaskOnLostFocus && (buffer.join("") === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
  1100. writeBuffer(el, buffer), document.activeElement === el && caret(el, seekNext(getLastValidPosition()));
  1101. }
  1102. }
  1103. var undoValue, compositionData, el, $el, maxLength, valueBuffer, isRTL = !1, skipKeyPressEvent = !1, skipInputEvent = !1, ignorable = !1, mouseEnter = !0, EventRuler = {
  1104. on: function(input, eventName, eventHandler) {
  1105. var ev = function(e) {
  1106. var inComposition = !1, keydownPressed = !1;
  1107. if (void 0 === this.inputmask) {
  1108. var imOpts = $.data(this, "_inputmask_opts");
  1109. imOpts ? new Inputmask(imOpts).mask(this) : EventRuler.off(this);
  1110. } else {
  1111. if ("setvalue" === e.type || !(this.disabled || this.readOnly && !("keydown" === e.type && e.ctrlKey && 67 === e.keyCode || opts.tabThrough === !1 && e.keyCode === Inputmask.keyCode.TAB))) {
  1112. switch (e.type) {
  1113. case "input":
  1114. if (skipInputEvent === !0 || inComposition === !0) return skipInputEvent = !1, e.preventDefault();
  1115. keydownPressed = !1;
  1116. break;
  1117. case "keydown":
  1118. skipKeyPressEvent = !1, inComposition = !1, keydownPressed = !0;
  1119. break;
  1120. case "keypress":
  1121. if (skipKeyPressEvent === !0) return e.preventDefault();
  1122. skipKeyPressEvent = !0;
  1123. break;
  1124. case "compositionstart":
  1125. inComposition = !0;
  1126. break;
  1127. case "compositionupdate":
  1128. skipInputEvent = keydownPressed;
  1129. break;
  1130. case "compositionend":
  1131. inComposition = !1, keydownPressed = !1;
  1132. break;
  1133. case "cut":
  1134. skipInputEvent = !0;
  1135. }
  1136. return eventHandler.apply(this, arguments);
  1137. }
  1138. e.preventDefault();
  1139. }
  1140. };
  1141. input.inputmask.events[eventName] = input.inputmask.events[eventName] || [], input.inputmask.events[eventName].push(ev),
  1142. -1 != [ "submit", "reset" ].indexOf(eventName) ? null != input.form && $(input.form).on(eventName, ev) : $(input).on(eventName, ev);
  1143. },
  1144. off: function(input, event) {
  1145. input.inputmask && input.inputmask.events && $.each(event ? [ event ] : input.inputmask.events, function(eventName, evArr) {
  1146. for (;evArr.length > 0; ) {
  1147. var ev = evArr.pop();
  1148. -1 != [ "submit", "reset" ].indexOf(eventName) ? null != input.form && $(input.form).off(eventName, ev) : $(input).off(eventName, ev);
  1149. }
  1150. delete input.inputmask.events[eventName];
  1151. });
  1152. }
  1153. };
  1154. if (void 0 !== actionObj) switch (actionObj.action) {
  1155. case "isComplete":
  1156. return el = actionObj.el, isComplete(getBuffer());
  1157. case "unmaskedvalue":
  1158. return el = actionObj.el, void 0 !== el && void 0 !== el.inputmask ? (maskset = el.inputmask.maskset,
  1159. opts = el.inputmask.opts, isRTL = el.inputmask.isRTL) : (valueBuffer = actionObj.value,
  1160. opts.numericInput && (isRTL = !0), valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(valueBuffer, opts) || valueBuffer : valueBuffer).split(""),
  1161. checkVal(void 0, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite(void 0, getBuffer(), 0, opts)),
  1162. unmaskedvalue(el);
  1163. case "mask":
  1164. el = actionObj.el, maskset = el.inputmask.maskset, opts = el.inputmask.opts, isRTL = el.inputmask.isRTL,
  1165. undoValue = getBuffer().join(""), mask(el);
  1166. break;
  1167. case "format":
  1168. return opts.numericInput && (isRTL = !0), valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(actionObj.value, opts) || actionObj.value : actionObj.value).split(""),
  1169. checkVal(void 0, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite(void 0, getBuffer(), 0, opts),
  1170. actionObj.metadata ? {
  1171. value: isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join(""),
  1172. metadata: maskScope({
  1173. action: "getmetadata"
  1174. }, maskset, opts)
  1175. } : isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join("");
  1176. case "isValid":
  1177. opts.numericInput && (isRTL = !0), actionObj.value ? (valueBuffer = actionObj.value.split(""),
  1178. checkVal(void 0, !1, !0, isRTL ? valueBuffer.reverse() : valueBuffer)) : actionObj.value = getBuffer().join("");
  1179. for (var buffer = getBuffer(), rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
  1180. return buffer.splice(rl, lmib + 1 - rl), isComplete(buffer) && actionObj.value === getBuffer().join("");
  1181. case "getemptymask":
  1182. return getBufferTemplate();
  1183. case "remove":
  1184. el = actionObj.el, $el = $(el), maskset = el.inputmask.maskset, opts = el.inputmask.opts,
  1185. el.inputmask._valueSet(unmaskedvalue(el)), EventRuler.off(el);
  1186. var valueProperty;
  1187. Object.getOwnPropertyDescriptor && (valueProperty = Object.getOwnPropertyDescriptor(el, "value")),
  1188. valueProperty && valueProperty.get ? el.inputmask.__valueGet && Object.defineProperty(el, "value", {
  1189. get: el.inputmask.__valueGet,
  1190. set: el.inputmask.__valueSet
  1191. }) : document.__lookupGetter__ && el.__lookupGetter__("value") && el.inputmask.__valueGet && (el.__defineGetter__("value", el.inputmask.__valueGet),
  1192. el.__defineSetter__("value", el.inputmask.__valueSet)), el.inputmask = void 0;
  1193. break;
  1194. case "getmetadata":
  1195. if ($.isArray(maskset.metadata)) {
  1196. for (var alternation, lvp = getLastValidPosition(), firstAlt = lvp; firstAlt >= 0; firstAlt--) if (getMaskSet().validPositions[firstAlt] && void 0 !== getMaskSet().validPositions[firstAlt].alternation) {
  1197. alternation = getMaskSet().validPositions[firstAlt].alternation;
  1198. break;
  1199. }
  1200. return void 0 !== alternation ? maskset.metadata[getMaskSet().validPositions[lvp].locator[alternation]] : maskset.metadata[0];
  1201. }
  1202. return maskset.metadata;
  1203. }
  1204. }
  1205. Inputmask.prototype = {
  1206. defaults: {
  1207. placeholder: "_",
  1208. optionalmarker: {
  1209. start: "[",
  1210. end: "]"
  1211. },
  1212. quantifiermarker: {
  1213. start: "{",
  1214. end: "}"
  1215. },
  1216. groupmarker: {
  1217. start: "(",
  1218. end: ")"
  1219. },
  1220. alternatormarker: "|",
  1221. escapeChar: "\\",
  1222. mask: null,
  1223. oncomplete: $.noop,
  1224. onincomplete: $.noop,
  1225. oncleared: $.noop,
  1226. repeat: 0,
  1227. greedy: !0,
  1228. autoUnmask: !1,
  1229. removeMaskOnSubmit: !1,
  1230. clearMaskOnLostFocus: !0,
  1231. insertMode: !0,
  1232. clearIncomplete: !1,
  1233. aliases: {},
  1234. alias: null,
  1235. onKeyDown: $.noop,
  1236. onBeforeMask: null,
  1237. onBeforePaste: function(pastedValue, opts) {
  1238. return $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(pastedValue, opts) : pastedValue;
  1239. },
  1240. onBeforeWrite: null,
  1241. onUnMask: null,
  1242. showMaskOnFocus: !0,
  1243. showMaskOnHover: !0,
  1244. onKeyValidation: $.noop,
  1245. skipOptionalPartCharacter: " ",
  1246. showTooltip: !1,
  1247. tooltip: void 0,
  1248. numericInput: !1,
  1249. rightAlign: !1,
  1250. undoOnEscape: !0,
  1251. radixPoint: "",
  1252. groupSeparator: "",
  1253. radixFocus: !1,
  1254. nojumps: !1,
  1255. nojumpsThreshold: 0,
  1256. keepStatic: null,
  1257. positionCaretOnTab: !1,
  1258. tabThrough: !1,
  1259. supportsInputType: [],
  1260. definitions: {
  1261. "9": {
  1262. validator: "[0-9]",
  1263. cardinality: 1,
  1264. definitionSymbol: "*"
  1265. },
  1266. a: {
  1267. validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  1268. cardinality: 1,
  1269. definitionSymbol: "*"
  1270. },
  1271. "*": {
  1272. validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  1273. cardinality: 1
  1274. }
  1275. },
  1276. 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 ],
  1277. isComplete: null,
  1278. canClearPosition: $.noop,
  1279. postValidation: null,
  1280. staticDefinitionSymbol: void 0
  1281. },
  1282. masksCache: {},
  1283. mask: function(elems) {
  1284. var that = this;
  1285. return "string" == typeof elems && (elems = document.getElementById(elems) || document.querySelectorAll(elems)),
  1286. elems = elems.nodeName ? [ elems ] : elems, $.each(elems, function(ndx, el) {
  1287. var scopedOpts = $.extend(!0, {}, that.opts);
  1288. importAttributeOptions(el, scopedOpts, $.extend(!0, {}, that.userOptions));
  1289. var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
  1290. void 0 !== maskset && (void 0 !== el.inputmask && el.inputmask.remove(), el.inputmask = new Inputmask(),
  1291. el.inputmask.opts = scopedOpts, el.inputmask.noMasksCache = that.noMasksCache, el.inputmask.userOptions = $.extend(!0, {}, that.userOptions),
  1292. el.inputmask.el = el, el.inputmask.maskset = maskset, el.inputmask.isRTL = !1, $.data(el, "_inputmask_opts", scopedOpts),
  1293. maskScope({
  1294. action: "mask",
  1295. el: el
  1296. }));
  1297. }), elems && elems[0] ? elems[0].inputmask || this : this;
  1298. },
  1299. option: function(options) {
  1300. return "string" == typeof options ? this.opts[options] : "object" == typeof options ? ($.extend(this.opts, options),
  1301. $.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),
  1302. maskScope({
  1303. action: "mask",
  1304. el: this.el
  1305. }))), this) : void 0;
  1306. },
  1307. unmaskedvalue: function(value) {
  1308. return maskScope({
  1309. action: "unmaskedvalue",
  1310. el: this.el,
  1311. value: value
  1312. }, this.el && this.el.inputmask ? this.el.inputmask.maskset : generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1313. },
  1314. remove: function() {
  1315. return this.el ? (maskScope({
  1316. action: "remove",
  1317. el: this.el
  1318. }), this.el.inputmask = void 0, this.el) : void 0;
  1319. },
  1320. getemptymask: function() {
  1321. return maskScope({
  1322. action: "getemptymask"
  1323. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1324. },
  1325. hasMaskedValue: function() {
  1326. return !this.opts.autoUnmask;
  1327. },
  1328. isComplete: function() {
  1329. return maskScope({
  1330. action: "isComplete",
  1331. el: this.el
  1332. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1333. },
  1334. getmetadata: function() {
  1335. return maskScope({
  1336. action: "getmetadata"
  1337. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1338. },
  1339. isValid: function(value) {
  1340. return maskScope({
  1341. action: "isValid",
  1342. value: value
  1343. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1344. },
  1345. format: function(value, metadata) {
  1346. return maskScope({
  1347. action: "format",
  1348. value: value,
  1349. metadata: metadata
  1350. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1351. }
  1352. }, Inputmask.extendDefaults = function(options) {
  1353. $.extend(!0, Inputmask.prototype.defaults, options);
  1354. }, Inputmask.extendDefinitions = function(definition) {
  1355. $.extend(!0, Inputmask.prototype.defaults.definitions, definition);
  1356. }, Inputmask.extendAliases = function(alias) {
  1357. $.extend(!0, Inputmask.prototype.defaults.aliases, alias);
  1358. }, Inputmask.format = function(value, options, metadata) {
  1359. return Inputmask(options).format(value, metadata);
  1360. }, Inputmask.unmask = function(value, options) {
  1361. return Inputmask(options).unmaskedvalue(value);
  1362. }, Inputmask.isValid = function(value, options) {
  1363. return Inputmask(options).isValid(value);
  1364. }, Inputmask.remove = function(elems) {
  1365. $.each(elems, function(ndx, el) {
  1366. el.inputmask && el.inputmask.remove();
  1367. });
  1368. }, Inputmask.escapeRegex = function(str) {
  1369. var specials = [ "/", ".", "*", "+", "?", "|", "(", ")", "[", "]", "{", "}", "\\", "$", "^" ];
  1370. return str.replace(new RegExp("(\\" + specials.join("|\\") + ")", "gim"), "\\$1");
  1371. }, Inputmask.keyCode = {
  1372. ALT: 18,
  1373. BACKSPACE: 8,
  1374. CAPS_LOCK: 20,
  1375. COMMA: 188,
  1376. COMMAND: 91,
  1377. COMMAND_LEFT: 91,
  1378. COMMAND_RIGHT: 93,
  1379. CONTROL: 17,
  1380. DELETE: 46,
  1381. DOWN: 40,
  1382. END: 35,
  1383. ENTER: 13,
  1384. ESCAPE: 27,
  1385. HOME: 36,
  1386. INSERT: 45,
  1387. LEFT: 37,
  1388. MENU: 93,
  1389. NUMPAD_ADD: 107,
  1390. NUMPAD_DECIMAL: 110,
  1391. NUMPAD_DIVIDE: 111,
  1392. NUMPAD_ENTER: 108,
  1393. NUMPAD_MULTIPLY: 106,
  1394. NUMPAD_SUBTRACT: 109,
  1395. PAGE_DOWN: 34,
  1396. PAGE_UP: 33,
  1397. PERIOD: 190,
  1398. RIGHT: 39,
  1399. SHIFT: 16,
  1400. SPACE: 32,
  1401. TAB: 9,
  1402. UP: 38,
  1403. WINDOWS: 91
  1404. };
  1405. 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";
  1406. return window.Inputmask = Inputmask, Inputmask;
  1407. }(jQuery), function($, Inputmask) {
  1408. return void 0 === $.fn.inputmask && ($.fn.inputmask = function(fn, options) {
  1409. var nptmask, input = this[0];
  1410. if (options = options || {}, "string" == typeof fn) switch (fn) {
  1411. case "unmaskedvalue":
  1412. return input && input.inputmask ? input.inputmask.unmaskedvalue() : $(input).val();
  1413. case "remove":
  1414. return this.each(function() {
  1415. this.inputmask && this.inputmask.remove();
  1416. });
  1417. case "getemptymask":
  1418. return input && input.inputmask ? input.inputmask.getemptymask() : "";
  1419. case "hasMaskedValue":
  1420. return input && input.inputmask ? input.inputmask.hasMaskedValue() : !1;
  1421. case "isComplete":
  1422. return input && input.inputmask ? input.inputmask.isComplete() : !0;
  1423. case "getmetadata":
  1424. return input && input.inputmask ? input.inputmask.getmetadata() : void 0;
  1425. case "setvalue":
  1426. $(input).val(options), input && void 0 !== input.inputmask && $(input).triggerHandler("setvalue");
  1427. break;
  1428. case "option":
  1429. if ("string" != typeof options) return this.each(function() {
  1430. return void 0 !== this.inputmask ? this.inputmask.option(options) : void 0;
  1431. });
  1432. if (input && void 0 !== input.inputmask) return input.inputmask.option(options);
  1433. break;
  1434. default:
  1435. return options.alias = fn, nptmask = new Inputmask(options), this.each(function() {
  1436. nptmask.mask(this);
  1437. });
  1438. } else {
  1439. if ("object" == typeof fn) return nptmask = new Inputmask(fn), void 0 === fn.mask && void 0 === fn.alias ? this.each(function() {
  1440. return void 0 !== this.inputmask ? this.inputmask.option(fn) : void nptmask.mask(this);
  1441. }) : this.each(function() {
  1442. nptmask.mask(this);
  1443. });
  1444. if (void 0 === fn) return this.each(function() {
  1445. nptmask = new Inputmask(options), nptmask.mask(this);
  1446. });
  1447. }
  1448. }), $.fn.inputmask;
  1449. }(jQuery, Inputmask), function($, Inputmask) {
  1450. return Inputmask.extendDefinitions({
  1451. h: {
  1452. validator: "[01][0-9]|2[0-3]",
  1453. cardinality: 2,
  1454. prevalidator: [ {
  1455. validator: "[0-2]",
  1456. cardinality: 1
  1457. } ]
  1458. },
  1459. s: {
  1460. validator: "[0-5][0-9]",
  1461. cardinality: 2,
  1462. prevalidator: [ {
  1463. validator: "[0-5]",
  1464. cardinality: 1
  1465. } ]
  1466. },
  1467. d: {
  1468. validator: "0[1-9]|[12][0-9]|3[01]",
  1469. cardinality: 2,
  1470. prevalidator: [ {
  1471. validator: "[0-3]",
  1472. cardinality: 1
  1473. } ]
  1474. },
  1475. m: {
  1476. validator: "0[1-9]|1[012]",
  1477. cardinality: 2,
  1478. prevalidator: [ {
  1479. validator: "[01]",
  1480. cardinality: 1
  1481. } ]
  1482. },
  1483. y: {
  1484. validator: "(19|20)\\d{2}",
  1485. cardinality: 4,
  1486. prevalidator: [ {
  1487. validator: "[12]",
  1488. cardinality: 1
  1489. }, {
  1490. validator: "(19|20)",
  1491. cardinality: 2
  1492. }, {
  1493. validator: "(19|20)\\d",
  1494. cardinality: 3
  1495. } ]
  1496. }
  1497. }), Inputmask.extendAliases({
  1498. "dd/mm/yyyy": {
  1499. mask: "1/2/y",
  1500. placeholder: "dd/mm/yyyy",
  1501. regex: {
  1502. val1pre: new RegExp("[0-3]"),
  1503. val1: new RegExp("0[1-9]|[12][0-9]|3[01]"),
  1504. val2pre: function(separator) {
  1505. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1506. return new RegExp("((0[1-9]|[12][0-9]|3[01])" + escapedSeparator + "[01])");
  1507. },
  1508. val2: function(separator) {
  1509. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1510. 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]))");
  1511. }
  1512. },
  1513. leapday: "29/02/",
  1514. separator: "/",
  1515. yearrange: {
  1516. minyear: 1900,
  1517. maxyear: 2099
  1518. },
  1519. isInYearRange: function(chrs, minyear, maxyear) {
  1520. if (isNaN(chrs)) return !1;
  1521. var enteredyear = parseInt(chrs.concat(minyear.toString().slice(chrs.length))), enteredyear2 = parseInt(chrs.concat(maxyear.toString().slice(chrs.length)));
  1522. return (isNaN(enteredyear) ? !1 : enteredyear >= minyear && maxyear >= enteredyear) || (isNaN(enteredyear2) ? !1 : enteredyear2 >= minyear && maxyear >= enteredyear2);
  1523. },
  1524. determinebaseyear: function(minyear, maxyear, hint) {
  1525. var currentyear = new Date().getFullYear();
  1526. if (minyear > currentyear) return minyear;
  1527. if (currentyear > maxyear) {
  1528. for (var maxYearPrefix = maxyear.toString().slice(0, 2), maxYearPostfix = maxyear.toString().slice(2, 4); maxYearPrefix + hint > maxyear; ) maxYearPrefix--;
  1529. var maxxYear = maxYearPrefix + maxYearPostfix;
  1530. return minyear > maxxYear ? minyear : maxxYear;
  1531. }
  1532. return currentyear;
  1533. },
  1534. onKeyDown: function(e, buffer, caretPos, opts) {
  1535. var $input = $(this);
  1536. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  1537. var today = new Date();
  1538. $input.val(today.getDate().toString() + (today.getMonth() + 1).toString() + today.getFullYear().toString()),
  1539. $input.trigger("setvalue");
  1540. }
  1541. },
  1542. getFrontValue: function(mask, buffer, opts) {
  1543. for (var start = 0, length = 0, i = 0; i < mask.length && "2" !== mask.charAt(i); i++) {
  1544. var definition = opts.definitions[mask.charAt(i)];
  1545. definition ? (start += length, length = definition.cardinality) : length++;
  1546. }
  1547. return buffer.join("").substr(start, length);
  1548. },
  1549. definitions: {
  1550. "1": {
  1551. validator: function(chrs, maskset, pos, strict, opts) {
  1552. var isValid = opts.regex.val1.test(chrs);
  1553. 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",
  1554. {
  1555. refreshFromBuffer: {
  1556. start: pos - 1,
  1557. end: pos
  1558. },
  1559. pos: pos,
  1560. c: chrs.charAt(0)
  1561. });
  1562. },
  1563. cardinality: 2,
  1564. prevalidator: [ {
  1565. validator: function(chrs, maskset, pos, strict, opts) {
  1566. var pchrs = chrs;
  1567. isNaN(maskset.buffer[pos + 1]) || (pchrs += maskset.buffer[pos + 1]);
  1568. var isValid = 1 === pchrs.length ? opts.regex.val1pre.test(pchrs) : opts.regex.val1.test(pchrs);
  1569. if (!strict && !isValid) {
  1570. if (isValid = opts.regex.val1.test(chrs + "0")) return maskset.buffer[pos] = chrs,
  1571. maskset.buffer[++pos] = "0", {
  1572. pos: pos,
  1573. c: "0"
  1574. };
  1575. if (isValid = opts.regex.val1.test("0" + chrs)) return maskset.buffer[pos] = "0",
  1576. pos++, {
  1577. pos: pos
  1578. };
  1579. }
  1580. return isValid;
  1581. },
  1582. cardinality: 1
  1583. } ]
  1584. },
  1585. "2": {
  1586. validator: function(chrs, maskset, pos, strict, opts) {
  1587. var frontValue = opts.getFrontValue(maskset.mask, maskset.buffer, opts);
  1588. -1 !== frontValue.indexOf(opts.placeholder[0]) && (frontValue = "01" + opts.separator);
  1589. var isValid = opts.regex.val2(opts.separator).test(frontValue + chrs);
  1590. 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",
  1591. {
  1592. refreshFromBuffer: {
  1593. start: pos - 1,
  1594. end: pos
  1595. },
  1596. pos: pos,
  1597. c: chrs.charAt(0)
  1598. };
  1599. if (opts.mask.indexOf("2") === opts.mask.length - 1 && isValid) {
  1600. var dayMonthValue = maskset.buffer.join("").substr(4, 4) + chrs;
  1601. if (dayMonthValue !== opts.leapday) return !0;
  1602. var year = parseInt(maskset.buffer.join("").substr(0, 4), 10);
  1603. return year % 4 === 0 ? year % 100 === 0 ? year % 400 === 0 ? !0 : !1 : !0 : !1;
  1604. }
  1605. return isValid;
  1606. },
  1607. cardinality: 2,
  1608. prevalidator: [ {
  1609. validator: function(chrs, maskset, pos, strict, opts) {
  1610. isNaN(maskset.buffer[pos + 1]) || (chrs += maskset.buffer[pos + 1]);
  1611. var frontValue = opts.getFrontValue(maskset.mask, maskset.buffer, opts);
  1612. -1 !== frontValue.indexOf(opts.placeholder[0]) && (frontValue = "01" + opts.separator);
  1613. var isValid = 1 === chrs.length ? opts.regex.val2pre(opts.separator).test(frontValue + chrs) : opts.regex.val2(opts.separator).test(frontValue + chrs);
  1614. return strict || isValid || !(isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
  1615. pos++, {
  1616. pos: pos
  1617. });
  1618. },
  1619. cardinality: 1
  1620. } ]
  1621. },
  1622. y: {
  1623. validator: function(chrs, maskset, pos, strict, opts) {
  1624. if (opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) {
  1625. var dayMonthValue = maskset.buffer.join("").substr(0, 6);
  1626. if (dayMonthValue !== opts.leapday) return !0;
  1627. var year = parseInt(chrs, 10);
  1628. return year % 4 === 0 ? year % 100 === 0 ? year % 400 === 0 ? !0 : !1 : !0 : !1;
  1629. }
  1630. return !1;
  1631. },
  1632. cardinality: 4,
  1633. prevalidator: [ {
  1634. validator: function(chrs, maskset, pos, strict, opts) {
  1635. var isValid = opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1636. if (!strict && !isValid) {
  1637. var yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs + "0").toString().slice(0, 1);
  1638. if (isValid = opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) return maskset.buffer[pos++] = yearPrefix.charAt(0),
  1639. {
  1640. pos: pos
  1641. };
  1642. if (yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs + "0").toString().slice(0, 2),
  1643. isValid = opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) return maskset.buffer[pos++] = yearPrefix.charAt(0),
  1644. maskset.buffer[pos++] = yearPrefix.charAt(1), {
  1645. pos: pos
  1646. };
  1647. }
  1648. return isValid;
  1649. },
  1650. cardinality: 1
  1651. }, {
  1652. validator: function(chrs, maskset, pos, strict, opts) {
  1653. var isValid = opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1654. if (!strict && !isValid) {
  1655. var yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs).toString().slice(0, 2);
  1656. if (isValid = opts.isInYearRange(chrs[0] + yearPrefix[1] + chrs[1], opts.yearrange.minyear, opts.yearrange.maxyear)) return maskset.buffer[pos++] = yearPrefix.charAt(1),
  1657. {
  1658. pos: pos
  1659. };
  1660. if (yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs).toString().slice(0, 2),
  1661. opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) {
  1662. var dayMonthValue = maskset.buffer.join("").substr(0, 6);
  1663. if (dayMonthValue !== opts.leapday) isValid = !0; else {
  1664. var year = parseInt(chrs, 10);
  1665. isValid = year % 4 === 0 ? year % 100 === 0 ? year % 400 === 0 ? !0 : !1 : !0 : !1;
  1666. }
  1667. } else isValid = !1;
  1668. if (isValid) return maskset.buffer[pos - 1] = yearPrefix.charAt(0), maskset.buffer[pos++] = yearPrefix.charAt(1),
  1669. maskset.buffer[pos++] = chrs.charAt(0), {
  1670. refreshFromBuffer: {
  1671. start: pos - 3,
  1672. end: pos
  1673. },
  1674. pos: pos
  1675. };
  1676. }
  1677. return isValid;
  1678. },
  1679. cardinality: 2
  1680. }, {
  1681. validator: function(chrs, maskset, pos, strict, opts) {
  1682. return opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1683. },
  1684. cardinality: 3
  1685. } ]
  1686. }
  1687. },
  1688. insertMode: !1,
  1689. autoUnmask: !1
  1690. },
  1691. "mm/dd/yyyy": {
  1692. placeholder: "mm/dd/yyyy",
  1693. alias: "dd/mm/yyyy",
  1694. regex: {
  1695. val2pre: function(separator) {
  1696. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1697. return new RegExp("((0[13-9]|1[012])" + escapedSeparator + "[0-3])|(02" + escapedSeparator + "[0-2])");
  1698. },
  1699. val2: function(separator) {
  1700. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1701. 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)");
  1702. },
  1703. val1pre: new RegExp("[01]"),
  1704. val1: new RegExp("0[1-9]|1[012]")
  1705. },
  1706. leapday: "02/29/",
  1707. onKeyDown: function(e, buffer, caretPos, opts) {
  1708. var $input = $(this);
  1709. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  1710. var today = new Date();
  1711. $input.val((today.getMonth() + 1).toString() + today.getDate().toString() + today.getFullYear().toString()),
  1712. $input.trigger("setvalue");
  1713. }
  1714. }
  1715. },
  1716. "yyyy/mm/dd": {
  1717. mask: "y/1/2",
  1718. placeholder: "yyyy/mm/dd",
  1719. alias: "mm/dd/yyyy",
  1720. leapday: "/02/29",
  1721. onKeyDown: function(e, buffer, caretPos, opts) {
  1722. var $input = $(this);
  1723. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  1724. var today = new Date();
  1725. $input.val(today.getFullYear().toString() + (today.getMonth() + 1).toString() + today.getDate().toString()),
  1726. $input.trigger("setvalue");
  1727. }
  1728. }
  1729. },
  1730. "dd.mm.yyyy": {
  1731. mask: "1.2.y",
  1732. placeholder: "dd.mm.yyyy",
  1733. leapday: "29.02.",
  1734. separator: ".",
  1735. alias: "dd/mm/yyyy"
  1736. },
  1737. "dd-mm-yyyy": {
  1738. mask: "1-2-y",
  1739. placeholder: "dd-mm-yyyy",
  1740. leapday: "29-02-",
  1741. separator: "-",
  1742. alias: "dd/mm/yyyy"
  1743. },
  1744. "mm.dd.yyyy": {
  1745. mask: "1.2.y",
  1746. placeholder: "mm.dd.yyyy",
  1747. leapday: "02.29.",
  1748. separator: ".",
  1749. alias: "mm/dd/yyyy"
  1750. },
  1751. "mm-dd-yyyy": {
  1752. mask: "1-2-y",
  1753. placeholder: "mm-dd-yyyy",
  1754. leapday: "02-29-",
  1755. separator: "-",
  1756. alias: "mm/dd/yyyy"
  1757. },
  1758. "yyyy.mm.dd": {
  1759. mask: "y.1.2",
  1760. placeholder: "yyyy.mm.dd",
  1761. leapday: ".02.29",
  1762. separator: ".",
  1763. alias: "yyyy/mm/dd"
  1764. },
  1765. "yyyy-mm-dd": {
  1766. mask: "y-1-2",
  1767. placeholder: "yyyy-mm-dd",
  1768. leapday: "-02-29",
  1769. separator: "-",
  1770. alias: "yyyy/mm/dd"
  1771. },
  1772. datetime: {
  1773. mask: "1/2/y h:s",
  1774. placeholder: "dd/mm/yyyy hh:mm",
  1775. alias: "dd/mm/yyyy",
  1776. regex: {
  1777. hrspre: new RegExp("[012]"),
  1778. hrs24: new RegExp("2[0-4]|1[3-9]"),
  1779. hrs: new RegExp("[01][0-9]|2[0-4]"),
  1780. ampm: new RegExp("^[a|p|A|P][m|M]"),
  1781. mspre: new RegExp("[0-5]"),
  1782. ms: new RegExp("[0-5][0-9]")
  1783. },
  1784. timeseparator: ":",
  1785. hourFormat: "24",
  1786. definitions: {
  1787. h: {
  1788. validator: function(chrs, maskset, pos, strict, opts) {
  1789. if ("24" === opts.hourFormat && 24 === parseInt(chrs, 10)) return maskset.buffer[pos - 1] = "0",
  1790. maskset.buffer[pos] = "0", {
  1791. refreshFromBuffer: {
  1792. start: pos - 1,
  1793. end: pos
  1794. },
  1795. c: "0"
  1796. };
  1797. var isValid = opts.regex.hrs.test(chrs);
  1798. 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",
  1799. maskset.buffer[pos] = chrs.charAt(0), pos++, {
  1800. refreshFromBuffer: {
  1801. start: pos - 2,
  1802. end: pos
  1803. },
  1804. pos: pos,
  1805. c: opts.timeseparator
  1806. };
  1807. if (isValid && "24" !== opts.hourFormat && opts.regex.hrs24.test(chrs)) {
  1808. var tmp = parseInt(chrs, 10);
  1809. return 24 === tmp ? (maskset.buffer[pos + 5] = "a", maskset.buffer[pos + 6] = "m") : (maskset.buffer[pos + 5] = "p",
  1810. maskset.buffer[pos + 6] = "m"), tmp -= 12, 10 > tmp ? (maskset.buffer[pos] = tmp.toString(),
  1811. maskset.buffer[pos - 1] = "0") : (maskset.buffer[pos] = tmp.toString().charAt(1),
  1812. maskset.buffer[pos - 1] = tmp.toString().charAt(0)), {
  1813. refreshFromBuffer: {
  1814. start: pos - 1,
  1815. end: pos + 6
  1816. },
  1817. c: maskset.buffer[pos]
  1818. };
  1819. }
  1820. return isValid;
  1821. },
  1822. cardinality: 2,
  1823. prevalidator: [ {
  1824. validator: function(chrs, maskset, pos, strict, opts) {
  1825. var isValid = opts.regex.hrspre.test(chrs);
  1826. return strict || isValid || !(isValid = opts.regex.hrs.test("0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
  1827. pos++, {
  1828. pos: pos
  1829. });
  1830. },
  1831. cardinality: 1
  1832. } ]
  1833. },
  1834. s: {
  1835. validator: "[0-5][0-9]",
  1836. cardinality: 2,
  1837. prevalidator: [ {
  1838. validator: function(chrs, maskset, pos, strict, opts) {
  1839. var isValid = opts.regex.mspre.test(chrs);
  1840. return strict || isValid || !(isValid = opts.regex.ms.test("0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
  1841. pos++, {
  1842. pos: pos
  1843. });
  1844. },
  1845. cardinality: 1
  1846. } ]
  1847. },
  1848. t: {
  1849. validator: function(chrs, maskset, pos, strict, opts) {
  1850. return opts.regex.ampm.test(chrs + "m");
  1851. },
  1852. casing: "lower",
  1853. cardinality: 1
  1854. }
  1855. },
  1856. insertMode: !1,
  1857. autoUnmask: !1
  1858. },
  1859. datetime12: {
  1860. mask: "1/2/y h:s t\\m",
  1861. placeholder: "dd/mm/yyyy hh:mm xm",
  1862. alias: "datetime",
  1863. hourFormat: "12"
  1864. },
  1865. "mm/dd/yyyy hh:mm xm": {
  1866. mask: "1/2/y h:s t\\m",
  1867. placeholder: "mm/dd/yyyy hh:mm xm",
  1868. alias: "datetime12",
  1869. regex: {
  1870. val2pre: function(separator) {
  1871. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1872. return new RegExp("((0[13-9]|1[012])" + escapedSeparator + "[0-3])|(02" + escapedSeparator + "[0-2])");
  1873. },
  1874. val2: function(separator) {
  1875. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1876. 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)");
  1877. },
  1878. val1pre: new RegExp("[01]"),
  1879. val1: new RegExp("0[1-9]|1[012]")
  1880. },
  1881. leapday: "02/29/",
  1882. onKeyDown: function(e, buffer, caretPos, opts) {
  1883. var $input = $(this);
  1884. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  1885. var today = new Date();
  1886. $input.val((today.getMonth() + 1).toString() + today.getDate().toString() + today.getFullYear().toString()),
  1887. $input.trigger("setvalue");
  1888. }
  1889. }
  1890. },
  1891. "hh:mm t": {
  1892. mask: "h:s t\\m",
  1893. placeholder: "hh:mm xm",
  1894. alias: "datetime",
  1895. hourFormat: "12"
  1896. },
  1897. "h:s t": {
  1898. mask: "h:s t\\m",
  1899. placeholder: "hh:mm xm",
  1900. alias: "datetime",
  1901. hourFormat: "12"
  1902. },
  1903. "hh:mm:ss": {
  1904. mask: "h:s:s",
  1905. placeholder: "hh:mm:ss",
  1906. alias: "datetime",
  1907. autoUnmask: !1
  1908. },
  1909. "hh:mm": {
  1910. mask: "h:s",
  1911. placeholder: "hh:mm",
  1912. alias: "datetime",
  1913. autoUnmask: !1
  1914. },
  1915. date: {
  1916. alias: "dd/mm/yyyy"
  1917. },
  1918. "mm/yyyy": {
  1919. mask: "1/y",
  1920. placeholder: "mm/yyyy",
  1921. leapday: "donotuse",
  1922. separator: "/",
  1923. alias: "mm/dd/yyyy"
  1924. },
  1925. shamsi: {
  1926. regex: {
  1927. val2pre: function(separator) {
  1928. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1929. return new RegExp("((0[1-9]|1[012])" + escapedSeparator + "[0-3])");
  1930. },
  1931. val2: function(separator) {
  1932. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1933. 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)");
  1934. },
  1935. val1pre: new RegExp("[01]"),
  1936. val1: new RegExp("0[1-9]|1[012]")
  1937. },
  1938. yearrange: {
  1939. minyear: 1300,
  1940. maxyear: 1499
  1941. },
  1942. mask: "y/1/2",
  1943. leapday: "/12/30",
  1944. placeholder: "yyyy/mm/dd",
  1945. alias: "mm/dd/yyyy",
  1946. clearIncomplete: !0
  1947. }
  1948. }), Inputmask;
  1949. }(jQuery, Inputmask), function($, Inputmask) {
  1950. return Inputmask.extendDefinitions({
  1951. A: {
  1952. validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  1953. cardinality: 1,
  1954. casing: "upper"
  1955. },
  1956. "&": {
  1957. validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  1958. cardinality: 1,
  1959. casing: "upper"
  1960. },
  1961. "#": {
  1962. validator: "[0-9A-Fa-f]",
  1963. cardinality: 1,
  1964. casing: "upper"
  1965. }
  1966. }), Inputmask.extendAliases({
  1967. url: {
  1968. definitions: {
  1969. i: {
  1970. validator: ".",
  1971. cardinality: 1
  1972. }
  1973. },
  1974. mask: "(\\http://)|(\\http\\s://)|(ftp://)|(ftp\\s://)i{+}",
  1975. insertMode: !1,
  1976. autoUnmask: !1
  1977. },
  1978. ip: {
  1979. mask: "i[i[i]].i[i[i]].i[i[i]].i[i[i]]",
  1980. definitions: {
  1981. i: {
  1982. validator: function(chrs, maskset, pos, strict, opts) {
  1983. return pos - 1 > -1 && "." !== maskset.buffer[pos - 1] ? (chrs = maskset.buffer[pos - 1] + chrs,
  1984. chrs = pos - 2 > -1 && "." !== maskset.buffer[pos - 2] ? maskset.buffer[pos - 2] + chrs : "0" + chrs) : chrs = "00" + chrs,
  1985. new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]").test(chrs);
  1986. },
  1987. cardinality: 1
  1988. }
  1989. },
  1990. onUnMask: function(maskedValue, unmaskedValue, opts) {
  1991. return maskedValue;
  1992. }
  1993. },
  1994. email: {
  1995. mask: "*{1,64}[.*{1,64}][.*{1,64}][.*{1,64}]@*{1,64}[.*{2,64}][.*{2,6}][.*{1,2}]",
  1996. greedy: !1,
  1997. onBeforePaste: function(pastedValue, opts) {
  1998. return pastedValue = pastedValue.toLowerCase(), pastedValue.replace("mailto:", "");
  1999. },
  2000. definitions: {
  2001. "*": {
  2002. validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~-]",
  2003. cardinality: 1,
  2004. casing: "lower"
  2005. }
  2006. },
  2007. onUnMask: function(maskedValue, unmaskedValue, opts) {
  2008. return maskedValue;
  2009. }
  2010. },
  2011. mac: {
  2012. mask: "##:##:##:##:##:##"
  2013. }
  2014. }), Inputmask;
  2015. }(jQuery, Inputmask), function($, Inputmask) {
  2016. return Inputmask.extendAliases({
  2017. numeric: {
  2018. mask: function(opts) {
  2019. function autoEscape(txt) {
  2020. for (var escapedTxt = "", i = 0; i < txt.length; i++) escapedTxt += opts.definitions[txt.charAt(i)] ? "\\" + txt.charAt(i) : txt.charAt(i);
  2021. return escapedTxt;
  2022. }
  2023. if (0 !== opts.repeat && isNaN(opts.integerDigits) && (opts.integerDigits = opts.repeat),
  2024. opts.repeat = 0, opts.groupSeparator === opts.radixPoint && ("." === opts.radixPoint ? opts.groupSeparator = "," : "," === opts.radixPoint ? opts.groupSeparator = "." : opts.groupSeparator = ""),
  2025. " " === opts.groupSeparator && (opts.skipOptionalPartCharacter = void 0), opts.autoGroup = opts.autoGroup && "" !== opts.groupSeparator,
  2026. opts.autoGroup && ("string" == typeof opts.groupSize && isFinite(opts.groupSize) && (opts.groupSize = parseInt(opts.groupSize)),
  2027. isFinite(opts.integerDigits))) {
  2028. var seps = Math.floor(opts.integerDigits / opts.groupSize), mod = opts.integerDigits % opts.groupSize;
  2029. opts.integerDigits = parseInt(opts.integerDigits) + (0 === mod ? seps - 1 : seps),
  2030. opts.integerDigits < 1 && (opts.integerDigits = "*");
  2031. }
  2032. opts.placeholder.length > 1 && (opts.placeholder = opts.placeholder.charAt(0)),
  2033. opts.radixFocus = opts.radixFocus && "" !== opts.placeholder && opts.integerOptional === !0,
  2034. opts.definitions[";"] = opts.definitions["~"], opts.definitions[";"].definitionSymbol = "~",
  2035. opts.numericInput === !0 && (opts.radixFocus = !1, opts.digitsOptional = !1, isNaN(opts.digits) && (opts.digits = 2),
  2036. opts.decimalProtect = !1);
  2037. var mask = autoEscape(opts.prefix);
  2038. return mask += "[+]", mask += opts.integerOptional === !0 ? "~{1," + opts.integerDigits + "}" : "~{" + opts.integerDigits + "}",
  2039. 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 + "}"),
  2040. "" !== opts.negationSymbol.back && (mask += "[-]"), mask += autoEscape(opts.suffix),
  2041. opts.greedy = !1, mask;
  2042. },
  2043. placeholder: "",
  2044. greedy: !1,
  2045. digits: "*",
  2046. digitsOptional: !0,
  2047. radixPoint: ".",
  2048. radixFocus: !0,
  2049. groupSize: 3,
  2050. groupSeparator: "",
  2051. autoGroup: !1,
  2052. allowPlus: !0,
  2053. allowMinus: !0,
  2054. negationSymbol: {
  2055. front: "-",
  2056. back: ""
  2057. },
  2058. integerDigits: "+",
  2059. integerOptional: !0,
  2060. prefix: "",
  2061. suffix: "",
  2062. rightAlign: !0,
  2063. decimalProtect: !0,
  2064. min: null,
  2065. max: null,
  2066. step: 1,
  2067. insertMode: !0,
  2068. autoUnmask: !1,
  2069. unmaskAsNumber: !1,
  2070. postFormat: function(buffer, pos, reformatOnly, opts) {
  2071. opts.numericInput === !0 && (buffer = buffer.reverse(), isFinite(pos) && (pos = buffer.join("").length - pos - 1));
  2072. var i, l, suffixStripped = !1;
  2073. buffer.length >= opts.suffix.length && buffer.join("").indexOf(opts.suffix) === buffer.length - opts.suffix.length && (buffer.length = buffer.length - opts.suffix.length,
  2074. suffixStripped = !0), pos = pos >= buffer.length ? buffer.length - 1 : pos < opts.prefix.length ? opts.prefix.length : pos;
  2075. var needsRefresh = !1, charAtPos = buffer[pos];
  2076. 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)) {
  2077. if (suffixStripped) for (i = 0, l = opts.suffix.length; l > i; i++) buffer.push(opts.suffix.charAt(i));
  2078. return {
  2079. pos: pos
  2080. };
  2081. }
  2082. var cbuf = buffer.slice();
  2083. charAtPos === opts.groupSeparator && (cbuf.splice(pos--, 1), charAtPos = cbuf[pos]),
  2084. reformatOnly ? charAtPos !== opts.radixPoint && (cbuf[pos] = "?") : cbuf.splice(pos, 0, "?");
  2085. var bufVal = cbuf.join(""), bufValOrigin = bufVal;
  2086. if (bufVal.length > 0 && opts.autoGroup || reformatOnly && -1 !== bufVal.indexOf(opts.groupSeparator)) {
  2087. var escapedGroupSeparator = Inputmask.escapeRegex(opts.groupSeparator);
  2088. needsRefresh = 0 === bufVal.indexOf(opts.groupSeparator), bufVal = bufVal.replace(new RegExp(escapedGroupSeparator, "g"), "");
  2089. var radixSplit = bufVal.split(opts.radixPoint);
  2090. 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"),
  2091. bufVal = bufVal.replace(opts.groupSeparator + opts.groupSeparator, opts.groupSeparator);
  2092. "" !== opts.radixPoint && radixSplit.length > 1 && (bufVal += opts.radixPoint + radixSplit[1]);
  2093. }
  2094. for (needsRefresh = bufValOrigin !== bufVal, buffer.length = bufVal.length, i = 0,
  2095. l = bufVal.length; l > i; i++) buffer[i] = bufVal.charAt(i);
  2096. var newPos = $.inArray("?", buffer);
  2097. if (-1 === newPos && charAtPos === opts.radixPoint && (newPos = $.inArray(opts.radixPoint, buffer)),
  2098. reformatOnly ? buffer[newPos] = charAtPos : buffer.splice(newPos, 1), !needsRefresh && suffixStripped) for (i = 0,
  2099. l = opts.suffix.length; l > i; i++) buffer.push(opts.suffix.charAt(i));
  2100. return newPos = opts.numericInput && isFinite(pos) ? buffer.join("").length - newPos - 1 : newPos,
  2101. opts.numericInput && (buffer = buffer.reverse(), $.inArray(opts.radixPoint, buffer) < newPos && buffer.join("").length - opts.suffix.length !== newPos && (newPos -= 1)),
  2102. {
  2103. pos: newPos,
  2104. refreshFromBuffer: needsRefresh,
  2105. buffer: buffer
  2106. };
  2107. },
  2108. onBeforeWrite: function(e, buffer, caretPos, opts) {
  2109. if (e && ("blur" === e.type || "checkval" === e.type)) {
  2110. var maskedValue = buffer.join(""), processValue = maskedValue.replace(opts.prefix, "");
  2111. if (processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2112. "," === opts.radixPoint && (processValue = processValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".")),
  2113. isFinite(processValue) && isFinite(opts.min) && parseFloat(processValue) < parseFloat(opts.min)) return $.extend(!0, {
  2114. refreshFromBuffer: !0,
  2115. buffer: (opts.prefix + opts.min).split("")
  2116. }, opts.postFormat((opts.prefix + opts.min).split(""), 0, !0, opts));
  2117. if (opts.numericInput !== !0) {
  2118. 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;
  2119. if (matchRslt) {
  2120. 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);
  2121. var radixPosition = $.inArray(opts.radixPoint, buffer);
  2122. if (-1 !== radixPosition) {
  2123. if (isFinite(opts.digits) && !opts.digitsOptional) {
  2124. for (var i = 1; i <= opts.digits; i++) (void 0 === buffer[radixPosition + i] || buffer[radixPosition + i] === opts.placeholder.charAt(0)) && (buffer[radixPosition + i] = "0");
  2125. return {
  2126. refreshFromBuffer: maskedValue !== buffer.join(""),
  2127. buffer: buffer
  2128. };
  2129. }
  2130. if (radixPosition === buffer.length - opts.suffix.length - 1) return buffer.splice(radixPosition, 1),
  2131. {
  2132. refreshFromBuffer: !0,
  2133. buffer: buffer
  2134. };
  2135. }
  2136. }
  2137. }
  2138. }
  2139. if (opts.autoGroup) {
  2140. var rslt = opts.postFormat(buffer, opts.numericInput ? caretPos : caretPos - 1, !0, opts);
  2141. return rslt.caret = caretPos <= opts.prefix.length ? rslt.pos : rslt.pos + 1, rslt;
  2142. }
  2143. },
  2144. regex: {
  2145. integerPart: function(opts) {
  2146. return new RegExp("[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "+]?\\d+");
  2147. },
  2148. integerNPart: function(opts) {
  2149. return new RegExp("[\\d" + Inputmask.escapeRegex(opts.groupSeparator) + "]+");
  2150. }
  2151. },
  2152. signHandler: function(chrs, maskset, pos, strict, opts) {
  2153. if (!strict && opts.allowMinus && "-" === chrs || opts.allowPlus && "+" === chrs) {
  2154. var matchRslt = maskset.buffer.join("").match(opts.regex.integerPart(opts));
  2155. if (matchRslt && matchRslt[0].length > 0) return maskset.buffer[matchRslt.index] === ("-" === chrs ? "+" : opts.negationSymbol.front) ? "-" === chrs ? "" !== opts.negationSymbol.back ? {
  2156. pos: matchRslt.index,
  2157. c: opts.negationSymbol.front,
  2158. remove: matchRslt.index,
  2159. caret: pos,
  2160. insert: {
  2161. pos: maskset.buffer.length - opts.suffix.length - 1,
  2162. c: opts.negationSymbol.back
  2163. }
  2164. } : {
  2165. pos: matchRslt.index,
  2166. c: opts.negationSymbol.front,
  2167. remove: matchRslt.index,
  2168. caret: pos
  2169. } : "" !== opts.negationSymbol.back ? {
  2170. pos: matchRslt.index,
  2171. c: "+",
  2172. remove: [ matchRslt.index, maskset.buffer.length - opts.suffix.length - 1 ],
  2173. caret: pos
  2174. } : {
  2175. pos: matchRslt.index,
  2176. c: "+",
  2177. remove: matchRslt.index,
  2178. caret: pos
  2179. } : maskset.buffer[matchRslt.index] === ("-" === chrs ? opts.negationSymbol.front : "+") ? "-" === chrs && "" !== opts.negationSymbol.back ? {
  2180. remove: [ matchRslt.index, maskset.buffer.length - opts.suffix.length - 1 ],
  2181. caret: pos - 1
  2182. } : {
  2183. remove: matchRslt.index,
  2184. caret: pos - 1
  2185. } : "-" === chrs ? "" !== opts.negationSymbol.back ? {
  2186. pos: matchRslt.index,
  2187. c: opts.negationSymbol.front,
  2188. caret: pos + 1,
  2189. insert: {
  2190. pos: maskset.buffer.length - opts.suffix.length,
  2191. c: opts.negationSymbol.back
  2192. }
  2193. } : {
  2194. pos: matchRslt.index,
  2195. c: opts.negationSymbol.front,
  2196. caret: pos + 1
  2197. } : {
  2198. pos: matchRslt.index,
  2199. c: chrs,
  2200. caret: pos + 1
  2201. };
  2202. }
  2203. return !1;
  2204. },
  2205. radixHandler: function(chrs, maskset, pos, strict, opts) {
  2206. if (!strict && (-1 !== $.inArray(chrs, [ ",", "." ]) && (chrs = opts.radixPoint),
  2207. chrs === opts.radixPoint && void 0 !== opts.digits && (isNaN(opts.digits) || parseInt(opts.digits) > 0))) {
  2208. var radixPos = $.inArray(opts.radixPoint, maskset.buffer), integerValue = maskset.buffer.join("").match(opts.regex.integerPart(opts));
  2209. if (-1 !== radixPos && maskset.validPositions[radixPos]) return maskset.validPositions[radixPos - 1] ? {
  2210. caret: radixPos + 1
  2211. } : {
  2212. pos: integerValue.index,
  2213. c: integerValue[0],
  2214. caret: radixPos + 1
  2215. };
  2216. if (!integerValue || "0" === integerValue[0] && integerValue.index + 1 !== pos) return maskset.buffer[integerValue ? integerValue.index : pos] = "0",
  2217. {
  2218. pos: (integerValue ? integerValue.index : pos) + 1,
  2219. c: opts.radixPoint
  2220. };
  2221. }
  2222. return !1;
  2223. },
  2224. leadingZeroHandler: function(chrs, maskset, pos, strict, opts) {
  2225. if (opts.numericInput === !0) {
  2226. if ("0" === maskset.buffer[maskset.buffer.length - opts.prefix.length - 1]) return {
  2227. pos: pos,
  2228. remove: maskset.buffer.length - opts.prefix.length - 1
  2229. };
  2230. } else {
  2231. var matchRslt = maskset.buffer.join("").match(opts.regex.integerNPart(opts)), radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
  2232. if (matchRslt && !strict && (-1 === radixPosition || radixPosition >= pos)) if (0 === matchRslt[0].indexOf("0")) {
  2233. pos < opts.prefix.length && (pos = matchRslt.index);
  2234. 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("");
  2235. if (-1 === radixPosition || digitsMatch && integerMatch) return maskset.buffer.splice(matchRslt.index, 1),
  2236. pos = pos > matchRslt.index ? pos - 1 : matchRslt.index, {
  2237. pos: pos,
  2238. remove: matchRslt.index
  2239. };
  2240. if (matchRslt.index + 1 === pos || "0" === chrs) return maskset.buffer.splice(matchRslt.index, 1),
  2241. pos = matchRslt.index, {
  2242. pos: pos,
  2243. remove: matchRslt.index
  2244. };
  2245. } else if ("0" === chrs && pos <= matchRslt.index && matchRslt[0] !== opts.groupSeparator) return !1;
  2246. }
  2247. return !0;
  2248. },
  2249. postValidation: function(buffer, opts) {
  2250. var isValid = !0, maskedValue = buffer.join(""), processValue = maskedValue.replace(opts.prefix, "");
  2251. return processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2252. "," === opts.radixPoint && (processValue = processValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".")),
  2253. processValue = processValue.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), "-"),
  2254. processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), ""),
  2255. processValue = processValue === opts.negationSymbol.front ? processValue + "0" : processValue,
  2256. isFinite(processValue) && (null !== opts.max && isFinite(opts.max) && (isValid = parseFloat(processValue) <= parseFloat(opts.max)),
  2257. isValid && null !== opts.min && isFinite(opts.min) && (0 >= processValue || processValue.toString().length >= opts.min.toString().length) && (isValid = parseFloat(processValue) >= parseFloat(opts.min),
  2258. isValid || (isValid = $.extend(!0, {
  2259. refreshFromBuffer: !0,
  2260. buffer: (opts.prefix + opts.min).split("")
  2261. }, opts.postFormat((opts.prefix + opts.min).split(""), 0, !0, opts)), isValid.refreshFromBuffer = !0))),
  2262. isValid;
  2263. },
  2264. definitions: {
  2265. "~": {
  2266. validator: function(chrs, maskset, pos, strict, opts) {
  2267. var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
  2268. if (!isValid && (isValid = opts.radixHandler(chrs, maskset, pos, strict, opts),
  2269. !isValid && (isValid = strict ? new RegExp("[0-9" + Inputmask.escapeRegex(opts.groupSeparator) + "]").test(chrs) : new RegExp("[0-9]").test(chrs),
  2270. isValid === !0 && (isValid = opts.leadingZeroHandler(chrs, maskset, pos, strict, opts),
  2271. isValid === !0)))) {
  2272. var radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
  2273. isValid = -1 !== radixPosition && opts.digitsOptional === !1 && opts.numericInput !== !0 && pos > radixPosition && !strict ? {
  2274. pos: pos,
  2275. remove: pos
  2276. } : {
  2277. pos: pos
  2278. };
  2279. }
  2280. return isValid;
  2281. },
  2282. cardinality: 1,
  2283. prevalidator: null
  2284. },
  2285. "+": {
  2286. validator: function(chrs, maskset, pos, strict, opts) {
  2287. var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
  2288. return !isValid && (strict && opts.allowMinus && chrs === opts.negationSymbol.front || opts.allowMinus && "-" === chrs || opts.allowPlus && "+" === chrs) && (isValid = "-" === chrs ? "" !== opts.negationSymbol.back ? {
  2289. pos: pos,
  2290. c: "-" === chrs ? opts.negationSymbol.front : "+",
  2291. caret: pos + 1,
  2292. insert: {
  2293. pos: maskset.buffer.length,
  2294. c: opts.negationSymbol.back
  2295. }
  2296. } : {
  2297. pos: pos,
  2298. c: "-" === chrs ? opts.negationSymbol.front : "+",
  2299. caret: pos + 1
  2300. } : !0), isValid;
  2301. },
  2302. cardinality: 1,
  2303. prevalidator: null,
  2304. placeholder: ""
  2305. },
  2306. "-": {
  2307. validator: function(chrs, maskset, pos, strict, opts) {
  2308. var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
  2309. return !isValid && strict && opts.allowMinus && chrs === opts.negationSymbol.back && (isValid = !0),
  2310. 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. if (!isValid) {
  2320. var radix = "[" + Inputmask.escapeRegex(opts.radixPoint) + ",\\.]";
  2321. isValid = new RegExp(radix).test(chrs), isValid && maskset.validPositions[pos] && maskset.validPositions[pos].match.placeholder === opts.radixPoint && (isValid = {
  2322. caret: pos + 1
  2323. });
  2324. }
  2325. return isValid ? {
  2326. c: opts.radixPoint
  2327. } : isValid;
  2328. },
  2329. cardinality: 1,
  2330. prevalidator: null,
  2331. placeholder: function(opts) {
  2332. return opts.radixPoint;
  2333. }
  2334. }
  2335. },
  2336. onUnMask: function(maskedValue, unmaskedValue, opts) {
  2337. var processValue = maskedValue.replace(opts.prefix, "");
  2338. return processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2339. opts.unmaskAsNumber ? ("" !== opts.radixPoint && -1 !== processValue.indexOf(opts.radixPoint) && (processValue = processValue.replace(Inputmask.escapeRegex.call(this, opts.radixPoint), ".")),
  2340. Number(processValue)) : processValue;
  2341. },
  2342. isComplete: function(buffer, opts) {
  2343. var maskedValue = buffer.join(""), bufClone = buffer.slice();
  2344. if (opts.postFormat(bufClone, 0, !0, opts), bufClone.join("") !== maskedValue) return !1;
  2345. var processValue = maskedValue.replace(opts.prefix, "");
  2346. return processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2347. "," === opts.radixPoint && (processValue = processValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".")),
  2348. isFinite(processValue);
  2349. },
  2350. onBeforeMask: function(initialValue, opts) {
  2351. if ("" !== opts.radixPoint && isFinite(initialValue)) initialValue = initialValue.toString().replace(".", opts.radixPoint); else {
  2352. var kommaMatches = initialValue.match(/,/g), dotMatches = initialValue.match(/\./g);
  2353. dotMatches && kommaMatches ? dotMatches.length > kommaMatches.length ? (initialValue = initialValue.replace(/\./g, ""),
  2354. initialValue = initialValue.replace(",", opts.radixPoint)) : kommaMatches.length > dotMatches.length ? (initialValue = initialValue.replace(/,/g, ""),
  2355. 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"), "");
  2356. }
  2357. if (0 === opts.digits && (-1 !== initialValue.indexOf(".") ? initialValue = initialValue.substring(0, initialValue.indexOf(".")) : -1 !== initialValue.indexOf(",") && (initialValue = initialValue.substring(0, initialValue.indexOf(",")))),
  2358. "" !== opts.radixPoint && isFinite(opts.digits) && -1 !== initialValue.indexOf(opts.radixPoint)) {
  2359. var valueParts = initialValue.split(opts.radixPoint), decPart = valueParts[1].match(new RegExp("\\d*"))[0];
  2360. if (parseInt(opts.digits) < decPart.toString().length) {
  2361. var digitsFactor = Math.pow(10, parseInt(opts.digits));
  2362. initialValue = initialValue.replace(Inputmask.escapeRegex(opts.radixPoint), "."),
  2363. initialValue = Math.round(parseFloat(initialValue) * digitsFactor) / digitsFactor,
  2364. initialValue = initialValue.toString().replace(".", opts.radixPoint);
  2365. }
  2366. }
  2367. return initialValue.toString();
  2368. },
  2369. canClearPosition: function(maskset, position, lvp, strict, opts) {
  2370. 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;
  2371. if (canClear && isFinite(positionInput)) {
  2372. var matchRslt, radixPos = $.inArray(opts.radixPoint, maskset.buffer), radixInjection = !1;
  2373. if (void 0 === maskset.validPositions[radixPos] && (maskset.validPositions[radixPos] = {
  2374. input: opts.radixPoint
  2375. }, radixInjection = !0), !strict && maskset.buffer) {
  2376. matchRslt = maskset.buffer.join("").substr(0, position).match(opts.regex.integerNPart(opts));
  2377. var pos = position + 1, isNull = null == matchRslt || 0 === parseInt(matchRslt[0].replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""));
  2378. if (isNull) for (;maskset.validPositions[pos] && (maskset.validPositions[pos].input === opts.groupSeparator || "0" === maskset.validPositions[pos].input); ) delete maskset.validPositions[pos],
  2379. pos++;
  2380. }
  2381. var buffer = [];
  2382. for (var vp in maskset.validPositions) void 0 !== maskset.validPositions[vp].input && buffer.push(maskset.validPositions[vp].input);
  2383. if (radixInjection && delete maskset.validPositions[radixPos], radixPos > 0) {
  2384. var bufVal = buffer.join("");
  2385. 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 {
  2386. var intPart = parseInt(matchRslt[0].replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "")), radixPart = parseInt(bufVal.split(opts.radixPoint)[1]);
  2387. 10 > intPart && maskset.validPositions[position] && ("0" !== opts.placeholder || radixPart > 0) && (maskset.validPositions[position].input = "0",
  2388. maskset.p = opts.prefix.length + 1, canClear = !1);
  2389. } else 0 === matchRslt[0].indexOf("0") && 3 === bufVal.length && (maskset.validPositions = {},
  2390. canClear = !1);
  2391. }
  2392. }
  2393. return canClear;
  2394. },
  2395. onKeyDown: function(e, buffer, caretPos, opts) {
  2396. var $input = $(this);
  2397. if (e.ctrlKey) switch (e.keyCode) {
  2398. case Inputmask.keyCode.UP:
  2399. $input.val(parseFloat(this.inputmask.unmaskedvalue()) + parseInt(opts.step)), $input.trigger("setvalue");
  2400. break;
  2401. case Inputmask.keyCode.DOWN:
  2402. $input.val(parseFloat(this.inputmask.unmaskedvalue()) - parseInt(opts.step)), $input.trigger("setvalue");
  2403. }
  2404. }
  2405. },
  2406. currency: {
  2407. prefix: "$ ",
  2408. groupSeparator: ",",
  2409. alias: "numeric",
  2410. placeholder: "0",
  2411. autoGroup: !0,
  2412. digits: 2,
  2413. digitsOptional: !1,
  2414. clearMaskOnLostFocus: !1
  2415. },
  2416. decimal: {
  2417. alias: "numeric"
  2418. },
  2419. integer: {
  2420. alias: "numeric",
  2421. digits: 0,
  2422. radixPoint: ""
  2423. },
  2424. percentage: {
  2425. alias: "numeric",
  2426. digits: 2,
  2427. radixPoint: ".",
  2428. placeholder: "0",
  2429. autoGroup: !1,
  2430. min: 0,
  2431. max: 100,
  2432. suffix: " %",
  2433. allowPlus: !1,
  2434. allowMinus: !1
  2435. }
  2436. }), Inputmask;
  2437. }(jQuery, Inputmask), function($, Inputmask) {
  2438. return Inputmask.extendAliases({
  2439. phone: {
  2440. url: "phone-codes/phone-codes.js",
  2441. countrycode: "",
  2442. mask: function(opts) {
  2443. opts.definitions["#"] = opts.definitions[9];
  2444. var maskList = [];
  2445. return $.ajax({
  2446. url: opts.url,
  2447. async: !1,
  2448. dataType: "json",
  2449. success: function(response) {
  2450. maskList = response;
  2451. },
  2452. error: function(xhr, ajaxOptions, thrownError) {
  2453. alert(thrownError + " - " + opts.url);
  2454. }
  2455. }), maskList = maskList.sort(function(a, b) {
  2456. return (a.mask || a) < (b.mask || b) ? -1 : 1;
  2457. });
  2458. },
  2459. keepStatic: !1,
  2460. nojumps: !0,
  2461. nojumpsThreshold: 1,
  2462. onBeforeMask: function(value, opts) {
  2463. var processedValue = value.replace(/^0/g, "");
  2464. return (processedValue.indexOf(opts.countrycode) > 1 || -1 === processedValue.indexOf(opts.countrycode)) && (processedValue = "+" + opts.countrycode + processedValue),
  2465. processedValue;
  2466. }
  2467. },
  2468. phonebe: {
  2469. alias: "phone",
  2470. url: "phone-codes/phone-be.js",
  2471. countrycode: "32",
  2472. nojumpsThreshold: 4
  2473. }
  2474. }), Inputmask;
  2475. }(jQuery, Inputmask), function($, Inputmask) {
  2476. return Inputmask.extendAliases({
  2477. Regex: {
  2478. mask: "r",
  2479. greedy: !1,
  2480. repeat: "*",
  2481. regex: null,
  2482. regexTokens: null,
  2483. 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,
  2484. quantifierFilter: /[0-9]+[^,]/,
  2485. isComplete: function(buffer, opts) {
  2486. return new RegExp(opts.regex).test(buffer.join(""));
  2487. },
  2488. definitions: {
  2489. r: {
  2490. validator: function(chrs, maskset, pos, strict, opts) {
  2491. function RegexToken(isGroup, isQuantifier) {
  2492. this.matches = [], this.isGroup = isGroup || !1, this.isQuantifier = isQuantifier || !1,
  2493. this.quantifier = {
  2494. min: 1,
  2495. max: 1
  2496. }, this.repeaterPart = void 0;
  2497. }
  2498. function analyseRegex() {
  2499. var match, m, currentToken = new RegexToken(), opengroups = [];
  2500. for (opts.regexTokens = []; match = opts.tokenizer.exec(opts.regex); ) switch (m = match[0],
  2501. m.charAt(0)) {
  2502. case "(":
  2503. opengroups.push(new RegexToken(!0));
  2504. break;
  2505. case ")":
  2506. groupToken = opengroups.pop(), opengroups.length > 0 ? opengroups[opengroups.length - 1].matches.push(groupToken) : currentToken.matches.push(groupToken);
  2507. break;
  2508. case "{":
  2509. case "+":
  2510. case "*":
  2511. var quantifierToken = new RegexToken(!1, !0);
  2512. m = m.replace(/[{}]/g, "");
  2513. 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]);
  2514. if (quantifierToken.quantifier = {
  2515. min: mq0,
  2516. max: mq1
  2517. }, opengroups.length > 0) {
  2518. var matches = opengroups[opengroups.length - 1].matches;
  2519. match = matches.pop(), match.isGroup || (groupToken = new RegexToken(!0), groupToken.matches.push(match),
  2520. match = groupToken), matches.push(match), matches.push(quantifierToken);
  2521. } else match = currentToken.matches.pop(), match.isGroup || (groupToken = new RegexToken(!0),
  2522. groupToken.matches.push(match), match = groupToken), currentToken.matches.push(match),
  2523. currentToken.matches.push(quantifierToken);
  2524. break;
  2525. default:
  2526. opengroups.length > 0 ? opengroups[opengroups.length - 1].matches.push(m) : currentToken.matches.push(m);
  2527. }
  2528. currentToken.matches.length > 0 && opts.regexTokens.push(currentToken);
  2529. }
  2530. function validateRegexToken(token, fromGroup) {
  2531. var isvalid = !1;
  2532. fromGroup && (regexPart += "(", openGroupCount++);
  2533. for (var mndx = 0; mndx < token.matches.length; mndx++) {
  2534. var matchToken = token.matches[mndx];
  2535. if (matchToken.isGroup === !0) isvalid = validateRegexToken(matchToken, !0); else if (matchToken.isQuantifier === !0) {
  2536. var crrntndx = $.inArray(matchToken, token.matches), matchGroup = token.matches[crrntndx - 1], regexPartBak = regexPart;
  2537. if (isNaN(matchToken.quantifier.max)) {
  2538. for (;matchToken.repeaterPart && matchToken.repeaterPart !== regexPart && matchToken.repeaterPart.length > regexPart.length && !(isvalid = validateRegexToken(matchGroup, !0)); ) ;
  2539. isvalid = isvalid || validateRegexToken(matchGroup, !0), isvalid && (matchToken.repeaterPart = regexPart),
  2540. regexPart = regexPartBak + matchToken.quantifier.max;
  2541. } else {
  2542. for (var i = 0, qm = matchToken.quantifier.max - 1; qm > i && !(isvalid = validateRegexToken(matchGroup, !0)); i++) ;
  2543. regexPart = regexPartBak + "{" + matchToken.quantifier.min + "," + matchToken.quantifier.max + "}";
  2544. }
  2545. } else if (void 0 !== matchToken.matches) for (var k = 0; k < matchToken.length && !(isvalid = validateRegexToken(matchToken[k], fromGroup)); k++) ; else {
  2546. var testExp;
  2547. if ("[" == matchToken.charAt(0)) {
  2548. testExp = regexPart, testExp += matchToken;
  2549. for (var j = 0; openGroupCount > j; j++) testExp += ")";
  2550. var exp = new RegExp("^(" + testExp + ")$");
  2551. isvalid = exp.test(bufferStr);
  2552. } else for (var l = 0, tl = matchToken.length; tl > l; l++) if ("\\" !== matchToken.charAt(l)) {
  2553. testExp = regexPart, testExp += matchToken.substr(0, l + 1), testExp = testExp.replace(/\|$/, "");
  2554. for (var j = 0; openGroupCount > j; j++) testExp += ")";
  2555. var exp = new RegExp("^(" + testExp + ")$");
  2556. if (isvalid = exp.test(bufferStr)) break;
  2557. }
  2558. regexPart += matchToken;
  2559. }
  2560. if (isvalid) break;
  2561. }
  2562. return fromGroup && (regexPart += ")", openGroupCount--), isvalid;
  2563. }
  2564. var groupToken, cbuffer = maskset.buffer.slice(), regexPart = "", isValid = !1, openGroupCount = 0;
  2565. null === opts.regexTokens && analyseRegex(), cbuffer.splice(pos, 0, chrs);
  2566. for (var bufferStr = cbuffer.join(""), i = 0; i < opts.regexTokens.length; i++) {
  2567. var regexToken = opts.regexTokens[i];
  2568. if (isValid = validateRegexToken(regexToken, regexToken.isGroup)) break;
  2569. }
  2570. return isValid;
  2571. },
  2572. cardinality: 1
  2573. }
  2574. }
  2575. }
  2576. }), Inputmask;
  2577. }(jQuery, Inputmask);