Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

2653 lines
163KB

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