Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

1471 lines
99KB

  1. /*!
  2. * inputmask.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(factory) {
  9. "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery")) : factory(window.dependencyLib || jQuery);
  10. }(function($) {
  11. function Inputmask(alias, options) {
  12. return this instanceof Inputmask ? ($.isPlainObject(alias) ? options = alias : (options = options || {},
  13. options.alias = alias), this.el = void 0, this.opts = $.extend(!0, {}, this.defaults, options),
  14. this.noMasksCache = options && void 0 !== options.definitions, this.userOptions = options || {},
  15. this.events = {}, void resolveAlias(this.opts.alias, options, this.opts)) : new Inputmask(alias, options);
  16. }
  17. function isInputEventSupported(eventName) {
  18. var el = document.createElement("input"), evName = "on" + eventName, isSupported = evName in el;
  19. return isSupported || (el.setAttribute(evName, "return;"), isSupported = "function" == typeof el[evName]),
  20. el = null, isSupported;
  21. }
  22. function isElementTypeSupported(input, opts) {
  23. var elementType = input.getAttribute("type"), isSupported = "INPUT" === input.tagName && -1 !== $.inArray(elementType, opts.supportsInputType) || input.isContentEditable || "TEXTAREA" === input.tagName;
  24. if (!isSupported) {
  25. var el = document.createElement("input");
  26. el.setAttribute("type", elementType), isSupported = "text" === el.type, el = null;
  27. }
  28. return isSupported;
  29. }
  30. function resolveAlias(aliasStr, options, opts) {
  31. var aliasDefinition = opts.aliases[aliasStr];
  32. return aliasDefinition ? (aliasDefinition.alias && resolveAlias(aliasDefinition.alias, void 0, opts),
  33. $.extend(!0, opts, aliasDefinition), $.extend(!0, opts, options), !0) : (null === opts.mask && (opts.mask = aliasStr),
  34. !1);
  35. }
  36. function importAttributeOptions(npt, opts, userOptions) {
  37. function importOption(option, optionData) {
  38. optionData = void 0 !== optionData ? optionData : npt.getAttribute("data-inputmask-" + option),
  39. null !== optionData && ("string" == typeof optionData && (0 === option.indexOf("on") ? optionData = window[optionData] : "false" === optionData ? optionData = !1 : "true" === optionData && (optionData = !0)),
  40. userOptions[option] = optionData);
  41. }
  42. var option, dataoptions, optionData, p, attrOptions = npt.getAttribute("data-inputmask");
  43. if (attrOptions && "" !== attrOptions && (attrOptions = attrOptions.replace(new RegExp("'", "g"), '"'),
  44. dataoptions = JSON.parse("{" + attrOptions + "}")), dataoptions) {
  45. optionData = void 0;
  46. for (p in dataoptions) if ("alias" === p.toLowerCase()) {
  47. optionData = dataoptions[p];
  48. break;
  49. }
  50. }
  51. importOption("alias", optionData), userOptions.alias && resolveAlias(userOptions.alias, userOptions, opts);
  52. for (option in opts) {
  53. if (dataoptions) {
  54. optionData = void 0;
  55. for (p in dataoptions) if (p.toLowerCase() === option.toLowerCase()) {
  56. optionData = dataoptions[p];
  57. break;
  58. }
  59. }
  60. importOption(option, optionData);
  61. }
  62. return $.extend(!0, opts, userOptions), opts;
  63. }
  64. function generateMaskSet(opts, nocache) {
  65. function analyseMask(mask) {
  66. function MaskToken(isGroup, isOptional, isQuantifier, isAlternator) {
  67. this.matches = [], this.isGroup = isGroup || !1, this.isOptional = isOptional || !1,
  68. this.isQuantifier = isQuantifier || !1, this.isAlternator = isAlternator || !1,
  69. this.quantifier = {
  70. min: 1,
  71. max: 1
  72. };
  73. }
  74. function insertTestDefinition(mtoken, element, position) {
  75. var maskdef = opts.definitions[element];
  76. position = void 0 !== position ? position : mtoken.matches.length;
  77. var prevMatch = mtoken.matches[position - 1];
  78. if (maskdef && !escaped) {
  79. maskdef.placeholder = $.isFunction(maskdef.placeholder) ? maskdef.placeholder(opts) : maskdef.placeholder;
  80. for (var prevalidators = maskdef.prevalidator, prevalidatorsL = prevalidators ? prevalidators.length : 0, i = 1; i < maskdef.cardinality; i++) {
  81. var prevalidator = prevalidatorsL >= i ? prevalidators[i - 1] : [], validator = prevalidator.validator, cardinality = prevalidator.cardinality;
  82. mtoken.matches.splice(position++, 0, {
  83. fn: validator ? "string" == typeof validator ? new RegExp(validator) : new function() {
  84. this.test = validator;
  85. }() : new RegExp("."),
  86. cardinality: cardinality ? cardinality : 1,
  87. optionality: mtoken.isOptional,
  88. newBlockMarker: void 0 === prevMatch || prevMatch.def !== (maskdef.definitionSymbol || element),
  89. casing: maskdef.casing,
  90. def: maskdef.definitionSymbol || element,
  91. placeholder: maskdef.placeholder,
  92. mask: element
  93. }), prevMatch = mtoken.matches[position - 1];
  94. }
  95. mtoken.matches.splice(position++, 0, {
  96. fn: maskdef.validator ? "string" == typeof maskdef.validator ? new RegExp(maskdef.validator) : new function() {
  97. this.test = maskdef.validator;
  98. }() : new RegExp("."),
  99. cardinality: maskdef.cardinality,
  100. optionality: mtoken.isOptional,
  101. newBlockMarker: void 0 === prevMatch || prevMatch.def !== (maskdef.definitionSymbol || element),
  102. casing: maskdef.casing,
  103. def: maskdef.definitionSymbol || element,
  104. placeholder: maskdef.placeholder,
  105. mask: element
  106. });
  107. } else mtoken.matches.splice(position++, 0, {
  108. fn: null,
  109. cardinality: 0,
  110. optionality: mtoken.isOptional,
  111. newBlockMarker: void 0 === prevMatch || prevMatch.def !== element,
  112. casing: null,
  113. def: opts.staticDefinitionSymbol || element,
  114. placeholder: void 0 !== opts.staticDefinitionSymbol ? element : void 0,
  115. mask: element
  116. }), escaped = !1;
  117. }
  118. function verifyGroupMarker(lastMatch, isOpenGroup) {
  119. lastMatch.isGroup && (lastMatch.isGroup = !1, insertTestDefinition(lastMatch, opts.groupmarker.start, 0),
  120. isOpenGroup !== !0 && insertTestDefinition(lastMatch, opts.groupmarker.end));
  121. }
  122. function maskCurrentToken(m, currentToken, lastMatch, extraCondition) {
  123. currentToken.matches.length > 0 && (void 0 === extraCondition || extraCondition) && (lastMatch = currentToken.matches[currentToken.matches.length - 1],
  124. verifyGroupMarker(lastMatch)), insertTestDefinition(currentToken, m);
  125. }
  126. function defaultCase() {
  127. if (openenings.length > 0) {
  128. if (currentOpeningToken = openenings[openenings.length - 1], maskCurrentToken(m, currentOpeningToken, lastMatch, !currentOpeningToken.isAlternator),
  129. currentOpeningToken.isAlternator) {
  130. alternator = openenings.pop();
  131. for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
  132. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  133. currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
  134. }
  135. } else maskCurrentToken(m, currentToken, lastMatch);
  136. }
  137. function reverseTokens(maskToken) {
  138. function reverseStatic(st) {
  139. 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),
  140. st;
  141. }
  142. maskToken.matches = maskToken.matches.reverse();
  143. for (var match in maskToken.matches) {
  144. var intMatch = parseInt(match);
  145. if (maskToken.matches[match].isQuantifier && maskToken.matches[intMatch + 1] && maskToken.matches[intMatch + 1].isGroup) {
  146. var qt = maskToken.matches[match];
  147. maskToken.matches.splice(match, 1), maskToken.matches.splice(intMatch + 1, 0, qt);
  148. }
  149. void 0 !== maskToken.matches[match].matches ? maskToken.matches[match] = reverseTokens(maskToken.matches[match]) : maskToken.matches[match] = reverseStatic(maskToken.matches[match]);
  150. }
  151. return maskToken;
  152. }
  153. 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],
  154. escaped) defaultCase(); else switch (m.charAt(0)) {
  155. case opts.escapeChar:
  156. escaped = !0;
  157. break;
  158. case opts.optionalmarker.end:
  159. case opts.groupmarker.end:
  160. if (openingToken = openenings.pop(), void 0 !== openingToken) if (openenings.length > 0) {
  161. if (currentOpeningToken = openenings[openenings.length - 1], currentOpeningToken.matches.push(openingToken),
  162. currentOpeningToken.isAlternator) {
  163. alternator = openenings.pop();
  164. for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
  165. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  166. currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
  167. }
  168. } else currentToken.matches.push(openingToken); else defaultCase();
  169. break;
  170. case opts.optionalmarker.start:
  171. openenings.push(new MaskToken(!1, !0));
  172. break;
  173. case opts.groupmarker.start:
  174. openenings.push(new MaskToken(!0));
  175. break;
  176. case opts.quantifiermarker.start:
  177. var quantifier = new MaskToken(!1, !1, !0);
  178. m = m.replace(/[{}]/g, "");
  179. 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]);
  180. if (("*" === mq1 || "+" === mq1) && (mq0 = "*" === mq1 ? 0 : 1), quantifier.quantifier = {
  181. min: mq0,
  182. max: mq1
  183. }, openenings.length > 0) {
  184. var matches = openenings[openenings.length - 1].matches;
  185. match = matches.pop(), match.isGroup || (groupToken = new MaskToken(!0), groupToken.matches.push(match),
  186. match = groupToken), matches.push(match), matches.push(quantifier);
  187. } else match = currentToken.matches.pop(), match.isGroup || (groupToken = new MaskToken(!0),
  188. groupToken.matches.push(match), match = groupToken), currentToken.matches.push(match),
  189. currentToken.matches.push(quantifier);
  190. break;
  191. case opts.alternatormarker:
  192. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  193. lastMatch = currentOpeningToken.matches.pop()) : lastMatch = currentToken.matches.pop(),
  194. lastMatch.isAlternator ? openenings.push(lastMatch) : (alternator = new MaskToken(!1, !1, !1, !0),
  195. alternator.matches.push(lastMatch), openenings.push(alternator));
  196. break;
  197. default:
  198. defaultCase();
  199. }
  200. for (;openenings.length > 0; ) openingToken = openenings.pop(), verifyGroupMarker(openingToken, !0),
  201. currentToken.matches.push(openingToken);
  202. return currentToken.matches.length > 0 && (lastMatch = currentToken.matches[currentToken.matches.length - 1],
  203. verifyGroupMarker(lastMatch), maskTokens.push(currentToken)), opts.numericInput && reverseTokens(maskTokens[0]),
  204. maskTokens;
  205. }
  206. function generateMask(mask, metadata) {
  207. if (null === mask || "" === mask) return void 0;
  208. if (1 === mask.length && opts.greedy === !1 && 0 !== opts.repeat && (opts.placeholder = ""),
  209. opts.repeat > 0 || "*" === opts.repeat || "+" === opts.repeat) {
  210. var repeatStart = "*" === opts.repeat ? 0 : "+" === opts.repeat ? 1 : opts.repeat;
  211. mask = opts.groupmarker.start + mask + opts.groupmarker.end + opts.quantifiermarker.start + repeatStart + "," + opts.repeat + opts.quantifiermarker.end;
  212. }
  213. var masksetDefinition;
  214. return void 0 === Inputmask.prototype.masksCache[mask] || nocache === !0 ? (masksetDefinition = {
  215. mask: mask,
  216. maskToken: analyseMask(mask),
  217. validPositions: {},
  218. _buffer: void 0,
  219. buffer: void 0,
  220. tests: {},
  221. metadata: metadata
  222. }, nocache !== !0 && (Inputmask.prototype.masksCache[opts.numericInput ? mask.split("").reverse().join("") : mask] = masksetDefinition,
  223. 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]),
  224. masksetDefinition;
  225. }
  226. function preProcessMask(mask) {
  227. return mask = mask.toString();
  228. }
  229. var ms;
  230. if ($.isFunction(opts.mask) && (opts.mask = opts.mask(opts)), $.isArray(opts.mask)) {
  231. if (opts.mask.length > 1) {
  232. opts.keepStatic = null === opts.keepStatic ? !0 : opts.keepStatic;
  233. var altMask = "(";
  234. return $.each(opts.numericInput ? opts.mask.reverse() : opts.mask, function(ndx, msk) {
  235. altMask.length > 1 && (altMask += ")|("), altMask += preProcessMask(void 0 === msk.mask || $.isFunction(msk.mask) ? msk : msk.mask);
  236. }), altMask += ")", generateMask(altMask, opts.mask);
  237. }
  238. opts.mask = opts.mask.pop();
  239. }
  240. 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)),
  241. ms;
  242. }
  243. function maskScope(actionObj, maskset, opts) {
  244. function getMaskTemplate(baseOnInput, minimalPos, includeInput) {
  245. minimalPos = minimalPos || 0;
  246. var ndxIntlzr, test, testPos, maskTemplate = [], pos = 0, lvp = getLastValidPosition();
  247. do {
  248. if (baseOnInput === !0 && getMaskSet().validPositions[pos]) {
  249. var validPos = getMaskSet().validPositions[pos];
  250. test = validPos.match, ndxIntlzr = validPos.locator.slice(), maskTemplate.push(includeInput === !0 ? validPos.input : getPlaceholder(pos, test));
  251. } else testPos = getTestTemplate(pos, ndxIntlzr, pos - 1), test = testPos.match,
  252. ndxIntlzr = testPos.locator.slice(), (opts.jitMasking === !1 || lvp > pos || isFinite(opts.jitMasking) && opts.jitMasking > pos) && maskTemplate.push(getPlaceholder(pos, test));
  253. pos++;
  254. } while ((void 0 === maxLength || maxLength > pos - 1) && null !== test.fn || null === test.fn && "" !== test.def || minimalPos >= pos);
  255. return "" === maskTemplate[maskTemplate.length - 1] && maskTemplate.pop(), maskTemplate;
  256. }
  257. function getMaskSet() {
  258. return maskset;
  259. }
  260. function resetMaskSet(soft) {
  261. var maskset = getMaskSet();
  262. maskset.buffer = void 0, soft !== !0 && (maskset.tests = {}, maskset._buffer = void 0,
  263. maskset.validPositions = {}, maskset.p = 0);
  264. }
  265. function getLastValidPosition(closestTo, strict) {
  266. var before = -1, after = -1, valids = getMaskSet().validPositions;
  267. void 0 === closestTo && (closestTo = -1);
  268. for (var posNdx in valids) {
  269. var psNdx = parseInt(posNdx);
  270. valids[psNdx] && (strict || null !== valids[psNdx].match.fn) && (closestTo >= psNdx && (before = psNdx),
  271. psNdx >= closestTo && (after = psNdx));
  272. }
  273. return -1 !== before && closestTo - before > 1 || closestTo > after ? before : after;
  274. }
  275. function setValidPosition(pos, validTest, fromSetValid) {
  276. if (opts.insertMode && void 0 !== getMaskSet().validPositions[pos] && void 0 === fromSetValid) {
  277. var i, positionsClone = $.extend(!0, {}, getMaskSet().validPositions), lvp = getLastValidPosition();
  278. for (i = pos; lvp >= i; i++) delete getMaskSet().validPositions[i];
  279. getMaskSet().validPositions[pos] = validTest;
  280. var j, valid = !0, vps = getMaskSet().validPositions;
  281. for (i = j = pos; lvp >= i; i++) {
  282. var t = positionsClone[i];
  283. 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); ) {
  284. 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),
  285. positionCanMatchDefinition(posMatch, t.match.def)) {
  286. var result = isValid(posMatch, t.input, !0, !0);
  287. valid = result !== !1, j = result.caret || result.insert ? getLastValidPosition() : posMatch;
  288. break;
  289. }
  290. if (valid = null == t.match.fn, prevPosMatch === posMatch) break;
  291. prevPosMatch = posMatch;
  292. }
  293. if (!valid) break;
  294. }
  295. if (!valid) return getMaskSet().validPositions = $.extend(!0, {}, positionsClone),
  296. resetMaskSet(!0), !1;
  297. } else getMaskSet().validPositions[pos] = validTest;
  298. return resetMaskSet(!0), !0;
  299. }
  300. function stripValidPositions(start, end, nocheck, strict) {
  301. var i, startPos = start;
  302. 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];
  303. for (i = startPos + 1; i <= getLastValidPosition(); ) {
  304. for (;void 0 !== getMaskSet().validPositions[startPos]; ) startPos++;
  305. var s = getMaskSet().validPositions[startPos];
  306. if (startPos > i && (i = startPos + 1), void 0 === getMaskSet().validPositions[i] && isMask(i) || void 0 !== s) i++; else {
  307. var t = getTestTemplate(i);
  308. positionCanMatchDefinition(startPos, t.match.def) ? isValid(startPos, t.input || getPlaceholder(i), !0) !== !1 && (delete getMaskSet().validPositions[i],
  309. i++) : isMask(i) || (i++, startPos--), startPos++;
  310. }
  311. }
  312. var lvp = getLastValidPosition(), ml = getMaskLength();
  313. for (strict !== !0 && nocheck !== !0 && void 0 !== getMaskSet().validPositions[lvp] && getMaskSet().validPositions[lvp].input === opts.radixPoint && delete getMaskSet().validPositions[lvp],
  314. i = lvp + 1; ml >= i; i++) getMaskSet().validPositions[i] && delete getMaskSet().validPositions[i];
  315. resetMaskSet(!0);
  316. }
  317. function getTestTemplate(pos, ndxIntlzr, tstPs) {
  318. var testPos = getMaskSet().validPositions[pos];
  319. 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],
  320. !(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++) ;
  321. return testPos;
  322. }
  323. function getTest(pos) {
  324. return getMaskSet().validPositions[pos] ? getMaskSet().validPositions[pos].match : getTests(pos)[0].match;
  325. }
  326. function positionCanMatchDefinition(pos, def) {
  327. for (var valid = !1, tests = getTests(pos), tndx = 0; tndx < tests.length; tndx++) if (tests[tndx].match && tests[tndx].match.def === def) {
  328. valid = !0;
  329. break;
  330. }
  331. return valid;
  332. }
  333. function selectBestMatch(pos, alternateNdx) {
  334. var bestMatch, indexPos;
  335. return (getMaskSet().tests[pos] || getMaskSet().validPositions[pos]) && $.each(getMaskSet().tests[pos] || [ getMaskSet().validPositions[pos] ], function(ndx, lmnt) {
  336. var ndxPos = lmnt.alternation ? lmnt.locator[lmnt.alternation].toString().indexOf(alternateNdx) : -1;
  337. (void 0 === indexPos || indexPos > ndxPos) && -1 !== ndxPos && (bestMatch = lmnt,
  338. indexPos = ndxPos);
  339. }), bestMatch;
  340. }
  341. function getTests(pos, ndxIntlzr, tstPs) {
  342. function resolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) {
  343. function handleMatch(match, loopNdx, quantifierRecurse) {
  344. function isFirstMatch(latestMatch, tokenGroup) {
  345. var firstMatch = 0 === $.inArray(latestMatch, tokenGroup.matches);
  346. return firstMatch || $.each(tokenGroup.matches, function(ndx, match) {
  347. return match.isQuantifier === !0 && (firstMatch = isFirstMatch(latestMatch, tokenGroup.matches[ndx - 1])) ? !1 : void 0;
  348. }), firstMatch;
  349. }
  350. function resolveNdxInitializer(pos, alternateNdx) {
  351. var bestMatch = selectBestMatch(pos, alternateNdx);
  352. return bestMatch ? bestMatch.locator.slice(bestMatch.alternation + 1) : [];
  353. }
  354. 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;
  355. if (testPos === pos && void 0 === match.matches) return matches.push({
  356. match: match,
  357. locator: loopNdx.reverse(),
  358. cd: cacheDependency
  359. }), !0;
  360. if (void 0 !== match.matches) {
  361. if (match.isGroup && quantifierRecurse !== match) {
  362. if (match = handleMatch(maskToken.matches[$.inArray(match, maskToken.matches) + 1], loopNdx)) return !0;
  363. } else if (match.isOptional) {
  364. var optionalToken = match;
  365. if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) {
  366. if (latestMatch = matches[matches.length - 1].match, !isFirstMatch(latestMatch, optionalToken)) return !0;
  367. insertStop = !0, testPos = pos;
  368. }
  369. } else if (match.isAlternator) {
  370. var maltMatches, alternateToken = match, malternateMatches = [], currentMatches = matches.slice(), loopNdxCnt = loopNdx.length, altIndex = ndxInitializer.length > 0 ? ndxInitializer.shift() : -1;
  371. if (-1 === altIndex || "string" == typeof altIndex) {
  372. var amndx, currentPos = testPos, ndxInitializerClone = ndxInitializer.slice(), altIndexArr = [];
  373. if ("string" == typeof altIndex) altIndexArr = altIndex.split(","); else for (amndx = 0; amndx < alternateToken.matches.length; amndx++) altIndexArr.push(amndx);
  374. for (var ndx = 0; ndx < altIndexArr.length; ndx++) {
  375. if (amndx = parseInt(altIndexArr[ndx]), matches = [], ndxInitializer = resolveNdxInitializer(testPos, amndx),
  376. match = handleMatch(alternateToken.matches[amndx] || maskToken.matches[amndx], [ amndx ].concat(loopNdx), quantifierRecurse) || match,
  377. match !== !0 && void 0 !== match && altIndexArr[altIndexArr.length - 1] < alternateToken.matches.length) {
  378. var ntndx = $.inArray(match, maskToken.matches) + 1;
  379. maskToken.matches.length > ntndx && (match = handleMatch(maskToken.matches[ntndx], [ ntndx ].concat(loopNdx.slice(1, loopNdx.length)), quantifierRecurse),
  380. match && (altIndexArr.push(ntndx.toString()), $.each(matches, function(ndx, lmnt) {
  381. lmnt.alternation = loopNdx.length - 1;
  382. })));
  383. }
  384. maltMatches = matches.slice(), testPos = currentPos, matches = [];
  385. for (var i = 0; i < ndxInitializerClone.length; i++) ndxInitializer[i] = ndxInitializerClone[i];
  386. for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) {
  387. var altMatch = maltMatches[ndx1];
  388. altMatch.alternation = altMatch.alternation || loopNdxCnt;
  389. for (var ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) {
  390. var altMatch2 = malternateMatches[ndx2];
  391. if (altMatch.match.def === altMatch2.match.def && ("string" != typeof altIndex || -1 !== $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr))) {
  392. altMatch.match.mask === altMatch2.match.mask && (maltMatches.splice(ndx1, 1), ndx1--),
  393. -1 === altMatch2.locator[altMatch.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) && (altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation],
  394. altMatch2.alternation = altMatch.alternation);
  395. break;
  396. }
  397. }
  398. }
  399. malternateMatches = malternateMatches.concat(maltMatches);
  400. }
  401. "string" == typeof altIndex && (malternateMatches = $.map(malternateMatches, function(lmnt, ndx) {
  402. if (isFinite(ndx)) {
  403. var mamatch, alternation = lmnt.alternation, altLocArr = lmnt.locator[alternation].toString().split(",");
  404. lmnt.locator[alternation] = void 0, lmnt.alternation = void 0;
  405. for (var alndx = 0; alndx < altLocArr.length; alndx++) mamatch = -1 !== $.inArray(altLocArr[alndx], altIndexArr),
  406. mamatch && (void 0 !== lmnt.locator[alternation] ? (lmnt.locator[alternation] += ",",
  407. lmnt.locator[alternation] += altLocArr[alndx]) : lmnt.locator[alternation] = parseInt(altLocArr[alndx]),
  408. lmnt.alternation = alternation);
  409. if (void 0 !== lmnt.locator[alternation]) return lmnt;
  410. }
  411. })), matches = currentMatches.concat(malternateMatches), testPos = pos, insertStop = matches.length > 0;
  412. } else match = handleMatch(alternateToken.matches[altIndex] || maskToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse);
  413. if (match) return !0;
  414. } 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++) {
  415. var tokenGroup = maskToken.matches[$.inArray(qt, maskToken.matches) - 1];
  416. if (match = handleMatch(tokenGroup, [ qndx ].concat(loopNdx), tokenGroup)) {
  417. if (latestMatch = matches[matches.length - 1].match, latestMatch.optionalQuantifier = qndx > qt.quantifier.min - 1,
  418. isFirstMatch(latestMatch, tokenGroup)) {
  419. if (qndx > qt.quantifier.min - 1) {
  420. insertStop = !0, testPos = pos;
  421. break;
  422. }
  423. return !0;
  424. }
  425. return !0;
  426. }
  427. } else if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) return !0;
  428. } else testPos++;
  429. }
  430. for (var tndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; tndx < maskToken.matches.length; tndx++) if (maskToken.matches[tndx].isQuantifier !== !0) {
  431. var match = handleMatch(maskToken.matches[tndx], [ tndx ].concat(loopNdx), quantifierRecurse);
  432. if (match && testPos === pos) return match;
  433. if (testPos > pos) break;
  434. }
  435. }
  436. function mergeLocators(tests) {
  437. var test = tests[0] || tests;
  438. return test.locator.slice();
  439. }
  440. var latestMatch, maskTokens = getMaskSet().maskToken, testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr || [ 0 ], matches = [], insertStop = !1, cacheDependency = ndxIntlzr ? ndxIntlzr.join("") : "";
  441. if (pos > -1) {
  442. if (void 0 === ndxIntlzr) {
  443. for (var test, previousPos = pos - 1; void 0 === (test = getMaskSet().validPositions[previousPos] || getMaskSet().tests[previousPos]) && previousPos > -1; ) previousPos--;
  444. void 0 !== test && previousPos > -1 && (ndxInitializer = mergeLocators(test), cacheDependency = ndxInitializer.join(""),
  445. test = test[0] || test, testPos = previousPos);
  446. }
  447. if (getMaskSet().tests[pos] && getMaskSet().tests[pos][0].cd === cacheDependency) return getMaskSet().tests[pos];
  448. for (var mtndx = ndxInitializer.shift(); mtndx < maskTokens.length; mtndx++) {
  449. var match = resolveTestFromToken(maskTokens[mtndx], ndxInitializer, [ mtndx ]);
  450. if (match && testPos === pos || testPos > pos) break;
  451. }
  452. }
  453. return (0 === matches.length || insertStop) && matches.push({
  454. match: {
  455. fn: null,
  456. cardinality: 0,
  457. optionality: !0,
  458. casing: null,
  459. def: ""
  460. },
  461. locator: []
  462. }), getMaskSet().tests[pos] = $.extend(!0, [], matches), getMaskSet().tests[pos];
  463. }
  464. function getBufferTemplate() {
  465. return void 0 === getMaskSet()._buffer && (getMaskSet()._buffer = getMaskTemplate(!1, 1)),
  466. getMaskSet()._buffer;
  467. }
  468. function getBuffer(noCache) {
  469. if (void 0 === getMaskSet().buffer || noCache === !0) {
  470. if (noCache === !0) for (var testNdx in getMaskSet().tests) void 0 === getMaskSet().validPositions[testNdx] && delete getMaskSet().tests[testNdx];
  471. getMaskSet().buffer = getMaskTemplate(!0, getLastValidPosition(), !0);
  472. }
  473. return getMaskSet().buffer;
  474. }
  475. function refreshFromBuffer(start, end, buffer) {
  476. var i;
  477. if (buffer = buffer, start === !0) resetMaskSet(), start = 0, end = buffer.length; else for (i = start; end > i; i++) delete getMaskSet().validPositions[i],
  478. delete getMaskSet().tests[i];
  479. for (i = start; end > i; i++) resetMaskSet(!0), buffer[i] !== opts.skipOptionalPartCharacter && isValid(i, buffer[i], !0, !0);
  480. }
  481. function casing(elem, test) {
  482. switch (test.casing) {
  483. case "upper":
  484. elem = elem.toUpperCase();
  485. break;
  486. case "lower":
  487. elem = elem.toLowerCase();
  488. }
  489. return elem;
  490. }
  491. function checkAlternationMatch(altArr1, altArr2) {
  492. for (var altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1), isMatch = !1, alndx = 0; alndx < altArr1.length; alndx++) if (-1 !== $.inArray(altArr1[alndx], altArrC)) {
  493. isMatch = !0;
  494. break;
  495. }
  496. return isMatch;
  497. }
  498. function isValid(pos, c, strict, fromSetValid) {
  499. function _isValid(position, c, strict, fromSetValid) {
  500. var rslt = !1;
  501. return $.each(getTests(position), function(ndx, tst) {
  502. for (var test = tst.match, loopend = c ? 1 : 0, chrs = "", i = test.cardinality; i > loopend; i--) chrs += getBufferElement(position - (i - 1));
  503. 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 : {
  504. c: test.placeholder || test.def,
  505. pos: position
  506. }, rslt !== !1) {
  507. var elem = void 0 !== rslt.c ? rslt.c : c;
  508. elem = elem === opts.skipOptionalPartCharacter && null === test.fn ? test.placeholder || test.def : elem;
  509. var validatedPos = position, possibleModifiedBuffer = getBuffer();
  510. if (void 0 !== rslt.remove && ($.isArray(rslt.remove) || (rslt.remove = [ rslt.remove ]),
  511. $.each(rslt.remove.sort(function(a, b) {
  512. return b - a;
  513. }), function(ndx, lmnt) {
  514. stripValidPositions(lmnt, lmnt + 1, !0);
  515. })), void 0 !== rslt.insert && ($.isArray(rslt.insert) || (rslt.insert = [ rslt.insert ]),
  516. $.each(rslt.insert.sort(function(a, b) {
  517. return a - b;
  518. }), function(ndx, lmnt) {
  519. isValid(lmnt.pos, lmnt.c, !1, fromSetValid);
  520. })), rslt.refreshFromBuffer) {
  521. var refresh = rslt.refreshFromBuffer;
  522. if (strict = !0, refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, possibleModifiedBuffer),
  523. void 0 === rslt.pos && void 0 === rslt.c) return rslt.pos = getLastValidPosition(),
  524. !1;
  525. if (validatedPos = void 0 !== rslt.pos ? rslt.pos : position, validatedPos !== position) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0, fromSetValid)),
  526. !1;
  527. } else if (rslt !== !0 && void 0 !== rslt.pos && rslt.pos !== position && (validatedPos = rslt.pos,
  528. refreshFromBuffer(position, validatedPos, getBuffer().slice()), validatedPos !== position)) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0)),
  529. !1;
  530. return rslt !== !0 && void 0 === rslt.pos && void 0 === rslt.c ? !1 : (ndx > 0 && resetMaskSet(!0),
  531. setValidPosition(validatedPos, $.extend({}, tst, {
  532. input: casing(elem, test)
  533. }), fromSetValid) || (rslt = !1), !1);
  534. }
  535. }), rslt;
  536. }
  537. function alternate(pos, c, strict, fromSetValid) {
  538. 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],
  539. !altPos || void 0 === altPos.alternation || (lastAlt = lAlt, alternation = getMaskSet().validPositions[lastAlt].alternation,
  540. getTestTemplate(lastAlt).locator[altPos.alternation] === altPos.locator[altPos.alternation])); lAlt--) ;
  541. if (void 0 !== alternation) {
  542. lastAlt = parseInt(lastAlt);
  543. for (var decisionPos in getMaskSet().validPositions) if (decisionPos = parseInt(decisionPos),
  544. altPos = getMaskSet().validPositions[decisionPos], decisionPos >= lastAlt && void 0 !== altPos.alternation) {
  545. var altNdxs;
  546. 0 === lastAlt ? (altNdxs = [], $.each(getMaskSet().tests[lastAlt], function(ndx, test) {
  547. void 0 !== test.locator[alternation] && (altNdxs = altNdxs.concat(test.locator[alternation].toString().split(",")));
  548. })) : altNdxs = getMaskSet().validPositions[lastAlt].locator[alternation].toString().split(",");
  549. var decisionTaker = void 0 !== altPos.locator[alternation] ? altPos.locator[alternation] : altNdxs[0];
  550. decisionTaker.length > 0 && (decisionTaker = decisionTaker.split(",")[0]);
  551. for (var mndx = 0; mndx < altNdxs.length; mndx++) {
  552. var validInputs = [], staticInputsBeforePos = 0, staticInputsBeforePosAlternate = 0;
  553. if (decisionTaker < altNdxs[mndx]) {
  554. for (var possibilityPos, possibilities, dp = decisionPos; dp >= 0; dp--) if (possibilityPos = getMaskSet().validPositions[dp],
  555. void 0 !== possibilityPos) {
  556. var bestMatch = selectBestMatch(dp, altNdxs[mndx]);
  557. getMaskSet().validPositions[dp].match.def !== bestMatch.match.def && (validInputs.push(getMaskSet().validPositions[dp].input),
  558. getMaskSet().validPositions[dp] = bestMatch, getMaskSet().validPositions[dp].input = getPlaceholder(dp),
  559. null === getMaskSet().validPositions[dp].match.fn && staticInputsBeforePosAlternate++,
  560. possibilityPos = bestMatch), possibilities = possibilityPos.locator[alternation],
  561. possibilityPos.locator[alternation] = parseInt(altNdxs[mndx]);
  562. break;
  563. }
  564. if (decisionTaker !== possibilityPos.locator[alternation]) {
  565. for (i = decisionPos + 1; i < getLastValidPosition(void 0, !0) + 1; i++) validPos = getMaskSet().validPositions[i],
  566. validPos && null != validPos.match.fn ? validInputs.push(validPos.input) : pos > i && staticInputsBeforePos++,
  567. delete getMaskSet().validPositions[i], delete getMaskSet().tests[i];
  568. for (resetMaskSet(!0), opts.keepStatic = !opts.keepStatic, isValidRslt = !0; validInputs.length > 0; ) {
  569. var input = validInputs.shift();
  570. if (input !== opts.skipOptionalPartCharacter && !(isValidRslt = isValid(getLastValidPosition(void 0, !0) + 1, input, !1, fromSetValid))) break;
  571. }
  572. if (possibilityPos.alternation = alternation, possibilityPos.locator[alternation] = possibilities,
  573. isValidRslt) {
  574. var targetLvp = getLastValidPosition(pos) + 1;
  575. for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) validPos = getMaskSet().validPositions[i],
  576. (void 0 === validPos || null == validPos.match.fn) && pos > i && staticInputsBeforePosAlternate++;
  577. pos += staticInputsBeforePosAlternate - staticInputsBeforePos, isValidRslt = isValid(pos > targetLvp ? targetLvp : pos, c, strict, fromSetValid);
  578. }
  579. if (opts.keepStatic = !opts.keepStatic, isValidRslt) return isValidRslt;
  580. resetMaskSet(), getMaskSet().validPositions = $.extend(!0, {}, validPsClone), getMaskSet().tests = $.extend(!0, {}, testsClone);
  581. }
  582. }
  583. }
  584. break;
  585. }
  586. }
  587. return !1;
  588. }
  589. function trackbackAlternations(originalPos, newPos) {
  590. 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)) {
  591. var tests = getTests(ps), bestMatch = tests[0], equality = -1;
  592. $.each(tests, function(ndx, tst) {
  593. 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,
  594. bestMatch = tst);
  595. }), setValidPosition(ps, $.extend({}, bestMatch, {
  596. input: bestMatch.match.placeholder || bestMatch.match.def
  597. }), !0);
  598. }
  599. }
  600. strict = strict === !0;
  601. for (var buffer = getBuffer(), pndx = pos - 1; pndx > -1 && !getMaskSet().validPositions[pndx]; pndx--) ;
  602. 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);
  603. var maskPos = pos, result = !1, positionsClone = $.extend(!0, {}, getMaskSet().validPositions);
  604. if (maskPos < getMaskLength() && (result = _isValid(maskPos, c, strict, fromSetValid),
  605. (!strict || fromSetValid === !0) && result === !1)) {
  606. var currentPosValid = getMaskSet().validPositions[maskPos];
  607. if (!currentPosValid || null !== currentPosValid.match.fn || currentPosValid.match.def !== c && c !== opts.skipOptionalPartCharacter) {
  608. if ((opts.insertMode || void 0 === getMaskSet().validPositions[seekNext(maskPos)]) && !isMask(maskPos, !0)) {
  609. var staticChar = getTestTemplate(maskPos).match, staticChar = staticChar.placeholder || staticChar.def;
  610. _isValid(maskPos, staticChar, strict, fromSetValid);
  611. for (var nPos = maskPos + 1, snPos = seekNext(maskPos); snPos >= nPos; nPos++) if (result = _isValid(nPos, c, strict, fromSetValid),
  612. result !== !1) {
  613. trackbackAlternations(maskPos, nPos), maskPos = nPos;
  614. break;
  615. }
  616. }
  617. } else result = {
  618. caret: seekNext(maskPos)
  619. };
  620. }
  621. if (result === !1 && opts.keepStatic && (result = alternate(pos, c, strict, fromSetValid)),
  622. result === !0 && (result = {
  623. pos: maskPos
  624. }), $.isFunction(opts.postValidation) && result !== !1 && !strict && fromSetValid !== !0) {
  625. var postValidResult = opts.postValidation(getBuffer(!0), result, opts);
  626. if (postValidResult) {
  627. if (postValidResult.refreshFromBuffer) {
  628. var refresh = postValidResult.refreshFromBuffer;
  629. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, postValidResult.buffer),
  630. resetMaskSet(!0), result = postValidResult;
  631. }
  632. } else resetMaskSet(!0), getMaskSet().validPositions = $.extend(!0, {}, positionsClone),
  633. result = !1;
  634. }
  635. return result;
  636. }
  637. function isMask(pos, strict) {
  638. var test;
  639. if (strict ? (test = getTestTemplate(pos).match, "" == test.def && (test = getTest(pos))) : test = getTest(pos),
  640. null != test.fn) return test.fn;
  641. if (strict !== !0 && pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
  642. var tests = getTests(pos);
  643. return tests.length > 2;
  644. }
  645. return !1;
  646. }
  647. function getMaskLength() {
  648. var maskLength;
  649. maxLength = void 0 !== el ? el.maxLength : void 0, -1 === maxLength && (maxLength = void 0);
  650. var pos, lvp = getLastValidPosition(), testPos = getMaskSet().validPositions[lvp], ndxIntlzr = void 0 !== testPos ? testPos.locator.slice() : void 0;
  651. 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),
  652. ndxIntlzr = testPos.locator.slice();
  653. var lastTest = getTest(pos - 1);
  654. return maskLength = "" !== lastTest.def ? pos : pos - 1, void 0 === maxLength || maxLength > maskLength ? maskLength : maxLength;
  655. }
  656. function seekNext(pos, newBlock) {
  657. var maskL = getMaskLength();
  658. if (pos >= maskL) return maskL;
  659. for (var position = pos; ++position < maskL && (newBlock === !0 && (getTest(position).newBlockMarker !== !0 || !isMask(position)) || newBlock !== !0 && !isMask(position) && (opts.nojumps !== !0 || opts.nojumpsThreshold > position)); ) ;
  660. return position;
  661. }
  662. function seekPrevious(pos, newBlock) {
  663. var position = pos;
  664. if (0 >= position) return 0;
  665. for (;--position > 0 && (newBlock === !0 && getTest(position).newBlockMarker !== !0 || newBlock !== !0 && !isMask(position)); ) ;
  666. return position;
  667. }
  668. function getBufferElement(position) {
  669. return void 0 === getMaskSet().validPositions[position] ? getPlaceholder(position) : getMaskSet().validPositions[position].input;
  670. }
  671. function writeBuffer(input, buffer, caretPos, event, triggerInputEvent) {
  672. if (event && $.isFunction(opts.onBeforeWrite)) {
  673. var result = opts.onBeforeWrite(event, buffer, caretPos, opts);
  674. if (result) {
  675. if (result.refreshFromBuffer) {
  676. var refresh = result.refreshFromBuffer;
  677. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, result.buffer || buffer),
  678. buffer = getBuffer(!0);
  679. }
  680. void 0 !== caretPos && (caretPos = void 0 !== result.caret ? result.caret : caretPos);
  681. }
  682. }
  683. input.inputmask._valueSet(buffer.join("")), void 0 === caretPos || void 0 !== event && "blur" === event.type || caret(input, caretPos),
  684. triggerInputEvent === !0 && (skipInputEvent = !0, $(input).trigger("input"));
  685. }
  686. function getPlaceholder(pos, test) {
  687. if (test = test || getTest(pos), void 0 !== test.placeholder) return test.placeholder;
  688. if (null === test.fn) {
  689. if (pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
  690. var prevTest, tests = getTests(pos), staticAlternations = 0;
  691. 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++,
  692. null === tests[i].match.fn && (prevTest = tests[i]), staticAlternations > 1)) return opts.placeholder.charAt(pos % opts.placeholder.length);
  693. }
  694. return test.def;
  695. }
  696. return opts.placeholder.charAt(pos % opts.placeholder.length);
  697. }
  698. function checkVal(input, writeOut, strict, nptvl) {
  699. function isTemplateMatch() {
  700. var isMatch = !1, charCodeNdx = getBufferTemplate().slice(initialNdx, seekNext(initialNdx)).join("").indexOf(charCodes);
  701. if (-1 !== charCodeNdx && !isMask(initialNdx)) {
  702. isMatch = !0;
  703. for (var bufferTemplateArr = getBufferTemplate().slice(initialNdx, initialNdx + charCodeNdx), i = 0; i < bufferTemplateArr.length; i++) if (" " !== bufferTemplateArr[i]) {
  704. isMatch = !1;
  705. break;
  706. }
  707. }
  708. return isMatch;
  709. }
  710. var inputValue = nptvl.slice(), charCodes = "", initialNdx = 0;
  711. if (resetMaskSet(), getMaskSet().p = seekNext(-1), !strict) if (opts.autoUnmask !== !0) {
  712. var staticInput = getBufferTemplate().slice(0, seekNext(-1)).join(""), matches = inputValue.join("").match(new RegExp("^" + Inputmask.escapeRegex(staticInput), "g"));
  713. matches && matches.length > 0 && (inputValue.splice(0, matches.length * staticInput.length),
  714. initialNdx = seekNext(initialNdx));
  715. } else initialNdx = seekNext(initialNdx);
  716. $.each(inputValue, function(ndx, charCode) {
  717. if (void 0 !== charCode) {
  718. var keypress = new $.Event("keypress");
  719. keypress.which = charCode.charCodeAt(0), charCodes += charCode;
  720. var lvp = getLastValidPosition(void 0, !0), lvTest = getMaskSet().validPositions[lvp], nextTest = getTestTemplate(lvp + 1, lvTest ? lvTest.locator.slice() : void 0, lvp);
  721. if (!isTemplateMatch() || strict || opts.autoUnmask) {
  722. var pos = strict ? ndx : null == nextTest.match.fn && nextTest.match.optionality && lvp + 1 < getMaskSet().p ? lvp + 1 : getMaskSet().p;
  723. keypressEvent.call(input, keypress, !0, !1, strict, pos), initialNdx = pos + 1,
  724. charCodes = "";
  725. } else keypressEvent.call(input, keypress, !0, !1, !0, lvp + 1);
  726. }
  727. }), writeOut && writeBuffer(input, getBuffer(), document.activeElement === input ? seekNext(getLastValidPosition(0)) : void 0, new $.Event("checkval"));
  728. }
  729. function unmaskedvalue(input) {
  730. if (input && void 0 === input.inputmask) return input.value;
  731. var umValue = [], vps = getMaskSet().validPositions;
  732. for (var pndx in vps) vps[pndx].match && null != vps[pndx].match.fn && umValue.push(vps[pndx].input);
  733. var unmaskedValue = 0 === umValue.length ? null : (isRTL ? umValue.reverse() : umValue).join("");
  734. if (null !== unmaskedValue) {
  735. var bufferValue = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join("");
  736. $.isFunction(opts.onUnMask) && (unmaskedValue = opts.onUnMask(bufferValue, unmaskedValue, opts) || unmaskedValue);
  737. }
  738. return unmaskedValue;
  739. }
  740. function caret(input, begin, end, notranslate) {
  741. function translatePosition(pos) {
  742. if (notranslate !== !0 && isRTL && "number" == typeof pos && (!opts.greedy || "" !== opts.placeholder)) {
  743. var bffrLght = getBuffer().join("").length;
  744. pos = bffrLght - pos;
  745. }
  746. return pos;
  747. }
  748. var range;
  749. if ("number" != typeof begin) return input.setSelectionRange ? (begin = input.selectionStart,
  750. end = input.selectionEnd) : window.getSelection ? (range = window.getSelection().getRangeAt(0),
  751. (range.commonAncestorContainer.parentNode === input || range.commonAncestorContainer === input) && (begin = range.startOffset,
  752. end = range.endOffset)) : document.selection && document.selection.createRange && (range = document.selection.createRange(),
  753. begin = 0 - range.duplicate().moveStart("character", -1e5), end = begin + range.text.length),
  754. {
  755. begin: translatePosition(begin),
  756. end: translatePosition(end)
  757. };
  758. begin = translatePosition(begin), end = translatePosition(end), end = "number" == typeof end ? end : begin;
  759. var scrollCalc = parseInt(((input.ownerDocument.defaultView || window).getComputedStyle ? (input.ownerDocument.defaultView || window).getComputedStyle(input, null) : input.currentStyle).fontSize) * end;
  760. if (input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0, mobile || opts.insertMode !== !1 || begin !== end || end++,
  761. input.setSelectionRange) input.selectionStart = begin, input.selectionEnd = end; else if (window.getSelection) {
  762. if (range = document.createRange(), void 0 === input.firstChild || null === input.firstChild) {
  763. var textNode = document.createTextNode("");
  764. input.appendChild(textNode);
  765. }
  766. range.setStart(input.firstChild, begin < input.inputmask._valueGet().length ? begin : input.inputmask._valueGet().length),
  767. range.setEnd(input.firstChild, end < input.inputmask._valueGet().length ? end : input.inputmask._valueGet().length),
  768. range.collapse(!0);
  769. var sel = window.getSelection();
  770. sel.removeAllRanges(), sel.addRange(range);
  771. } else input.createTextRange && (range = input.createTextRange(), range.collapse(!0),
  772. range.moveEnd("character", end), range.moveStart("character", begin), range.select());
  773. }
  774. function determineLastRequiredPosition(returnDefinition) {
  775. var pos, testPos, buffer = getBuffer(), bl = buffer.length, lvp = getLastValidPosition(), positions = {}, lvTest = getMaskSet().validPositions[lvp], ndxIntlzr = void 0 !== lvTest ? lvTest.locator.slice() : void 0;
  776. for (pos = lvp + 1; pos < buffer.length; pos++) testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
  777. ndxIntlzr = testPos.locator.slice(), positions[pos] = $.extend(!0, {}, testPos);
  778. var lvTestAlt = lvTest && void 0 !== lvTest.alternation ? lvTest.locator[lvTest.alternation] : void 0;
  779. 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--;
  780. return returnDefinition ? {
  781. l: bl,
  782. def: positions[bl] ? positions[bl].match : void 0
  783. } : bl;
  784. }
  785. function clearOptionalTail(buffer) {
  786. for (var rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
  787. return buffer.splice(rl, lmib + 1 - rl), buffer;
  788. }
  789. function isComplete(buffer) {
  790. if ($.isFunction(opts.isComplete)) return opts.isComplete(buffer, opts);
  791. if ("*" === opts.repeat) return void 0;
  792. var complete = !1, lrp = determineLastRequiredPosition(!0), aml = seekPrevious(lrp.l);
  793. if (void 0 === lrp.def || lrp.def.newBlockMarker || lrp.def.optionality || lrp.def.optionalQuantifier) {
  794. complete = !0;
  795. for (var i = 0; aml >= i; i++) {
  796. var test = getTestTemplate(i).match;
  797. if (null !== test.fn && void 0 === getMaskSet().validPositions[i] && test.optionality !== !0 && test.optionalQuantifier !== !0 || null === test.fn && buffer[i] !== getPlaceholder(i, test)) {
  798. complete = !1;
  799. break;
  800. }
  801. }
  802. }
  803. return complete;
  804. }
  805. function isSelection(begin, end) {
  806. return isRTL ? begin - end > 1 || begin - end === 1 && opts.insertMode : end - begin > 1 || end - begin === 1 && opts.insertMode;
  807. }
  808. function patchValueProperty(npt) {
  809. function patchValhook(type) {
  810. if ($.valHooks && (void 0 === $.valHooks[type] || $.valHooks[type].inputmaskpatch !== !0)) {
  811. var valhookGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function(elem) {
  812. return elem.value;
  813. }, valhookSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function(elem, value) {
  814. return elem.value = value, elem;
  815. };
  816. $.valHooks[type] = {
  817. get: function(elem) {
  818. if (elem.inputmask) {
  819. if (elem.inputmask.opts.autoUnmask) return elem.inputmask.unmaskedvalue();
  820. var result = valhookGet(elem), maskset = elem.inputmask.maskset, bufferTemplate = maskset._buffer;
  821. return bufferTemplate = bufferTemplate ? bufferTemplate.join("") : "", result !== bufferTemplate ? result : "";
  822. }
  823. return valhookGet(elem);
  824. },
  825. set: function(elem, value) {
  826. var result, $elem = $(elem);
  827. return result = valhookSet(elem, value), elem.inputmask && $elem.trigger("setvalue"),
  828. result;
  829. },
  830. inputmaskpatch: !0
  831. };
  832. }
  833. }
  834. function getter() {
  835. 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);
  836. }
  837. function setter(value) {
  838. valueSet.call(this, value), this.inputmask && $(this).trigger("setvalue");
  839. }
  840. function installNativeValueSetFallback(npt) {
  841. EventRuler.on(npt, "mouseenter", function(event) {
  842. var $input = $(this), input = this, value = input.inputmask._valueGet();
  843. value !== getBuffer().join("") && getLastValidPosition() > 0 && $input.trigger("setvalue");
  844. });
  845. }
  846. var valueGet, valueSet;
  847. npt.inputmask.__valueGet || (Object.getOwnPropertyDescriptor && void 0 === npt.value ? (valueGet = function() {
  848. return this.textContent;
  849. }, valueSet = function(value) {
  850. this.textContent = value;
  851. }, Object.defineProperty(npt, "value", {
  852. get: getter,
  853. set: setter
  854. })) : document.__lookupGetter__ && npt.__lookupGetter__("value") ? (valueGet = npt.__lookupGetter__("value"),
  855. valueSet = npt.__lookupSetter__("value"), npt.__defineGetter__("value", getter),
  856. npt.__defineSetter__("value", setter)) : (valueGet = function() {
  857. return npt.value;
  858. }, valueSet = function(value) {
  859. npt.value = value;
  860. }, patchValhook(npt.type), installNativeValueSetFallback(npt)), npt.inputmask.__valueGet = valueGet,
  861. npt.inputmask._valueGet = function(overruleRTL) {
  862. return isRTL && overruleRTL !== !0 ? valueGet.call(this.el).split("").reverse().join("") : valueGet.call(this.el);
  863. }, npt.inputmask.__valueSet = valueSet, npt.inputmask._valueSet = function(value, overruleRTL) {
  864. valueSet.call(this.el, null === value || void 0 === value ? "" : overruleRTL !== !0 && isRTL ? value.split("").reverse().join("") : value);
  865. });
  866. }
  867. function handleRemove(input, k, pos, strict) {
  868. function generalize() {
  869. if (opts.keepStatic) {
  870. resetMaskSet(!0);
  871. var lastAlt, validInputs = [], positionsClone = $.extend(!0, {}, getMaskSet().validPositions);
  872. for (lastAlt = getLastValidPosition(); lastAlt >= 0; lastAlt--) {
  873. var validPos = getMaskSet().validPositions[lastAlt];
  874. if (validPos && (null != validPos.match.fn && validInputs.push(validPos.input),
  875. delete getMaskSet().validPositions[lastAlt], void 0 !== validPos.alternation && validPos.locator[validPos.alternation] === getTestTemplate(lastAlt).locator[validPos.alternation])) break;
  876. }
  877. if (lastAlt > -1) for (;validInputs.length > 0; ) {
  878. getMaskSet().p = seekNext(getLastValidPosition());
  879. var keypress = new $.Event("keypress");
  880. keypress.which = validInputs.pop().charCodeAt(0), keypressEvent.call(input, keypress, !0, !1, !1, getMaskSet().p);
  881. } else getMaskSet().validPositions = $.extend(!0, {}, positionsClone);
  882. }
  883. }
  884. if ((opts.numericInput || isRTL) && (k === Inputmask.keyCode.BACKSPACE ? k = Inputmask.keyCode.DELETE : k === Inputmask.keyCode.DELETE && (k = Inputmask.keyCode.BACKSPACE),
  885. isRTL)) {
  886. var pend = pos.end;
  887. pos.end = pos.begin, pos.begin = pend;
  888. }
  889. k === Inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || opts.insertMode === !1) ? (pos.begin = seekPrevious(pos.begin),
  890. 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,
  891. void 0 === getMaskSet().validPositions[pos.begin] || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.end++),
  892. stripValidPositions(pos.begin, pos.end, !1, strict), strict !== !0 && generalize();
  893. var lvp = getLastValidPosition(pos.begin);
  894. lvp < pos.begin ? (-1 === lvp && resetMaskSet(), getMaskSet().p = seekNext(lvp)) : strict !== !0 && (getMaskSet().p = pos.begin);
  895. }
  896. function keydownEvent(e) {
  897. var input = this, $input = $(input), k = e.keyCode, pos = caret(input);
  898. if (k === Inputmask.keyCode.BACKSPACE || k === Inputmask.keyCode.DELETE || iphone && 127 === k || e.ctrlKey && 88 === k && !isInputEventSupported("cut")) e.preventDefault(),
  899. 88 === k && (undoValue = getBuffer().join("")), handleRemove(input, k, pos), writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")),
  900. input.inputmask._valueGet() === getBufferTemplate().join("") ? $input.trigger("cleared") : isComplete(getBuffer()) === !0 && $input.trigger("complete"),
  901. opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask); else if (k === Inputmask.keyCode.END || k === Inputmask.keyCode.PAGE_DOWN) {
  902. e.preventDefault();
  903. var caretPos = seekNext(getLastValidPosition());
  904. opts.insertMode || caretPos !== getMaskLength() || e.shiftKey || caretPos--, caret(input, e.shiftKey ? pos.begin : caretPos, caretPos, !0);
  905. } else k === Inputmask.keyCode.HOME && !e.shiftKey || k === Inputmask.keyCode.PAGE_UP ? (e.preventDefault(),
  906. 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("")),
  907. $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)),
  908. pos.end = seekPrevious(pos.begin, !0), pos.begin = seekPrevious(pos.end, !0)) : (pos.begin = seekNext(pos.begin, !0),
  909. pos.end = seekNext(pos.begin, !0), pos.end < getMaskLength() && pos.end--), pos.begin < getMaskLength() && (e.preventDefault(),
  910. caret(input, pos.begin, pos.end))) : opts.insertMode !== !1 || e.shiftKey || (k === Inputmask.keyCode.RIGHT ? setTimeout(function() {
  911. var caretPos = caret(input);
  912. caret(input, caretPos.begin);
  913. }, 0) : k === Inputmask.keyCode.LEFT && setTimeout(function() {
  914. var caretPos = caret(input);
  915. caret(input, isRTL ? caretPos.begin + 1 : caretPos.begin - 1);
  916. }, 0)) : (opts.insertMode = !opts.insertMode, caret(input, opts.insertMode || pos.begin !== getMaskLength() ? pos.begin : pos.begin - 1));
  917. opts.onKeyDown.call(this, e, getBuffer(), caret(input).begin, opts), ignorable = -1 !== $.inArray(k, opts.ignorables);
  918. }
  919. function keypressEvent(e, checkval, writeOut, strict, ndx) {
  920. var input = this, $input = $(input), k = e.which || e.charCode || e.keyCode;
  921. if (!(checkval === !0 || e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable)) return k === Inputmask.keyCode.ENTER && undoValue !== getBuffer().join("") && (undoValue = getBuffer().join(""),
  922. setTimeout(function() {
  923. $input.trigger("change");
  924. }, 0)), !0;
  925. if (k) {
  926. 46 === k && e.shiftKey === !1 && "," === opts.radixPoint && (k = 44);
  927. var forwardPosition, pos = checkval ? {
  928. begin: ndx,
  929. end: ndx
  930. } : caret(input), c = String.fromCharCode(k), isSlctn = isSelection(pos.begin, pos.end);
  931. isSlctn && (getMaskSet().undoPositions = $.extend(!0, {}, getMaskSet().validPositions),
  932. handleRemove(input, Inputmask.keyCode.DELETE, pos, !0), pos.begin = getMaskSet().p,
  933. opts.insertMode || (opts.insertMode = !opts.insertMode, setValidPosition(pos.begin, strict),
  934. opts.insertMode = !opts.insertMode), isSlctn = !opts.multi), getMaskSet().writeOutBuffer = !0;
  935. var p = isRTL && !isSlctn ? pos.end : pos.begin, valResult = isValid(p, c, strict);
  936. if (valResult !== !1) {
  937. if (valResult !== !0 && (p = void 0 !== valResult.pos ? valResult.pos : p, c = void 0 !== valResult.c ? valResult.c : c),
  938. resetMaskSet(!0), void 0 !== valResult.caret) forwardPosition = valResult.caret; else {
  939. var vps = getMaskSet().validPositions;
  940. 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);
  941. }
  942. getMaskSet().p = forwardPosition;
  943. }
  944. if (writeOut !== !1) {
  945. var self = this;
  946. if (setTimeout(function() {
  947. opts.onKeyValidation.call(self, k, valResult, opts);
  948. }, 0), getMaskSet().writeOutBuffer && valResult !== !1) {
  949. var buffer = getBuffer();
  950. writeBuffer(input, buffer, opts.numericInput && void 0 === valResult.caret ? seekPrevious(forwardPosition) : forwardPosition, e, checkval !== !0),
  951. checkval !== !0 && setTimeout(function() {
  952. isComplete(buffer) === !0 && $input.trigger("complete");
  953. }, 0);
  954. } else isSlctn && (getMaskSet().buffer = void 0, getMaskSet().validPositions = getMaskSet().undoPositions);
  955. } else isSlctn && (getMaskSet().buffer = void 0, getMaskSet().validPositions = getMaskSet().undoPositions);
  956. if (opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask), checkval && $.isFunction(opts.onBeforeWrite)) {
  957. var result = opts.onBeforeWrite(e, getBuffer(), forwardPosition, opts);
  958. if (result && result.refreshFromBuffer) {
  959. var refresh = result.refreshFromBuffer;
  960. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, result.buffer),
  961. resetMaskSet(!0), result.caret && (getMaskSet().p = result.caret);
  962. }
  963. }
  964. if (e.preventDefault(), checkval) return valResult;
  965. }
  966. }
  967. function pasteEvent(e) {
  968. 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);
  969. valueBeforeCaret === getBufferTemplate().slice(0, caretPos.begin).join("") && (valueBeforeCaret = ""),
  970. valueAfterCaret === getBufferTemplate().slice(caretPos.end).join("") && (valueAfterCaret = ""),
  971. 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);
  972. var pasteValue = inputValue;
  973. if ($.isFunction(opts.onBeforePaste)) {
  974. if (pasteValue = opts.onBeforePaste(inputValue, opts), pasteValue === !1) return e.preventDefault(),
  975. !1;
  976. pasteValue || (pasteValue = inputValue);
  977. }
  978. return checkVal(input, !1, !1, isRTL ? pasteValue.split("").reverse() : pasteValue.toString().split("")),
  979. writeBuffer(input, getBuffer(), void 0, e, !0), $input.trigger("click"), isComplete(getBuffer()) === !0 && $input.trigger("complete"),
  980. !1;
  981. }
  982. function inputFallBackEvent(e) {
  983. var input = this, inputValue = input.inputmask._valueGet();
  984. if (getBuffer().join("") !== inputValue) {
  985. var caretPos = caret(input);
  986. if (inputValue = inputValue.replace(new RegExp("(" + Inputmask.escapeRegex(getBufferTemplate().join("")) + ")*"), ""),
  987. iemobile) {
  988. var inputChar = inputValue.replace(getBuffer().join(""), "");
  989. if (1 === inputChar.length) {
  990. var keypress = new $.Event("keypress");
  991. return keypress.which = inputChar.charCodeAt(0), keypressEvent.call(input, keypress, !0, !0, !1, getMaskSet().validPositions[caretPos.begin - 1] ? caretPos.begin : caretPos.begin - 1),
  992. !1;
  993. }
  994. }
  995. if (caretPos.begin > inputValue.length && (caret(input, inputValue.length), caretPos = caret(input)),
  996. getBuffer().length - inputValue.length !== 1 || inputValue.charAt(caretPos.begin) === getBuffer()[caretPos.begin] || inputValue.charAt(caretPos.begin + 1) === getBuffer()[caretPos.begin] || isMask(caretPos.begin)) {
  997. for (var lvp = getLastValidPosition() + 1, bufferTemplate = getBuffer().slice(lvp).join(""); null === inputValue.match(Inputmask.escapeRegex(bufferTemplate) + "$"); ) bufferTemplate = bufferTemplate.slice(1);
  998. inputValue = inputValue.replace(bufferTemplate, ""), inputValue = inputValue.split(""),
  999. checkVal(input, !0, !1, inputValue), isComplete(getBuffer()) === !0 && $(input).trigger("complete");
  1000. } else e.keyCode = Inputmask.keyCode.BACKSPACE, keydownEvent.call(input, e);
  1001. e.preventDefault();
  1002. }
  1003. }
  1004. function compositionStartEvent(e) {
  1005. var ev = e.originalEvent || e;
  1006. undoValue = getBuffer().join(""), "" === compositionData || 0 !== ev.data.indexOf(compositionData);
  1007. }
  1008. function compositionUpdateEvent(e) {
  1009. var input = this, ev = e.originalEvent || e, inputBuffer = getBuffer().join("");
  1010. 0 === ev.data.indexOf(compositionData) && (resetMaskSet(), getMaskSet().p = seekNext(-1));
  1011. for (var newData = ev.data, i = 0; i < newData.length; i++) {
  1012. var keypress = new $.Event("keypress");
  1013. keypress.which = newData.charCodeAt(i), skipKeyPressEvent = !1, ignorable = !1,
  1014. keypressEvent.call(input, keypress, !0, !1, !1, getMaskSet().p);
  1015. }
  1016. inputBuffer !== getBuffer().join("") && setTimeout(function() {
  1017. var forwardPosition = getMaskSet().p;
  1018. writeBuffer(input, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
  1019. }, 0), compositionData = ev.data;
  1020. }
  1021. function compositionEndEvent(e) {}
  1022. function setValueEvent(e) {
  1023. var input = this, value = input.inputmask._valueGet();
  1024. checkVal(input, !0, !1, ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(value, opts) || value : value).split("")),
  1025. undoValue = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() === getBufferTemplate().join("") && input.inputmask._valueSet("");
  1026. }
  1027. function focusEvent(e) {
  1028. var input = this, nptValue = input.inputmask._valueGet();
  1029. opts.showMaskOnFocus && (!opts.showMaskOnHover || opts.showMaskOnHover && "" === nptValue) ? input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer(), seekNext(getLastValidPosition())) : mouseEnter === !1 && caret(input, seekNext(getLastValidPosition())),
  1030. opts.positionCaretOnTab === !0 && setTimeout(function() {
  1031. caret(input, seekNext(getLastValidPosition()));
  1032. }, 0), undoValue = getBuffer().join("");
  1033. }
  1034. function mouseleaveEvent(e) {
  1035. var input = this;
  1036. if (mouseEnter = !1, opts.clearMaskOnLostFocus && document.activeElement !== input) {
  1037. var buffer = getBuffer().slice(), nptValue = input.inputmask._valueGet();
  1038. nptValue !== input.getAttribute("placeholder") && "" !== nptValue && (-1 === getLastValidPosition() && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer),
  1039. writeBuffer(input, buffer));
  1040. }
  1041. }
  1042. function clickEvent(e) {
  1043. function doRadixFocus(clickPos) {
  1044. if (opts.radixFocus && "" !== opts.radixPoint) {
  1045. var vps = getMaskSet().validPositions;
  1046. if (void 0 === vps[clickPos] || vps[clickPos].input === getPlaceholder(clickPos)) {
  1047. if (clickPos < seekNext(-1)) return !0;
  1048. var radixPos = $.inArray(opts.radixPoint, getBuffer());
  1049. if (-1 !== radixPos) {
  1050. for (var vp in vps) if (vp > radixPos && vps[vp].input !== getPlaceholder(vp)) return !1;
  1051. return !0;
  1052. }
  1053. }
  1054. }
  1055. return !1;
  1056. }
  1057. var input = this;
  1058. if (document.activeElement === input) {
  1059. var selectedCaret = caret(input);
  1060. if (selectedCaret.begin === selectedCaret.end) if (doRadixFocus(selectedCaret.begin)) caret(input, opts.numericInput ? seekNext($.inArray(opts.radixPoint, getBuffer())) : $.inArray(opts.radixPoint, getBuffer())); else {
  1061. var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition), lastPosition = seekNext(lvclickPosition);
  1062. 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)),
  1063. caret(input, lastPosition));
  1064. }
  1065. }
  1066. }
  1067. function dblclickEvent(e) {
  1068. var input = this;
  1069. setTimeout(function() {
  1070. caret(input, 0, seekNext(getLastValidPosition()));
  1071. }, 0);
  1072. }
  1073. function cutEvent(e) {
  1074. 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);
  1075. clipboardData.setData("text", isRTL ? clipData.reverse().join("") : clipData.join("")),
  1076. document.execCommand && document.execCommand("copy"), handleRemove(input, Inputmask.keyCode.DELETE, pos),
  1077. writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")),
  1078. input.inputmask._valueGet() === getBufferTemplate().join("") && $input.trigger("cleared"),
  1079. opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask);
  1080. }
  1081. function blurEvent(e) {
  1082. var $input = $(this), input = this;
  1083. if (input.inputmask) {
  1084. var nptValue = input.inputmask._valueGet(), buffer = getBuffer().slice();
  1085. undoValue !== buffer.join("") && setTimeout(function() {
  1086. $input.trigger("change"), undoValue = buffer.join("");
  1087. }, 0), "" !== nptValue && (opts.clearMaskOnLostFocus && (-1 === getLastValidPosition() && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
  1088. isComplete(buffer) === !1 && (setTimeout(function() {
  1089. $input.trigger("incomplete");
  1090. }, 0), opts.clearIncomplete && (resetMaskSet(), buffer = opts.clearMaskOnLostFocus ? [] : getBufferTemplate().slice())),
  1091. writeBuffer(input, buffer, void 0, e));
  1092. }
  1093. }
  1094. function mouseenterEvent(e) {
  1095. var input = this;
  1096. mouseEnter = !0, document.activeElement !== input && opts.showMaskOnHover && input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer());
  1097. }
  1098. function submitEvent(e) {
  1099. undoValue !== getBuffer().join("") && $el.trigger("change"), opts.clearMaskOnLostFocus && -1 === getLastValidPosition() && el.inputmask._valueGet && el.inputmask._valueGet() === getBufferTemplate().join("") && el.inputmask._valueSet(""),
  1100. opts.removeMaskOnSubmit && (el.inputmask._valueSet(el.inputmask.unmaskedvalue(), !0),
  1101. setTimeout(function() {
  1102. writeBuffer(el, getBuffer());
  1103. }, 0));
  1104. }
  1105. function resetEvent(e) {
  1106. setTimeout(function() {
  1107. $el.trigger("setvalue");
  1108. }, 0);
  1109. }
  1110. function mask(elem) {
  1111. if (el = elem, $el = $(el), opts.showTooltip && (el.title = opts.tooltip || getMaskSet().mask),
  1112. ("rtl" === el.dir || opts.rightAlign) && (el.style.textAlign = "right"), ("rtl" === el.dir || opts.numericInput) && (el.dir = "ltr",
  1113. el.removeAttribute("dir"), el.inputmask.isRTL = !0, isRTL = !0), EventRuler.off(el),
  1114. patchValueProperty(el), isElementTypeSupported(el, opts) && (EventRuler.on(el, "submit", submitEvent),
  1115. EventRuler.on(el, "reset", resetEvent), EventRuler.on(el, "mouseenter", mouseenterEvent),
  1116. EventRuler.on(el, "blur", blurEvent), EventRuler.on(el, "focus", focusEvent), EventRuler.on(el, "mouseleave", mouseleaveEvent),
  1117. EventRuler.on(el, "click", clickEvent), EventRuler.on(el, "dblclick", dblclickEvent),
  1118. EventRuler.on(el, "paste", pasteEvent), EventRuler.on(el, "dragdrop", pasteEvent),
  1119. EventRuler.on(el, "drop", pasteEvent), EventRuler.on(el, "cut", cutEvent), EventRuler.on(el, "complete", opts.oncomplete),
  1120. EventRuler.on(el, "incomplete", opts.onincomplete), EventRuler.on(el, "cleared", opts.oncleared),
  1121. EventRuler.on(el, "keydown", keydownEvent), EventRuler.on(el, "keypress", keypressEvent),
  1122. EventRuler.on(el, "input", inputFallBackEvent), mobile || (EventRuler.on(el, "compositionstart", compositionStartEvent),
  1123. EventRuler.on(el, "compositionupdate", compositionUpdateEvent), EventRuler.on(el, "compositionend", compositionEndEvent))),
  1124. EventRuler.on(el, "setvalue", setValueEvent), "" !== el.inputmask._valueGet() || opts.clearMaskOnLostFocus === !1) {
  1125. var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(el.inputmask._valueGet(), opts) || el.inputmask._valueGet() : el.inputmask._valueGet();
  1126. checkVal(el, !0, !1, initialValue.split(""));
  1127. var buffer = getBuffer().slice();
  1128. undoValue = buffer.join(""), isComplete(buffer) === !1 && opts.clearIncomplete && resetMaskSet(),
  1129. opts.clearMaskOnLostFocus && (buffer.join("") === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
  1130. writeBuffer(el, buffer), document.activeElement === el && caret(el, seekNext(getLastValidPosition()));
  1131. }
  1132. }
  1133. var undoValue, compositionData, el, $el, maxLength, valueBuffer, isRTL = !1, skipKeyPressEvent = !1, skipInputEvent = !1, ignorable = !1, mouseEnter = !0, inComposition = !1, EventRuler = {
  1134. on: function(input, eventName, eventHandler) {
  1135. var ev = function(e) {
  1136. if (void 0 === this.inputmask && "FORM" !== this.nodeName) {
  1137. var imOpts = $.data(this, "_inputmask_opts");
  1138. imOpts ? new Inputmask(imOpts).mask(this) : EventRuler.off(this);
  1139. } else {
  1140. if ("setvalue" === e.type || !(this.disabled || this.readOnly && !("keydown" === e.type && e.ctrlKey && 67 === e.keyCode || opts.tabThrough === !1 && e.keyCode === Inputmask.keyCode.TAB))) {
  1141. switch (e.type) {
  1142. case "input":
  1143. if (skipInputEvent === !0 || inComposition === !0) return skipInputEvent = inComposition,
  1144. e.preventDefault();
  1145. break;
  1146. case "keydown":
  1147. skipKeyPressEvent = !1, skipInputEvent = !1, inComposition = !1;
  1148. break;
  1149. case "keypress":
  1150. if (skipKeyPressEvent === !0) return e.preventDefault();
  1151. skipKeyPressEvent = !0;
  1152. break;
  1153. case "compositionstart":
  1154. inComposition = !0;
  1155. break;
  1156. case "compositionupdate":
  1157. skipInputEvent = !0;
  1158. break;
  1159. case "compositionend":
  1160. inComposition = !1;
  1161. break;
  1162. case "cut":
  1163. skipInputEvent = !0;
  1164. break;
  1165. case "click":
  1166. if (iemobile) {
  1167. var that = this;
  1168. return setTimeout(function() {
  1169. eventHandler.apply(that, arguments);
  1170. }, 0), !1;
  1171. }
  1172. }
  1173. return eventHandler.apply(this, arguments);
  1174. }
  1175. e.preventDefault();
  1176. }
  1177. };
  1178. input.inputmask.events[eventName] = input.inputmask.events[eventName] || [], input.inputmask.events[eventName].push(ev),
  1179. -1 !== $.inArray(eventName, [ "submit", "reset" ]) ? null != input.form && $(input.form).on(eventName, ev) : $(input).on(eventName, ev);
  1180. },
  1181. off: function(input, event) {
  1182. if (input.inputmask && input.inputmask.events) {
  1183. var events;
  1184. event ? (events = [], events[event] = input.inputmask.events[event]) : events = input.inputmask.events,
  1185. $.each(events, function(eventName, evArr) {
  1186. for (;evArr.length > 0; ) {
  1187. var ev = evArr.pop();
  1188. -1 !== $.inArray(eventName, [ "submit", "reset" ]) ? null != input.form && $(input.form).off(eventName, ev) : $(input).off(eventName, ev);
  1189. }
  1190. delete input.inputmask.events[eventName];
  1191. });
  1192. }
  1193. }
  1194. };
  1195. if (void 0 !== actionObj) switch (actionObj.action) {
  1196. case "isComplete":
  1197. return el = actionObj.el, isComplete(getBuffer());
  1198. case "unmaskedvalue":
  1199. return el = actionObj.el, void 0 !== el && void 0 !== el.inputmask ? (maskset = el.inputmask.maskset,
  1200. opts = el.inputmask.opts, isRTL = el.inputmask.isRTL) : (valueBuffer = actionObj.value,
  1201. opts.numericInput && (isRTL = !0), valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(valueBuffer, opts) || valueBuffer : valueBuffer).split(""),
  1202. checkVal(void 0, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite(void 0, getBuffer(), 0, opts)),
  1203. unmaskedvalue(el);
  1204. case "mask":
  1205. el = actionObj.el, maskset = el.inputmask.maskset, opts = el.inputmask.opts, isRTL = el.inputmask.isRTL,
  1206. undoValue = getBuffer().join(""), mask(el);
  1207. break;
  1208. case "format":
  1209. return opts.numericInput && (isRTL = !0), valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(actionObj.value, opts) || actionObj.value : actionObj.value).split(""),
  1210. checkVal(void 0, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite(void 0, getBuffer(), 0, opts),
  1211. actionObj.metadata ? {
  1212. value: isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join(""),
  1213. metadata: maskScope({
  1214. action: "getmetadata"
  1215. }, maskset, opts)
  1216. } : isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join("");
  1217. case "isValid":
  1218. opts.numericInput && (isRTL = !0), actionObj.value ? (valueBuffer = actionObj.value.split(""),
  1219. checkVal(void 0, !1, !0, isRTL ? valueBuffer.reverse() : valueBuffer)) : actionObj.value = getBuffer().join("");
  1220. for (var buffer = getBuffer(), rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
  1221. return buffer.splice(rl, lmib + 1 - rl), isComplete(buffer) && actionObj.value === getBuffer().join("");
  1222. case "getemptymask":
  1223. return getBufferTemplate();
  1224. case "remove":
  1225. el = actionObj.el, $el = $(el), maskset = el.inputmask.maskset, opts = el.inputmask.opts,
  1226. el.inputmask._valueSet(unmaskedvalue(el)), EventRuler.off(el);
  1227. var valueProperty;
  1228. Object.getOwnPropertyDescriptor && (valueProperty = Object.getOwnPropertyDescriptor(el, "value")),
  1229. valueProperty && valueProperty.get ? el.inputmask.__valueGet && Object.defineProperty(el, "value", {
  1230. get: el.inputmask.__valueGet,
  1231. set: el.inputmask.__valueSet
  1232. }) : document.__lookupGetter__ && el.__lookupGetter__("value") && el.inputmask.__valueGet && (el.__defineGetter__("value", el.inputmask.__valueGet),
  1233. el.__defineSetter__("value", el.inputmask.__valueSet)), el.inputmask = void 0;
  1234. break;
  1235. case "getmetadata":
  1236. if ($.isArray(maskset.metadata)) {
  1237. for (var alternation, lvp = getLastValidPosition(), firstAlt = lvp; firstAlt >= 0; firstAlt--) if (getMaskSet().validPositions[firstAlt] && void 0 !== getMaskSet().validPositions[firstAlt].alternation) {
  1238. alternation = getMaskSet().validPositions[firstAlt].alternation;
  1239. break;
  1240. }
  1241. return void 0 !== alternation ? maskset.metadata[getMaskSet().validPositions[lvp].locator[alternation]] : maskset.metadata[0];
  1242. }
  1243. return maskset.metadata;
  1244. }
  1245. }
  1246. Inputmask.prototype = {
  1247. defaults: {
  1248. placeholder: "_",
  1249. optionalmarker: {
  1250. start: "[",
  1251. end: "]"
  1252. },
  1253. quantifiermarker: {
  1254. start: "{",
  1255. end: "}"
  1256. },
  1257. groupmarker: {
  1258. start: "(",
  1259. end: ")"
  1260. },
  1261. alternatormarker: "|",
  1262. escapeChar: "\\",
  1263. mask: null,
  1264. oncomplete: $.noop,
  1265. onincomplete: $.noop,
  1266. oncleared: $.noop,
  1267. repeat: 0,
  1268. greedy: !0,
  1269. autoUnmask: !1,
  1270. removeMaskOnSubmit: !1,
  1271. clearMaskOnLostFocus: !0,
  1272. insertMode: !0,
  1273. clearIncomplete: !1,
  1274. aliases: {},
  1275. alias: null,
  1276. onKeyDown: $.noop,
  1277. onBeforeMask: null,
  1278. onBeforePaste: function(pastedValue, opts) {
  1279. return $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(pastedValue, opts) : pastedValue;
  1280. },
  1281. onBeforeWrite: null,
  1282. onUnMask: null,
  1283. showMaskOnFocus: !0,
  1284. showMaskOnHover: !0,
  1285. onKeyValidation: $.noop,
  1286. skipOptionalPartCharacter: " ",
  1287. showTooltip: !1,
  1288. tooltip: void 0,
  1289. numericInput: !1,
  1290. rightAlign: !1,
  1291. undoOnEscape: !0,
  1292. radixPoint: "",
  1293. groupSeparator: "",
  1294. radixFocus: !1,
  1295. nojumps: !1,
  1296. nojumpsThreshold: 0,
  1297. keepStatic: null,
  1298. positionCaretOnTab: !1,
  1299. tabThrough: !1,
  1300. supportsInputType: [ "text", "tel", "password" ],
  1301. definitions: {
  1302. "9": {
  1303. validator: "[0-9]",
  1304. cardinality: 1,
  1305. definitionSymbol: "*"
  1306. },
  1307. a: {
  1308. validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  1309. cardinality: 1,
  1310. definitionSymbol: "*"
  1311. },
  1312. "*": {
  1313. validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  1314. cardinality: 1
  1315. }
  1316. },
  1317. 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 ],
  1318. isComplete: null,
  1319. canClearPosition: $.noop,
  1320. postValidation: null,
  1321. staticDefinitionSymbol: void 0,
  1322. jitMasking: !1
  1323. },
  1324. masksCache: {},
  1325. mask: function(elems) {
  1326. var that = this;
  1327. return "string" == typeof elems && (elems = document.getElementById(elems) || document.querySelectorAll(elems)),
  1328. elems = elems.nodeName ? [ elems ] : elems, $.each(elems, function(ndx, el) {
  1329. var scopedOpts = $.extend(!0, {}, that.opts);
  1330. importAttributeOptions(el, scopedOpts, $.extend(!0, {}, that.userOptions));
  1331. var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
  1332. void 0 !== maskset && (void 0 !== el.inputmask && el.inputmask.remove(), el.inputmask = new Inputmask(),
  1333. el.inputmask.opts = scopedOpts, el.inputmask.noMasksCache = that.noMasksCache, el.inputmask.userOptions = $.extend(!0, {}, that.userOptions),
  1334. el.inputmask.el = el, el.inputmask.maskset = maskset, el.inputmask.isRTL = !1, $.data(el, "_inputmask_opts", scopedOpts),
  1335. maskScope({
  1336. action: "mask",
  1337. el: el
  1338. }));
  1339. }), elems && elems[0] ? elems[0].inputmask || this : this;
  1340. },
  1341. option: function(options) {
  1342. return "string" == typeof options ? this.opts[options] : "object" == typeof options ? ($.extend(this.opts, options),
  1343. $.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),
  1344. maskScope({
  1345. action: "mask",
  1346. el: this.el
  1347. }))), this) : void 0;
  1348. },
  1349. unmaskedvalue: function(value) {
  1350. return maskScope({
  1351. action: "unmaskedvalue",
  1352. el: this.el,
  1353. value: value
  1354. }, this.el && this.el.inputmask ? this.el.inputmask.maskset : generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1355. },
  1356. remove: function() {
  1357. return this.el ? (maskScope({
  1358. action: "remove",
  1359. el: this.el
  1360. }), this.el.inputmask = void 0, this.el) : void 0;
  1361. },
  1362. getemptymask: function() {
  1363. return maskScope({
  1364. action: "getemptymask"
  1365. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1366. },
  1367. hasMaskedValue: function() {
  1368. return !this.opts.autoUnmask;
  1369. },
  1370. isComplete: function() {
  1371. return maskScope({
  1372. action: "isComplete",
  1373. el: this.el
  1374. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1375. },
  1376. getmetadata: function() {
  1377. return maskScope({
  1378. action: "getmetadata"
  1379. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1380. },
  1381. isValid: function(value) {
  1382. return maskScope({
  1383. action: "isValid",
  1384. value: value
  1385. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1386. },
  1387. format: function(value, metadata) {
  1388. return maskScope({
  1389. action: "format",
  1390. value: value,
  1391. metadata: metadata
  1392. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1393. }
  1394. }, Inputmask.extendDefaults = function(options) {
  1395. $.extend(!0, Inputmask.prototype.defaults, options);
  1396. }, Inputmask.extendDefinitions = function(definition) {
  1397. $.extend(!0, Inputmask.prototype.defaults.definitions, definition);
  1398. }, Inputmask.extendAliases = function(alias) {
  1399. $.extend(!0, Inputmask.prototype.defaults.aliases, alias);
  1400. }, Inputmask.format = function(value, options, metadata) {
  1401. return Inputmask(options).format(value, metadata);
  1402. }, Inputmask.unmask = function(value, options) {
  1403. return Inputmask(options).unmaskedvalue(value);
  1404. }, Inputmask.isValid = function(value, options) {
  1405. return Inputmask(options).isValid(value);
  1406. }, Inputmask.remove = function(elems) {
  1407. $.each(elems, function(ndx, el) {
  1408. el.inputmask && el.inputmask.remove();
  1409. });
  1410. }, Inputmask.escapeRegex = function(str) {
  1411. var specials = [ "/", ".", "*", "+", "?", "|", "(", ")", "[", "]", "{", "}", "\\", "$", "^" ];
  1412. return str.replace(new RegExp("(\\" + specials.join("|\\") + ")", "gim"), "\\$1");
  1413. }, Inputmask.keyCode = {
  1414. ALT: 18,
  1415. BACKSPACE: 8,
  1416. CAPS_LOCK: 20,
  1417. COMMA: 188,
  1418. COMMAND: 91,
  1419. COMMAND_LEFT: 91,
  1420. COMMAND_RIGHT: 93,
  1421. CONTROL: 17,
  1422. DELETE: 46,
  1423. DOWN: 40,
  1424. END: 35,
  1425. ENTER: 13,
  1426. ESCAPE: 27,
  1427. HOME: 36,
  1428. INSERT: 45,
  1429. LEFT: 37,
  1430. MENU: 93,
  1431. NUMPAD_ADD: 107,
  1432. NUMPAD_DECIMAL: 110,
  1433. NUMPAD_DIVIDE: 111,
  1434. NUMPAD_ENTER: 108,
  1435. NUMPAD_MULTIPLY: 106,
  1436. NUMPAD_SUBTRACT: 109,
  1437. PAGE_DOWN: 34,
  1438. PAGE_UP: 33,
  1439. PERIOD: 190,
  1440. RIGHT: 39,
  1441. SHIFT: 16,
  1442. SPACE: 32,
  1443. TAB: 9,
  1444. UP: 38,
  1445. WINDOWS: 91
  1446. };
  1447. var ua = navigator.userAgent, mobile = /mobile/i.test(ua), iemobile = /iemobile/i.test(ua), iphone = /iphone/i.test(ua) && !iemobile;
  1448. /android.*safari.*/i.test(ua) && !iemobile;
  1449. return window.Inputmask = Inputmask, Inputmask;
  1450. });