ソースを参照

Fix special latin charset for Chrome/Linux #192

Robin Herbots 11 年 前
コミット
7e21d8049a

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.0.65",
+  "version": "3.0.66",
   "main": [
     "./dist/inputmask/jquery.inputmask.js",
     "./dist/inputmask/jquery.inputmask.extensions.js",

+ 1 - 1
build.properties

@@ -7,7 +7,7 @@ distdir = dist
 
 build.major = 3
 build.minor = 0
-build.revision = 65
+build.revision = 66
 
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js

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


+ 36 - 13
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: 3.0.65
+* Version: 3.0.66
 */
 
 (function (factory) {
@@ -1380,17 +1380,37 @@
                 }
                 e.preventDefault();
             }
-            function compositionupdateEvent(e) {
-                var that = this;
+            function inputFallBackEvent(e) { //fallback when keypress & compositionevents fail
+             	if (skipInputEvent === true && e.type == "input") {
+                    skipInputEvent = false;
+                    return true;
+                }
+                var input = this;
+                var caretPos = caret(input),
+                    currentValue = input._valueGet();
+                
+                caret(input, caretPos.begin - 1);
+                var keypress = $.Event("keypress");
+                keypress.which = currentValue.charCodeAt(caretPos.begin - 1);
+                skipKeyPressEvent = false;
+                ignorable = false;
+                keypressEvent.call(input, keypress, undefined, undefined, false);
+                var forwardPosition = getMaskSet()["p"];
+                writeBuffer(input, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
+               
+                e.preventDefault();
+            }
+            function compositionupdateEvent(e) { //fix for special latin-charset FF/Linux
+                var input = this;
                 setTimeout(function () {
-                    caret(that, caret(that).begin - 1);
+                    caret(input, caret(input).begin - 1);
                     var keypress = $.Event("keypress");
                     keypress.which = e.originalEvent.data.charCodeAt(0);
                     skipKeyPressEvent = false;
-                     ignorable = false;
-                    keypressEvent.call(that, keypress, undefined, undefined, false);
+                    ignorable = false;
+                    keypressEvent.call(input, keypress, undefined, undefined, false);
                     var forwardPosition = getMaskSet()["p"];
-                    writeBuffer(that, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
+                    writeBuffer(input, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
                 }, 0);
                 return false;
             }
@@ -1528,7 +1548,10 @@
                     ).bind("keypress.inputmask", keypressEvent
                     ).bind("keyup.inputmask", keyupEvent
                     ).bind("compositionupdate.inputmask", compositionupdateEvent);
-
+                    
+                    if (PasteEventType === "paste") {
+                     	$el.bind("input.inputmask", inputFallBackEvent);
+                    }
                     if (android || androidfirefox || androidchrome || kindle) {
                         if (PasteEventType == "input") {
                             $el.unbind(PasteEventType + ".inputmask");
@@ -1863,7 +1886,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: 3.0.65
+Version: 3.0.66
 
 Optional extensions on the jquery.inputmask base
 */
@@ -1990,7 +2013,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: 3.0.65
+Version: 3.0.66
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2484,7 +2507,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: 3.0.65
+Version: 3.0.66
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2743,7 +2766,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: 3.0.65
+Version: 3.0.66
 
 Regex extensions on the jquery.inputmask base
 Allows for using regular expressions as a mask
@@ -2936,7 +2959,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: 3.0.65
+Version: 3.0.66
 
 Phone extension.
 When using this extension make sure you specify the correct url to get the masks

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


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 30 - 7
js/jquery.inputmask.js

@@ -1380,17 +1380,37 @@
                 }
                 e.preventDefault();
             }
-            function compositionupdateEvent(e) {
-                var that = this;
+            function inputFallBackEvent(e) { //fallback when keypress & compositionevents fail
+             	if (skipInputEvent === true && e.type == "input") {
+                    skipInputEvent = false;
+                    return true;
+                }
+                var input = this;
+                var caretPos = caret(input),
+                    currentValue = input._valueGet();
+                
+                caret(input, caretPos.begin - 1);
+                var keypress = $.Event("keypress");
+                keypress.which = currentValue.charCodeAt(caretPos.begin - 1);
+                skipKeyPressEvent = false;
+                ignorable = false;
+                keypressEvent.call(input, keypress, undefined, undefined, false);
+                var forwardPosition = getMaskSet()["p"];
+                writeBuffer(input, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
+               
+                e.preventDefault();
+            }
+            function compositionupdateEvent(e) { //fix for special latin-charset FF/Linux
+                var input = this;
                 setTimeout(function () {
-                    caret(that, caret(that).begin - 1);
+                    caret(input, caret(input).begin - 1);
                     var keypress = $.Event("keypress");
                     keypress.which = e.originalEvent.data.charCodeAt(0);
                     skipKeyPressEvent = false;
-                     ignorable = false;
-                    keypressEvent.call(that, keypress, undefined, undefined, false);
+                    ignorable = false;
+                    keypressEvent.call(input, keypress, undefined, undefined, false);
                     var forwardPosition = getMaskSet()["p"];
-                    writeBuffer(that, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
+                    writeBuffer(input, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
                 }, 0);
                 return false;
             }
@@ -1528,7 +1548,10 @@
                     ).bind("keypress.inputmask", keypressEvent
                     ).bind("keyup.inputmask", keyupEvent
                     ).bind("compositionupdate.inputmask", compositionupdateEvent);
-
+                    
+                    if (PasteEventType === "paste") {
+                     	$el.bind("input.inputmask", inputFallBackEvent);
+                    }
                     if (android || androidfirefox || androidchrome || kindle) {
                         if (PasteEventType == "input") {
                             $el.unbind(PasteEventType + ".inputmask");

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.0.65",
+  "version": "3.0.66",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "main": [
     "./dist/inputmask/jquery.inputmask.js",