PageSourceSearch

https://matras-vladimir.ru/js/jquery.inputmask.js

js matras-vladimir.ru collected 2026-09-28 23:15:11 UTC 121,423 bytes, 2,102 lines download raw bytes

1/*
2* Input Mask plugin for jquery
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: 0.0.0
7*/
8
9(function ($) {
10    if ($.fn.inputmask === undefined) {
11
12        //helper functions
13        function isInputEventSupported(eventName) {
14            var el = document.createElement('input'),
15                evName = 'on' + eventName,
16                isSupported = (evName in el);
17            if (!isSupported) {
18                el.setAttribute(evName, 'return;');
19                isSupported = typeof el[evName] == 'function';
20            }
21            el = null;
22            return isSupported;
23        }
24
25        function isInputTypeSupported(inputType) {
26            var isSupported = inputType == "text" || inputType == "tel";
27            if (!isSupported) {
28                var el = document.createElement('input');
29                el.setAttribute("type", inputType);
30                isSupported = el.type === "text"; //apply mask only if the type is not natively supported
31                el = null;
32            }
33            return isSupported;
34        }
35
36        function resolveAlias(aliasStr, options, opts) {
37            var aliasDefinition = opts.aliases[aliasStr];
38            if (aliasDefinition) {
39                if (aliasDefinition.alias) resolveAlias(aliasDefinition.alias, undefined, opts); //alias is another alias
40                $.extend(true, opts, aliasDefinition); //merge alias definition in the options
41                $.extend(true, opts, options); //reapply extra given options
42                return true;
43            }
44            return false;
45        }
46
47        function generateMaskSet(opts, multi) {
48            var ms = undefined;
49
50            function analyseMask(mask) {
51                var tokenizer = /(?:[?*+]|\{[0-9\+\*]+(?:,[0-9\+\*]*)?\})\??|[^.?*+^${[]()|\\]+|./g,
52                    escaped = false;
53
54                function maskToken(isGroup, isOptional, isQuantifier, isAlternator) {
55                    this.matches = [];
56                    this.isGroup = isGroup || false;
57                    this.isOptional = isOptional || false;
58                    this.isQuantifier = isQuantifier || false;
59                    this.isAlternator = isAlternator || false;
60                    this.quantifier = { min: 1, max: 1 };
61                };
62
63                //test definition => {fn: RegExp/function, cardinality: int, optionality: bool, newBlockMarker: bool, casing: null/upper/lower, def: definitionSymbol, placeholder: placeholder, mask: real maskDefinition}
64                function insertTestDefinition(mtoken, element, position) {
65                    var maskdef = opts.definitions[element];
66                    var newBlockMarker = mtoken.matches.length == 0;
67                    position = position != undefined ? position : mtoken.matches.length;
68                    if (maskdef && !escaped) {
69                        maskdef["placeholder"] = $.isFunction(maskdef["placeholder"]) ? maskdef["placeholder"].call(this, opts) : maskdef["placeholder"];
70                        var prevalidators = maskdef["prevalidator"], prevalidatorsL = prevalidators ? prevalidators.length : 0;
71                        for (var i = 1; i < maskdef.cardinality; i++) {
72                            var prevalidator = prevalidatorsL >= i ? prevalidators[i - 1] : [], validator = prevalidator["validator"], cardinality = prevalidator["cardinality"];
73                            mtoken.matches.splice(position++, 0, { fn: validator ? typeof validator == 'string' ? new RegExp(validator) : new function () { this.test = validator; } : new RegExp("."), cardinality: cardinality ? cardinality : 1, optionality: mtoken.isOptional, newBlockMarker: newBlockMarker, casing: maskdef["casing"], def: maskdef["definitionSymbol"] || element, placeholder: maskdef["placeholder"], mask: element });
74                        }
75                        mtoken.matches.splice(position++, 0, { fn: maskdef.validator ? typeof maskdef.validator == 'string' ? new RegExp(maskdef.validator) : new function () { this.test = maskdef.validator; } : new RegExp("."), cardinality: maskdef.cardinality, optionality: mtoken.isOptional, newBlockMarker: newBlockMarker, casing: maskdef["casing"], def: maskdef["definitionSymbol"] || element, placeholder: maskdef["placeholder"], mask: element });
76                    } else {
77                        mtoken.matches.splice(position++, 0, { fn: null, cardinality: 0, optionality: mtoken.isOptional, newBlockMarker: newBlockMarker, casing: null, def: element, placeholder: undefined, mask: element });
78                        escaped = false;
79                    }
80                }
81
82                var currentToken = new maskToken(),
83                    match,
84                    m,
85                    openenings = [],
86                    maskTokens = [],
87                    openingToken,
88                    currentOpeningToken,
89                    alternator,
90                    lastMatch;
91
92                while (match = tokenizer.exec(mask)) {
93                    m = match[0];
94                    switch (m.charAt(0)) {
95                        case opts.optionalmarker.end:
96                            // optional closing
97                        case opts.groupmarker.end:
98                            // Group closing
99                            openingToken = openenings.pop();
100                            if (openenings.length > 0) {
101                                currentOpeningToken = openenings[openenings.length - 1];
102                                currentOpeningToken["matches"].push(openingToken);
103                                if (currentOpeningToken.isAlternator) {  //handle alternator (a) | (b) case
104                                    alternator = openenings.pop();
105                                    for (var mndx = 0; mndx < alternator.matches.length; mndx++) {
106                                        alternator.matches[mndx].isGroup = false; //don't mark alternate groups as group
107                                    }
108                                    if (openenings.length > 0) {
109                                        currentOpeningToken = openenings[openenings.length - 1];
110                                        currentOpeningToken["matches"].push(alternator);
111                                    } else {
112                                        currentToken.matches.push(alternator);
113                                    }
114                                }
115                            } else {
116                                currentToken.matches.push(openingToken);
117                            }
118                            break;
119                        case opts.optionalmarker.start:
120                            // optional opening
121                            openenings.push(new maskToken(false, true));
122                            break;
123                        case opts.groupmarker.start:
124                            // Group opening
125                            openenings.push(new maskToken(true));
126                            break;
127                        case opts.quantifiermarker.start:
128                            //Quantifier
129                            var quantifier = new maskToken(false, false, true);
130
131                            m = m.replace(/[{}]/g, "");
132                            var mq = m.split(","),
133                                mq0 = isNaN(mq[0]) ? mq[0] : parseInt(mq[0]),
134                                mq1 = mq.length == 1 ? mq0 : (isNaN(mq[1]) ? mq[1] : parseInt(mq[1]));
135                            if (mq1 == "*" || mq1 == "+") {
136                                mq0 = mq1 == "*" ? 0 : 1;
137                            }
138                            quantifier.quantifier = { min: mq0, max: mq1 };
139                            if (openenings.length > 0) {
140                                var matches = openenings[openenings.length - 1]["matches"];
141                                match = matches.pop();
142                                if (!match["isGroup"]) {
143                                    var groupToken = new maskToken(true);
144                                    groupToken.matches.push(match);
145                                    match = groupToken;
146                                }
147                                matches.push(match);
148                                matches.push(quantifier);
149                            } else {
150                                match = currentToken.matches.pop();
151                                if (!match["isGroup"]) {
152                                    var groupToken = new maskToken(true);
153                                    groupToken.matches.push(match);
154                                    match = groupToken;
155                                }
156                                currentToken.matches.push(match);
157                                currentToken.matches.push(quantifier);
158                            }
159                            break;
160                        case opts.escapeChar:
161                            escaped = true;
162                            break;
163                        case opts.alternatormarker:
164                            if (openenings.length > 0) {
165                                currentOpeningToken = openenings[openenings.length - 1];
166                                lastMatch = currentOpeningToken.matches.pop();
167                            } else {
168                                lastMatch = currentToken.matches.pop();
169                            }
170                            if (lastMatch.isAlternator) {
171                                openenings.push(lastMatch);
172                            } else {
173                                alternator = new maskToken(false, false, false, true);
174                                alternator.matches.push(lastMatch);
175                                openenings.push(alternator);
176                            }
177                            break;
178                        default:
179                            if (openenings.length > 0) {
180                                currentOpeningToken = openenings[openenings.length - 1];
181                                if (currentOpeningToken.matches.length > 0) {
182                                    lastMatch = currentOpeningToken.matches[currentOpeningToken.matches.length - 1];
183                                    if (lastMatch["isGroup"]) { //this is not a group but a normal mask => convert
184                                        lastMatch.isGroup = false;
185                                        insertTestDefinition(lastMatch, opts.groupmarker.start, 0);
186                                        insertTestDefinition(lastMatch, opts.groupmarker.end);
187                                    }
188                                }
189                                insertTestDefinition(currentOpeningToken, m);
190                                if (currentOpeningToken.isAlternator) {  //handle alternator a | b case
191                                    alternator = openenings.pop();
192                                    for (var mndx = 0; mndx < alternator.matches.length; mndx++) {
193                                        alternator.matches[mndx].isGroup = false; //don't mark alternate groups as group
194                                    }
195                                    if (openenings.length > 0) {
196                                        currentOpeningToken = openenings[openenings.length - 1];
197                                        currentOpeningToken["matches"].push(alternator);
198                                    } else {
199                                        currentToken.matches.push(alternator);
200                                    }
201                                }
202                            } else {
203                                if (currentToken.matches.length > 0) {
204                                    lastMatch = currentToken.matches[currentToken.matches.length - 1];
205                                    if (lastMatch["isGroup"]) { //this is not a group but a normal mask => convert
206                                        lastMatch.isGroup = false;
207                                        insertTestDefinition(lastMatch, opts.groupmarker.start, 0);
208                                        insertTestDefinition(lastMatch, opts.groupmarker.end);
209                                    }
210                                }
211                                insertTestDefinition(currentToken, m);
212                            }
213                    }
214                }
215
216                if (currentToken.matches.length > 0) {
217                    lastMatch = currentToken.matches[currentToken.matches.length - 1];
218                    if (lastMatch["isGroup"]) { //this is not a group but a normal mask => convert
219                        lastMatch.isGroup = false;
220                        insertTestDefinition(lastMatch, opts.groupmarker.start, 0);
221                        insertTestDefinition(lastMatch, opts.groupmarker.end);
222                    }
223                    maskTokens.push(currentToken);
224                }
225
226                //console.log(JSON.stringify(maskTokens));
227                return maskTokens;
228            }
229
230            function generateMask(mask, metadata) {
231                if (mask == undefined || mask == "")
232                    return undefined;
233                else {
234                    if (mask.length == 1 && opts.greedy == false && opts.repeat != 0) {
235                        opts.placeholder = "";
236                    } //hide placeholder with single non-greedy mask
237                    if (opts.repeat > 0 || opts.repeat == "*" || opts.repeat == "+") {
238                        var repeatStart = opts.repeat == "*" ? 0 : (opts.repeat == "+" ? 1 : opts.repeat);
239                        mask = opts.groupmarker.start + mask + opts.groupmarker.end + opts.quantifiermarker.start + repeatStart + "," + opts.repeat + opts.quantifiermarker.end;
240                    }
241                    if ($.inputmask.masksCache[mask] == undefined) {
242                        $.inputmask.masksCache[mask] = {
243                            "mask": mask,
244                            "maskToken": analyseMask(mask),
245                            "validPositions": {},
246                            "_buffer": undefined,
247                            "buffer": undefined,
248                            "tests": {},
249                            "metadata": metadata
250                        };
251                    }
252
253                    return $.extend(true, {}, $.inputmask.masksCache[mask]);
254                }
255            }
256            function preProcessMask(mask) {
257                mask = mask.toString();
258                if (opts.numericInput) { //TODO FIX FOR DYNAMIC MASKS WITH QUANTIFIERS
259                    mask = mask.split('').reverse();
260                    for (var ndx = 0; ndx < mask.length; ndx++) {
261                        if (mask[ndx] == opts.optionalmarker.start)
262                            mask[ndx] = opts.optionalmarker.end;
263                        else if (mask[ndx] == opts.optionalmarker.end)
264                            mask[ndx] = opts.optionalmarker.start;
265                        else if (mask[ndx] == opts.groupmarker.start)
266                            mask[ndx] = opts.groupmarker.end;
267                        else if (mask[ndx] == opts.groupmarker.end)
268                            mask[ndx] = opts.groupmarker.start;
269                    }
270                    mask = mask.join('');
271                }
272                return mask;
273            }
274
275            if ($.isFunction(opts.mask)) { //allow mask to be a preprocessing fn - should return a valid mask
276                opts.mask = opts.mask.call(this, opts);
277            }
278            if ($.isArray(opts.mask)) {
279                if (multi) {  //remove me
280                    ms = [];
281                    $.each(opts.mask, function (ndx, msk) {
282                        if (msk["mask"] != undefined && !$.isFunction(msk["mask"])) {
283                            ms.push(generateMask(preProcessMask(msk["mask"]), msk));
284                        } else {
285                            ms.push(generateMask(preProcessMask(msk), msk));
286                        }
287                    });
288                } else {
289                    opts.keepStatic = opts.keepStatic == undefined ? true : opts.keepStatic; //enable by default when passing multiple masks when the option is not explicitly specified
290                    var altMask = "(";
291                    $.each(opts.mask, function (ndx, msk) {
292                        if (altMask.length > 1)
293                            altMask += ")|(";
294                        if (msk["mask"] != undefined && !$.isFunction(msk["mask"])) {
295                            altMask += preProcessMask(msk["mask"]);
296                        } else {
297                            altMask += preProcessMask(msk);
298                        }
299                    });
300                    altMask += ")";
301                    ms = generateMask(altMask, opts.mask);
302                }
303            } else {
304                if (opts.mask) {
305                    if (opts.mask["mask"] != undefined && !$.isFunction(opts.mask["mask"])) {
306                        ms = generateMask(preProcessMask(opts.mask["mask"]), opts.mask);
307                    } else {
308                        ms = generateMask(preProcessMask(opts.mask), opts.mask);
309                    }
310                }
311            }
312            return ms;
313        }
314
315        var ua = navigator.userAgent,
316            iphone = ua.match(new RegExp("iphone", "i")) !== null,
317            android = ua.match(new RegExp("android.*safari.*", "i")) !== null,
318            androidchrome = ua.match(new RegExp("android.*chrome.*", "i")) !== null,
319            androidfirefox = ua.match(new RegExp("android.*firefox.*", "i")) !== null,
320            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),
321            PasteEventType = isInputEventSupported('paste') ? 'paste' : isInputEventSupported('input') ? 'input' : "propertychange";
322
323        //if (androidchrome) {
324        //    var browser = navigator.userAgent.match(new RegExp("chrome.*", "i")),
325        //        version = parseInt(new RegExp(/[0-9]+/).exec(browser));
326        //    androidchrome32 = (version == 32);
327        //}
328
329        //masking scope
330        //actionObj definition see below
331        function maskScope(actionObj, maskset, opts) {
332            var isRTL = false,
333                undoValue,
334                $el,
335                skipKeyPressEvent = false, //Safari 5.1.x - modal dialog fires keypress twice workaround
336                skipInputEvent = false, //skip when triggered from within inputmask
337                ignorable = false,
338                maxLength,
339                firstClick = true;
340
341            //maskset helperfunctions
342
343
344            function getMaskTemplate(baseOnInput, minimalPos, includeInput) {
345                minimalPos = minimalPos || 0;
346                var maskTemplate = [], ndxIntlzr, pos = 0, test, testPos;
347                do {
348                    if (baseOnInput === true && getMaskSet()['validPositions'][pos]) {
349                        var validPos = getMaskSet()['validPositions'][pos];
350                        test = validPos["match"];
351                        ndxIntlzr = validPos["locator"].slice();
352                        maskTemplate.push(includeInput === true ? validPos["input"] : getPlaceholder(pos, test));
353                    } else {
354                        if (minimalPos > pos) {
355                            var testPositions = getTests(pos, ndxIntlzr, pos - 1);
356                            testPos = testPositions[0];
357                        } else {
358                            testPos = getTestTemplate(pos, ndxIntlzr, pos - 1);
359                        }
360                        test = testPos["match"];
361                        ndxIntlzr = testPos["locator"].slice();
362                        maskTemplate.push(getPlaceholder(pos, test));
363                    }
364                    pos++;
365                } while ((maxLength == undefined || pos - 1 < maxLength) && test["fn"] != null || (test["fn"] == null && test["def"] != "") || minimalPos >= pos);
366                maskTemplate.pop(); //drop the last one which is empty
367                return maskTemplate;
368            }
369            function getMaskSet() {
370                return maskset;
371            }
372            function resetMaskSet(soft) {
373                var maskset = getMaskSet();
374                maskset["buffer"] = undefined;
375                maskset["tests"] = {};
376                if (soft !== true) {
377                    maskset["_buffer"] = undefined;
378                    maskset["validPositions"] = {};
379                    maskset["p"] = 0;
380                }
381            }
382            function getLastValidPosition(closestTo) {
383                var maskset = getMaskSet(), lastValidPosition = -1, valids = maskset["validPositions"];
384                if (closestTo == undefined) closestTo = -1;
385                var before = lastValidPosition, after = lastValidPosition;
386                for (var posNdx in valids) {
387                    var psNdx = parseInt(posNdx);
388                    if (closestTo == -1 || valids[psNdx]["match"].fn != null) {
389                        if (psNdx <= closestTo) before = psNdx;
390                        if (psNdx >= closestTo) after = psNdx;
391                    }
392                }
393                lastValidPosition = (closestTo - before) > 1 || after < closestTo ? before : after;
394                return lastValidPosition;
395            }
396            function setValidPosition(pos, validTest, fromSetValid) {
397                if (opts.insertMode && getMaskSet()["validPositions"][pos] != undefined && fromSetValid == undefined) {
398                    //reposition & revalidate others
399                    var positionsClone = $.extend(true, {}, getMaskSet()["validPositions"]), lvp = getLastValidPosition(), i;
400                    for (i = pos; i <= lvp; i++) { //clear selection
401                        delete getMaskSet()["validPositions"][i];
402                    }
403                    getMaskSet()["validPositions"][pos] = validTest;
404                    var valid = true, j;
405                    for (i = pos; i <= lvp ; i++) {
406                        var t = positionsClone[i];
407                        if (t != undefined) {
408                            var vps = getMaskSet()["validPositions"];
409                            if (!opts.keepStatic && vps[i] && (vps[i + 1] != undefined && getTests(i + 1, vps[i].locator.slice(), i).length > 1 || vps[i].alternation != undefined))
410                                j = i + 1;
411                            else
412                                j = seekNext(i);
413
414                            if (positionCanMatchDefinition(j, t["match"].def)) {
415                                valid = valid && (isValid(j, t["input"], true, true) !== false);
416                            } else valid = t["match"].fn == null;
417                        }
418                        if (!valid) break;
419                    }
420
421                    if (!valid) {
422                        getMaskSet()["validPositions"] = $.extend(true, {}, positionsClone);
423                        return false;
424                    }
425                } else
426                    getMaskSet()["validPositions"][pos] = validTest;
427
428                return true;
429            }
430            function stripValidPositions(start, end) {
431                var i, startPos = start;
432                if (getMaskSet()["validPositions"][start] != undefined && getMaskSet()["validPositions"][start].input == opts.radixPoint) {
433                    end++;
434                    startPos++;
435                }
436                for (i = startPos; i < end; i++) { //clear selection
437                    if (getMaskSet()["validPositions"][i] != undefined &&
438                        (getMaskSet()["validPositions"][i].input != opts.radixPoint || i == getLastValidPosition()))
439                        delete getMaskSet()["validPositions"][i];
440                }
441
442                for (i = end ; i <= getLastValidPosition() ;) {
443                    var t = getMaskSet()["validPositions"][i];
444                    var s = getMaskSet()["validPositions"][startPos];
445                    if (t != undefined && s == undefined) {
446                        if (positionCanMatchDefinition(startPos, t.match.def) && isValid(startPos, t["input"], true) !== false) {
447                            delete getMaskSet()["validPositions"][i];
448                            i++;
449                        }
450                        startPos++;
451                    } else i++;
452                }
453                //remove radixpoint if needed
454                var lvp = getLastValidPosition();
455                if (start <= lvp && getMaskSet()["validPositions"][lvp] != undefined && (getMaskSet()["validPositions"][lvp].input == opts.radixPoint))
456                    delete getMaskSet()["validPositions"][lvp];
457
458                resetMaskSet(true);
459            }
460            function getTestTemplate(pos, ndxIntlzr, tstPs) {
461                var testPositions = getTests(pos, ndxIntlzr, tstPs),
462                    testPos,
463                    lvp = getLastValidPosition(),
464                    lvTest = getMaskSet()["validPositions"][lvp] || getTests(0)[0],
465                    lvTestAltArr = (lvTest.alternation != undefined) ? lvTest["locator"][lvTest.alternation].split(",") : [];
466                for (var ndx = 0; ndx < testPositions.length; ndx++) {
467                    testPos = testPositions[ndx];
468
469                    if (opts.greedy ||
470                        ((testPos["match"] && (testPos["match"].optionality === false || testPos["match"].newBlockMarker === false) && testPos["match"].optionalQuantifier !== true) &&
471                        (lvTest.alternation == undefined ||
472                        (testPos["locator"][lvTest.alternation] != undefined && checkAlternationMatch(testPos.locator[lvTest.alternation].toString().split(","), lvTestAltArr))))) {
473                        break;
474                    }
475                }
476
477                return testPos;
478            }
479            function getTest(pos) {
480                if (getMaskSet()['validPositions'][pos]) {
481                    return getMaskSet()['validPositions'][pos]["match"];
482                }
483                return getTests(pos)[0]["match"];
484            }
485            function positionCanMatchDefinition(pos, def) {
486                var valid = false, tests = getTests(pos);
487                for (var tndx = 0; tndx < tests.length; tndx++) {
488                    if (tests[tndx]["match"] && tests[tndx]["match"].def == def) {
489                        valid = true;
490                        break;
491                    }
492                }
493                return valid;
494            };
495            function getTests(pos, ndxIntlzr, tstPs) {
496                var maskTokens = getMaskSet()["maskToken"], testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr || [0], matches = [], insertStop = false;
497                function ResolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) { //ndxInitilizer contains a set of indexes to speedup searches in the mtokens
498                    function handleMatch(match, loopNdx, quantifierRecurse) {
499                        if (testPos > 10000) {
500                            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"]);
501                            return true;
502                        }
503                        if (testPos == pos && match.matches == undefined) {
504                            matches.push({ "match": match, "locator": loopNdx.reverse() });
505                            return true;
506                        } else if (match.matches != undefined) {
507                            if (match.isGroup && quantifierRecurse !== true) { //when a group pass along to the quantifier
508                                match = handleMatch(maskToken.matches[tndx + 1], loopNdx);
509                                if (match) return true;
510                            } else if (match.isOptional) {
511                                var optionalToken = match;
512                                match = ResolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse);
513                                if (match) {
514                                    var latestMatch = matches[matches.length - 1]["match"];
515                                    var isFirstMatch = $.inArray(latestMatch, optionalToken.matches) == 0;
516                                    if (isFirstMatch) {
517                                        insertStop = true; //insert a stop for non greedy
518                                    }
519                                    testPos = pos; //match the position after the group
520                                }
521                            } else if (match.isAlternator) {
522                                var alternateToken = match, malternateMatches = [], maltMatches,
523                                    currentMatches = matches.slice(), loopNdxCnt = loopNdx.length;
524                                var altIndex = ndxInitializer.length > 0 ? ndxInitializer.shift() : -1;
525                                if (altIndex == -1 || typeof altIndex == "string") {
526                                    var currentPos = testPos, ndxInitializerClone = ndxInitializer.slice(), altIndexArr;
527                                    if (typeof altIndex == "string") altIndexArr = altIndex.split(",");
528                                    for (var amndx = 0;
528 amndx < alternateToken.matches.length; amndx++) {
529                                        matches = [];
530                                        match = handleMatch(alternateToken.matches[amndx], [amndx].concat(loopNdx), quantifierRecurse) || match;
531                                        maltMatches = matches.slice();
532                                        testPos = currentPos;
533                                        matches = [];
534                                        //cloneback
535                                        for (var i = 0; i < ndxInitializerClone.length; i++) {
536                                            ndxInitializer[i] = ndxInitializerClone[i];
537                                        }
538                                        //fuzzy merge matches
539                                        for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) {
540                                            var altMatch = maltMatches[ndx1];
541                                            for (var ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) {
542                                                var altMatch2 = malternateMatches[ndx2];
543                                                //verify equality
544                                                if (altMatch.match.mask == altMatch2.match.mask && (typeof altIndex != "string" || $.inArray(altMatch.locator[loopNdxCnt].toString(), altIndexArr) != -1)) {
545                                                    maltMatches.splice(ndx1, 1);
546                                                    altMatch2.locator[loopNdxCnt] = altMatch2.locator[loopNdxCnt] + "," + altMatch.locator[loopNdxCnt];
547                                                    altMatch2.alternation = loopNdxCnt; //we pass the alternation index => used in determineLastRequiredPosition
548                                                    break;
549                                                }
550                                            }
551                                        }
552                                        malternateMatches = malternateMatches.concat(maltMatches);
553                                    }
554
555                                    if (typeof altIndex == "string") { //filter matches
556                                        malternateMatches = $.map(malternateMatches, function (lmnt, ndx) {
557                                            if (isFinite(ndx)) {
558                                                var altLocArr = lmnt.locator[loopNdxCnt].toString().split(",");
559                                                var mamatch;
560                                                lmnt.locator[loopNdxCnt] = undefined;
561                                                lmnt.alternation = undefined;
562                                                for (var alndx = 0; alndx < altLocArr.length; alndx++) {
563                                                    mamatch = $.inArray(altLocArr[alndx], altIndexArr) != -1;
564                                                    if (mamatch) { //rebuild the locator with valid entries
565                                                        if (lmnt.locator[loopNdxCnt] != undefined) {
566                                                            lmnt.locator[loopNdxCnt] += ",";
567                                                            lmnt.alternation = loopNdxCnt; //only define alternation when there is more then 1 possibility
568                                                            lmnt.locator[loopNdxCnt] += altLocArr[alndx];
569                                                        } else
570                                                            lmnt.locator[loopNdxCnt] = parseInt(altLocArr[alndx]);
571                                                    }
572                                                }
573                                                if (lmnt.locator[loopNdxCnt] != undefined) return lmnt;
574                                            }
575                                        });
576                                    }
577
578                                    matches = currentMatches.concat(malternateMatches);
579                                    //console.log("alternates " + pos + " -> " + JSON.stringify(matches));
580                                    insertStop = true; //insert a stopelemnt when there is an alternate
581                                } else {
582                                    match = handleMatch(alternateToken.matches[altIndex], [altIndex].concat(loopNdx), quantifierRecurse);
583                                }
584                                if (match) return true;
585                            } else if (match.isQuantifier && quantifierRecurse !== true) {
586                                var qt = match;
587                                opts.greedy = opts.greedy && isFinite(qt.quantifier.max); //greedy must be off when * or + is used (always!!)
588                                for (var qndx = (ndxInitializer.length > 0 && quantifierRecurse !== true) ? ndxInitializer.shift() : 0; (qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max)) && testPos <= pos; qndx++) {
589                                    var tokenGroup = maskToken.matches[$.inArray(qt, maskToken.matches) - 1];
590                                    match = handleMatch(tokenGroup, [qndx].concat(loopNdx), true);
591                                    if (match) {
592                                        //get latest match
593                                        var latestMatch = matches[matches.length - 1]["match"];
594                                        latestMatch.optionalQuantifier = qndx > (qt.quantifier.min - 1);
595                                        var isFirstMatch = $.inArray(latestMatch, tokenGroup.matches) == 0;
596
597                                        if (isFirstMatch) { //search for next possible match
598                                            if (qndx > (qt.quantifier.min - 1)) {
599                                                insertStop = true;
600                                                testPos = pos; //match the position after the group
601                                                break; //stop quantifierloop
602                                            } else return true;
603                                        } else {
604                                            return true;
605                                        }
606                                    }
607                                }
608                            } else {
609                                match = ResolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse);
610                                if (match)
611                                    return true;
612                            }
613                        } else testPos++;
614                    }
615
616                    for (var tndx = (ndxInitializer.length > 0 ? ndxInitializer.shift() : 0) ; tndx < maskToken.matches.length; tndx++) {
617                        if (maskToken.matches[tndx]["isQuantifier"] !== true) {
618                            var match = handleMatch(maskToken.matches[tndx], [tndx].concat(loopNdx), quantifierRecurse);
619                            if (match && testPos == pos) {
620                                return match;
621                            } else if (testPos > pos) {
622                                break;
623                            }
624                        }
625                    }
626                }
627
628                //if (disableCache !== true && getMaskSet()['tests'][pos] && !getMaskSet()['validPositions'][pos]) {
629                //    return getMaskSet()['tests'][pos];
630                //}
631                if (ndxIntlzr == undefined) {
632                    var previousPos = pos - 1, test;
633                    while ((test = getMaskSet()['validPositions'][previousPos]) == undefined && previousPos > -1) {
634                        previousPos--;
635                    }
636                    if (test != undefined && previousPos > -1) {
637                        testPos = previousPos;
638                        ndxInitializer = test["locator"].slice();
639                    } else {
640                        previousPos = pos - 1;
641                        while ((test = getMaskSet()['tests'][previousPos]) == undefined && previousPos > -1) {
642                            previousPos--;
643                        }
644                        if (test != undefined && previousPos > -1) {
645                            testPos = previousPos;
646                            ndxInitializer = test[0]["locator"].slice();
647                        }
648                    }
649                }
650                for (var mtndx = ndxInitializer.shift() ; mtndx < maskTokens.length; mtndx++) {
651                    var match = ResolveTestFromToken(maskTokens[mtndx], ndxInitializer, [mtndx]);
652                    if ((match && testPos == pos) || testPos > pos) {
653                        break;
654                    }
655                }
656                if (matches.length == 0 || insertStop)
657                    matches.push({ "match": { fn: null, cardinality: 0, optionality: true, casing: null, def: "" }, "locator": [] });
658
659                getMaskSet()['tests'][pos] = $.extend(true, [], matches);
659 //set a clone to prevent overwriting some props
660                //console.log(pos + " - " + JSON.stringify(matches));
661                return getMaskSet()['tests'][pos];
662            }
663            function getBufferTemplate() {
664                if (getMaskSet()['_buffer'] == undefined) {
665                    //generate template
666                    getMaskSet()["_buffer"] = getMaskTemplate(false, 1);
667                }
668                return getMaskSet()['_buffer'];
669            }
670            function getBuffer() {
671                if (getMaskSet()['buffer'] == undefined) {
672                    getMaskSet()['buffer'] = getMaskTemplate(true, getLastValidPosition(), true);
673                }
674                return getMaskSet()['buffer'];
675            }
676            function refreshFromBuffer(start, end, buffer) {
677                buffer = buffer || getBuffer().slice(); //pass or work on clone
678                if (start === true) {
679                    resetMaskSet();
680                    start = 0;
681                    end = buffer.length;
682                } else {
683                    for (var i = start; i < end; i++) {
684                        delete getMaskSet()["validPositions"][i];
685                        delete getMaskSet()["tests"][i];
686                    }
687                }
688
689                for (var i = start; i < end; i++) {
690                    if (buffer[i] != opts.skipOptionalPartCharacter) {
691                        isValid(i, buffer[i], true, true);
692                    }
693                }
694            }
695            function casing(elem, test) {
696                switch (test.casing) {
697                    case "upper":
698                        elem = elem.toUpperCase();
699                        break;
700                    case "lower":
701                        elem = elem.toLowerCase();
702                        break;
703                }
704
705                return elem;
706            }
707            function checkAlternationMatch(altArr1, altArr2) {
708                var altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1),
709                    isMatch = false;
710                for (var alndx = 0; alndx < altArr1.length; alndx++) {
711                    if ($.inArray(altArr1[alndx], altArrC) != -1) {
712                        isMatch = true;
713                        break;
714                    }
715                }
716                return isMatch;
717            }
718            function isValid(pos, c, strict, fromSetValid) { //strict true ~ no correction or autofill
719                strict = strict === true; //always set a value to strict to prevent possible strange behavior in the extensions 
720
721                function _isValid(position, c, strict, fromSetValid) {
722                    var rslt = false;
723                    $.each(getTests(position), function (ndx, tst) {
724                        var test = tst["match"];
725                        var loopend = c ? 1 : 0, chrs = '', buffer = getBuffer();
726                        for (var i = test.cardinality; i > loopend; i--) {
727                            chrs += getBufferElement(position - (i - 1));
728                        }
729                        if (c) {
730                            chrs += c;
731                        }
732
733                        //return is false or a json object => { pos: ??, c: ??} or true
734                        rslt = test.fn != null ?
735                            test.fn.test(chrs, getMaskSet(), position, strict, opts)
736                            : (c == test["def"] || c == opts.skipOptionalPartCharacter) && test["def"] != "" ? //non mask
737                            { c: test["def"], pos: position }
738                            : false;
739
740                        if (rslt !== false) {
741                            var elem = rslt.c != undefined ? rslt.c : c;
742                            elem = (elem == opts.skipOptionalPartCharacter && test["fn"] === null) ? test["def"] : elem;
743
744                            var validatedPos = position;
745                            if (rslt["remove"] != undefined) { //remove position
746                                stripValidPositions(rslt["remove"], rslt["remove"] + 1);
747                            }
748
749                            if (rslt["refreshFromBuffer"]) {
750                                var refresh = rslt["refreshFromBuffer"];
751                                strict = true;
752                                refreshFromBuffer(refresh === true ? refresh : refresh["start"], refresh["end"]);
753                                if (rslt.pos == undefined && rslt.c == undefined) {
754                                    rslt.pos = getLastValidPosition();
755                                    return false;//breakout if refreshFromBuffer && nothing to insert
756                                }
757                                validatedPos = rslt.pos != undefined ? rslt.pos : position;
758                                if (validatedPos != position) {
759                                    rslt = $.extend(rslt, isValid(validatedPos, elem, true)); //revalidate new position strict
760                                    return false;
761                                }
762
763                            } else if (rslt !== true && rslt.pos != undefined && rslt["pos"] != position) { //their is a position offset
764                                validatedPos = rslt["pos"];
765                                refreshFromBuffer(position, validatedPos);
766                                if (validatedPos != position) {
767                                    rslt = $.extend(rslt, isValid(validatedPos, elem, true)); //revalidate new position strict
768                                    return false;
769                                }
770                            }
771
772                            if (rslt != true && rslt.pos == undefined && rslt.c == undefined) {
773                                return false; //breakout if nothing to insert
774                            }
775
776                            if (ndx > 0) {
777                                resetMaskSet(true);
778                            }
779
780                            if (!setValidPosition(validatedPos, $.extend({}, tst, { "input": casing(elem, test) }), fromSetValid))
781                                rslt = false;
782                            return false; //break from $.each
783                        }
784                    });
785
786                    return rslt;
787                }
788                function alternate(pos, c, strict, fromSetValid) {
789                    var validPsClone = $.extend(true, {}, getMaskSet()["validPositions"]),
790                        lastAlt,
791                        alternation;
792                    //find last alternation
793                    for (lastAlt = getLastValidPosition() ; lastAlt >= 0; lastAlt--) {
794                        if (getMaskSet()["validPositions"][lastAlt] && getMaskSet()["validPositions"][lastAlt].alternation != undefined) {
795                            alternation = getMaskSet()["validPositions"][lastAlt].alternation;
796                            break;
797                        }
798                    }
799                    if (alternation != undefined) {
800                        //find first decision making position
801                        for (var decisionPos in getMaskSet()["validPositions"]) {
802                            if (parseInt(decisionPos) > parseInt(lastAlt) && getMaskSet()["validPositions"][decisionPos].alternation === undefined) {
803                                var altPos = getMaskSet()["validPositions"][decisionPos],
804                                    decisionTaker = altPos.locator[alternation],
805                                    altNdxs = getMaskSet()["validPositions"][lastAlt].locator[alternation].split(",");
806
807                                for (var mndx = 0; mndx < altNdxs.length; mndx++) {
808                                    if (decisionTaker < altNdxs[mndx]) {
809                                        var possibilityPos, possibilities;
810                                        for (var dp = decisionPos - 1; dp >= 0; dp--) {
811                                            possibilityPos = getMaskSet()["validPositions"][dp];
812                                            if (possibilityPos != undefined) {
813                                                possibilities = possibilityPos.locator[alternation]; //store to reset 
814                                                possibilityPos.locator[alternation] = altNdxs[mndx];
815                                                break;
816                                            }
817                                        }
818                                        if (decisionTaker != possibilityPos.locator[alternation]) {
819                                            var buffer = getBuffer().slice(); //work on clone
820                                            for (var i = decisionPos; i < getLastValidPosition() + 1; i++) {
821                                                delete getMaskSet()["validPositions"][i];
822                                                delete getMaskSet()["tests"][i];
823                                            }
824                                            resetMaskSet(true); //clear getbuffer
825                                            opts.keepStatic = !opts.keepStatic; //disable keepStatic on getMaskLength
826                                            for (var i = decisionPos; i < buffer.length; i++) {
827                                                if (buffer[i] != opts.skipOptionalPartCharacter) {
828                                                    isValid(getLastValidPosition() + 1, buffer[i], false, true);
829                                                }
830                                            }
831                                            possibilityPos.locator[alternation] = possibilities; //reset forceddecision ~ needed for proper delete
832                                            var isValidRslt = isValid(pos, c, strict, fromSetValid);
833                                            opts.keepStatic = !opts.keepStatic; //enable keepStatic on getMaskLength
834                                            if (!isValidRslt) {
835                                                resetMaskSet();
836                                                getMaskSet()["validPositions"] 
836= $.extend(true, {}, validPsClone);
837                                            } else
838                                                return isValidRslt;
839                                        }
840                                    }
841                                }
842                                break;
843                            }
844                        }
845                    }
846                    return false;
847                }
848                //set alternator choice on previous skipped placeholder positions
849                function trackbackAlternations(originalPos, newPos) {
850                    var vp = getMaskSet()["validPositions"][newPos],
851                         targetLocator = vp.locator,
852                         tll = targetLocator.length;
853
854                    for (var ps = originalPos; ps < newPos; ps++) {
855                        if (!isMask(ps)) {
856                            var tests = getTests(ps),
857                            bestMatch = tests[0], equality = -1;
858                            $.each(tests, function (ndx, tst) {
859                                for (var i = 0; i < tll; i++) {
860                                    if (tst.locator[i] && checkAlternationMatch(tst.locator[i].toString().split(','), targetLocator[i].toString().split(',')) && equality < i) {
861                                        equality = i;
862                                        bestMatch = tst;
863                                    }
864                                }
865                            });
866                            setValidPosition(ps, $.extend({}, bestMatch, { "input": bestMatch["match"].def }), true)
867                        }
868                    }
869                }
870                //Check for a nonmask before the pos
871                var buffer = getBuffer();
872                for (var pndx = pos - 1; pndx > -1; pndx--) {
873                    if (getMaskSet()["validPositions"][pndx] && getMaskSet()["validPositions"][pndx]["match"].fn == null)
874                        break;
875                    else if (getMaskSet()["validPositions"][pndx] == undefined && (!isMask(pndx) || buffer[pndx] != getPlaceholder(pndx)) && getTests(pndx).length > 1) {
876                        _isValid(pndx, buffer[pndx], true);
877                    }
878                }
879
880                var maskPos = pos;
881                var result = false;
882
883                if (fromSetValid && maskPos >= getMaskLength()) {
884                    resetMaskSet(true); //masklenght can be altered on the process => reset to get the actual length
885                }
886                if (maskPos < getMaskLength()) {
887                    result = _isValid(maskPos, c, strict, fromSetValid);
888                    if (!strict && result === false) {
889                        var currentPosValid = getMaskSet()["validPositions"][maskPos];
890                        if (currentPosValid && currentPosValid["match"].fn == null && (currentPosValid["match"].def == c || c == opts.skipOptionalPartCharacter)) {
891                            result = { "caret": seekNext(maskPos) };
892                        } else if ((opts.insertMode || getMaskSet()["validPositions"][seekNext(maskPos)] == undefined) && !isMask(maskPos)) { //does the input match on a further position?
893                            for (var nPos = maskPos + 1, snPos = seekNext(maskPos) ; nPos <= snPos; nPos++) {
894                                result = _isValid(nPos, c, strict, fromSetValid);
895                                if (result !== false) {
896                                    trackbackAlternations(maskPos, nPos);
897                                    maskPos = nPos;
898                                    break;
899                                }
900                            }
901                        }
902                    }
903                }
904                if (result === false && opts.keepStatic && isComplete(buffer)) { //try fuzzy alternator logic
905                    result = alternate(pos, c, strict, fromSetValid);
906                }
907                if (result === true) result = { "pos": maskPos };
908                return result;
909            }
910            function isMask(pos) {
911                var test = getTest(pos);
912                return test.fn != null ? test.fn : false;
913            }
914            function getMaskLength() {
915                var maskLength;
916                maxLength = $el.prop('maxLength');
917                if (maxLength == -1) maxLength = undefined; /* FF sets no defined max length to -1 */
918                if (opts.greedy == false) {
919                    var pos, lvp = getLastValidPosition(), testPos = getMaskSet()["validPositions"][lvp],
920                        ndxIntlzr = testPos != undefined ? testPos["locator"].slice() : undefined;
921                    for (pos = lvp + 1; testPos == undefined || (testPos["match"]["fn"] != null || (testPos["match"]["fn"] == null && testPos["match"]["def"] != "")) ; pos++) {
922                        testPos = getTestTemplate(pos, ndxIntlzr, pos - 1);
923                        ndxIntlzr = testPos["locator"].slice();
924                    }
925                    maskLength = pos;
926                } else
927                    maskLength = getBuffer().length;
928
929                return (maxLength == undefined || maskLength < maxLength) ? maskLength : maxLength;
930            }
931            function seekNext(pos) {
932                var maskL = getMaskLength();
933                if (pos >= maskL) return maskL;
934                var position = pos;
935                while (++position < maskL && !isMask(position) && (opts.nojumps !== true || opts.nojumpsThreshold > position)) {
936                }
937                return position;
938            }
939            function seekPrevious(pos) {
940                var position = pos;
941                if (position <= 0) return 0;
942
943                while (--position > 0 && !isMask(position)) {
944                };
945                return position;
946            }
947            function getBufferElement(position) {
948                return getMaskSet()["validPositions"][position] == undefined ? getPlaceholder(position) : getMaskSet()["validPositions"][position]["input"];
949            }
950            function writeBuffer(input, buffer, caretPos) {
951                input._valueSet(buffer.join(''));
952                if (caretPos != undefined) {
953                    caret(input, caretPos);
954                }
955            }
956            function getPlaceholder(pos, test) {
957                test = test || getTest(pos);
958                return test["placeholder"] != undefined ? test["placeholder"] : (test["fn"] == null ? test["def"] : opts.placeholder.charAt(pos % opts.placeholder.length));
959            }
960            function checkVal(input, writeOut, strict, nptvl) {
961                var inputValue = nptvl != undefined ? nptvl.slice() : input._valueGet().split('');
962                resetMaskSet();
963                if (writeOut) input._valueSet(""); //initial clear
964
965                var staticInput = getBufferTemplate().slice(0, seekNext(-1)).join(''), matches = inputValue.join('').match(new RegExp(escapeRegex(staticInput), "g"));
966                if (matches && matches.length > 1) {
967                    inputValue.splice(0, staticInput.length);
968                }
969
970                $.each(inputValue, function (ndx, charCode) {
971                    var keypress = $.Event("keypress");
972                    keypress.which = charCode.charCodeAt(0);
973                    var lvp = getLastValidPosition(), lvTest = getMaskSet()["validPositions"][lvp], nextTest = getTestTemplate(lvp + 1, lvTest ? lvTest.locator.slice() : undefined, lvp);
974                    if ($.inArray(charCode, getBufferTemplate().slice(lvp + 1, getMaskSet()["p"])) == -1 || strict) {
975                        var pos = strict ? ndx : (nextTest["match"].fn == null && (lvp + 1) < getMaskSet()["p"] ? lvp + 1 : getMaskSet()["p"]);
976                        keypressEvent.call(input, keypress, true, false, strict, pos);
977                        strict = strict || (ndx > 0 && ndx > getMaskSet()["p"]);
978                    } else {
979                        keypressEvent.call(input, keypress, true, false, true, lvp + 1);
980                    }
981
982                });
983                if (writeOut) {
984                    var keypressResult = opts.onKeyPress.call(this, undefined, getBuffer(), 0, opts);
985                    handleOnKeyResult(input, keypressResult);
986                    writeBuffer(input, getBuffer(), $(input).is(":focus") ? seekNext(getLastValidPosition(0)) : undefined);
987                }
988            }
989            function escapeRegex(str) {
990                return $.inputmask.escapeRegex.call(this, str);
991            }
992            function unmaskedvalue($input) {
993                if ($input.data('_inputmask') && !$input.hasClass('hasDatepicker')) {
994                    var umValue = [], vps = getMaskSet()["validPositions"];
995                    for (var pndx in vps) {
996                        if (vps[pndx]["match"] && vps[pndx]["match"].fn != null) {
997                            umValue.push(vps[pndx]["input"]);
998                        }
999                    }
1000                    var unmaskedValue = (isRTL ? umValue.reverse() : umValue).join('');
1001                    var bufferValue = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join('');
1002                    if ($.isFunction(opts.onUnMask)) {
1003                        unmaskedValue = (opts.onUnMask.call($input, bufferValue, unmaskedValue, opts) || unmaskedValue);
1004                    }
1005                    return unmaskedValue;
1006                } else {
1007                    return $input[0]._valueGet();
1008                }
1009            }
1010            function TranslatePosition(pos) {
1011                if (isRTL && typeof pos == 'number' && (!opts.greedy || opts.placeholder != "")) {
1012                    var bffrLght = getBuffer().length;
1013                    pos = bffrLght - pos;
1014                }
1015                return pos;
1016            }
1017            function caret(input, begin, end) {
1018                var npt = input.jquery && input.length > 0 ? input[0] : input, range;
1019                if (typeof begin == 'number') {
1020                    begin = TranslatePosition(begin);
1021                    end = TranslatePosition(end);
1022                    end = (typeof end == 'number') ? end : begin;
1023
1024                    //store caret for multi scope
1025                    var data = $(npt).data('_inputmask') || {};
1026                    data["caret"] = { "begin": begin, "end": end };
1027                    $(npt).data('_inputmask', data);
1028
1029                    if (!$(npt).is(":visible")) {
1030                        return;
1031                    }
1032
1033                    var scrollCalc = $(npt).css("font-size").replace("px", "") * end;
1034                    npt.scrollLeft = scrollCalc > npt.scrollWidth ? scrollCalc : 0;
1035                    if (opts.insertMode == false && begin == end) end++; //set visualization for insert/overwrite mode
1036                    if (npt.setSelectionRange) {
1037                        npt.selectionStart = begin;
1038                        npt.selectionEnd = end;
1039
1040                    } else if (npt.createTextRange) {
1041                        range = npt.createTextRange();
1042                        range.collapse(true);
1043                        range.moveEnd('character', end);
1044                        range.moveStart('character', begin);
1045                        range.select();
1046                    }
1047                } else {
1048                    var data = $(npt).data('_inputmask');
1049                    if (!$(npt).is(":visible") && data && data["caret"] != undefined) {
1050                        begin = data["caret"]["begin"];
1051                        end = data["caret"]["end"];
1052                    } else if (npt.setSelectionRange) {
1053                        begin = npt.selectionStart;
1054                        end = npt.selectionEnd;
1055                    } else if (document.selection && document.selection.createRange) {
1056                        range = document.selection.createRange();
1057                        begin = 0 - range.duplicate().moveStart('character', -100000);
1058                        end = begin + range.text.length;
1059                    }
1060                    begin = TranslatePosition(begin);
1061                    end = TranslatePosition(end);
1062                    return { "begin": begin, "end": end };
1063                }
1064            }
1065            function determineLastRequiredPosition(returnDefinition) {
1066                var buffer = getBuffer(), bl = buffer.length,
1067                   pos, lvp = getLastValidPosition(), positions = {}, lvTest = getMaskSet()["validPositions"][lvp],
1068                   ndxIntlzr = lvTest != undefined ? lvTest["locator"].slice() : undefined, testPos;
1069                for (pos = lvp + 1; pos < buffer.length; pos++) {
1070                    testPos = getTestTemplate(pos, ndxIntlzr, pos - 1);
1071                    ndxIntlzr = testPos["locator"].slice();
1072                    positions[pos] = $.extend(true, {}, testPos);
1073                }
1074
1075                var lvTestAltArr = lvTest && lvTest.alternation != undefined ? lvTest["locator"][lvTest.alternation].split(",") : [];
1076                for (pos = bl - 1; pos > lvp; pos--) {
1077                    testPos = positions[pos]["match"];
1078                    if ((testPos.optionality ||
1079                        testPos.optionalQuantifier ||
1080                        (lvTest && lvTest.alternation != undefined && positions[pos]["locator"][lvTest.alternation] != undefined && $.inArray(positions[pos]["locator"][lvTest.alternation].toString(), lvTestAltArr) != -1))
1081                        && buffer[pos] == getPlaceholder(pos, testPos)) {
1082                        bl--;
1083                    } else break;
1084                }
1085                return returnDefinition ? { "l": bl, "def": positions[bl] ? positions[bl]["match"] : undefined } : bl;
1086            }
1087            function clearOptionalTail(buffer) {
1088                var rl = determineLastRequiredPosition(), lmib = buffer.length - 1;
1089                for (; lmib > rl; lmib--) {
1090                    if (isMask(lmib)) break; //fixme ismask is not good enough
1091                }
1092                buffer.splice(rl, lmib + 1 - rl);
1093            }
1094            function isComplete(buffer) { //return true / false / undefined (repeat *)
1095                if ($.isFunction(opts.isComplete)) return opts.isComplete.call($el, buffer, opts);
1096                if (opts.repeat == "*") return undefined;
1097                var complete = false, lrp = determineLastRequiredPosition(true), aml = seekPrevious(lrp["l"]), lvp = getLastValidPosition();
1098
1099                if (lvp == aml) {
1100                    if (lrp["def"] == undefined || lrp["def"].newBlockMarker || lrp["def"].optionalQuantifier) {
1101                        complete = true;
1102                        for (var i = 0; i <= aml; i++) {
1103                            var mask = isMask(i);
1104                            if ((mask && (buffer[i] == undefined || buffer[i] == getPlaceholder(i))) || (!mask && buffer[i] != getPlaceholder(i))) {
1105                                complete = false;
1106                                break;
1107                            }
1108                        }
1109                    }
1110                }
1111                return complete;
1112            }
1113            function isSelection(begin, end) {
1114                return isRTL ? (begin - end) > 1 || ((begin - end) == 1 && opts.insertMode) :
1115                (end - begin) > 1 || ((end - begin) == 1 && opts.insertMode);
1116            }
1117            function installEventRuler(npt) {
1118                var events = $._data(npt).events;
1119
1120                $.each(events, function (eventType, eventHandlers) {
1121                    $.each(eventHandlers, function (ndx, eventHandler) {
1122                        if (eventHandler.namespace == "inputmask") {
1123                            if (eventHandler.type != "setvalue") {
1124                                var handler = eventHandler.handler;
1125                                eventHandler.handler = function (e) {
1126                                    //console.log(e.type);
1127                                    if (this.readOnly || this.disabled)
1128                                        e.preventDefault;
1129                                    else {
1130                                        switch (e.type) {
1131                                            case "input":
1132                                                if (skipInputEvent === true) {
1133                                                    skipInputEvent = false;
1134                                                    return e.preventDefault;
1135                                                }
1136                                                break;
1137                                            case "keydown":
1138                                                //Safari 5.1.x - modal dialog fires keypress twice workaround
1139                                                skipKeyPressEvent = false;
1140                                                break;
1141                                            case "keypress":
1142                                                if (skipKeyPressEvent === true)
1143                                                    return e.preventDefault;
1144                                                skipKeyPressEvent = true;
1145                                                break;
1146                                            case "compositionupdate": case "compositionend":
1147                                                skipInputEvent = true; //stop inutFallback
1148                                                break;
1149                                        }
1150                                        return handler.apply(this, arguments);
1151                                    }
1152                                };
1153                            }
1154                        }
1155                    });
1156                });
1157            }
1158            function patchValueProperty(npt) {
1159                var valueGet;
1160                var valueSet;
1161                function PatchValhook(type) {
1162                    if ($.valHooks[type] == undefined || $.valHooks[type].inputmaskpatch != true) {
1163                        var valhookGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function (elem) { return elem.value; };
1164                        var valhookSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function (elem, value) {
1165                            elem.value = value;
1166                            return elem;
1167                        };
1168
1169                        $.valHooks[type] = {
1170                            get: function (elem) {
1171                                var $elem = $(elem);
1172                                if ($elem.data('_inputmask')) {
1173                                    if ($elem.data('_inputmask')['opts'].autoUnmask)
1174                                        return $elem.inputmask('unmaskedvalue');
1175                                    else {
1176                                        var result = valhookGet(elem),
1177                                            inputData = $elem.data('_inputmask'),
1178                                            maskset = inputData['maskset'],
1179                                            bufferTemplate = maskset['_buffer'];
1180                                        bufferTemplate = bufferTemplate ? bufferTemplate.join('') : '';
1181                                        return result != bufferTemplate ? result : '';
1182                                    }
1183                                } else return valhookGet(elem);
1184                            },
1185                            set: function (elem, value) {
1186                                var $elem = $(elem), inputData = $elem.data('_inputmask'), result;
1187                                if (inputData) {
1188                                    result = valhookSet(elem, $.isFunction(inputData['opts'].onBeforeMask) ? (inputData['opts'].onBeforeMask.call(el, value, inputData['opts']) || value) : value);
1189                                    $elem.triggerHandler('setvalue.inputmask');
1190                                } else {
1191                                    result = valhookSet(elem, value);
1192                                }
1193                                return result;
1194                            },
1195                            inputmaskpatch: true
1196                        };
1197                    }
1198                }
1199                function getter() {
1200                    var $self = $(this), inputData = $(this).data('_inputmask');
1201                    if (inputData) {
1202                        return inputData['opts'].autoUnmask ? $self.inputmask('unmaskedvalue') : (valueGet.call(this) != getBufferTemplate().join('') ? valueGet.call(this) : '');
1203                    } else return valueGet.call(this);
1204                }
1205                function setter(value) {
1206                    var inputData = $(this).data('_inputmask');
1207                    if (inputData) {
1208                        valueSet.call(this, $.isFunction(inputData['opts'].onBeforeMask) ? (inputData['opts'].onBeforeMask.call(el, value, inputData['opts']) || value) : value);
1209                        $(this).triggerHandler('setvalue.inputmask');
1210                    } else {
1211                        valueSet.call(this, value);
1212                    }
1213                }
1214                function InstallNativeValueSetFallback(npt) {
1215                    $(npt).bind("mouseenter.inputmask", function (event) {
1216                        var $input = $(this), input = this, value = input._valueGet();
1217                        if (value != "" && value != getBuffer().join('')) {
1218                            this._valueSet($.isFunction(opts.onBeforeMask) ? (opts.onBeforeMask.call(el, value, opts) || value) : value);
1219                            $input.trigger("setvalue");
1220                        }
1221                    });
1222                    //!! the bound handlers are executed in the order they where bound
1223                    //reorder the events - the mouseenter event is internally mapped to the mouseover event
1224                    var events = $._data(npt).events;
1225                    var handlers = events["mouseover"];
1226                    if (handlers) {
1227                        var ourHandler = handlers[handlers.length - 1];
1228                        for (var i = handlers.length - 1; i > 0; i--) {
1229                            handlers[i] = handlers[i - 1];
1230                        }
1231                        handlers[0] = ourHandler;
1232                    }
1233                }
1234
1235                if (!npt._valueGet) {
1236                    //var valueProperty;
1237                    if (Object.getOwnPropertyDescriptor)
1238                        var valueProperty = Object.getOwnPropertyDescriptor(npt, "value");
1239                    if (valueProperty && valueProperty.configurable && false) { //experimental for chrome
1240                        npt._value = valueProperty.value;
1241                        valueGet = function () {
1242                            return this._value || "";
1243                        }
1244                        valueSet = function (value) {
1245                            this._value = value;
1246                            this.select();
1247                            this.setRangeText(value);
1248                            this.selectionStart = this.selectionEnd;
1249                        }
1250
1251                        Object.defineProperty(npt, "value", {
1252                            get: getter,
1253                            set: setter
1254                        });
1255                    } else if (document.__lookupGetter__ && npt.__lookupGetter__("value")) {
1256                        valueGet = npt.__lookupGetter__("value");
1257                        valueSet = npt.__lookupSetter__("value");
1258
1259                        npt.__defineGetter__("value", getter);
1260                        npt.__defineSetter__("value", setter);
1261                    } else { //jquery.val 
1262                        valueGet = function () { return npt.value; }
1263                        valueSet = function (value) { npt.value = value; }
1264                        PatchValhook(npt.type);
1265                        InstallNativeValueSetFallback(npt);
1266                    }
1267                    npt._valueGet = function () {
1268                        return isRTL ? valueGet.call(this).split('').reverse().join('') : valueGet.call(this);
1269                    };
1270                    npt._valueSet = function (value) {
1271                        valueSet.call(this, isRTL ? value.split('').reverse().join('') : value);
1272                    };
1273                }
1274            }
1275            function handleRemove(input, k, pos) {
1276                function generalize() {
1277                    if (opts.keepStatic) {
1278                        resetMaskSet(true);
1279                        var validInputs = [],
1280                          lastAlt;
1281                        //find last alternation
1282                        for (lastAlt = getLastValidPosition() ; lastAlt >= 0; lastAlt--) {
1283                            if (getMaskSet()["validPositions"][lastAlt]) {
1284                                if (getMaskSet()["validPositions"][lastAlt].alternation != undefined) {
1285                                    break;
1286                                }
1287                                validInputs.push(getMaskSet()["validPositions"][lastAlt].input);
1288                                delete getMaskSet()["validPositions"][lastAlt];
1289                            }
1290                        }
1291                        if (lastAlt > 0) {
1292                            while (validInputs.length > 0) {
1293                                getMaskSet()["p"] = seekNext(getLastValidPosition());
1294                                var keypress = $.Event("keypress");
1295                                keypress.which = validInputs.pop().charCo
1295deAt(0);
1296                                keypressEvent.call(input, keypress, true, false, false, getMaskSet()["p"]);
1297                            }
1298                        }
1299                    }
1300                }
1301
1302                if (opts.numericInput || isRTL) {
1303                    if (k == $.inputmask.keyCode.BACKSPACE)
1304                        k = $.inputmask.keyCode.DELETE;
1305                    else if (k == $.inputmask.keyCode.DELETE)
1306                        k = $.inputmask.keyCode.BACKSPACE;
1307
1308                    if (isRTL) {
1309                        var pend = pos.end;
1310                        pos.end = pos.begin;
1311                        pos.begin = pend;
1312                    }
1313                }
1314
1315                if (k == $.inputmask.keyCode.BACKSPACE && pos.end - pos.begin <= 1)
1316                    pos.begin = seekPrevious(pos.begin);
1317                else if (k == $.inputmask.keyCode.DELETE && pos.begin == pos.end)
1318                    pos.end++;
1319
1320                stripValidPositions(pos.begin, pos.end);
1321                generalize(); //revert the alternation
1322
1323                var firstMaskedPos = getLastValidPosition(pos.begin);
1324                if (firstMaskedPos < pos.begin) {
1325                    if (firstMaskedPos == -1) resetMaskSet();
1326                    getMaskSet()["p"] = seekNext(firstMaskedPos);
1327                } else {
1328                    getMaskSet()["p"] = pos.begin;
1329                }
1330            }
1331            //postprocessing of the validpositions according to the buffer manipulations
1332            function handleOnKeyResult(input, keyResult, caretPos) {
1333                if (keyResult && keyResult["refreshFromBuffer"]) {
1334                    var refresh = keyResult["refreshFromBuffer"];
1335                    refreshFromBuffer(refresh === true ? refresh : refresh["start"], refresh["end"], keyResult["buffer"]);
1336
1337                    resetMaskSet(true);
1338                    if (caretPos != undefined) {
1339                        writeBuffer(input, getBuffer());
1340                        caret(input, keyResult.caret || caretPos.begin, keyResult.caret || caretPos.end);
1341                    }
1342                }
1343            }
1344            function keydownEvent(e) {
1345                var input = this, $input = $(input), k = e.keyCode, pos = caret(input);
1346
1347                //backspace, delete, and escape get special treatment
1348                if (k == $.inputmask.keyCode.BACKSPACE || k == $.inputmask.keyCode.DELETE || (iphone && k == 127) || (e.ctrlKey && k == 88 && !isInputEventSupported("cut"))) { //backspace/delete
1349                    e.preventDefault(); //stop default action but allow propagation
1350                    if (k == 88) undoValue = getBuffer().join('');
1351                    handleRemove(input, k, pos);
1352                    writeBuffer(input, getBuffer(), getMaskSet()["p"]);
1353                    if (input._valueGet() == getBufferTemplate().join(''))
1354                        $input.trigger('cleared');
1355
1356                    if (opts.showTooltip) { //update tooltip
1357                        $input.prop("title", getMaskSet()["mask"]);
1358                    }
1359                } else if (k == $.inputmask.keyCode.END || k == $.inputmask.keyCode.PAGE_DOWN) { //when END or PAGE_DOWN pressed set position at lastmatch
1360                    setTimeout(function () {
1361                        var caretPos = seekNext(getLastValidPosition());
1362                        if (!opts.insertMode && caretPos == getMaskLength() && !e.shiftKey) caretPos--;
1363                        caret(input, e.shiftKey ? pos.begin : caretPos, caretPos);
1364                    }, 0);
1365                } else if ((k == $.inputmask.keyCode.HOME && !e.shiftKey) || k == $.inputmask.keyCode.PAGE_UP) { //Home or page_up
1366                    caret(input, 0, e.shiftKey ? pos.begin : 0);
1367                } else if ((opts.undoOnEscape && k == $.inputmask.keyCode.ESCAPE) || (k == 90 && e.ctrlKey)) { //escape && undo
1368                    checkVal(input, true, false, undoValue.split(''));
1369                    $input.click();
1370                } else if (k == $.inputmask.keyCode.INSERT && !(e.shiftKey || e.ctrlKey)) { //insert
1371                    opts.insertMode = !opts.insertMode;
1372                    caret(input, !opts.insertMode && pos.begin == getMaskLength() ? pos.begin - 1 : pos.begin);
1373                } else if (opts.insertMode == false && !e.shiftKey) {
1374                    if (k == $.inputmask.keyCode.RIGHT) {
1375                        setTimeout(function () {
1376                            var caretPos = caret(input);
1377                            caret(input, caretPos.begin);
1378                        }, 0);
1379                    } else if (k == $.inputmask.keyCode.LEFT) {
1380                        setTimeout(function () {
1381                            var caretPos = caret(input);
1382                            caret(input, isRTL ? caretPos.begin + 1 : caretPos.begin - 1);
1383                        }, 0);
1384                    }
1385                }
1386
1387                var currentCaretPos = caret(input);
1388                var keydownResult = opts.onKeyDown.call(this, e, getBuffer(), currentCaretPos.begin, opts);
1389                handleOnKeyResult(input, keydownResult, currentCaretPos);
1390                ignorable = $.inArray(k, opts.ignorables) != -1;
1391            }
1392            function keypressEvent(e, checkval, writeOut, strict, ndx) {
1393                var input = this, $input = $(input);
1394
1395                var k = e.which || e.charCode || e.keyCode;
1396                if (checkval !== true && (!(e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable))) {
1397                    return true;
1398                } else {
1399                    if (k) {
1400                        //special treat the decimal separator
1401                        if (k == 46 && e.shiftKey == false && opts.radixPoint == ",") k = 44;
1402                        var pos = checkval ? { begin: ndx, end: ndx } : caret(input), forwardPosition, c = String.fromCharCode(k);
1403
1404                        //should we clear a possible selection??
1405                        var isSlctn = isSelection(pos.begin, pos.end);
1406                        if (isSlctn) {
1407                            getMaskSet()["undoPositions"] = $.extend(true, {}, getMaskSet()["validPositions"]); //init undobuffer for recovery when not valid
1408                            handleRemove(input, $.inputmask.keyCode.DELETE, pos);
1409                            if (!opts.insertMode) { //preserve some space
1410                                opts.insertMode = !opts.insertMode;
1411                                setValidPosition(pos.begin, strict);
1412                                opts.insertMode = !opts.insertMode;
1413                            }
1414                            isSlctn = !opts.multi;
1415                        }
1416
1417                        getMaskSet()["writeOutBuffer"] = true;
1418                        var p = isRTL && !isSlctn ? pos.end : pos.begin;
1419                        var valResult = isValid(p, c, strict);
1420                        if (valResult !== false) {
1421                            if (valResult !== true) {
1422                                p = valResult.pos != undefined ? valResult.pos : p; //set new position from isValid
1423                                c = valResult.c != undefined ? valResult.c : c; //set new char from isValid
1424                            }
1425                            resetMaskSet(true);
1426                            if (valResult.caret != undefined)
1427                                forwardPosition = valResult.caret;
1428                            else {
1429                                var vps = getMaskSet()["validPositions"];
1430                                if (!opts.keepStatic && (vps[p + 1] != undefined && getTests(p + 1, vps[p].locator.slice(), p).length > 1 || vps[p].alternation != undefined))
1431                                    forwardPosition = p + 1;
1432                                else
1433                                    forwardPosition = seekNext(p);
1434                            }
1435                            getMaskSet()["p"] = forwardPosition; //needed for checkval
1436                        }
1437
1438                        if (writeOut !== false) {
1439                            var self = this;
1440                            setTimeout(function () { opts.onKeyValidation.call(self, valResult, opts); }, 0);
1441                            if (getMaskSet()["writeOutBuffer"] && valResult !== false) {
1442                                var buffer = getBuffer();
1443                                writeBuffer(input, buffer, checkval ? undefined : opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
1444                                if (checkval !== true) {
1445                                    setTimeout(function () { //timeout needed for IE
1446                                        if (isComplete(buffer) === true)
1447                                            $input.trigger("complete");
1448                                        skipInputEvent = true;
1449                                        $input.trigger("input");
1450                                    }, 0);
1451                                }
1452                            } else if (isSlctn) {
1453                                getMaskSet()["buffer"] = undefined;
1454                                getMaskSet()["validPositions"] = getMaskSet()["undoPositions"];
1455                            }
1456                        } else if (isSlctn) {
1457                            getMaskSet()["buffer"] = undefined;
1458                            getMaskSet()["validPositions"] = getMaskSet()["undoPositions"];
1459                        }
1460
1461
1462                        if (opts.showTooltip) { //update tooltip
1463                            $input.prop("title", getMaskSet()["mask"]);
1464                        }
1465
1466                        if (checkval) {
1467                            var keyResult = opts.onKeyPress.call(this, e, getBuffer(), forwardPosition, opts);
1468                            if (keyResult && keyResult["refreshFromBuffer"]) {
1469                                handleOnKeyResult(input, keyResult);
1470                                if (keyResult.caret)
1471                                    getMaskSet()["p"] = keyResult.caret;
1472                            }
1473                        } else {
1474                            var currentCaretPos = caret(input);
1475                            handleOnKeyResult(input, opts.onKeyPress.call(this, e, getBuffer(), currentCaretPos.begin, opts), currentCaretPos);
1476                        }
1477                        e.preventDefault();
1478                    }
1479                }
1480            }
1481            function keyupEvent(e) {
1482                var $input = $(this), input = this, k = e.keyCode, buffer = getBuffer();
1483                var currentCaretPos = caret(input);
1484                var keyupResult = opts.onKeyUp.call(this, e, buffer, currentCaretPos.begin, opts);
1485                handleOnKeyResult(input, keyupResult, currentCaretPos);
1486            }
1487            function pasteEvent(e) {
1488                var input = this, $input = $(input), inputValue = input._valueGet(), caretPos = caret(input);
1489                //paste event for IE8 and lower I guess ;-)
1490                if (e.type == "propertychange" && input._valueGet().length <= getMaskLength()) {
1491                    return true;
1492                } else if (e.type == "paste") {
1493                    if (window.clipboardData && window.clipboardData.getData) { // IE
1494                        inputValue = inputValue.substr(0, caretPos.begin) + window.clipboardData.getData('Text') + inputValue.substr(caretPos.end, inputValue.length);
1495                    } else if (e.originalEvent && e.originalEvent.clipboardData && e.originalEvent.clipboardData.getData) {
1496                        inputValue = inputValue.substr(0, caretPos.begin) + e.originalEvent.clipboardData.getData('text/plain') + inputValue.substr(caretPos.end, inputValue.length);;
1497                    }
1498                }
1499
1500                var pasteValue = $.isFunction(opts.onBeforePaste) ? (opts.onBeforePaste.call(input, inputValue, opts) || inputValue) : inputValue;
1501                checkVal(input, true, false, isRTL ? pasteValue.split('').reverse() : pasteValue.split(''));
1502                $input.click();
1503                if (isComplete(getBuffer()) === true)
1504                    $input.trigger("complete");
1505
1506                return false;
1507            }
1508            //function mobileInputEvent(e) {
1509            //    var input = this;
1510
1511            //    //backspace in chrome32 only fires input event - detect & treat
1512            //    var caretPos = caret(input),
1513            //        currentValue = input._valueGet();
1514
1515            //    currentValue = currentValue.replace(new RegExp("(" + escapeRegex(getBufferTemplate().join('')) + ")*"), "");
1516            //    //correct caretposition for chrome
1517            //    if (caretPos.begin > currentValue.length) {
1518            //        caret(input, currentValue.length);
1519            //        caretPos = caret(input);
1520            //    }
1521            //    if ((getBuffer().length - currentValue.length) == 1 && currentValue.charAt(caretPos.begin) != getBuffer()[caretPos.begin]
1522            //        && currentValue.charAt(caretPos.begin + 1) != getBuffer()[caretPos.begin]
1523            //        && !isMask(caretPos.begin)) {
1524            //        e.keyCode = $.inputmask.keyCode.BACKSPACE;
1525            //        keydownEvent.call(input, e);
1526            //    }
1527            //    e.preventDefault();
1528            //}
1529            function inputFallBackEvent(e) { //fallback when keypress & compositionevents fail
1530                var input = this;
1531                checkVal(input, true, false);
1532                //var forwardPosition = getMaskSet()["p"];
1533                //writeBuffer(input, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
1534
1535                if (isComplete(getBuffer()) === true)
1536                    $(input).trigger("complete");
1537
1538                e.preventDefault();
1539            }
1540            function compositionEndEvent(e) {
1541                var input = this, caretPos = caret(input);
1542                setTimeout(function () {
1543                    var newData = e.originalEvent.data;
1544                    caret(input, caretPos.begin - 1, caretPos.end);
1545                    for (var i = 0; i < newData.length; i++) {
1546                        var keypress = $.Event("keypress");
1547                        keypress.which = newData.charCodeAt(i);
1548                        skipKeyPressEvent = false;
1549                        ignorable = false;
1550                        keypressEvent.call(input, keypress);
1551                    }
1552                }, 0);
1553                return false;
1554            }
1555            function mask(el) {
1556                $el = $(el);
1557                if ($el.is(":input") && isInputTypeSupported($el.attr("type"))) {
1558                    //store tests & original buffer in the input element - used to get the unmasked value
1559                    $el.data('_inputmask', {
1560                        'maskset': maskset,
1561                        'opts': opts,
1562                        'isRTL': false
1563                    });
1564
1565                    //show tooltip
1566                    if (opts.showTooltip) {
1567                        $el.prop("title", getMaskSet()["mask"]);
1568                    }
1569
1570                    if (el.dir == "rtl" || opts.rightAlign)
1571                        $el.css("text-align", "right");
1572
1573                    if (el.dir == "rtl" || opts.numericInput) {
1574                        el.dir = "ltr";
1575                        $el.removeAttr("dir");
1576                        var inputData = $el.data('_inputmask');
1577                        inputData['isRTL'] = true;
1578                        $el.data('_inputmask', inputData);
1579                        isRTL = true;
1580                    }
1581
1582                    //unbind all events - to make sure that no other mask will interfere when re-masking
1583                    $el.unbind(".inputmask");
1584                    //bind events
1585                    $el.closest('form').bind("submit", function (e) { //trigger change on submit if any
1586                        if (undoValue != getBuffer().join('')) {
1587                            $el.change();
1588                        }
1589                        if ($el[0]._valueGet && $el[0]._valueGet() == getBufferTemplate().join('')) {
1590                            $el[0]._valueSet(''); //clear masktemplete on submit and still has focus
1591                        }
1592                        if (opts.removeMaskOnSubmit) {
1593                            $el.inputmask("remove");
1594                        }
1595                    }).bind('reset', function () {
1596                        setTimeout(function () {
1597                            $el.trigger("setvalue");
1598                        }, 0);
1599                    });
1600                    $el.bind("mouseenter.inputmask", function () {
1601                        var $input = $(this), input = this;
1602                        if (!$input.is(":focus") && opts.showMaskOnHover) {
1603                            if (input._valueGet() != getBuffer().join('')) {
1604                                writeBuffer(input, getBuffer());
1605                            }
1606                        }
1607                    }).bind("blur.inputmask", function () {
1608                        var $input = $(this), input = this;
1609                        if ($input.data('_inputmask')) {
1610                            var nptValue = input._valueGet(), buffer = getBuffer().slice();
1611                            firstClick = true;
1612                            if (undoValue != buffer.join('')) {
1613                                $input.change();
1614                                undoValue = buffer.join('');
1615                            }
1616                            if (nptValue != '') {
1617                                if (opts.clearMaskOnLostFocus) {
1618                                    if (nptValue == getBufferTemplate().join(''))
1619                                        buffer = [];
1620                                    else { //clearout optional tail of the mask
1621                                        clearOptionalTail(buffer);
1622                                    }
1623                                }
1624                                if (isComplete(buffer) === false) {
1625                                    $input.trigger("incomplete");
1626                                    if (opts.clearIncomplete) {
1627                                        resetMaskSet();
1628                                        if (opts.clearMaskOnLostFocus)
1629                                            buffer = [];
1630                                        else {
1631                                            buffer = getBufferTemplate().slice();
1632
1633                                        }
1634                                    }
1635                                }
1636
1637                                if ($.isFunction(opts.postProcessOnBlur)) {
1638                                    var keyResult = opts.postProcessOnBlur.call(input, buffer, opts);
1639                                    if (keyResult) {
1640                                        handleOnKeyResult(input, keyResult);
1641                                        buffer = getBuffer();
1642                                    }
1643                                }
1644                                writeBuffer(input, buffer);
1645                            }
1646                        }
1647                    }).bind("focus.inputmask", function (e) {
1648                        var $input = $(this), input = this, nptValue = input._valueGet();
1649                        if (opts.showMaskOnFocus && (!opts.showMaskOnHover || (opts.showMaskOnHover && nptValue == ''))) {
1650                            if (input._valueGet() != getBuffer().join('')) {
1651                                writeBuffer(input, getBuffer(), seekNext(getLastValidPosition()));
1652                            }
1653                        }
1654                        undoValue = getBuffer().join('');
1655                    }).bind("mouseleave.inputmask", function () {
1656                        var $input = $(this), input = this;
1657                        if (opts.clearMaskOnLostFocus) {
1658                            var buffer = getBuffer().slice(), nptValue = input._valueGet();
1659                            if (!$input.is(":focus") && nptValue != $input.attr("placeholder") && nptValue != '') {
1660                                if (nptValue == getBufferTemplate().join(''))
1661                                    buffer = [];
1662                                else { //clearout optional tail of the mask
1663                                    clearOptionalTail(buffer);
1664                                }
1665                                writeBuffer(input, buffer);
1666                            }
1667                        }
1668                    }).bind("click.inputmask", function () {
1669                        var $input = $(this), input = this;
1670                        if ($input.is(":focus")) {
1671                            var selectedCaret = caret(input);
1672                            if (selectedCaret.begin == selectedCaret.end) {
1673                                if (opts.radixFocus && opts.radixPoint != "" && $.inArray(opts.radixPoint, getBuffer()) != -1 && (firstClick || getBuffer().join('') == getBufferTemplate().join(''))) {
1674                                    caret(input, $.inArray(opts.radixPoint, getBuffer()));
1675                                    firstClick = false;
1676                                } else {
1677                                    var clickPosition = isRTL ? TranslatePosition(selectedCaret.begin) : selectedCaret.begin,
1678                                        lastPosition = seekNext(getLastValidPosition(clickPosition));
1679                                    if (clickPosition < lastPosition) {
1680                                        caret(input, isMask(clickPosition) ? clickPosition : seekNext(clickPosition));
1681                                    } else {
1682                                        caret(input, lastPosition);
1683                                    }
1684                                }
1685                            }
1686                        }
1687                    }).bind('dblclick.inputmask', function () {
1688                        var input = this;
1689                        setTimeout(function () {
1690                            caret(input, 0, seekNext(getLastValidPosition()));
1691                        }, 0);
1692                    }).bind(PasteEventType + ".inputmask dragdrop.inputmask drop.inputmask", pasteEvent
1693                    ).bind('setvalue.inputmask', function () {
1694                        var input = this;
1695                        checkVal(input, true, false);
1696                        undoValue = getBuffer().join('');
1697                        if ((opts.clearMaskOnLostFocus || opts.clearIncomplete) && input._valueGet() == getBufferTemplate().join(''))
1698                            input._valueSet('');
1699                    }).bind('cut.inputmask', function (e) {
1700                        skipInputEvent = true; //stop inutFallback
1701                        var input = this, $input = $(input), pos = caret(input);
1702
1703                        handleRemove(input, $.inputmask.keyCode.DELETE, pos);
1704                        var keypressResult = opts.onKeyPress.call(this, e, getBuffer(), getMaskSet()["p"], opts);
1705                        handleOnKeyResult(input, keypressResult, { begin: getMaskSet()["p"], end: getMaskSet()["p"] });
1706                        if (input._valueGet() == getBufferTemplate().join(''))
1707                            $input.trigger('cleared');
1708
1709                        if (opts.showTooltip) { //update tooltip
1710                            $input.prop("title", getMaskSet()["mask"]);
1711                        }
1712                    }).bind('complete.inputmask', opts.oncomplete
1713                    ).bind('incomplete.inputmask', opts.onincomplete
1714                    ).bind('cleared.inputmask', opts.oncleared);
1715
1716                    $el.bind("keydown.inputmask", keydownEvent
1717                    ).bind("keypress.inputmask", keypressEvent
1718                    ).bind("keyup.inputmask", keyupEvent
1719                    ).bind("compositionstart.inputmask", function (e) {
1720                        undoValue = getBuffer().join('');
1721                    }).bind("compositionupdate.inputmask", function (e) {
1722                        
1723                    }).bind("compositionend.inputmask", compositionEndEvent);
1724
1725                    if (PasteEventType === "paste") {
1726                        $el.bind("input.inputmask", inputFallBackEvent);
1727                    }
1728
1729                    //if (android || androidfirefox || androidchrome || kindle) {
1730                    //    $el.unbind("input.inputmask");
1731                    //    $el.bind("input.inputmask", mobileInputEvent);
1732                    //}
1733
1734                    patchValueProperty(el);
1735
1736                    //apply mask
1737                    var initialValue = $.isFunction(opts.onBeforeMask) ? (opts.onBeforeMask.call(el, el._valueGet(), opts) || el._valueGet()) : el._valueGet();
1738                    checkVal(el, true, false, initialValue.split(''));
1739                    var buffer = getBuffer().slice();
1740                    undoValue = buffer.join('');
1741                    // Wrap document.activeElement in a try/catch block since IE9 throw "Unspecified error" if document.activeElement is undefined when we are in an IFrame.
1742                    var activeElement;
1743                    try {
1744                        activeElement = document.activeElement;
1745                    } catch (e) {
1746                    }
1747                    if (isComplete(buffer) === false) {
1748                        if (opts.clearIncomplete)
1749                            resetMaskSet();
1750                    }
1751                    if (opts.clearMaskOnLostFocus) {
1752                        if (buffer.join('') == getBufferTemplate().join('')) {
1753                            buffer = [];
1754                        } else {
1755                            clearOptionalTail(buffer);
1756                        }
1757                    }
1758                    writeBuffer(el, buffer);
1759                    if (activeElement === el) { //position the caret when in focus
1760                        caret(el, seekNext(getLastValidPosition()));
1761                    }
1762
1763                    installEventRuler(el);
1764                }
1765            }
1766
1767            //action object
1768            if (actionObj != undefined) {
1769                switch (actionObj["action"]) {
1770                    case "isComplete":
1771                        $el = $(actionObj["el"]);
1772                        maskset = $el.data('_inputmask')['maskset'];
1773                        opts = $el.data('_inputmask')['opts'];
1774                        return isComplete(actionObj["buffer"]);
1775                    case "unmaskedvalue":
1776                        $el = actionObj["$input"];
1777                        maskset = $el.data('_inputmask')['maskset'];
1778                        opts = $el.data('_inputmask')['opts'];
1779                        isRTL = actionObj["$input"].data('_inputmask')['isRTL'];
1780                        return unmaskedvalue(actionObj["$input"]);
1781                    case "mask":
1782                        undoValue = getBuffer().join('');
1783                        mask(actionObj["el"]);
1784                        break;
1785                    case "format":
1786                        $el = $({});
1787                        $el.data('_inputmask', {
1788                            'maskset': maskset,
1789                            'opts': opts,
1790                            'isRTL': opts.numericInput
1791                        });
1792                        if (opts.numericInput) {
1793                            isRTL = true;
1794                        }
1795                        var valueBuffer = ($.isFunction(opts.onBeforeMask) ? (opts.onBeforeMask.call($el, actionObj["value"], opts) || actionObj["value"]) : actionObj["value"]).split('');
1796                        checkVal($el, false, false, isRTL ? valueBuffer.reverse() : valueBuffer);
1797                        opts.onKeyPress.call(this, undefined, getBuffer(), 0, opts);
1798
1799                        if (actionObj["metadata"]) {
1800                            return {
1801                                value: isRTL ? getBuffer().slice().reverse().join('') : getBuffer().join(''),
1802                                metadata: $el.inputmask("getmetadata")
1803                            }
1804                        }
1805
1806                        return isRTL ? getBuffer().slice().reverse().join('') : getBuffer().join('');
1807                    case "isValid":
1808                        $el = $({});
1809                        $el.data('_inputmask', {
1810                            'maskset': maskset,
1811                            'opts': opts,
1812                            'isRTL': opts.numericInput
1813                        });
1814                        if (opts.numericInput) {
1815                            isRTL = true;
1816                        }
1817                        var valueBuffer = actionObj["value"].split('');
1818                        checkVal($el, false, true, isRTL ? valueBuffer.reverse() : valueBuffer);
1819                        var buffer = getBuffer();
1820                        var rl = determineLastRequiredPosition(), lmib = buffer.length - 1;
1821                        for (; lmib > rl; lmib--) {
1822                            if (isMask(lmib)) break;
1823                        }
1824                        buffer.splice(rl, lmib + 1 - rl);
1825
1826                        return isComplete(buffer) && actionObj["value"] == buffer.join('');
1827                    case "getemptymask":
1828                        $el = $(actionObj["el"]);
1829                        maskset = $el.data('_inputmask')['maskset'];
1830                        opts = $el.data('_inputmask')['opts'];
1831                        return getBufferTemplate();
1832                    case "remove":
1833                        var el = actionObj["el"];
1834                        $el = $(el);
1835                        maskset = $el.data('_inputmask')['maskset'];
1836                        opts = $el.data('_inputmask')['opts'];
1837                        //writeout the unmaskedvalue
1838                        el._valueSet(unmaskedvalue($el));
1839                        //unbind all events
1840                        $el.unbind(".inputmask");
1841                        //clear data
1842                        $el.removeData('_inputmask');
1843                        //restore the value property
1844                        var valueProperty;
1845                        if (Object.getOwnPropertyDescriptor)
1846                            valueProperty = Object.getOwnPropertyDescriptor(el, "value");
1847                        if (valueProperty && valueProperty.get) {
1848                            if (el._valueGet) {
1849                                Object.defineProperty(el, "value", {
1850                                    get: el._valueGet,
1851                                    set: el._valueSet
1852                                });
1853                            }
1854                        } else if (document.__lookupGetter__ && el.__lookupGetter__("value")) {
1855                            if (el._valueGet) {
1856                                el.__defineGetter__("value", el._valueGet);
1857                                el.__defineSetter__("value", el._valueSet);
1858                            }
1859                        }
1860                        try { //try catch needed for IE7 as it does not supports deleting fns
1861                            delete el._valueGet;
1862                            delete el._valueSet;
1863                        } catch (e) {
1864                            el._valueGet = undefined;
1865                            el._valueSet = undefined;
1866
1867                        }
1868                        break;
1869                    case "getmetadata":
1870                        $el = $(actionObj["el"]);
1871                        maskset = $el.data('_inputmask')['maskset'];
1872                        opts = $el.data('_inputmask')['opts'];
1873                        if ($.isArray(maskset["metadata"])) {
1874                            //find last alternation
1875                            var alternation, lvp = getLastValidPosition();
1876                            for (var firstAlt = lvp; firstAlt >= 0; firstAlt--) {
1877                                if (getMaskSet()["validPositions"][firstAlt] && getMaskSet()["validPositions"][firstAlt].alternation != undefined) {
1878                                    alternation = getMaskSet()["validPositions"][firstAlt].alternation;
1879                                    break;
1880                                }
1881                            }
1882                            if (alternation != undefined) {
1883                                return maskset["metadata"][getMaskSet()["validPositions"][lvp].locator[alternation]];
1884                            } else return maskset["metadata"][0];
1885                        }
1886
1887                        return maskset["metadata"];
1888                }
1889            }
1890        }
1891
1892        $.inputmask = {
1893            //options default
1894            defaults: {
1895                placeholder: "_",
1896                optionalmarker: { start: "[", end: "]" },
1897                quantifiermarker: { start: "{", end: "}" },
1898                groupmarker: { start: "(", end: ")" },
1899                alternatormarker: "|",
1900                escapeChar: "\\",
1901                mask: null,
1902                oncomplete: $.noop, //executes when the mask is complete
1903                onincomplete: $.noop, //executes when the mask is incomplete and focus is lost
1904                oncleared: $.noop, //executes when the mask is cleared
1905                repeat: 0, //repetitions of the mask: * ~ forever, otherwise specify an integer
1906                greedy: true, //true: allocated buffer for the mask and repetitions - false: allocate only if needed
1907                autoUnmask: false, //automatically unmask when retrieving the value with $.fn.val or value if the browser supports __lookupGetter__ or getOwnPropertyDescriptor
1908                removeMaskOnSubmit: false, //remove the mask before submitting the form.
1909                clearMaskOnLostFocus: true,
1910                insertMode: true, //insert the input or overwrite the input
1911                clearIncomplete: false, //clear the incomplete input on blur
1912                aliases: {}, //aliases definitions => see jquery.inputmask.extensions.js
1913                alias: null,
1914                onKeyUp: $.noop, //callback to implement autocomplete on certain keys for example
1915                onKeyPress: $.noop, //callback to implement autocomplete on certain keys for example
1916                onKeyDown: $.noop, //callback to implement autocomplete on certain keys for example
1917                onBeforeMask: undefined, //executes before masking the initial value to allow preprocessing of the initial value.  args => initialValue, opts => return processedValue
1918                onBeforePaste: undefined, //executes before masking the pasted value to allow preprocessing of the pasted value.  args => pastedValue, opts => return processedValue
1919                onUnMask: undefined, //executes after unmasking to allow postprocessing of the unmaskedvalue.  args => maskedValue, unmaskedValue, opts
1920                showMaskOnFocus: true, //show the mask-placeholder when the input has focus
1921                showMaskOnHover: true, //show the mask-placeholder when hovering the empty input
1922                onKeyValidation: $.noop, //executes on every key-press with the result of isValid. Params: result, opts
1923                skipOptionalPartCharacter: " ", //a character which can be used to skip an optional part of a mask
1924                showTooltip: false, //show the activemask as tooltip
1925                numericInput: false, //numericInput input direction style (input shifts to the left while holding the caret position)
1926                rightAlign: false, //align to the right
1927                undoOnEscape: true, //pressing escape reverts the value to the value before focus
1928                //numeric basic properties
1929                radixPoint: "", //".", // | ","
1930                radixFocus: false, //position caret to radixpoint on initial click
1931                //numeric basic properties
1932                nojumps: false, //do not jump over fixed parts in the mask
1933                nojumpsThreshold: 0, //start nojumps as of
1934                keepStatic: undefined, //try to keep the mask static while typing. Decisions to alter the mask will be posponed if possible - undefined see auto selection for multi masks
1935                definitions: {
1936                    '9': {
1937                        validator: "[0-9]",
1938                        cardinality: 1,
1939                        definitionSymbol: "*"
1940                    },
1941                    'a': {
1942                        validator: "[A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
1943                        cardinality: 1,
1944                        definitionSymbol: "*"
1945                    },
1946                    '*': {
1947                        validator: "[0-9A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
1948                        cardinality: 1
1949                    }
1950                },
1951                //specify keyCodes which should not be considered in the keypress event, otherwise the preventDefault will stop their default behavior especially in FF
1952                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],
1953                isComplete: undefined, //override for isComplete - args => buffer, opts - return true || false
1954                postProcessOnBlur: undefined //do some postprocessing of the value on the blur event, args => tmpBuffer, opts
1955            },
1956            keyCode: {
1957                ALT: 18, BACKSPACE: 8, CAPS_LOCK: 20, COMMA: 188, COMMAND: 91, COMMAND_LEFT: 91, COMMAND_RIGHT: 93, CONTROL: 17, DELETE: 46, DOWN: 40, END: 35, ENTER: 13, ESCAPE: 27, HOME: 36, INSERT: 45, LEFT: 37, MENU: 93, NUMPAD_ADD: 107, NUMPAD_DECIMAL: 110, NUMPAD_DIVIDE: 111, NUMPAD_ENTER: 108,
1958                NUMPAD_MULTIPLY: 106, NUMPAD_SUBTRACT: 109, PAGE_DOWN: 34, PAGE_UP: 33, PERIOD: 190, RIGHT: 39, SHIFT: 16, SPACE: 32, TAB: 9, UP: 38, WINDOWS: 91
1959            },
1960            masksCache: {},
1961            escapeRegex: function (str) {
1962                var specials = ['/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\'];
1963                return str.replace(new RegExp('(\\' + specials.join('|\\') + ')', 'gim'), '\\$1');
1964            },
1965            format: function (value, options, metadata) {
1966                var opts = $.extend(true, {}, $.inputmask.defaults, options);
1967                resolveAlias(opts.alias, options, opts);
1968                return maskScope({ "action": "format", "value": value, "metadata": metadata }, generateMaskSet(opts), opts);
1969            },
1970            isValid: function (value, options) {
1971                var opts = $.extend(true, {}, $.inputmask.defaults, options);
1972                resolveAlias(opts.alias, options, opts);
1973                return maskScope({ "action": "isValid", "value": value }, generateMaskSet(opts), opts);
1974            }
1975        };
1976
1977        $.fn.inputmask = function (fn, options, targetScope, targetData, msk) {
1978            targetScope = targetScope || maskScope;
1979            targetData = targetData || "_inputmask";
1980            function importAttributeOptions(npt, opts, importedOptionsContainer) {
1981                var $npt = $(npt);
1982                if ($npt.data("inputmask-alias")) {
1983                    resolveAlias($npt.data("inputmask-alias"), {}, opts);
1984                }
1985                for (var option in opts) {
1986                    var optionData = $npt.data("inputmask-" + option.toLowerCase());
1987                    if (optionData != undefined) {
1988                        if (option == "mask" && optionData.indexOf("[") == 0) {
1989                            opts[option] = optionData.replace(/[\s[\]]/g, "").split("','");
1990                            opts[option][0] = opts[option][0].replace("'", "");
1991                            opts[option][opts[option].length - 1] = opts[option][opts[option].length - 1].replace("'", "");
1992                        } else
1993                            opts[option] = typeof optionData == "boolean" ? optionData : optionData.toString();
1994                        if (importedOptionsContainer)
1995                            importedOptionsContainer[option] = opts[option];
1996                    }
1997                }
1998                return opts;
1999            }
2000            var opts = $.extend(true, {}, $.inputmask.defaults, options),
2001                maskset;
2002
2003            if (typeof fn === "string") {
2004                switch (fn) {
2005                    case "mask":
2006                        //resolve possible aliases given by options
2007                        resolveAlias(opts.alias, options, opts);
2008                        maskset = generateMaskSet(opts, targetScope !== maskScope);
2009                        if (maskset == undefined) { return this; }
2010
2011                        return this.each(function () {
2012                            targetScope({ "action": "mask", "el": this }, $.extend(true, {}, maskset), importAttributeOptions(this, opts));
2013                        });
2014                    case "unmaskedvalue":
2015                        var $input = $(this);
2016                        if ($input.data(targetData)) {
2017                            return targetScope({ "action": "unmaskedvalue", "$input": $input });
2018                        } else return $input.val();
2019                    case "remove":
2020                        return this.each(function () {
2021                            var $input = $(this);
2022                            if ($input.data(targetData)) {
2023                                targetScope({ "action": "remove", "el": this });
2024                            }
2025                        });
2026                    case "getemptymask": //return the default (empty) mask value, usefull for setting the default value in validation
2027                        if (this.data(targetData)) {
2028                            return targetScope({ "action": "getemptymask", "el": this });
2029                        }
2030                        else return "";
2031                    case "hasMaskedValue": //check wheter the returned value is masked or not;
2031 currently only works reliable when using jquery.val fn to retrieve the value 
2032                        return this.data(targetData) ? !this.data(targetData)['opts'].autoUnmask : false;
2033                    case "isComplete":
2034                        if (this.data(targetData)) {
2035                            return targetScope({ "action": "isComplete", "buffer": this[0]._valueGet().split(''), "el": this });
2036                        } else return true;
2037                    case "getmetadata": //return mask metadata if exists
2038                        if (this.data(targetData)) {
2039                            return targetScope({ "action": "getmetadata", "el": this });
2040                        }
2041                        else return undefined;
2042                    case "_detectScope":
2043                        resolveAlias(opts.alias, options, opts);
2044                        if (msk != undefined && !resolveAlias(msk, options, opts) && $.inArray(msk, ["mask", "unmaskedvalue", "remove", "getemptymask", "hasMaskedValue", "isComplete", "getmetadata", "_detectScope"]) == -1) {
2045                            opts.mask = msk;
2046                        }
2047                        if ($.isFunction(opts.mask)) {
2048                            opts.mask = opts.mask.call(this, opts);
2049                        }
2050                        return $.isArray(opts.mask);
2051                    default:
2052                        resolveAlias(opts.alias, options, opts);
2053                        //check if the fn is an alias
2054                        if (!resolveAlias(fn, options, opts)) {
2055                            //maybe fn is a mask so we try
2056                            //set mask
2057                            opts.mask = fn;
2058                        }
2059                        maskset = generateMaskSet(opts, targetScope !== maskScope);
2060                        if (maskset == undefined) { return this; }
2061                        return this.each(function () {
2062                            targetScope({ "action": "mask", "el": this }, $.extend(true, {}, maskset), importAttributeOptions(this, opts));
2063                        });
2064                }
2065            } else if (typeof fn == "object") {
2066                opts = $.extend(true, {}, $.inputmask.defaults, fn);
2067                resolveAlias(opts.alias, fn, opts); //resolve aliases
2068                maskset = generateMaskSet(opts, targetScope !== maskScope);
2069                if (maskset == undefined) { return this; }
2070                return this.each(function () {
2071                    targetScope({ "action": "mask", "el": this }, $.extend(true, {}, maskset), importAttributeOptions(this, opts));
2072                });
2073            } else if (fn == undefined) {
2074                //look for data-inputmask atribute - the attribute should only contain optipns
2075                return this.each(function () {
2076                    var attrOptions = $(this).attr("data-inputmask");
2077                    if (attrOptions && attrOptions != "") {
2078                        try {
2079                            attrOptions = attrOptions.replace(new RegExp("'", "g"), '"');
2080                            var dataoptions = $.parseJSON("{" + attrOptions + "}");
2081                            $.extend(true, dataoptions, options);
2082                            opts = $.extend(true, {}, $.inputmask.defaults, dataoptions);
2083                            opts = importAttributeOptions(this, opts);
2084                            resolveAlias(opts.alias, dataoptions, opts);
2085                            opts.alias = undefined;
2086                            $(this).inputmask("mask", opts, targetScope);
2087                        } catch (ex) { } //need a more relax parseJSON
2088                    }
2089                    if ($(this).attr("data-inputmask-mask") || $(this).attr("data-inputmask-alias")) {
2090                        opts = $.extend(true, {}, $.inputmask.defaults, {});
2091                        var dataOptions = {};
2092                        opts = importAttributeOptions(this, opts, dataOptions);
2093                        resolveAlias(opts.alias, dataOptions, opts);
2094                        opts.alias = undefined;
2095                        $(this).inputmask("mask", opts, targetScope);
2096                    }
2097                });
2098            }
2099        };
2100    }
2101    return $.fn.inputmask;
2102})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.