|
|
@@ -3,7 +3,7 @@
|
|
|
* 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.4-27
|
|
|
+* Version: 3.3.4-32
|
|
|
*/
|
|
|
!function($) {
|
|
|
function Inputmask(alias, options) {
|
|
|
@@ -521,7 +521,7 @@
|
|
|
$.each(rslt.insert.sort(function(a, b) {
|
|
|
return a - b;
|
|
|
}), function(ndx, lmnt) {
|
|
|
- isValid(lmnt.pos, lmnt.c, !1, fromSetValid);
|
|
|
+ isValid(lmnt.pos, lmnt.c, !0, fromSetValid);
|
|
|
})), rslt.refreshFromBuffer) {
|
|
|
var refresh = rslt.refreshFromBuffer;
|
|
|
if (strict = !0, refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, possibleModifiedBuffer),
|
|
|
@@ -1152,15 +1152,31 @@
|
|
|
}, 0);
|
|
|
}
|
|
|
function initializeColorMask(input) {
|
|
|
- var computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null);
|
|
|
- colorMask = document.createElement("span"), colorMask.style.position = "absolute",
|
|
|
- colorMask.style.top = input.clientTop + "px",
|
|
|
- colorMask.style.left = input.clientLeft + parseInt(computedStyle.paddingLeft) + 'px',
|
|
|
- colorMask.style.lineHeight = input.clientHeight + "px",
|
|
|
- colorMask.style.color = computedStyle.color, colorMask.style.fontSize = computedStyle.fontSize,
|
|
|
- colorMask.style.fontStyle = computedStyle.fontStyle, colorMask.style.fontFamily = computedStyle.fontFamily,
|
|
|
- colorMask.style.letterSpacing = computedStyle.letterSpacing, input.style.color = "transparent",
|
|
|
- input.style.backgroundColor = "transparent", input.parentNode.insertBefore(colorMask, input.nextSibling);
|
|
|
+ function charSize() {
|
|
|
+ var e = document.createElement("span"), width = 0;
|
|
|
+ return e.style.visibility = "hidden", e.style.whiteSpace = "nowrap", e.style.fontSize = computedStyle.fontSize,
|
|
|
+ e.style.fontFamily = computedStyle.fontFamily, e.innerHTML = "0", input.parentNode.insertBefore(e, input.nextSibling),
|
|
|
+ width = e.offsetWidth, input.parentNode.removeChild(e), width;
|
|
|
+ }
|
|
|
+ var offset = $(input).position(), computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null);
|
|
|
+ colorMask = document.createElement("div"), colorMask.style.position = "absolute",
|
|
|
+ colorMask.style.top = offset.top + parseInt(computedStyle.borderTopWidth) + parseInt(computedStyle.paddingTop) + "px",
|
|
|
+ colorMask.style.left = offset.left + parseInt(computedStyle.borderLeftWidth) + parseInt(computedStyle.paddingLeft) + "px",
|
|
|
+ colorMask.style.width = computedStyle.width, colorMask.style.height = computedStyle.height,
|
|
|
+ colorMask.style.color = computedStyle.color, colorMask.style.backgroundColor = computedStyle.backgroundColor,
|
|
|
+ colorMask.style.fontSize = computedStyle.fontSize, colorMask.style.fontStyle = computedStyle.fontStyle,
|
|
|
+ colorMask.style.fontFamily = computedStyle.fontFamily, colorMask.style.letterSpacing = computedStyle.letterSpacing,
|
|
|
+ input.style.color = "transparent", input.parentNode.insertBefore(colorMask, input.nextSibling),
|
|
|
+ $(window).on("resize", function(e) {
|
|
|
+ offset = $(input).position(), computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null),
|
|
|
+ colorMask.style.top = offset.top + parseInt(computedStyle.borderTopWidth) + parseInt(computedStyle.paddingTop) + "px",
|
|
|
+ colorMask.style.left = offset.left + parseInt(computedStyle.borderLeftWidth) + parseInt(computedStyle.paddingLeft) + "px",
|
|
|
+ colorMask.style.width = computedStyle.width, colorMask.style.height = computedStyle.height;
|
|
|
+ }), EventRuler.off(input, "mouseenter"), $(input.nextSibling).on("mouseenter", function(e) {
|
|
|
+ mouseenterEvent.call(input, e);
|
|
|
+ }), $(input.nextSibling).on("click", function(e) {
|
|
|
+ input.focus(), caret(input, Math.floor(e.clientX / charSize())), $(input).trigger("click");
|
|
|
+ });
|
|
|
}
|
|
|
function renderColorMask(input, buffer, caretPos) {
|
|
|
function handleStatic() {
|
|
|
@@ -1188,11 +1204,11 @@
|
|
|
if (el = elem, $el = $(el), opts.showTooltip && (el.title = opts.tooltip || getMaskSet().mask),
|
|
|
("rtl" === el.dir || opts.rightAlign) && (el.style.textAlign = "right"), ("rtl" === el.dir || opts.numericInput) && (el.dir = "ltr",
|
|
|
el.removeAttribute("dir"), el.inputmask.isRTL = !0, isRTL = !0), opts.colorMask === !0 && initializeColorMask(el),
|
|
|
- android && (el.hasOwnProperty("inputmode") || el.hasOwnProperty("x-inputmode") ? (el.inputmode = opts.inputmode,
|
|
|
- el["x-inputmode"] = opts.inputmode) : (el.type = "password", initializeColorMask(el),
|
|
|
- el.style.letterSpacing = "1px")), EventRuler.off(el), patchValueProperty(el), isElementTypeSupported(el, opts) && (EventRuler.on(el, "submit", submitEvent),
|
|
|
- EventRuler.on(el, "reset", resetEvent), EventRuler.on(el, "mouseenter", mouseenterEvent),
|
|
|
- EventRuler.on(el, "blur", blurEvent), EventRuler.on(el, "focus", focusEvent), EventRuler.on(el, "mouseleave", mouseleaveEvent),
|
|
|
+ android && (el.hasOwnProperty("inputmode") ? (el.inputmode = opts.inputmode, el.setAttribute("inputmode", opts.inputmode)) : (el.type = "password",
|
|
|
+ opts.colorMask !== !0 && initializeColorMask(el))), EventRuler.off(el), patchValueProperty(el),
|
|
|
+ isElementTypeSupported(el, opts) && (EventRuler.on(el, "submit", submitEvent), EventRuler.on(el, "reset", resetEvent),
|
|
|
+ EventRuler.on(el, "mouseenter", mouseenterEvent), EventRuler.on(el, "blur", blurEvent),
|
|
|
+ EventRuler.on(el, "focus", focusEvent), EventRuler.on(el, "mouseleave", mouseleaveEvent),
|
|
|
EventRuler.on(el, "click", clickEvent), EventRuler.on(el, "dblclick", dblclickEvent),
|
|
|
EventRuler.on(el, "paste", pasteEvent), EventRuler.on(el, "dragdrop", pasteEvent),
|
|
|
EventRuler.on(el, "drop", pasteEvent), EventRuler.on(el, "cut", cutEvent), EventRuler.on(el, "complete", opts.oncomplete),
|
|
|
@@ -2191,14 +2207,14 @@
|
|
|
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);
|
|
|
- if (mask += "[+]", mask += opts.integerOptional === !0 ? "~{1," + opts.integerDigits + "}" : "~{" + opts.integerDigits + "}",
|
|
|
+ var mask = "[+]";
|
|
|
+ if (mask += autoEscape(opts.prefix), mask += opts.integerOptional === !0 ? "~{1," + opts.integerDigits + "}" : "~{" + opts.integerDigits + "}",
|
|
|
void 0 !== opts.digits) {
|
|
|
opts.decimalProtect && (opts.radixPointDefinitionSymbol = ":");
|
|
|
var dq = opts.digits.toString().split(",");
|
|
|
isFinite(dq[0] && dq[1] && isFinite(dq[1])) ? mask += (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + 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 + "}");
|
|
|
}
|
|
|
- return mask += "[-]", mask += autoEscape(opts.suffix), opts.greedy = !1, null !== opts.min && (opts.min = opts.min.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
|
|
|
+ return mask += autoEscape(opts.suffix), mask += "[-]", opts.greedy = !1, null !== opts.min && (opts.min = opts.min.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
|
|
|
"," === opts.radixPoint && (opts.min = opts.min.replace(opts.radixPoint, "."))),
|
|
|
null !== opts.max && (opts.max = opts.max.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
|
|
|
"," === opts.radixPoint && (opts.max = opts.max.replace(opts.radixPoint, "."))),
|
|
|
@@ -2239,8 +2255,10 @@
|
|
|
var charAtPos = buffer[pos], cbuf = buffer.slice();
|
|
|
charAtPos === opts.groupSeparator && (cbuf.splice(pos--, 1), charAtPos = cbuf[pos]),
|
|
|
cbuf[pos] = "!";
|
|
|
- var bufVal = cbuf.join(""), bufValOrigin = bufVal;
|
|
|
- if (bufVal = bufVal.replace(new RegExp(Inputmask.escapeRegex(opts.suffix) + "$"), ""),
|
|
|
+ var bufVal = cbuf.join(""), bufValOrigin = bufVal, isNegative = bufVal.match(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)));
|
|
|
+ if (isNegative = null !== isNegative && 1 === isNegative.length, isNegative && (bufVal = bufVal.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), ""),
|
|
|
+ bufVal = bufVal.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), "")),
|
|
|
+ bufVal = bufVal.replace(new RegExp(Inputmask.escapeRegex(opts.suffix) + "$"), ""),
|
|
|
bufVal = bufVal.replace(new RegExp("^" + Inputmask.escapeRegex(opts.prefix)), ""),
|
|
|
bufVal.length > 0 && opts.autoGroup || bufVal.indexOf(opts.groupSeparator) !== -1) {
|
|
|
var escapedGroupSeparator = Inputmask.escapeRegex(opts.groupSeparator);
|
|
|
@@ -2251,7 +2269,7 @@
|
|
|
bufVal = bufVal.replace(opts.groupSeparator + opts.groupSeparator, opts.groupSeparator);
|
|
|
bufVal = bufVal.replace("?", "!"), "" !== opts.radixPoint && radixSplit.length > 1 && (bufVal += (charAtPos === opts.radixPoint ? "!" : opts.radixPoint) + radixSplit[1]);
|
|
|
}
|
|
|
- bufVal = opts.prefix + bufVal + opts.suffix;
|
|
|
+ bufVal = opts.prefix + bufVal + opts.suffix, isNegative && (bufVal = opts.negationSymbol.front + bufVal + opts.negationSymbol.back);
|
|
|
var needsRefresh = bufValOrigin !== bufVal;
|
|
|
if (needsRefresh) for (buffer.length = bufVal.length, i = 0, l = bufVal.length; i < l; i++) buffer[i] = bufVal.charAt(i);
|
|
|
var newPos = $.inArray("!", bufVal);
|
|
|
@@ -2285,9 +2303,10 @@
|
|
|
for (var i = 1; i <= opts.digits; i++) opts.digitsOptional || void 0 !== processValue[radixPosition + i] && processValue[radixPosition + i] !== opts.placeholder.charAt(0) ? rpb !== -1 && void 0 !== maskedValue[rpb + i] && (processValue[radixPosition + i] = processValue[radixPosition + i] || maskedValue[rpb + i]) : processValue[radixPosition + i] = "0";
|
|
|
processValue[processValue.length - 1] === opts.radixPoint && delete processValue[processValue.length - 1];
|
|
|
}
|
|
|
- if (floatValue.toString() !== processValue && floatValue.toString() + "." !== processValue || isNegative) return !isNegative || 0 === floatValue && "blur" === e.type || (processValue.unshift(opts.negationSymbol.front),
|
|
|
- processValue.push(opts.negationSymbol.back)), processValue = (opts.prefix + processValue.join("")).split(""),
|
|
|
- opts.numericInput && (processValue = processValue.reverse()), rslt = opts.postFormat(processValue, opts.numericInput ? caretPos : caretPos - 1, opts),
|
|
|
+ if (floatValue.toString() !== processValue && floatValue.toString() + "." !== processValue || isNegative) return processValue = (opts.prefix + processValue.join("")).split(""),
|
|
|
+ !isNegative || 0 === floatValue && "blur" === e.type || (processValue.unshift(opts.negationSymbol.front),
|
|
|
+ processValue.push(opts.negationSymbol.back)), opts.numericInput && (processValue = processValue.reverse()),
|
|
|
+ rslt = opts.postFormat(processValue, opts.numericInput ? caretPos : caretPos - 1, opts),
|
|
|
rslt.buffer && (rslt.refreshFromBuffer = rslt.buffer.join("") !== buffer.join("")),
|
|
|
rslt;
|
|
|
}
|
|
|
@@ -2307,49 +2326,49 @@
|
|
|
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,
|
|
|
+ pos: 0,
|
|
|
c: opts.negationSymbol.front,
|
|
|
- remove: matchRslt.index,
|
|
|
+ remove: 0,
|
|
|
caret: pos,
|
|
|
insert: {
|
|
|
- pos: maskset.buffer.length - opts.suffix.length - 1,
|
|
|
+ pos: maskset.buffer.length - 1,
|
|
|
c: opts.negationSymbol.back
|
|
|
}
|
|
|
} : {
|
|
|
- pos: matchRslt.index,
|
|
|
+ pos: 0,
|
|
|
c: opts.negationSymbol.front,
|
|
|
- remove: matchRslt.index,
|
|
|
+ remove: 0,
|
|
|
caret: pos
|
|
|
} : "" !== opts.negationSymbol.back ? {
|
|
|
- pos: matchRslt.index,
|
|
|
+ pos: 0,
|
|
|
c: "+",
|
|
|
- remove: [ matchRslt.index, maskset.buffer.length - opts.suffix.length - 1 ],
|
|
|
+ remove: [ 0, maskset.buffer.length - 1 ],
|
|
|
caret: pos
|
|
|
} : {
|
|
|
- pos: matchRslt.index,
|
|
|
+ pos: 0,
|
|
|
c: "+",
|
|
|
- remove: matchRslt.index,
|
|
|
+ remove: 0,
|
|
|
caret: pos
|
|
|
- } : maskset.buffer[matchRslt.index] === ("-" === chrs ? opts.negationSymbol.front : "+") ? "-" === chrs && "" !== opts.negationSymbol.back ? {
|
|
|
- remove: [ matchRslt.index, maskset.buffer.length - opts.suffix.length - 1 ],
|
|
|
+ } : maskset.buffer[0] === ("-" === chrs ? opts.negationSymbol.front : "+") ? "-" === chrs && "" !== opts.negationSymbol.back ? {
|
|
|
+ remove: [ 0, maskset.buffer.length - 1 ],
|
|
|
caret: pos - 1
|
|
|
} : {
|
|
|
- remove: matchRslt.index,
|
|
|
+ remove: 0,
|
|
|
caret: pos - 1
|
|
|
} : "-" === chrs ? "" !== opts.negationSymbol.back ? {
|
|
|
- pos: matchRslt.index,
|
|
|
+ pos: 0,
|
|
|
c: opts.negationSymbol.front,
|
|
|
caret: pos + 1,
|
|
|
insert: {
|
|
|
- pos: maskset.buffer.length - opts.suffix.length,
|
|
|
+ pos: maskset.buffer.length,
|
|
|
c: opts.negationSymbol.back
|
|
|
}
|
|
|
} : {
|
|
|
- pos: matchRslt.index,
|
|
|
+ pos: 0,
|
|
|
c: opts.negationSymbol.front,
|
|
|
caret: pos + 1
|
|
|
} : {
|
|
|
- pos: matchRslt.index,
|
|
|
+ pos: 0,
|
|
|
c: chrs,
|
|
|
caret: pos + 1
|
|
|
};
|