|
|
@@ -230,7 +230,7 @@
|
|
|
iphone = navigator.userAgent.match(new RegExp("iphone", "i")) !== null,
|
|
|
android = navigator.userAgent.match(new RegExp("android.*safari.*", "i")) !== null,
|
|
|
androidchrome = navigator.userAgent.match(new RegExp("android.*chrome.*", "i")) !== null,
|
|
|
- pasteEvent = isInputEventSupported('paste') ? 'paste' : isInputEventSupported('input') ? 'input' : "propertychange";
|
|
|
+ PasteEventType = isInputEventSupported('paste') ? 'paste' : isInputEventSupported('input') ? 'input' : "propertychange";
|
|
|
|
|
|
//if (androidchrome) {
|
|
|
// var browser = navigator.userAgent.match(new RegExp("chrome.*", "i")),
|
|
|
@@ -928,6 +928,8 @@
|
|
|
skipKeyPressEvent = false;
|
|
|
var input = this, $input = $(input), k = e.keyCode, pos = caret(input);
|
|
|
|
|
|
+ console.log("keydown " + k);
|
|
|
+
|
|
|
//backspace, delete, and escape get special treatment
|
|
|
if (k == opts.keyCode.BACKSPACE || k == opts.keyCode.DELETE || (iphone && k == 127) || e.ctrlKey && k == 88) { //backspace/delete
|
|
|
e.preventDefault(); //stop default action but allow propagation
|
|
|
@@ -985,6 +987,7 @@
|
|
|
|
|
|
e = e || window.event;
|
|
|
var k = checkval ? k : (e.which || e.charCode || e.keyCode);
|
|
|
+ if (!checkval) console.log("keypress " + k);
|
|
|
|
|
|
if (checkval !== true && (!(e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable))) {
|
|
|
return true;
|
|
|
@@ -1140,6 +1143,8 @@
|
|
|
function keyupEvent(e) {
|
|
|
var $input = $(this), input = this, k = e.keyCode, buffer = getActiveBuffer();
|
|
|
|
|
|
+ console.log("keyup " + k);
|
|
|
+
|
|
|
opts.onKeyUp.call(this, e, buffer, opts); //extra stuff to execute on keyup
|
|
|
if (k == opts.keyCode.TAB && opts.showMaskOnFocus) {
|
|
|
if ($input.hasClass('focus.inputmask') && input._valueGet().length == 0) {
|
|
|
@@ -1158,18 +1163,25 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- function inputEvent(e) {
|
|
|
+ function pasteEvent(e) {
|
|
|
if (skipInputEvent === true) {
|
|
|
skipInputEvent = false;
|
|
|
return true;
|
|
|
}
|
|
|
var input = this, $input = $(input);
|
|
|
|
|
|
- checkVal(input, false, false);
|
|
|
- writeBuffer(input, getActiveBuffer());
|
|
|
- if (isComplete(getActiveBuffer()) === true)
|
|
|
- $input.trigger("complete");
|
|
|
- $input.click();
|
|
|
+ //paste event for IE8 and lower I guess ;-)
|
|
|
+ if (e.type == "propertychange" && input._valueGet().length <= getMaskLength()) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ setTimeout(function () {
|
|
|
+ var pasteValue = opts.onBeforePaste != undefined ? opts.onBeforePaste.call(this, input._valueGet()) : input._valueGet();
|
|
|
+ console.log("paste " + pasteValue);
|
|
|
+ checkVal(input, true, false, pasteValue.split(''), true);
|
|
|
+ if (isComplete(getActiveBuffer()) === true)
|
|
|
+ $input.trigger("complete");
|
|
|
+ $input.click();
|
|
|
+ }, 0);
|
|
|
}
|
|
|
|
|
|
function chromeInputEvent(e) {
|
|
|
@@ -1182,6 +1194,9 @@
|
|
|
//backspace in chrome32 only fires input event - detect & treat
|
|
|
var caretPos = caret(input),
|
|
|
currentValue = input._valueGet();
|
|
|
+
|
|
|
+ console.log("input " + currentValue);
|
|
|
+
|
|
|
if (currentValue.charAt(caretPos.begin) != getActiveBuffer()[caretPos.begin]
|
|
|
&& currentValue.charAt(caretPos.begin + 1) != getActiveBuffer()[caretPos.begin]
|
|
|
&& !isMask(caretPos.begin)) {
|
|
|
@@ -1194,7 +1209,7 @@
|
|
|
$input.trigger("complete");
|
|
|
$input.click();
|
|
|
}
|
|
|
- e.preventDefault()
|
|
|
+ e.preventDefault();
|
|
|
}
|
|
|
|
|
|
function mask(el) {
|
|
|
@@ -1352,25 +1367,8 @@
|
|
|
setTimeout(function () {
|
|
|
caret(input, 0, seekNext(getActiveMaskSet()["lastValidPosition"]));
|
|
|
}, 0);
|
|
|
- }).bind(pasteEvent + ".inputmask dragdrop.inputmask drop.inputmask", function (e) {
|
|
|
- if (skipInputEvent === true) {
|
|
|
- skipInputEvent = false;
|
|
|
- return true;
|
|
|
- }
|
|
|
- var input = this, $input = $(input);
|
|
|
-
|
|
|
- //paste event for IE8 and lower I guess ;-)
|
|
|
- if (e.type == "propertychange" && input._valueGet().length <= getMaskLength()) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- setTimeout(function () {
|
|
|
- var pasteValue = opts.onBeforePaste != undefined ? opts.onBeforePaste.call(this, input._valueGet()) : input._valueGet();
|
|
|
- checkVal(input, true, false, pasteValue.split(''), true);
|
|
|
- if (isComplete(getActiveBuffer()) === true)
|
|
|
- $input.trigger("complete");
|
|
|
- $input.click();
|
|
|
- }, 0);
|
|
|
- }).bind('setvalue.inputmask', function () {
|
|
|
+ }).bind(PasteEventType + ".inputmask dragdrop.inputmask drop.inputmask", pasteEvent
|
|
|
+ ).bind('setvalue.inputmask', function () {
|
|
|
var input = this;
|
|
|
checkVal(input, true);
|
|
|
valueOnFocus = getActiveBuffer().join('');
|
|
|
@@ -1378,8 +1376,7 @@
|
|
|
input._valueSet('');
|
|
|
}).bind('complete.inputmask', opts.oncomplete
|
|
|
).bind('incomplete.inputmask', opts.onincomplete
|
|
|
- ).bind('cleared.inputmask', opts.oncleared
|
|
|
- ).bind("keyup.inputmask", keyupEvent);
|
|
|
+ ).bind('cleared.inputmask', opts.oncleared);
|
|
|
|
|
|
$el.bind("keydown.inputmask", keydownEvent
|
|
|
).bind("keypress.inputmask", keypressEvent
|
|
|
@@ -1389,7 +1386,7 @@
|
|
|
$el.bind("input.inputmask", chromeInputEvent);
|
|
|
}
|
|
|
if (msie1x)
|
|
|
- $el.bind("input.inputmask", inputEvent);
|
|
|
+ $el.bind("input.inputmask", pasteEvent);
|
|
|
|
|
|
//apply mask
|
|
|
var initialValue = opts.onBeforeMask != undefined ? opts.onBeforeMask.call(this, el._valueGet()) : el._valueGet();
|