jquery.inputmask.bundle.js 125 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135
  1. /*!
  2. * jquery.inputmask.bundle
  3. * http://github.com/RobinHerbots/jquery.inputmask
  4. * Copyright (c) 2010 - 2014 Robin Herbots
  5. * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
  6. * Version: 3.1.32
  7. */
  8. !function($) {
  9. function isInputEventSupported(eventName) {
  10. var el = document.createElement("input"), evName = "on" + eventName, isSupported = evName in el;
  11. return isSupported || (el.setAttribute(evName, "return;"), isSupported = "function" == typeof el[evName]),
  12. el = null, isSupported;
  13. }
  14. function isInputTypeSupported(inputType) {
  15. var isSupported = "text" == inputType || "tel" == inputType;
  16. if (!isSupported) {
  17. var el = document.createElement("input");
  18. el.setAttribute("type", inputType), isSupported = "text" === el.type, el = null;
  19. }
  20. return isSupported;
  21. }
  22. function resolveAlias(aliasStr, options, opts) {
  23. var aliasDefinition = opts.aliases[aliasStr];
  24. return aliasDefinition ? (aliasDefinition.alias && resolveAlias(aliasDefinition.alias, void 0, opts),
  25. $.extend(!0, opts, aliasDefinition), $.extend(!0, opts, options), !0) : !1;
  26. }
  27. function generateMaskSet(opts, multi) {
  28. function analyseMask(mask) {
  29. function maskToken(isGroup, isOptional, isQuantifier, isAlternator) {
  30. this.matches = [], this.isGroup = isGroup || !1, this.isOptional = isOptional || !1,
  31. this.isQuantifier = isQuantifier || !1, this.isAlternator = isAlternator || !1,
  32. this.quantifier = {
  33. min: 1,
  34. max: 1
  35. };
  36. }
  37. function insertTestDefinition(mtoken, element, position) {
  38. var maskdef = opts.definitions[element], newBlockMarker = 0 == mtoken.matches.length;
  39. if (position = void 0 != position ? position : mtoken.matches.length, maskdef && !escaped) {
  40. for (var prevalidators = maskdef.prevalidator, prevalidatorsL = prevalidators ? prevalidators.length : 0, i = 1; i < maskdef.cardinality; i++) {
  41. var prevalidator = prevalidatorsL >= i ? prevalidators[i - 1] : [], validator = prevalidator.validator, cardinality = prevalidator.cardinality;
  42. mtoken.matches.splice(position++, 0, {
  43. fn: validator ? "string" == typeof validator ? new RegExp(validator) : new function() {
  44. this.test = validator;
  45. }() : new RegExp("."),
  46. cardinality: cardinality ? cardinality : 1,
  47. optionality: mtoken.isOptional,
  48. newBlockMarker: newBlockMarker,
  49. casing: maskdef.casing,
  50. def: maskdef.definitionSymbol || element,
  51. placeholder: maskdef.placeholder,
  52. mask: element
  53. });
  54. }
  55. mtoken.matches.splice(position++, 0, {
  56. fn: maskdef.validator ? "string" == typeof maskdef.validator ? new RegExp(maskdef.validator) : new function() {
  57. this.test = maskdef.validator;
  58. }() : new RegExp("."),
  59. cardinality: maskdef.cardinality,
  60. optionality: mtoken.isOptional,
  61. newBlockMarker: newBlockMarker,
  62. casing: maskdef.casing,
  63. def: maskdef.definitionSymbol || element,
  64. placeholder: maskdef.placeholder,
  65. mask: element
  66. });
  67. } else mtoken.matches.splice(position++, 0, {
  68. fn: null,
  69. cardinality: 0,
  70. optionality: mtoken.isOptional,
  71. newBlockMarker: newBlockMarker,
  72. casing: null,
  73. def: element,
  74. placeholder: void 0,
  75. mask: element
  76. }), escaped = !1;
  77. }
  78. for (var match, m, openingToken, currentOpeningToken, alternator, lastMatch, tokenizer = /(?:[?*+]|\{[0-9\+\*]+(?:,[0-9\+\*]*)?\})\??|[^.?*+^${[]()|\\]+|./g, escaped = !1, currentToken = new maskToken(), openenings = [], maskTokens = []; match = tokenizer.exec(mask); ) switch (m = match[0],
  79. m.charAt(0)) {
  80. case opts.optionalmarker.end:
  81. case opts.groupmarker.end:
  82. if (openingToken = openenings.pop(), openenings.length > 0) {
  83. if (currentOpeningToken = openenings[openenings.length - 1], currentOpeningToken.matches.push(openingToken),
  84. currentOpeningToken.isAlternator) {
  85. alternator = openenings.pop();
  86. for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
  87. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  88. currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
  89. }
  90. } else currentToken.matches.push(openingToken);
  91. break;
  92. case opts.optionalmarker.start:
  93. openenings.push(new maskToken(!1, !0));
  94. break;
  95. case opts.groupmarker.start:
  96. openenings.push(new maskToken(!0));
  97. break;
  98. case opts.quantifiermarker.start:
  99. var quantifier = new maskToken(!1, !1, !0);
  100. m = m.replace(/[{}]/g, "");
  101. 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]);
  102. if (("*" == mq1 || "+" == mq1) && (mq0 = "*" == mq1 ? 0 : 1), quantifier.quantifier = {
  103. min: mq0,
  104. max: mq1
  105. }, openenings.length > 0) {
  106. var matches = openenings[openenings.length - 1].matches;
  107. if (match = matches.pop(), !match.isGroup) {
  108. var groupToken = new maskToken(!0);
  109. groupToken.matches.push(match), match = groupToken;
  110. }
  111. matches.push(match), matches.push(quantifier);
  112. } else {
  113. if (match = currentToken.matches.pop(), !match.isGroup) {
  114. var groupToken = new maskToken(!0);
  115. groupToken.matches.push(match), match = groupToken;
  116. }
  117. currentToken.matches.push(match), currentToken.matches.push(quantifier);
  118. }
  119. break;
  120. case opts.escapeChar:
  121. escaped = !0;
  122. break;
  123. case opts.alternatormarker:
  124. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  125. lastMatch = currentOpeningToken.matches.pop()) : lastMatch = currentToken.matches.pop(),
  126. lastMatch.isAlternator ? openenings.push(lastMatch) : (alternator = new maskToken(!1, !1, !1, !0),
  127. alternator.matches.push(lastMatch), openenings.push(alternator));
  128. break;
  129. default:
  130. if (openenings.length > 0) {
  131. if (currentOpeningToken = openenings[openenings.length - 1], currentOpeningToken.matches.length > 0 && (lastMatch = currentOpeningToken.matches[currentOpeningToken.matches.length - 1],
  132. lastMatch.isGroup && (lastMatch.isGroup = !1, insertTestDefinition(lastMatch, opts.groupmarker.start, 0),
  133. insertTestDefinition(lastMatch, opts.groupmarker.end))), insertTestDefinition(currentOpeningToken, m),
  134. currentOpeningToken.isAlternator) {
  135. alternator = openenings.pop();
  136. for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
  137. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  138. currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
  139. }
  140. } else currentToken.matches.length > 0 && (lastMatch = currentToken.matches[currentToken.matches.length - 1],
  141. lastMatch.isGroup && (lastMatch.isGroup = !1, insertTestDefinition(lastMatch, opts.groupmarker.start, 0),
  142. insertTestDefinition(lastMatch, opts.groupmarker.end))), insertTestDefinition(currentToken, m);
  143. }
  144. return currentToken.matches.length > 0 && (lastMatch = currentToken.matches[currentToken.matches.length - 1],
  145. lastMatch.isGroup && (lastMatch.isGroup = !1, insertTestDefinition(lastMatch, opts.groupmarker.start, 0),
  146. insertTestDefinition(lastMatch, opts.groupmarker.end)), maskTokens.push(currentToken)),
  147. maskTokens;
  148. }
  149. function generateMask(mask, metadata) {
  150. if (opts.numericInput && opts.multi !== !0) {
  151. mask = mask.split("").reverse();
  152. for (var ndx = 0; ndx < mask.length; ndx++) mask[ndx] == opts.optionalmarker.start ? mask[ndx] = opts.optionalmarker.end : mask[ndx] == opts.optionalmarker.end ? mask[ndx] = opts.optionalmarker.start : mask[ndx] == opts.groupmarker.start ? mask[ndx] = opts.groupmarker.end : mask[ndx] == opts.groupmarker.end && (mask[ndx] = opts.groupmarker.start);
  153. mask = mask.join("");
  154. }
  155. if (void 0 == mask || "" == mask) return void 0;
  156. if (1 == mask.length && 0 == opts.greedy && 0 != opts.repeat && (opts.placeholder = ""),
  157. opts.repeat > 0 || "*" == opts.repeat || "+" == opts.repeat) {
  158. var repeatStart = "*" == opts.repeat ? 0 : "+" == opts.repeat ? 1 : opts.repeat;
  159. mask = opts.groupmarker.start + mask + opts.groupmarker.end + opts.quantifiermarker.start + repeatStart + "," + opts.repeat + opts.quantifiermarker.end;
  160. }
  161. return void 0 == $.inputmask.masksCache[mask] && ($.inputmask.masksCache[mask] = {
  162. mask: mask,
  163. maskToken: analyseMask(mask),
  164. validPositions: {},
  165. _buffer: void 0,
  166. buffer: void 0,
  167. tests: {},
  168. metadata: metadata
  169. }), $.extend(!0, {}, $.inputmask.masksCache[mask]);
  170. }
  171. var ms = void 0;
  172. if ($.isFunction(opts.mask) && (opts.mask = opts.mask.call(this, opts)), $.isArray(opts.mask)) if (multi) ms = [],
  173. $.each(opts.mask, function(ndx, msk) {
  174. ms.push(void 0 == msk.mask || $.isFunction(msk.mask) ? generateMask(msk.toString(), msk) : generateMask(msk.mask.toString(), msk));
  175. }); else {
  176. opts.keepStatic = void 0 == opts.keepStatic ? !0 : opts.keepStatic;
  177. var altMask = "(";
  178. $.each(opts.mask, function(ndx, msk) {
  179. altMask.length > 1 && (altMask += ")|("), altMask += void 0 == msk.mask || $.isFunction(msk.mask) ? msk.toString() : msk.mask.toString();
  180. }), altMask += ")", ms = generateMask(altMask, opts.mask);
  181. } else opts.mask && (ms = void 0 == opts.mask.mask || $.isFunction(opts.mask.mask) ? generateMask(opts.mask.toString(), opts.mask) : generateMask(opts.mask.mask.toString(), opts.mask));
  182. return ms;
  183. }
  184. function maskScope(actionObj, maskset, opts) {
  185. function getMaskTemplate(baseOnInput, minimalPos, includeInput) {
  186. minimalPos = minimalPos || 0;
  187. var ndxIntlzr, test, testPos, maskTemplate = [], pos = 0;
  188. do {
  189. if (baseOnInput === !0 && getMaskSet().validPositions[pos]) {
  190. var validPos = getMaskSet().validPositions[pos];
  191. test = validPos.match, ndxIntlzr = validPos.locator.slice(), maskTemplate.push(includeInput === !0 ? validPos.input : getPlaceholder(pos, test));
  192. } else {
  193. if (minimalPos > pos) {
  194. var testPositions = getTests(pos, ndxIntlzr, pos - 1);
  195. testPos = testPositions[0];
  196. } else testPos = getTestTemplate(pos, ndxIntlzr, pos - 1);
  197. test = testPos.match, ndxIntlzr = testPos.locator.slice(), maskTemplate.push(getPlaceholder(pos, test));
  198. }
  199. pos++;
  200. } while ((void 0 == maxLength || maxLength > pos - 1) && null != test.fn || null == test.fn && "" != test.def || minimalPos >= pos);
  201. return maskTemplate.pop(), maskTemplate;
  202. }
  203. function getMaskSet() {
  204. return maskset;
  205. }
  206. function resetMaskSet(soft) {
  207. var maskset = getMaskSet();
  208. maskset.buffer = void 0, maskset.tests = {}, soft !== !0 && (maskset._buffer = void 0,
  209. maskset.validPositions = {}, maskset.p = 0);
  210. }
  211. function getLastValidPosition(closestTo) {
  212. var maskset = getMaskSet(), lastValidPosition = -1, valids = maskset.validPositions;
  213. void 0 == closestTo && (closestTo = -1);
  214. var before = lastValidPosition, after = lastValidPosition;
  215. for (var posNdx in valids) {
  216. var psNdx = parseInt(posNdx);
  217. (-1 == closestTo || null != valids[psNdx].match.fn) && (closestTo >= psNdx && (before = psNdx),
  218. psNdx >= closestTo && (after = psNdx));
  219. }
  220. return lastValidPosition = closestTo - before > 1 || closestTo > after ? before : after;
  221. }
  222. function setValidPosition(pos, validTest, fromSetValid) {
  223. if (opts.insertMode && void 0 != getMaskSet().validPositions[pos] && void 0 == fromSetValid) {
  224. var i, positionsClone = $.extend(!0, {}, getMaskSet().validPositions), lvp = getLastValidPosition();
  225. for (i = pos; lvp >= i; i++) delete getMaskSet().validPositions[i];
  226. getMaskSet().validPositions[pos] = validTest;
  227. var j, valid = !0;
  228. for (i = pos; lvp >= i; i++) {
  229. var t = positionsClone[i];
  230. if (void 0 != t) {
  231. var vps = getMaskSet().validPositions;
  232. j = !opts.keepStatic && (void 0 != vps[i + 1] && getTests(i + 1, vps[i].locator.slice(), i).length > 1 || vps[i] && void 0 != vps[i].alternation) ? i + 1 : seekNext(i),
  233. valid = positionCanMatchDefinition(j, t.match.def) ? valid && isValid(j, t.input, !0, !0) !== !1 : null == t.match.fn;
  234. }
  235. if (!valid) break;
  236. }
  237. if (!valid) return getMaskSet().validPositions = $.extend(!0, {}, positionsClone),
  238. !1;
  239. } else getMaskSet().validPositions[pos] = validTest;
  240. return !0;
  241. }
  242. function stripValidPositions(start, end) {
  243. var i, startPos = start;
  244. for (void 0 != getMaskSet().validPositions[start] && getMaskSet().validPositions[start].input == opts.radixPoint && (end++,
  245. startPos++), i = startPos; end > i; i++) void 0 == getMaskSet().validPositions[i] || getMaskSet().validPositions[i].input == opts.radixPoint && i != getLastValidPosition() || delete getMaskSet().validPositions[i];
  246. for (i = end; i <= getLastValidPosition(); ) {
  247. var t = getMaskSet().validPositions[i], s = getMaskSet().validPositions[startPos];
  248. void 0 != t && void 0 == s ? (positionCanMatchDefinition(startPos, t.match.def) && isValid(startPos, t.input, !0) !== !1 && (delete getMaskSet().validPositions[i],
  249. i++), startPos++) : i++;
  250. }
  251. var lvp = getLastValidPosition();
  252. lvp >= start && void 0 != getMaskSet().validPositions[lvp] && getMaskSet().validPositions[lvp].input == opts.radixPoint && delete getMaskSet().validPositions[lvp],
  253. resetMaskSet(!0);
  254. }
  255. function getTestTemplate(pos, ndxIntlzr, tstPs) {
  256. function checkAlternationMatch(test, altNdx, altArr) {
  257. for (var isMatch = !1, altLocArr = test.locator[altNdx].toString().split(","), alndx = 0; alndx < altLocArr.length; alndx++) if (-1 != $.inArray(altLocArr[alndx], altArr)) {
  258. isMatch = !0;
  259. break;
  260. }
  261. return isMatch;
  262. }
  263. for (var testPos, testPositions = getTests(pos, ndxIntlzr, tstPs), lvp = getLastValidPosition(), lvTest = getMaskSet().validPositions[lvp] || getTests(0)[0], lvTestAltArr = void 0 != lvTest.alternation ? lvTest.locator[lvTest.alternation].split(",") : [], ndx = 0; ndx < testPositions.length && (testPos = testPositions[ndx],
  264. !(opts.greedy || testPos.match && (testPos.match.optionality === !1 || testPos.match.newBlockMarker === !1) && testPos.match.optionalQuantifier !== !0 && (void 0 == lvTest.alternation || void 0 != testPos.locator[lvTest.alternation] && checkAlternationMatch(testPos, lvTest.alternation, lvTestAltArr)))); ndx++) ;
  265. return testPos;
  266. }
  267. function getTest(pos) {
  268. return getMaskSet().validPositions[pos] ? getMaskSet().validPositions[pos].match : getTests(pos)[0].match;
  269. }
  270. function positionCanMatchDefinition(pos, def) {
  271. for (var valid = !1, tests = getTests(pos), tndx = 0; tndx < tests.length; tndx++) if (tests[tndx].match && tests[tndx].match.def == def) {
  272. valid = !0;
  273. break;
  274. }
  275. return valid;
  276. }
  277. function getTests(pos, ndxIntlzr, tstPs) {
  278. function ResolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) {
  279. function handleMatch(match, loopNdx, quantifierRecurse) {
  280. if (testPos > 1e4) return alert("jquery.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),
  281. !0;
  282. if (testPos == pos && void 0 == match.matches) return matches.push({
  283. match: match,
  284. locator: loopNdx.reverse()
  285. }), !0;
  286. if (void 0 != match.matches) {
  287. if (match.isGroup && quantifierRecurse !== !0) {
  288. if (match = handleMatch(maskToken.matches[tndx + 1], loopNdx)) return !0;
  289. } else if (match.isOptional) {
  290. var optionalToken = match;
  291. if (match = ResolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) {
  292. var latestMatch = matches[matches.length - 1].match, isFirstMatch = 0 == $.inArray(latestMatch, optionalToken.matches);
  293. isFirstMatch && (insertStop = !0), testPos = pos;
  294. }
  295. } else if (match.isAlternator) {
  296. var maltMatches, alternateToken = match, malternateMatches = [], currentMatches = matches.slice(), loopNdxCnt = loopNdx.length, altIndex = ndxInitializer.length > 0 ? ndxInitializer.shift() : -1;
  297. if (-1 == altIndex || "string" == typeof altIndex) {
  298. var altIndexArr, currentPos = testPos, ndxInitializerClone = ndxInitializer.slice();
  299. "string" == typeof altIndex && (altIndexArr = altIndex.split(","));
  300. for (var amndx = 0; amndx < alternateToken.matches.length; amndx++) {
  301. matches = [], match = handleMatch(alternateToken.matches[amndx], [ amndx ].concat(loopNdx), quantifierRecurse) || match,
  302. maltMatches = matches.slice(), testPos = currentPos, matches = [];
  303. for (var i = 0; i < ndxInitializerClone.length; i++) ndxInitializer[i] = ndxInitializerClone[i];
  304. for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) for (var altMatch = maltMatches[ndx1], ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) {
  305. var altMatch2 = malternateMatches[ndx2];
  306. if (altMatch.match.mask == altMatch2.match.mask && ("string" != typeof altIndex || -1 != $.inArray(altMatch.locator[loopNdxCnt].toString(), altIndexArr))) {
  307. maltMatches.splice(ndx1, 1), altMatch2.locator[loopNdxCnt] = altMatch2.locator[loopNdxCnt] + "," + altMatch.locator[loopNdxCnt],
  308. altMatch2.alternation = loopNdxCnt;
  309. break;
  310. }
  311. }
  312. malternateMatches = malternateMatches.concat(maltMatches);
  313. }
  314. "string" == typeof altIndex && (malternateMatches = $.map(malternateMatches, function(lmnt, ndx) {
  315. if (isFinite(ndx)) {
  316. var mamatch, altLocArr = lmnt.locator[loopNdxCnt].toString().split(",");
  317. lmnt.locator[loopNdxCnt] = void 0, lmnt.alternation = void 0;
  318. for (var alndx = 0; alndx < altLocArr.length; alndx++) mamatch = -1 != $.inArray(altLocArr[alndx], altIndexArr),
  319. mamatch && (void 0 != lmnt.locator[loopNdxCnt] ? (lmnt.locator[loopNdxCnt] += ",",
  320. lmnt.alternation = loopNdxCnt, lmnt.locator[loopNdxCnt] += altLocArr[alndx]) : lmnt.locator[loopNdxCnt] = parseInt(altLocArr[alndx]));
  321. if (void 0 != lmnt.locator[loopNdxCnt]) return lmnt;
  322. }
  323. })), matches = currentMatches.concat(malternateMatches), insertStop = !0;
  324. } else match = handleMatch(alternateToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse);
  325. if (match) return !0;
  326. } else if (match.isQuantifier && quantifierRecurse !== !0) {
  327. var qt = match;
  328. opts.greedy = opts.greedy && isFinite(qt.quantifier.max);
  329. for (var qndx = ndxInitializer.length > 0 && quantifierRecurse !== !0 ? ndxInitializer.shift() : 0; qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max) && pos >= testPos; qndx++) {
  330. var tokenGroup = maskToken.matches[$.inArray(qt, maskToken.matches) - 1];
  331. if (match = handleMatch(tokenGroup, [ qndx ].concat(loopNdx), !0)) {
  332. var latestMatch = matches[matches.length - 1].match;
  333. latestMatch.optionalQuantifier = qndx > qt.quantifier.min - 1;
  334. var isFirstMatch = 0 == $.inArray(latestMatch, tokenGroup.matches);
  335. if (isFirstMatch) {
  336. if (qndx > qt.quantifier.min - 1) {
  337. insertStop = !0, testPos = pos;
  338. break;
  339. }
  340. return !0;
  341. }
  342. return !0;
  343. }
  344. }
  345. } else if (match = ResolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) return !0;
  346. } else testPos++;
  347. }
  348. for (var tndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; tndx < maskToken.matches.length; tndx++) if (maskToken.matches[tndx].isQuantifier !== !0) {
  349. var match = handleMatch(maskToken.matches[tndx], [ tndx ].concat(loopNdx), quantifierRecurse);
  350. if (match && testPos == pos) return match;
  351. if (testPos > pos) break;
  352. }
  353. }
  354. var maskTokens = getMaskSet().maskToken, testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr || [ 0 ], matches = [], insertStop = !1;
  355. if (void 0 == ndxIntlzr) {
  356. for (var test, previousPos = pos - 1; void 0 == (test = getMaskSet().validPositions[previousPos]) && previousPos > -1; ) previousPos--;
  357. if (void 0 != test && previousPos > -1) testPos = previousPos, ndxInitializer = test.locator.slice(); else {
  358. for (previousPos = pos - 1; void 0 == (test = getMaskSet().tests[previousPos]) && previousPos > -1; ) previousPos--;
  359. void 0 != test && previousPos > -1 && (testPos = previousPos, ndxInitializer = test[0].locator.slice());
  360. }
  361. }
  362. for (var mtndx = ndxInitializer.shift(); mtndx < maskTokens.length; mtndx++) {
  363. var match = ResolveTestFromToken(maskTokens[mtndx], ndxInitializer, [ mtndx ]);
  364. if (match && testPos == pos || testPos > pos) break;
  365. }
  366. return (0 == matches.length || insertStop) && matches.push({
  367. match: {
  368. fn: null,
  369. cardinality: 0,
  370. optionality: !0,
  371. casing: null,
  372. def: ""
  373. },
  374. locator: []
  375. }), getMaskSet().tests[pos] = $.extend(!0, [], matches), getMaskSet().tests[pos];
  376. }
  377. function getBufferTemplate() {
  378. return void 0 == getMaskSet()._buffer && (getMaskSet()._buffer = getMaskTemplate(!1, 1)),
  379. getMaskSet()._buffer;
  380. }
  381. function getBuffer() {
  382. return void 0 == getMaskSet().buffer && (getMaskSet().buffer = getMaskTemplate(!0, getLastValidPosition(), !0)),
  383. getMaskSet().buffer;
  384. }
  385. function refreshFromBuffer(start, end) {
  386. var buffer = getBuffer().slice();
  387. if (start === !0) resetMaskSet(), start = 0, end = buffer.length; else for (var i = start; end > i; i++) delete getMaskSet().validPositions[i],
  388. delete getMaskSet().tests[i];
  389. for (var i = start; end > i; i++) buffer[i] != opts.skipOptionalPartCharacter && isValid(i, buffer[i], !0, !0);
  390. }
  391. function casing(elem, test) {
  392. switch (test.casing) {
  393. case "upper":
  394. elem = elem.toUpperCase();
  395. break;
  396. case "lower":
  397. elem = elem.toLowerCase();
  398. }
  399. return elem;
  400. }
  401. function isValid(pos, c, strict, fromSetValid) {
  402. function _isValid(position, c, strict, fromSetValid) {
  403. var rslt = !1;
  404. return $.each(getTests(position), function(ndx, tst) {
  405. for (var test = tst.match, loopend = c ? 1 : 0, chrs = "", i = (getBuffer(), test.cardinality); i > loopend; i--) chrs += getBufferElement(position - (i - 1));
  406. if (c && (chrs += c), rslt = null != test.fn ? test.fn.test(chrs, getMaskSet(), position, strict, opts) : c != test.def && c != opts.skipOptionalPartCharacter || "" == test.def ? !1 : {
  407. c: test.def,
  408. pos: position
  409. }, rslt !== !1) {
  410. var elem = void 0 != rslt.c ? rslt.c : c;
  411. elem = elem == opts.skipOptionalPartCharacter && null === test.fn ? test.def : elem;
  412. var validatedPos = position;
  413. if (void 0 != rslt.remove && stripValidPositions(rslt.remove, rslt.remove + 1),
  414. rslt.refreshFromBuffer) {
  415. var refresh = rslt.refreshFromBuffer;
  416. if (strict = !0, refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end),
  417. void 0 == rslt.pos && void 0 == rslt.c) return rslt.pos = getLastValidPosition(),
  418. !1;
  419. if (validatedPos = void 0 != rslt.pos ? rslt.pos : position, validatedPos != position) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0)),
  420. !1;
  421. } else if (rslt !== !0 && void 0 != rslt.pos && rslt.pos != position && (validatedPos = rslt.pos,
  422. refreshFromBuffer(position, validatedPos), validatedPos != position)) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0)),
  423. !1;
  424. return 1 != rslt && void 0 == rslt.pos && void 0 == rslt.c ? !1 : (ndx > 0 && resetMaskSet(!0),
  425. setValidPosition(validatedPos, $.extend({}, tst, {
  426. input: casing(elem, test)
  427. }), fromSetValid) || (rslt = !1), !1);
  428. }
  429. }), rslt;
  430. }
  431. function alternate(pos, c, strict, fromSetValid) {
  432. var lastAlt, alternation, validPsClone = $.extend(!0, {}, getMaskSet().validPositions);
  433. for (lastAlt = getLastValidPosition(); lastAlt >= 0; lastAlt--) if (getMaskSet().validPositions[lastAlt] && void 0 != getMaskSet().validPositions[lastAlt].alternation) {
  434. alternation = getMaskSet().validPositions[lastAlt].alternation;
  435. break;
  436. }
  437. if (void 0 != alternation) for (var decisionPos in getMaskSet().validPositions) if (parseInt(decisionPos) > parseInt(lastAlt) && void 0 === getMaskSet().validPositions[decisionPos].alternation) {
  438. for (var altPos = getMaskSet().validPositions[decisionPos], decisionTaker = altPos.locator[alternation], altNdxs = getMaskSet().validPositions[lastAlt].locator[alternation].split(","), mndx = 0; mndx < altNdxs.length; mndx++) if (decisionTaker < altNdxs[mndx]) {
  439. for (var possibilityPos, possibilities, dp = decisionPos - 1; dp >= 0; dp--) if (possibilityPos = getMaskSet().validPositions[dp],
  440. void 0 != possibilityPos) {
  441. possibilities = possibilityPos.locator[alternation], possibilityPos.locator[alternation] = altNdxs[mndx];
  442. break;
  443. }
  444. if (decisionTaker != possibilityPos.locator[alternation]) {
  445. for (var buffer = getBuffer().slice(), i = decisionPos; i < getLastValidPosition() + 1; i++) delete getMaskSet().validPositions[i],
  446. delete getMaskSet().tests[i];
  447. resetMaskSet(!0), opts.keepStatic = !opts.keepStatic;
  448. for (var i = decisionPos; i < buffer.length; i++) buffer[i] != opts.skipOptionalPartCharacter && isValid(getLastValidPosition() + 1, buffer[i], !1, !0);
  449. possibilityPos.locator[alternation] = possibilities;
  450. var isValidRslt = isValid(pos, c, strict, fromSetValid);
  451. if (opts.keepStatic = !opts.keepStatic, isValidRslt) return isValidRslt;
  452. resetMaskSet(), getMaskSet().validPositions = $.extend(!0, {}, validPsClone);
  453. }
  454. }
  455. break;
  456. }
  457. return !1;
  458. }
  459. strict = strict === !0;
  460. for (var buffer = getBuffer(), pndx = pos - 1; pndx > -1 && (!getMaskSet().validPositions[pndx] || null != getMaskSet().validPositions[pndx].match.fn); pndx--) void 0 == getMaskSet().validPositions[pndx] && (!isMask(pndx) || buffer[pndx] != getPlaceholder(pndx)) && getTests(pndx).length > 1 && _isValid(pndx, buffer[pndx], !0);
  461. var maskPos = pos, result = !1;
  462. if (fromSetValid && maskPos >= getMaskLength() && resetMaskSet(!0), maskPos < getMaskLength() && (result = _isValid(maskPos, c, strict, fromSetValid),
  463. !strict && result === !1)) {
  464. var currentPosValid = getMaskSet().validPositions[maskPos];
  465. if (!currentPosValid || null != currentPosValid.match.fn || currentPosValid.match.def != c && c != opts.skipOptionalPartCharacter) {
  466. if ((opts.insertMode || void 0 == getMaskSet().validPositions[seekNext(maskPos)]) && !isMask(maskPos)) for (var nPos = maskPos + 1, snPos = seekNext(maskPos); snPos >= nPos; nPos++) if (result = _isValid(nPos, c, strict, fromSetValid),
  467. result !== !1) {
  468. maskPos = nPos;
  469. break;
  470. }
  471. } else result = {
  472. caret: seekNext(maskPos)
  473. };
  474. }
  475. return result === !1 && opts.keepStatic && isComplete(buffer) && (result = alternate(pos, c, strict, fromSetValid)),
  476. result === !0 && (result = {
  477. pos: maskPos
  478. }), result;
  479. }
  480. function isMask(pos) {
  481. var test = getTest(pos);
  482. return null != test.fn ? test.fn : !1;
  483. }
  484. function getMaskLength() {
  485. var maskLength;
  486. if (maxLength = $el.prop("maxLength"), -1 == maxLength && (maxLength = void 0),
  487. 0 == opts.greedy) {
  488. var pos, lvp = getLastValidPosition(), testPos = getMaskSet().validPositions[lvp], ndxIntlzr = void 0 != testPos ? testPos.locator.slice() : void 0;
  489. 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),
  490. ndxIntlzr = testPos.locator.slice();
  491. maskLength = pos;
  492. } else maskLength = getBuffer().length;
  493. return void 0 == maxLength || maxLength > maskLength ? maskLength : maxLength;
  494. }
  495. function seekNext(pos) {
  496. var maskL = getMaskLength();
  497. if (pos >= maskL) return maskL;
  498. for (var position = pos; ++position < maskL && !isMask(position) && (opts.nojumps !== !0 || opts.nojumpsThreshold > position); ) ;
  499. return position;
  500. }
  501. function seekPrevious(pos) {
  502. var position = pos;
  503. if (0 >= position) return 0;
  504. for (;--position > 0 && !isMask(position); ) ;
  505. return position;
  506. }
  507. function getBufferElement(position) {
  508. return void 0 == getMaskSet().validPositions[position] ? getPlaceholder(position) : getMaskSet().validPositions[position].input;
  509. }
  510. function writeBuffer(input, buffer, caretPos) {
  511. input._valueSet(buffer.join("")), void 0 != caretPos && caret(input, caretPos);
  512. }
  513. function getPlaceholder(pos, test) {
  514. test = test || getTest(pos);
  515. var placeholder = $.isFunction(test.placeholder) ? test.placeholder.call(this, opts) : test.placeholder;
  516. return void 0 != placeholder ? placeholder : null == test.fn ? test.def : opts.placeholder.charAt(pos % opts.placeholder.length);
  517. }
  518. function checkVal(input, writeOut, strict, nptvl) {
  519. var inputValue = void 0 != nptvl ? nptvl.slice() : input._valueGet().split("");
  520. resetMaskSet(), writeOut && input._valueSet("");
  521. var staticInput = getBufferTemplate().slice(0, seekNext(-1)).join(""), matches = inputValue.join("").match(new RegExp(escapeRegex(staticInput), "g"));
  522. if (matches && matches.length > 1 && inputValue.splice(0, staticInput.length), $.each(inputValue, function(ndx, charCode) {
  523. var lvp = getLastValidPosition();
  524. -1 == $.inArray(charCode, getBufferTemplate().slice(lvp + 1, getMaskSet().p)) || strict ? (keypressEvent.call(input, void 0, !0, charCode.charCodeAt(0), !1, strict, strict ? ndx : getMaskSet().p),
  525. strict = strict || ndx > 0 && ndx > getMaskSet().p) : keypressEvent.call(input, void 0, !0, charCode.charCodeAt(0), !1, !0, lvp + 1);
  526. }), writeOut) {
  527. var keypressResult = opts.onKeyPress.call(this, void 0, getBuffer(), 0, opts);
  528. handleOnKeyResult(input, keypressResult), writeBuffer(input, getBuffer(), $(input).is(":focus") ? seekNext(getLastValidPosition(0)) : void 0);
  529. }
  530. }
  531. function escapeRegex(str) {
  532. return $.inputmask.escapeRegex.call(this, str);
  533. }
  534. function unmaskedvalue($input) {
  535. if ($input.data("_inputmask") && !$input.hasClass("hasDatepicker")) {
  536. var umValue = [], vps = getMaskSet().validPositions;
  537. for (var pndx in vps) vps[pndx].match && null != vps[pndx].match.fn && umValue.push(vps[pndx].input);
  538. var unmaskedValue = (isRTL ? umValue.reverse() : umValue).join(""), bufferValue = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join("");
  539. return $.isFunction(opts.onUnMask) && (unmaskedValue = opts.onUnMask.call($input, bufferValue, unmaskedValue, opts) || unmaskedValue),
  540. unmaskedValue;
  541. }
  542. return $input[0]._valueGet();
  543. }
  544. function TranslatePosition(pos) {
  545. if (isRTL && "number" == typeof pos && (!opts.greedy || "" != opts.placeholder)) {
  546. var bffrLght = getBuffer().length;
  547. pos = bffrLght - pos;
  548. }
  549. return pos;
  550. }
  551. function caret(input, begin, end) {
  552. var range, npt = input.jquery && input.length > 0 ? input[0] : input;
  553. if ("number" != typeof begin) {
  554. var data = $(npt).data("_inputmask");
  555. return !$(npt).is(":visible") && data && void 0 != data.caret ? (begin = data.caret.begin,
  556. end = data.caret.end) : npt.setSelectionRange ? (begin = npt.selectionStart, end = npt.selectionEnd) : document.selection && document.selection.createRange && (range = document.selection.createRange(),
  557. begin = 0 - range.duplicate().moveStart("character", -1e5), end = begin + range.text.length),
  558. begin = TranslatePosition(begin), end = TranslatePosition(end), {
  559. begin: begin,
  560. end: end
  561. };
  562. }
  563. begin = TranslatePosition(begin), end = TranslatePosition(end), end = "number" == typeof end ? end : begin;
  564. var data = $(npt).data("_inputmask") || {};
  565. data.caret = {
  566. begin: begin,
  567. end: end
  568. }, $(npt).data("_inputmask", data), $(npt).is(":visible") && (npt.scrollLeft = npt.scrollWidth,
  569. 0 == opts.insertMode && begin == end && end++, npt.setSelectionRange ? (npt.selectionStart = begin,
  570. npt.selectionEnd = end) : npt.createTextRange && (range = npt.createTextRange(),
  571. range.collapse(!0), range.moveEnd("character", end), range.moveStart("character", begin),
  572. range.select()));
  573. }
  574. function determineLastRequiredPosition(returnDefinition) {
  575. var pos, testPos, buffer = getBuffer(), bl = buffer.length, lvp = getLastValidPosition(), positions = {}, lvTest = getMaskSet().validPositions[lvp], ndxIntlzr = void 0 != lvTest ? lvTest.locator.slice() : void 0;
  576. for (pos = lvp + 1; pos < buffer.length; pos++) testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
  577. ndxIntlzr = testPos.locator.slice(), positions[pos] = $.extend(!0, {}, testPos);
  578. var lvTestAltArr = lvTest && void 0 != lvTest.alternation ? lvTest.locator[lvTest.alternation].split(",") : [];
  579. for (pos = bl - 1; pos > lvp && (testPos = positions[pos].match, (testPos.optionality || testPos.optionalQuantifier || lvTest && void 0 != lvTest.alternation && void 0 != positions[pos].locator[lvTest.alternation] && -1 != $.inArray(positions[pos].locator[lvTest.alternation].toString(), lvTestAltArr)) && buffer[pos] == getPlaceholder(pos, testPos)); pos--) bl--;
  580. return returnDefinition ? {
  581. l: bl,
  582. def: positions[bl] ? positions[bl].match : void 0
  583. } : bl;
  584. }
  585. function clearOptionalTail(input) {
  586. for (var buffer = getBuffer(), tmpBuffer = buffer.slice(), rl = determineLastRequiredPosition(), lmib = tmpBuffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
  587. tmpBuffer.splice(rl, lmib + 1 - rl), writeBuffer(input, tmpBuffer);
  588. }
  589. function isComplete(buffer) {
  590. if ($.isFunction(opts.isComplete)) return opts.isComplete.call($el, buffer, opts);
  591. if ("*" == opts.repeat) return void 0;
  592. var complete = !1, lrp = determineLastRequiredPosition(!0), aml = seekPrevious(lrp.l), lvp = getLastValidPosition();
  593. if (lvp == aml && (void 0 == lrp.def || lrp.def.newBlockMarker || lrp.def.optionalQuantifier)) {
  594. complete = !0;
  595. for (var i = 0; aml >= i; i++) {
  596. var mask = isMask(i);
  597. if (mask && (void 0 == buffer[i] || buffer[i] == getPlaceholder(i)) || !mask && buffer[i] != getPlaceholder(i)) {
  598. complete = !1;
  599. break;
  600. }
  601. }
  602. }
  603. return complete;
  604. }
  605. function isSelection(begin, end) {
  606. return isRTL ? begin - end > 1 || begin - end == 1 && opts.insertMode : end - begin > 1 || end - begin == 1 && opts.insertMode;
  607. }
  608. function installEventRuler(npt) {
  609. var events = $._data(npt).events;
  610. $.each(events, function(eventType, eventHandlers) {
  611. $.each(eventHandlers, function(ndx, eventHandler) {
  612. if ("inputmask" == eventHandler.namespace && "setvalue" != eventHandler.type) {
  613. var handler = eventHandler.handler;
  614. eventHandler.handler = function(e) {
  615. return this.readOnly || this.disabled ? void e.preventDefault : handler.apply(this, arguments);
  616. };
  617. }
  618. });
  619. });
  620. }
  621. function patchValueProperty(npt) {
  622. function PatchValhook(type) {
  623. if (void 0 == $.valHooks[type] || 1 != $.valHooks[type].inputmaskpatch) {
  624. var valueGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function(elem) {
  625. return elem.value;
  626. }, valueSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function(elem, value) {
  627. return elem.value = value, elem;
  628. };
  629. $.valHooks[type] = {
  630. get: function(elem) {
  631. var $elem = $(elem);
  632. if ($elem.data("_inputmask")) {
  633. if ($elem.data("_inputmask").opts.autoUnmask) return $elem.inputmask("unmaskedvalue");
  634. var result = valueGet(elem), inputData = $elem.data("_inputmask"), maskset = inputData.maskset, bufferTemplate = maskset._buffer;
  635. return bufferTemplate = bufferTemplate ? bufferTemplate.join("") : "", result != bufferTemplate ? result : "";
  636. }
  637. return valueGet(elem);
  638. },
  639. set: function(elem, value) {
  640. var result, $elem = $(elem), inputData = $elem.data("_inputmask");
  641. return inputData ? (result = valueSet(elem, $.isFunction(inputData.opts.onBeforeMask) ? inputData.opts.onBeforeMask.call(el, value, inputData.opts) || value : value),
  642. $elem.triggerHandler("setvalue.inputmask")) : result = valueSet(elem, value), result;
  643. },
  644. inputmaskpatch: !0
  645. };
  646. }
  647. }
  648. function getter() {
  649. var $self = $(this), inputData = $(this).data("_inputmask");
  650. return inputData ? inputData.opts.autoUnmask ? $self.inputmask("unmaskedvalue") : valueGet.call(this) != getBufferTemplate().join("") ? valueGet.call(this) : "" : valueGet.call(this);
  651. }
  652. function setter(value) {
  653. var inputData = $(this).data("_inputmask");
  654. inputData ? (valueSet.call(this, $.isFunction(inputData.opts.onBeforeMask) ? inputData.opts.onBeforeMask.call(el, value, inputData.opts) || value : value),
  655. $(this).triggerHandler("setvalue.inputmask")) : valueSet.call(this, value);
  656. }
  657. function InstallNativeValueSetFallback(npt) {
  658. $(npt).bind("mouseenter.inputmask", function() {
  659. var $input = $(this), input = this, value = input._valueGet();
  660. "" != value && value != getBuffer().join("") && $input.trigger("setvalue");
  661. });
  662. var events = $._data(npt).events, handlers = events.mouseover;
  663. if (handlers) {
  664. for (var ourHandler = handlers[handlers.length - 1], i = handlers.length - 1; i > 0; i--) handlers[i] = handlers[i - 1];
  665. handlers[0] = ourHandler;
  666. }
  667. }
  668. var valueGet, valueSet;
  669. if (!npt._valueGet) {
  670. if (Object.getOwnPropertyDescriptor) {
  671. Object.getOwnPropertyDescriptor(npt, "value");
  672. }
  673. document.__lookupGetter__ && npt.__lookupGetter__("value") ? (valueGet = npt.__lookupGetter__("value"),
  674. valueSet = npt.__lookupSetter__("value"), npt.__defineGetter__("value", getter),
  675. npt.__defineSetter__("value", setter)) : (valueGet = function() {
  676. return npt.value;
  677. }, valueSet = function(value) {
  678. npt.value = value;
  679. }, PatchValhook(npt.type), InstallNativeValueSetFallback(npt)), npt._valueGet = function() {
  680. return isRTL ? valueGet.call(this).split("").reverse().join("") : valueGet.call(this);
  681. }, npt._valueSet = function(value) {
  682. valueSet.call(this, isRTL ? value.split("").reverse().join("") : value);
  683. };
  684. }
  685. }
  686. function handleRemove(input, k, pos) {
  687. function generalize() {
  688. if (opts.keepStatic) {
  689. resetMaskSet(!0);
  690. var lastAlt, validInputs = [];
  691. for (lastAlt = getLastValidPosition(); lastAlt >= 0; lastAlt--) if (getMaskSet().validPositions[lastAlt]) {
  692. if (void 0 != getMaskSet().validPositions[lastAlt].alternation) break;
  693. validInputs.push(getMaskSet().validPositions[lastAlt].input), delete getMaskSet().validPositions[lastAlt];
  694. }
  695. if (lastAlt > 0) for (;validInputs.length > 0; ) getMaskSet().p = seekNext(getLastValidPosition()),
  696. keypressEvent.call(input, void 0, !0, validInputs.pop().charCodeAt(0), !1, !1, getMaskSet().p);
  697. }
  698. }
  699. if ((opts.numericInput || isRTL) && (k == $.inputmask.keyCode.BACKSPACE ? k = $.inputmask.keyCode.DELETE : k == $.inputmask.keyCode.DELETE && (k = $.inputmask.keyCode.BACKSPACE),
  700. isRTL)) {
  701. var pend = pos.end;
  702. pos.end = pos.begin, pos.begin = pend;
  703. }
  704. k == $.inputmask.keyCode.BACKSPACE && pos.end - pos.begin <= 1 ? pos.begin = seekPrevious(pos.begin) : k == $.inputmask.keyCode.DELETE && pos.begin == pos.end && pos.end++,
  705. stripValidPositions(pos.begin, pos.end), generalize();
  706. var firstMaskedPos = getLastValidPosition(pos.begin);
  707. firstMaskedPos < pos.begin ? (-1 == firstMaskedPos && resetMaskSet(), getMaskSet().p = seekNext(firstMaskedPos)) : getMaskSet().p = pos.begin;
  708. }
  709. function handleOnKeyResult(input, keyResult, caretPos) {
  710. if (keyResult && keyResult.refreshFromBuffer) {
  711. var refresh = keyResult.refreshFromBuffer;
  712. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end), resetMaskSet(!0),
  713. void 0 != caretPos && (writeBuffer(input, getBuffer()), caret(input, keyResult.caret || caretPos.begin, keyResult.caret || caretPos.end));
  714. }
  715. }
  716. function keydownEvent(e) {
  717. skipKeyPressEvent = !1;
  718. var input = this, $input = $(input), k = e.keyCode, pos = caret(input);
  719. k == $.inputmask.keyCode.BACKSPACE || k == $.inputmask.keyCode.DELETE || iphone && 127 == k || e.ctrlKey && 88 == k && !isInputEventSupported("cut") ? (e.preventDefault(),
  720. 88 == k && (valueOnFocus = getBuffer().join("")), handleRemove(input, k, pos), writeBuffer(input, getBuffer(), getMaskSet().p),
  721. input._valueGet() == getBufferTemplate().join("") && $input.trigger("cleared"),
  722. opts.showTooltip && $input.prop("title", getMaskSet().mask)) : k == $.inputmask.keyCode.END || k == $.inputmask.keyCode.PAGE_DOWN ? setTimeout(function() {
  723. var caretPos = seekNext(getLastValidPosition());
  724. opts.insertMode || caretPos != getMaskLength() || e.shiftKey || caretPos--, caret(input, e.shiftKey ? pos.begin : caretPos, caretPos);
  725. }, 0) : k == $.inputmask.keyCode.HOME && !e.shiftKey || k == $.inputmask.keyCode.PAGE_UP ? caret(input, 0, e.shiftKey ? pos.begin : 0) : k == $.inputmask.keyCode.ESCAPE || 90 == k && e.ctrlKey ? (checkVal(input, !0, !1, valueOnFocus.split("")),
  726. $input.click()) : k != $.inputmask.keyCode.INSERT || e.shiftKey || e.ctrlKey ? 0 != opts.insertMode || e.shiftKey || (k == $.inputmask.keyCode.RIGHT ? setTimeout(function() {
  727. var caretPos = caret(input);
  728. caret(input, caretPos.begin);
  729. }, 0) : k == $.inputmask.keyCode.LEFT && setTimeout(function() {
  730. var caretPos = caret(input);
  731. caret(input, isRTL ? caretPos.begin + 1 : caretPos.begin - 1);
  732. }, 0)) : (opts.insertMode = !opts.insertMode, caret(input, opts.insertMode || pos.begin != getMaskLength() ? pos.begin : pos.begin - 1));
  733. var currentCaretPos = caret(input), keydownResult = opts.onKeyDown.call(this, e, getBuffer(), currentCaretPos.begin, opts);
  734. handleOnKeyResult(input, keydownResult, currentCaretPos), ignorable = -1 != $.inArray(k, opts.ignorables);
  735. }
  736. function keypressEvent(e, checkval, k, writeOut, strict, ndx) {
  737. if (void 0 == k && skipKeyPressEvent) return !1;
  738. skipKeyPressEvent = !0;
  739. var input = this, $input = $(input);
  740. e = e || window.event;
  741. var k = checkval ? k : e.which || e.charCode || e.keyCode;
  742. if (!(checkval === !0 || e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable)) return !0;
  743. if (k) {
  744. checkval !== !0 && 46 == k && 0 == e.shiftKey && "," == opts.radixPoint && (k = 44);
  745. var forwardPosition, pos = checkval ? {
  746. begin: ndx,
  747. end: ndx
  748. } : caret(input), c = String.fromCharCode(k), isSlctn = isSelection(pos.begin, pos.end);
  749. isSlctn && (getMaskSet().undoPositions = $.extend(!0, {}, getMaskSet().validPositions),
  750. handleRemove(input, $.inputmask.keyCode.DELETE, pos), opts.insertMode || (opts.insertMode = !opts.insertMode,
  751. setValidPosition(pos.begin, strict), opts.insertMode = !opts.insertMode), isSlctn = !opts.multi),
  752. getMaskSet().writeOutBuffer = !0;
  753. var p = isRTL && !isSlctn ? pos.end : pos.begin, valResult = isValid(p, c, strict);
  754. if (valResult !== !1) {
  755. if (valResult !== !0 && (p = void 0 != valResult.pos ? valResult.pos : p, c = void 0 != valResult.c ? valResult.c : c),
  756. resetMaskSet(!0), void 0 != valResult.caret) forwardPosition = valResult.caret; else {
  757. var vps = getMaskSet().validPositions;
  758. 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);
  759. }
  760. getMaskSet().p = forwardPosition;
  761. }
  762. if (writeOut !== !1) {
  763. var self = this;
  764. if (setTimeout(function() {
  765. opts.onKeyValidation.call(self, valResult, opts);
  766. }, 0), getMaskSet().writeOutBuffer && valResult !== !1) {
  767. var buffer = getBuffer();
  768. writeBuffer(input, buffer, checkval ? void 0 : opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition),
  769. checkval !== !0 && setTimeout(function() {
  770. isComplete(buffer) === !0 && $input.trigger("complete"), skipInputEvent = !0, $input.trigger("input");
  771. }, 0);
  772. } else isSlctn && (getMaskSet().buffer = void 0, getMaskSet().validPositions = getMaskSet().undoPositions);
  773. } else isSlctn && (getMaskSet().buffer = void 0, getMaskSet().validPositions = getMaskSet().undoPositions);
  774. if (opts.showTooltip && $input.prop("title", getMaskSet().mask), e && 1 != checkval) {
  775. e.preventDefault();
  776. var currentCaretPos = caret(input), keypressResult = opts.onKeyPress.call(this, e, getBuffer(), currentCaretPos.begin, opts);
  777. handleOnKeyResult(input, keypressResult, currentCaretPos);
  778. }
  779. }
  780. }
  781. function keyupEvent(e) {
  782. var $input = $(this), input = this, k = e.keyCode, buffer = getBuffer(), currentCaretPos = caret(input), keyupResult = opts.onKeyUp.call(this, e, buffer, currentCaretPos.begin, opts);
  783. handleOnKeyResult(input, keyupResult, currentCaretPos), k == $.inputmask.keyCode.TAB && opts.showMaskOnFocus && ($input.hasClass("focus-inputmask") && 0 == input._valueGet().length ? (resetMaskSet(),
  784. buffer = getBuffer(), writeBuffer(input, buffer), caret(input, 0), valueOnFocus = getBuffer().join("")) : (writeBuffer(input, buffer),
  785. caret(input, TranslatePosition(0), TranslatePosition(getMaskLength()))));
  786. }
  787. function pasteEvent(e) {
  788. if (skipInputEvent === !0 && "input" == e.type) return skipInputEvent = !1, !0;
  789. var input = this, $input = $(input), inputValue = input._valueGet(), caretPos = caret(input);
  790. if ("propertychange" == e.type && input._valueGet().length <= getMaskLength()) return !0;
  791. "paste" == e.type && (window.clipboardData && window.clipboardData.getData ? inputValue = inputValue.substr(0, caretPos.begin) + window.clipboardData.getData("Text") + inputValue.substr(caretPos.end, inputValue.length) : e.originalEvent && e.originalEvent.clipboardData && e.originalEvent.clipboardData.getData && (inputValue = inputValue.substr(0, caretPos.begin) + e.originalEvent.clipboardData.getData("text/plain") + inputValue.substr(caretPos.end, inputValue.length)));
  792. var pasteValue = $.isFunction(opts.onBeforePaste) ? opts.onBeforePaste.call(input, inputValue, opts) || inputValue : inputValue;
  793. return checkVal(input, !0, !1, isRTL ? pasteValue.split("").reverse() : pasteValue.split("")),
  794. $input.click(), isComplete(getBuffer()) === !0 && $input.trigger("complete"), !1;
  795. }
  796. function mobileInputEvent(e) {
  797. if (skipInputEvent === !0 && "input" == e.type) return skipInputEvent = !1, !0;
  798. var input = this, caretPos = caret(input), currentValue = input._valueGet();
  799. currentValue = currentValue.replace(new RegExp("(" + escapeRegex(getBufferTemplate().join("")) + ")*"), ""),
  800. caretPos.begin > currentValue.length && (caret(input, currentValue.length), caretPos = caret(input)),
  801. getBuffer().length - currentValue.length != 1 || currentValue.charAt(caretPos.begin) == getBuffer()[caretPos.begin] || currentValue.charAt(caretPos.begin + 1) == getBuffer()[caretPos.begin] || isMask(caretPos.begin) || (e.keyCode = $.inputmask.keyCode.BACKSPACE,
  802. keydownEvent.call(input, e)), e.preventDefault();
  803. }
  804. function inputFallBackEvent(e) {
  805. if (skipInputEvent === !0 && "input" == e.type) return skipInputEvent = !1, !0;
  806. var input = this;
  807. checkVal(input, !1, !1);
  808. var forwardPosition = getMaskSet().p;
  809. writeBuffer(input, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition),
  810. isComplete(getBuffer()) === !0 && $(input).trigger("complete"), e.preventDefault();
  811. }
  812. function compositionupdateEvent(e) {
  813. skipInputEvent = !0;
  814. var input = this;
  815. return setTimeout(function() {
  816. caret(input, caret(input).begin - 1);
  817. var keypress = $.Event("keypress");
  818. keypress.which = e.originalEvent.data.charCodeAt(0), skipKeyPressEvent = !1, ignorable = !1,
  819. keypressEvent.call(input, keypress, void 0, void 0, !1);
  820. var forwardPosition = getMaskSet().p;
  821. writeBuffer(input, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
  822. }, 0), !1;
  823. }
  824. function mask(el) {
  825. if ($el = $(el), $el.is(":input") && isInputTypeSupported($el.attr("type"))) {
  826. if ($el.data("_inputmask", {
  827. maskset: maskset,
  828. opts: opts,
  829. isRTL: !1
  830. }), opts.showTooltip && $el.prop("title", getMaskSet().mask), ("rtl" == el.dir || opts.rightAlign) && $el.css("text-align", "right"),
  831. "rtl" == el.dir || opts.numericInput) {
  832. el.dir = "ltr", $el.removeAttr("dir");
  833. var inputData = $el.data("_inputmask");
  834. inputData.isRTL = !0, $el.data("_inputmask", inputData), isRTL = !0;
  835. }
  836. $el.unbind(".inputmask"), $el.removeClass("focus-inputmask"), $el.closest("form").bind("submit", function() {
  837. valueOnFocus != getBuffer().join("") && $el.change(), $el[0]._valueGet && $el[0]._valueGet() == getBufferTemplate().join("") && $el[0]._valueSet(""),
  838. opts.autoUnmask && opts.removeMaskOnSubmit && $el.inputmask("remove");
  839. }).bind("reset", function() {
  840. setTimeout(function() {
  841. $el.trigger("setvalue");
  842. }, 0);
  843. }), $el.bind("mouseenter.inputmask", function() {
  844. var $input = $(this), input = this;
  845. !$input.hasClass("focus-inputmask") && opts.showMaskOnHover && input._valueGet() != getBuffer().join("") && writeBuffer(input, getBuffer());
  846. }).bind("blur.inputmask", function() {
  847. var $input = $(this), input = this;
  848. if ($input.data("_inputmask")) {
  849. var nptValue = input._valueGet(), buffer = getBuffer();
  850. $input.removeClass("focus-inputmask"), valueOnFocus != getBuffer().join("") && $input.change(),
  851. opts.clearMaskOnLostFocus && "" != nptValue && (nptValue == getBufferTemplate().join("") ? input._valueSet("") : clearOptionalTail(input)),
  852. isComplete(buffer) === !1 && ($input.trigger("incomplete"), opts.clearIncomplete && (resetMaskSet(),
  853. opts.clearMaskOnLostFocus ? input._valueSet("") : (buffer = getBufferTemplate().slice(),
  854. writeBuffer(input, buffer))));
  855. }
  856. }).bind("focus.inputmask", function() {
  857. var $input = $(this), input = this, nptValue = input._valueGet();
  858. opts.showMaskOnFocus && !$input.hasClass("focus-inputmask") && (!opts.showMaskOnHover || opts.showMaskOnHover && "" == nptValue) && input._valueGet() != getBuffer().join("") && writeBuffer(input, getBuffer(), seekNext(getLastValidPosition())),
  859. $input.addClass("focus-inputmask"), valueOnFocus = getBuffer().join("");
  860. }).bind("mouseleave.inputmask", function() {
  861. var $input = $(this), input = this;
  862. opts.clearMaskOnLostFocus && ($input.hasClass("focus-inputmask") || input._valueGet() == $input.attr("placeholder") || (input._valueGet() == getBufferTemplate().join("") || "" == input._valueGet() ? input._valueSet("") : clearOptionalTail(input)));
  863. }).bind("click.inputmask", function() {
  864. var input = this;
  865. $(input).is(":focus") && setTimeout(function() {
  866. var selectedCaret = caret(input);
  867. if (selectedCaret.begin == selectedCaret.end) if (opts.radixFocus && "" != opts.radixPoint && -1 != $.inArray(opts.radixPoint, getBuffer()) && getBuffer().join("") == getBufferTemplate().join("")) caret(input, $.inArray(opts.radixPoint, getBuffer())); else {
  868. var clickPosition = isRTL ? TranslatePosition(selectedCaret.begin) : selectedCaret.begin, lastPosition = seekNext(getLastValidPosition(clickPosition));
  869. lastPosition > clickPosition ? caret(input, isMask(clickPosition) ? clickPosition : seekNext(clickPosition)) : caret(input, lastPosition);
  870. }
  871. }, 0);
  872. }).bind("dblclick.inputmask", function() {
  873. var input = this;
  874. setTimeout(function() {
  875. caret(input, 0, seekNext(getLastValidPosition()));
  876. }, 0);
  877. }).bind(PasteEventType + ".inputmask dragdrop.inputmask drop.inputmask", pasteEvent).bind("setvalue.inputmask", function() {
  878. var input = this;
  879. checkVal(input, !0, !1), valueOnFocus = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input._valueGet() == getBufferTemplate().join("") && input._valueSet("");
  880. }).bind("cut.inputmask", function(e) {
  881. skipInputEvent = !0;
  882. var input = this, $input = $(input), pos = caret(input);
  883. handleRemove(input, $.inputmask.keyCode.DELETE, pos);
  884. var keypressResult = opts.onKeyPress.call(this, e, getBuffer(), getMaskSet().p, opts);
  885. handleOnKeyResult(input, keypressResult, {
  886. begin: getMaskSet().p,
  887. end: getMaskSet().p
  888. }), input._valueGet() == getBufferTemplate().join("") && $input.trigger("cleared"),
  889. opts.showTooltip && $input.prop("title", getMaskSet().mask);
  890. }).bind("complete.inputmask", opts.oncomplete).bind("incomplete.inputmask", opts.onincomplete).bind("cleared.inputmask", opts.oncleared),
  891. $el.bind("keydown.inputmask", keydownEvent).bind("keypress.inputmask", keypressEvent).bind("keyup.inputmask", keyupEvent).bind("compositionupdate.inputmask", compositionupdateEvent),
  892. "paste" === PasteEventType && $el.bind("input.inputmask", inputFallBackEvent), (android || androidfirefox || androidchrome || kindle) && ($el.unbind("input.inputmask"),
  893. $el.bind("input.inputmask", mobileInputEvent)), patchValueProperty(el);
  894. var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(el, el._valueGet(), opts) || el._valueGet() : el._valueGet();
  895. checkVal(el, !0, !1, initialValue.split("")), valueOnFocus = getBuffer().join("");
  896. var activeElement;
  897. try {
  898. activeElement = document.activeElement;
  899. } catch (e) {}
  900. isComplete(getBuffer()) === !1 && opts.clearIncomplete && resetMaskSet(), opts.clearMaskOnLostFocus ? getBuffer().join("") == getBufferTemplate().join("") ? el._valueSet("") : clearOptionalTail(el) : writeBuffer(el, getBuffer()),
  901. activeElement === el && ($el.addClass("focus-inputmask"), caret(el, seekNext(getLastValidPosition()))),
  902. installEventRuler(el);
  903. }
  904. }
  905. var valueOnFocus, $el, maxLength, isRTL = !1, skipKeyPressEvent = !1, skipInputEvent = !1, ignorable = !1;
  906. if (void 0 != actionObj) switch (actionObj.action) {
  907. case "isComplete":
  908. return $el = $(actionObj.el), maskset = $el.data("_inputmask").maskset, opts = $el.data("_inputmask").opts,
  909. isComplete(actionObj.buffer);
  910. case "unmaskedvalue":
  911. return $el = actionObj.$input, maskset = $el.data("_inputmask").maskset, opts = $el.data("_inputmask").opts,
  912. isRTL = actionObj.$input.data("_inputmask").isRTL, unmaskedvalue(actionObj.$input);
  913. case "mask":
  914. valueOnFocus = getBuffer().join(""), mask(actionObj.el);
  915. break;
  916. case "format":
  917. $el = $({}), $el.data("_inputmask", {
  918. maskset: maskset,
  919. opts: opts,
  920. isRTL: opts.numericInput
  921. }), opts.numericInput && (isRTL = !0);
  922. var valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call($el, actionObj.value, opts) || actionObj.value : actionObj.value).split("");
  923. return checkVal($el, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), opts.onKeyPress.call(this, void 0, getBuffer(), 0, opts),
  924. actionObj.metadata ? {
  925. value: isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join(""),
  926. metadata: $el.inputmask("getmetadata")
  927. } : isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join("");
  928. case "isValid":
  929. $el = $({}), $el.data("_inputmask", {
  930. maskset: maskset,
  931. opts: opts,
  932. isRTL: opts.numericInput
  933. }), opts.numericInput && (isRTL = !0);
  934. var valueBuffer = actionObj.value.split("");
  935. checkVal($el, !1, !0, isRTL ? valueBuffer.reverse() : valueBuffer);
  936. for (var buffer = getBuffer(), rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
  937. return buffer.splice(rl, lmib + 1 - rl), isComplete(buffer) && actionObj.value == buffer.join("");
  938. case "getemptymask":
  939. return $el = $(actionObj.el), maskset = $el.data("_inputmask").maskset, opts = $el.data("_inputmask").opts,
  940. getBufferTemplate();
  941. case "remove":
  942. var el = actionObj.el;
  943. $el = $(el), maskset = $el.data("_inputmask").maskset, opts = $el.data("_inputmask").opts,
  944. el._valueSet(unmaskedvalue($el)), $el.unbind(".inputmask"), $el.removeClass("focus-inputmask"),
  945. $el.removeData("_inputmask");
  946. var valueProperty;
  947. Object.getOwnPropertyDescriptor && (valueProperty = Object.getOwnPropertyDescriptor(el, "value")),
  948. valueProperty && valueProperty.get ? el._valueGet && Object.defineProperty(el, "value", {
  949. get: el._valueGet,
  950. set: el._valueSet
  951. }) : document.__lookupGetter__ && el.__lookupGetter__("value") && el._valueGet && (el.__defineGetter__("value", el._valueGet),
  952. el.__defineSetter__("value", el._valueSet));
  953. try {
  954. delete el._valueGet, delete el._valueSet;
  955. } catch (e) {
  956. el._valueGet = void 0, el._valueSet = void 0;
  957. }
  958. break;
  959. case "getmetadata":
  960. if ($el = $(actionObj.el), maskset = $el.data("_inputmask").maskset, opts = $el.data("_inputmask").opts,
  961. $.isArray(maskset.metadata)) {
  962. for (var alternation, lvp = getLastValidPosition(), firstAlt = lvp; firstAlt >= 0; firstAlt--) if (getMaskSet().validPositions[firstAlt] && void 0 != getMaskSet().validPositions[firstAlt].alternation) {
  963. alternation = getMaskSet().validPositions[firstAlt].alternation;
  964. break;
  965. }
  966. return void 0 != alternation ? maskset.metadata[getMaskSet().validPositions[lvp].locator[alternation]] : maskset.metadata[0];
  967. }
  968. return maskset.metadata;
  969. }
  970. }
  971. if (void 0 === $.fn.inputmask) {
  972. var ua = ("function" == typeof ScriptEngineMajorVersion ? ScriptEngineMajorVersion() : new Function("/*@cc_on return @_jscript_version; @*/")() >= 10,
  973. 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";
  974. $.inputmask = {
  975. defaults: {
  976. placeholder: "_",
  977. optionalmarker: {
  978. start: "[",
  979. end: "]"
  980. },
  981. quantifiermarker: {
  982. start: "{",
  983. end: "}"
  984. },
  985. groupmarker: {
  986. start: "(",
  987. end: ")"
  988. },
  989. alternatormarker: "|",
  990. escapeChar: "\\",
  991. mask: null,
  992. oncomplete: $.noop,
  993. onincomplete: $.noop,
  994. oncleared: $.noop,
  995. repeat: 0,
  996. greedy: !0,
  997. autoUnmask: !1,
  998. removeMaskOnSubmit: !0,
  999. clearMaskOnLostFocus: !0,
  1000. insertMode: !0,
  1001. clearIncomplete: !1,
  1002. aliases: {},
  1003. alias: null,
  1004. onKeyUp: $.noop,
  1005. onKeyPress: $.noop,
  1006. onKeyDown: $.noop,
  1007. onBeforeMask: void 0,
  1008. onBeforePaste: void 0,
  1009. onUnMask: void 0,
  1010. showMaskOnFocus: !0,
  1011. showMaskOnHover: !0,
  1012. onKeyValidation: $.noop,
  1013. skipOptionalPartCharacter: " ",
  1014. showTooltip: !1,
  1015. numericInput: !1,
  1016. rightAlign: !1,
  1017. radixPoint: "",
  1018. radixFocus: !1,
  1019. nojumps: !1,
  1020. nojumpsThreshold: 0,
  1021. keepStatic: void 0,
  1022. definitions: {
  1023. "9": {
  1024. validator: "[0-9]",
  1025. cardinality: 1,
  1026. definitionSymbol: "*"
  1027. },
  1028. a: {
  1029. validator: "[A-Za-zА-яЁёÀ-ÿµ]",
  1030. cardinality: 1,
  1031. definitionSymbol: "*"
  1032. },
  1033. "*": {
  1034. validator: "[0-9A-Za-zА-яЁёÀ-ÿµ]",
  1035. cardinality: 1
  1036. }
  1037. },
  1038. 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 ],
  1039. isComplete: void 0
  1040. },
  1041. keyCode: {
  1042. ALT: 18,
  1043. BACKSPACE: 8,
  1044. CAPS_LOCK: 20,
  1045. COMMA: 188,
  1046. COMMAND: 91,
  1047. COMMAND_LEFT: 91,
  1048. COMMAND_RIGHT: 93,
  1049. CONTROL: 17,
  1050. DELETE: 46,
  1051. DOWN: 40,
  1052. END: 35,
  1053. ENTER: 13,
  1054. ESCAPE: 27,
  1055. HOME: 36,
  1056. INSERT: 45,
  1057. LEFT: 37,
  1058. MENU: 93,
  1059. NUMPAD_ADD: 107,
  1060. NUMPAD_DECIMAL: 110,
  1061. NUMPAD_DIVIDE: 111,
  1062. NUMPAD_ENTER: 108,
  1063. NUMPAD_MULTIPLY: 106,
  1064. NUMPAD_SUBTRACT: 109,
  1065. PAGE_DOWN: 34,
  1066. PAGE_UP: 33,
  1067. PERIOD: 190,
  1068. RIGHT: 39,
  1069. SHIFT: 16,
  1070. SPACE: 32,
  1071. TAB: 9,
  1072. UP: 38,
  1073. WINDOWS: 91
  1074. },
  1075. masksCache: {},
  1076. escapeRegex: function(str) {
  1077. var specials = [ "/", ".", "*", "+", "?", "|", "(", ")", "[", "]", "{", "}", "\\" ];
  1078. return str.replace(new RegExp("(\\" + specials.join("|\\") + ")", "gim"), "\\$1");
  1079. },
  1080. format: function(value, options, metadata) {
  1081. var opts = $.extend(!0, {}, $.inputmask.defaults, options);
  1082. return resolveAlias(opts.alias, options, opts), maskScope({
  1083. action: "format",
  1084. value: value,
  1085. metadata: metadata
  1086. }, generateMaskSet(opts), opts);
  1087. },
  1088. isValid: function(value, options) {
  1089. var opts = $.extend(!0, {}, $.inputmask.defaults, options);
  1090. return resolveAlias(opts.alias, options, opts), maskScope({
  1091. action: "isValid",
  1092. value: value
  1093. }, generateMaskSet(opts), opts);
  1094. }
  1095. }, $.fn.inputmask = function(fn, options, targetScope, targetData, msk) {
  1096. function importAttributeOptions(npt, opts, importedOptionsContainer) {
  1097. var $npt = $(npt);
  1098. $npt.data("inputmask-alias") && resolveAlias($npt.data("inputmask-alias"), {}, opts);
  1099. for (var option in opts) {
  1100. var optionData = $npt.data("inputmask-" + option.toLowerCase());
  1101. void 0 != optionData && ("mask" == option && 0 == optionData.indexOf("[") ? (opts[option] = optionData.replace(/[\s[\]]/g, "").split("','"),
  1102. opts[option][0] = opts[option][0].replace("'", ""), opts[option][opts[option].length - 1] = opts[option][opts[option].length - 1].replace("'", "")) : opts[option] = "boolean" == typeof optionData ? optionData : optionData.toString(),
  1103. importedOptionsContainer && (importedOptionsContainer[option] = opts[option]));
  1104. }
  1105. return opts;
  1106. }
  1107. targetScope = targetScope || maskScope, targetData = targetData || "_inputmask";
  1108. var maskset, opts = $.extend(!0, {}, $.inputmask.defaults, options);
  1109. if ("string" == typeof fn) switch (fn) {
  1110. case "mask":
  1111. return resolveAlias(opts.alias, options, opts), maskset = generateMaskSet(opts, targetScope !== maskScope),
  1112. void 0 == maskset ? this : this.each(function() {
  1113. targetScope({
  1114. action: "mask",
  1115. el: this
  1116. }, $.extend(!0, {}, maskset), importAttributeOptions(this, opts));
  1117. });
  1118. case "unmaskedvalue":
  1119. var $input = $(this);
  1120. return $input.data(targetData) ? targetScope({
  1121. action: "unmaskedvalue",
  1122. $input: $input
  1123. }) : $input.val();
  1124. case "remove":
  1125. return this.each(function() {
  1126. var $input = $(this);
  1127. $input.data(targetData) && targetScope({
  1128. action: "remove",
  1129. el: this
  1130. });
  1131. });
  1132. case "getemptymask":
  1133. return this.data(targetData) ? targetScope({
  1134. action: "getemptymask",
  1135. el: this
  1136. }) : "";
  1137. case "hasMaskedValue":
  1138. return this.data(targetData) ? !this.data(targetData).opts.autoUnmask : !1;
  1139. case "isComplete":
  1140. return this.data(targetData) ? targetScope({
  1141. action: "isComplete",
  1142. buffer: this[0]._valueGet().split(""),
  1143. el: this
  1144. }) : !0;
  1145. case "getmetadata":
  1146. return this.data(targetData) ? targetScope({
  1147. action: "getmetadata",
  1148. el: this
  1149. }) : void 0;
  1150. case "_detectScope":
  1151. return resolveAlias(opts.alias, options, opts), void 0 == msk || resolveAlias(msk, options, opts) || -1 != $.inArray(msk, [ "mask", "unmaskedvalue", "remove", "getemptymask", "hasMaskedValue", "isComplete", "getmetadata", "_detectScope" ]) || (opts.mask = msk),
  1152. $.isFunction(opts.mask) && (opts.mask = opts.mask.call(this, opts)), $.isArray(opts.mask);
  1153. default:
  1154. return resolveAlias(opts.alias, options, opts), resolveAlias(fn, options, opts) || (opts.mask = fn),
  1155. maskset = generateMaskSet(opts, targetScope !== maskScope), void 0 == maskset ? this : this.each(function() {
  1156. targetScope({
  1157. action: "mask",
  1158. el: this
  1159. }, $.extend(!0, {}, maskset), importAttributeOptions(this, opts));
  1160. });
  1161. } else {
  1162. if ("object" == typeof fn) return opts = $.extend(!0, {}, $.inputmask.defaults, fn),
  1163. resolveAlias(opts.alias, fn, opts), maskset = generateMaskSet(opts, targetScope !== maskScope),
  1164. void 0 == maskset ? this : this.each(function() {
  1165. targetScope({
  1166. action: "mask",
  1167. el: this
  1168. }, $.extend(!0, {}, maskset), importAttributeOptions(this, opts));
  1169. });
  1170. if (void 0 == fn) return this.each(function() {
  1171. var attrOptions = $(this).attr("data-inputmask");
  1172. if (attrOptions && "" != attrOptions) try {
  1173. attrOptions = attrOptions.replace(new RegExp("'", "g"), '"');
  1174. var dataoptions = $.parseJSON("{" + attrOptions + "}");
  1175. $.extend(!0, dataoptions, options), opts = $.extend(!0, {}, $.inputmask.defaults, dataoptions),
  1176. opts = importAttributeOptions(this, opts), resolveAlias(opts.alias, dataoptions, opts),
  1177. opts.alias = void 0, $(this).inputmask("mask", opts, targetScope);
  1178. } catch (ex) {}
  1179. if ($(this).attr("data-inputmask-mask") || $(this).attr("data-inputmask-alias")) {
  1180. opts = $.extend(!0, {}, $.inputmask.defaults, {});
  1181. var dataOptions = {};
  1182. opts = importAttributeOptions(this, opts, dataOptions), resolveAlias(opts.alias, dataOptions, opts),
  1183. opts.alias = void 0, $(this).inputmask("mask", opts, targetScope);
  1184. }
  1185. });
  1186. }
  1187. };
  1188. }
  1189. return $.fn.inputmask;
  1190. }(jQuery), function($) {
  1191. return $.extend($.inputmask.defaults.definitions, {
  1192. h: {
  1193. validator: "[01][0-9]|2[0-3]",
  1194. cardinality: 2,
  1195. prevalidator: [ {
  1196. validator: "[0-2]",
  1197. cardinality: 1
  1198. } ]
  1199. },
  1200. s: {
  1201. validator: "[0-5][0-9]",
  1202. cardinality: 2,
  1203. prevalidator: [ {
  1204. validator: "[0-5]",
  1205. cardinality: 1
  1206. } ]
  1207. },
  1208. d: {
  1209. validator: "0[1-9]|[12][0-9]|3[01]",
  1210. cardinality: 2,
  1211. prevalidator: [ {
  1212. validator: "[0-3]",
  1213. cardinality: 1
  1214. } ]
  1215. },
  1216. m: {
  1217. validator: "0[1-9]|1[012]",
  1218. cardinality: 2,
  1219. prevalidator: [ {
  1220. validator: "[01]",
  1221. cardinality: 1
  1222. } ]
  1223. },
  1224. y: {
  1225. validator: "(19|20)\\d{2}",
  1226. cardinality: 4,
  1227. prevalidator: [ {
  1228. validator: "[12]",
  1229. cardinality: 1
  1230. }, {
  1231. validator: "(19|20)",
  1232. cardinality: 2
  1233. }, {
  1234. validator: "(19|20)\\d",
  1235. cardinality: 3
  1236. } ]
  1237. }
  1238. }), $.extend($.inputmask.defaults.aliases, {
  1239. "dd/mm/yyyy": {
  1240. mask: "1/2/y",
  1241. placeholder: "dd/mm/yyyy",
  1242. regex: {
  1243. val1pre: new RegExp("[0-3]"),
  1244. val1: new RegExp("0[1-9]|[12][0-9]|3[01]"),
  1245. val2pre: function(separator) {
  1246. var escapedSeparator = $.inputmask.escapeRegex.call(this, separator);
  1247. return new RegExp("((0[1-9]|[12][0-9]|3[01])" + escapedSeparator + "[01])");
  1248. },
  1249. val2: function(separator) {
  1250. var escapedSeparator = $.inputmask.escapeRegex.call(this, separator);
  1251. 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]))");
  1252. }
  1253. },
  1254. leapday: "29/02/",
  1255. separator: "/",
  1256. yearrange: {
  1257. minyear: 1900,
  1258. maxyear: 2099
  1259. },
  1260. isInYearRange: function(chrs, minyear, maxyear) {
  1261. if (isNaN(chrs)) return !1;
  1262. var enteredyear = parseInt(chrs.concat(minyear.toString().slice(chrs.length))), enteredyear2 = parseInt(chrs.concat(maxyear.toString().slice(chrs.length)));
  1263. return (isNaN(enteredyear) ? !1 : enteredyear >= minyear && maxyear >= enteredyear) || (isNaN(enteredyear2) ? !1 : enteredyear2 >= minyear && maxyear >= enteredyear2);
  1264. },
  1265. determinebaseyear: function(minyear, maxyear, hint) {
  1266. var currentyear = new Date().getFullYear();
  1267. if (minyear > currentyear) return minyear;
  1268. if (currentyear > maxyear) {
  1269. for (var maxYearPrefix = maxyear.toString().slice(0, 2), maxYearPostfix = maxyear.toString().slice(2, 4); maxYearPrefix + hint > maxyear; ) maxYearPrefix--;
  1270. var maxxYear = maxYearPrefix + maxYearPostfix;
  1271. return minyear > maxxYear ? minyear : maxxYear;
  1272. }
  1273. return currentyear;
  1274. },
  1275. onKeyUp: function(e) {
  1276. var $input = $(this);
  1277. if (e.ctrlKey && e.keyCode == $.inputmask.keyCode.RIGHT) {
  1278. var today = new Date();
  1279. $input.val(today.getDate().toString() + (today.getMonth() + 1).toString() + today.getFullYear().toString());
  1280. }
  1281. },
  1282. definitions: {
  1283. "1": {
  1284. validator: function(chrs, maskset, pos, strict, opts) {
  1285. var isValid = opts.regex.val1.test(chrs);
  1286. 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",
  1287. {
  1288. refreshFromBuffer: {
  1289. start: pos - 1,
  1290. end: pos
  1291. },
  1292. pos: pos,
  1293. c: chrs.charAt(0)
  1294. });
  1295. },
  1296. cardinality: 2,
  1297. prevalidator: [ {
  1298. validator: function(chrs, maskset, pos, strict, opts) {
  1299. isNaN(maskset.buffer[pos + 1]) || (chrs += maskset.buffer[pos + 1]);
  1300. var isValid = 1 == chrs.length ? opts.regex.val1pre.test(chrs) : opts.regex.val1.test(chrs);
  1301. return strict || isValid || !(isValid = opts.regex.val1.test("0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
  1302. pos++, {
  1303. pos: pos
  1304. });
  1305. },
  1306. cardinality: 1
  1307. } ]
  1308. },
  1309. "2": {
  1310. validator: function(chrs, maskset, pos, strict, opts) {
  1311. var frontValue = opts.mask.indexOf("2") == opts.mask.length - 1 ? maskset.buffer.join("").substr(5, 3) : maskset.buffer.join("").substr(0, 3);
  1312. -1 != frontValue.indexOf(opts.placeholder[0]) && (frontValue = "01" + opts.separator);
  1313. var isValid = opts.regex.val2(opts.separator).test(frontValue + chrs);
  1314. 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",
  1315. {
  1316. refreshFromBuffer: {
  1317. start: pos - 1,
  1318. end: pos
  1319. },
  1320. pos: pos,
  1321. c: chrs.charAt(0)
  1322. };
  1323. if (opts.mask.indexOf("2") == opts.mask.length - 1 && isValid) {
  1324. var dayMonthValue = maskset.buffer.join("").substr(4, 4) + chrs;
  1325. if (dayMonthValue != opts.leapday) return !0;
  1326. var year = parseInt(maskset.buffer.join("").substr(0, 4), 10);
  1327. return year % 4 === 0 ? year % 100 === 0 ? year % 400 === 0 ? !0 : !1 : !0 : !1;
  1328. }
  1329. return isValid;
  1330. },
  1331. cardinality: 2,
  1332. prevalidator: [ {
  1333. validator: function(chrs, maskset, pos, strict, opts) {
  1334. isNaN(maskset.buffer[pos + 1]) || (chrs += maskset.buffer[pos + 1]);
  1335. var frontValue = opts.mask.indexOf("2") == opts.mask.length - 1 ? maskset.buffer.join("").substr(5, 3) : maskset.buffer.join("").substr(0, 3);
  1336. -1 != frontValue.indexOf(opts.placeholder[0]) && (frontValue = "01" + opts.separator);
  1337. var isValid = 1 == chrs.length ? opts.regex.val2pre(opts.separator).test(frontValue + chrs) : opts.regex.val2(opts.separator).test(frontValue + chrs);
  1338. return strict || isValid || !(isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
  1339. pos++, {
  1340. pos: pos
  1341. });
  1342. },
  1343. cardinality: 1
  1344. } ]
  1345. },
  1346. y: {
  1347. validator: function(chrs, maskset, pos, strict, opts) {
  1348. if (opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) {
  1349. var dayMonthValue = maskset.buffer.join("").substr(0, 6);
  1350. if (dayMonthValue != opts.leapday) return !0;
  1351. var year = parseInt(chrs, 10);
  1352. return year % 4 === 0 ? year % 100 === 0 ? year % 400 === 0 ? !0 : !1 : !0 : !1;
  1353. }
  1354. return !1;
  1355. },
  1356. cardinality: 4,
  1357. prevalidator: [ {
  1358. validator: function(chrs, maskset, pos, strict, opts) {
  1359. var isValid = opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1360. if (!strict && !isValid) {
  1361. var yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs + "0").toString().slice(0, 1);
  1362. if (isValid = opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) return maskset.buffer[pos++] = yearPrefix.charAt(0),
  1363. {
  1364. pos: pos
  1365. };
  1366. if (yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs + "0").toString().slice(0, 2),
  1367. isValid = opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) return maskset.buffer[pos++] = yearPrefix.charAt(0),
  1368. maskset.buffer[pos++] = yearPrefix.charAt(1), {
  1369. pos: pos
  1370. };
  1371. }
  1372. return isValid;
  1373. },
  1374. cardinality: 1
  1375. }, {
  1376. validator: function(chrs, maskset, pos, strict, opts) {
  1377. var isValid = opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1378. if (!strict && !isValid) {
  1379. var yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs).toString().slice(0, 2);
  1380. if (isValid = opts.isInYearRange(chrs[0] + yearPrefix[1] + chrs[1], opts.yearrange.minyear, opts.yearrange.maxyear)) return maskset.buffer[pos++] = yearPrefix.charAt(1),
  1381. {
  1382. pos: pos
  1383. };
  1384. if (yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs).toString().slice(0, 2),
  1385. opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) {
  1386. var dayMonthValue = maskset.buffer.join("").substr(0, 6);
  1387. if (dayMonthValue != opts.leapday) isValid = !0; else {
  1388. var year = parseInt(chrs, 10);
  1389. isValid = year % 4 === 0 ? year % 100 === 0 ? year % 400 === 0 ? !0 : !1 : !0 : !1;
  1390. }
  1391. } else isValid = !1;
  1392. if (isValid) return maskset.buffer[pos - 1] = yearPrefix.charAt(0), maskset.buffer[pos++] = yearPrefix.charAt(1),
  1393. maskset.buffer[pos++] = chrs.charAt(0), {
  1394. refreshFromBuffer: {
  1395. start: pos - 3,
  1396. end: pos
  1397. },
  1398. pos: pos
  1399. };
  1400. }
  1401. return isValid;
  1402. },
  1403. cardinality: 2
  1404. }, {
  1405. validator: function(chrs, maskset, pos, strict, opts) {
  1406. return opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1407. },
  1408. cardinality: 3
  1409. } ]
  1410. }
  1411. },
  1412. insertMode: !1,
  1413. autoUnmask: !1
  1414. },
  1415. "mm/dd/yyyy": {
  1416. placeholder: "mm/dd/yyyy",
  1417. alias: "dd/mm/yyyy",
  1418. regex: {
  1419. val2pre: function(separator) {
  1420. var escapedSeparator = $.inputmask.escapeRegex.call(this, separator);
  1421. return new RegExp("((0[13-9]|1[012])" + escapedSeparator + "[0-3])|(02" + escapedSeparator + "[0-2])");
  1422. },
  1423. val2: function(separator) {
  1424. var escapedSeparator = $.inputmask.escapeRegex.call(this, separator);
  1425. 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)");
  1426. },
  1427. val1pre: new RegExp("[01]"),
  1428. val1: new RegExp("0[1-9]|1[012]")
  1429. },
  1430. leapday: "02/29/",
  1431. onKeyUp: function(e) {
  1432. var $input = $(this);
  1433. if (e.ctrlKey && e.keyCode == $.inputmask.keyCode.RIGHT) {
  1434. var today = new Date();
  1435. $input.val((today.getMonth() + 1).toString() + today.getDate().toString() + today.getFullYear().toString());
  1436. }
  1437. }
  1438. },
  1439. "yyyy/mm/dd": {
  1440. mask: "y/1/2",
  1441. placeholder: "yyyy/mm/dd",
  1442. alias: "mm/dd/yyyy",
  1443. leapday: "/02/29",
  1444. onKeyUp: function(e) {
  1445. var $input = $(this);
  1446. if (e.ctrlKey && e.keyCode == $.inputmask.keyCode.RIGHT) {
  1447. var today = new Date();
  1448. $input.val(today.getFullYear().toString() + (today.getMonth() + 1).toString() + today.getDate().toString());
  1449. }
  1450. }
  1451. },
  1452. "dd.mm.yyyy": {
  1453. mask: "1.2.y",
  1454. placeholder: "dd.mm.yyyy",
  1455. leapday: "29.02.",
  1456. separator: ".",
  1457. alias: "dd/mm/yyyy"
  1458. },
  1459. "dd-mm-yyyy": {
  1460. mask: "1-2-y",
  1461. placeholder: "dd-mm-yyyy",
  1462. leapday: "29-02-",
  1463. separator: "-",
  1464. alias: "dd/mm/yyyy"
  1465. },
  1466. "mm.dd.yyyy": {
  1467. mask: "1.2.y",
  1468. placeholder: "mm.dd.yyyy",
  1469. leapday: "02.29.",
  1470. separator: ".",
  1471. alias: "mm/dd/yyyy"
  1472. },
  1473. "mm-dd-yyyy": {
  1474. mask: "1-2-y",
  1475. placeholder: "mm-dd-yyyy",
  1476. leapday: "02-29-",
  1477. separator: "-",
  1478. alias: "mm/dd/yyyy"
  1479. },
  1480. "yyyy.mm.dd": {
  1481. mask: "y.1.2",
  1482. placeholder: "yyyy.mm.dd",
  1483. leapday: ".02.29",
  1484. separator: ".",
  1485. alias: "yyyy/mm/dd"
  1486. },
  1487. "yyyy-mm-dd": {
  1488. mask: "y-1-2",
  1489. placeholder: "yyyy-mm-dd",
  1490. leapday: "-02-29",
  1491. separator: "-",
  1492. alias: "yyyy/mm/dd"
  1493. },
  1494. datetime: {
  1495. mask: "1/2/y h:s",
  1496. placeholder: "dd/mm/yyyy hh:mm",
  1497. alias: "dd/mm/yyyy",
  1498. regex: {
  1499. hrspre: new RegExp("[012]"),
  1500. hrs24: new RegExp("2[0-4]|1[3-9]"),
  1501. hrs: new RegExp("[01][0-9]|2[0-4]"),
  1502. ampm: new RegExp("^[a|p|A|P][m|M]"),
  1503. mspre: new RegExp("[0-5]"),
  1504. ms: new RegExp("[0-5][0-9]")
  1505. },
  1506. timeseparator: ":",
  1507. hourFormat: "24",
  1508. definitions: {
  1509. h: {
  1510. validator: function(chrs, maskset, pos, strict, opts) {
  1511. if ("24" == opts.hourFormat && 24 == parseInt(chrs, 10)) return maskset.buffer[pos - 1] = "0",
  1512. maskset.buffer[pos] = "0", {
  1513. refreshFromBuffer: {
  1514. start: pos - 1,
  1515. end: pos
  1516. },
  1517. c: "0"
  1518. };
  1519. var isValid = opts.regex.hrs.test(chrs);
  1520. 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",
  1521. maskset.buffer[pos] = chrs.charAt(0), pos++, {
  1522. refreshFromBuffer: {
  1523. start: pos - 2,
  1524. end: pos
  1525. },
  1526. pos: pos,
  1527. c: opts.timeseparator
  1528. };
  1529. if (isValid && "24" !== opts.hourFormat && opts.regex.hrs24.test(chrs)) {
  1530. var tmp = parseInt(chrs, 10);
  1531. return 24 == tmp ? (maskset.buffer[pos + 5] = "a", maskset.buffer[pos + 6] = "m") : (maskset.buffer[pos + 5] = "p",
  1532. maskset.buffer[pos + 6] = "m"), tmp -= 12, 10 > tmp ? (maskset.buffer[pos] = tmp.toString(),
  1533. maskset.buffer[pos - 1] = "0") : (maskset.buffer[pos] = tmp.toString().charAt(1),
  1534. maskset.buffer[pos - 1] = tmp.toString().charAt(0)), {
  1535. refreshFromBuffer: {
  1536. start: pos - 1,
  1537. end: pos + 6
  1538. },
  1539. c: maskset.buffer[pos]
  1540. };
  1541. }
  1542. return isValid;
  1543. },
  1544. cardinality: 2,
  1545. prevalidator: [ {
  1546. validator: function(chrs, maskset, pos, strict, opts) {
  1547. var isValid = opts.regex.hrspre.test(chrs);
  1548. return strict || isValid || !(isValid = opts.regex.hrs.test("0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
  1549. pos++, {
  1550. pos: pos
  1551. });
  1552. },
  1553. cardinality: 1
  1554. } ]
  1555. },
  1556. s: {
  1557. validator: "[0-5][0-9]",
  1558. cardinality: 2,
  1559. prevalidator: [ {
  1560. validator: function(chrs, maskset, pos, strict, opts) {
  1561. var isValid = opts.regex.mspre.test(chrs);
  1562. return strict || isValid || !(isValid = opts.regex.ms.test("0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
  1563. pos++, {
  1564. pos: pos
  1565. });
  1566. },
  1567. cardinality: 1
  1568. } ]
  1569. },
  1570. t: {
  1571. validator: function(chrs, maskset, pos, strict, opts) {
  1572. return opts.regex.ampm.test(chrs + "m");
  1573. },
  1574. casing: "lower",
  1575. cardinality: 1
  1576. }
  1577. },
  1578. insertMode: !1,
  1579. autoUnmask: !1
  1580. },
  1581. datetime12: {
  1582. mask: "1/2/y h:s t\\m",
  1583. placeholder: "dd/mm/yyyy hh:mm xm",
  1584. alias: "datetime",
  1585. hourFormat: "12"
  1586. },
  1587. "hh:mm t": {
  1588. mask: "h:s t\\m",
  1589. placeholder: "hh:mm xm",
  1590. alias: "datetime",
  1591. hourFormat: "12"
  1592. },
  1593. "h:s t": {
  1594. mask: "h:s t\\m",
  1595. placeholder: "hh:mm xm",
  1596. alias: "datetime",
  1597. hourFormat: "12"
  1598. },
  1599. "hh:mm:ss": {
  1600. mask: "h:s:s",
  1601. placeholder: "hh:mm:ss",
  1602. alias: "datetime",
  1603. autoUnmask: !1
  1604. },
  1605. "hh:mm": {
  1606. mask: "h:s",
  1607. placeholder: "hh:mm",
  1608. alias: "datetime",
  1609. autoUnmask: !1
  1610. },
  1611. date: {
  1612. alias: "dd/mm/yyyy"
  1613. },
  1614. "mm/yyyy": {
  1615. mask: "1/y",
  1616. placeholder: "mm/yyyy",
  1617. leapday: "donotuse",
  1618. separator: "/",
  1619. alias: "mm/dd/yyyy"
  1620. }
  1621. }), $.fn.inputmask;
  1622. }(jQuery), function($) {
  1623. return $.extend($.inputmask.defaults.definitions, {
  1624. A: {
  1625. validator: "[A-Za-zА-яЁёÀ-ÿµ]",
  1626. cardinality: 1,
  1627. casing: "upper"
  1628. },
  1629. "#": {
  1630. validator: "[0-9A-Za-zА-яЁёÀ-ÿµ]",
  1631. cardinality: 1,
  1632. casing: "upper"
  1633. }
  1634. }), $.extend($.inputmask.defaults.aliases, {
  1635. url: {
  1636. mask: "ir",
  1637. placeholder: "",
  1638. separator: "",
  1639. defaultPrefix: "http://",
  1640. regex: {
  1641. urlpre1: new RegExp("[fh]"),
  1642. urlpre2: new RegExp("(ft|ht)"),
  1643. urlpre3: new RegExp("(ftp|htt)"),
  1644. urlpre4: new RegExp("(ftp:|http|ftps)"),
  1645. urlpre5: new RegExp("(ftp:/|ftps:|http:|https)"),
  1646. urlpre6: new RegExp("(ftp://|ftps:/|http:/|https:)"),
  1647. urlpre7: new RegExp("(ftp://|ftps://|http://|https:/)"),
  1648. urlpre8: new RegExp("(ftp://|ftps://|http://|https://)")
  1649. },
  1650. definitions: {
  1651. i: {
  1652. validator: function() {
  1653. return !0;
  1654. },
  1655. cardinality: 8,
  1656. prevalidator: function() {
  1657. for (var result = [], prefixLimit = 8, i = 0; prefixLimit > i; i++) result[i] = function() {
  1658. var j = i;
  1659. return {
  1660. validator: function(chrs, maskset, pos, strict, opts) {
  1661. if (opts.regex["urlpre" + (j + 1)]) {
  1662. var k, tmp = chrs;
  1663. j + 1 - chrs.length > 0 && (tmp = maskset.buffer.join("").substring(0, j + 1 - chrs.length) + "" + tmp);
  1664. var isValid = opts.regex["urlpre" + (j + 1)].test(tmp);
  1665. if (!strict && !isValid) {
  1666. for (pos -= j, k = 0; k < opts.defaultPrefix.length; k++) maskset.buffer[pos] = opts.defaultPrefix[k],
  1667. pos++;
  1668. for (k = 0; k < tmp.length - 1; k++) maskset.buffer[pos] = tmp[k], pos++;
  1669. return {
  1670. pos: pos
  1671. };
  1672. }
  1673. return isValid;
  1674. }
  1675. return !1;
  1676. },
  1677. cardinality: j
  1678. };
  1679. }();
  1680. return result;
  1681. }()
  1682. },
  1683. r: {
  1684. validator: ".",
  1685. cardinality: 50
  1686. }
  1687. },
  1688. insertMode: !1,
  1689. autoUnmask: !1
  1690. },
  1691. ip: {
  1692. mask: "i[i[i]].i[i[i]].i[i[i]].i[i[i]]",
  1693. definitions: {
  1694. i: {
  1695. validator: function(chrs, maskset, pos) {
  1696. return pos - 1 > -1 && "." != maskset.buffer[pos - 1] ? (chrs = maskset.buffer[pos - 1] + chrs,
  1697. chrs = pos - 2 > -1 && "." != maskset.buffer[pos - 2] ? maskset.buffer[pos - 2] + chrs : "0" + chrs) : chrs = "00" + chrs,
  1698. new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]").test(chrs);
  1699. },
  1700. cardinality: 1
  1701. }
  1702. }
  1703. },
  1704. email: {
  1705. mask: "*{1,64}[.*{1,64}][.*{1,64}][.*{1,64}]@*{1,64}[.*{2,64}][.*{2,6}][.*{1,2}]",
  1706. greedy: !1,
  1707. onBeforePaste: function(pastedValue) {
  1708. return pastedValue = pastedValue.toLowerCase(), pastedValue.replace("mailto:", "");
  1709. },
  1710. definitions: {
  1711. "*": {
  1712. validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~-]",
  1713. cardinality: 1,
  1714. casing: "lower"
  1715. }
  1716. }
  1717. }
  1718. }), $.fn.inputmask;
  1719. }(jQuery), function($) {
  1720. return $.extend($.inputmask.defaults.aliases, {
  1721. numeric: {
  1722. mask: function(opts) {
  1723. if (0 !== opts.repeat && isNaN(opts.integerDigits) && (opts.integerDigits = opts.repeat),
  1724. opts.repeat = 0, opts.groupSeparator == opts.radixPoint && (opts.groupSeparator = "." == opts.radixPoint ? "," : "," == opts.radixPoint ? "." : ""),
  1725. " " === opts.groupSeparator && (opts.skipOptionalPartCharacter = void 0), opts.autoGroup = opts.autoGroup && "" != opts.groupSeparator,
  1726. opts.autoGroup && isFinite(opts.integerDigits)) {
  1727. var seps = Math.floor(opts.integerDigits / opts.groupSize), mod = opts.integerDigits % opts.groupSize;
  1728. opts.integerDigits += 0 == mod ? seps - 1 : seps;
  1729. }
  1730. opts.definitions[";"] = opts.definitions["~"];
  1731. var mask = opts.prefix;
  1732. return mask += "[+]", mask += "~{1," + opts.integerDigits + "}", void 0 != opts.digits && (isNaN(opts.digits) || parseInt(opts.digits) > 0) && (mask += opts.digitsOptional ? "[" + (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}]" : (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}"),
  1733. mask += opts.suffix;
  1734. },
  1735. placeholder: "",
  1736. greedy: !1,
  1737. digits: "*",
  1738. digitsOptional: !0,
  1739. groupSeparator: "",
  1740. radixPoint: ".",
  1741. radixFocus: !0,
  1742. groupSize: 3,
  1743. autoGroup: !1,
  1744. allowPlus: !0,
  1745. allowMinus: !0,
  1746. integerDigits: "+",
  1747. prefix: "",
  1748. suffix: "",
  1749. rightAlign: !0,
  1750. decimalProtect: !0,
  1751. postFormat: function(buffer, pos, reformatOnly, opts) {
  1752. var needsRefresh = !1, charAtPos = buffer[pos];
  1753. if ("" == opts.groupSeparator || -1 != $.inArray(opts.radixPoint, buffer) && pos >= $.inArray(opts.radixPoint, buffer) || new RegExp("[-+]").test(charAtPos)) return {
  1754. pos: pos
  1755. };
  1756. var cbuf = buffer.slice();
  1757. charAtPos == opts.groupSeparator && (cbuf.splice(pos--, 1), charAtPos = cbuf[pos]),
  1758. reformatOnly ? cbuf[pos] = "?" : cbuf.splice(pos, 0, "?");
  1759. var bufVal = cbuf.join("");
  1760. if (bufVal.length > 0 && opts.autoGroup || reformatOnly && -1 != bufVal.indexOf(opts.groupSeparator)) {
  1761. var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
  1762. needsRefresh = 0 == bufVal.indexOf(opts.groupSeparator), bufVal = bufVal.replace(new RegExp(escapedGroupSeparator, "g"), "");
  1763. var radixSplit = bufVal.split(opts.radixPoint);
  1764. if (bufVal = "" == opts.radixPoint ? bufVal : radixSplit[0], bufVal != opts.prefix + "?0" && bufVal.length >= opts.groupSize + opts.prefix.length) {
  1765. needsRefresh = !0;
  1766. for (var reg = new RegExp("([-+]?[\\d?]+)([\\d?]{" + opts.groupSize + "})"); reg.test(bufVal); ) bufVal = bufVal.replace(reg, "$1" + opts.groupSeparator + "$2"),
  1767. bufVal = bufVal.replace(opts.groupSeparator + opts.groupSeparator, opts.groupSeparator);
  1768. }
  1769. "" != opts.radixPoint && radixSplit.length > 1 && (bufVal += opts.radixPoint + radixSplit[1]);
  1770. }
  1771. buffer.length = bufVal.length;
  1772. for (var i = 0, l = bufVal.length; l > i; i++) buffer[i] = bufVal.charAt(i);
  1773. var newPos = $.inArray("?", buffer);
  1774. return reformatOnly ? buffer[newPos] = charAtPos : buffer.splice(newPos, 1), {
  1775. pos: newPos,
  1776. refreshFromBuffer: needsRefresh
  1777. };
  1778. },
  1779. onKeyDown: function(e, buffer, caretPos, opts) {
  1780. if (e.keyCode == $.inputmask.keyCode.TAB && "0" != opts.placeholder.charAt(0)) {
  1781. var radixPosition = $.inArray(opts.radixPoint, buffer);
  1782. if (-1 != radixPosition && isFinite(opts.digits)) {
  1783. for (var i = 1; i <= opts.digits; i++) (void 0 == buffer[radixPosition + i] || buffer[radixPosition + i] == opts.placeholder.charAt(0)) && (buffer[radixPosition + i] = "0");
  1784. return {
  1785. refreshFromBuffer: {
  1786. start: ++radixPosition,
  1787. end: radixPosition + opts.digits
  1788. }
  1789. };
  1790. }
  1791. } else if (opts.autoGroup && (e.keyCode == $.inputmask.keyCode.DELETE || e.keyCode == $.inputmask.keyCode.BACKSPACE)) {
  1792. var rslt = opts.postFormat(buffer, caretPos - 1, !0, opts);
  1793. return rslt.caret = rslt.pos + 1, rslt;
  1794. }
  1795. },
  1796. onKeyPress: function(e, buffer, caretPos, opts) {
  1797. if (opts.autoGroup) {
  1798. var rslt = opts.postFormat(buffer, caretPos - 1, !0, opts);
  1799. return rslt.caret = rslt.pos + 1, rslt;
  1800. }
  1801. },
  1802. regex: {
  1803. integerPart: function() {
  1804. return new RegExp("[-+]?\\d+");
  1805. },
  1806. integerNPart: function() {
  1807. return new RegExp("\\d+");
  1808. }
  1809. },
  1810. signHandler: function(chrs, buffer, pos, strict, opts) {
  1811. if (!strict && (opts.allowMinus && "-" === chrs || opts.allowPlus && "+" === chrs)) {
  1812. var matchRslt = buffer.join("").match(opts.regex.integerPart(opts));
  1813. if (matchRslt && matchRslt.length > 0 && "0" !== matchRslt[matchRslt.index]) return buffer[matchRslt.index] == ("-" === chrs ? "+" : "-") ? {
  1814. pos: matchRslt.index,
  1815. c: chrs,
  1816. remove: matchRslt.index,
  1817. caret: pos
  1818. } : buffer[matchRslt.index] == ("-" === chrs ? "-" : "+") ? {
  1819. remove: matchRslt.index,
  1820. caret: pos - 1
  1821. } : {
  1822. pos: matchRslt.index,
  1823. c: chrs,
  1824. caret: pos + 1
  1825. };
  1826. }
  1827. return !1;
  1828. },
  1829. radixHandler: function(chrs, maskset, pos, strict, opts) {
  1830. if (!strict && chrs === opts.radixPoint) {
  1831. var radixPos = $.inArray(opts.radixPoint, maskset.buffer), integerValue = maskset.buffer.join("").match(opts.regex.integerPart(opts));
  1832. if (-1 != radixPos && maskset.validPositions[radixPos]) return maskset.validPositions[radixPos - 1] ? {
  1833. caret: radixPos + 1
  1834. } : {
  1835. pos: integerValue.index,
  1836. c: integerValue[0],
  1837. caret: radixPos + 1
  1838. };
  1839. }
  1840. return !1;
  1841. },
  1842. leadingZeroHandler: function(chrs, maskset, pos, strict, opts) {
  1843. var matchRslt = maskset.buffer.join("").match(opts.regex.integerNPart(opts)), radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
  1844. if (matchRslt && !strict && (-1 == radixPosition || matchRslt.index < radixPosition)) if ("0" == matchRslt[0] && pos >= opts.prefix.length) {
  1845. if (-1 == radixPosition || radixPosition >= pos && void 0 == maskset.validPositions[radixPosition]) return maskset.buffer.splice(matchRslt.index, 1),
  1846. pos = pos > matchRslt.index ? pos - 1 : matchRslt.index, {
  1847. pos: pos,
  1848. remove: matchRslt.index
  1849. };
  1850. if (pos > matchRslt.index && radixPosition >= pos) return maskset.buffer.splice(matchRslt.index, 1),
  1851. pos = pos > matchRslt.index ? pos - 1 : matchRslt.index, {
  1852. pos: pos,
  1853. remove: matchRslt.index
  1854. };
  1855. if (void 0 == maskset.validPositions[radixPosition]) return maskset.buffer[pos] = chrs,
  1856. {
  1857. refreshFromBuffer: !0
  1858. };
  1859. } else if ("0" == chrs && pos <= matchRslt.index) return !1;
  1860. return !0;
  1861. },
  1862. definitions: {
  1863. "~": {
  1864. validator: function(chrs, maskset, pos, strict, opts) {
  1865. var isValid = opts.signHandler(chrs, maskset.buffer, pos, strict, opts);
  1866. if (!isValid && (isValid = opts.radixHandler(chrs, maskset, pos, strict, opts),
  1867. !isValid && (isValid = strict ? new RegExp("[0-9" + $.inputmask.escapeRegex.call(this, opts.groupSeparator) + "]").test(chrs) : new RegExp("[0-9]").test(chrs),
  1868. isValid === !0 && (isValid = opts.leadingZeroHandler(chrs, maskset, pos, strict, opts),
  1869. isValid === !0)))) {
  1870. var radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
  1871. isValid = opts.digitsOptional === !1 && pos > radixPosition && !strict ? {
  1872. pos: pos,
  1873. remove: pos
  1874. } : {
  1875. pos: pos
  1876. };
  1877. }
  1878. return isValid;
  1879. },
  1880. cardinality: 1,
  1881. prevalidator: null
  1882. },
  1883. "+": {
  1884. validator: function(chrs, maskset, pos, strict, opts) {
  1885. var isValid = opts.signHandler(chrs, maskset.buffer, pos, strict, opts);
  1886. return isValid || (isValid = opts.allowMinus && "-" == chrs || opts.allowPlus && "+" == chrs),
  1887. isValid;
  1888. },
  1889. cardinality: 1,
  1890. prevalidator: null,
  1891. placeholder: ""
  1892. },
  1893. ":": {
  1894. validator: function(chrs, maskset, pos, strict, opts) {
  1895. var isValid = opts.signHandler(chrs, maskset.buffer, pos, strict, opts);
  1896. if (!isValid) {
  1897. var radix = "[" + $.inputmask.escapeRegex.call(this, opts.radixPoint) + "]";
  1898. isValid = new RegExp(radix).test(chrs), isValid && maskset.validPositions[pos] && maskset.validPositions[pos].match.placeholder == opts.radixPoint && (isValid = {
  1899. pos: pos,
  1900. remove: pos
  1901. });
  1902. }
  1903. return isValid;
  1904. },
  1905. cardinality: 1,
  1906. prevalidator: null,
  1907. placeholder: function(opts) {
  1908. return opts.radixPoint;
  1909. }
  1910. }
  1911. },
  1912. insertMode: !0,
  1913. autoUnmask: !1,
  1914. onUnMask: function(maskedValue, unmaskedValue, opts) {
  1915. var processValue = maskedValue.replace(opts.prefix, "");
  1916. return processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp($.inputmask.escapeRegex.call(this, opts.groupSeparator), "g"), "");
  1917. },
  1918. isComplete: function(buffer, opts) {
  1919. var maskedValue = buffer.join(""), bufClone = buffer.slice();
  1920. if (opts.postFormat(bufClone, 0, !0, opts), bufClone.join("") != maskedValue) return !1;
  1921. var processValue = maskedValue.replace(opts.prefix, "");
  1922. return processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp($.inputmask.escapeRegex.call(this, opts.groupSeparator), "g"), ""),
  1923. processValue = processValue.replace($.inputmask.escapeRegex.call(this, opts.radixPoint), "."),
  1924. isFinite(processValue);
  1925. },
  1926. onBeforeMask: function(initialValue, opts) {
  1927. if (isFinite(initialValue)) return initialValue.toString().replace(".", opts.radixPoint);
  1928. var kommaMatches = initialValue.match(/,/g), dotMatches = initialValue.match(/\./g);
  1929. return dotMatches && kommaMatches ? dotMatches.length > kommaMatches.length ? (initialValue = initialValue.replace(/\./g, ""),
  1930. initialValue = initialValue.replace(",", opts.radixPoint)) : kommaMatches.length > dotMatches.length && (initialValue = initialValue.replace(/,/g, ""),
  1931. initialValue = initialValue.replace(".", opts.radixPoint)) : initialValue = initialValue.replace(new RegExp($.inputmask.escapeRegex.call(this, opts.groupSeparator), "g"), ""),
  1932. initialValue;
  1933. }
  1934. },
  1935. currency: {
  1936. prefix: "$ ",
  1937. groupSeparator: ",",
  1938. alias: "numeric",
  1939. placeholder: "0",
  1940. autoGroup: !0,
  1941. digits: 2,
  1942. digitsOptional: !1,
  1943. clearMaskOnLostFocus: !1
  1944. },
  1945. decimal: {
  1946. alias: "numeric"
  1947. },
  1948. integer: {
  1949. alias: "numeric",
  1950. digits: "0",
  1951. radixPoint: ""
  1952. }
  1953. }), $.fn.inputmask;
  1954. }(jQuery), function($) {
  1955. return $.extend($.inputmask.defaults.aliases, {
  1956. phone: {
  1957. url: "phone-codes/phone-codes.js",
  1958. maskInit: "+pp(pp)pppppppp",
  1959. mask: function(opts) {
  1960. opts.definitions = {
  1961. p: {
  1962. validator: function() {
  1963. return !1;
  1964. },
  1965. cardinality: 1
  1966. },
  1967. "#": {
  1968. validator: "[0-9]",
  1969. cardinality: 1
  1970. }
  1971. };
  1972. var maskList = [];
  1973. return $.ajax({
  1974. url: opts.url,
  1975. async: !1,
  1976. dataType: "json",
  1977. success: function(response) {
  1978. maskList = response;
  1979. }
  1980. }), maskList = maskList.sort(function(a, b) {
  1981. return (a.mask || a) < (b.mask || b) ? -1 : 1;
  1982. }), maskList.splice(0, 0, opts.maskInit), maskList;
  1983. },
  1984. nojumps: !0,
  1985. nojumpsThreshold: 1
  1986. },
  1987. phonebe: {
  1988. alias: "phone",
  1989. url: "phone-codes/phone-be.js",
  1990. maskInit: "+32(pp)pppppppp",
  1991. nojumpsThreshold: 4,
  1992. onBeforeMask: function(value) {
  1993. var processedValue = value.replace(/^0/g, "");
  1994. return (processedValue.indexOf("32") > 1 || -1 == processedValue.indexOf("32")) && (processedValue = "32" + processedValue),
  1995. processedValue;
  1996. }
  1997. }
  1998. }), $.fn.inputmask;
  1999. }(jQuery), function($) {
  2000. return $.extend($.inputmask.defaults.aliases, {
  2001. Regex: {
  2002. mask: "r",
  2003. greedy: !1,
  2004. repeat: "*",
  2005. regex: null,
  2006. regexTokens: null,
  2007. 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,
  2008. quantifierFilter: /[0-9]+[^,]/,
  2009. isComplete: function(buffer, opts) {
  2010. return new RegExp(opts.regex).test(buffer.join(""));
  2011. },
  2012. definitions: {
  2013. r: {
  2014. validator: function(chrs, maskset, pos, strict, opts) {
  2015. function regexToken(isGroup, isQuantifier) {
  2016. this.matches = [], this.isGroup = isGroup || !1, this.isQuantifier = isQuantifier || !1,
  2017. this.quantifier = {
  2018. min: 1,
  2019. max: 1
  2020. }, this.repeaterPart = void 0;
  2021. }
  2022. function analyseRegex() {
  2023. var match, m, currentToken = new regexToken(), opengroups = [];
  2024. for (opts.regexTokens = []; match = opts.tokenizer.exec(opts.regex); ) switch (m = match[0],
  2025. m.charAt(0)) {
  2026. case "(":
  2027. opengroups.push(new regexToken(!0));
  2028. break;
  2029. case ")":
  2030. var groupToken = opengroups.pop();
  2031. opengroups.length > 0 ? opengroups[opengroups.length - 1].matches.push(groupToken) : currentToken.matches.push(groupToken);
  2032. break;
  2033. case "{":
  2034. case "+":
  2035. case "*":
  2036. var quantifierToken = new regexToken(!1, !0);
  2037. m = m.replace(/[{}]/g, "");
  2038. 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]);
  2039. if (quantifierToken.quantifier = {
  2040. min: mq0,
  2041. max: mq1
  2042. }, opengroups.length > 0) {
  2043. var matches = opengroups[opengroups.length - 1].matches;
  2044. if (match = matches.pop(), !match.isGroup) {
  2045. var groupToken = new regexToken(!0);
  2046. groupToken.matches.push(match), match = groupToken;
  2047. }
  2048. matches.push(match), matches.push(quantifierToken);
  2049. } else {
  2050. if (match = currentToken.matches.pop(), !match.isGroup) {
  2051. var groupToken = new regexToken(!0);
  2052. groupToken.matches.push(match), match = groupToken;
  2053. }
  2054. currentToken.matches.push(match), currentToken.matches.push(quantifierToken);
  2055. }
  2056. break;
  2057. default:
  2058. opengroups.length > 0 ? opengroups[opengroups.length - 1].matches.push(m) : currentToken.matches.push(m);
  2059. }
  2060. currentToken.matches.length > 0 && opts.regexTokens.push(currentToken);
  2061. }
  2062. function validateRegexToken(token, fromGroup) {
  2063. var isvalid = !1;
  2064. fromGroup && (regexPart += "(", openGroupCount++);
  2065. for (var mndx = 0; mndx < token.matches.length; mndx++) {
  2066. var matchToken = token.matches[mndx];
  2067. if (1 == matchToken.isGroup) isvalid = validateRegexToken(matchToken, !0); else if (1 == matchToken.isQuantifier) {
  2068. var crrntndx = $.inArray(matchToken, token.matches), matchGroup = token.matches[crrntndx - 1], regexPartBak = regexPart;
  2069. if (isNaN(matchToken.quantifier.max)) {
  2070. for (;matchToken.repeaterPart && matchToken.repeaterPart != regexPart && matchToken.repeaterPart.length > regexPart.length && !(isvalid = validateRegexToken(matchGroup, !0)); ) ;
  2071. isvalid = isvalid || validateRegexToken(matchGroup, !0), isvalid && (matchToken.repeaterPart = regexPart),
  2072. regexPart = regexPartBak + matchToken.quantifier.max;
  2073. } else {
  2074. for (var i = 0, qm = matchToken.quantifier.max - 1; qm > i && !(isvalid = validateRegexToken(matchGroup, !0)); i++) ;
  2075. regexPart = regexPartBak + "{" + matchToken.quantifier.min + "," + matchToken.quantifier.max + "}";
  2076. }
  2077. } else if (void 0 != matchToken.matches) for (var k = 0; k < matchToken.length && !(isvalid = validateRegexToken(matchToken[k], fromGroup)); k++) ; else {
  2078. var testExp;
  2079. if ("[" == matchToken.charAt(0)) {
  2080. testExp = regexPart, testExp += matchToken;
  2081. for (var j = 0; openGroupCount > j; j++) testExp += ")";
  2082. var exp = new RegExp("^(" + testExp + ")$");
  2083. isvalid = exp.test(bufferStr);
  2084. } else for (var l = 0, tl = matchToken.length; tl > l; l++) if ("\\" != matchToken.charAt(l)) {
  2085. testExp = regexPart, testExp += matchToken.substr(0, l + 1), testExp = testExp.replace(/\|$/, "");
  2086. for (var j = 0; openGroupCount > j; j++) testExp += ")";
  2087. var exp = new RegExp("^(" + testExp + ")$");
  2088. if (isvalid = exp.test(bufferStr)) break;
  2089. }
  2090. regexPart += matchToken;
  2091. }
  2092. if (isvalid) break;
  2093. }
  2094. return fromGroup && (regexPart += ")", openGroupCount--), isvalid;
  2095. }
  2096. null == opts.regexTokens && analyseRegex();
  2097. var cbuffer = maskset.buffer.slice(), regexPart = "", isValid = !1, openGroupCount = 0;
  2098. cbuffer.splice(pos, 0, chrs);
  2099. for (var bufferStr = cbuffer.join(""), i = 0; i < opts.regexTokens.length; i++) {
  2100. var regexToken = opts.regexTokens[i];
  2101. if (isValid = validateRegexToken(regexToken, regexToken.isGroup)) break;
  2102. }
  2103. return isValid;
  2104. },
  2105. cardinality: 1
  2106. }
  2107. }
  2108. }
  2109. }), $.fn.inputmask;
  2110. }(jQuery);