|
|
@@ -1600,7 +1600,7 @@ function maskScope(actionObj, maskset, opts) {
|
|
|
|
|
|
if (maxLength === undefined || maskPos < maxLength) {
|
|
|
result = _isValid(maskPos, c, strict);
|
|
|
- console.log(maskPos + " " + c + " " + JSON.stringify(getMaskSet().jitOffset))
|
|
|
+ // console.log(maskPos + " " + c + " " + JSON.stringify(getMaskSet().jitOffset))
|
|
|
if ((!strict || fromIsValid === true) && result === false && validateOnly !== true) {
|
|
|
var currentPosValid = getMaskSet().validPositions[maskPos];
|
|
|
if (currentPosValid && currentPosValid.match.fn === null && (currentPosValid.match.def === c || c === opts.skipOptionalPartCharacter)) {
|
|
|
@@ -1663,7 +1663,7 @@ function maskScope(actionObj, maskset, opts) {
|
|
|
|
|
|
//fill in best positions according the current input
|
|
|
function trackbackPositions(originalPos, newPos, fillOnly) {
|
|
|
- // console.log("trackbackPositions " + originalPos + " " + newPos);
|
|
|
+ console.log("trackbackPositions " + originalPos + " " + newPos);
|
|
|
var result;
|
|
|
if (originalPos === undefined) {
|
|
|
//find previous valid
|
|
|
@@ -1678,16 +1678,20 @@ function maskScope(actionObj, maskset, opts) {
|
|
|
var tests = getTests(ps).slice()
|
|
|
if (tests[tests.length - 1].match.def === "") tests.pop();
|
|
|
var bestMatch = determineTestTemplate(ps, tests);
|
|
|
- bestMatch = $.extend({}, bestMatch, {
|
|
|
- "input": getPlaceholder(ps, bestMatch.match, true) || bestMatch.match.def
|
|
|
- });
|
|
|
- bestMatch.generatedInput = true;
|
|
|
- revalidateMask(ps, bestMatch, true);
|
|
|
- if (fillOnly !== true) {
|
|
|
- //revalidate the new position to update the locator value
|
|
|
- var cvpInput = getMaskSet().validPositions[newPos].input;
|
|
|
- getMaskSet().validPositions[newPos] = undefined;
|
|
|
- result = isValid(newPos, cvpInput, true, true);
|
|
|
+ if (bestMatch && (bestMatch.match.jit !== true && originalPos !== undefined)) {
|
|
|
+ console.log("bestmatch " + JSON.stringify(bestMatch));
|
|
|
+ console.log("newpos " + JSON.stringify(getTest(newPos)));
|
|
|
+ bestMatch = $.extend({}, bestMatch, {
|
|
|
+ "input": getPlaceholder(ps, bestMatch.match, true) || bestMatch.match.def
|
|
|
+ });
|
|
|
+ bestMatch.generatedInput = true;
|
|
|
+ revalidateMask(ps, bestMatch, true);
|
|
|
+ if (fillOnly !== true) {
|
|
|
+ //revalidate the new position to update the locator value
|
|
|
+ var cvpInput = getMaskSet().validPositions[newPos].input;
|
|
|
+ getMaskSet().validPositions[newPos] = undefined;
|
|
|
+ result = isValid(newPos, cvpInput, true, true);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -2047,6 +2051,19 @@ function maskScope(actionObj, maskset, opts) {
|
|
|
$input = $(input),
|
|
|
k = e.which || e.charCode || e.keyCode;
|
|
|
|
|
|
+
|
|
|
+ function hanndleRadixDance(pos, c) {
|
|
|
+ if (opts._radixDance && opts.numericInput) {
|
|
|
+ var radixPos = getBuffer().indexOf(opts.radixPoint.charAt(0)) + 1;
|
|
|
+ if (pos.begin <= radixPos && (radixPos > 1 || c == opts.radixPoint)) {
|
|
|
+ if (c == opts.radixPoint && radixPos > 1) offset = 1;
|
|
|
+ pos.begin -= 1;
|
|
|
+ pos.end -= 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return pos;
|
|
|
+ }
|
|
|
+
|
|
|
if (checkval !== true && (!(e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable))) {
|
|
|
if (k === Inputmask.keyCode.ENTER && undoValue !== getBuffer().join("")) {
|
|
|
undoValue = getBuffer().join("");
|
|
|
@@ -2056,52 +2073,41 @@ function maskScope(actionObj, maskset, opts) {
|
|
|
}, 0);
|
|
|
}
|
|
|
return true;
|
|
|
- } else {
|
|
|
- if (k) {
|
|
|
- //special treat the decimal separator
|
|
|
- if (k === 46 && e.shiftKey === false && opts.radixPoint !== "") k = opts.radixPoint.charCodeAt(0);
|
|
|
- var pos = checkval ? {
|
|
|
- begin: ndx,
|
|
|
- end: ndx
|
|
|
- } : caret(input),
|
|
|
- forwardPosition, c = String.fromCharCode(k), offset = 0;
|
|
|
-
|
|
|
- if (opts._radixDance && opts.numericInput) {
|
|
|
- var radixPos = getBuffer().indexOf(opts.radixPoint.charAt(0)) + 1;
|
|
|
- if (pos.begin <= radixPos && (radixPos > 1 || c == opts.radixPoint)) {
|
|
|
- if (c == opts.radixPoint && radixPos > 1) offset = 1;
|
|
|
- pos.begin -= 1;
|
|
|
- pos.end -= 1;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- getMaskSet().writeOutBuffer = true;
|
|
|
- var valResult = isValid(pos, c, strict);
|
|
|
- if (valResult !== false) {
|
|
|
- resetMaskSet(true);
|
|
|
- forwardPosition = valResult.caret !== undefined ? valResult.caret : seekNext(valResult.pos.begin ? valResult.pos.begin : valResult.pos);
|
|
|
- getMaskSet().p = forwardPosition; //needed for checkval
|
|
|
- }
|
|
|
+ } else if (k) {
|
|
|
+ //special treat the decimal separator
|
|
|
+ if (k === 46 && e.shiftKey === false && opts.radixPoint !== "") k = opts.radixPoint.charCodeAt(0);
|
|
|
+ var pos = checkval ? {
|
|
|
+ begin: ndx,
|
|
|
+ end: ndx
|
|
|
+ } : caret(input),
|
|
|
+ forwardPosition, c = String.fromCharCode(k), offset = 0;
|
|
|
+ pos = hanndleRadixDance(pos, c);
|
|
|
+
|
|
|
+ getMaskSet().writeOutBuffer = true;
|
|
|
+ var valResult = isValid(pos, c, strict);
|
|
|
+ if (valResult !== false) {
|
|
|
+ resetMaskSet(true);
|
|
|
+ forwardPosition = valResult.caret !== undefined ? valResult.caret : seekNext(valResult.pos.begin ? valResult.pos.begin : valResult.pos);
|
|
|
+ getMaskSet().p = forwardPosition; //needed for checkval
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- forwardPosition = ((opts.numericInput && valResult.caret === undefined) ? seekPrevious(forwardPosition) : forwardPosition) + offset;
|
|
|
- if (writeOut !== false) {
|
|
|
- setTimeout(function () {
|
|
|
- opts.onKeyValidation.call(input, k, valResult, opts);
|
|
|
- }, 0);
|
|
|
- if (getMaskSet().writeOutBuffer && valResult !== false) {
|
|
|
- var buffer = getBuffer();
|
|
|
- writeBuffer(input, buffer, forwardPosition, e, checkval !== true);
|
|
|
- }
|
|
|
+ forwardPosition = ((opts.numericInput && valResult.caret === undefined) ? seekPrevious(forwardPosition) : forwardPosition) + offset;
|
|
|
+ if (writeOut !== false) {
|
|
|
+ setTimeout(function () {
|
|
|
+ opts.onKeyValidation.call(input, k, valResult, opts);
|
|
|
+ }, 0);
|
|
|
+ if (getMaskSet().writeOutBuffer && valResult !== false) {
|
|
|
+ var buffer = getBuffer();
|
|
|
+ writeBuffer(input, buffer, forwardPosition, e, checkval !== true);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- e.preventDefault();
|
|
|
+ e.preventDefault();
|
|
|
|
|
|
- if (checkval) {
|
|
|
- if (valResult !== false) valResult.forwardPosition = forwardPosition;
|
|
|
- return valResult;
|
|
|
- }
|
|
|
+ if (checkval) {
|
|
|
+ if (valResult !== false) valResult.forwardPosition = forwardPosition;
|
|
|
+ return valResult;
|
|
|
}
|
|
|
}
|
|
|
},
|