您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

2278 行
135KB

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