|
|
@@ -3,7 +3,7 @@
|
|
|
* 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: 1.0.21
|
|
|
+* Version: 1.0.22a
|
|
|
*/
|
|
|
|
|
|
(function ($) {
|
|
|
@@ -63,6 +63,7 @@
|
|
|
|
|
|
$.fn.inputmask = function (fn, options) {
|
|
|
var opts = $.extend(true, {}, $.inputmask.defaults, options);
|
|
|
+ var pasteEvent = isInputEventSupported('paste') ? 'paste' : 'input';
|
|
|
|
|
|
var iphone = navigator.userAgent.match(/iphone/i) != null;
|
|
|
var android = navigator.userAgent.match(/android.*mobile safari.*/i) != null;
|
|
|
@@ -137,6 +138,8 @@
|
|
|
if (this.data('inputmask'))
|
|
|
return this.data('inputmask')['_buffer'].join('');
|
|
|
else return "";
|
|
|
+ case "hasMaskedValue": //check wheter the returned value is masked or not; currently only works reliable when using jquery.val fn to retrieve the value
|
|
|
+ return this.data('inputmask') ? !this.data('inputmask')['autoUnmask'] : false;
|
|
|
default:
|
|
|
//check if the fn is an alias
|
|
|
if (!resolveAlias(fn)) {
|
|
|
@@ -167,6 +170,18 @@
|
|
|
}
|
|
|
|
|
|
//helper functions
|
|
|
+ function isInputEventSupported(eventName) {
|
|
|
+ var el = document.createElement('input'),
|
|
|
+ eventName = 'on' + eventName,
|
|
|
+ isSupported = (eventName in el);
|
|
|
+ if (!isSupported) {
|
|
|
+ el.setAttribute(eventName, 'return;');
|
|
|
+ isSupported = typeof el[eventName] == 'function';
|
|
|
+ }
|
|
|
+ el = null;
|
|
|
+ return isSupported;
|
|
|
+ }
|
|
|
+
|
|
|
function resolveAlias(aliasStr) {
|
|
|
var aliasDefinition = opts.aliases[aliasStr];
|
|
|
if (aliasDefinition) {
|
|
|
@@ -636,7 +651,7 @@
|
|
|
}).bind("keydown.inputmask", keydownEvent
|
|
|
).bind("keypress.inputmask", keypressEvent
|
|
|
).bind("keyup.inputmask", keyupEvent
|
|
|
- ).bind("paste.inputmask", function () {
|
|
|
+ ).bind(pasteEvent + ".inputmask", function () {
|
|
|
var input = this;
|
|
|
setTimeout(function () {
|
|
|
caret(input, checkVal(input, buffer, true));
|
|
|
@@ -1002,4 +1017,4 @@
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
-})(jQuery);
|
|
|
+})(jQuery);
|