|
|
@@ -231,7 +231,7 @@
|
|
|
(-1 == closestTo || null != valids[psNdx].match.fn) && (closestTo >= psNdx && (before = psNdx),
|
|
|
psNdx >= closestTo && (after = psNdx));
|
|
|
}
|
|
|
- return lastValidPosition = closestTo - before > 1 || closestTo > after ? before : after;
|
|
|
+ return lastValidPosition = -1 != before && closestTo - before > 1 || closestTo > after ? before : after;
|
|
|
}
|
|
|
function setValidPosition(pos, validTest, fromSetValid) {
|
|
|
if (opts.insertMode && void 0 != getMaskSet().validPositions[pos] && void 0 == fromSetValid) {
|
|
|
@@ -552,7 +552,7 @@
|
|
|
function checkVal(input, writeOut, strict, nptvl) {
|
|
|
function isTemplateMatch() {
|
|
|
var isMatch = !1, charCodeNdx = getBufferTemplate().slice(initialNdx, seekNext(initialNdx)).join("").indexOf(charCodes);
|
|
|
- if (-1 != charCodeNdx) {
|
|
|
+ if (-1 != charCodeNdx && !isMask(initialNdx)) {
|
|
|
isMatch = !0;
|
|
|
for (var bufferTemplateArr = getBufferTemplate().slice(initialNdx, initialNdx + charCodeNdx), i = 0; i < bufferTemplateArr.length; i++) if (" " != bufferTemplateArr[i]) {
|
|
|
isMatch = !1;
|
|
|
@@ -567,6 +567,7 @@
|
|
|
matches && matches.length > 0 && inputValue.splice(0, staticInput.length * matches.length);
|
|
|
var charCodes = "", initialNdx = 0;
|
|
|
$.each(inputValue, function(ndx, charCode) {
|
|
|
+ console.log("checkval " + charCode);
|
|
|
var keypress = $.Event("keypress");
|
|
|
keypress.which = charCode.charCodeAt(0), charCodes += charCode;
|
|
|
var lvp = getLastValidPosition(), lvTest = getMaskSet().validPositions[lvp], nextTest = getTestTemplate(lvp + 1, lvTest ? lvTest.locator.slice() : void 0, lvp);
|
|
|
@@ -858,7 +859,12 @@
|
|
|
function pasteEvent(e) {
|
|
|
var input = this, $input = $(input), inputValue = input._valueGet(!0), caretPos = caret(input);
|
|
|
if ("propertychange" == e.type && input._valueGet().length <= getMaskLength()) return !0;
|
|
|
- "paste" == e.type && (window.clipboardData && window.clipboardData.getData ? inputValue = inputValue.substr(0, caretPos.begin) + window.clipboardData.getData("Text") + inputValue.substr(caretPos.end, inputValue.length) : e.originalEvent && e.originalEvent.clipboardData && e.originalEvent.clipboardData.getData && (inputValue = inputValue.substr(0, caretPos.begin) + e.originalEvent.clipboardData.getData("text/plain") + inputValue.substr(caretPos.end, inputValue.length)));
|
|
|
+ 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 = ""),
|
|
|
+ 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 = $.isFunction(opts.onBeforePaste) ? opts.onBeforePaste.call(input, inputValue, opts) || inputValue : inputValue;
|
|
|
return checkVal(input, !0, !1, isRTL ? pasteValue.split("").reverse() : pasteValue.split("")),
|
|
|
$input.click(), isComplete(getBuffer()) === !0 && $input.trigger("complete"), !1;
|
|
|
@@ -1879,7 +1885,7 @@
|
|
|
onBeforeWrite: function(e, buffer, caretPos, opts) {
|
|
|
if (e && "blur" == e.type) {
|
|
|
var tmpBufSplit = "" != opts.radixPoint ? buffer.join("").split(opts.radixPoint) : [ buffer.join("") ], matchRslt = tmpBufSplit[0].match(opts.regex.integerPart(opts)), matchRsltDigits = 2 == tmpBufSplit.length ? tmpBufSplit[1].match(opts.regex.integerNPart(opts)) : void 0;
|
|
|
- matchRslt && "-0" == matchRslt[matchRslt.index] && (void 0 == matchRsltDigits || matchRsltDigits[matchRsltDigits.index].match(/^0+$/)) && buffer.splice(0, 1);
|
|
|
+ matchRslt && "-0" == matchRslt[0] && (void 0 == matchRsltDigits || matchRsltDigits[0].match(/^0+$/)) && buffer.splice(0, 1);
|
|
|
var radixPosition = $.inArray(opts.radixPoint, buffer);
|
|
|
if (-1 != radixPosition && isFinite(opts.digits) && !opts.digitsOptional) {
|
|
|
for (var i = 1; i <= opts.digits; i++) (void 0 == buffer[radixPosition + i] || buffer[radixPosition + i] == opts.placeholder.charAt(0)) && (buffer[radixPosition + i] = "0");
|
|
|
@@ -1905,7 +1911,7 @@
|
|
|
signHandler: function(chrs, maskset, pos, strict, opts) {
|
|
|
if (!strict && (opts.allowMinus && "-" === chrs || opts.allowPlus && "+" === chrs)) {
|
|
|
var matchRslt = maskset.buffer.join("").match(opts.regex.integerPart(opts));
|
|
|
- if (matchRslt && matchRslt[matchRslt.index].length > 0 && ("0" !== matchRslt[matchRslt.index] || maskset.buffer && maskset._buffer && maskset.buffer.join("") != maskset._buffer.join(""))) return maskset.buffer[matchRslt.index] == ("-" === chrs ? "+" : "-") ? {
|
|
|
+ if (matchRslt && matchRslt[0].length > 0 && ("0" !== matchRslt[0] || maskset.buffer && maskset._buffer && maskset.buffer.join("") != maskset._buffer.join(""))) return maskset.buffer[matchRslt.index] == ("-" === chrs ? "+" : "-") ? {
|
|
|
pos: matchRslt.index,
|
|
|
c: chrs,
|
|
|
remove: matchRslt.index,
|
|
|
@@ -1940,22 +1946,20 @@
|
|
|
},
|
|
|
leadingZeroHandler: function(chrs, maskset, pos, strict, opts) {
|
|
|
var matchRslt = maskset.buffer.join("").match(opts.regex.integerNPart(opts)), radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
|
|
|
- if (matchRslt && !strict && (-1 == radixPosition || matchRslt.index < radixPosition)) if ("0" == matchRslt[0] && pos >= opts.prefix.length) {
|
|
|
- if (-1 == radixPosition || radixPosition >= pos && void 0 == maskset.validPositions[radixPosition]) return maskset.buffer.splice(matchRslt.index, 1),
|
|
|
+ if (matchRslt && !strict && (-1 == radixPosition || radixPosition >= pos) && 0 == matchRslt[0].indexOf("0")) {
|
|
|
+ pos < opts.prefix.length && (pos = matchRslt.index);
|
|
|
+ var digitsMatch = maskset._buffer && maskset.buffer.slice(radixPosition).join("") == maskset._buffer.slice(radixPosition).join(""), integerMatch = maskset._buffer && maskset.buffer.slice(opts.prefix.length, radixPosition).join("") == maskset._buffer.slice(opts.prefix.length, radixPosition).join("");
|
|
|
+ if (-1 == radixPosition || digitsMatch && integerMatch) return maskset.buffer.splice(matchRslt.index, 1),
|
|
|
pos = pos > matchRslt.index ? pos - 1 : matchRslt.index, {
|
|
|
pos: pos,
|
|
|
remove: matchRslt.index
|
|
|
};
|
|
|
- if (pos >= matchRslt.index && radixPosition >= pos) return maskset.buffer.splice(matchRslt.index, 1),
|
|
|
- pos = pos > matchRslt.index ? pos - 1 : matchRslt.index, {
|
|
|
+ if (matchRslt.index + 1 == pos || "0" == chrs) return maskset.buffer.splice(matchRslt.index, 1),
|
|
|
+ pos = matchRslt.index, {
|
|
|
pos: pos,
|
|
|
remove: matchRslt.index
|
|
|
};
|
|
|
- if (void 0 == maskset.validPositions[radixPosition]) return maskset.buffer[pos] = chrs,
|
|
|
- {
|
|
|
- refreshFromBuffer: !0
|
|
|
- };
|
|
|
- } else if ("0" == chrs && pos <= matchRslt.index) return !1;
|
|
|
+ }
|
|
|
return !0;
|
|
|
},
|
|
|
definitions: {
|