|
|
@@ -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-108
|
|
|
+* Version: 3.3.4-113
|
|
|
*/
|
|
|
!function(factory) {
|
|
|
"function" == typeof define && define.amd ? define("inputmask", [ "inputmask.dependencyLib" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib")) : factory(window.dependencyLib || jQuery);
|
|
|
@@ -11,8 +11,15 @@
|
|
|
function Inputmask(alias, options) {
|
|
|
return this instanceof Inputmask ? ($.isPlainObject(alias) ? options = alias : (options = options || {},
|
|
|
options.alias = alias), this.el = void 0, this.opts = $.extend(!0, {}, this.defaults, options),
|
|
|
- this.noMasksCache = options && void 0 !== options.definitions, this.userOptions = options || {},
|
|
|
- this.events = {}, this.dataAttribute = "data-inputmask", void this.resolveAlias(this.opts.alias, options, this.opts)) : new Inputmask(alias, options);
|
|
|
+ this.maskset = void 0, this.noMasksCache = options && void 0 !== options.definitions,
|
|
|
+ this.userOptions = options || {}, this.events = {}, this.dataAttribute = "data-inputmask",
|
|
|
+ this.isRTL = this.opts.numericInput, void resolveAlias(this.opts.alias, options, this.opts)) : new Inputmask(alias, options);
|
|
|
+ }
|
|
|
+ function resolveAlias(aliasStr, options, opts) {
|
|
|
+ var aliasDefinition = opts.aliases[aliasStr];
|
|
|
+ return aliasDefinition ? (aliasDefinition.alias && resolveAlias(aliasDefinition.alias, void 0, opts),
|
|
|
+ $.extend(!0, opts, aliasDefinition), $.extend(!0, opts, options), !0) : (null === opts.mask && (opts.mask = aliasStr),
|
|
|
+ !1);
|
|
|
}
|
|
|
function generateMaskSet(opts, nocache) {
|
|
|
function generateMask(mask, metadata, opts) {
|
|
|
@@ -136,10 +143,10 @@
|
|
|
function resolveNdxInitializer(pos, alternateNdx, targetAlternation) {
|
|
|
var bestMatch, indexPos;
|
|
|
return (getMaskSet().tests[pos] || getMaskSet().validPositions[pos]) && $.each(getMaskSet().tests[pos] || [ getMaskSet().validPositions[pos] ], function(ndx, lmnt) {
|
|
|
- var alternation = void 0 !== targetAlternation ? targetAlternation : lmnt.alternation, ndxPos = lmnt.locator[alternation] ? lmnt.locator[alternation].toString().indexOf(alternateNdx) : -1;
|
|
|
+ var alternation = void 0 !== targetAlternation ? targetAlternation : lmnt.alternation, ndxPos = void 0 !== lmnt.locator[alternation] ? lmnt.locator[alternation].toString().indexOf(alternateNdx) : -1;
|
|
|
(void 0 === indexPos || ndxPos < indexPos) && ndxPos !== -1 && (bestMatch = lmnt,
|
|
|
indexPos = ndxPos);
|
|
|
- }), bestMatch ? bestMatch.locator.slice(bestMatch.alternation + 1) : void 0 !== targetAlternation ? resolveNdxInitializer(pos, alternateNdx) : void 0;
|
|
|
+ }), bestMatch ? bestMatch.locator.slice((void 0 !== targetAlternation ? targetAlternation : bestMatch.alternation) + 1) : void 0 !== targetAlternation ? resolveNdxInitializer(pos, alternateNdx) : void 0;
|
|
|
}
|
|
|
function staticCanMatchDefinition(source, target) {
|
|
|
return null === source.match.fn && null !== target.match.fn && target.match.fn.test(source.match.def, getMaskSet(), pos, !1, opts, !1);
|
|
|
@@ -546,9 +553,9 @@
|
|
|
var lvp = getLastValidPosition(void 0, !0), lvTest = getMaskSet().validPositions[lvp], nextTest = getTestTemplate(lvp + 1, lvTest ? lvTest.locator.slice() : void 0, lvp);
|
|
|
if (!isTemplateMatch() || strict || opts.autoUnmask) {
|
|
|
var pos = strict ? ndx : null == nextTest.match.fn && nextTest.match.optionality && lvp + 1 < getMaskSet().p ? lvp + 1 : getMaskSet().p;
|
|
|
- result = keypressEvent.call(input, keypress, !0, !1, strict, pos), initialNdx = pos + 1,
|
|
|
- charCodes = "";
|
|
|
- } else result = keypressEvent.call(input, keypress, !0, !1, !0, lvp + 1);
|
|
|
+ result = EventHandlers.keypressEvent.call(input, keypress, !0, !1, strict, pos),
|
|
|
+ initialNdx = pos + 1, charCodes = "";
|
|
|
+ } else result = EventHandlers.keypressEvent.call(input, keypress, !0, !1, !0, lvp + 1);
|
|
|
if (!strict && $.isFunction(opts.onBeforeWrite) && (result = opts.onBeforeWrite(keypress, getBuffer(), result.forwardPosition, opts),
|
|
|
result && result.refreshFromBuffer)) {
|
|
|
var refresh = result.refreshFromBuffer;
|
|
|
@@ -736,7 +743,7 @@
|
|
|
}
|
|
|
if (lastAlt > -1) for (getMaskSet().p = seekNext(getLastValidPosition(-1, !0)); validInputs.length > 0; ) {
|
|
|
var keypress = new $.Event("keypress");
|
|
|
- keypress.which = validInputs.pop().charCodeAt(0), keypressEvent.call(input, keypress, !0, !1, !1, getMaskSet().p);
|
|
|
+ keypress.which = validInputs.pop().charCodeAt(0), EventHandlers.keypressEvent.call(input, keypress, !0, !1, !1, getMaskSet().p);
|
|
|
} else getMaskSet().validPositions = $.extend(!0, {}, positionsClone);
|
|
|
}
|
|
|
}
|
|
|
@@ -752,214 +759,6 @@
|
|
|
var lvp = getLastValidPosition(pos.begin, !0);
|
|
|
lvp < pos.begin ? getMaskSet().p = seekNext(lvp) : strict !== !0 && (getMaskSet().p = pos.begin);
|
|
|
}
|
|
|
- function keydownEvent(e) {
|
|
|
- function isInputEventSupported(eventName) {
|
|
|
- var el = document.createElement("input"), evName = "on" + eventName, isSupported = evName in el;
|
|
|
- return isSupported || (el.setAttribute(evName, "return;"), isSupported = "function" == typeof el[evName]),
|
|
|
- el = null, isSupported;
|
|
|
- }
|
|
|
- var input = this, $input = $(input), k = e.keyCode, pos = caret(input);
|
|
|
- if (k === Inputmask.keyCode.BACKSPACE || k === Inputmask.keyCode.DELETE || iphone && k === Inputmask.keyCode.BACKSPACE_SAFARI || e.ctrlKey && k === Inputmask.keyCode.X && !isInputEventSupported("cut")) e.preventDefault(),
|
|
|
- handleRemove(input, k, pos), writeBuffer(input, getBuffer(!0), getMaskSet().p, e, input.inputmask._valueGet() !== getBuffer().join("")),
|
|
|
- input.inputmask._valueGet() === getBufferTemplate().join("") ? $input.trigger("cleared") : isComplete(getBuffer()) === !0 && $input.trigger("complete"),
|
|
|
- opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask); else if (k === Inputmask.keyCode.END || k === Inputmask.keyCode.PAGE_DOWN) {
|
|
|
- e.preventDefault();
|
|
|
- var caretPos = seekNext(getLastValidPosition());
|
|
|
- opts.insertMode || caretPos !== getMaskSet().maskLength || e.shiftKey || caretPos--,
|
|
|
- caret(input, e.shiftKey ? pos.begin : caretPos, caretPos, !0);
|
|
|
- } else k === Inputmask.keyCode.HOME && !e.shiftKey || k === Inputmask.keyCode.PAGE_UP ? (e.preventDefault(),
|
|
|
- caret(input, 0, e.shiftKey ? pos.begin : 0, !0)) : (opts.undoOnEscape && k === Inputmask.keyCode.ESCAPE || 90 === k && e.ctrlKey) && e.altKey !== !0 ? (checkVal(input, !0, !1, undoValue.split("")),
|
|
|
- $input.trigger("click")) : k !== Inputmask.keyCode.INSERT || e.shiftKey || e.ctrlKey ? opts.tabThrough === !0 && k === Inputmask.keyCode.TAB ? (e.shiftKey === !0 ? (null === getTest(pos.begin).match.fn && (pos.begin = seekNext(pos.begin)),
|
|
|
- pos.end = seekPrevious(pos.begin, !0), pos.begin = seekPrevious(pos.end, !0)) : (pos.begin = seekNext(pos.begin, !0),
|
|
|
- pos.end = seekNext(pos.begin, !0), pos.end < getMaskSet().maskLength && pos.end--),
|
|
|
- pos.begin < getMaskSet().maskLength && (e.preventDefault(), caret(input, pos.begin, pos.end))) : e.shiftKey || (opts.insertMode === !1 ? k === Inputmask.keyCode.RIGHT ? setTimeout(function() {
|
|
|
- var caretPos = caret(input);
|
|
|
- caret(input, caretPos.begin);
|
|
|
- }, 0) : k === Inputmask.keyCode.LEFT && setTimeout(function() {
|
|
|
- var caretPos = caret(input);
|
|
|
- caret(input, isRTL ? caretPos.begin + 1 : caretPos.begin - 1);
|
|
|
- }, 0) : setTimeout(function() {
|
|
|
- renderColorMask(input);
|
|
|
- }, 0)) : (opts.insertMode = !opts.insertMode, caret(input, opts.insertMode || pos.begin !== getMaskSet().maskLength ? pos.begin : pos.begin - 1));
|
|
|
- opts.onKeyDown.call(this, e, getBuffer(), caret(input).begin, opts), ignorable = $.inArray(k, opts.ignorables) !== -1;
|
|
|
- }
|
|
|
- function keypressEvent(e, checkval, writeOut, strict, ndx) {
|
|
|
- var input = this, $input = $(input), k = e.which || e.charCode || e.keyCode;
|
|
|
- if (!(checkval === !0 || e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable)) return k === Inputmask.keyCode.ENTER && undoValue !== getBuffer().join("") && (undoValue = getBuffer().join(""),
|
|
|
- setTimeout(function() {
|
|
|
- $input.trigger("change");
|
|
|
- }, 0)), !0;
|
|
|
- if (k) {
|
|
|
- 46 === k && e.shiftKey === !1 && "," === opts.radixPoint && (k = 44);
|
|
|
- var forwardPosition, pos = checkval ? {
|
|
|
- begin: ndx,
|
|
|
- end: ndx
|
|
|
- } : caret(input), c = String.fromCharCode(k);
|
|
|
- getMaskSet().writeOutBuffer = !0;
|
|
|
- var valResult = isValid(pos, c, strict);
|
|
|
- if (valResult !== !1 && (resetMaskSet(!0), forwardPosition = void 0 !== valResult.caret ? valResult.caret : checkval ? valResult.pos + 1 : seekNext(valResult.pos),
|
|
|
- getMaskSet().p = forwardPosition), writeOut !== !1) {
|
|
|
- var self = this;
|
|
|
- if (setTimeout(function() {
|
|
|
- opts.onKeyValidation.call(self, k, valResult, opts);
|
|
|
- }, 0), getMaskSet().writeOutBuffer && valResult !== !1) {
|
|
|
- var buffer = getBuffer();
|
|
|
- writeBuffer(input, buffer, opts.numericInput && void 0 === valResult.caret ? seekPrevious(forwardPosition) : forwardPosition, e, checkval !== !0),
|
|
|
- checkval !== !0 && setTimeout(function() {
|
|
|
- isComplete(buffer) === !0 && $input.trigger("complete");
|
|
|
- }, 0);
|
|
|
- }
|
|
|
- }
|
|
|
- if (opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask), e.preventDefault(),
|
|
|
- checkval) return valResult.forwardPosition = forwardPosition, valResult;
|
|
|
- }
|
|
|
- }
|
|
|
- function pasteEvent(e) {
|
|
|
- var tempValue, input = this, ev = e.originalEvent || e, $input = $(input), inputValue = input.inputmask._valueGet(!0), caretPos = caret(input);
|
|
|
- isRTL && (tempValue = caretPos.end, caretPos.end = caretPos.begin, caretPos.begin = tempValue);
|
|
|
- var valueBeforeCaret = inputValue.substr(0, caretPos.begin), valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length);
|
|
|
- if (valueBeforeCaret === (isRTL ? getBufferTemplate().reverse() : getBufferTemplate()).slice(0, caretPos.begin).join("") && (valueBeforeCaret = ""),
|
|
|
- valueAfterCaret === (isRTL ? getBufferTemplate().reverse() : getBufferTemplate()).slice(caretPos.end).join("") && (valueAfterCaret = ""),
|
|
|
- isRTL && (tempValue = valueBeforeCaret, valueBeforeCaret = valueAfterCaret, valueAfterCaret = tempValue),
|
|
|
- window.clipboardData && window.clipboardData.getData) inputValue = valueBeforeCaret + window.clipboardData.getData("Text") + valueAfterCaret; else {
|
|
|
- if (!ev.clipboardData || !ev.clipboardData.getData) return !0;
|
|
|
- inputValue = valueBeforeCaret + ev.clipboardData.getData("text/plain") + valueAfterCaret;
|
|
|
- }
|
|
|
- var pasteValue = inputValue;
|
|
|
- if ($.isFunction(opts.onBeforePaste)) {
|
|
|
- if (pasteValue = opts.onBeforePaste(inputValue, opts), pasteValue === !1) return e.preventDefault();
|
|
|
- pasteValue || (pasteValue = inputValue);
|
|
|
- }
|
|
|
- return checkVal(input, !1, !1, isRTL ? pasteValue.split("").reverse() : pasteValue.toString().split("")),
|
|
|
- writeBuffer(input, getBuffer(), seekNext(getLastValidPosition()), e, undoValue !== getBuffer().join("")),
|
|
|
- isComplete(getBuffer()) === !0 && $input.trigger("complete"), e.preventDefault();
|
|
|
- }
|
|
|
- function inputFallBackEvent(e) {
|
|
|
- var input = this, inputValue = input.inputmask._valueGet();
|
|
|
- if (getBuffer().join("") !== inputValue) {
|
|
|
- var caretPos = caret(input);
|
|
|
- if (inputValue = inputValue.replace(new RegExp("(" + Inputmask.escapeRegex(getBufferTemplate().join("")) + ")*"), ""),
|
|
|
- iemobile) {
|
|
|
- var inputChar = inputValue.replace(getBuffer().join(""), "");
|
|
|
- if (1 === inputChar.length) {
|
|
|
- var keypress = new $.Event("keypress");
|
|
|
- return keypress.which = inputChar.charCodeAt(0), keypressEvent.call(input, keypress, !0, !0, !1, getMaskSet().validPositions[caretPos.begin - 1] ? caretPos.begin : caretPos.begin - 1),
|
|
|
- !1;
|
|
|
- }
|
|
|
- }
|
|
|
- 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)) {
|
|
|
- for (var lvp = getLastValidPosition() + 1, bufferTemplate = getBufferTemplate().join(""); null === inputValue.match(Inputmask.escapeRegex(bufferTemplate) + "$"); ) bufferTemplate = bufferTemplate.slice(1);
|
|
|
- inputValue = inputValue.replace(bufferTemplate, ""), inputValue = inputValue.split(""),
|
|
|
- checkVal(input, !0, !1, inputValue, e, caretPos.begin < lvp), isComplete(getBuffer()) === !0 && $(input).trigger("complete");
|
|
|
- } else e.keyCode = Inputmask.keyCode.BACKSPACE, keydownEvent.call(input, e);
|
|
|
- e.preventDefault();
|
|
|
- }
|
|
|
- }
|
|
|
- function setValueEvent(e) {
|
|
|
- var input = this, value = input.inputmask._valueGet();
|
|
|
- checkVal(input, !0, !1, ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(value, opts) || value : value).split("")),
|
|
|
- undoValue = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() === getBufferTemplate().join("") && input.inputmask._valueSet("");
|
|
|
- }
|
|
|
- function focusEvent(e) {
|
|
|
- var input = this, nptValue = input.inputmask._valueGet();
|
|
|
- opts.showMaskOnFocus && (!opts.showMaskOnHover || opts.showMaskOnHover && "" === nptValue) && (input.inputmask._valueGet() !== getBuffer().join("") ? writeBuffer(input, getBuffer(), seekNext(getLastValidPosition())) : mouseEnter === !1 && caret(input, seekNext(getLastValidPosition()))),
|
|
|
- opts.positionCaretOnTab === !0 && setTimeout(function() {
|
|
|
- clickEvent.apply(this, [ e ]);
|
|
|
- }, 0), undoValue = getBuffer().join("");
|
|
|
- }
|
|
|
- function mouseleaveEvent(e) {
|
|
|
- var input = this;
|
|
|
- if (mouseEnter = !1, opts.clearMaskOnLostFocus && document.activeElement !== input) {
|
|
|
- var buffer = getBuffer().slice(), nptValue = input.inputmask._valueGet();
|
|
|
- nptValue !== input.getAttribute("placeholder") && "" !== nptValue && (getLastValidPosition() === -1 && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer),
|
|
|
- writeBuffer(input, buffer));
|
|
|
- }
|
|
|
- }
|
|
|
- function clickEvent(e) {
|
|
|
- function doRadixFocus(clickPos) {
|
|
|
- if ("" !== opts.radixPoint) {
|
|
|
- var vps = getMaskSet().validPositions;
|
|
|
- if (void 0 === vps[clickPos] || vps[clickPos].input === getPlaceholder(clickPos)) {
|
|
|
- if (clickPos < seekNext(-1)) return !0;
|
|
|
- var radixPos = $.inArray(opts.radixPoint, getBuffer());
|
|
|
- if (radixPos !== -1) {
|
|
|
- for (var vp in vps) if (radixPos < vp && vps[vp].input !== getPlaceholder(vp)) return !1;
|
|
|
- return !0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return !1;
|
|
|
- }
|
|
|
- var input = this;
|
|
|
- setTimeout(function() {
|
|
|
- if (document.activeElement === input) {
|
|
|
- var selectedCaret = caret(input);
|
|
|
- if (selectedCaret.begin === selectedCaret.end) switch (opts.positionCaretOnClick) {
|
|
|
- case "none":
|
|
|
- break;
|
|
|
-
|
|
|
- case "radixFocus":
|
|
|
- if (doRadixFocus(selectedCaret.begin)) {
|
|
|
- var radixPos = $.inArray(opts.radixPoint, getBuffer().join(""));
|
|
|
- caret(input, opts.numericInput ? seekNext(radixPos) : radixPos);
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- default:
|
|
|
- var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition, !0), lastPosition = seekNext(lvclickPosition);
|
|
|
- if (clickPosition < lastPosition) caret(input, isMask(clickPosition) || isMask(clickPosition - 1) ? clickPosition : seekNext(clickPosition)); else {
|
|
|
- var placeholder = getPlaceholder(lastPosition);
|
|
|
- ("" !== placeholder && getBuffer()[lastPosition] !== placeholder && getTest(lastPosition).match.optionalQuantifier !== !0 || !isMask(lastPosition) && getTest(lastPosition).match.def === placeholder) && (lastPosition = seekNext(lastPosition)),
|
|
|
- caret(input, lastPosition);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }, 0);
|
|
|
- }
|
|
|
- function dblclickEvent(e) {
|
|
|
- var input = this;
|
|
|
- setTimeout(function() {
|
|
|
- caret(input, 0, seekNext(getLastValidPosition()));
|
|
|
- }, 0);
|
|
|
- }
|
|
|
- function cutEvent(e) {
|
|
|
- var input = this, $input = $(input), pos = caret(input), ev = e.originalEvent || e, clipboardData = window.clipboardData || ev.clipboardData, clipData = isRTL ? getBuffer().slice(pos.end, pos.begin) : getBuffer().slice(pos.begin, pos.end);
|
|
|
- clipboardData.setData("text", isRTL ? clipData.reverse().join("") : clipData.join("")),
|
|
|
- document.execCommand && document.execCommand("copy"), handleRemove(input, Inputmask.keyCode.DELETE, pos),
|
|
|
- writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")),
|
|
|
- input.inputmask._valueGet() === getBufferTemplate().join("") && $input.trigger("cleared"),
|
|
|
- opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask);
|
|
|
- }
|
|
|
- function blurEvent(e) {
|
|
|
- var $input = $(this), input = this;
|
|
|
- if (input.inputmask) {
|
|
|
- var nptValue = input.inputmask._valueGet(), buffer = getBuffer().slice();
|
|
|
- undoValue !== buffer.join("") && setTimeout(function() {
|
|
|
- $input.trigger("change"), undoValue = buffer.join("");
|
|
|
- }, 0), "" !== nptValue && (opts.clearMaskOnLostFocus && (getLastValidPosition() === -1 && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
|
|
|
- isComplete(buffer) === !1 && (setTimeout(function() {
|
|
|
- $input.trigger("incomplete");
|
|
|
- }, 0), opts.clearIncomplete && (resetMaskSet(), buffer = opts.clearMaskOnLostFocus ? [] : getBufferTemplate().slice())),
|
|
|
- writeBuffer(input, buffer, void 0, e));
|
|
|
- }
|
|
|
- }
|
|
|
- function mouseenterEvent(e) {
|
|
|
- var input = this;
|
|
|
- mouseEnter = !0, document.activeElement !== input && opts.showMaskOnHover && input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer());
|
|
|
- }
|
|
|
- function submitEvent(e) {
|
|
|
- undoValue !== getBuffer().join("") && $el.trigger("change"), opts.clearMaskOnLostFocus && getLastValidPosition() === -1 && el.inputmask._valueGet && el.inputmask._valueGet() === getBufferTemplate().join("") && el.inputmask._valueSet(""),
|
|
|
- opts.removeMaskOnSubmit && (el.inputmask._valueSet(el.inputmask.unmaskedvalue(), !0),
|
|
|
- setTimeout(function() {
|
|
|
- writeBuffer(el, getBuffer());
|
|
|
- }, 0));
|
|
|
- }
|
|
|
- function resetEvent(e) {
|
|
|
- setTimeout(function() {
|
|
|
- $el.trigger("setvalue");
|
|
|
- }, 0);
|
|
|
- }
|
|
|
function initializeColorMask(input) {
|
|
|
function findCaretPos(clientx) {
|
|
|
var caretPos, e = document.createElement("span");
|
|
|
@@ -996,7 +795,11 @@
|
|
|
offset = $(input).position(), computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null),
|
|
|
position();
|
|
|
}), $(input).on("click", function(e) {
|
|
|
- return caret(input, findCaretPos(e.clientX)), clickEvent.call(this, [ e ]);
|
|
|
+ return caret(input, findCaretPos(e.clientX)), EventHandlers.clickEvent.call(this, [ e ]);
|
|
|
+ }), $(input).on("keydown", function(e) {
|
|
|
+ e.shiftKey || opts.insertMode === !1 || setTimeout(function() {
|
|
|
+ renderColorMask(input);
|
|
|
+ }, 0);
|
|
|
});
|
|
|
}
|
|
|
function renderColorMask(input, buffer, caretPos) {
|
|
|
@@ -1035,18 +838,20 @@
|
|
|
el.removeAttribute("dir"), el.inputmask.isRTL = !0, isRTL = !0), opts.colorMask === !0 && initializeColorMask(el),
|
|
|
android && (el.hasOwnProperty("inputmode") && (el.inputmode = opts.inputmode, el.setAttribute("inputmode", opts.inputmode)),
|
|
|
"rtfm" === opts.androidHack && (opts.colorMask !== !0 && initializeColorMask(el),
|
|
|
- el.type = "password")), EventRuler.off(el), patchValueProperty(el), 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),
|
|
|
- opts.colorMask !== !0 && 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),
|
|
|
+ el.type = "password")), EventRuler.off(el), patchValueProperty(el), EventRuler.on(el, "submit", EventHandlers.submitEvent),
|
|
|
+ EventRuler.on(el, "reset", EventHandlers.resetEvent), EventRuler.on(el, "mouseenter", EventHandlers.mouseenterEvent),
|
|
|
+ EventRuler.on(el, "blur", EventHandlers.blurEvent), EventRuler.on(el, "focus", EventHandlers.focusEvent),
|
|
|
+ EventRuler.on(el, "mouseleave", EventHandlers.mouseleaveEvent), opts.colorMask !== !0 && EventRuler.on(el, "click", EventHandlers.clickEvent),
|
|
|
+ EventRuler.on(el, "dblclick", EventHandlers.dblclickEvent), EventRuler.on(el, "paste", EventHandlers.pasteEvent),
|
|
|
+ EventRuler.on(el, "dragdrop", EventHandlers.pasteEvent), EventRuler.on(el, "drop", EventHandlers.pasteEvent),
|
|
|
+ EventRuler.on(el, "cut", EventHandlers.cutEvent), EventRuler.on(el, "complete", opts.oncomplete),
|
|
|
EventRuler.on(el, "incomplete", opts.onincomplete), EventRuler.on(el, "cleared", opts.oncleared),
|
|
|
- opts.inputEventOnly !== !0 && (EventRuler.on(el, "keydown", keydownEvent), EventRuler.on(el, "keypress", keypressEvent)),
|
|
|
- EventRuler.on(el, "compositionstart", $.noop), EventRuler.on(el, "compositionupdate", $.noop),
|
|
|
- EventRuler.on(el, "compositionend", $.noop), EventRuler.on(el, "keyup", $.noop),
|
|
|
- EventRuler.on(el, "input", inputFallBackEvent), EventRuler.on(el, "setvalue", setValueEvent),
|
|
|
- getBufferTemplate(), "" !== el.inputmask._valueGet() || opts.clearMaskOnLostFocus === !1 || document.activeElement === el)) {
|
|
|
+ opts.inputEventOnly !== !0 && (EventRuler.on(el, "keydown", EventHandlers.keydownEvent),
|
|
|
+ EventRuler.on(el, "keypress", EventHandlers.keypressEvent)), EventRuler.on(el, "compositionstart", $.noop),
|
|
|
+ EventRuler.on(el, "compositionupdate", $.noop), EventRuler.on(el, "compositionend", $.noop),
|
|
|
+ EventRuler.on(el, "keyup", $.noop), EventRuler.on(el, "input", EventHandlers.inputFallBackEvent),
|
|
|
+ EventRuler.on(el, "setvalue", EventHandlers.setValueEvent), getBufferTemplate(),
|
|
|
+ "" !== el.inputmask._valueGet() || opts.clearMaskOnLostFocus === !1 || document.activeElement === el)) {
|
|
|
var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(el.inputmask._valueGet(), opts) || el.inputmask._valueGet() : el.inputmask._valueGet();
|
|
|
checkVal(el, !0, !1, initialValue.split(""));
|
|
|
var buffer = getBuffer().slice();
|
|
|
@@ -1055,7 +860,8 @@
|
|
|
writeBuffer(el, buffer), document.activeElement === el && caret(el, seekNext(getLastValidPosition()));
|
|
|
}
|
|
|
}
|
|
|
- var undoValue, el, $el, maxLength, colorMask, valueBuffer, isRTL = !1, skipKeyPressEvent = !1, skipInputEvent = !1, ignorable = !1, mouseEnter = !1, EventRuler = {
|
|
|
+ maskset = maskset || this.maskset, opts = opts || this.opts;
|
|
|
+ var undoValue, $el, maxLength, colorMask, valueBuffer, el = this.el, isRTL = this.isRTL, skipKeyPressEvent = !1, skipInputEvent = !1, ignorable = !1, mouseEnter = !1, EventRuler = {
|
|
|
on: function(input, eventName, eventHandler) {
|
|
|
var ev = function(e) {
|
|
|
if (void 0 === this.inputmask && "FORM" !== this.nodeName) {
|
|
|
@@ -1107,36 +913,240 @@
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+ }, EventHandlers = {
|
|
|
+ keydownEvent: function(e) {
|
|
|
+ function isInputEventSupported(eventName) {
|
|
|
+ var el = document.createElement("input"), evName = "on" + eventName, isSupported = evName in el;
|
|
|
+ return isSupported || (el.setAttribute(evName, "return;"), isSupported = "function" == typeof el[evName]),
|
|
|
+ el = null, isSupported;
|
|
|
+ }
|
|
|
+ var input = this, $input = $(input), k = e.keyCode, pos = caret(input);
|
|
|
+ if (k === Inputmask.keyCode.BACKSPACE || k === Inputmask.keyCode.DELETE || iphone && k === Inputmask.keyCode.BACKSPACE_SAFARI || e.ctrlKey && k === Inputmask.keyCode.X && !isInputEventSupported("cut")) e.preventDefault(),
|
|
|
+ handleRemove(input, k, pos), writeBuffer(input, getBuffer(!0), getMaskSet().p, e, input.inputmask._valueGet() !== getBuffer().join("")),
|
|
|
+ input.inputmask._valueGet() === getBufferTemplate().join("") ? $input.trigger("cleared") : isComplete(getBuffer()) === !0 && $input.trigger("complete"),
|
|
|
+ opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask); else if (k === Inputmask.keyCode.END || k === Inputmask.keyCode.PAGE_DOWN) {
|
|
|
+ e.preventDefault();
|
|
|
+ var caretPos = seekNext(getLastValidPosition());
|
|
|
+ opts.insertMode || caretPos !== getMaskSet().maskLength || e.shiftKey || caretPos--,
|
|
|
+ caret(input, e.shiftKey ? pos.begin : caretPos, caretPos, !0);
|
|
|
+ } else k === Inputmask.keyCode.HOME && !e.shiftKey || k === Inputmask.keyCode.PAGE_UP ? (e.preventDefault(),
|
|
|
+ caret(input, 0, e.shiftKey ? pos.begin : 0, !0)) : (opts.undoOnEscape && k === Inputmask.keyCode.ESCAPE || 90 === k && e.ctrlKey) && e.altKey !== !0 ? (checkVal(input, !0, !1, undoValue.split("")),
|
|
|
+ $input.trigger("click")) : k !== Inputmask.keyCode.INSERT || e.shiftKey || e.ctrlKey ? opts.tabThrough === !0 && k === Inputmask.keyCode.TAB ? (e.shiftKey === !0 ? (null === getTest(pos.begin).match.fn && (pos.begin = seekNext(pos.begin)),
|
|
|
+ pos.end = seekPrevious(pos.begin, !0), pos.begin = seekPrevious(pos.end, !0)) : (pos.begin = seekNext(pos.begin, !0),
|
|
|
+ pos.end = seekNext(pos.begin, !0), pos.end < getMaskSet().maskLength && pos.end--),
|
|
|
+ pos.begin < getMaskSet().maskLength && (e.preventDefault(), caret(input, pos.begin, pos.end))) : e.shiftKey || opts.insertMode === !1 && (k === Inputmask.keyCode.RIGHT ? setTimeout(function() {
|
|
|
+ var caretPos = caret(input);
|
|
|
+ caret(input, caretPos.begin);
|
|
|
+ }, 0) : k === Inputmask.keyCode.LEFT && setTimeout(function() {
|
|
|
+ var caretPos = caret(input);
|
|
|
+ caret(input, isRTL ? caretPos.begin + 1 : caretPos.begin - 1);
|
|
|
+ }, 0)) : (opts.insertMode = !opts.insertMode, caret(input, opts.insertMode || pos.begin !== getMaskSet().maskLength ? pos.begin : pos.begin - 1));
|
|
|
+ opts.onKeyDown.call(this, e, getBuffer(), caret(input).begin, opts), ignorable = $.inArray(k, opts.ignorables) !== -1;
|
|
|
+ },
|
|
|
+ keypressEvent: function(e, checkval, writeOut, strict, ndx) {
|
|
|
+ var input = this, $input = $(input), k = e.which || e.charCode || e.keyCode;
|
|
|
+ if (!(checkval === !0 || e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable)) return k === Inputmask.keyCode.ENTER && undoValue !== getBuffer().join("") && (undoValue = getBuffer().join(""),
|
|
|
+ setTimeout(function() {
|
|
|
+ $input.trigger("change");
|
|
|
+ }, 0)), !0;
|
|
|
+ if (k) {
|
|
|
+ 46 === k && e.shiftKey === !1 && "," === opts.radixPoint && (k = 44);
|
|
|
+ var forwardPosition, pos = checkval ? {
|
|
|
+ begin: ndx,
|
|
|
+ end: ndx
|
|
|
+ } : caret(input), c = String.fromCharCode(k);
|
|
|
+ getMaskSet().writeOutBuffer = !0;
|
|
|
+ var valResult = isValid(pos, c, strict);
|
|
|
+ if (valResult !== !1 && (resetMaskSet(!0), forwardPosition = void 0 !== valResult.caret ? valResult.caret : checkval ? valResult.pos + 1 : seekNext(valResult.pos),
|
|
|
+ getMaskSet().p = forwardPosition), writeOut !== !1) {
|
|
|
+ var self = this;
|
|
|
+ if (setTimeout(function() {
|
|
|
+ opts.onKeyValidation.call(self, k, valResult, opts);
|
|
|
+ }, 0), getMaskSet().writeOutBuffer && valResult !== !1) {
|
|
|
+ var buffer = getBuffer();
|
|
|
+ writeBuffer(input, buffer, opts.numericInput && void 0 === valResult.caret ? seekPrevious(forwardPosition) : forwardPosition, e, checkval !== !0),
|
|
|
+ checkval !== !0 && setTimeout(function() {
|
|
|
+ isComplete(buffer) === !0 && $input.trigger("complete");
|
|
|
+ }, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask), e.preventDefault(),
|
|
|
+ checkval) return valResult.forwardPosition = forwardPosition, valResult;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ pasteEvent: function(e) {
|
|
|
+ var tempValue, input = this, ev = e.originalEvent || e, $input = $(input), inputValue = input.inputmask._valueGet(!0), caretPos = caret(input);
|
|
|
+ isRTL && (tempValue = caretPos.end, caretPos.end = caretPos.begin, caretPos.begin = tempValue);
|
|
|
+ var valueBeforeCaret = inputValue.substr(0, caretPos.begin), valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length);
|
|
|
+ if (valueBeforeCaret === (isRTL ? getBufferTemplate().reverse() : getBufferTemplate()).slice(0, caretPos.begin).join("") && (valueBeforeCaret = ""),
|
|
|
+ valueAfterCaret === (isRTL ? getBufferTemplate().reverse() : getBufferTemplate()).slice(caretPos.end).join("") && (valueAfterCaret = ""),
|
|
|
+ isRTL && (tempValue = valueBeforeCaret, valueBeforeCaret = valueAfterCaret, valueAfterCaret = tempValue),
|
|
|
+ window.clipboardData && window.clipboardData.getData) inputValue = valueBeforeCaret + window.clipboardData.getData("Text") + valueAfterCaret; else {
|
|
|
+ if (!ev.clipboardData || !ev.clipboardData.getData) return !0;
|
|
|
+ inputValue = valueBeforeCaret + ev.clipboardData.getData("text/plain") + valueAfterCaret;
|
|
|
+ }
|
|
|
+ var pasteValue = inputValue;
|
|
|
+ if ($.isFunction(opts.onBeforePaste)) {
|
|
|
+ if (pasteValue = opts.onBeforePaste(inputValue, opts), pasteValue === !1) return e.preventDefault();
|
|
|
+ pasteValue || (pasteValue = inputValue);
|
|
|
+ }
|
|
|
+ return checkVal(input, !1, !1, isRTL ? pasteValue.split("").reverse() : pasteValue.toString().split("")),
|
|
|
+ writeBuffer(input, getBuffer(), seekNext(getLastValidPosition()), e, undoValue !== getBuffer().join("")),
|
|
|
+ isComplete(getBuffer()) === !0 && $input.trigger("complete"), e.preventDefault();
|
|
|
+ },
|
|
|
+ inputFallBackEvent: function(e) {
|
|
|
+ var input = this, inputValue = input.inputmask._valueGet();
|
|
|
+ if (getBuffer().join("") !== inputValue) {
|
|
|
+ var caretPos = caret(input);
|
|
|
+ if (inputValue = inputValue.replace(new RegExp("(" + Inputmask.escapeRegex(getBufferTemplate().join("")) + ")*"), ""),
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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)) {
|
|
|
+ for (var lvp = getLastValidPosition() + 1, bufferTemplate = getBufferTemplate().join(""); null === inputValue.match(Inputmask.escapeRegex(bufferTemplate) + "$"); ) bufferTemplate = bufferTemplate.slice(1);
|
|
|
+ inputValue = inputValue.replace(bufferTemplate, ""), inputValue = inputValue.split(""),
|
|
|
+ checkVal(input, !0, !1, inputValue, e, caretPos.begin < lvp), isComplete(getBuffer()) === !0 && $(input).trigger("complete");
|
|
|
+ } else e.keyCode = Inputmask.keyCode.BACKSPACE, EventHandlers.keydownEvent.call(input, e);
|
|
|
+ e.preventDefault();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setValueEvent: function(e) {
|
|
|
+ var input = this, value = input.inputmask._valueGet();
|
|
|
+ checkVal(input, !0, !1, ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(value, opts) || value : value).split("")),
|
|
|
+ undoValue = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() === getBufferTemplate().join("") && input.inputmask._valueSet("");
|
|
|
+ },
|
|
|
+ focusEvent: function(e) {
|
|
|
+ var input = this, nptValue = input.inputmask._valueGet();
|
|
|
+ opts.showMaskOnFocus && (!opts.showMaskOnHover || opts.showMaskOnHover && "" === nptValue) && (input.inputmask._valueGet() !== getBuffer().join("") ? writeBuffer(input, getBuffer(), seekNext(getLastValidPosition())) : mouseEnter === !1 && caret(input, seekNext(getLastValidPosition()))),
|
|
|
+ opts.positionCaretOnTab === !0 && setTimeout(function() {
|
|
|
+ EventHandlers.clickEvent.apply(this, [ e ]);
|
|
|
+ }, 0), undoValue = getBuffer().join("");
|
|
|
+ },
|
|
|
+ mouseleaveEvent: function(e) {
|
|
|
+ var input = this;
|
|
|
+ if (mouseEnter = !1, opts.clearMaskOnLostFocus && document.activeElement !== input) {
|
|
|
+ var buffer = getBuffer().slice(), nptValue = input.inputmask._valueGet();
|
|
|
+ nptValue !== input.getAttribute("placeholder") && "" !== nptValue && (getLastValidPosition() === -1 && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer),
|
|
|
+ writeBuffer(input, buffer));
|
|
|
+ }
|
|
|
+ },
|
|
|
+ clickEvent: function(e) {
|
|
|
+ function doRadixFocus(clickPos) {
|
|
|
+ if ("" !== opts.radixPoint) {
|
|
|
+ var vps = getMaskSet().validPositions;
|
|
|
+ if (void 0 === vps[clickPos] || vps[clickPos].input === getPlaceholder(clickPos)) {
|
|
|
+ if (clickPos < seekNext(-1)) return !0;
|
|
|
+ var radixPos = $.inArray(opts.radixPoint, getBuffer());
|
|
|
+ if (radixPos !== -1) {
|
|
|
+ for (var vp in vps) if (radixPos < vp && vps[vp].input !== getPlaceholder(vp)) return !1;
|
|
|
+ return !0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return !1;
|
|
|
+ }
|
|
|
+ var input = this;
|
|
|
+ setTimeout(function() {
|
|
|
+ if (document.activeElement === input) {
|
|
|
+ var selectedCaret = caret(input);
|
|
|
+ if (selectedCaret.begin === selectedCaret.end) switch (opts.positionCaretOnClick) {
|
|
|
+ case "none":
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "radixFocus":
|
|
|
+ if (doRadixFocus(selectedCaret.begin)) {
|
|
|
+ var radixPos = $.inArray(opts.radixPoint, getBuffer().join(""));
|
|
|
+ caret(input, opts.numericInput ? seekNext(radixPos) : radixPos);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ default:
|
|
|
+ var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition, !0), lastPosition = seekNext(lvclickPosition);
|
|
|
+ if (clickPosition < lastPosition) caret(input, isMask(clickPosition) || isMask(clickPosition - 1) ? clickPosition : seekNext(clickPosition)); else {
|
|
|
+ var placeholder = getPlaceholder(lastPosition);
|
|
|
+ ("" !== placeholder && getBuffer()[lastPosition] !== placeholder && getTest(lastPosition).match.optionalQuantifier !== !0 || !isMask(lastPosition) && getTest(lastPosition).match.def === placeholder) && (lastPosition = seekNext(lastPosition)),
|
|
|
+ caret(input, lastPosition);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 0);
|
|
|
+ },
|
|
|
+ dblclickEvent: function(e) {
|
|
|
+ var input = this;
|
|
|
+ setTimeout(function() {
|
|
|
+ caret(input, 0, seekNext(getLastValidPosition()));
|
|
|
+ }, 0);
|
|
|
+ },
|
|
|
+ cutEvent: function(e) {
|
|
|
+ var input = this, $input = $(input), pos = caret(input), ev = e.originalEvent || e, clipboardData = window.clipboardData || ev.clipboardData, clipData = isRTL ? getBuffer().slice(pos.end, pos.begin) : getBuffer().slice(pos.begin, pos.end);
|
|
|
+ clipboardData.setData("text", isRTL ? clipData.reverse().join("") : clipData.join("")),
|
|
|
+ document.execCommand && document.execCommand("copy"), handleRemove(input, Inputmask.keyCode.DELETE, pos),
|
|
|
+ writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")),
|
|
|
+ input.inputmask._valueGet() === getBufferTemplate().join("") && $input.trigger("cleared"),
|
|
|
+ opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask);
|
|
|
+ },
|
|
|
+ blurEvent: function(e) {
|
|
|
+ var $input = $(this), input = this;
|
|
|
+ if (input.inputmask) {
|
|
|
+ var nptValue = input.inputmask._valueGet(), buffer = getBuffer().slice();
|
|
|
+ undoValue !== buffer.join("") && setTimeout(function() {
|
|
|
+ $input.trigger("change"), undoValue = buffer.join("");
|
|
|
+ }, 0), "" !== nptValue && (opts.clearMaskOnLostFocus && (getLastValidPosition() === -1 && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
|
|
|
+ isComplete(buffer) === !1 && (setTimeout(function() {
|
|
|
+ $input.trigger("incomplete");
|
|
|
+ }, 0), opts.clearIncomplete && (resetMaskSet(), buffer = opts.clearMaskOnLostFocus ? [] : getBufferTemplate().slice())),
|
|
|
+ writeBuffer(input, buffer, void 0, e));
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mouseenterEvent: function(e) {
|
|
|
+ var input = this;
|
|
|
+ mouseEnter = !0, document.activeElement !== input && opts.showMaskOnHover && input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer());
|
|
|
+ },
|
|
|
+ submitEvent: function(e) {
|
|
|
+ undoValue !== getBuffer().join("") && $el.trigger("change"), opts.clearMaskOnLostFocus && getLastValidPosition() === -1 && el.inputmask._valueGet && el.inputmask._valueGet() === getBufferTemplate().join("") && el.inputmask._valueSet(""),
|
|
|
+ opts.removeMaskOnSubmit && (el.inputmask._valueSet(el.inputmask.unmaskedvalue(), !0),
|
|
|
+ setTimeout(function() {
|
|
|
+ writeBuffer(el, getBuffer());
|
|
|
+ }, 0));
|
|
|
+ },
|
|
|
+ resetEvent: function(e) {
|
|
|
+ setTimeout(function() {
|
|
|
+ $el.trigger("setvalue");
|
|
|
+ }, 0);
|
|
|
+ }
|
|
|
};
|
|
|
if (void 0 !== actionObj) switch (actionObj.action) {
|
|
|
case "isComplete":
|
|
|
return el = actionObj.el, isComplete(getBuffer());
|
|
|
|
|
|
case "unmaskedvalue":
|
|
|
- return el = actionObj.el, void 0 !== el && void 0 !== el.inputmask ? (maskset = el.inputmask.maskset,
|
|
|
- opts = el.inputmask.opts, isRTL = el.inputmask.isRTL) : (valueBuffer = actionObj.value,
|
|
|
- opts.numericInput && (isRTL = !0), valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(valueBuffer, opts) || valueBuffer : valueBuffer).split(""),
|
|
|
+ return void 0 !== el && void 0 === actionObj.value || (valueBuffer = actionObj.value,
|
|
|
+ valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(valueBuffer, opts) || valueBuffer : valueBuffer).split(""),
|
|
|
checkVal(void 0, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite(void 0, getBuffer(), 0, opts)),
|
|
|
unmaskedvalue(el);
|
|
|
|
|
|
case "mask":
|
|
|
- el = actionObj.el, maskset = el.inputmask.maskset, opts = el.inputmask.opts, isRTL = el.inputmask.isRTL,
|
|
|
mask(el);
|
|
|
break;
|
|
|
|
|
|
case "format":
|
|
|
- return opts.numericInput && (isRTL = !0), valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(actionObj.value, opts) || actionObj.value : actionObj.value).split(""),
|
|
|
+ return valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(actionObj.value, opts) || actionObj.value : actionObj.value).split(""),
|
|
|
checkVal(void 0, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite(void 0, getBuffer(), 0, opts),
|
|
|
actionObj.metadata ? {
|
|
|
value: isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join(""),
|
|
|
- metadata: maskScope({
|
|
|
+ metadata: maskScope.call(this, {
|
|
|
action: "getmetadata"
|
|
|
}, maskset, opts)
|
|
|
} : isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join("");
|
|
|
|
|
|
case "isValid":
|
|
|
- opts.numericInput && (isRTL = !0), actionObj.value ? (valueBuffer = actionObj.value.split(""),
|
|
|
- checkVal(void 0, !1, !0, isRTL ? valueBuffer.reverse() : valueBuffer)) : actionObj.value = getBuffer().join("");
|
|
|
+ actionObj.value ? (valueBuffer = actionObj.value.split(""), checkVal(void 0, !1, !0, isRTL ? valueBuffer.reverse() : valueBuffer)) : actionObj.value = getBuffer().join("");
|
|
|
for (var buffer = getBuffer(), rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
|
|
|
return buffer.splice(rl, lmib + 1 - rl), isComplete(buffer) && actionObj.value === getBuffer().join("");
|
|
|
|
|
|
@@ -1144,17 +1154,18 @@
|
|
|
return getBufferTemplate().join("");
|
|
|
|
|
|
case "remove":
|
|
|
- el = actionObj.el, $el = $(el), maskset = el.inputmask.maskset, opts = el.inputmask.opts,
|
|
|
- el.inputmask._valueSet(unmaskedvalue(el)), EventRuler.off(el);
|
|
|
- var valueProperty;
|
|
|
- Object.getOwnPropertyDescriptor && Object.getPrototypeOf ? (valueProperty = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(el), "value"),
|
|
|
- valueProperty && el.inputmask.__valueGet && Object.defineProperty(el, "value", {
|
|
|
- get: el.inputmask.__valueGet,
|
|
|
- set: el.inputmask.__valueSet,
|
|
|
- configurable: !0
|
|
|
- })) : document.__lookupGetter__ && el.__lookupGetter__("value") && el.inputmask.__valueGet && (el.__defineGetter__("value", el.inputmask.__valueGet),
|
|
|
- el.__defineSetter__("value", el.inputmask.__valueSet)), el.inputmask = void 0;
|
|
|
- break;
|
|
|
+ if (el) {
|
|
|
+ $el = $(el), el.inputmask._valueSet(unmaskedvalue(el)), EventRuler.off(el);
|
|
|
+ var valueProperty;
|
|
|
+ Object.getOwnPropertyDescriptor && Object.getPrototypeOf ? (valueProperty = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(el), "value"),
|
|
|
+ valueProperty && el.inputmask.__valueGet && Object.defineProperty(el, "value", {
|
|
|
+ get: el.inputmask.__valueGet,
|
|
|
+ set: el.inputmask.__valueSet,
|
|
|
+ configurable: !0
|
|
|
+ })) : document.__lookupGetter__ && el.__lookupGetter__("value") && el.inputmask.__valueGet && (el.__defineGetter__("value", el.inputmask.__valueGet),
|
|
|
+ el.__defineSetter__("value", el.inputmask.__valueSet)), el.inputmask = void 0;
|
|
|
+ }
|
|
|
+ return el;
|
|
|
|
|
|
case "getmetadata":
|
|
|
if ($.isArray(maskset.metadata)) {
|
|
|
@@ -1268,7 +1279,7 @@
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- importOption("alias", optionData), userOptions.alias && that.resolveAlias(userOptions.alias, userOptions, opts);
|
|
|
+ importOption("alias", optionData), userOptions.alias && resolveAlias(userOptions.alias, userOptions, opts);
|
|
|
for (option in opts) {
|
|
|
if (dataoptions) {
|
|
|
optionData = void 0;
|
|
|
@@ -1289,10 +1300,9 @@
|
|
|
var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
|
|
|
void 0 !== maskset && (void 0 !== el.inputmask && el.inputmask.remove(), el.inputmask = new Inputmask(),
|
|
|
el.inputmask.opts = scopedOpts, el.inputmask.noMasksCache = that.noMasksCache, el.inputmask.userOptions = $.extend(!0, {}, that.userOptions),
|
|
|
- el.inputmask.el = el, el.inputmask.maskset = maskset, el.inputmask.isRTL = !1, $.data(el, "_inputmask_opts", scopedOpts),
|
|
|
- maskScope({
|
|
|
- action: "mask",
|
|
|
- el: el
|
|
|
+ el.inputmask.el = el, el.inputmask.maskset = maskset, $.data(el, "_inputmask_opts", scopedOpts),
|
|
|
+ maskScope.call(el.inputmask, {
|
|
|
+ action: "mask"
|
|
|
}));
|
|
|
}), elems && elems[0] ? elems[0].inputmask || this : this;
|
|
|
},
|
|
|
@@ -1301,49 +1311,52 @@
|
|
|
this.el && noremask !== !0 && this.mask(this.el), this) : void 0;
|
|
|
},
|
|
|
unmaskedvalue: function(value) {
|
|
|
- return maskScope({
|
|
|
+ return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
|
|
|
+ maskScope.call(this, {
|
|
|
action: "unmaskedvalue",
|
|
|
- el: this.el,
|
|
|
value: value
|
|
|
- }, this.el && this.el.inputmask ? this.el.inputmask.maskset : generateMaskSet(this.opts, this.noMasksCache), this.opts);
|
|
|
+ });
|
|
|
},
|
|
|
remove: function() {
|
|
|
- if (this.el) return maskScope({
|
|
|
- action: "remove",
|
|
|
- el: this.el
|
|
|
- }), this.el.inputmask = void 0, this.el;
|
|
|
+ return maskScope.call(this, {
|
|
|
+ action: "remove"
|
|
|
+ });
|
|
|
},
|
|
|
getemptymask: function() {
|
|
|
- return maskScope({
|
|
|
+ return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
|
|
|
+ maskScope.call(this, {
|
|
|
action: "getemptymask"
|
|
|
- }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
|
|
|
+ });
|
|
|
},
|
|
|
hasMaskedValue: function() {
|
|
|
return !this.opts.autoUnmask;
|
|
|
},
|
|
|
isComplete: function() {
|
|
|
- return maskScope({
|
|
|
- action: "isComplete",
|
|
|
- el: this.el
|
|
|
- }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
|
|
|
+ return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
|
|
|
+ maskScope.call(this, {
|
|
|
+ action: "isComplete"
|
|
|
+ });
|
|
|
},
|
|
|
getmetadata: function() {
|
|
|
- return maskScope({
|
|
|
+ return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
|
|
|
+ maskScope.call(this, {
|
|
|
action: "getmetadata"
|
|
|
- }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
|
|
|
+ });
|
|
|
},
|
|
|
isValid: function(value) {
|
|
|
- return maskScope({
|
|
|
+ return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
|
|
|
+ maskScope.call(this, {
|
|
|
action: "isValid",
|
|
|
value: value
|
|
|
- }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
|
|
|
+ });
|
|
|
},
|
|
|
format: function(value, metadata) {
|
|
|
- return maskScope({
|
|
|
+ return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
|
|
|
+ maskScope.call(this, {
|
|
|
action: "format",
|
|
|
value: value,
|
|
|
metadata: metadata
|
|
|
- }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
|
|
|
+ });
|
|
|
},
|
|
|
analyseMask: function(mask, opts) {
|
|
|
function MaskToken(isGroup, isOptional, isQuantifier, isAlternator) {
|
|
|
@@ -1491,12 +1504,6 @@
|
|
|
return currentToken.matches.length > 0 && (lastMatch = currentToken.matches[currentToken.matches.length - 1],
|
|
|
verifyGroupMarker(lastMatch), maskTokens.push(currentToken)), opts.numericInput && reverseTokens(maskTokens[0]),
|
|
|
maskTokens;
|
|
|
- },
|
|
|
- resolveAlias: function(aliasStr, options, opts) {
|
|
|
- var aliasDefinition = opts.aliases[aliasStr];
|
|
|
- return aliasDefinition ? (aliasDefinition.alias && this.resolveAlias(aliasDefinition.alias, void 0, opts),
|
|
|
- $.extend(!0, opts, aliasDefinition), $.extend(!0, opts, options), !0) : (null === opts.mask && (opts.mask = aliasStr),
|
|
|
- !1);
|
|
|
}
|
|
|
}, Inputmask.extendDefaults = function(options) {
|
|
|
$.extend(!0, Inputmask.prototype.defaults, options);
|