|
@@ -638,7 +638,7 @@
|
|
|
return isRTL ? begin - end > 1 || begin - end == 1 && opts.insertMode : end - begin > 1 || end - begin == 1 && opts.insertMode;
|
|
return isRTL ? begin - end > 1 || begin - end == 1 && opts.insertMode : end - begin > 1 || end - begin == 1 && opts.insertMode;
|
|
|
}
|
|
}
|
|
|
function installEventRuler(npt) {
|
|
function installEventRuler(npt) {
|
|
|
- var events = $._data(npt).events;
|
|
|
|
|
|
|
+ var events = $._data(npt).events, incomposition = !1;
|
|
|
$.each(events, function(eventType, eventHandlers) {
|
|
$.each(events, function(eventType, eventHandlers) {
|
|
|
$.each(eventHandlers, function(ndx, eventHandler) {
|
|
$.each(eventHandlers, function(ndx, eventHandler) {
|
|
|
if ("inputmask" == eventHandler.namespace && "setvalue" != eventHandler.type) {
|
|
if ("inputmask" == eventHandler.namespace && "setvalue" != eventHandler.type) {
|
|
@@ -647,7 +647,7 @@
|
|
|
if (!this.readOnly && !this.disabled) {
|
|
if (!this.readOnly && !this.disabled) {
|
|
|
switch (e.type) {
|
|
switch (e.type) {
|
|
|
case "input":
|
|
case "input":
|
|
|
- if (skipInputEvent === !0) return skipInputEvent = !1, e.preventDefault;
|
|
|
|
|
|
|
+ if (skipInputEvent === !0 || incomposition) return skipInputEvent = !1, e.preventDefault;
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case "keydown":
|
|
case "keydown":
|
|
@@ -659,9 +659,17 @@
|
|
|
skipKeyPressEvent = !0;
|
|
skipKeyPressEvent = !0;
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
|
|
+ case "compositionstart":
|
|
|
case "compositionupdate":
|
|
case "compositionupdate":
|
|
|
case "compositionend":
|
|
case "compositionend":
|
|
|
- skipInputEvent = !0;
|
|
|
|
|
|
|
+ incomposition = !0;
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ case "compositionupdate":
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ case "compositionend":
|
|
|
|
|
+ incomposition = !1;
|
|
|
}
|
|
}
|
|
|
return handler.apply(this, arguments);
|
|
return handler.apply(this, arguments);
|
|
|
}
|
|
}
|
|
@@ -855,15 +863,18 @@
|
|
|
}
|
|
}
|
|
|
function compositionEndEvent(e) {
|
|
function compositionEndEvent(e) {
|
|
|
var input = this, caretPos = caret(input);
|
|
var input = this, caretPos = caret(input);
|
|
|
- return setTimeout(function() {
|
|
|
|
|
|
|
+ getMaskSet().validPositions = $.extend(!0, {}, compositionValidPos), setTimeout(function() {
|
|
|
var newData = e.originalEvent.data;
|
|
var newData = e.originalEvent.data;
|
|
|
- caret(input, caretPos.begin - 1, caretPos.end);
|
|
|
|
|
|
|
+ newData = newData.replace(compositionData, ""), caret(input, caretPos.begin - 1, caretPos.end);
|
|
|
for (var i = 0; i < newData.length; i++) {
|
|
for (var i = 0; i < newData.length; i++) {
|
|
|
var keypress = $.Event("keypress");
|
|
var keypress = $.Event("keypress");
|
|
|
keypress.which = newData.charCodeAt(i), skipKeyPressEvent = !1, ignorable = !1,
|
|
keypress.which = newData.charCodeAt(i), skipKeyPressEvent = !1, ignorable = !1,
|
|
|
keypressEvent.call(input, keypress);
|
|
keypressEvent.call(input, keypress);
|
|
|
}
|
|
}
|
|
|
- }, 0), !1;
|
|
|
|
|
|
|
+ compositionData = e.originalEvent.data;
|
|
|
|
|
+ var forwardPosition = getMaskSet().p;
|
|
|
|
|
+ writeBuffer(input, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
|
|
|
|
|
+ }, 0);
|
|
|
}
|
|
}
|
|
|
function mask(el) {
|
|
function mask(el) {
|
|
|
if ($el = $(el), $el.is(":input") && isInputTypeSupported($el.attr("type"))) {
|
|
if ($el = $(el), $el.is(":input") && isInputTypeSupported($el.attr("type"))) {
|
|
@@ -943,9 +954,9 @@
|
|
|
opts.showTooltip && $input.prop("title", getMaskSet().mask);
|
|
opts.showTooltip && $input.prop("title", getMaskSet().mask);
|
|
|
}).bind("complete.inputmask", opts.oncomplete).bind("incomplete.inputmask", opts.onincomplete).bind("cleared.inputmask", opts.oncleared),
|
|
}).bind("complete.inputmask", opts.oncomplete).bind("incomplete.inputmask", opts.onincomplete).bind("cleared.inputmask", opts.oncleared),
|
|
|
$el.bind("keydown.inputmask", keydownEvent).bind("keypress.inputmask", keypressEvent).bind("keyup.inputmask", keyupEvent).bind("compositionstart.inputmask", function() {
|
|
$el.bind("keydown.inputmask", keydownEvent).bind("keypress.inputmask", keypressEvent).bind("keyup.inputmask", keyupEvent).bind("compositionstart.inputmask", function() {
|
|
|
- undoValue = getBuffer().join("");
|
|
|
|
|
- }).bind("compositionupdate.inputmask", function() {}).bind("compositionend.inputmask", compositionEndEvent),
|
|
|
|
|
- "paste" === PasteEventType && $el.bind("input.inputmask", inputFallBackEvent), patchValueProperty(el);
|
|
|
|
|
|
|
+ undoValue = getBuffer().join(""), compositionValidPos = $.extend(!0, {}, getMaskSet().validPositions);
|
|
|
|
|
+ }).bind("compositionend.inputmask", compositionEndEvent), "paste" === PasteEventType && $el.bind("input.inputmask", inputFallBackEvent),
|
|
|
|
|
+ patchValueProperty(el);
|
|
|
var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(el, el._valueGet(), opts) || el._valueGet() : el._valueGet();
|
|
var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(el, el._valueGet(), opts) || el._valueGet() : el._valueGet();
|
|
|
checkVal(el, !0, !1, initialValue.split(""));
|
|
checkVal(el, !0, !1, initialValue.split(""));
|
|
|
var buffer = getBuffer().slice();
|
|
var buffer = getBuffer().slice();
|
|
@@ -959,7 +970,7 @@
|
|
|
installEventRuler(el);
|
|
installEventRuler(el);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- var undoValue, $el, maxLength, isRTL = !1, skipKeyPressEvent = !1, skipInputEvent = !1, ignorable = !1, firstClick = !0;
|
|
|
|
|
|
|
+ var undoValue, compositionData, compositionValidPos, $el, maxLength, isRTL = !1, skipKeyPressEvent = !1, skipInputEvent = !1, ignorable = !1, firstClick = !0;
|
|
|
if (void 0 != actionObj) switch (actionObj.action) {
|
|
if (void 0 != actionObj) switch (actionObj.action) {
|
|
|
case "isComplete":
|
|
case "isComplete":
|
|
|
return $el = $(actionObj.el), maskset = $el.data("_inputmask").maskset, opts = $el.data("_inputmask").opts,
|
|
return $el = $(actionObj.el), maskset = $el.data("_inputmask").maskset, opts = $el.data("_inputmask").opts,
|