Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new event onIncompleteFocus #2248

Open
wants to merge 1 commit into
base: 5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions dist/inputmask.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
regex: null,
oncomplete: $.noop,
onincomplete: $.noop,
onincompleteFocus: $.noop,
oncleared: $.noop,
repeat: 0,
greedy: !1,
Expand Down Expand Up @@ -1277,7 +1278,7 @@
!0 === triggerEvents)) {
var $input = $(input), nptVal = input.inputmask._valueGet();
skipInputEvent = !0, $input.trigger("input"), setTimeout(function() {
nptVal === getBufferTemplate().join("") ? $input.trigger("cleared") : !0 === isComplete(buffer) && $input.trigger("complete");
nptVal === getBufferTemplate().join("") ? $input.trigger("cleared") : !0 === isComplete(buffer) ? $input.trigger("complete") : $input.trigger("incompleteFocus");
}, 0);
}
}
Expand Down Expand Up @@ -1870,8 +1871,8 @@
EventRuler.on(el, "click", EventHandlers.clickEvent), EventRuler.on(el, "mouseleave", EventHandlers.mouseleaveEvent),
EventRuler.on(el, "mouseenter", EventHandlers.mouseenterEvent), EventRuler.on(el, "paste", 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),
mobile || !0 === opts.inputEventOnly ? el.removeAttribute("maxLength") : (EventRuler.on(el, "keydown", EventHandlers.keydownEvent),
EventRuler.on(el, "incomplete", opts.onincomplete), EventRuler.on(el, "incompleteFocus", opts.onincompleteFocus),
EventRuler.on(el, "cleared", opts.oncleared), mobile || !0 === opts.inputEventOnly ? el.removeAttribute("maxLength") : (EventRuler.on(el, "keydown", EventHandlers.keydownEvent),
EventRuler.on(el, "keypress", EventHandlers.keypressEvent)), EventRuler.on(el, "input", EventHandlers.inputFallBackEvent),
EventRuler.on(el, "compositionend", EventHandlers.compositionendEvent)), EventRuler.on(el, "setvalue", EventHandlers.setValueEvent),
undoValue = getBufferTemplate().join(""), "" !== el.inputmask._valueGet(!0) || !1 === opts.clearMaskOnLostFocus || document.activeElement === el)) {
Expand Down Expand Up @@ -2275,7 +2276,7 @@
opts.greedy = !1, parseMinMaxOptions(opts), mask;
}
function hanndleRadixDance(pos, c, radixPos, maskset, opts) {
return opts._radixDance && opts.numericInput && c !== opts.negationSymbol.back && pos <= radixPos && (0 < radixPos || c == opts.radixPoint) && (void 0 === maskset.validPositions[pos - 1] || maskset.validPositions[pos - 1].input !== opts.negationSymbol.back) && (pos -= 1),
return opts._radixDance && opts.numericInput && c !== opts.negationSymbol.back && pos <= radixPos && (0 < radixPos || c == opts.radixPoint) && (void 0 === maskset.validPositions[pos - 1] || maskset.validPositions[pos - 1].input !== opts.negationSymbol.back) && --pos,
pos;
}
function decimalValidator(chrs, maskset, pos, strict, opts) {
Expand Down
2 changes: 1 addition & 1 deletion dist/inputmask.min.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions dist/jquery.inputmask.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
regex: null,
oncomplete: $.noop,
onincomplete: $.noop,
onincompleteFocus: $.noop,
oncleared: $.noop,
repeat: 0,
greedy: !1,
Expand Down Expand Up @@ -1152,7 +1153,7 @@
!0 === triggerEvents)) {
var $input = $(input), nptVal = input.inputmask._valueGet();
skipInputEvent = !0, $input.trigger("input"), setTimeout(function() {
nptVal === getBufferTemplate().join("") ? $input.trigger("cleared") : !0 === isComplete(buffer) && $input.trigger("complete");
nptVal === getBufferTemplate().join("") ? $input.trigger("cleared") : !0 === isComplete(buffer) ? $input.trigger("complete") : $input.trigger("incompleteFocus");
}, 0);
}
}
Expand Down Expand Up @@ -1745,8 +1746,8 @@
EventRuler.on(el, "click", EventHandlers.clickEvent), EventRuler.on(el, "mouseleave", EventHandlers.mouseleaveEvent),
EventRuler.on(el, "mouseenter", EventHandlers.mouseenterEvent), EventRuler.on(el, "paste", 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),
mobile || !0 === opts.inputEventOnly ? el.removeAttribute("maxLength") : (EventRuler.on(el, "keydown", EventHandlers.keydownEvent),
EventRuler.on(el, "incomplete", opts.onincomplete), EventRuler.on(el, "incompleteFocus", opts.onincompleteFocus),
EventRuler.on(el, "cleared", opts.oncleared), mobile || !0 === opts.inputEventOnly ? el.removeAttribute("maxLength") : (EventRuler.on(el, "keydown", EventHandlers.keydownEvent),
EventRuler.on(el, "keypress", EventHandlers.keypressEvent)), EventRuler.on(el, "input", EventHandlers.inputFallBackEvent),
EventRuler.on(el, "compositionend", EventHandlers.compositionendEvent)), EventRuler.on(el, "setvalue", EventHandlers.setValueEvent),
undoValue = getBufferTemplate().join(""), "" !== el.inputmask._valueGet(!0) || !1 === opts.clearMaskOnLostFocus || document.activeElement === el)) {
Expand Down Expand Up @@ -2150,7 +2151,7 @@
opts.greedy = !1, parseMinMaxOptions(opts), mask;
}
function hanndleRadixDance(pos, c, radixPos, maskset, opts) {
return opts._radixDance && opts.numericInput && c !== opts.negationSymbol.back && pos <= radixPos && (0 < radixPos || c == opts.radixPoint) && (void 0 === maskset.validPositions[pos - 1] || maskset.validPositions[pos - 1].input !== opts.negationSymbol.back) && (pos -= 1),
return opts._radixDance && opts.numericInput && c !== opts.negationSymbol.back && pos <= radixPos && (0 < radixPos || c == opts.radixPoint) && (void 0 === maskset.validPositions[pos - 1] || maskset.validPositions[pos - 1].input !== opts.negationSymbol.back) && --pos,
pos;
}
function decimalValidator(chrs, maskset, pos, strict, opts) {
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.inputmask.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/inputmask.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Inputmask.prototype = {
regex: null, //regular expression as a mask
oncomplete: $.noop, //executes when the mask is complete
onincomplete: $.noop, //executes when the mask is incomplete and focus is lost
onincompleteFocus: $.noop, //executes when the mask is incomplete
oncleared: $.noop, //executes when the mask is cleared
repeat: 0, //repetitions of the mask: * ~ forever, otherwise specify an integer
greedy: false, //true: allocated buffer for the mask and repetitions - false: allocate only if needed
Expand Down
3 changes: 3 additions & 0 deletions lib/maskScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,8 @@ module.exports = function maskScope(actionObj, maskset, opts) {
$input.trigger("cleared");
} else if (isComplete(buffer) === true) {
$input.trigger("complete");
} else {
$input.trigger("incompleteFocus");
}
}, 0);
}
Expand Down Expand Up @@ -2325,6 +2327,7 @@ module.exports = function maskScope(actionObj, maskset, opts) {
EventRuler.on(el, "cut", EventHandlers.cutEvent);
EventRuler.on(el, "complete", opts.oncomplete);
EventRuler.on(el, "incomplete", opts.onincomplete);
EventRuler.on(el, "incompleteFocus", opts.onincompleteFocus);
EventRuler.on(el, "cleared", opts.oncleared);
if (!mobile && opts.inputEventOnly !== true) {
EventRuler.on(el, "keydown", EventHandlers.keydownEvent);
Expand Down