|
|
@@ -3,7 +3,7 @@
|
|
|
* http://github.com/RobinHerbots/jquery.inputmask
|
|
|
* Copyright (c) 2010 - 2013 Robin Herbots
|
|
|
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
|
-* Version: 2.1.13
|
|
|
+* Version: 2.1.15
|
|
|
*/
|
|
|
|
|
|
(function ($) {
|
|
|
@@ -80,16 +80,15 @@
|
|
|
var iphone = navigator.userAgent.match(/iphone/i) != null;
|
|
|
var android = navigator.userAgent.match(/android.*safari.*/i) != null,
|
|
|
android534;
|
|
|
- if (android) {
|
|
|
- var browser = navigator.userAgent.match(/safari.*/i);
|
|
|
- var version = parseInt(new RegExp(/[0-9]+/).exec(browser));
|
|
|
- android = (version <= 533);
|
|
|
- android534 = (533 < version <= 534);
|
|
|
- }
|
|
|
- var caretposCorrection = null;
|
|
|
+ //if (android) {
|
|
|
+ // var browser = navigator.userAgent.match(/safari.*/i);
|
|
|
+ // var version = parseInt(new RegExp(/[0-9]+/).exec(browser));
|
|
|
+ // android = (version <= 533);
|
|
|
+ // android534 = (533 < version) && (version <= 534);
|
|
|
+ //}
|
|
|
+
|
|
|
var masksets,
|
|
|
activeMasksetIndex = 0;
|
|
|
-
|
|
|
if (typeof fn == "string") {
|
|
|
switch (fn) {
|
|
|
case "mask":
|
|
|
@@ -524,12 +523,7 @@
|
|
|
function writeBuffer(input, buffer, caretPos) {
|
|
|
input._valueSet(buffer.join(''));
|
|
|
if (caretPos != undefined) {
|
|
|
- if (android) {
|
|
|
- setTimeout(function () {
|
|
|
- caret(input, caretPos);
|
|
|
- }, 100);
|
|
|
- }
|
|
|
- else caret(input, caretPos);
|
|
|
+ caret(input, caretPos);
|
|
|
}
|
|
|
};
|
|
|
function clearBuffer(buffer, start, end) {
|
|
|
@@ -656,55 +650,49 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- function caret(input, begin, end) {
|
|
|
- var npt = input.jquery && input.length > 0 ? input[0] : input;
|
|
|
+ function caret(input, begin, end) {
|
|
|
+ var npt = input.jquery && input.length > 0 ? input[0] : input, rabge;
|
|
|
if (typeof begin == 'number') {
|
|
|
- if (!$(input).is(':visible')) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ if (!$(input).is(':visible')) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
end = (typeof end == 'number') ? end : begin;
|
|
|
if (opts.insertMode == false && begin == end) end++; //set visualization for insert/overwrite mode
|
|
|
if (npt.setSelectionRange) {
|
|
|
- if (end == begin) {
|
|
|
- npt.focus();
|
|
|
- npt.setSelectionRange(begin, end);
|
|
|
- } else {
|
|
|
- npt.select();
|
|
|
- npt.selectionStart = begin;
|
|
|
- npt.selectionEnd = android534 ? begin : end;
|
|
|
- }
|
|
|
+ if (android)
|
|
|
+ setTimeout(function () {
|
|
|
+ npt.selectionStart = begin;
|
|
|
+ npt.selectionEnd = end;
|
|
|
+ }, 0);
|
|
|
+ else {
|
|
|
+ npt.selectionStart = begin;
|
|
|
+ npt.selectionEnd = end;
|
|
|
+ }
|
|
|
} else if (npt.createTextRange) {
|
|
|
- var range = npt.createTextRange();
|
|
|
+ range = npt.createTextRange();
|
|
|
range.collapse(true);
|
|
|
range.moveEnd('character', end);
|
|
|
range.moveStart('character', begin);
|
|
|
range.select();
|
|
|
}
|
|
|
- npt.focus();
|
|
|
- if (android && end != npt.selectionEnd) caretposCorrection = { begin: begin, end: end };
|
|
|
} else {
|
|
|
- if (!$(input).is(':visible')) {
|
|
|
- return { begin: 0, end: 0 };
|
|
|
- }
|
|
|
- var caretpos = android ? caretposCorrection : null, caretposCorrection = null;
|
|
|
- if (caretpos == null) {
|
|
|
- if (npt.setSelectionRange) {
|
|
|
- begin = npt.selectionStart;
|
|
|
- end = npt.selectionEnd;
|
|
|
- } else if (document.selection && document.selection.createRange) {
|
|
|
- var range = document.selection.createRange();
|
|
|
- begin = 0 - range.duplicate().moveStart('character', -100000);
|
|
|
- end = begin + range.text.length;
|
|
|
- }
|
|
|
- caretpos = { begin: begin, end: end };
|
|
|
+ if (!$(input).is(':visible')) {
|
|
|
+ return { begin: 0, end: 0 };
|
|
|
}
|
|
|
- return caretpos;
|
|
|
+ if (npt.setSelectionRange) {
|
|
|
+ begin = npt.selectionStart;
|
|
|
+ end = npt.selectionEnd;
|
|
|
+ } else if (document.selection && document.selection.createRange) {
|
|
|
+ range = document.selection.createRange();
|
|
|
+ begin = 0 - range.duplicate().moveStart('character', -100000);
|
|
|
+ end = begin + range.text.length;
|
|
|
+ }
|
|
|
+ return { begin: begin, end: end };
|
|
|
}
|
|
|
};
|
|
|
|
|
|
function isComplete(buffer) {
|
|
|
- var complete = false;
|
|
|
- currentActiveMasksetIndex = activeMasksetIndex, highestValidPosition = 0;
|
|
|
+ var complete = false, highestValidPosition = 0, currentActiveMasksetIndex = activeMasksetIndex;
|
|
|
$.each(masksets, function (ndx, ms) {
|
|
|
activeMasksetIndex = ndx;
|
|
|
var aml = getMaskLength(buffer);
|
|
|
@@ -1213,7 +1201,7 @@
|
|
|
$input.trigger("complete");
|
|
|
}, 0);
|
|
|
}
|
|
|
- } else if (android) writeBuffer(input, buffer, pos.begin);
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
var p = seekNext(buffer, pos.begin - 1), np;
|
|
|
@@ -1246,7 +1234,7 @@
|
|
|
$input.trigger("complete");
|
|
|
}, 0);
|
|
|
}
|
|
|
- } else if (android) writeBuffer(input, buffer, pos.begin);
|
|
|
+ }
|
|
|
}
|
|
|
e.preventDefault();
|
|
|
}
|
|
|
@@ -1275,7 +1263,7 @@ Input Mask plugin extensions
|
|
|
http://github.com/RobinHerbots/jquery.inputmask
|
|
|
Copyright (c) 2010 - 2013 Robin Herbots
|
|
|
Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
|
-Version: 2.1.13
|
|
|
+Version: 2.1.15
|
|
|
|
|
|
Optional extensions on the jquery.inputmask base
|
|
|
*/
|
|
|
@@ -1372,7 +1360,7 @@ Input Mask plugin extensions
|
|
|
http://github.com/RobinHerbots/jquery.inputmask
|
|
|
Copyright (c) 2010 - 2012 Robin Herbots
|
|
|
Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
|
-Version: 2.1.13
|
|
|
+Version: 2.1.15
|
|
|
|
|
|
Optional extensions on the jquery.inputmask base
|
|
|
*/
|
|
|
@@ -1865,7 +1853,7 @@ Input Mask plugin extensions
|
|
|
http://github.com/RobinHerbots/jquery.inputmask
|
|
|
Copyright (c) 2010 - 2013 Robin Herbots
|
|
|
Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
|
-Version: 2.1.13
|
|
|
+Version: 2.1.15
|
|
|
|
|
|
Optional extensions on the jquery.inputmask base
|
|
|
*/
|