Skip to content
This repository was archived by the owner on Dec 11, 2017. It is now read-only.
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
node_modules/
bower_components/
dist/
/.project
19 changes: 10 additions & 9 deletions dist/jquery.maskedinput.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
jQuery Masked Input Plugin
Copyright (c) 2007 - 2015 Josh Bush (digitalbush.com)
Copyright (c) 2007 - 2016 Josh Bush (digitalbush.com)
Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license)
Version: 1.4.1
*/
Expand All @@ -20,7 +20,7 @@
}, $.fn.extend({
caret: function(begin, end) {
var range;
if (0 !== this.length && !this.is(":hidden")) return "number" == typeof begin ? (end = "number" == typeof end ? end : begin,
if (0 !== this.length && !this.is(":hidden") && this.get(0) === document.activeElement) return "number" == typeof begin ? (end = "number" == typeof end ? end : begin,
this.each(function() {
this.setSelectionRange ? this.setSelectionRange(begin, end) : this.createTextRange && (range = this.createTextRange(),
range.collapse(!0), range.moveEnd("character", end), range.moveStart("character", begin),
Expand All @@ -37,7 +37,7 @@
},
mask: function(mask, settings) {
var input, defs, tests, partialPosition, firstNonMaskPos, lastRequiredNonMaskPos, len, oldVal;
if (!mask && this.length > 0) {
if ("object" == typeof mask && (mask = ""), !mask && this.length > 0) {
input = $(this[0]);
var fn = input.data($.mask.dataName);
return fn ? fn() : void 0;
Expand All @@ -47,7 +47,7 @@
placeholder: $.mask.placeholder,
completed: null
}, settings), defs = $.mask.definitions, tests = [], partialPosition = len = mask.length,
firstNonMaskPos = null, $.each(mask.split(""), function(i, c) {
firstNonMaskPos = null, mask = String(mask), $.each(mask.split(""), function(i, c) {
"?" == c ? (len--, partialPosition = i) : defs[c] ? (tests.push(new RegExp(defs[c])),
null === firstNonMaskPos && (firstNonMaskPos = tests.length - 1), partialPosition > i && (lastRequiredNonMaskPos = tests.length - 1)) : tests.push(null);
}), this.trigger("unmask").each(function() {
Expand All @@ -58,7 +58,7 @@
}
}
function getPlaceholder(i) {
return settings.placeholder.charAt(i < settings.placeholder.length ? i : 0);
return i < settings.placeholder.length ? settings.placeholder.charAt(i) : settings.placeholder.charAt(0);
}
function seekNext(pos) {
for (;++pos < len && !tests[pos]; ) ;
Expand All @@ -85,19 +85,20 @@
c = t;
}
}
function androidInputEvent() {
function androidInputEvent(e) {
var curVal = input.val(), pos = input.caret();
if (oldVal && oldVal.length && oldVal.length > curVal.length) {
for (checkVal(!0); pos.begin > 0 && !tests[pos.begin - 1]; ) pos.begin--;
if (0 === pos.begin) for (;pos.begin < firstNonMaskPos && !tests[pos.begin]; ) pos.begin++;
input.caret(pos.begin, pos.begin);
} else {
for (checkVal(!0); pos.begin < len && !tests[pos.begin]; ) pos.begin++;
input.caret(pos.begin, pos.begin);
var lastEnteredValue = (checkVal(!0), curVal.charAt(pos.begin));
pos.begin < len && (tests[pos.begin] ? tests[pos.begin].test(lastEnteredValue) && pos.begin++ : (pos.begin++,
tests[pos.begin].test(lastEnteredValue) && pos.begin++)), input.caret(pos.begin, pos.begin);
}
tryFireCompleted();
}
function blurEvent() {
function blurEvent(e) {
checkVal(), input.val() != focusText && input.change();
}
function keydownEvent(e) {
Expand Down
4 changes: 2 additions & 2 deletions dist/jquery.maskedinput.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/jquery.maskedinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ $.fn.extend({
lastRequiredNonMaskPos,
len,
oldVal;

if(typeof mask === 'object') mask = '';
if (!mask && this.length > 0) {
input = $(this[0]);
var fn = input.data($.mask.dataName)
Expand Down