ソースを参照

improve support for android 4.x

Robin Herbots 12 年 前
コミット
f154ae3d28

+ 1 - 1
build.properties

@@ -7,7 +7,7 @@ distdir = dist
 
 build.major = 1
 build.minor = 3
-build.revision = 11
+build.revision = 12
 
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js

+ 20 - 11
dist/jquery.inputmask.bundle.js

@@ -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: 1.3.11
+* Version: 1.3.12
 */
 
 (function ($) {
@@ -77,12 +77,14 @@
             var pasteEvent = isInputEventSupported('paste') ? 'paste' : 'input';
 
             var iphone = navigator.userAgent.match(/iphone/i) != null;
-            var android = navigator.userAgent.match(/android.*mobile safari.*/i) != null;
-            //if (android) {
-            //    var browser = navigator.userAgent.match(/mobile safari.*/i);
-            //    var version = parseInt(new RegExp(/[0-9]+/).exec(browser));
-            //    android = version <= 533;
-            //}
+            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 (typeof fn == "string") {
@@ -544,7 +546,14 @@
                     end = (typeof end == 'number') ? end : begin;
                     if (opts.insertMode == false && begin == end) end++; //set visualization for insert/overwrite mode
                     if (npt.setSelectionRange) {
-                        npt.setSelectionRange(begin, end);
+                        if (end == begin) {
+                       		npt.focus();
+                        	npt.setSelectionRange(begin, end);
+                    	} else {
+                        	npt.select();
+                        	npt.selectionStart = begin;
+                        	npt.selectionEnd = android534 ? begin : end;
+                    	}
                     } else if (npt.createTextRange) {
                         var range = npt.createTextRange();
                         range.collapse(true);
@@ -1118,7 +1127,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: 1.3.11
+Version: 1.3.12
 
 Optional extensions on the jquery.inputmask base
 */
@@ -1215,7 +1224,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: 1.3.11
+Version: 1.3.12
 
 Optional extensions on the jquery.inputmask base
 */
@@ -1708,7 +1717,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: 1.3.11
+Version: 1.3.12
 
 Optional extensions on the jquery.inputmask base
 */

ファイルの差分が大きいため隠しています
+ 28 - 27
dist/jquery.inputmask.bundle.min.js


ファイルの差分が大きいため隠しています
+ 33 - 32
dist/min/jquery.inputmask.js


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 16 - 7
js/jquery.inputmask.js

@@ -77,12 +77,14 @@
             var pasteEvent = isInputEventSupported('paste') ? 'paste' : 'input';
 
             var iphone = navigator.userAgent.match(/iphone/i) != null;
-            var android = navigator.userAgent.match(/android.*mobile safari.*/i) != null;
-            //if (android) {
-            //    var browser = navigator.userAgent.match(/mobile safari.*/i);
-            //    var version = parseInt(new RegExp(/[0-9]+/).exec(browser));
-            //    android = version <= 533;
-            //}
+            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 (typeof fn == "string") {
@@ -544,7 +546,14 @@
                     end = (typeof end == 'number') ? end : begin;
                     if (opts.insertMode == false && begin == end) end++; //set visualization for insert/overwrite mode
                     if (npt.setSelectionRange) {
-                        npt.setSelectionRange(begin, end);
+                        if (end == begin) {
+                       		npt.focus();
+                        	npt.setSelectionRange(begin, end);
+                    	} else {
+                        	npt.select();
+                        	npt.selectionStart = begin;
+                        	npt.selectionEnd = android534 ? begin : end;
+                    	}
                     } else if (npt.createTextRange) {
                         var range = npt.createTextRange();
                         range.collapse(true);