You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1277 lines
81KB

  1. /*!
  2. * jquery.inputmask.js
  3. * http://github.com/RobinHerbots/jquery.inputmask
  4. * Copyright (c) 2010 - 2015 Robin Herbots
  5. * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
  6. * Version: 3.1.61
  7. */
  8. !function(factory) {
  9. "function" == typeof define && define.amd ? define([ "jquery" ], factory) : factory(jQuery);
  10. }(function($) {
  11. function isInputEventSupported(eventName) {
  12. var el = document.createElement("input"), evName = "on" + eventName, isSupported = evName in el;
  13. return isSupported || (el.setAttribute(evName, "return;"), isSupported = "function" == typeof el[evName]),
  14. el = null, isSupported;
  15. }
  16. function isInputTypeSupported(inputType) {
  17. var isSupported = "text" == inputType || "tel" == inputType;
  18. if (!isSupported) {
  19. var el = document.createElement("input");
  20. el.setAttribute("type", inputType), isSupported = "text" === el.type, el = null;
  21. }
  22. return isSupported;
  23. }
  24. function resolveAlias(aliasStr, options, opts) {
  25. var aliasDefinition = opts.aliases[aliasStr];
  26. return aliasDefinition ? (aliasDefinition.alias && resolveAlias(aliasDefinition.alias, void 0, opts),
  27. $.extend(!0, opts, aliasDefinition), $.extend(!0, opts, options), !0) : !1;
  28. }
  29. function generateMaskSet(opts) {
  30. function analyseMask(mask) {
  31. function maskToken(isGroup, isOptional, isQuantifier, isAlternator) {
  32. this.matches = [], this.isGroup = isGroup || !1, this.isOptional = isOptional || !1,
  33. this.isQuantifier = isQuantifier || !1, this.isAlternator = isAlternator || !1,
  34. this.quantifier = {
  35. min: 1,
  36. max: 1
  37. };
  38. }
  39. function insertTestDefinition(mtoken, element, position) {
  40. var maskdef = opts.definitions[element], newBlockMarker = 0 == mtoken.matches.length;
  41. if (position = void 0 != position ? position : mtoken.matches.length, maskdef && !escaped) {
  42. maskdef.placeholder = $.isFunction(maskdef.placeholder) ? maskdef.placeholder.call(this, opts) : maskdef.placeholder;
  43. for (var prevalidators = maskdef.prevalidator, prevalidatorsL = prevalidators ? prevalidators.length : 0, i = 1; i < maskdef.cardinality; i++) {
  44. var prevalidator = prevalidatorsL >= i ? prevalidators[i - 1] : [], validator = prevalidator.validator, cardinality = prevalidator.cardinality;
  45. mtoken.matches.splice(position++, 0, {
  46. fn: validator ? "string" == typeof validator ? new RegExp(validator) : new function() {
  47. this.test = validator;
  48. }() : new RegExp("."),
  49. cardinality: cardinality ? cardinality : 1,
  50. optionality: mtoken.isOptional,
  51. newBlockMarker: newBlockMarker,
  52. casing: maskdef.casing,
  53. def: maskdef.definitionSymbol || element,
  54. placeholder: maskdef.placeholder,
  55. mask: element
  56. });
  57. }
  58. mtoken.matches.splice(position++, 0, {
  59. fn: maskdef.validator ? "string" == typeof maskdef.validator ? new RegExp(maskdef.validator) : new function() {
  60. this.test = maskdef.validator;
  61. }() : new RegExp("."),
  62. cardinality: maskdef.cardinality,
  63. optionality: mtoken.isOptional,
  64. newBlockMarker: newBlockMarker,
  65. casing: maskdef.casing,
  66. def: maskdef.definitionSymbol || element,
  67. placeholder: maskdef.placeholder,
  68. mask: element
  69. });
  70. } else mtoken.matches.splice(position++, 0, {
  71. fn: null,
  72. cardinality: 0,
  73. optionality: mtoken.isOptional,
  74. newBlockMarker: newBlockMarker,
  75. casing: null,
  76. def: element,
  77. placeholder: void 0,
  78. mask: element
  79. }), escaped = !1;
  80. }
  81. for (var match, m, openingToken, currentOpeningToken, alternator, lastMatch, tokenizer = /(?:[?*+]|\{[0-9\+\*]+(?:,[0-9\+\*]*)?\})\??|[^.?*+^${[]()|\\]+|./g, escaped = !1, currentToken = new maskToken(), openenings = [], maskTokens = []; match = tokenizer.exec(mask); ) switch (m = match[0],
  82. m.charAt(0)) {
  83. case opts.optionalmarker.end:
  84. case opts.groupmarker.end:
  85. if (openingToken = openenings.pop(), openenings.length > 0) {
  86. if (currentOpeningToken = openenings[openenings.length - 1], currentOpeningToken.matches.push(openingToken),
  87. currentOpeningToken.isAlternator) {
  88. alternator = openenings.pop();
  89. for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
  90. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  91. currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
  92. }
  93. } else currentToken.matches.push(openingToken);
  94. break;
  95. case opts.optionalmarker.start:
  96. openenings.push(new maskToken(!1, !0));
  97. break;
  98. case opts.groupmarker.start:
  99. openenings.push(new maskToken(!0));
  100. break;
  101. case opts.quantifiermarker.start:
  102. var quantifier = new maskToken(!1, !1, !0);
  103. m = m.replace(/[{}]/g, "");
  104. 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]);
  105. if (("*" == mq1 || "+" == mq1) && (mq0 = "*" == mq1 ? 0 : 1), quantifier.quantifier = {
  106. min: mq0,
  107. max: mq1
  108. }, openenings.length > 0) {
  109. var matches = openenings[openenings.length - 1].matches;
  110. if (match = matches.pop(), !match.isGroup) {
  111. var groupToken = new maskToken(!0);
  112. groupToken.matches.push(match), match = groupToken;
  113. }
  114. matches.push(match), matches.push(quantifier);
  115. } else {
  116. if (match = currentToken.matches.pop(), !match.isGroup) {
  117. var groupToken = new maskToken(!0);
  118. groupToken.matches.push(match), match = groupToken;
  119. }
  120. currentToken.matches.push(match), currentToken.matches.push(quantifier);
  121. }
  122. break;
  123. case opts.escapeChar:
  124. escaped = !0;
  125. break;
  126. case opts.alternatormarker:
  127. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  128. lastMatch = currentOpeningToken.matches.pop()) : lastMatch = currentToken.matches.pop(),
  129. lastMatch.isAlternator ? openenings.push(lastMatch) : (alternator = new maskToken(!1, !1, !1, !0),
  130. alternator.matches.push(lastMatch), openenings.push(alternator));
  131. break;
  132. default:
  133. if (openenings.length > 0) {
  134. if (currentOpeningToken = openenings[openenings.length - 1], currentOpeningToken.matches.length > 0 && (lastMatch = currentOpeningToken.matches[currentOpeningToken.matches.length - 1],
  135. lastMatch.isGroup && (lastMatch.isGroup = !1, insertTestDefinition(lastMatch, opts.groupmarker.start, 0),
  136. insertTestDefinition(lastMatch, opts.groupmarker.end))), insertTestDefinition(currentOpeningToken, m),
  137. currentOpeningToken.isAlternator) {
  138. alternator = openenings.pop();
  139. for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
  140. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  141. currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
  142. }
  143. } else currentToken.matches.length > 0 && (lastMatch = currentToken.matches[currentToken.matches.length - 1],
  144. lastMatch.isGroup && (lastMatch.isGroup = !1, insertTestDefinition(lastMatch, opts.groupmarker.start, 0),
  145. insertTestDefinition(lastMatch, opts.groupmarker.end))), insertTestDefinition(currentToken, m);
  146. }
  147. return currentToken.matches.length > 0 && (lastMatch = currentToken.matches[currentToken.matches.length - 1],
  148. lastMatch.isGroup && (lastMatch.isGroup = !1, insertTestDefinition(lastMatch, opts.groupmarker.start, 0),
  149. insertTestDefinition(lastMatch, opts.groupmarker.end)), maskTokens.push(currentToken)),
  150. maskTokens;
  151. }
  152. function generateMask(mask, metadata) {
  153. if (void 0 == mask || "" == mask) return void 0;
  154. if (1 == mask.length && 0 == opts.greedy && 0 != opts.repeat && (opts.placeholder = ""),
  155. opts.repeat > 0 || "*" == opts.repeat || "+" == opts.repeat) {
  156. var repeatStart = "*" == opts.repeat ? 0 : "+" == opts.repeat ? 1 : opts.repeat;
  157. mask = opts.groupmarker.start + mask + opts.groupmarker.end + opts.quantifiermarker.start + repeatStart + "," + opts.repeat + opts.quantifiermarker.end;
  158. }
  159. return void 0 == $.inputmask.masksCache[mask] && ($.inputmask.masksCache[mask] = {
  160. mask: mask,
  161. maskToken: analyseMask(mask),
  162. validPositions: {},
  163. _buffer: void 0,
  164. buffer: void 0,
  165. tests: {},
  166. metadata: metadata
  167. }), $.extend(!0, {}, $.inputmask.masksCache[mask]);
  168. }
  169. function preProcessMask(mask) {
  170. if (mask = mask.toString(), opts.numericInput) {
  171. mask = mask.split("").reverse();
  172. for (var ndx = 0; ndx < mask.length; ndx++) mask[ndx] == opts.optionalmarker.start ? mask[ndx] = opts.optionalmarker.end : mask[ndx] == opts.optionalmarker.end ? mask[ndx] = opts.optionalmarker.start : mask[ndx] == opts.groupmarker.start ? mask[ndx] = opts.groupmarker.end : mask[ndx] == opts.groupmarker.end && (mask[ndx] = opts.groupmarker.start);
  173. mask = mask.join("");
  174. }
  175. return mask;
  176. }
  177. var ms = void 0;
  178. if ($.isFunction(opts.mask) && (opts.mask = opts.mask.call(this, opts)), $.isArray(opts.mask)) {
  179. if (opts.mask.length > 1) {
  180. opts.keepStatic = void 0 == opts.keepStatic ? !0 : opts.keepStatic;
  181. var altMask = "(";
  182. return $.each(opts.mask, function(ndx, msk) {
  183. altMask.length > 1 && (altMask += ")|("), altMask += preProcessMask(void 0 == msk.mask || $.isFunction(msk.mask) ? msk : msk.mask);
  184. }), altMask += ")", generateMask(altMask, opts.mask);
  185. }
  186. opts.mask = opts.mask.pop();
  187. }
  188. 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)),
  189. ms;
  190. }
  191. function maskScope(actionObj, maskset, opts) {
  192. function getMaskTemplate(baseOnInput, minimalPos, includeInput) {
  193. minimalPos = minimalPos || 0;
  194. var ndxIntlzr, test, testPos, maskTemplate = [], pos = 0;
  195. do {
  196. if (baseOnInput === !0 && getMaskSet().validPositions[pos]) {
  197. var validPos = getMaskSet().validPositions[pos];
  198. test = validPos.match, ndxIntlzr = validPos.locator.slice(), maskTemplate.push(includeInput === !0 ? validPos.input : getPlaceholder(pos, test));
  199. } else testPos = getTestTemplate(pos, ndxIntlzr, pos - 1), test = testPos.match,
  200. ndxIntlzr = testPos.locator.slice(), maskTemplate.push(getPlaceholder(pos, test));
  201. pos++;
  202. } while ((void 0 == maxLength || maxLength > pos - 1) && null != test.fn || null == test.fn && "" != test.def || minimalPos >= pos);
  203. return maskTemplate.pop(), maskTemplate;
  204. }
  205. function getMaskSet() {
  206. return maskset;
  207. }
  208. function resetMaskSet(soft) {
  209. var maskset = getMaskSet();
  210. maskset.buffer = void 0, maskset.tests = {}, soft !== !0 && (maskset._buffer = void 0,
  211. maskset.validPositions = {}, maskset.p = 0);
  212. }
  213. function getLastValidPosition(closestTo) {
  214. var maskset = getMaskSet(), lastValidPosition = -1, valids = maskset.validPositions;
  215. void 0 == closestTo && (closestTo = -1);
  216. var before = lastValidPosition, after = lastValidPosition;
  217. for (var posNdx in valids) {
  218. var psNdx = parseInt(posNdx);
  219. (-1 == closestTo || null != valids[psNdx].match.fn) && (closestTo >= psNdx && (before = psNdx),
  220. psNdx >= closestTo && (after = psNdx));
  221. }
  222. return lastValidPosition = -1 != before && closestTo - before > 1 || closestTo > after ? before : after;
  223. }
  224. function setValidPosition(pos, validTest, fromSetValid) {
  225. if (opts.insertMode && void 0 != getMaskSet().validPositions[pos] && void 0 == fromSetValid) {
  226. var i, positionsClone = $.extend(!0, {}, getMaskSet().validPositions), lvp = getLastValidPosition();
  227. for (i = pos; lvp >= i; i++) delete getMaskSet().validPositions[i];
  228. getMaskSet().validPositions[pos] = validTest;
  229. var j, valid = !0;
  230. for (i = pos; lvp >= i; i++) {
  231. var t = positionsClone[i];
  232. if (void 0 != t) {
  233. var vps = getMaskSet().validPositions;
  234. j = !opts.keepStatic && vps[i] && (void 0 != vps[i + 1] && getTests(i + 1, vps[i].locator.slice(), i).length > 1 || void 0 != vps[i].alternation) ? i + 1 : seekNext(i),
  235. valid = positionCanMatchDefinition(j, t.match.def) ? valid && isValid(j, t.input, !0, !0) !== !1 : null == t.match.fn;
  236. }
  237. if (!valid) break;
  238. }
  239. if (!valid) return getMaskSet().validPositions = $.extend(!0, {}, positionsClone),
  240. !1;
  241. } else getMaskSet().validPositions[pos] = validTest;
  242. return !0;
  243. }
  244. function stripValidPositions(start, end, nocheck, strict) {
  245. var i, startPos = start;
  246. getMaskSet().p = start, void 0 != getMaskSet().validPositions[start] && getMaskSet().validPositions[start].input == opts.radixPoint && (end++,
  247. startPos++);
  248. for (i = startPos; end > i; i++) void 0 != getMaskSet().validPositions[i] && (nocheck === !0 || 0 != opts.canClearPosition(getMaskSet(), i, getLastValidPosition(), strict, opts)) && delete getMaskSet().validPositions[i];
  249. for (resetMaskSet(!0), i = startPos + 1; i <= getLastValidPosition(); ) {
  250. for (;void 0 != getMaskSet().validPositions[startPos]; ) startPos++;
  251. var s = getMaskSet().validPositions[startPos];
  252. startPos > i && (i = startPos + 1);
  253. var t = getMaskSet().validPositions[i];
  254. void 0 != t && void 0 == s ? (positionCanMatchDefinition(startPos, t.match.def) && isValid(startPos, t.input, !0) !== !1 && (delete getMaskSet().validPositions[i],
  255. i++), startPos++) : i++;
  256. }
  257. var lvp = getLastValidPosition();
  258. lvp >= start && void 0 != getMaskSet().validPositions[lvp] && getMaskSet().validPositions[lvp].input == opts.radixPoint && delete getMaskSet().validPositions[lvp],
  259. resetMaskSet(!0);
  260. }
  261. function getTestTemplate(pos, ndxIntlzr, tstPs) {
  262. for (var testPos, testPositions = getTests(pos, ndxIntlzr, tstPs), lvp = getLastValidPosition(), lvTest = getMaskSet().validPositions[lvp] || getTests(0)[0], lvTestAltArr = void 0 != lvTest.alternation ? lvTest.locator[lvTest.alternation].split(",") : [], ndx = 0; ndx < testPositions.length && (testPos = testPositions[ndx],
  263. !(testPos.match && (opts.greedy && testPos.match.optionalQuantifier !== !0 || (testPos.match.optionality === !1 || testPos.match.newBlockMarker === !1) && testPos.match.optionalQuantifier !== !0) && (void 0 == lvTest.alternation || void 0 != testPos.locator[lvTest.alternation] && checkAlternationMatch(testPos.locator[lvTest.alternation].toString().split(","), lvTestAltArr)))); ndx++) ;
  264. return testPos;
  265. }
  266. function getTest(pos) {
  267. return getMaskSet().validPositions[pos] ? getMaskSet().validPositions[pos].match : getTests(pos)[0].match;
  268. }
  269. function positionCanMatchDefinition(pos, def) {
  270. for (var valid = !1, tests = getTests(pos), tndx = 0; tndx < tests.length; tndx++) if (tests[tndx].match && tests[tndx].match.def == def) {
  271. valid = !0;
  272. break;
  273. }
  274. return valid;
  275. }
  276. function getTests(pos, ndxIntlzr, tstPs) {
  277. function ResolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) {
  278. function handleMatch(match, loopNdx, quantifierRecurse) {
  279. if (testPos > 1e4) return alert("jquery.inputmask: There is probably an error in your mask definition or in the code. Create an issue on github with an example of the mask you are using. " + getMaskSet().mask),
  280. !0;
  281. if (testPos == pos && void 0 == match.matches) return matches.push({
  282. match: match,
  283. locator: loopNdx.reverse()
  284. }), !0;
  285. if (void 0 != match.matches) {
  286. if (match.isGroup && quantifierRecurse !== !0) {
  287. if (match = handleMatch(maskToken.matches[tndx + 1], loopNdx)) return !0;
  288. } else if (match.isOptional) {
  289. var optionalToken = match;
  290. if (match = ResolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) {
  291. var latestMatch = matches[matches.length - 1].match, isFirstMatch = 0 == $.inArray(latestMatch, optionalToken.matches);
  292. isFirstMatch && (insertStop = !0), testPos = pos;
  293. }
  294. } else if (match.isAlternator) {
  295. var maltMatches, alternateToken = match, malternateMatches = [], currentMatches = matches.slice(), loopNdxCnt = loopNdx.length, altIndex = ndxInitializer.length > 0 ? ndxInitializer.shift() : -1;
  296. if (-1 == altIndex || "string" == typeof altIndex) {
  297. var altIndexArr, currentPos = testPos, ndxInitializerClone = ndxInitializer.slice();
  298. "string" == typeof altIndex && (altIndexArr = altIndex.split(","));
  299. for (var amndx = 0; amndx < alternateToken.matches.length; amndx++) {
  300. matches = [], match = handleMatch(alternateToken.matches[amndx], [ amndx ].concat(loopNdx), quantifierRecurse) || match,
  301. maltMatches = matches.slice(), testPos = currentPos, matches = [];
  302. for (var i = 0; i < ndxInitializerClone.length; i++) ndxInitializer[i] = ndxInitializerClone[i];
  303. for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) for (var altMatch = maltMatches[ndx1], ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) {
  304. var altMatch2 = malternateMatches[ndx2];
  305. if (altMatch.match.mask == altMatch2.match.mask && ("string" != typeof altIndex || -1 != $.inArray(altMatch.locator[loopNdxCnt].toString(), altIndexArr))) {
  306. maltMatches.splice(ndx1, 1), altMatch2.locator[loopNdxCnt] = altMatch2.locator[loopNdxCnt] + "," + altMatch.locator[loopNdxCnt],
  307. altMatch2.alternation = loopNdxCnt;
  308. break;
  309. }
  310. }
  311. malternateMatches = malternateMatches.concat(maltMatches);
  312. }
  313. "string" == typeof altIndex && (malternateMatches = $.map(malternateMatches, function(lmnt, ndx) {
  314. if (isFinite(ndx)) {
  315. var mamatch, altLocArr = lmnt.locator[loopNdxCnt].toString().split(",");
  316. lmnt.locator[loopNdxCnt] = void 0, lmnt.alternation = void 0;
  317. for (var alndx = 0; alndx < altLocArr.length; alndx++) mamatch = -1 != $.inArray(altLocArr[alndx], altIndexArr),
  318. mamatch && (void 0 != lmnt.locator[loopNdxCnt] ? (lmnt.locator[loopNdxCnt] += ",",
  319. lmnt.alternation = loopNdxCnt, lmnt.locator[loopNdxCnt] += altLocArr[alndx]) : lmnt.locator[loopNdxCnt] = parseInt(altLocArr[alndx]));
  320. if (void 0 != lmnt.locator[loopNdxCnt]) return lmnt;
  321. }
  322. })), matches = currentMatches.concat(malternateMatches), insertStop = !0;
  323. } else match = handleMatch(alternateToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse);
  324. if (match) return !0;
  325. } else if (match.isQuantifier && quantifierRecurse !== !0) for (var qt = match, qndx = ndxInitializer.length > 0 && quantifierRecurse !== !0 ? ndxInitializer.shift() : 0; qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max) && pos >= testPos; qndx++) {
  326. var tokenGroup = maskToken.matches[$.inArray(qt, maskToken.matches) - 1];
  327. if (match = handleMatch(tokenGroup, [ qndx ].concat(loopNdx), !0)) {
  328. var latestMatch = matches[matches.length - 1].match;
  329. latestMatch.optionalQuantifier = qndx > qt.quantifier.min - 1;
  330. var isFirstMatch = 0 == $.inArray(latestMatch, tokenGroup.matches);
  331. if (isFirstMatch) {
  332. if (qndx > qt.quantifier.min - 1) {
  333. insertStop = !0, testPos = pos;
  334. break;
  335. }
  336. return !0;
  337. }
  338. return !0;
  339. }
  340. } else if (match = ResolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) return !0;
  341. } else testPos++;
  342. }
  343. for (var tndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; tndx < maskToken.matches.length; tndx++) if (maskToken.matches[tndx].isQuantifier !== !0) {
  344. var match = handleMatch(maskToken.matches[tndx], [ tndx ].concat(loopNdx), quantifierRecurse);
  345. if (match && testPos == pos) return match;
  346. if (testPos > pos) break;
  347. }
  348. }
  349. var maskTokens = getMaskSet().maskToken, testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr || [ 0 ], matches = [], insertStop = !1;
  350. if (void 0 == ndxIntlzr) {
  351. for (var test, previousPos = pos - 1; void 0 == (test = getMaskSet().validPositions[previousPos]) && previousPos > -1; ) previousPos--;
  352. if (void 0 != test && previousPos > -1) testPos = previousPos, ndxInitializer = test.locator.slice(); else {
  353. for (previousPos = pos - 1; void 0 == (test = getMaskSet().tests[previousPos]) && previousPos > -1; ) previousPos--;
  354. void 0 != test && previousPos > -1 && (testPos = previousPos, ndxInitializer = test[0].locator.slice());
  355. }
  356. }
  357. for (var mtndx = ndxInitializer.shift(); mtndx < maskTokens.length; mtndx++) {
  358. var match = ResolveTestFromToken(maskTokens[mtndx], ndxInitializer, [ mtndx ]);
  359. if (match && testPos == pos || testPos > pos) break;
  360. }
  361. return (0 == matches.length || insertStop) && matches.push({
  362. match: {
  363. fn: null,
  364. cardinality: 0,
  365. optionality: !0,
  366. casing: null,
  367. def: ""
  368. },
  369. locator: []
  370. }), getMaskSet().tests[pos] = $.extend(!0, [], matches), getMaskSet().tests[pos];
  371. }
  372. function getBufferTemplate() {
  373. return void 0 == getMaskSet()._buffer && (getMaskSet()._buffer = getMaskTemplate(!1, 1)),
  374. getMaskSet()._buffer;
  375. }
  376. function getBuffer() {
  377. return void 0 == getMaskSet().buffer && (getMaskSet().buffer = getMaskTemplate(!0, getLastValidPosition(), !0)),
  378. getMaskSet().buffer;
  379. }
  380. function refreshFromBuffer(start, end, buffer) {
  381. if (buffer = buffer || getBuffer().slice(), start === !0) resetMaskSet(), start = 0,
  382. end = buffer.length; else for (var i = start; end > i; i++) delete getMaskSet().validPositions[i],
  383. delete getMaskSet().tests[i];
  384. for (var i = start; end > i; i++) buffer[i] != opts.skipOptionalPartCharacter && isValid(i, buffer[i], !0, !0);
  385. }
  386. function casing(elem, test) {
  387. switch (test.casing) {
  388. case "upper":
  389. elem = elem.toUpperCase();
  390. break;
  391. case "lower":
  392. elem = elem.toLowerCase();
  393. }
  394. return elem;
  395. }
  396. function checkAlternationMatch(altArr1, altArr2) {
  397. for (var altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1), isMatch = !1, alndx = 0; alndx < altArr1.length; alndx++) if (-1 != $.inArray(altArr1[alndx], altArrC)) {
  398. isMatch = !0;
  399. break;
  400. }
  401. return isMatch;
  402. }
  403. function isValid(pos, c, strict, fromSetValid) {
  404. function _isValid(position, c, strict, fromSetValid) {
  405. var rslt = !1;
  406. return $.each(getTests(position), function(ndx, tst) {
  407. for (var test = tst.match, loopend = c ? 1 : 0, chrs = "", i = (getBuffer(), test.cardinality); i > loopend; i--) chrs += getBufferElement(position - (i - 1));
  408. if (c && (chrs += c), rslt = null != test.fn ? test.fn.test(chrs, getMaskSet(), position, strict, opts) : c != test.def && c != opts.skipOptionalPartCharacter || "" == test.def ? !1 : {
  409. c: test.def,
  410. pos: position
  411. }, rslt !== !1) {
  412. var elem = void 0 != rslt.c ? rslt.c : c;
  413. elem = elem == opts.skipOptionalPartCharacter && null === test.fn ? test.def : elem;
  414. var validatedPos = position;
  415. if (void 0 != rslt.remove && stripValidPositions(rslt.remove, rslt.remove + 1, !0),
  416. rslt.refreshFromBuffer) {
  417. var refresh = rslt.refreshFromBuffer;
  418. if (strict = !0, refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end),
  419. void 0 == rslt.pos && void 0 == rslt.c) return rslt.pos = getLastValidPosition(),
  420. !1;
  421. if (validatedPos = void 0 != rslt.pos ? rslt.pos : position, validatedPos != position) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0)),
  422. !1;
  423. } else if (rslt !== !0 && void 0 != rslt.pos && rslt.pos != position && (validatedPos = rslt.pos,
  424. refreshFromBuffer(position, validatedPos), validatedPos != position)) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0)),
  425. !1;
  426. return 1 != rslt && void 0 == rslt.pos && void 0 == rslt.c ? !1 : (ndx > 0 && resetMaskSet(!0),
  427. setValidPosition(validatedPos, $.extend({}, tst, {
  428. input: casing(elem, test)
  429. }), fromSetValid) || (rslt = !1), !1);
  430. }
  431. }), rslt;
  432. }
  433. function alternate(pos, c, strict, fromSetValid) {
  434. var lastAlt, alternation, validPsClone = $.extend(!0, {}, getMaskSet().validPositions);
  435. for (lastAlt = getLastValidPosition(); lastAlt >= 0; lastAlt--) if (getMaskSet().validPositions[lastAlt] && void 0 != getMaskSet().validPositions[lastAlt].alternation) {
  436. alternation = getMaskSet().validPositions[lastAlt].alternation;
  437. break;
  438. }
  439. if (void 0 != alternation) for (var decisionPos in getMaskSet().validPositions) if (parseInt(decisionPos) > parseInt(lastAlt) && void 0 === getMaskSet().validPositions[decisionPos].alternation) {
  440. for (var altPos = getMaskSet().validPositions[decisionPos], decisionTaker = altPos.locator[alternation], altNdxs = getMaskSet().validPositions[lastAlt].locator[alternation].split(","), mndx = 0; mndx < altNdxs.length; mndx++) if (decisionTaker < altNdxs[mndx]) {
  441. for (var possibilityPos, possibilities, dp = decisionPos - 1; dp >= 0; dp--) if (possibilityPos = getMaskSet().validPositions[dp],
  442. void 0 != possibilityPos) {
  443. possibilities = possibilityPos.locator[alternation], possibilityPos.locator[alternation] = altNdxs[mndx];
  444. break;
  445. }
  446. if (decisionTaker != possibilityPos.locator[alternation]) {
  447. for (var buffer = getBuffer().slice(), i = decisionPos; i < getLastValidPosition() + 1; i++) delete getMaskSet().validPositions[i],
  448. delete getMaskSet().tests[i];
  449. resetMaskSet(!0), opts.keepStatic = !opts.keepStatic;
  450. for (var i = decisionPos; i < buffer.length; i++) buffer[i] != opts.skipOptionalPartCharacter && isValid(getLastValidPosition() + 1, buffer[i], !1, !0);
  451. possibilityPos.locator[alternation] = possibilities;
  452. var isValidRslt = isValid(pos, c, strict, fromSetValid);
  453. if (opts.keepStatic = !opts.keepStatic, isValidRslt) return isValidRslt;
  454. resetMaskSet(), getMaskSet().validPositions = $.extend(!0, {}, validPsClone);
  455. }
  456. }
  457. break;
  458. }
  459. return !1;
  460. }
  461. function trackbackAlternations(originalPos, newPos) {
  462. for (var vp = getMaskSet().validPositions[newPos], targetLocator = vp.locator, tll = targetLocator.length, ps = originalPos; newPos > ps; ps++) if (!isMask(ps)) {
  463. var tests = getTests(ps), bestMatch = tests[0], equality = -1;
  464. $.each(tests, function(ndx, tst) {
  465. for (var i = 0; tll > i; i++) tst.locator[i] && checkAlternationMatch(tst.locator[i].toString().split(","), targetLocator[i].toString().split(",")) && i > equality && (equality = i,
  466. bestMatch = tst);
  467. }), setValidPosition(ps, $.extend({}, bestMatch, {
  468. input: bestMatch.match.def
  469. }), !0);
  470. }
  471. }
  472. strict = strict === !0;
  473. for (var buffer = getBuffer(), pndx = pos - 1; pndx > -1 && !getMaskSet().validPositions[pndx]; pndx--) ;
  474. 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);
  475. var maskPos = pos, result = !1, positionsClone = $.extend(!0, {}, getMaskSet().validPositions);
  476. if (maskPos < getMaskLength() && (result = _isValid(maskPos, c, strict, fromSetValid),
  477. !strict && result === !1)) {
  478. var currentPosValid = getMaskSet().validPositions[maskPos];
  479. if (!currentPosValid || null != currentPosValid.match.fn || currentPosValid.match.def != c && c != opts.skipOptionalPartCharacter) {
  480. if ((opts.insertMode || void 0 == getMaskSet().validPositions[seekNext(maskPos)]) && !isMask(maskPos)) for (var nPos = maskPos + 1, snPos = seekNext(maskPos); snPos >= nPos; nPos++) if (result = _isValid(nPos, c, strict, fromSetValid),
  481. result !== !1) {
  482. trackbackAlternations(maskPos, nPos), maskPos = nPos;
  483. break;
  484. }
  485. } else result = {
  486. caret: seekNext(maskPos)
  487. };
  488. }
  489. if (result === !1 && opts.keepStatic && isComplete(buffer) && (result = alternate(pos, c, strict, fromSetValid)),
  490. result === !0 && (result = {
  491. pos: maskPos
  492. }), $.isFunction(opts.postValidation) && 0 != result && !strict) {
  493. resetMaskSet(!0);
  494. var postValidResult = opts.postValidation(getBuffer(), opts);
  495. if (!postValidResult) return resetMaskSet(!0), getMaskSet().validPositions = $.extend(!0, {}, positionsClone),
  496. !1;
  497. }
  498. return result;
  499. }
  500. function isMask(pos) {
  501. var test = getTest(pos);
  502. return null != test.fn ? test.fn : !1;
  503. }
  504. function getMaskLength() {
  505. var maskLength;
  506. maxLength = $el.prop("maxLength"), -1 == maxLength && (maxLength = void 0);
  507. var pos, lvp = getLastValidPosition(), testPos = getMaskSet().validPositions[lvp], ndxIntlzr = void 0 != testPos ? testPos.locator.slice() : void 0;
  508. 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),
  509. ndxIntlzr = testPos.locator.slice();
  510. return maskLength = pos, void 0 == maxLength || maxLength > maskLength ? maskLength : maxLength;
  511. }
  512. function seekNext(pos) {
  513. var maskL = getMaskLength();
  514. if (pos >= maskL) return maskL;
  515. for (var position = pos; ++position < maskL && !isMask(position) && (opts.nojumps !== !0 || opts.nojumpsThreshold > position); ) ;
  516. return position;
  517. }
  518. function seekPrevious(pos) {
  519. var position = pos;
  520. if (0 >= position) return 0;
  521. for (;--position > 0 && !isMask(position); ) ;
  522. return position;
  523. }
  524. function getBufferElement(position) {
  525. return void 0 == getMaskSet().validPositions[position] ? getPlaceholder(position) : getMaskSet().validPositions[position].input;
  526. }
  527. function writeBuffer(input, buffer, caretPos, event, triggerInputEvent) {
  528. if (event && $.isFunction(opts.onBeforeWrite)) {
  529. var result = opts.onBeforeWrite.call(input, event, buffer, caretPos, opts);
  530. if (result) {
  531. if (result.refreshFromBuffer) {
  532. var refresh = result.refreshFromBuffer;
  533. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, result.buffer),
  534. resetMaskSet(!0), buffer = getBuffer();
  535. }
  536. caretPos = result.caret || caretPos;
  537. }
  538. }
  539. input._valueSet(buffer.join("")), void 0 != caretPos && caret(input, caretPos),
  540. triggerInputEvent === !0 && (skipInputEvent = !0, $(input).trigger("input"));
  541. }
  542. function getPlaceholder(pos, test) {
  543. return test = test || getTest(pos), void 0 != test.placeholder ? test.placeholder : null == test.fn ? test.def : opts.placeholder.charAt(pos % opts.placeholder.length);
  544. }
  545. function checkVal(input, writeOut, strict, nptvl) {
  546. function isTemplateMatch() {
  547. var isMatch = !1, charCodeNdx = getBufferTemplate().slice(initialNdx, seekNext(initialNdx)).join("").indexOf(charCodes);
  548. if (-1 != charCodeNdx && !isMask(initialNdx)) {
  549. isMatch = !0;
  550. for (var bufferTemplateArr = getBufferTemplate().slice(initialNdx, initialNdx + charCodeNdx), i = 0; i < bufferTemplateArr.length; i++) if (" " != bufferTemplateArr[i]) {
  551. isMatch = !1;
  552. break;
  553. }
  554. }
  555. return isMatch;
  556. }
  557. var inputValue = void 0 != nptvl ? nptvl.slice() : input._valueGet().split(""), charCodes = "", initialNdx = 0;
  558. resetMaskSet(), getMaskSet().p = seekNext(-1), writeOut && input._valueSet("");
  559. var staticInput = getBufferTemplate().slice(0, seekNext(-1)).join(""), matches = inputValue.join("").match(new RegExp(escapeRegex(staticInput), "g"));
  560. matches && matches.length > 0 && (inputValue.splice(0, matches.length * staticInput.length),
  561. initialNdx = seekNext(initialNdx)), $.each(inputValue, function(ndx, charCode) {
  562. var keypress = $.Event("keypress");
  563. keypress.which = charCode.charCodeAt(0), charCodes += charCode;
  564. var lvp = getLastValidPosition(), lvTest = getMaskSet().validPositions[lvp], nextTest = getTestTemplate(lvp + 1, lvTest ? lvTest.locator.slice() : void 0, lvp);
  565. if (!isTemplateMatch() || strict) {
  566. var pos = strict ? ndx : null == nextTest.match.fn && nextTest.match.optionality && lvp + 1 < getMaskSet().p ? lvp + 1 : getMaskSet().p;
  567. keypressEvent.call(input, keypress, !0, !1, strict, pos), initialNdx = pos + 1,
  568. charCodes = "";
  569. } else keypressEvent.call(input, keypress, !0, !1, !0, lvp + 1);
  570. }), writeOut && writeBuffer(input, getBuffer(), $(input).is(":focus") ? seekNext(getLastValidPosition(0)) : void 0, $.Event("checkval"));
  571. }
  572. function escapeRegex(str) {
  573. return $.inputmask.escapeRegex.call(this, str);
  574. }
  575. function unmaskedvalue($input) {
  576. if ($input.data("_inputmask") && !$input.hasClass("hasDatepicker")) {
  577. var umValue = [], vps = getMaskSet().validPositions;
  578. for (var pndx in vps) vps[pndx].match && null != vps[pndx].match.fn && umValue.push(vps[pndx].input);
  579. var unmaskedValue = (isRTL ? umValue.reverse() : umValue).join(""), bufferValue = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join("");
  580. return $.isFunction(opts.onUnMask) && (unmaskedValue = opts.onUnMask.call($input, bufferValue, unmaskedValue, opts) || unmaskedValue),
  581. unmaskedValue;
  582. }
  583. return $input[0]._valueGet();
  584. }
  585. function TranslatePosition(pos) {
  586. if (isRTL && "number" == typeof pos && (!opts.greedy || "" != opts.placeholder)) {
  587. var bffrLght = getBuffer().length;
  588. pos = bffrLght - pos;
  589. }
  590. return pos;
  591. }
  592. function caret(input, begin, end) {
  593. var range, npt = input.jquery && input.length > 0 ? input[0] : input;
  594. if ("number" != typeof begin) return npt.setSelectionRange ? (begin = npt.selectionStart,
  595. end = npt.selectionEnd) : document.selection && document.selection.createRange && (range = document.selection.createRange(),
  596. begin = 0 - range.duplicate().moveStart("character", -1e5), end = begin + range.text.length),
  597. {
  598. begin: TranslatePosition(begin),
  599. end: TranslatePosition(end)
  600. };
  601. if (begin = TranslatePosition(begin), end = TranslatePosition(end), end = "number" == typeof end ? end : begin,
  602. $(npt).is(":visible")) {
  603. var scrollCalc = $(npt).css("font-size").replace("px", "") * end;
  604. npt.scrollLeft = scrollCalc > npt.scrollWidth ? scrollCalc : 0, 0 == opts.insertMode && begin == end && end++,
  605. npt.setSelectionRange ? (npt.selectionStart = begin, npt.selectionEnd = end) : npt.createTextRange && (range = npt.createTextRange(),
  606. range.collapse(!0), range.moveEnd("character", end), range.moveStart("character", begin),
  607. range.select());
  608. }
  609. }
  610. function determineLastRequiredPosition(returnDefinition) {
  611. var pos, testPos, buffer = getBuffer(), bl = buffer.length, lvp = getLastValidPosition(), positions = {}, lvTest = getMaskSet().validPositions[lvp], ndxIntlzr = void 0 != lvTest ? lvTest.locator.slice() : void 0;
  612. for (pos = lvp + 1; pos < buffer.length; pos++) testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
  613. ndxIntlzr = testPos.locator.slice(), positions[pos] = $.extend(!0, {}, testPos);
  614. var lvTestAltArr = lvTest && void 0 != lvTest.alternation ? lvTest.locator[lvTest.alternation].split(",") : [];
  615. for (pos = bl - 1; pos > lvp && (testPos = positions[pos].match, (testPos.optionality || testPos.optionalQuantifier || lvTest && void 0 != lvTest.alternation && void 0 != positions[pos].locator[lvTest.alternation] && -1 != $.inArray(positions[pos].locator[lvTest.alternation].toString(), lvTestAltArr)) && buffer[pos] == getPlaceholder(pos, testPos)); pos--) bl--;
  616. return returnDefinition ? {
  617. l: bl,
  618. def: positions[bl] ? positions[bl].match : void 0
  619. } : bl;
  620. }
  621. function clearOptionalTail(buffer) {
  622. for (var rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
  623. buffer.splice(rl, lmib + 1 - rl);
  624. }
  625. function isComplete(buffer) {
  626. if ($.isFunction(opts.isComplete)) return opts.isComplete.call($el, buffer, opts);
  627. if ("*" == opts.repeat) return void 0;
  628. {
  629. var complete = !1, lrp = determineLastRequiredPosition(!0), aml = seekPrevious(lrp.l);
  630. getLastValidPosition();
  631. }
  632. if (void 0 == lrp.def || lrp.def.newBlockMarker || lrp.def.optionalQuantifier) {
  633. complete = !0;
  634. for (var i = 0; aml >= i; i++) {
  635. var mask = isMask(i), test = getTest(i);
  636. if (mask && void 0 == getMaskSet().validPositions[i] && test.optionality !== !0 && test.optionalQuantifier !== !0 || !mask && buffer[i] != getPlaceholder(i)) {
  637. complete = !1;
  638. break;
  639. }
  640. }
  641. }
  642. return complete;
  643. }
  644. function isSelection(begin, end) {
  645. return isRTL ? begin - end > 1 || begin - end == 1 && opts.insertMode : end - begin > 1 || end - begin == 1 && opts.insertMode;
  646. }
  647. function installEventRuler(npt) {
  648. var events = $._data(npt).events;
  649. $.each(events, function(eventType, eventHandlers) {
  650. $.each(eventHandlers, function(ndx, eventHandler) {
  651. if ("inputmask" == eventHandler.namespace && "setvalue" != eventHandler.type) {
  652. var handler = eventHandler.handler;
  653. eventHandler.handler = function(e) {
  654. if (!this.disabled && (!this.readOnly || "keydown" == e.type && e.ctrlKey && 67 == e.keyCode)) {
  655. switch (e.type) {
  656. case "input":
  657. if (skipInputEvent === !0) return skipInputEvent = !1, e.preventDefault();
  658. break;
  659. case "keydown":
  660. skipKeyPressEvent = !1;
  661. break;
  662. case "keypress":
  663. if (skipKeyPressEvent === !0) return e.preventDefault();
  664. skipKeyPressEvent = !0;
  665. break;
  666. case "compositionstart":
  667. break;
  668. case "compositionupdate":
  669. skipInputEvent = !0;
  670. break;
  671. case "compositionend": }
  672. return handler.apply(this, arguments);
  673. }
  674. e.preventDefault();
  675. };
  676. }
  677. });
  678. });
  679. }
  680. function patchValueProperty(npt) {
  681. function PatchValhook(type) {
  682. if (void 0 == $.valHooks[type] || 1 != $.valHooks[type].inputmaskpatch) {
  683. var valhookGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function(elem) {
  684. return elem.value;
  685. }, valhookSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function(elem, value) {
  686. return elem.value = value, elem;
  687. };
  688. $.valHooks[type] = {
  689. get: function(elem) {
  690. var $elem = $(elem);
  691. if ($elem.data("_inputmask")) {
  692. if ($elem.data("_inputmask").opts.autoUnmask) return $elem.inputmask("unmaskedvalue");
  693. var result = valhookGet(elem), inputData = $elem.data("_inputmask"), maskset = inputData.maskset, bufferTemplate = maskset._buffer;
  694. return bufferTemplate = bufferTemplate ? bufferTemplate.join("") : "", result != bufferTemplate ? result : "";
  695. }
  696. return valhookGet(elem);
  697. },
  698. set: function(elem, value) {
  699. var result, $elem = $(elem), inputData = $elem.data("_inputmask");
  700. return inputData ? (result = valhookSet(elem, $.isFunction(inputData.opts.onBeforeMask) ? inputData.opts.onBeforeMask.call(el, value, inputData.opts) || value : value),
  701. $elem.triggerHandler("setvalue.inputmask")) : result = valhookSet(elem, value),
  702. result;
  703. },
  704. inputmaskpatch: !0
  705. };
  706. }
  707. }
  708. function getter() {
  709. var $self = $(this), inputData = $(this).data("_inputmask");
  710. return inputData ? inputData.opts.autoUnmask ? $self.inputmask("unmaskedvalue") : valueGet.call(this) != getBufferTemplate().join("") ? valueGet.call(this) : "" : valueGet.call(this);
  711. }
  712. function setter(value) {
  713. var inputData = $(this).data("_inputmask");
  714. inputData ? (valueSet.call(this, $.isFunction(inputData.opts.onBeforeMask) ? inputData.opts.onBeforeMask.call(el, value, inputData.opts) || value : value),
  715. $(this).triggerHandler("setvalue.inputmask")) : valueSet.call(this, value);
  716. }
  717. function InstallNativeValueSetFallback(npt) {
  718. $(npt).bind("mouseenter.inputmask", function() {
  719. var $input = $(this), input = this, value = input._valueGet();
  720. "" != value && value != getBuffer().join("") && (this._valueSet($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(el, value, opts) || value : value),
  721. $input.triggerHandler("setvalue.inputmask"));
  722. });
  723. //!! the bound handlers are executed in the order they where bound
  724. var events = $._data(npt).events, handlers = events.mouseover;
  725. if (handlers) {
  726. for (var ourHandler = handlers[handlers.length - 1], i = handlers.length - 1; i > 0; i--) handlers[i] = handlers[i - 1];
  727. handlers[0] = ourHandler;
  728. }
  729. }
  730. var valueGet, valueSet;
  731. if (!npt._valueGet) {
  732. if (Object.getOwnPropertyDescriptor) {
  733. Object.getOwnPropertyDescriptor(npt, "value");
  734. }
  735. document.__lookupGetter__ && npt.__lookupGetter__("value") ? (valueGet = npt.__lookupGetter__("value"),
  736. valueSet = npt.__lookupSetter__("value"), npt.__defineGetter__("value", getter),
  737. npt.__defineSetter__("value", setter)) : (valueGet = function() {
  738. return npt.value;
  739. }, valueSet = function(value) {
  740. npt.value = value;
  741. }, PatchValhook(npt.type), InstallNativeValueSetFallback(npt)), npt._valueGet = function(overruleRTL) {
  742. return isRTL && overruleRTL !== !0 ? valueGet.call(this).split("").reverse().join("") : valueGet.call(this);
  743. }, npt._valueSet = function(value) {
  744. valueSet.call(this, isRTL ? value.split("").reverse().join("") : value);
  745. };
  746. }
  747. }
  748. function handleRemove(input, k, pos, strict) {
  749. function generalize() {
  750. if (opts.keepStatic) {
  751. resetMaskSet(!0);
  752. var lastAlt, validInputs = [];
  753. for (lastAlt = getLastValidPosition(); lastAlt >= 0; lastAlt--) if (getMaskSet().validPositions[lastAlt]) {
  754. if (void 0 != getMaskSet().validPositions[lastAlt].alternation) break;
  755. validInputs.push(getMaskSet().validPositions[lastAlt].input), delete getMaskSet().validPositions[lastAlt];
  756. }
  757. if (lastAlt > 0) for (;validInputs.length > 0; ) {
  758. getMaskSet().p = seekNext(getLastValidPosition());
  759. var keypress = $.Event("keypress");
  760. keypress.which = validInputs.pop().charCodeAt(0), keypressEvent.call(input, keypress, !0, !1, !1, getMaskSet().p);
  761. }
  762. }
  763. }
  764. if ((opts.numericInput || isRTL) && (k == $.inputmask.keyCode.BACKSPACE ? k = $.inputmask.keyCode.DELETE : k == $.inputmask.keyCode.DELETE && (k = $.inputmask.keyCode.BACKSPACE),
  765. isRTL)) {
  766. var pend = pos.end;
  767. pos.end = pos.begin, pos.begin = pend;
  768. }
  769. if (k == $.inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || 0 == opts.insertMode) ? pos.begin = seekPrevious(pos.begin) : k == $.inputmask.keyCode.DELETE && pos.begin == pos.end && (pos.end = isMask(pos.end) ? pos.end + 1 : seekNext(pos.end) + 1),
  770. stripValidPositions(pos.begin, pos.end, !1, strict), strict !== !0) {
  771. generalize();
  772. var lvp = getLastValidPosition(pos.begin);
  773. lvp < pos.begin ? (-1 == lvp && resetMaskSet(), getMaskSet().p = seekNext(lvp)) : getMaskSet().p = pos.begin;
  774. }
  775. }
  776. function keydownEvent(e) {
  777. var input = this, $input = $(input), k = e.keyCode, pos = caret(input);
  778. k == $.inputmask.keyCode.BACKSPACE || k == $.inputmask.keyCode.DELETE || iphone && 127 == k || e.ctrlKey && 88 == k && !isInputEventSupported("cut") ? (e.preventDefault(),
  779. 88 == k && (undoValue = getBuffer().join("")), handleRemove(input, k, pos), writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue != getBuffer().join("")),
  780. input._valueGet() == getBufferTemplate().join("") ? $input.trigger("cleared") : isComplete(getBuffer()) === !0 && $input.trigger("complete"),
  781. opts.showTooltip && $input.prop("title", getMaskSet().mask)) : k == $.inputmask.keyCode.END || k == $.inputmask.keyCode.PAGE_DOWN ? setTimeout(function() {
  782. var caretPos = seekNext(getLastValidPosition());
  783. opts.insertMode || caretPos != getMaskLength() || e.shiftKey || caretPos--, caret(input, e.shiftKey ? pos.begin : caretPos, caretPos);
  784. }, 0) : k == $.inputmask.keyCode.HOME && !e.shiftKey || k == $.inputmask.keyCode.PAGE_UP ? caret(input, 0, e.shiftKey ? pos.begin : 0) : (opts.undoOnEscape && k == $.inputmask.keyCode.ESCAPE || 90 == k && e.ctrlKey) && e.altKey !== !0 ? (checkVal(input, !0, !1, undoValue.split("")),
  785. $input.click()) : k != $.inputmask.keyCode.INSERT || e.shiftKey || e.ctrlKey ? 0 != opts.insertMode || e.shiftKey || (k == $.inputmask.keyCode.RIGHT ? setTimeout(function() {
  786. var caretPos = caret(input);
  787. caret(input, caretPos.begin);
  788. }, 0) : k == $.inputmask.keyCode.LEFT && setTimeout(function() {
  789. var caretPos = caret(input);
  790. caret(input, isRTL ? caretPos.begin + 1 : caretPos.begin - 1);
  791. }, 0)) : (opts.insertMode = !opts.insertMode, caret(input, opts.insertMode || pos.begin != getMaskLength() ? pos.begin : pos.begin - 1)),
  792. opts.onKeyDown.call(this, e, getBuffer(), caret(input).begin, opts), ignorable = -1 != $.inArray(k, opts.ignorables);
  793. }
  794. function keypressEvent(e, checkval, writeOut, strict, ndx) {
  795. var input = this, $input = $(input), k = e.which || e.charCode || e.keyCode;
  796. if (!(checkval === !0 || e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable)) return !0;
  797. if (k) {
  798. 46 == k && 0 == e.shiftKey && "," == opts.radixPoint && (k = 44);
  799. var forwardPosition, pos = checkval ? {
  800. begin: ndx,
  801. end: ndx
  802. } : caret(input), c = String.fromCharCode(k), isSlctn = isSelection(pos.begin, pos.end);
  803. isSlctn && (getMaskSet().undoPositions = $.extend(!0, {}, getMaskSet().validPositions),
  804. handleRemove(input, $.inputmask.keyCode.DELETE, pos, !0), pos.begin = getMaskSet().p,
  805. opts.insertMode || (opts.insertMode = !opts.insertMode, setValidPosition(pos.begin, strict),
  806. opts.insertMode = !opts.insertMode), isSlctn = !opts.multi), getMaskSet().writeOutBuffer = !0;
  807. var p = isRTL && !isSlctn ? pos.end : pos.begin, valResult = isValid(p, c, strict);
  808. if (valResult !== !1) {
  809. if (valResult !== !0 && (p = void 0 != valResult.pos ? valResult.pos : p, c = void 0 != valResult.c ? valResult.c : c),
  810. resetMaskSet(!0), void 0 != valResult.caret) forwardPosition = valResult.caret; else {
  811. var vps = getMaskSet().validPositions;
  812. 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);
  813. }
  814. getMaskSet().p = forwardPosition;
  815. }
  816. if (writeOut !== !1) {
  817. var self = this;
  818. if (setTimeout(function() {
  819. opts.onKeyValidation.call(self, valResult, opts);
  820. }, 0), getMaskSet().writeOutBuffer && valResult !== !1) {
  821. var buffer = getBuffer();
  822. writeBuffer(input, buffer, checkval ? void 0 : opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition, e, checkval !== !0),
  823. checkval !== !0 && setTimeout(function() {
  824. isComplete(buffer) === !0 && $input.trigger("complete");
  825. }, 0);
  826. } else isSlctn && (getMaskSet().buffer = void 0, getMaskSet().validPositions = getMaskSet().undoPositions);
  827. } else isSlctn && (getMaskSet().buffer = void 0, getMaskSet().validPositions = getMaskSet().undoPositions);
  828. if (opts.showTooltip && $input.prop("title", getMaskSet().mask), checkval && $.isFunction(opts.onBeforeWrite)) {
  829. var result = opts.onBeforeWrite.call(this, e, getBuffer(), forwardPosition, opts);
  830. if (result && result.refreshFromBuffer) {
  831. var refresh = result.refreshFromBuffer;
  832. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, result.buffer),
  833. resetMaskSet(!0), result.caret && (getMaskSet().p = result.caret);
  834. }
  835. }
  836. e.preventDefault();
  837. }
  838. }
  839. function pasteEvent(e) {
  840. var input = this, $input = $(input), inputValue = input._valueGet(!0), caretPos = caret(input);
  841. if ("propertychange" == e.type && input._valueGet().length <= getMaskLength()) return !0;
  842. if ("paste" == e.type) {
  843. var valueBeforeCaret = inputValue.substr(0, caretPos.begin), valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length);
  844. valueBeforeCaret == getBufferTemplate().slice(0, caretPos.begin).join("") && (valueBeforeCaret = ""),
  845. valueAfterCaret == getBufferTemplate().slice(caretPos.end).join("") && (valueAfterCaret = ""),
  846. window.clipboardData && window.clipboardData.getData ? inputValue = valueBeforeCaret + window.clipboardData.getData("Text") + valueAfterCaret : e.originalEvent && e.originalEvent.clipboardData && e.originalEvent.clipboardData.getData && (inputValue = valueBeforeCaret + e.originalEvent.clipboardData.getData("text/plain") + valueAfterCaret);
  847. }
  848. var pasteValue = inputValue;
  849. if ($.isFunction(opts.onBeforePaste)) {
  850. if (pasteValue = opts.onBeforePaste.call(input, inputValue, opts), pasteValue === !1) return e.preventDefault(),
  851. !1;
  852. pasteValue || (pasteValue = inputValue);
  853. }
  854. return checkVal(input, !0, !1, isRTL ? pasteValue.split("").reverse() : pasteValue.split("")),
  855. $input.click(), isComplete(getBuffer()) === !0 && $input.trigger("complete"), !1;
  856. }
  857. function inputFallBackEvent(e) {
  858. var input = this;
  859. checkVal(input, !0, !1), isComplete(getBuffer()) === !0 && $(input).trigger("complete"),
  860. e.preventDefault();
  861. }
  862. function compositionStartEvent(e) {
  863. var input = this;
  864. undoValue = getBuffer().join(""), ("" == compositionData || 0 != e.originalEvent.data.indexOf(compositionData)) && (compositionCaretPos = caret(input));
  865. }
  866. function compositionUpdateEvent(e) {
  867. var input = this, caretPos = compositionCaretPos || caret(input);
  868. 0 == e.originalEvent.data.indexOf(compositionData) && (resetMaskSet(), caretPos = {
  869. begin: 0,
  870. end: 0
  871. });
  872. var newData = e.originalEvent.data;
  873. caret(input, caretPos.begin, caretPos.end);
  874. for (var i = 0; i < newData.length; i++) {
  875. var keypress = $.Event("keypress");
  876. keypress.which = newData.charCodeAt(i), skipKeyPressEvent = !1, ignorable = !1,
  877. keypressEvent.call(input, keypress);
  878. }
  879. setTimeout(function() {
  880. var forwardPosition = getMaskSet().p;
  881. writeBuffer(input, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
  882. }, 0), compositionData = e.originalEvent.data;
  883. }
  884. function compositionEndEvent() {}
  885. function mask(el) {
  886. if ($el = $(el), $el.is(":input") && isInputTypeSupported($el.attr("type"))) {
  887. if ($el.data("_inputmask", {
  888. maskset: maskset,
  889. opts: opts,
  890. isRTL: !1
  891. }), opts.showTooltip && $el.prop("title", getMaskSet().mask), ("rtl" == el.dir || opts.rightAlign) && $el.css("text-align", "right"),
  892. "rtl" == el.dir || opts.numericInput) {
  893. el.dir = "ltr", $el.removeAttr("dir");
  894. var inputData = $el.data("_inputmask");
  895. inputData.isRTL = !0, $el.data("_inputmask", inputData), isRTL = !0;
  896. }
  897. $el.unbind(".inputmask"), $el.closest("form").bind("submit", function() {
  898. undoValue != getBuffer().join("") && $el.change(), $el[0]._valueGet && $el[0]._valueGet() == getBufferTemplate().join("") && $el[0]._valueSet(""),
  899. opts.removeMaskOnSubmit && $el.inputmask("remove");
  900. }).bind("reset", function() {
  901. setTimeout(function() {
  902. $el.triggerHandler("setvalue.inputmask");
  903. }, 0);
  904. }), $el.bind("mouseenter.inputmask", function() {
  905. var $input = $(this), input = this;
  906. !$input.is(":focus") && opts.showMaskOnHover && input._valueGet() != getBuffer().join("") && writeBuffer(input, getBuffer());
  907. }).bind("blur.inputmask", function(e) {
  908. var $input = $(this), input = this;
  909. if ($input.data("_inputmask")) {
  910. var nptValue = input._valueGet(), buffer = getBuffer().slice();
  911. firstClick = !0, undoValue != buffer.join("") && setTimeout(function() {
  912. $input.change(), undoValue = buffer.join("");
  913. }, 0), "" != nptValue && (opts.clearMaskOnLostFocus && (nptValue == getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
  914. isComplete(buffer) === !1 && ($input.trigger("incomplete"), opts.clearIncomplete && (resetMaskSet(),
  915. buffer = opts.clearMaskOnLostFocus ? [] : getBufferTemplate().slice())), writeBuffer(input, buffer, void 0, e));
  916. }
  917. }).bind("focus.inputmask", function() {
  918. var input = ($(this), this), nptValue = input._valueGet();
  919. opts.showMaskOnFocus && (!opts.showMaskOnHover || opts.showMaskOnHover && "" == nptValue) && input._valueGet() != getBuffer().join("") && writeBuffer(input, getBuffer(), seekNext(getLastValidPosition())),
  920. undoValue = getBuffer().join("");
  921. }).bind("mouseleave.inputmask", function() {
  922. var $input = $(this), input = this;
  923. if (opts.clearMaskOnLostFocus) {
  924. var buffer = getBuffer().slice(), nptValue = input._valueGet();
  925. $input.is(":focus") || nptValue == $input.attr("placeholder") || "" == nptValue || (nptValue == getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer),
  926. writeBuffer(input, buffer));
  927. }
  928. }).bind("click.inputmask", function() {
  929. var $input = $(this), input = this;
  930. if ($input.is(":focus")) {
  931. var selectedCaret = caret(input);
  932. if (selectedCaret.begin == selectedCaret.end) if (opts.radixFocus && "" != opts.radixPoint && -1 != $.inArray(opts.radixPoint, getBuffer()) && (firstClick || getBuffer().join("") == getBufferTemplate().join(""))) caret(input, $.inArray(opts.radixPoint, getBuffer())),
  933. firstClick = !1; else {
  934. var clickPosition = isRTL ? TranslatePosition(selectedCaret.begin) : selectedCaret.begin, lastPosition = seekNext(getLastValidPosition(clickPosition));
  935. lastPosition > clickPosition ? caret(input, isMask(clickPosition) ? clickPosition : seekNext(clickPosition)) : caret(input, lastPosition);
  936. }
  937. }
  938. }).bind("dblclick.inputmask", function() {
  939. var input = this;
  940. setTimeout(function() {
  941. caret(input, 0, seekNext(getLastValidPosition()));
  942. }, 0);
  943. }).bind(PasteEventType + ".inputmask dragdrop.inputmask drop.inputmask", pasteEvent).bind("setvalue.inputmask", function() {
  944. var input = this;
  945. checkVal(input, !0, !1), undoValue = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input._valueGet() == getBufferTemplate().join("") && input._valueSet("");
  946. }).bind("cut.inputmask", function(e) {
  947. skipInputEvent = !0;
  948. var input = this, $input = $(input), pos = caret(input);
  949. handleRemove(input, $.inputmask.keyCode.DELETE, pos), writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue != getBuffer().join("")),
  950. input._valueGet() == getBufferTemplate().join("") && $input.trigger("cleared"),
  951. opts.showTooltip && $input.prop("title", getMaskSet().mask);
  952. }).bind("complete.inputmask", opts.oncomplete).bind("incomplete.inputmask", opts.onincomplete).bind("cleared.inputmask", opts.oncleared),
  953. $el.bind("keydown.inputmask", keydownEvent).bind("keypress.inputmask", keypressEvent),
  954. androidfirefox || $el.bind("compositionstart.inputmask", compositionStartEvent).bind("compositionupdate.inputmask", compositionUpdateEvent).bind("compositionend.inputmask", compositionEndEvent),
  955. "paste" === PasteEventType && $el.bind("input.inputmask", inputFallBackEvent), patchValueProperty(el);
  956. var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(el, el._valueGet(), opts) || el._valueGet() : el._valueGet();
  957. checkVal(el, !0, !1, initialValue.split(""));
  958. var buffer = getBuffer().slice();
  959. undoValue = buffer.join("");
  960. var activeElement;
  961. try {
  962. activeElement = document.activeElement;
  963. } catch (e) {}
  964. isComplete(buffer) === !1 && opts.clearIncomplete && resetMaskSet(), opts.clearMaskOnLostFocus && (buffer.join("") == getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
  965. writeBuffer(el, buffer), activeElement === el && caret(el, seekNext(getLastValidPosition())),
  966. installEventRuler(el);
  967. }
  968. }
  969. var undoValue, compositionCaretPos, compositionData, $el, maxLength, isRTL = !1, skipKeyPressEvent = !1, skipInputEvent = !1, ignorable = !1, firstClick = !0;
  970. if (void 0 != actionObj) switch (actionObj.action) {
  971. case "isComplete":
  972. return $el = $(actionObj.el), maskset = $el.data("_inputmask").maskset, opts = $el.data("_inputmask").opts,
  973. isComplete(actionObj.buffer);
  974. case "unmaskedvalue":
  975. return $el = actionObj.$input, maskset = $el.data("_inputmask").maskset, opts = $el.data("_inputmask").opts,
  976. isRTL = actionObj.$input.data("_inputmask").isRTL, unmaskedvalue(actionObj.$input);
  977. case "mask":
  978. undoValue = getBuffer().join(""), mask(actionObj.el);
  979. break;
  980. case "format":
  981. $el = $({}), $el.data("_inputmask", {
  982. maskset: maskset,
  983. opts: opts,
  984. isRTL: opts.numericInput
  985. }), opts.numericInput && (isRTL = !0);
  986. var valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call($el, actionObj.value, opts) || actionObj.value : actionObj.value).split("");
  987. return checkVal($el, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite.call(this, void 0, getBuffer(), 0, opts),
  988. actionObj.metadata ? {
  989. value: isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join(""),
  990. metadata: $el.inputmask("getmetadata")
  991. } : isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join("");
  992. case "isValid":
  993. $el = $({}), $el.data("_inputmask", {
  994. maskset: maskset,
  995. opts: opts,
  996. isRTL: opts.numericInput
  997. }), opts.numericInput && (isRTL = !0);
  998. var valueBuffer = actionObj.value.split("");
  999. checkVal($el, !1, !0, isRTL ? valueBuffer.reverse() : valueBuffer);
  1000. for (var buffer = getBuffer(), rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
  1001. return buffer.splice(rl, lmib + 1 - rl), isComplete(buffer) && actionObj.value == buffer.join("");
  1002. case "getemptymask":
  1003. return $el = $(actionObj.el), maskset = $el.data("_inputmask").maskset, opts = $el.data("_inputmask").opts,
  1004. getBufferTemplate();
  1005. case "remove":
  1006. var el = actionObj.el;
  1007. $el = $(el), maskset = $el.data("_inputmask").maskset, opts = $el.data("_inputmask").opts,
  1008. el._valueSet(unmaskedvalue($el)), $el.unbind(".inputmask"), $el.removeData("_inputmask");
  1009. var valueProperty;
  1010. Object.getOwnPropertyDescriptor && (valueProperty = Object.getOwnPropertyDescriptor(el, "value")),
  1011. valueProperty && valueProperty.get ? el._valueGet && Object.defineProperty(el, "value", {
  1012. get: el._valueGet,
  1013. set: el._valueSet
  1014. }) : document.__lookupGetter__ && el.__lookupGetter__("value") && el._valueGet && (el.__defineGetter__("value", el._valueGet),
  1015. el.__defineSetter__("value", el._valueSet));
  1016. try {
  1017. delete el._valueGet, delete el._valueSet;
  1018. } catch (e) {
  1019. el._valueGet = void 0, el._valueSet = void 0;
  1020. }
  1021. break;
  1022. case "getmetadata":
  1023. if ($el = $(actionObj.el), maskset = $el.data("_inputmask").maskset, opts = $el.data("_inputmask").opts,
  1024. $.isArray(maskset.metadata)) {
  1025. for (var alternation, lvp = getLastValidPosition(), firstAlt = lvp; firstAlt >= 0; firstAlt--) if (getMaskSet().validPositions[firstAlt] && void 0 != getMaskSet().validPositions[firstAlt].alternation) {
  1026. alternation = getMaskSet().validPositions[firstAlt].alternation;
  1027. break;
  1028. }
  1029. return void 0 != alternation ? maskset.metadata[getMaskSet().validPositions[lvp].locator[alternation]] : maskset.metadata[0];
  1030. }
  1031. return maskset.metadata;
  1032. }
  1033. }
  1034. if (void 0 === $.fn.inputmask) {
  1035. var ua = navigator.userAgent, iphone = null !== ua.match(new RegExp("iphone", "i")), androidfirefox = (null !== ua.match(new RegExp("android.*safari.*", "i")),
  1036. null !== ua.match(new RegExp("android.*chrome.*", "i")), null !== ua.match(new RegExp("android.*firefox.*", "i"))), PasteEventType = (/Kindle/i.test(ua) || /Silk/i.test(ua) || /KFTT/i.test(ua) || /KFOT/i.test(ua) || /KFJWA/i.test(ua) || /KFJWI/i.test(ua) || /KFSOWI/i.test(ua) || /KFTHWA/i.test(ua) || /KFTHWI/i.test(ua) || /KFAPWA/i.test(ua) || /KFAPWI/i.test(ua),
  1037. isInputEventSupported("paste") ? "paste" : isInputEventSupported("input") ? "input" : "propertychange");
  1038. $.inputmask = {
  1039. defaults: {
  1040. placeholder: "_",
  1041. optionalmarker: {
  1042. start: "[",
  1043. end: "]"
  1044. },
  1045. quantifiermarker: {
  1046. start: "{",
  1047. end: "}"
  1048. },
  1049. groupmarker: {
  1050. start: "(",
  1051. end: ")"
  1052. },
  1053. alternatormarker: "|",
  1054. escapeChar: "\\",
  1055. mask: null,
  1056. oncomplete: $.noop,
  1057. onincomplete: $.noop,
  1058. oncleared: $.noop,
  1059. repeat: 0,
  1060. greedy: !0,
  1061. autoUnmask: !1,
  1062. removeMaskOnSubmit: !1,
  1063. clearMaskOnLostFocus: !0,
  1064. insertMode: !0,
  1065. clearIncomplete: !1,
  1066. aliases: {},
  1067. alias: null,
  1068. onKeyDown: $.noop,
  1069. onBeforeMask: void 0,
  1070. onBeforePaste: void 0,
  1071. onBeforeWrite: void 0,
  1072. onUnMask: void 0,
  1073. showMaskOnFocus: !0,
  1074. showMaskOnHover: !0,
  1075. onKeyValidation: $.noop,
  1076. skipOptionalPartCharacter: " ",
  1077. showTooltip: !1,
  1078. numericInput: !1,
  1079. rightAlign: !1,
  1080. undoOnEscape: !0,
  1081. radixPoint: "",
  1082. radixFocus: !1,
  1083. nojumps: !1,
  1084. nojumpsThreshold: 0,
  1085. keepStatic: void 0,
  1086. definitions: {
  1087. "9": {
  1088. validator: "[0-9]",
  1089. cardinality: 1,
  1090. definitionSymbol: "*"
  1091. },
  1092. a: {
  1093. validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  1094. cardinality: 1,
  1095. definitionSymbol: "*"
  1096. },
  1097. "*": {
  1098. validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  1099. cardinality: 1
  1100. }
  1101. },
  1102. 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 ],
  1103. isComplete: void 0,
  1104. canClearPosition: $.noop,
  1105. postValidation: void 0
  1106. },
  1107. keyCode: {
  1108. ALT: 18,
  1109. BACKSPACE: 8,
  1110. CAPS_LOCK: 20,
  1111. COMMA: 188,
  1112. COMMAND: 91,
  1113. COMMAND_LEFT: 91,
  1114. COMMAND_RIGHT: 93,
  1115. CONTROL: 17,
  1116. DELETE: 46,
  1117. DOWN: 40,
  1118. END: 35,
  1119. ENTER: 13,
  1120. ESCAPE: 27,
  1121. HOME: 36,
  1122. INSERT: 45,
  1123. LEFT: 37,
  1124. MENU: 93,
  1125. NUMPAD_ADD: 107,
  1126. NUMPAD_DECIMAL: 110,
  1127. NUMPAD_DIVIDE: 111,
  1128. NUMPAD_ENTER: 108,
  1129. NUMPAD_MULTIPLY: 106,
  1130. NUMPAD_SUBTRACT: 109,
  1131. PAGE_DOWN: 34,
  1132. PAGE_UP: 33,
  1133. PERIOD: 190,
  1134. RIGHT: 39,
  1135. SHIFT: 16,
  1136. SPACE: 32,
  1137. TAB: 9,
  1138. UP: 38,
  1139. WINDOWS: 91
  1140. },
  1141. masksCache: {},
  1142. escapeRegex: function(str) {
  1143. var specials = [ "/", ".", "*", "+", "?", "|", "(", ")", "[", "]", "{", "}", "\\", "$", "^" ];
  1144. return str.replace(new RegExp("(\\" + specials.join("|\\") + ")", "gim"), "\\$1");
  1145. },
  1146. format: function(value, options, metadata) {
  1147. var opts = $.extend(!0, {}, $.inputmask.defaults, options);
  1148. return resolveAlias(opts.alias, options, opts), maskScope({
  1149. action: "format",
  1150. value: value,
  1151. metadata: metadata
  1152. }, generateMaskSet(opts), opts);
  1153. },
  1154. isValid: function(value, options) {
  1155. var opts = $.extend(!0, {}, $.inputmask.defaults, options);
  1156. return resolveAlias(opts.alias, options, opts), maskScope({
  1157. action: "isValid",
  1158. value: value
  1159. }, generateMaskSet(opts), opts);
  1160. }
  1161. }, $.fn.inputmask = function(fn, options) {
  1162. function importAttributeOptions(npt, opts, importedOptionsContainer) {
  1163. var $npt = $(npt);
  1164. $npt.data("inputmask-alias") && resolveAlias($npt.data("inputmask-alias"), {}, opts);
  1165. for (var option in opts) {
  1166. var optionData = $npt.data("inputmask-" + option.toLowerCase());
  1167. void 0 != optionData && ("mask" == option && 0 == optionData.indexOf("[") ? (opts[option] = optionData.replace(/[\s[\]]/g, "").split("','"),
  1168. opts[option][0] = opts[option][0].replace("'", ""), opts[option][opts[option].length - 1] = opts[option][opts[option].length - 1].replace("'", "")) : opts[option] = "boolean" == typeof optionData ? optionData : optionData.toString(),
  1169. importedOptionsContainer && (importedOptionsContainer[option] = opts[option]));
  1170. }
  1171. return opts;
  1172. }
  1173. var maskset, opts = $.extend(!0, {}, $.inputmask.defaults, options);
  1174. if ("string" == typeof fn) switch (fn) {
  1175. case "mask":
  1176. return resolveAlias(opts.alias, options, opts), maskset = generateMaskSet(opts),
  1177. void 0 == maskset ? this : this.each(function() {
  1178. maskScope({
  1179. action: "mask",
  1180. el: this
  1181. }, $.extend(!0, {}, maskset), importAttributeOptions(this, opts));
  1182. });
  1183. case "unmaskedvalue":
  1184. var $input = $(this);
  1185. return $input.data("_inputmask") ? maskScope({
  1186. action: "unmaskedvalue",
  1187. $input: $input
  1188. }) : $input.val();
  1189. case "remove":
  1190. return this.each(function() {
  1191. var $input = $(this);
  1192. $input.data("_inputmask") && maskScope({
  1193. action: "remove",
  1194. el: this
  1195. });
  1196. });
  1197. case "getemptymask":
  1198. return this.data("_inputmask") ? maskScope({
  1199. action: "getemptymask",
  1200. el: this
  1201. }) : "";
  1202. case "hasMaskedValue":
  1203. return this.data("_inputmask") ? !this.data("_inputmask").opts.autoUnmask : !1;
  1204. case "isComplete":
  1205. return this.data("_inputmask") ? maskScope({
  1206. action: "isComplete",
  1207. buffer: this[0]._valueGet().split(""),
  1208. el: this
  1209. }) : !0;
  1210. case "getmetadata":
  1211. return this.data("_inputmask") ? maskScope({
  1212. action: "getmetadata",
  1213. el: this
  1214. }) : void 0;
  1215. default:
  1216. return resolveAlias(opts.alias, options, opts), resolveAlias(fn, options, opts) || (opts.mask = fn),
  1217. maskset = generateMaskSet(opts), void 0 == maskset ? this : this.each(function() {
  1218. maskScope({
  1219. action: "mask",
  1220. el: this
  1221. }, $.extend(!0, {}, maskset), importAttributeOptions(this, opts));
  1222. });
  1223. } else {
  1224. if ("object" == typeof fn) return opts = $.extend(!0, {}, $.inputmask.defaults, fn),
  1225. resolveAlias(opts.alias, fn, opts), maskset = generateMaskSet(opts), void 0 == maskset ? this : this.each(function() {
  1226. maskScope({
  1227. action: "mask",
  1228. el: this
  1229. }, $.extend(!0, {}, maskset), importAttributeOptions(this, opts));
  1230. });
  1231. if (void 0 == fn) return this.each(function() {
  1232. var attrOptions = $(this).attr("data-inputmask");
  1233. if (attrOptions && "" != attrOptions) try {
  1234. attrOptions = attrOptions.replace(new RegExp("'", "g"), '"');
  1235. var dataoptions = $.parseJSON("{" + attrOptions + "}");
  1236. $.extend(!0, dataoptions, options), opts = $.extend(!0, {}, $.inputmask.defaults, dataoptions),
  1237. opts = importAttributeOptions(this, opts), resolveAlias(opts.alias, dataoptions, opts),
  1238. opts.alias = void 0, $(this).inputmask("mask", opts);
  1239. } catch (ex) {}
  1240. if ($(this).attr("data-inputmask-mask") || $(this).attr("data-inputmask-alias")) {
  1241. opts = $.extend(!0, {}, $.inputmask.defaults, {});
  1242. var dataOptions = {};
  1243. opts = importAttributeOptions(this, opts, dataOptions), resolveAlias(opts.alias, dataOptions, opts),
  1244. opts.alias = void 0, $(this).inputmask("mask", opts);
  1245. }
  1246. });
  1247. }
  1248. };
  1249. }
  1250. return $.fn.inputmask;
  1251. });