|
|
@@ -3,21 +3,11 @@
|
|
|
* https://github.com/RobinHerbots/jquery.inputmask
|
|
|
* Copyright (c) 2010 - 2016 Robin Herbots
|
|
|
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
|
-* Version: 3.3.2-63
|
|
|
+* Version: 3.3.2-65
|
|
|
*/
|
|
|
-/*
|
|
|
- Input Mask plugin extensions
|
|
|
- http://github.com/RobinHerbots/jquery.inputmask
|
|
|
- Copyright (c) 2010 - Robin Herbots
|
|
|
- Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
|
- Version: 0.0.0-dev
|
|
|
-
|
|
|
- Optional extensions on the jquery.inputmask base
|
|
|
- */
|
|
|
!function(factory) {
|
|
|
"function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);
|
|
|
}(function($, Inputmask) {
|
|
|
- //number aliases
|
|
|
return Inputmask.extendAliases({
|
|
|
numeric: {
|
|
|
mask: function(opts) {
|
|
|
@@ -26,27 +16,20 @@
|
|
|
return escapedTxt;
|
|
|
}
|
|
|
if (0 !== opts.repeat && isNaN(opts.integerDigits) && (opts.integerDigits = opts.repeat),
|
|
|
- opts.repeat = 0, opts.groupSeparator === opts.radixPoint && (//treat equal separator and radixpoint
|
|
|
- "." === opts.radixPoint ? opts.groupSeparator = "," : "," === opts.radixPoint ? opts.groupSeparator = "." : opts.groupSeparator = ""),
|
|
|
- " " === opts.groupSeparator && (//prevent conflict with default skipOptionalPartCharacter
|
|
|
- opts.skipOptionalPartCharacter = void 0), opts.autoGroup = opts.autoGroup && "" !== opts.groupSeparator,
|
|
|
+ opts.repeat = 0, opts.groupSeparator === opts.radixPoint && ("." === opts.radixPoint ? opts.groupSeparator = "," : "," === opts.radixPoint ? opts.groupSeparator = "." : opts.groupSeparator = ""),
|
|
|
+ " " === opts.groupSeparator && (opts.skipOptionalPartCharacter = void 0), opts.autoGroup = opts.autoGroup && "" !== opts.groupSeparator,
|
|
|
opts.autoGroup && ("string" == typeof opts.groupSize && isFinite(opts.groupSize) && (opts.groupSize = parseInt(opts.groupSize)),
|
|
|
isFinite(opts.integerDigits))) {
|
|
|
var seps = Math.floor(opts.integerDigits / opts.groupSize), mod = opts.integerDigits % opts.groupSize;
|
|
|
opts.integerDigits = parseInt(opts.integerDigits) + (0 === mod ? seps - 1 : seps),
|
|
|
opts.integerDigits < 1 && (opts.integerDigits = "*");
|
|
|
}
|
|
|
- //enforce placeholder to single
|
|
|
opts.placeholder.length > 1 && (opts.placeholder = opts.placeholder.charAt(0)),
|
|
|
- //only allow radixfocus when placeholder = 0
|
|
|
"radixFocus" === opts.positionCaretOnClick && "" === opts.placeholder && opts.integerOptional === !1 && (opts.positionCaretOnClick = "lvp"),
|
|
|
- opts.definitions[";"] = opts.definitions["~"], //clone integer def for decimals
|
|
|
- opts.definitions[";"].definitionSymbol = "~", opts.numericInput === !0 && (//finance people input style
|
|
|
- opts.positionCaretOnClick = "radixFocus" === opts.positionCaretOnClick ? "lvp" : opts.positionCaretOnClick,
|
|
|
+ opts.definitions[";"] = opts.definitions["~"], opts.definitions[";"].definitionSymbol = "~",
|
|
|
+ opts.numericInput === !0 && (opts.positionCaretOnClick = "radixFocus" === opts.positionCaretOnClick ? "lvp" : opts.positionCaretOnClick,
|
|
|
opts.digitsOptional = !1, isNaN(opts.digits) && (opts.digits = 2), opts.decimalProtect = !1);
|
|
|
var mask = autoEscape(opts.prefix);
|
|
|
- //enforce greedy false
|
|
|
- //convert min and max options
|
|
|
return mask += "[+]", mask += opts.integerOptional === !0 ? "~{1," + opts.integerDigits + "}" : "~{" + opts.integerDigits + "}",
|
|
|
void 0 !== opts.digits && (isNaN(opts.digits) || parseInt(opts.digits) > 0) && (opts.decimalProtect && (opts.radixPointDefinitionSymbol = ":"),
|
|
|
mask += opts.digitsOptional ? "[" + (opts.decimalProtect ? ":" : opts.radixPoint) + ";{1," + opts.digits + "}]" : (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}"),
|
|
|
@@ -59,7 +42,6 @@
|
|
|
placeholder: "",
|
|
|
greedy: !1,
|
|
|
digits: "*",
|
|
|
- //number of fractionalDigits
|
|
|
digitsOptional: !0,
|
|
|
radixPoint: ".",
|
|
|
positionCaretOnClick: "radixFocus",
|
|
|
@@ -70,35 +52,26 @@
|
|
|
allowMinus: !0,
|
|
|
negationSymbol: {
|
|
|
front: "-",
|
|
|
- //"("
|
|
|
back: ""
|
|
|
},
|
|
|
integerDigits: "+",
|
|
|
- //number of integerDigits
|
|
|
integerOptional: !0,
|
|
|
prefix: "",
|
|
|
suffix: "",
|
|
|
rightAlign: !0,
|
|
|
decimalProtect: !0,
|
|
|
- //do not allow assumption of decimals input without entering the radixpoint
|
|
|
min: null,
|
|
|
- //minimum value
|
|
|
max: null,
|
|
|
- //maximum value
|
|
|
step: 1,
|
|
|
insertMode: !0,
|
|
|
autoUnmask: !1,
|
|
|
unmaskAsNumber: !1,
|
|
|
postFormat: function(buffer, pos, opts) {
|
|
|
- //this needs to be removed // this is crap
|
|
|
- // console.log(buffer);
|
|
|
opts.numericInput === !0 && (buffer = buffer.reverse(), isFinite(pos) && (pos = buffer.join("").length - pos - 1));
|
|
|
var i, l;
|
|
|
- //position overflow corrections
|
|
|
pos = pos >= buffer.length ? buffer.length - 1 : pos < opts.prefix.length ? opts.prefix.length : pos;
|
|
|
var charAtPos = buffer[pos], cbuf = buffer.slice();
|
|
|
charAtPos === opts.groupSeparator && (cbuf.splice(pos--, 1), charAtPos = cbuf[pos]),
|
|
|
- //mark current pos
|
|
|
cbuf[pos] = "!";
|
|
|
var bufVal = cbuf.join(""), bufValOrigin = bufVal;
|
|
|
if (bufVal = bufVal.replace(new RegExp(Inputmask.escapeRegex(opts.suffix) + "$"), ""),
|
|
|
@@ -114,10 +87,8 @@
|
|
|
}
|
|
|
bufVal = opts.prefix + bufVal + opts.suffix;
|
|
|
var needsRefresh = bufValOrigin !== bufVal;
|
|
|
- if (needsRefresh) //align the length
|
|
|
- for (buffer.length = bufVal.length, i = 0, l = bufVal.length; i < l; i++) buffer[i] = bufVal.charAt(i);
|
|
|
+ if (needsRefresh) for (buffer.length = bufVal.length, i = 0, l = bufVal.length; i < l; i++) buffer[i] = bufVal.charAt(i);
|
|
|
var newPos = $.inArray("!", bufVal);
|
|
|
- // console.log("formatted " + buffer + " refresh " + needsRefresh);
|
|
|
return buffer[newPos] = charAtPos, newPos = opts.numericInput && isFinite(pos) ? buffer.join("").length - newPos - 1 : newPos,
|
|
|
opts.numericInput && (buffer = buffer.reverse(), $.inArray(opts.radixPoint, buffer) < newPos && buffer.join("").length - opts.suffix.length !== newPos && (newPos -= 1)),
|
|
|
{
|
|
|
@@ -132,11 +103,9 @@
|
|
|
var maskedValue = opts.numericInput ? buffer.slice().reverse().join("") : buffer.join(""), processValue = maskedValue.replace(opts.prefix, "");
|
|
|
processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
|
|
|
"," === opts.radixPoint && (processValue = processValue.replace(opts.radixPoint, "."));
|
|
|
- //handle negation symbol
|
|
|
var isNegative = processValue.match(new RegExp("[-" + Inputmask.escapeRegex(opts.negationSymbol.front) + "]", "g"));
|
|
|
if (isNegative = null !== isNegative && 1 === isNegative.length, processValue = processValue.replace(new RegExp("[-" + Inputmask.escapeRegex(opts.negationSymbol.front) + "]", "g"), ""),
|
|
|
processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), ""),
|
|
|
- //strip placeholder at the end
|
|
|
isNaN(opts.placeholder) && (processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.placeholder), "g"), "")),
|
|
|
processValue = processValue === opts.negationSymbol.front ? processValue + "0" : processValue,
|
|
|
"" !== processValue && isFinite(processValue)) {
|
|
|
@@ -273,7 +242,6 @@
|
|
|
!isValid && (isValid = strict ? new RegExp("[0-9" + Inputmask.escapeRegex(opts.groupSeparator) + "]").test(chrs) : new RegExp("[0-9]").test(chrs),
|
|
|
isValid === !0 && (isValid = opts.leadingZeroHandler(chrs, maskset, pos, strict, opts, isSelection),
|
|
|
isValid === !0)))) {
|
|
|
- //handle overwrite when fixed precision
|
|
|
var radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
|
|
|
isValid = radixPosition !== -1 && (opts.digitsOptional === !1 || maskset.validPositions[pos]) && opts.numericInput !== !0 && pos > radixPosition && !strict ? {
|
|
|
pos: pos,
|
|
|
@@ -343,8 +311,7 @@
|
|
|
},
|
|
|
isComplete: function(buffer, opts) {
|
|
|
var maskedValue = buffer.join(""), bufClone = buffer.slice();
|
|
|
- if (//verify separator positions
|
|
|
- opts.postFormat(bufClone, 0, opts), bufClone.join("") !== maskedValue) return !1;
|
|
|
+ if (opts.postFormat(bufClone, 0, opts), bufClone.join("") !== maskedValue) return !1;
|
|
|
var processValue = maskedValue.replace(opts.prefix, "");
|
|
|
return processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
|
|
|
"," === opts.radixPoint && (processValue = processValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".")),
|
|
|
@@ -355,15 +322,13 @@
|
|
|
var kommaMatches = initialValue.match(/,/g), dotMatches = initialValue.match(/\./g);
|
|
|
dotMatches && kommaMatches ? dotMatches.length > kommaMatches.length ? (initialValue = initialValue.replace(/\./g, ""),
|
|
|
initialValue = initialValue.replace(",", opts.radixPoint)) : kommaMatches.length > dotMatches.length ? (initialValue = initialValue.replace(/,/g, ""),
|
|
|
- initialValue = initialValue.replace(".", opts.radixPoint)) : //equal
|
|
|
- initialValue = initialValue.indexOf(".") < initialValue.indexOf(",") ? initialValue.replace(/\./g, "") : initialValue = initialValue.replace(/,/g, "") : initialValue = initialValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
|
|
|
+ initialValue = initialValue.replace(".", opts.radixPoint)) : initialValue = initialValue.indexOf(".") < initialValue.indexOf(",") ? initialValue.replace(/\./g, "") : initialValue = initialValue.replace(/,/g, "") : initialValue = initialValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
|
|
|
}
|
|
|
if (0 === opts.digits && (initialValue.indexOf(".") !== -1 ? initialValue = initialValue.substring(0, initialValue.indexOf(".")) : initialValue.indexOf(",") !== -1 && (initialValue = initialValue.substring(0, initialValue.indexOf(",")))),
|
|
|
"" !== opts.radixPoint && isFinite(opts.digits) && initialValue.indexOf(opts.radixPoint) !== -1) {
|
|
|
var valueParts = initialValue.split(opts.radixPoint), decPart = valueParts[1].match(new RegExp("\\d*"))[0];
|
|
|
if (parseInt(opts.digits) < decPart.toString().length) {
|
|
|
var digitsFactor = Math.pow(10, parseInt(opts.digits));
|
|
|
- //make the initialValue a valid javascript number for the parsefloat
|
|
|
initialValue = initialValue.replace(Inputmask.escapeRegex(opts.radixPoint), "."),
|
|
|
initialValue = Math.round(parseFloat(initialValue) * digitsFactor) / digitsFactor,
|
|
|
initialValue = initialValue.toString().replace(".", opts.radixPoint);
|