Robin Herbots 12 years ago
parent
commit
bef296a0e4

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
     "name": "jquery.inputmask",
-    "version": "2.4.20",
+    "version": "2.4.21",
     "main": "./dist/jquery.inputmask.bundle.js",
 	"keywords" : ["jQuery", "plugins", "input", "form", "inputmask", "mask"],
 	"description": "jquery.inputmask is a jquery plugin which create an input mask.",

+ 1 - 1
build.properties

@@ -7,7 +7,7 @@ distdir = dist
 
 build.major = 2
 build.minor = 4
-build.revision = 20
+build.revision = 21
 
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js

BIN
dist/jQuery.InputMask.2.4.20.nupkg


BIN
dist/jQuery.InputMask.2.4.21.nupkg


+ 47 - 22
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2014 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 2.4.20
+* Version: 2.4.21
 */
 
 (function ($) {
@@ -224,19 +224,25 @@
             return opts.greedy ? ms : ms.sort(function (a, b) { return a["mask"].length - b["mask"].length; });
         }
 
-        var msie10 = navigator.userAgent.match(new RegExp("msie 10", "i")) !== null,
+        var msie1x = new Function("/*@cc_on return @_jscript_version; @*/")() >= 10, //conditional compilation from mickeysoft trick
             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";
+            pasteEvent = isInputEventSupported('paste') ? 'paste' : isInputEventSupported('input') ? 'input' : "propertychange",
+            androidchrome32 = false;
 
+        if (androidchrome) {
+            var browser = navigator.userAgent.match(new RegExp("chrome.*", "i")),
+                version = parseInt(new RegExp(/[0-9]+/).exec(browser));
+            androidchrome32 = (version == 32);
+        }
 
         //masking scope
         //actionObj definition see below
         function maskScope(masksets, activeMasksetIndex, opts, actionObj) {
             var isRTL = false,
                 valueOnFocus = getActiveBuffer().join(''),
-                $el, chromeValueOnInput,
+                $el,
                 skipKeyPressEvent = false, //Safari 5.1.x - modal dialog fires keypress twice workaround
                 skipInputEvent = false, //skip when triggered from within inputmask
                 ignorable = false;
@@ -1133,11 +1139,6 @@
             function keyupEvent(e) {
                 var $input = $(this), input = this, k = e.keyCode, buffer = getActiveBuffer();
 
-                if (androidchrome && k == opts.keyCode.BACKSPACE) {
-                    if (chromeValueOnInput == input._valueGet())
-                        keydownEvent.call(this, e);
-                }
-
                 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) {
@@ -1163,7 +1164,6 @@
                 }
                 var input = this, $input = $(input);
 
-                chromeValueOnInput = getActiveBuffer().join('');
                 checkVal(input, false, false);
                 writeBuffer(input, getActiveBuffer());
                 if (isComplete(getActiveBuffer()) === true)
@@ -1171,6 +1171,31 @@
                 $input.click();
             }
 
+            function chrome32InputEvent(e) {
+                if (skipInputEvent === true) {
+                    skipInputEvent = false;
+                    return true;
+                }
+                var input = this, $input = $(input);
+
+                //backspace in chrome32 only fires input event - detect & treat
+                var caretPos = caret(input),
+                    currentValue = input._valueGet();
+                if (currentValue.charAt(caretPos.begin) != getActiveBuffer()[caretPos.begin] 
+              	  	&& currentValue.charAt(caretPos.begin + 1) != getActiveBuffer()[caretPos.begin] 
+                	&& !isMask(caretPos.begin)) {
+                    	e.keyCode = opts.keyCode.BACKSPACE;
+                    	keydownEvent.call(input, e);
+                } else { //nonnumerics don't fire keypress 
+                    checkVal(input, false, false);
+                    writeBuffer(input, getActiveBuffer());
+                    if (isComplete(getActiveBuffer()) === true)
+                        $input.trigger("complete");
+                    $input.click();
+                }
+                e.preventDefault()
+            }
+
             function mask(el) {
                 $el = $(el);
                 if ($el.is(":input")) {
@@ -1355,14 +1380,14 @@
                     ).bind('cleared.inputmask', opts.oncleared
                     ).bind("keyup.inputmask", keyupEvent);
 
-                    if (androidchrome) {
-                        $el.bind("input.inputmask", inputEvent);
-                    } else {
-                        $el.bind("keydown.inputmask", keydownEvent
-                        ).bind("keypress.inputmask", keypressEvent);
-                    }
+                    $el.bind("keydown.inputmask", keydownEvent
+                         ).bind("keypress.inputmask", keypressEvent
+                         ).bind("keyup.inputmask", keyupEvent);
 
-                    if (msie10)
+                    if (androidchrome32) {
+                        $el.bind("input.inputmask", chrome32InputEvent);
+                    }    
+                    if (msie1x)
                         $el.bind("input.inputmask", inputEvent);
 
                     //apply mask
@@ -1635,7 +1660,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.4.20
+Version: 2.4.21
 
 Optional extensions on the jquery.inputmask base
 */
@@ -1757,7 +1782,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.4.20
+Version: 2.4.21
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2245,7 +2270,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.4.20
+Version: 2.4.21
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2422,7 +2447,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.4.20
+Version: 2.4.21
 
 Regex extensions on the jquery.inputmask base
 Allows for using regular expressions as a mask
@@ -2592,7 +2617,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.4.20
+Version: 2.4.21
 
 Phone extension.
 When using this extension make sure you specify the correct url to get the masks

File diff suppressed because it is too large
+ 80 - 79
dist/jquery.inputmask.bundle.min.js


File diff suppressed because it is too large
+ 51 - 50
dist/min/jquery.inputmask.js


+ 1 - 1
jquery.inputmask.jquery.json

@@ -8,7 +8,7 @@
 		"inputmask",
 		"mask"
     ],
-    "version": "2.4.20",
+    "version": "2.4.21",
     "author": {
         "name": "Robin Herbots",
         "url": "http://github.com/RobinHerbots/jquery.inputmask"