|
|
@@ -24,14 +24,14 @@ function autoEscape(txt, opts) {
|
|
|
return escapedTxt;
|
|
|
}
|
|
|
|
|
|
-function alignDigits(buffer, opts) {
|
|
|
+function alignDigits(buffer, digits, opts) {
|
|
|
if (buffer.length > 0) {
|
|
|
var radixPosition = $.inArray(opts.radixPoint, buffer);
|
|
|
if (radixPosition === -1) {
|
|
|
buffer.push(opts.radixPoint);
|
|
|
radixPosition = buffer.length - 1;
|
|
|
}
|
|
|
- for (var i = 1; i <= opts.digits; i++) {
|
|
|
+ for (var i = 1; i <= digits; i++) {
|
|
|
buffer[radixPosition + i] = buffer[radixPosition + i] || "0";
|
|
|
}
|
|
|
}
|
|
|
@@ -72,7 +72,9 @@ Inputmask.extendAliases({
|
|
|
opts.positionCaretOnClick = "lvp";
|
|
|
}
|
|
|
|
|
|
+ var decimalDef = "0";
|
|
|
if (opts.numericInput === true) { //finance people input style
|
|
|
+ decimalDef = "9";
|
|
|
opts.positionCaretOnClick = opts.positionCaretOnClick === "radixFocus" ? "lvp" : opts.positionCaretOnClick;
|
|
|
opts.digitsOptional = false;
|
|
|
if (isNaN(opts.digits)) opts.digits = 2;
|
|
|
@@ -87,19 +89,17 @@ Inputmask.extendAliases({
|
|
|
if (opts.digits !== undefined) {
|
|
|
var dq = opts.digits.toString().split(",");
|
|
|
if (isFinite(dq[0]) && dq[1] && isFinite(dq[1])) {
|
|
|
- mask += opts.radixPoint + "0{" + opts.digits + "}";
|
|
|
+ mask += opts.radixPoint + decimalDef + "{" + opts.digits + "}";
|
|
|
} else if (isNaN(opts.digits) || parseInt(opts.digits) > 0) {
|
|
|
if (opts.digitsOptional) {
|
|
|
- mask += "[" + opts.radixPoint + "0{1," + opts.digits + "}]";
|
|
|
- } else mask += opts.radixPoint + "0{" + opts.digits + "}";
|
|
|
+ mask += "[" + opts.radixPoint + decimalDef + "{1," + opts.digits + "}]";
|
|
|
+ } else mask += opts.radixPoint + decimalDef + "{" + opts.digits + "}";
|
|
|
}
|
|
|
}
|
|
|
mask += autoEscape(opts.suffix, opts);
|
|
|
mask += "[-]";
|
|
|
|
|
|
opts.greedy = false; //enforce greedy false
|
|
|
-
|
|
|
-
|
|
|
console.log(mask);
|
|
|
return mask;
|
|
|
},
|
|
|
@@ -162,7 +162,7 @@ Inputmask.extendAliases({
|
|
|
caret: radixPos >= pos ? pos + 1 : pos
|
|
|
};
|
|
|
}
|
|
|
- if (isSelection === false && c === opts.radixPoint && (opts.digits !== undefined && (isNaN(opts.digits) || parseInt(opts.digits) > 0)) && radixPos !== pos) return {
|
|
|
+ if (opts._radixDance === true && isSelection === false && c === opts.radixPoint && (opts.digits !== undefined && (isNaN(opts.digits) || parseInt(opts.digits) > 0)) && radixPos !== pos) return {
|
|
|
"caret": opts._radixDance && pos > radixPos ? radixPos : radixPos - 1
|
|
|
};
|
|
|
|
|
|
@@ -191,7 +191,7 @@ Inputmask.extendAliases({
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- var input = this;
|
|
|
+ var input = this.el, result;
|
|
|
if (e) {
|
|
|
switch (e.type) {
|
|
|
case "blur":
|
|
|
@@ -203,15 +203,14 @@ Inputmask.extendAliases({
|
|
|
unmaskAsNumber: true
|
|
|
}));
|
|
|
if (opts.min !== null && unmasked < opts.min) {
|
|
|
- input.value = opts.min;
|
|
|
- $(input).trigger("setvalue");
|
|
|
+ result = {refreshFromBuffer: true, buffer: opts.min.toString().split("")};
|
|
|
} else if (opts.max !== null && unmasked > opts.max) {
|
|
|
- input.value = opts.max;
|
|
|
- $(input).trigger("setvalue");
|
|
|
+ result = {refreshFromBuffer: true, buffer: opts.max.toString().split("")};
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ return result;
|
|
|
},
|
|
|
onUnMask: function (maskedValue, unmaskedValue, opts) {
|
|
|
if (unmaskedValue === "" && opts.nullable === true) {
|