|
|
@@ -3,7 +3,7 @@
|
|
|
* http://github.com/RobinHerbots/jquery.inputmask
|
|
|
* Copyright (c) 2010 - 2015 Robin Herbots
|
|
|
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
|
-* Version: 3.1.64-150
|
|
|
+* Version: 3.1.64-153
|
|
|
*/
|
|
|
!function($) {
|
|
|
function Inputmask(options) {
|
|
|
@@ -334,12 +334,12 @@
|
|
|
}), !0;
|
|
|
if (void 0 !== match.matches) {
|
|
|
if (match.isGroup && quantifierRecurse !== match) {
|
|
|
- if (match = handleMatch(maskToken.matches[tndx + 1], loopNdx)) return !0;
|
|
|
+ if (match = handleMatch(maskToken.matches[$.inArray(match, maskToken.matches) + 1], loopNdx)) return !0;
|
|
|
} else if (match.isOptional) {
|
|
|
var optionalToken = match;
|
|
|
if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) {
|
|
|
- var latestMatch = matches[matches.length - 1].match, isFirstMatch = 0 === $.inArray(latestMatch, optionalToken.matches);
|
|
|
- if (!isFirstMatch) return !0;
|
|
|
+ if (latestMatch = matches[matches.length - 1].match, isFirstMatch = 0 === $.inArray(latestMatch, optionalToken.matches),
|
|
|
+ !isFirstMatch) return !0;
|
|
|
insertStop = !0, testPos = pos;
|
|
|
}
|
|
|
} else if (match.isAlternator) {
|
|
|
@@ -388,10 +388,8 @@
|
|
|
} else if (match.isQuantifier && quantifierRecurse !== maskToken.matches[$.inArray(match, maskToken.matches) - 1]) for (var qt = match, qndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max) && pos >= testPos; qndx++) {
|
|
|
var tokenGroup = maskToken.matches[$.inArray(qt, maskToken.matches) - 1];
|
|
|
if (match = handleMatch(tokenGroup, [ qndx ].concat(loopNdx), tokenGroup)) {
|
|
|
- var latestMatch = matches[matches.length - 1].match;
|
|
|
- latestMatch.optionalQuantifier = qndx > qt.quantifier.min - 1;
|
|
|
- var isFirstMatch = 0 === $.inArray(latestMatch, tokenGroup.matches);
|
|
|
- if (isFirstMatch) {
|
|
|
+ if (latestMatch = matches[matches.length - 1].match, latestMatch.optionalQuantifier = qndx > qt.quantifier.min - 1,
|
|
|
+ isFirstMatch = 0 === $.inArray(latestMatch, tokenGroup.matches)) {
|
|
|
if (qndx > qt.quantifier.min - 1) {
|
|
|
insertStop = !0, testPos = pos;
|
|
|
break;
|
|
|
@@ -409,7 +407,7 @@
|
|
|
if (testPos > pos) break;
|
|
|
}
|
|
|
}
|
|
|
- var maskTokens = getMaskSet().maskToken, testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr || [ 0 ], matches = [], insertStop = !1;
|
|
|
+ var latestMatch, isFirstMatch, maskTokens = getMaskSet().maskToken, testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr || [ 0 ], matches = [], insertStop = !1;
|
|
|
if (cacheable === !0 && getMaskSet().tests[pos]) return getMaskSet().tests[pos];
|
|
|
if (void 0 === ndxIntlzr) {
|
|
|
for (var test, previousPos = pos - 1; void 0 === (test = getMaskSet().validPositions[previousPos]) && previousPos > -1 && (!getMaskSet().tests[previousPos] || void 0 === (test = getMaskSet().tests[previousPos][0])); ) previousPos--;
|
|
|
@@ -439,10 +437,11 @@
|
|
|
getMaskSet().buffer;
|
|
|
}
|
|
|
function refreshFromBuffer(start, end, buffer) {
|
|
|
+ var i;
|
|
|
if (buffer = buffer || getBuffer().slice(), start === !0) resetMaskSet(), start = 0,
|
|
|
- end = buffer.length; else for (var i = start; end > i; i++) delete getMaskSet().validPositions[i],
|
|
|
+ end = buffer.length; else for (i = start; end > i; i++) delete getMaskSet().validPositions[i],
|
|
|
delete getMaskSet().tests[i];
|
|
|
- for (var i = start; end > i; i++) buffer[i] !== opts.skipOptionalPartCharacter && isValid(i, buffer[i], !0, !0);
|
|
|
+ for (i = start; end > i; i++) buffer[i] !== opts.skipOptionalPartCharacter && isValid(i, buffer[i], !0, !0);
|
|
|
}
|
|
|
function casing(elem, test) {
|
|
|
switch (test.casing) {
|
|
|
@@ -456,7 +455,7 @@
|
|
|
return elem;
|
|
|
}
|
|
|
function checkAlternationMatch(altArr1, altArr2) {
|
|
|
- for (var altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1), isMatch = !1, alndx = 0; alndx < altArr1.length; alndx++) if (-1 != $.inArray(altArr1[alndx], altArrC)) {
|
|
|
+ for (var altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1), isMatch = !1, alndx = 0; alndx < altArr1.length; alndx++) if (-1 !== $.inArray(altArr1[alndx], altArrC)) {
|
|
|
isMatch = !0;
|
|
|
break;
|
|
|
}
|
|
|
@@ -467,19 +466,19 @@
|
|
|
var rslt = !1;
|
|
|
return $.each(getTests(position), function(ndx, tst) {
|
|
|
for (var test = tst.match, loopend = c ? 1 : 0, chrs = "", i = (getBuffer(), test.cardinality); i > loopend; i--) chrs += getBufferElement(position - (i - 1));
|
|
|
- if (c && (chrs += c), rslt = null != test.fn ? test.fn.test(chrs, getMaskSet(), position, strict, opts) : c != test.def && c != opts.skipOptionalPartCharacter || "" == test.def ? !1 : {
|
|
|
+ if (c && (chrs += c), rslt = null != test.fn ? test.fn.test(chrs, getMaskSet(), position, strict, opts) : c !== test.def && c !== opts.skipOptionalPartCharacter || "" === test.def ? !1 : {
|
|
|
c: test.def,
|
|
|
pos: position
|
|
|
}, rslt !== !1) {
|
|
|
- var elem = void 0 != rslt.c ? rslt.c : c;
|
|
|
- elem = elem == opts.skipOptionalPartCharacter && null === test.fn ? test.def : elem;
|
|
|
+ var elem = void 0 !== rslt.c ? rslt.c : c;
|
|
|
+ elem = elem === opts.skipOptionalPartCharacter && null === test.fn ? test.def : elem;
|
|
|
var validatedPos = position, possibleModifiedBuffer = getBuffer();
|
|
|
- if (void 0 != rslt.remove && ($.isArray(rslt.remove) || (rslt.remove = [ rslt.remove ]),
|
|
|
+ if (void 0 !== rslt.remove && ($.isArray(rslt.remove) || (rslt.remove = [ rslt.remove ]),
|
|
|
$.each(rslt.remove.sort(function(a, b) {
|
|
|
return b - a;
|
|
|
}), function(ndx, lmnt) {
|
|
|
stripValidPositions(lmnt, lmnt + 1, !0);
|
|
|
- })), void 0 != rslt.insert && ($.isArray(rslt.insert) || (rslt.insert = [ rslt.insert ]),
|
|
|
+ })), void 0 !== rslt.insert && ($.isArray(rslt.insert) || (rslt.insert = [ rslt.insert ]),
|
|
|
$.each(rslt.insert.sort(function(a, b) {
|
|
|
return a - b;
|
|
|
}), function(ndx, lmnt) {
|
|
|
@@ -489,7 +488,7 @@
|
|
|
if (strict = !0, refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, possibleModifiedBuffer),
|
|
|
void 0 === rslt.pos && void 0 === rslt.c) return rslt.pos = getLastValidPosition(),
|
|
|
!1;
|
|
|
- if (validatedPos = void 0 !== rslt.pos ? rslt.pos : position, validatedPos != position) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0)),
|
|
|
+ if (validatedPos = void 0 !== rslt.pos ? rslt.pos : position, validatedPos !== position) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0)),
|
|
|
!1;
|
|
|
} else if (rslt !== !0 && void 0 !== rslt.pos && rslt.pos !== position && (validatedPos = rslt.pos,
|
|
|
refreshFromBuffer(position, validatedPos), validatedPos !== position)) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0)),
|
|
|
@@ -502,7 +501,7 @@
|
|
|
}), rslt;
|
|
|
}
|
|
|
function alternate(pos, c, strict, fromSetValid) {
|
|
|
- for (var lastAlt, alternation, isValidRslt, altPos, validPsClone = $.extend(!0, {}, getMaskSet().validPositions), lAlt = getLastValidPosition(); lAlt >= 0 && (altPos = getMaskSet().validPositions[lAlt],
|
|
|
+ for (var lastAlt, alternation, isValidRslt, altPos, i, validPos, validPsClone = $.extend(!0, {}, getMaskSet().validPositions), lAlt = getLastValidPosition(); lAlt >= 0 && (altPos = getMaskSet().validPositions[lAlt],
|
|
|
!altPos || void 0 === altPos.alternation || (lastAlt = lAlt, alternation = getMaskSet().validPositions[lastAlt].alternation,
|
|
|
getTestTemplate(lastAlt).locator[altPos.alternation] === altPos.locator[altPos.alternation])); lAlt--) ;
|
|
|
if (void 0 !== alternation) {
|
|
|
@@ -518,21 +517,19 @@
|
|
|
break;
|
|
|
}
|
|
|
if (decisionTaker !== possibilityPos.locator[alternation]) {
|
|
|
- for (var validInputs = [], staticInputsBeforePos = 0, i = decisionPos + 1; i < getLastValidPosition() + 1; i++) {
|
|
|
- var validPos = getMaskSet().validPositions[i];
|
|
|
- validPos && (null != validPos.match.fn ? validInputs.push(validPos.input) : pos > i && staticInputsBeforePos++),
|
|
|
- delete getMaskSet().validPositions[i], delete getMaskSet().tests[i];
|
|
|
- }
|
|
|
+ var validInputs = [], staticInputsBeforePos = 0;
|
|
|
+ for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) validPos = getMaskSet().validPositions[i],
|
|
|
+ validPos && (null != validPos.match.fn ? validInputs.push(validPos.input) : pos > i && staticInputsBeforePos++),
|
|
|
+ delete getMaskSet().validPositions[i], delete getMaskSet().tests[i];
|
|
|
for (resetMaskSet(!0), opts.keepStatic = !opts.keepStatic, isValidRslt = !0; validInputs.length > 0; ) {
|
|
|
var input = validInputs.shift();
|
|
|
if (input !== opts.skipOptionalPartCharacter && !(isValidRslt = isValid(getLastValidPosition() + 1, input, !1, !0))) break;
|
|
|
}
|
|
|
if (possibilityPos.alternation = alternation, possibilityPos.locator[alternation] = possibilities,
|
|
|
isValidRslt) {
|
|
|
- for (var targetLvp = getLastValidPosition(pos) + 1, staticInputsBeforePosAlternate = 0, i = decisionPos + 1; i < getLastValidPosition() + 1; i++) {
|
|
|
- var validPos = getMaskSet().validPositions[i];
|
|
|
- validPos && null == validPos.match.fn && pos > i && staticInputsBeforePosAlternate++;
|
|
|
- }
|
|
|
+ var targetLvp = getLastValidPosition(pos) + 1, staticInputsBeforePosAlternate = 0;
|
|
|
+ for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) validPos = getMaskSet().validPositions[i],
|
|
|
+ validPos && null == validPos.match.fn && pos > i && staticInputsBeforePosAlternate++;
|
|
|
pos += staticInputsBeforePosAlternate - staticInputsBeforePos, isValidRslt = isValid(pos > targetLvp ? targetLvp : pos, c, strict, fromSetValid);
|
|
|
}
|
|
|
if (opts.keepStatic = !opts.keepStatic, isValidRslt) return isValidRslt;
|
|
|
@@ -691,9 +688,12 @@
|
|
|
if ($input[0].inputmask && !$input.hasClass("hasDatepicker")) {
|
|
|
var umValue = [], vps = getMaskSet().validPositions;
|
|
|
for (var pndx in vps) vps[pndx].match && null != vps[pndx].match.fn && umValue.push(vps[pndx].input);
|
|
|
- var unmaskedValue = (isRTL ? umValue.reverse() : umValue).join(""), bufferValue = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join("");
|
|
|
- return $.isFunction(opts.onUnMask) && (unmaskedValue = opts.onUnMask.call($input, bufferValue, unmaskedValue, opts) || unmaskedValue),
|
|
|
- unmaskedValue;
|
|
|
+ var unmaskedValue = 0 === umValue.length ? null : (isRTL ? umValue.reverse() : umValue).join("");
|
|
|
+ if (null !== unmaskedValue) {
|
|
|
+ var bufferValue = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join("");
|
|
|
+ $.isFunction(opts.onUnMask) && (unmaskedValue = opts.onUnMask.call($input, bufferValue, unmaskedValue, opts) || unmaskedValue);
|
|
|
+ }
|
|
|
+ return unmaskedValue;
|
|
|
}
|
|
|
return $input[0].inputmask._valueGet();
|
|
|
}
|
|
|
@@ -718,7 +718,7 @@
|
|
|
if (begin = translatePosition(begin), end = translatePosition(end), end = "number" == typeof end ? end : begin,
|
|
|
$(npt).is(":visible")) {
|
|
|
var scrollCalc = $(npt).css("font-size").replace("px", "") * end;
|
|
|
- if (npt.scrollLeft = scrollCalc > npt.scrollWidth ? scrollCalc : 0, androidchrome || 0 != opts.insertMode || begin != end || end++,
|
|
|
+ if (npt.scrollLeft = scrollCalc > npt.scrollWidth ? scrollCalc : 0, androidchrome || opts.insertMode !== !1 || begin !== end || end++,
|
|
|
npt.setSelectionRange) npt.selectionStart = begin, npt.selectionEnd = end; else if (window.getSelection) {
|
|
|
if (range = document.createRange(), void 0 === npt.firstChild) {
|
|
|
var textNode = document.createTextNode("");
|
|
|
@@ -906,17 +906,17 @@
|
|
|
pos.end = pos.begin, pos.begin = pend;
|
|
|
}
|
|
|
k === Inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || opts.insertMode === !1) ? (pos.begin = seekPrevious(pos.begin),
|
|
|
- void 0 === getMaskSet().validPositions[pos.begin] || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.begin--) : k == Inputmask.keyCode.DELETE && pos.begin == pos.end && (pos.end = isMask(pos.end) ? pos.end + 1 : seekNext(pos.end) + 1,
|
|
|
- void 0 == getMaskSet().validPositions[pos.begin] || getMaskSet().validPositions[pos.begin].input != opts.groupSeparator && getMaskSet().validPositions[pos.begin].input != opts.radixPoint || pos.end++),
|
|
|
+ void 0 === getMaskSet().validPositions[pos.begin] || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.begin--) : k === Inputmask.keyCode.DELETE && pos.begin === pos.end && (pos.end = isMask(pos.end) ? pos.end + 1 : seekNext(pos.end) + 1,
|
|
|
+ void 0 === getMaskSet().validPositions[pos.begin] || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.end++),
|
|
|
stripValidPositions(pos.begin, pos.end, !1, strict), strict !== !0 && generalize();
|
|
|
var lvp = getLastValidPosition(pos.begin);
|
|
|
- lvp < pos.begin ? (-1 == lvp && resetMaskSet(), getMaskSet().p = seekNext(lvp)) : strict !== !0 && (getMaskSet().p = pos.begin);
|
|
|
+ lvp < pos.begin ? (-1 === lvp && resetMaskSet(), getMaskSet().p = seekNext(lvp)) : strict !== !0 && (getMaskSet().p = pos.begin);
|
|
|
}
|
|
|
function keydownEvent(e) {
|
|
|
var input = this, $input = $(input), k = e.keyCode, pos = caret(input);
|
|
|
k === Inputmask.keyCode.BACKSPACE || k === Inputmask.keyCode.DELETE || iphone && 127 === k || e.ctrlKey && 88 === k && !isInputEventSupported("cut") ? (e.preventDefault(),
|
|
|
- 88 == k && (undoValue = getBuffer().join("")), handleRemove(input, k, pos), writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue != getBuffer().join("")),
|
|
|
- input.inputmask._valueGet() == getBufferTemplate().join("") ? $input.trigger("cleared") : isComplete(getBuffer()) === !0 && $input.trigger("complete"),
|
|
|
+ 88 === k && (undoValue = getBuffer().join("")), handleRemove(input, k, pos), writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")),
|
|
|
+ input.inputmask._valueGet() === getBufferTemplate().join("") ? $input.trigger("cleared") : isComplete(getBuffer()) === !0 && $input.trigger("complete"),
|
|
|
opts.showTooltip && $input.prop("title", getMaskSet().mask)) : k === Inputmask.keyCode.END || k === Inputmask.keyCode.PAGE_DOWN ? setTimeout(function() {
|
|
|
var caretPos = seekNext(getLastValidPosition());
|
|
|
opts.insertMode || caretPos !== getMaskLength() || e.shiftKey || caretPos--, caret(input, e.shiftKey ? pos.begin : caretPos, caretPos);
|
|
|
@@ -982,11 +982,11 @@
|
|
|
}
|
|
|
function pasteEvent(e) {
|
|
|
var input = this, $input = $(input), inputValue = input.inputmask._valueGet(!0), caretPos = caret(input);
|
|
|
- if ("propertychange" == e.type && input.inputmask._valueGet().length <= getMaskLength()) return !0;
|
|
|
- if ("paste" == e.type) {
|
|
|
+ if ("propertychange" === e.type && input.inputmask._valueGet().length <= getMaskLength()) return !0;
|
|
|
+ if ("paste" === e.type) {
|
|
|
var valueBeforeCaret = inputValue.substr(0, caretPos.begin), valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length);
|
|
|
- valueBeforeCaret == getBufferTemplate().slice(0, caretPos.begin).join("") && (valueBeforeCaret = ""),
|
|
|
- valueAfterCaret == getBufferTemplate().slice(caretPos.end).join("") && (valueAfterCaret = ""),
|
|
|
+ valueBeforeCaret === getBufferTemplate().slice(0, caretPos.begin).join("") && (valueBeforeCaret = ""),
|
|
|
+ valueAfterCaret === getBufferTemplate().slice(caretPos.end).join("") && (valueAfterCaret = ""),
|
|
|
window.clipboardData && window.clipboardData.getData ? inputValue = valueBeforeCaret + window.clipboardData.getData("Text") + valueAfterCaret : e.originalEvent && e.originalEvent.clipboardData && e.originalEvent.clipboardData.getData && (inputValue = valueBeforeCaret + e.originalEvent.clipboardData.getData("text/plain") + valueAfterCaret);
|
|
|
}
|
|
|
var pasteValue = inputValue;
|
|
|
@@ -1051,7 +1051,7 @@
|
|
|
}
|
|
|
}).bind("focus.inputmask", function(e) {
|
|
|
var input = ($(this), this), nptValue = input.inputmask._valueGet();
|
|
|
- opts.showMaskOnFocus && (!opts.showMaskOnHover || opts.showMaskOnHover && "" == nptValue) ? input.inputmask._valueGet() != getBuffer().join("") && writeBuffer(input, getBuffer(), seekNext(getLastValidPosition())) : mouseEnter === !1 && caret(input, seekNext(getLastValidPosition())),
|
|
|
+ opts.showMaskOnFocus && (!opts.showMaskOnHover || opts.showMaskOnHover && "" === nptValue) ? input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer(), seekNext(getLastValidPosition())) : mouseEnter === !1 && caret(input, seekNext(getLastValidPosition())),
|
|
|
opts.positionCaretOnTab === !0 && setTimeout(function() {
|
|
|
caret(input, seekNext(getLastValidPosition()));
|
|
|
}, 0), undoValue = getBuffer().join("");
|
|
|
@@ -1059,14 +1059,14 @@
|
|
|
var $input = $(this), input = this;
|
|
|
if (mouseEnter = !1, opts.clearMaskOnLostFocus) {
|
|
|
var buffer = getBuffer().slice(), nptValue = input.inputmask._valueGet();
|
|
|
- $input.is(":focus") || nptValue == $input.attr("placeholder") || "" == nptValue || (-1 === getLastValidPosition() && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer),
|
|
|
+ $input.is(":focus") || nptValue === $input.attr("placeholder") || "" === nptValue || (-1 === getLastValidPosition() && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer),
|
|
|
writeBuffer(input, buffer));
|
|
|
}
|
|
|
}).bind("click.inputmask", function() {
|
|
|
var $input = $(this), input = this;
|
|
|
if ($input.is(":focus")) {
|
|
|
var selectedCaret = caret(input);
|
|
|
- if (selectedCaret.begin === selectedCaret.end) if (opts.radixFocus && "" != opts.radixPoint && -1 != $.inArray(opts.radixPoint, getBuffer()) && (firstClick || getBuffer().join("") == getBufferTemplate().join(""))) caret(input, $.inArray(opts.radixPoint, getBuffer())),
|
|
|
+ if (selectedCaret.begin === selectedCaret.end) if (opts.radixFocus && "" !== opts.radixPoint && -1 !== $.inArray(opts.radixPoint, getBuffer()) && (firstClick || getBuffer().join("") === getBufferTemplate().join(""))) caret(input, $.inArray(opts.radixPoint, getBuffer())),
|
|
|
firstClick = !1; else {
|
|
|
var clickPosition = selectedCaret.begin, lastPosition = seekNext(getLastValidPosition(clickPosition));
|
|
|
lastPosition > clickPosition ? caret(input, isMask(clickPosition) ? clickPosition : seekNext(clickPosition)) : caret(input, opts.numericInput ? 0 : lastPosition);
|
|
|
@@ -1084,8 +1084,8 @@
|
|
|
var clipboardData = window.clipboardData || e.originalEvent.clipboardData, clipData = clipboardData.getData("text").split("").reverse().join("");
|
|
|
clipboardData.setData("text", clipData);
|
|
|
}
|
|
|
- handleRemove(input, Inputmask.keyCode.DELETE, pos), writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue != getBuffer().join("")),
|
|
|
- input.inputmask._valueGet() == getBufferTemplate().join("") && $input.trigger("cleared"),
|
|
|
+ handleRemove(input, Inputmask.keyCode.DELETE, pos), writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")),
|
|
|
+ input.inputmask._valueGet() === getBufferTemplate().join("") && $input.trigger("cleared"),
|
|
|
opts.showTooltip && $input.prop("title", getMaskSet().mask);
|
|
|
}).bind("complete.inputmask", opts.oncomplete).bind("incomplete.inputmask", opts.onincomplete).bind("cleared.inputmask", opts.oncleared),
|
|
|
$el.bind("keydown.inputmask", keydownEvent).bind("keypress.inputmask", keypressEvent),
|
|
|
@@ -1094,7 +1094,7 @@
|
|
|
$el.bind("setvalue.inputmask", function() {
|
|
|
var input = this, value = input.inputmask._valueGet();
|
|
|
input.inputmask._valueSet($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(input, value, opts) || value : value),
|
|
|
- checkVal(input, !0, !1), undoValue = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() == getBufferTemplate().join("") && input.inputmask._valueSet("");
|
|
|
+ checkVal(input, !0, !1), undoValue = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() === getBufferTemplate().join("") && input.inputmask._valueSet("");
|
|
|
}), patchValueProperty(el);
|
|
|
var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(el, el.inputmask._valueGet(), opts) || el.inputmask._valueGet() : el.inputmask._valueGet();
|
|
|
checkVal(el, !0, !1, initialValue.split(""));
|
|
|
@@ -1104,25 +1104,22 @@
|
|
|
try {
|
|
|
activeElement = document.activeElement;
|
|
|
} catch (e) {}
|
|
|
- isComplete(buffer) === !1 && opts.clearIncomplete && resetMaskSet(), opts.clearMaskOnLostFocus && (buffer.join("") == getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
|
|
|
+ isComplete(buffer) === !1 && opts.clearIncomplete && resetMaskSet(), opts.clearMaskOnLostFocus && (buffer.join("") === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
|
|
|
writeBuffer(el, buffer), activeElement === el && caret(el, seekNext(getLastValidPosition())),
|
|
|
installEventRuler(el);
|
|
|
}
|
|
|
- var undoValue, compositionCaretPos, compositionData, el, $el, maxLength, isRTL = !1, skipKeyPressEvent = !1, skipInputEvent = !1, ignorable = !1, firstClick = !0, mouseEnter = !0;
|
|
|
+ var undoValue, compositionCaretPos, compositionData, el, $el, maxLength, valueBuffer, isRTL = !1, skipKeyPressEvent = !1, skipInputEvent = !1, ignorable = !1, firstClick = !0, mouseEnter = !0;
|
|
|
if (void 0 !== actionObj) switch (actionObj.action) {
|
|
|
case "isComplete":
|
|
|
return el = actionObj.el, $el = $(el), maskset = el.inputmask.maskset, opts = el.inputmask.opts,
|
|
|
isComplete(actionObj.buffer);
|
|
|
|
|
|
case "unmaskedvalue":
|
|
|
- if (el = actionObj.el, void 0 === el) {
|
|
|
- $el = $({}), el = $el[0], el.inputmask = new Inputmask(), el.inputmask.opts = opts,
|
|
|
- el.inputmask.el = el, el.inputmask.maskset = maskset, el.inputmask.isRTL = opts.numericInput,
|
|
|
- opts.numericInput && (isRTL = !0);
|
|
|
- var valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call($el, actionObj.value, opts) || actionObj.value : actionObj.value).split("");
|
|
|
- checkVal($el, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite.call(this, void 0, getBuffer(), 0, opts);
|
|
|
- } else $el = $(el);
|
|
|
- return maskset = el.inputmask.maskset, opts = el.inputmask.opts, isRTL = el.inputmask.isRTL,
|
|
|
+ return el = actionObj.el, void 0 === el ? ($el = $({}), el = $el[0], el.inputmask = new Inputmask(),
|
|
|
+ el.inputmask.opts = opts, el.inputmask.el = el, el.inputmask.maskset = maskset,
|
|
|
+ el.inputmask.isRTL = opts.numericInput, opts.numericInput && (isRTL = !0), valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call($el, actionObj.value, opts) || actionObj.value : actionObj.value).split(""),
|
|
|
+ checkVal($el, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite.call(this, void 0, getBuffer(), 0, opts)) : $el = $(el),
|
|
|
+ maskset = el.inputmask.maskset, opts = el.inputmask.opts, isRTL = el.inputmask.isRTL,
|
|
|
unmaskedvalue($el);
|
|
|
|
|
|
case "mask":
|
|
|
@@ -1130,11 +1127,10 @@
|
|
|
break;
|
|
|
|
|
|
case "format":
|
|
|
- $el = $({}), $el[0].inputmask = new Inputmask(), $el[0].inputmask.opts = opts, $el[0].inputmask.el = $el[0],
|
|
|
- $el[0].inputmask.maskset = maskset, $el[0].inputmask.isRTL = opts.numericInput,
|
|
|
- opts.numericInput && (isRTL = !0);
|
|
|
- var valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call($el, actionObj.value, opts) || actionObj.value : actionObj.value).split("");
|
|
|
- return checkVal($el, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite.call(this, void 0, getBuffer(), 0, opts),
|
|
|
+ return $el = $({}), $el[0].inputmask = new Inputmask(), $el[0].inputmask.opts = opts,
|
|
|
+ $el[0].inputmask.el = $el[0], $el[0].inputmask.maskset = maskset, $el[0].inputmask.isRTL = opts.numericInput,
|
|
|
+ opts.numericInput && (isRTL = !0), valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call($el, actionObj.value, opts) || actionObj.value : actionObj.value).split(""),
|
|
|
+ checkVal($el, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite.call(this, void 0, getBuffer(), 0, opts),
|
|
|
actionObj.metadata ? {
|
|
|
value: isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join(""),
|
|
|
metadata: $el.inputmask("getmetadata")
|
|
|
@@ -1143,11 +1139,9 @@
|
|
|
case "isValid":
|
|
|
$el = $({}), $el[0].inputmask = new Inputmask(), $el[0].inputmask.opts = opts, $el[0].inputmask.el = $el[0],
|
|
|
$el[0].inputmask.maskset = maskset, $el[0].inputmask.isRTL = opts.numericInput,
|
|
|
- opts.numericInput && (isRTL = !0);
|
|
|
- var valueBuffer = actionObj.value.split("");
|
|
|
- checkVal($el, !1, !0, isRTL ? valueBuffer.reverse() : valueBuffer);
|
|
|
+ opts.numericInput && (isRTL = !0), valueBuffer = actionObj.value.split(""), checkVal($el, !1, !0, isRTL ? valueBuffer.reverse() : valueBuffer);
|
|
|
for (var buffer = getBuffer(), rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
|
|
|
- return buffer.splice(rl, lmib + 1 - rl), isComplete(buffer) && actionObj.value == buffer.join("");
|
|
|
+ return buffer.splice(rl, lmib + 1 - rl), isComplete(buffer) && actionObj.value === buffer.join("");
|
|
|
|
|
|
case "getemptymask":
|
|
|
return el = actionObj.el, $el = $(el), maskset = el.inputmask.maskset, opts = el.inputmask.opts,
|
|
|
@@ -1358,9 +1352,7 @@
|
|
|
UP: 38,
|
|
|
WINDOWS: 91
|
|
|
};
|
|
|
- var ua = navigator.userAgent, iphone = null !== ua.match(new RegExp("iphone", "i")), androidchrome = (null !== ua.match(new RegExp("android.*safari.*", "i")),
|
|
|
- null !== ua.match(new RegExp("android.*chrome.*", "i"))), androidfirefox = null !== ua.match(new RegExp("android.*firefox.*", "i")), PasteEventType = (/Kindle/i.test(ua) || /Silk/i.test(ua) || /KFTT/i.test(ua) || /KFOT/i.test(ua) || /KFJWA/i.test(ua) || /KFJWI/i.test(ua) || /KFSOWI/i.test(ua) || /KFTHWA/i.test(ua) || /KFTHWI/i.test(ua) || /KFAPWA/i.test(ua) || /KFAPWI/i.test(ua),
|
|
|
- isInputEventSupported("paste") ? "paste" : isInputEventSupported("input") ? "input" : "propertychange");
|
|
|
+ var ua = navigator.userAgent, iphone = null !== ua.match(new RegExp("iphone", "i")), androidchrome = null !== ua.match(new RegExp("android.*chrome.*", "i")), androidfirefox = null !== ua.match(new RegExp("android.*firefox.*", "i")), PasteEventType = isInputEventSupported("paste") ? "paste" : isInputEventSupported("input") ? "input" : "propertychange";
|
|
|
return window.Inputmask = Inputmask, Inputmask;
|
|
|
}(jQuery), function($) {
|
|
|
return void 0 === $.fn.inputmask && ($.fn.inputmask = function(fn, options) {
|
|
|
@@ -1496,14 +1488,14 @@
|
|
|
},
|
|
|
onKeyDown: function(e, buffer, caretPos, opts) {
|
|
|
var $input = $(this);
|
|
|
- if (e.ctrlKey && e.keyCode == Inputmask.keyCode.RIGHT) {
|
|
|
+ if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
|
|
|
var today = new Date();
|
|
|
$input.val(today.getDate().toString() + (today.getMonth() + 1).toString() + today.getFullYear().toString()),
|
|
|
$input.triggerHandler("setvalue.inputmask");
|
|
|
}
|
|
|
},
|
|
|
getFrontValue: function(mask, buffer, opts) {
|
|
|
- for (var start = 0, length = 0, i = 0; i < mask.length && "2" != mask.charAt(i); i++) {
|
|
|
+ for (var start = 0, length = 0, i = 0; i < mask.length && "2" !== mask.charAt(i); i++) {
|
|
|
var definition = opts.definitions[mask.charAt(i)];
|
|
|
definition ? (start += length, length = definition.cardinality) : length++;
|
|
|
}
|
|
|
@@ -1513,7 +1505,7 @@
|
|
|
"1": {
|
|
|
validator: function(chrs, maskset, pos, strict, opts) {
|
|
|
var isValid = opts.regex.val1.test(chrs);
|
|
|
- return strict || isValid || chrs.charAt(1) != opts.separator && -1 == "-./".indexOf(chrs.charAt(1)) || !(isValid = opts.regex.val1.test("0" + chrs.charAt(0))) ? isValid : (maskset.buffer[pos - 1] = "0",
|
|
|
+ return strict || isValid || chrs.charAt(1) !== opts.separator && -1 === "-./".indexOf(chrs.charAt(1)) || !(isValid = opts.regex.val1.test("0" + chrs.charAt(0))) ? isValid : (maskset.buffer[pos - 1] = "0",
|
|
|
{
|
|
|
refreshFromBuffer: {
|
|
|
start: pos - 1,
|
|
|
@@ -1528,7 +1520,7 @@
|
|
|
validator: function(chrs, maskset, pos, strict, opts) {
|
|
|
var pchrs = chrs;
|
|
|
isNaN(maskset.buffer[pos + 1]) || (pchrs += maskset.buffer[pos + 1]);
|
|
|
- var isValid = 1 == pchrs.length ? opts.regex.val1pre.test(pchrs) : opts.regex.val1.test(pchrs);
|
|
|
+ var isValid = 1 === pchrs.length ? opts.regex.val1pre.test(pchrs) : opts.regex.val1.test(pchrs);
|
|
|
if (!strict && !isValid) {
|
|
|
if (isValid = opts.regex.val1.test(chrs + "0")) return maskset.buffer[pos] = chrs,
|
|
|
maskset.buffer[++pos] = "0", {
|
|
|
@@ -1548,9 +1540,9 @@
|
|
|
"2": {
|
|
|
validator: function(chrs, maskset, pos, strict, opts) {
|
|
|
var frontValue = opts.getFrontValue(maskset.mask, maskset.buffer, opts);
|
|
|
- -1 != frontValue.indexOf(opts.placeholder[0]) && (frontValue = "01" + opts.separator);
|
|
|
+ -1 !== frontValue.indexOf(opts.placeholder[0]) && (frontValue = "01" + opts.separator);
|
|
|
var isValid = opts.regex.val2(opts.separator).test(frontValue + chrs);
|
|
|
- if (!strict && !isValid && (chrs.charAt(1) == opts.separator || -1 != "-./".indexOf(chrs.charAt(1))) && (isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs.charAt(0)))) return maskset.buffer[pos - 1] = "0",
|
|
|
+ if (!strict && !isValid && (chrs.charAt(1) === opts.separator || -1 !== "-./".indexOf(chrs.charAt(1))) && (isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs.charAt(0)))) return maskset.buffer[pos - 1] = "0",
|
|
|
{
|
|
|
refreshFromBuffer: {
|
|
|
start: pos - 1,
|
|
|
@@ -1559,9 +1551,9 @@
|
|
|
pos: pos,
|
|
|
c: chrs.charAt(0)
|
|
|
};
|
|
|
- if (opts.mask.indexOf("2") == opts.mask.length - 1 && isValid) {
|
|
|
+ if (opts.mask.indexOf("2") === opts.mask.length - 1 && isValid) {
|
|
|
var dayMonthValue = maskset.buffer.join("").substr(4, 4) + chrs;
|
|
|
- if (dayMonthValue != opts.leapday) return !0;
|
|
|
+ if (dayMonthValue !== opts.leapday) return !0;
|
|
|
var year = parseInt(maskset.buffer.join("").substr(0, 4), 10);
|
|
|
return year % 4 === 0 ? year % 100 === 0 ? year % 400 === 0 ? !0 : !1 : !0 : !1;
|
|
|
}
|
|
|
@@ -1572,8 +1564,8 @@
|
|
|
validator: function(chrs, maskset, pos, strict, opts) {
|
|
|
isNaN(maskset.buffer[pos + 1]) || (chrs += maskset.buffer[pos + 1]);
|
|
|
var frontValue = opts.getFrontValue(maskset.mask, maskset.buffer, opts);
|
|
|
- -1 != frontValue.indexOf(opts.placeholder[0]) && (frontValue = "01" + opts.separator);
|
|
|
- var isValid = 1 == chrs.length ? opts.regex.val2pre(opts.separator).test(frontValue + chrs) : opts.regex.val2(opts.separator).test(frontValue + chrs);
|
|
|
+ -1 !== frontValue.indexOf(opts.placeholder[0]) && (frontValue = "01" + opts.separator);
|
|
|
+ var isValid = 1 === chrs.length ? opts.regex.val2pre(opts.separator).test(frontValue + chrs) : opts.regex.val2(opts.separator).test(frontValue + chrs);
|
|
|
return strict || isValid || !(isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
|
|
|
pos++, {
|
|
|
pos: pos
|
|
|
@@ -1586,7 +1578,7 @@
|
|
|
validator: function(chrs, maskset, pos, strict, opts) {
|
|
|
if (opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) {
|
|
|
var dayMonthValue = maskset.buffer.join("").substr(0, 6);
|
|
|
- if (dayMonthValue != opts.leapday) return !0;
|
|
|
+ if (dayMonthValue !== opts.leapday) return !0;
|
|
|
var year = parseInt(chrs, 10);
|
|
|
return year % 4 === 0 ? year % 100 === 0 ? year % 400 === 0 ? !0 : !1 : !0 : !1;
|
|
|
}
|
|
|
@@ -1623,7 +1615,7 @@
|
|
|
if (yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs).toString().slice(0, 2),
|
|
|
opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) {
|
|
|
var dayMonthValue = maskset.buffer.join("").substr(0, 6);
|
|
|
- if (dayMonthValue != opts.leapday) isValid = !0; else {
|
|
|
+ if (dayMonthValue !== opts.leapday) isValid = !0; else {
|
|
|
var year = parseInt(chrs, 10);
|
|
|
isValid = year % 4 === 0 ? year % 100 === 0 ? year % 400 === 0 ? !0 : !1 : !0 : !1;
|
|
|
}
|
|
|
@@ -1669,7 +1661,7 @@
|
|
|
leapday: "02/29/",
|
|
|
onKeyDown: function(e, buffer, caretPos, opts) {
|
|
|
var $input = $(this);
|
|
|
- if (e.ctrlKey && e.keyCode == Inputmask.keyCode.RIGHT) {
|
|
|
+ if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
|
|
|
var today = new Date();
|
|
|
$input.val((today.getMonth() + 1).toString() + today.getDate().toString() + today.getFullYear().toString()),
|
|
|
$input.triggerHandler("setvalue.inputmask");
|
|
|
@@ -1683,7 +1675,7 @@
|
|
|
leapday: "/02/29",
|
|
|
onKeyDown: function(e, buffer, caretPos, opts) {
|
|
|
var $input = $(this);
|
|
|
- if (e.ctrlKey && e.keyCode == Inputmask.keyCode.RIGHT) {
|
|
|
+ if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
|
|
|
var today = new Date();
|
|
|
$input.val(today.getFullYear().toString() + (today.getMonth() + 1).toString() + today.getDate().toString()),
|
|
|
$input.triggerHandler("setvalue.inputmask");
|
|
|
@@ -1749,7 +1741,7 @@
|
|
|
definitions: {
|
|
|
h: {
|
|
|
validator: function(chrs, maskset, pos, strict, opts) {
|
|
|
- if ("24" == opts.hourFormat && 24 == parseInt(chrs, 10)) return maskset.buffer[pos - 1] = "0",
|
|
|
+ if ("24" === opts.hourFormat && 24 === parseInt(chrs, 10)) return maskset.buffer[pos - 1] = "0",
|
|
|
maskset.buffer[pos] = "0", {
|
|
|
refreshFromBuffer: {
|
|
|
start: pos - 1,
|
|
|
@@ -1758,7 +1750,7 @@
|
|
|
c: "0"
|
|
|
};
|
|
|
var isValid = opts.regex.hrs.test(chrs);
|
|
|
- if (!strict && !isValid && (chrs.charAt(1) == opts.timeseparator || -1 != "-.:".indexOf(chrs.charAt(1))) && (isValid = opts.regex.hrs.test("0" + chrs.charAt(0)))) return maskset.buffer[pos - 1] = "0",
|
|
|
+ if (!strict && !isValid && (chrs.charAt(1) === opts.timeseparator || -1 !== "-.:".indexOf(chrs.charAt(1))) && (isValid = opts.regex.hrs.test("0" + chrs.charAt(0)))) return maskset.buffer[pos - 1] = "0",
|
|
|
maskset.buffer[pos] = chrs.charAt(0), pos++, {
|
|
|
refreshFromBuffer: {
|
|
|
start: pos - 2,
|
|
|
@@ -1769,7 +1761,7 @@
|
|
|
};
|
|
|
if (isValid && "24" !== opts.hourFormat && opts.regex.hrs24.test(chrs)) {
|
|
|
var tmp = parseInt(chrs, 10);
|
|
|
- return 24 == tmp ? (maskset.buffer[pos + 5] = "a", maskset.buffer[pos + 6] = "m") : (maskset.buffer[pos + 5] = "p",
|
|
|
+ return 24 === tmp ? (maskset.buffer[pos + 5] = "a", maskset.buffer[pos + 6] = "m") : (maskset.buffer[pos + 5] = "p",
|
|
|
maskset.buffer[pos + 6] = "m"), tmp -= 12, 10 > tmp ? (maskset.buffer[pos] = tmp.toString(),
|
|
|
maskset.buffer[pos - 1] = "0") : (maskset.buffer[pos] = tmp.toString().charAt(1),
|
|
|
maskset.buffer[pos - 1] = tmp.toString().charAt(0)), {
|
|
|
@@ -1962,8 +1954,8 @@
|
|
|
definitions: {
|
|
|
i: {
|
|
|
validator: function(chrs, maskset, pos, strict, opts) {
|
|
|
- return pos - 1 > -1 && "." != maskset.buffer[pos - 1] ? (chrs = maskset.buffer[pos - 1] + chrs,
|
|
|
- chrs = pos - 2 > -1 && "." != maskset.buffer[pos - 2] ? maskset.buffer[pos - 2] + chrs : "0" + chrs) : chrs = "00" + chrs,
|
|
|
+ return pos - 1 > -1 && "." !== maskset.buffer[pos - 1] ? (chrs = maskset.buffer[pos - 1] + chrs,
|
|
|
+ chrs = pos - 2 > -1 && "." !== maskset.buffer[pos - 2] ? maskset.buffer[pos - 2] + chrs : "0" + chrs) : chrs = "00" + chrs,
|
|
|
new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]").test(chrs);
|
|
|
},
|
|
|
cardinality: 1
|
|
|
@@ -2430,7 +2422,7 @@
|
|
|
nojumpsThreshold: 1,
|
|
|
onBeforeMask: function(value, opts) {
|
|
|
var processedValue = value.replace(/^0/g, "");
|
|
|
- return (processedValue.indexOf(opts.countrycode) > 1 || -1 == processedValue.indexOf(opts.countrycode)) && (processedValue = "+" + opts.countrycode + processedValue),
|
|
|
+ return (processedValue.indexOf(opts.countrycode) > 1 || -1 === processedValue.indexOf(opts.countrycode)) && (processedValue = "+" + opts.countrycode + processedValue),
|
|
|
processedValue;
|
|
|
}
|
|
|
},
|
|
|
@@ -2457,7 +2449,7 @@
|
|
|
definitions: {
|
|
|
r: {
|
|
|
validator: function(chrs, maskset, pos, strict, opts) {
|
|
|
- function regexToken(isGroup, isQuantifier) {
|
|
|
+ function RegexToken(isGroup, isQuantifier) {
|
|
|
this.matches = [], this.isGroup = isGroup || !1, this.isQuantifier = isQuantifier || !1,
|
|
|
this.quantifier = {
|
|
|
min: 1,
|
|
|
@@ -2465,41 +2457,33 @@
|
|
|
}, this.repeaterPart = void 0;
|
|
|
}
|
|
|
function analyseRegex() {
|
|
|
- var match, m, currentToken = new regexToken(), opengroups = [];
|
|
|
+ var match, m, currentToken = new RegexToken(), opengroups = [];
|
|
|
for (opts.regexTokens = []; match = opts.tokenizer.exec(opts.regex); ) switch (m = match[0],
|
|
|
m.charAt(0)) {
|
|
|
case "(":
|
|
|
- opengroups.push(new regexToken(!0));
|
|
|
+ opengroups.push(new RegexToken(!0));
|
|
|
break;
|
|
|
|
|
|
case ")":
|
|
|
- var groupToken = opengroups.pop();
|
|
|
- opengroups.length > 0 ? opengroups[opengroups.length - 1].matches.push(groupToken) : currentToken.matches.push(groupToken);
|
|
|
+ groupToken = opengroups.pop(), opengroups.length > 0 ? opengroups[opengroups.length - 1].matches.push(groupToken) : currentToken.matches.push(groupToken);
|
|
|
break;
|
|
|
|
|
|
case "{":
|
|
|
case "+":
|
|
|
case "*":
|
|
|
- var quantifierToken = new regexToken(!1, !0);
|
|
|
+ var quantifierToken = new RegexToken(!1, !0);
|
|
|
m = m.replace(/[{}]/g, "");
|
|
|
- var mq = m.split(","), mq0 = isNaN(mq[0]) ? mq[0] : parseInt(mq[0]), mq1 = 1 == mq.length ? mq0 : isNaN(mq[1]) ? mq[1] : parseInt(mq[1]);
|
|
|
+ var mq = m.split(","), mq0 = isNaN(mq[0]) ? mq[0] : parseInt(mq[0]), mq1 = 1 === mq.length ? mq0 : isNaN(mq[1]) ? mq[1] : parseInt(mq[1]);
|
|
|
if (quantifierToken.quantifier = {
|
|
|
min: mq0,
|
|
|
max: mq1
|
|
|
}, opengroups.length > 0) {
|
|
|
var matches = opengroups[opengroups.length - 1].matches;
|
|
|
- if (match = matches.pop(), !match.isGroup) {
|
|
|
- var groupToken = new regexToken(!0);
|
|
|
- groupToken.matches.push(match), match = groupToken;
|
|
|
- }
|
|
|
- matches.push(match), matches.push(quantifierToken);
|
|
|
- } else {
|
|
|
- if (match = currentToken.matches.pop(), !match.isGroup) {
|
|
|
- var groupToken = new regexToken(!0);
|
|
|
- groupToken.matches.push(match), match = groupToken;
|
|
|
- }
|
|
|
- currentToken.matches.push(match), currentToken.matches.push(quantifierToken);
|
|
|
- }
|
|
|
+ match = matches.pop(), match.isGroup || (groupToken = new RegexToken(!0), groupToken.matches.push(match),
|
|
|
+ match = groupToken), matches.push(match), matches.push(quantifierToken);
|
|
|
+ } else match = currentToken.matches.pop(), match.isGroup || (groupToken = new RegexToken(!0),
|
|
|
+ groupToken.matches.push(match), match = groupToken), currentToken.matches.push(match),
|
|
|
+ currentToken.matches.push(quantifierToken);
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
@@ -2512,24 +2496,24 @@
|
|
|
fromGroup && (regexPart += "(", openGroupCount++);
|
|
|
for (var mndx = 0; mndx < token.matches.length; mndx++) {
|
|
|
var matchToken = token.matches[mndx];
|
|
|
- if (1 == matchToken.isGroup) isvalid = validateRegexToken(matchToken, !0); else if (1 == matchToken.isQuantifier) {
|
|
|
+ if (matchToken.isGroup === !0) isvalid = validateRegexToken(matchToken, !0); else if (matchToken.isQuantifier === !0) {
|
|
|
var crrntndx = $.inArray(matchToken, token.matches), matchGroup = token.matches[crrntndx - 1], regexPartBak = regexPart;
|
|
|
if (isNaN(matchToken.quantifier.max)) {
|
|
|
- for (;matchToken.repeaterPart && matchToken.repeaterPart != regexPart && matchToken.repeaterPart.length > regexPart.length && !(isvalid = validateRegexToken(matchGroup, !0)); ) ;
|
|
|
+ for (;matchToken.repeaterPart && matchToken.repeaterPart !== regexPart && matchToken.repeaterPart.length > regexPart.length && !(isvalid = validateRegexToken(matchGroup, !0)); ) ;
|
|
|
isvalid = isvalid || validateRegexToken(matchGroup, !0), isvalid && (matchToken.repeaterPart = regexPart),
|
|
|
regexPart = regexPartBak + matchToken.quantifier.max;
|
|
|
} else {
|
|
|
for (var i = 0, qm = matchToken.quantifier.max - 1; qm > i && !(isvalid = validateRegexToken(matchGroup, !0)); i++) ;
|
|
|
regexPart = regexPartBak + "{" + matchToken.quantifier.min + "," + matchToken.quantifier.max + "}";
|
|
|
}
|
|
|
- } else if (void 0 != matchToken.matches) for (var k = 0; k < matchToken.length && !(isvalid = validateRegexToken(matchToken[k], fromGroup)); k++) ; else {
|
|
|
+ } else if (void 0 !== matchToken.matches) for (var k = 0; k < matchToken.length && !(isvalid = validateRegexToken(matchToken[k], fromGroup)); k++) ; else {
|
|
|
var testExp;
|
|
|
if ("[" == matchToken.charAt(0)) {
|
|
|
testExp = regexPart, testExp += matchToken;
|
|
|
for (var j = 0; openGroupCount > j; j++) testExp += ")";
|
|
|
var exp = new RegExp("^(" + testExp + ")$");
|
|
|
isvalid = exp.test(bufferStr);
|
|
|
- } else for (var l = 0, tl = matchToken.length; tl > l; l++) if ("\\" != matchToken.charAt(l)) {
|
|
|
+ } else for (var l = 0, tl = matchToken.length; tl > l; l++) if ("\\" !== matchToken.charAt(l)) {
|
|
|
testExp = regexPart, testExp += matchToken.substr(0, l + 1), testExp = testExp.replace(/\|$/, "");
|
|
|
for (var j = 0; openGroupCount > j; j++) testExp += ")";
|
|
|
var exp = new RegExp("^(" + testExp + ")$");
|
|
|
@@ -2541,9 +2525,8 @@
|
|
|
}
|
|
|
return fromGroup && (regexPart += ")", openGroupCount--), isvalid;
|
|
|
}
|
|
|
- null == opts.regexTokens && analyseRegex();
|
|
|
- var cbuffer = maskset.buffer.slice(), regexPart = "", isValid = !1, openGroupCount = 0;
|
|
|
- cbuffer.splice(pos, 0, chrs);
|
|
|
+ var groupToken, cbuffer = maskset.buffer.slice(), regexPart = "", isValid = !1, openGroupCount = 0;
|
|
|
+ null === opts.regexTokens && analyseRegex(), cbuffer.splice(pos, 0, chrs);
|
|
|
for (var bufferStr = cbuffer.join(""), i = 0; i < opts.regexTokens.length; i++) {
|
|
|
var regexToken = opts.regexTokens[i];
|
|
|
if (isValid = validateRegexToken(regexToken, regexToken.isGroup)) break;
|