|
|
@@ -3,7 +3,7 @@
|
|
|
* https://github.com/RobinHerbots/Inputmask
|
|
|
* Copyright (c) 2010 - 2017 Robin Herbots
|
|
|
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
|
-* Version: 4.0.1-0
|
|
|
+* Version: 4.0.1-1
|
|
|
*/
|
|
|
|
|
|
!function(factory) {
|
|
|
@@ -414,7 +414,7 @@
|
|
|
var result = !0, positionsClone = $.extend(!0, {}, getMaskSet().validPositions);
|
|
|
if ($.isFunction(opts.preValidation) && !strict && !0 !== fromSetValid && (result = opts.preValidation(getBuffer(), maskPos, c, isSelection(pos), opts)),
|
|
|
!0 === result) {
|
|
|
- if (fillMissingNonMask(maskPos), isSelection(pos) && (handleRemove(undefined, Inputmask.keyCode.DELETE, pos, !0),
|
|
|
+ if (fillMissingNonMask(maskPos), isSelection(pos) && (handleRemove(undefined, Inputmask.keyCode.DELETE, pos, !0, !0),
|
|
|
maskPos = getMaskSet().p), maskPos < getMaskSet().maskLength && (maxLength === undefined || maskPos < maxLength) && (result = _isValid(maskPos, c, strict),
|
|
|
(!strict || !0 === fromSetValid) && !1 === result)) {
|
|
|
var currentPosValid = getMaskSet().validPositions[maskPos];
|
|
|
@@ -908,26 +908,41 @@
|
|
|
var input = this, inputValue = input.inputmask._valueGet();
|
|
|
if (getBuffer().join("") !== inputValue) {
|
|
|
var caretPos = caret(input);
|
|
|
- if ("." === inputValue.charAt(caretPos.begin - 1) && "" !== opts.radixPoint && (inputValue = inputValue.split(""),
|
|
|
- inputValue[caretPos.begin - 1] = opts.radixPoint.charAt(0), inputValue = inputValue.join("")),
|
|
|
- inputValue.charAt(caretPos.begin - 1) === opts.radixPoint && inputValue.length > getBuffer().length) {
|
|
|
- var keypress = new $.Event("keypress");
|
|
|
- return keypress.which = opts.radixPoint.charCodeAt(0), EventHandlers.keypressEvent.call(input, keypress, !0, !0, !1, caretPos.begin),
|
|
|
- !1;
|
|
|
- }
|
|
|
- if (inputValue = inputValue.replace(new RegExp("(" + Inputmask.escapeRegex(getBufferTemplate().join("")) + ")*"), ""),
|
|
|
- iemobile) {
|
|
|
- var inputChar = inputValue.replace(getBuffer().join(""), "");
|
|
|
- if (1 === inputChar.length) {
|
|
|
+ if (!1 === function(input, inputValue, caretPos) {
|
|
|
+ if ("." === inputValue.charAt(caretPos.begin - 1) && "" !== opts.radixPoint && (inputValue = inputValue.split(""),
|
|
|
+ inputValue[caretPos.begin - 1] = opts.radixPoint.charAt(0), inputValue = inputValue.join("")),
|
|
|
+ inputValue.charAt(caretPos.begin - 1) === opts.radixPoint && inputValue.length > getBuffer().length) {
|
|
|
var keypress = new $.Event("keypress");
|
|
|
- return keypress.which = inputChar.charCodeAt(0), EventHandlers.keypressEvent.call(input, keypress, !0, !0, !1, getMaskSet().validPositions[caretPos.begin - 1] ? caretPos.begin : caretPos.begin - 1),
|
|
|
+ return keypress.which = opts.radixPoint.charCodeAt(0), EventHandlers.keypressEvent.call(input, keypress, !0, !0, !1, caretPos.begin),
|
|
|
!1;
|
|
|
}
|
|
|
+ }(input, inputValue, caretPos)) return !1;
|
|
|
+ if (inputValue = inputValue.replace(new RegExp("(" + Inputmask.escapeRegex(getBufferTemplate().join("")) + ")*"), ""),
|
|
|
+ !1 === function(input, inputValue, caretPos) {
|
|
|
+ if (iemobile) {
|
|
|
+ var inputChar = inputValue.replace(getBuffer().join(""), "");
|
|
|
+ if (1 === inputChar.length) {
|
|
|
+ var keypress = new $.Event("keypress");
|
|
|
+ return keypress.which = inputChar.charCodeAt(0), EventHandlers.keypressEvent.call(input, keypress, !0, !0, !1, getMaskSet().validPositions[caretPos.begin - 1] ? caretPos.begin : caretPos.begin - 1),
|
|
|
+ !1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }(input, inputValue, caretPos)) return !1;
|
|
|
+ caretPos.begin > inputValue.length && (caret(input, inputValue.length), caretPos = caret(input));
|
|
|
+ var buffer = getBuffer().join(""), frontPart = inputValue.substr(0, caretPos.begin), backPart = inputValue.substr(caretPos.begin), frontBufferPart = buffer.substr(0, caretPos.begin), backBufferPart = buffer.substr(caretPos.begin), selection = {
|
|
|
+ begin: frontPart.length
|
|
|
+ }, endOffset = 0;
|
|
|
+ if (frontPart[frontPart.length - 1] !== frontBufferPart[frontBufferPart.length - 1] && (selection.begin--,
|
|
|
+ endOffset++), backPart.length > backBufferPart.length) selection.end = selection.begin; else {
|
|
|
+ var selectedPart = backBufferPart.replace(new RegExp(Inputmask.escapeRegex(backPart) + "$"), "");
|
|
|
+ selection.end = selection.begin + selectedPart.length + endOffset;
|
|
|
}
|
|
|
- if (caretPos.begin > inputValue.length && (caret(input, inputValue.length), caretPos = caret(input)),
|
|
|
- getBuffer().length - inputValue.length != 1 || inputValue.charAt(caretPos.begin) === getBuffer()[caretPos.begin] || inputValue.charAt(caretPos.begin + 1) === getBuffer()[caretPos.begin] || isMask(caretPos.begin)) {
|
|
|
- var stickyParts = [], bufferTemplate = getBufferTemplate().join("");
|
|
|
- for (stickyParts.push(inputValue.substr(0, caretPos.begin)), stickyParts.push(inputValue.substr(caretPos.begin)); null === inputValue.match(Inputmask.escapeRegex(bufferTemplate) + "$"); ) bufferTemplate = bufferTemplate.slice(1);
|
|
|
+ if (selection.begin != selection.end || isMask(selection.begin) || (selection.end = caretPos.end),
|
|
|
+ "" !== backPart && selection.begin < selection.end) writeBuffer(input, getBuffer(), selection),
|
|
|
+ frontPart.charCodeAt(frontPart.length - 1) !== frontBufferPart.charCodeAt(frontBufferPart.length - 1) ? (e.which = frontPart.charCodeAt(frontPart.length - 1),
|
|
|
+ EventHandlers.keypressEvent.call(input, e)) : (selection.begin == selection.end - 1 && caret(input, seekPrevious(selection.begin + 1), selection.end),
|
|
|
+ e.keyCode = Inputmask.keyCode.DELETE, EventHandlers.keydownEvent.call(input, e)); else {
|
|
|
+ for (var bufferTemplate = getBufferTemplate().join(""); null === inputValue.match(Inputmask.escapeRegex(bufferTemplate) + "$"); ) bufferTemplate = bufferTemplate.slice(1);
|
|
|
inputValue = inputValue.replace(bufferTemplate, ""), $.isFunction(opts.onBeforeMask) && (inputValue = opts.onBeforeMask(inputValue, opts) || inputValue),
|
|
|
checkVal(input, !0, !1, inputValue.split(""), e), function(input, frontPart, backPart) {
|
|
|
var targetPos = caret(input).begin, currentValue = input.inputmask._valueGet(), pos = currentValue.indexOf(frontPart), currentPos = targetPos;
|
|
|
@@ -940,8 +955,8 @@
|
|
|
android && setTimeout(function() {
|
|
|
caret(input, targetPos);
|
|
|
}, 0));
|
|
|
- }(input, stickyParts[0], stickyParts[1]), !0 === isComplete(getBuffer()) && $(input).trigger("complete");
|
|
|
- } else e.keyCode = Inputmask.keyCode.BACKSPACE, EventHandlers.keydownEvent.call(input, e);
|
|
|
+ }(input, frontPart, backPart), !0 === isComplete(getBuffer()) && $(input).trigger("complete");
|
|
|
+ }
|
|
|
e.preventDefault();
|
|
|
}
|
|
|
},
|