|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431 |
- /*!
- * inputmask.numeric.extensions.js
- * http://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.2.7
- */
- !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) {
- return Inputmask.extendAliases({
- numeric: {
- mask: function(opts) {
- function autoEscape(txt) {
- for (var escapedTxt = "", i = 0; i < txt.length; i++) escapedTxt += opts.definitions[txt.charAt(i)] ? "\\" + txt.charAt(i) : txt.charAt(i);
- return escapedTxt;
- }
- if (0 !== opts.repeat && isNaN(opts.integerDigits) && (opts.integerDigits = opts.repeat),
- 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 = "*");
- }
- opts.placeholder.length > 1 && (opts.placeholder = opts.placeholder.charAt(0)),
- opts.radixFocus = opts.radixFocus && "" !== opts.placeholder && opts.integerOptional === !0,
- opts.definitions[";"] = opts.definitions["~"], opts.definitions[";"].definitionSymbol = "~",
- 1 == opts.numericInput && (opts.radixFocus = !1, opts.digitsOptional = !1, isNaN(opts.digits) && (opts.digits = 2),
- opts.decimalProtect = !1);
- var mask = autoEscape(opts.prefix);
- return mask += "[+]", mask += opts.integerOptional === !0 ? "~{1," + opts.integerDigits + "}" : "~{" + opts.integerDigits + "}",
- void 0 !== opts.digits && (isNaN(opts.digits) || parseInt(opts.digits) > 0) && (mask += opts.digitsOptional ? "[" + (opts.decimalProtect ? ":" : opts.radixPoint) + ";{1," + opts.digits + "}]" : (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}"),
- "" !== opts.negationSymbol.back && (mask += "[-]"), mask += autoEscape(opts.suffix),
- opts.greedy = !1, mask;
- },
- placeholder: "",
- greedy: !1,
- digits: "*",
- digitsOptional: !0,
- radixPoint: ".",
- radixFocus: !0,
- groupSize: 3,
- groupSeparator: "",
- autoGroup: !1,
- allowPlus: !0,
- allowMinus: !0,
- negationSymbol: {
- front: "-",
- back: ""
- },
- integerDigits: "+",
- integerOptional: !0,
- prefix: "",
- suffix: "",
- rightAlign: !0,
- decimalProtect: !0,
- min: null,
- max: null,
- step: 1,
- insertMode: !0,
- autoUnmask: !1,
- unmaskAsNumber: !1,
- postFormat: function(buffer, pos, reformatOnly, opts) {
- opts.numericInput === !0 && (buffer = buffer.reverse(), isFinite(pos) && (pos = buffer.join("").length - pos - 1));
- var i, l, suffixStripped = !1;
- buffer.length >= opts.suffix.length && buffer.join("").indexOf(opts.suffix) === buffer.length - opts.suffix.length && (buffer.length = buffer.length - opts.suffix.length,
- suffixStripped = !0), pos = pos >= buffer.length ? buffer.length - 1 : pos < opts.prefix.length ? opts.prefix.length : pos;
- var needsRefresh = !1, charAtPos = buffer[pos];
- if ("" === opts.groupSeparator || opts.numericInput !== !0 && -1 !== $.inArray(opts.radixPoint, buffer) && pos > $.inArray(opts.radixPoint, buffer) || new RegExp("[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "+]").test(charAtPos)) {
- if (suffixStripped) for (i = 0, l = opts.suffix.length; l > i; i++) buffer.push(opts.suffix.charAt(i));
- return {
- pos: pos
- };
- }
- var cbuf = buffer.slice();
- charAtPos === opts.groupSeparator && (cbuf.splice(pos--, 1), charAtPos = cbuf[pos]),
- reformatOnly ? charAtPos !== opts.radixPoint && (cbuf[pos] = "?") : cbuf.splice(pos, 0, "?");
- var bufVal = cbuf.join(""), bufValOrigin = bufVal;
- if (bufVal.length > 0 && opts.autoGroup || reformatOnly && -1 !== bufVal.indexOf(opts.groupSeparator)) {
- var escapedGroupSeparator = Inputmask.escapeRegex(opts.groupSeparator);
- needsRefresh = 0 === bufVal.indexOf(opts.groupSeparator), bufVal = bufVal.replace(new RegExp(escapedGroupSeparator, "g"), "");
- var radixSplit = bufVal.split(opts.radixPoint);
- if (bufVal = "" === opts.radixPoint ? bufVal : radixSplit[0], bufVal !== opts.prefix + "?0" && bufVal.length >= opts.groupSize + opts.prefix.length) for (var reg = new RegExp("([-+]?[\\d?]+)([\\d?]{" + opts.groupSize + "})"); reg.test(bufVal); ) bufVal = bufVal.replace(reg, "$1" + opts.groupSeparator + "$2"),
- bufVal = bufVal.replace(opts.groupSeparator + opts.groupSeparator, opts.groupSeparator);
- "" !== opts.radixPoint && radixSplit.length > 1 && (bufVal += opts.radixPoint + radixSplit[1]);
- }
- for (needsRefresh = bufValOrigin !== bufVal, buffer.length = bufVal.length, i = 0,
- l = bufVal.length; l > i; i++) buffer[i] = bufVal.charAt(i);
- var newPos = $.inArray("?", buffer);
- if (-1 === newPos && charAtPos === opts.radixPoint && (newPos = $.inArray(opts.radixPoint, buffer)),
- reformatOnly ? buffer[newPos] = charAtPos : buffer.splice(newPos, 1), !needsRefresh && suffixStripped) for (i = 0,
- l = opts.suffix.length; l > i; i++) buffer.push(opts.suffix.charAt(i));
- return 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)),
- {
- pos: newPos,
- refreshFromBuffer: needsRefresh,
- buffer: buffer
- };
- },
- onBeforeWrite: function(e, buffer, caretPos, opts) {
- if (e && ("blur" === e.type || "checkval" === e.type)) {
- var maskedValue = buffer.join(""), processValue = maskedValue.replace(opts.prefix, "");
- if (processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
- "," === opts.radixPoint && (processValue = processValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".")),
- isFinite(processValue) && isFinite(opts.min) && parseFloat(processValue) < parseFloat(opts.min)) return $.extend(!0, {
- refreshFromBuffer: !0,
- buffer: (opts.prefix + opts.min).split("")
- }, opts.postFormat((opts.prefix + opts.min).split(""), 0, !0, opts));
- if (opts.numericInput !== !0) {
- 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;
- if (matchRslt) {
- matchRslt[0] !== opts.negationSymbol.front + "0" && matchRslt[0] !== opts.negationSymbol.front && "+" !== matchRslt[0] || void 0 !== matchRsltDigits && !matchRsltDigits[0].match(/^0+$/) || buffer.splice(matchRslt.index, 1);
- var radixPosition = $.inArray(opts.radixPoint, buffer);
- if (-1 !== radixPosition) {
- if (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");
- return {
- refreshFromBuffer: maskedValue !== buffer.join(""),
- buffer: buffer
- };
- }
- if (radixPosition === buffer.length - opts.suffix.length - 1) return buffer.splice(radixPosition, 1),
- {
- refreshFromBuffer: !0,
- buffer: buffer
- };
- }
- }
- }
- }
- if (opts.autoGroup) {
- var rslt = opts.postFormat(buffer, opts.numericInput ? caretPos : caretPos - 1, !0, opts);
- return rslt.caret = caretPos <= opts.prefix.length ? rslt.pos : rslt.pos + 1, rslt;
- }
- },
- regex: {
- integerPart: function(opts) {
- return new RegExp("[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "+]?\\d+");
- },
- integerNPart: function(opts) {
- return new RegExp("[\\d" + Inputmask.escapeRegex(opts.groupSeparator) + "]+");
- }
- },
- 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[0].length > 0) return maskset.buffer[matchRslt.index] === ("-" === chrs ? "+" : opts.negationSymbol.front) ? "-" === chrs ? "" !== opts.negationSymbol.back ? {
- pos: matchRslt.index,
- c: opts.negationSymbol.front,
- remove: matchRslt.index,
- caret: pos,
- insert: {
- pos: maskset.buffer.length - opts.suffix.length - 1,
- c: opts.negationSymbol.back
- }
- } : {
- pos: matchRslt.index,
- c: opts.negationSymbol.front,
- remove: matchRslt.index,
- caret: pos
- } : "" !== opts.negationSymbol.back ? {
- pos: matchRslt.index,
- c: "+",
- remove: [ matchRslt.index, maskset.buffer.length - opts.suffix.length - 1 ],
- caret: pos
- } : {
- pos: matchRslt.index,
- c: "+",
- remove: matchRslt.index,
- caret: pos
- } : maskset.buffer[matchRslt.index] === ("-" === chrs ? opts.negationSymbol.front : "+") ? "-" === chrs && "" !== opts.negationSymbol.back ? {
- remove: [ matchRslt.index, maskset.buffer.length - opts.suffix.length - 1 ],
- caret: pos - 1
- } : {
- remove: matchRslt.index,
- caret: pos - 1
- } : "-" === chrs ? "" !== opts.negationSymbol.back ? {
- pos: matchRslt.index,
- c: opts.negationSymbol.front,
- caret: pos + 1,
- insert: {
- pos: maskset.buffer.length - opts.suffix.length,
- c: opts.negationSymbol.back
- }
- } : {
- pos: matchRslt.index,
- c: opts.negationSymbol.front,
- caret: pos + 1
- } : {
- pos: matchRslt.index,
- c: chrs,
- caret: pos + 1
- };
- }
- return !1;
- },
- radixHandler: function(chrs, maskset, pos, strict, opts) {
- if (!strict && (-1 !== $.inArray(chrs, [ ",", "." ]) && (chrs = opts.radixPoint),
- chrs === opts.radixPoint && void 0 !== opts.digits && (isNaN(opts.digits) || parseInt(opts.digits) > 0))) {
- var radixPos = $.inArray(opts.radixPoint, maskset.buffer), integerValue = maskset.buffer.join("").match(opts.regex.integerPart(opts));
- if (-1 !== radixPos && maskset.validPositions[radixPos]) return maskset.validPositions[radixPos - 1] ? {
- caret: radixPos + 1
- } : {
- pos: integerValue.index,
- c: integerValue[0],
- caret: radixPos + 1
- };
- if (!integerValue || "0" === integerValue[0] && integerValue.index + 1 !== pos) return maskset.buffer[integerValue ? integerValue.index : pos] = "0",
- {
- pos: (integerValue ? integerValue.index : pos) + 1,
- c: opts.radixPoint
- };
- }
- return !1;
- },
- leadingZeroHandler: function(chrs, maskset, pos, strict, opts) {
- if (opts.numericInput === !0) {
- if ("0" === maskset.buffer[maskset.buffer.length - opts.prefix.length - 1]) return {
- pos: pos,
- remove: maskset.buffer.length - opts.prefix.length - 1
- };
- } else {
- var matchRslt = maskset.buffer.join("").match(opts.regex.integerNPart(opts)), radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
- if (matchRslt && !strict && (-1 === radixPosition || radixPosition >= pos)) if (0 === matchRslt[0].indexOf("0")) {
- pos < opts.prefix.length && (pos = matchRslt.index);
- var _radixPosition = $.inArray(opts.radixPoint, maskset._buffer), digitsMatch = maskset._buffer && maskset.buffer.slice(radixPosition).join("") === maskset._buffer.slice(_radixPosition).join("") || 0 === parseInt(maskset.buffer.slice(radixPosition + 1).join("")), integerMatch = maskset._buffer && maskset.buffer.slice(matchRslt.index, radixPosition).join("") === maskset._buffer.slice(opts.prefix.length, _radixPosition).join("") || "0" === maskset.buffer.slice(matchRslt.index, 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 (matchRslt.index + 1 === pos || "0" === chrs) return maskset.buffer.splice(matchRslt.index, 1),
- pos = matchRslt.index, {
- pos: pos,
- remove: matchRslt.index
- };
- } else if ("0" === chrs && pos <= matchRslt.index && matchRslt[0] !== opts.groupSeparator) return !1;
- }
- return !0;
- },
- postValidation: function(buffer, currentResult, opts) {
- var isValid = !0, maskedValue = opts.numericInput ? buffer.slice().reverse().join("") : buffer.join(""), 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), ".")),
- processValue = processValue.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), "-"),
- processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), ""),
- processValue = processValue === opts.negationSymbol.front ? processValue + "0" : processValue,
- isFinite(processValue) && (null !== opts.max && isFinite(opts.max) && (processValue = parseFloat(processValue) > parseFloat(opts.max) ? opts.max : processValue,
- isValid = opts.postFormat((opts.prefix + processValue).split(""), 0, !0, opts)),
- null !== opts.min && isFinite(opts.min) && (processValue = parseFloat(processValue) < parseFloat(opts.min) ? opts.min : processValue,
- isValid = opts.postFormat((opts.prefix + processValue).split(""), 0, !0, opts))),
- isValid;
- },
- definitions: {
- "~": {
- validator: function(chrs, maskset, pos, strict, opts) {
- var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
- if (!isValid && (isValid = opts.radixHandler(chrs, maskset, pos, strict, opts),
- !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),
- isValid === !0)))) {
- var radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
- isValid = -1 !== radixPosition && opts.digitsOptional === !1 && opts.numericInput !== !0 && pos > radixPosition && !strict ? {
- pos: pos,
- remove: pos
- } : {
- pos: pos
- };
- }
- return isValid;
- },
- cardinality: 1,
- prevalidator: null
- },
- "+": {
- validator: function(chrs, maskset, pos, strict, opts) {
- var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
- return !isValid && (strict && opts.allowMinus && chrs === opts.negationSymbol.front || opts.allowMinus && "-" === chrs || opts.allowPlus && "+" === chrs) && (isValid = "-" === chrs ? "" !== opts.negationSymbol.back ? {
- pos: pos,
- c: "-" === chrs ? opts.negationSymbol.front : "+",
- caret: pos + 1,
- insert: {
- pos: maskset.buffer.length,
- c: opts.negationSymbol.back
- }
- } : {
- pos: pos,
- c: "-" === chrs ? opts.negationSymbol.front : "+",
- caret: pos + 1
- } : !0), isValid;
- },
- cardinality: 1,
- prevalidator: null,
- placeholder: ""
- },
- "-": {
- validator: function(chrs, maskset, pos, strict, opts) {
- var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
- return !isValid && strict && opts.allowMinus && chrs === opts.negationSymbol.back && (isValid = !0),
- isValid;
- },
- cardinality: 1,
- prevalidator: null,
- placeholder: ""
- },
- ":": {
- validator: function(chrs, maskset, pos, strict, opts) {
- var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
- if (!isValid) {
- var radix = "[" + Inputmask.escapeRegex(opts.radixPoint) + ",\\.]";
- isValid = new RegExp(radix).test(chrs), isValid && maskset.validPositions[pos] && maskset.validPositions[pos].match.placeholder === opts.radixPoint && (isValid = {
- caret: pos + 1
- });
- }
- return isValid ? {
- c: opts.radixPoint
- } : isValid;
- },
- cardinality: 1,
- prevalidator: null,
- placeholder: function(opts) {
- return opts.radixPoint;
- }
- }
- },
- onUnMask: function(maskedValue, unmaskedValue, opts) {
- var processValue = maskedValue.replace(opts.prefix, "");
- return processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
- opts.unmaskAsNumber ? ("" !== opts.radixPoint && -1 !== processValue.indexOf(opts.radixPoint) && (processValue = processValue.replace(Inputmask.escapeRegex.call(this, opts.radixPoint), ".")),
- Number(processValue)) : processValue;
- },
- isComplete: function(buffer, opts) {
- var maskedValue = buffer.join(""), bufClone = buffer.slice();
- if (opts.postFormat(bufClone, 0, !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), ".")),
- isFinite(processValue);
- },
- onBeforeMask: function(initialValue, opts) {
- if ("" !== opts.radixPoint && isFinite(initialValue)) initialValue = initialValue.toString().replace(".", opts.radixPoint); else {
- 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)) : 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 && (-1 !== initialValue.indexOf(".") ? initialValue = initialValue.substring(0, initialValue.indexOf(".")) : -1 !== initialValue.indexOf(",") && (initialValue = initialValue.substring(0, initialValue.indexOf(",")))),
- "" !== opts.radixPoint && isFinite(opts.digits) && -1 !== initialValue.indexOf(opts.radixPoint)) {
- 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));
- initialValue = initialValue.replace(Inputmask.escapeRegex(opts.radixPoint), "."),
- initialValue = Math.round(parseFloat(initialValue) * digitsFactor) / digitsFactor,
- initialValue = initialValue.toString().replace(".", opts.radixPoint);
- }
- }
- return initialValue.toString();
- },
- canClearPosition: function(maskset, position, lvp, strict, opts) {
- var positionInput = maskset.validPositions[position].input, canClear = positionInput !== opts.radixPoint || null !== maskset.validPositions[position].match.fn && opts.decimalProtect === !1 || isFinite(positionInput) || position === lvp || positionInput === opts.groupSeparator || positionInput === opts.negationSymbol.front || positionInput === opts.negationSymbol.back;
- if (canClear && isFinite(positionInput)) {
- var matchRslt, radixPos = $.inArray(opts.radixPoint, maskset.buffer), radixInjection = !1;
- if (void 0 === maskset.validPositions[radixPos] && (maskset.validPositions[radixPos] = {
- input: opts.radixPoint
- }, radixInjection = !0), !strict && maskset.buffer) {
- matchRslt = maskset.buffer.join("").substr(0, position).match(opts.regex.integerNPart(opts));
- var pos = position + 1, isNull = null == matchRslt || 0 === parseInt(matchRslt[0].replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""));
- if (isNull) for (;maskset.validPositions[pos] && (maskset.validPositions[pos].input === opts.groupSeparator || "0" === maskset.validPositions[pos].input); ) delete maskset.validPositions[pos],
- pos++;
- }
- var buffer = [];
- for (var vp in maskset.validPositions) void 0 !== maskset.validPositions[vp].input && buffer.push(maskset.validPositions[vp].input);
- if (radixInjection && delete maskset.validPositions[radixPos], radixPos > 0) {
- var bufVal = buffer.join("");
- if (matchRslt = bufVal.match(opts.regex.integerNPart(opts))) if (radixPos >= position) if (0 === matchRslt[0].indexOf("0")) canClear = matchRslt.index !== position || "0" === opts.placeholder; else {
- var intPart = parseInt(matchRslt[0].replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "")), radixPart = parseInt(bufVal.split(opts.radixPoint)[1]);
- 10 > intPart && maskset.validPositions[position] && ("0" !== opts.placeholder || radixPart > 0) && (maskset.validPositions[position].input = "0",
- maskset.p = opts.prefix.length + 1, canClear = !1);
- } else 0 === matchRslt[0].indexOf("0") && 3 === bufVal.length && (maskset.validPositions = {},
- canClear = !1);
- }
- }
- return canClear;
- },
- onKeyDown: function(e, buffer, caretPos, opts) {
- var $input = $(this);
- if (e.ctrlKey) switch (e.keyCode) {
- case Inputmask.keyCode.UP:
- $input.val(parseFloat(this.inputmask.unmaskedvalue()) + parseInt(opts.step)), $input.trigger("setvalue");
- break;
-
- case Inputmask.keyCode.DOWN:
- $input.val(parseFloat(this.inputmask.unmaskedvalue()) - parseInt(opts.step)), $input.trigger("setvalue");
- }
- }
- },
- currency: {
- prefix: "$ ",
- groupSeparator: ",",
- alias: "numeric",
- placeholder: "0",
- autoGroup: !0,
- digits: 2,
- digitsOptional: !1,
- clearMaskOnLostFocus: !1
- },
- decimal: {
- alias: "numeric"
- },
- integer: {
- alias: "numeric",
- digits: 0,
- radixPoint: ""
- },
- percentage: {
- alias: "numeric",
- digits: 2,
- radixPoint: ".",
- placeholder: "0",
- autoGroup: !1,
- min: 0,
- max: 100,
- suffix: " %",
- allowPlus: !1,
- allowMinus: !1
- }
- }), Inputmask;
- });
|