|
@@ -28,8 +28,9 @@
|
|
|
opts.quantifiermarker.end === txt.charAt(i) ||
|
|
opts.quantifiermarker.end === txt.charAt(i) ||
|
|
|
opts.groupmarker.start === txt.charAt(i) ||
|
|
opts.groupmarker.start === txt.charAt(i) ||
|
|
|
opts.groupmarker.end === txt.charAt(i) ||
|
|
opts.groupmarker.end === txt.charAt(i) ||
|
|
|
- opts.alternatormarker === txt.charAt(i))
|
|
|
|
|
|
|
+ opts.alternatormarker === txt.charAt(i)) {
|
|
|
escapedTxt += "\\" + txt.charAt(i)
|
|
escapedTxt += "\\" + txt.charAt(i)
|
|
|
|
|
+ }
|
|
|
else escapedTxt += txt.charAt(i);
|
|
else escapedTxt += txt.charAt(i);
|
|
|
}
|
|
}
|
|
|
return escapedTxt;
|
|
return escapedTxt;
|
|
@@ -137,7 +138,7 @@
|
|
|
unmaskAsNumber: false,
|
|
unmaskAsNumber: false,
|
|
|
inputmode: "numeric",
|
|
inputmode: "numeric",
|
|
|
preValidation: function (buffer, pos, c, isSelection, opts) {
|
|
preValidation: function (buffer, pos, c, isSelection, opts) {
|
|
|
- if (c === "-" || c == opts.negationSymbol.front) {
|
|
|
|
|
|
|
+ if (c === "-" || c === opts.negationSymbol.front) {
|
|
|
if (opts.allowMinus !== true) return false;
|
|
if (opts.allowMinus !== true) return false;
|
|
|
opts.isNegative = opts.isNegative === undefined ? true : !opts.isNegative;
|
|
opts.isNegative = opts.isNegative === undefined ? true : !opts.isNegative;
|
|
|
if (buffer.join("") === "") return true;
|
|
if (buffer.join("") === "") return true;
|
|
@@ -172,9 +173,9 @@
|
|
|
|
|
|
|
|
var suffix = opts.suffix.split(""), prefix = opts.prefix.split("");
|
|
var suffix = opts.suffix.split(""), prefix = opts.prefix.split("");
|
|
|
|
|
|
|
|
- if (currentResult.pos == undefined && currentResult.caret !== undefined && currentResult.dopost !== true) return currentResult;
|
|
|
|
|
|
|
+ if (currentResult.pos === undefined && currentResult.caret !== undefined && currentResult.dopost !== true) return currentResult;
|
|
|
|
|
|
|
|
- var caretPos = currentResult.caret != undefined ? currentResult.caret : currentResult.pos;
|
|
|
|
|
|
|
+ var caretPos = currentResult.caret !== undefined ? currentResult.caret : currentResult.pos;
|
|
|
var maskedValue = buffer.slice();
|
|
var maskedValue = buffer.slice();
|
|
|
if (opts.numericInput) {
|
|
if (opts.numericInput) {
|
|
|
caretPos = maskedValue.length - caretPos - 1;
|
|
caretPos = maskedValue.length - caretPos - 1;
|
|
@@ -188,7 +189,7 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- if (caretPos == maskedValue.length - opts.suffix.length - 1 && charAtPos === opts.radixPoint) return currentResult;
|
|
|
|
|
|
|
+ if (caretPos === maskedValue.length - opts.suffix.length - 1 && charAtPos === opts.radixPoint) return currentResult;
|
|
|
|
|
|
|
|
if (charAtPos !== undefined) {
|
|
if (charAtPos !== undefined) {
|
|
|
if (charAtPos !== opts.radixPoint &&
|
|
if (charAtPos !== opts.radixPoint &&
|
|
@@ -219,7 +220,7 @@
|
|
|
|
|
|
|
|
//strip leading zeroes
|
|
//strip leading zeroes
|
|
|
if (processValue.length > 1 && processValue.indexOf(opts.radixPoint) !== 1) {
|
|
if (processValue.length > 1 && processValue.indexOf(opts.radixPoint) !== 1) {
|
|
|
- if (charAtPos == "0") {
|
|
|
|
|
|
|
+ if (charAtPos === "0") {
|
|
|
processValue = processValue.replace(/^\?/g, "");
|
|
processValue = processValue.replace(/^\?/g, "");
|
|
|
}
|
|
}
|
|
|
processValue = processValue.replace(/^0/g, "");
|
|
processValue = processValue.replace(/^0/g, "");
|
|
@@ -281,8 +282,9 @@
|
|
|
if (charAtPos !== undefined) {
|
|
if (charAtPos !== undefined) {
|
|
|
if (charAtPos !== opts.radixPoint && charAtPos !== opts.negationSymbol.front && charAtPos !== opts.negationSymbol.back) {
|
|
if (charAtPos !== opts.radixPoint && charAtPos !== opts.negationSymbol.front && charAtPos !== opts.negationSymbol.back) {
|
|
|
caretPos = $.inArray("?", processValue);
|
|
caretPos = $.inArray("?", processValue);
|
|
|
- if (caretPos > -1)
|
|
|
|
|
|
|
+ if (caretPos > -1) {
|
|
|
processValue[caretPos] = charAtPos;
|
|
processValue[caretPos] = charAtPos;
|
|
|
|
|
+ }
|
|
|
else caretPos = currentResult.caret || 0;
|
|
else caretPos = currentResult.caret || 0;
|
|
|
} else if (charAtPos === opts.radixPoint ||
|
|
} else if (charAtPos === opts.radixPoint ||
|
|
|
charAtPos === opts.negationSymbol.front ||
|
|
charAtPos === opts.negationSymbol.front ||
|
|
@@ -397,11 +399,13 @@
|
|
|
processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), "");
|
|
processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), "");
|
|
|
//filter 0 after radixpoint
|
|
//filter 0 after radixpoint
|
|
|
var pvRadixSplit = processValue.split(opts.radixPoint);
|
|
var pvRadixSplit = processValue.split(opts.radixPoint);
|
|
|
- if (pvRadixSplit.length > 1)
|
|
|
|
|
|
|
+ if (pvRadixSplit.length > 1) {
|
|
|
pvRadixSplit[1] = pvRadixSplit[1].replace(/0/g, opts.placeholder.charAt(0));
|
|
pvRadixSplit[1] = pvRadixSplit[1].replace(/0/g, opts.placeholder.charAt(0));
|
|
|
|
|
+ }
|
|
|
//filter 0 before radixpoint
|
|
//filter 0 before radixpoint
|
|
|
- if (pvRadixSplit[0] === "0")
|
|
|
|
|
|
|
+ if (pvRadixSplit[0] === "0") {
|
|
|
pvRadixSplit[0] = pvRadixSplit[0].replace(/0/g, opts.placeholder.charAt(0));
|
|
pvRadixSplit[0] = pvRadixSplit[0].replace(/0/g, opts.placeholder.charAt(0));
|
|
|
|
|
+ }
|
|
|
processValue = pvRadixSplit[0] + opts.radixPoint + pvRadixSplit[1] || "";
|
|
processValue = pvRadixSplit[0] + opts.radixPoint + pvRadixSplit[1] || "";
|
|
|
var bufferTemplate = maskset._buffer.join(""); //getBuffer().slice(lvp).join('');
|
|
var bufferTemplate = maskset._buffer.join(""); //getBuffer().slice(lvp).join('');
|
|
|
if (processValue === opts.radixPoint) {
|
|
if (processValue === opts.radixPoint) {
|
|
@@ -474,8 +478,9 @@
|
|
|
var processValue = maskedValue.replace(opts.prefix, "");
|
|
var processValue = maskedValue.replace(opts.prefix, "");
|
|
|
processValue = processValue.replace(opts.suffix, "");
|
|
processValue = processValue.replace(opts.suffix, "");
|
|
|
processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
|
|
processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
|
|
|
- if (opts.placeholder.charAt(0) !== "")
|
|
|
|
|
|
|
+ if (opts.placeholder.charAt(0) !== "") {
|
|
|
processValue = processValue.replace(new RegExp(opts.placeholder.charAt(0), "g"), "0");
|
|
processValue = processValue.replace(new RegExp(opts.placeholder.charAt(0), "g"), "0");
|
|
|
|
|
+ }
|
|
|
if (opts.unmaskAsNumber) {
|
|
if (opts.unmaskAsNumber) {
|
|
|
if (opts.radixPoint !== "" && processValue.indexOf(opts.radixPoint) !== -1) processValue = processValue.replace(Inputmask.escapeRegex.call(this, opts.radixPoint), ".");
|
|
if (opts.radixPoint !== "" && processValue.indexOf(opts.radixPoint) !== -1) processValue = processValue.replace(Inputmask.escapeRegex.call(this, opts.radixPoint), ".");
|
|
|
processValue = processValue.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), "-");
|
|
processValue = processValue.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), "-");
|
|
@@ -509,8 +514,9 @@
|
|
|
if (opts.radixPoint !== "" && isFinite(initialValue)) {
|
|
if (opts.radixPoint !== "" && isFinite(initialValue)) {
|
|
|
var vs = initialValue.split("."),
|
|
var vs = initialValue.split("."),
|
|
|
groupSize = opts.groupSeparator !== "" ? parseInt(opts.groupSize) : 0;
|
|
groupSize = opts.groupSeparator !== "" ? parseInt(opts.groupSize) : 0;
|
|
|
- if (vs.length === 2 && (vs[0].length > groupSize || vs[1].length > groupSize || (vs[0].length <= groupSize && vs[1].length < groupSize)))
|
|
|
|
|
|
|
+ if (vs.length === 2 && (vs[0].length > groupSize || vs[1].length > groupSize || (vs[0].length <= groupSize && vs[1].length < groupSize))) {
|
|
|
initialValue = initialValue.replace(".", opts.radixPoint);
|
|
initialValue = initialValue.replace(".", opts.radixPoint);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
var kommaMatches = initialValue.match(/,/g);
|
|
var kommaMatches = initialValue.match(/,/g);
|
|
|
var dotMatches = initialValue.match(/\./g);
|
|
var dotMatches = initialValue.match(/\./g);
|
|
@@ -522,7 +528,7 @@
|
|
|
initialValue = initialValue.replace(/,/g, "");
|
|
initialValue = initialValue.replace(/,/g, "");
|
|
|
initialValue = initialValue.replace(".", opts.radixPoint);
|
|
initialValue = initialValue.replace(".", opts.radixPoint);
|
|
|
} else { //equal
|
|
} else { //equal
|
|
|
- initialValue = initialValue.indexOf(".") < initialValue.indexOf(",") ? initialValue.replace(/\./g, "") : initialValue = initialValue.replace(/,/g, "");
|
|
|
|
|
|
|
+ initialValue = initialValue.indexOf(".") < initialValue.indexOf(",") ? initialValue.replace(/\./g, "") : initialValue.replace(/,/g, "");
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
initialValue = initialValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
|
|
initialValue = initialValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
|
|
@@ -566,7 +572,7 @@
|
|
|
vp.input === opts.negationSymbol.front ||
|
|
vp.input === opts.negationSymbol.front ||
|
|
|
vp.input === opts.negationSymbol.back;
|
|
vp.input === opts.negationSymbol.back;
|
|
|
|
|
|
|
|
- if (canClear && (vp.match.nativeDef == "+" || vp.match.nativeDef == "-")) {
|
|
|
|
|
|
|
+ if (canClear && (vp.match.nativeDef === "+" || vp.match.nativeDef === "-")) {
|
|
|
opts.isNegative = false;
|
|
opts.isNegative = false;
|
|
|
}
|
|
}
|
|
|
|
|
|