zip_search 0.1.3

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