Browse Source

Fix special latin charset for Chrome/Linux #192

Robin Herbots 11 years ago
parent
commit
7e21d8049a

+ 1 - 1
bower.json

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

+ 1 - 1
build.properties

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

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


+ 36 - 13
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2014 Robin Herbots
 * Copyright (c) 2010 - 2014 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.0.65
+* Version: 3.0.66
 */
 */
 
 
 (function (factory) {
 (function (factory) {
@@ -1380,17 +1380,37 @@
                 }
                 }
                 e.preventDefault();
                 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 () {
                 setTimeout(function () {
-                    caret(that, caret(that).begin - 1);
+                    caret(input, caret(input).begin - 1);
                     var keypress = $.Event("keypress");
                     var keypress = $.Event("keypress");
                     keypress.which = e.originalEvent.data.charCodeAt(0);
                     keypress.which = e.originalEvent.data.charCodeAt(0);
                     skipKeyPressEvent = false;
                     skipKeyPressEvent = false;
-                     ignorable = false;
-                    keypressEvent.call(that, keypress, undefined, undefined, false);
+                    ignorable = false;
+                    keypressEvent.call(input, keypress, undefined, undefined, false);
                     var forwardPosition = getMaskSet()["p"];
                     var forwardPosition = getMaskSet()["p"];
-                    writeBuffer(that, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
+                    writeBuffer(input, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
                 }, 0);
                 }, 0);
                 return false;
                 return false;
             }
             }
@@ -1528,7 +1548,10 @@
                     ).bind("keypress.inputmask", keypressEvent
                     ).bind("keypress.inputmask", keypressEvent
                     ).bind("keyup.inputmask", keyupEvent
                     ).bind("keyup.inputmask", keyupEvent
                     ).bind("compositionupdate.inputmask", compositionupdateEvent);
                     ).bind("compositionupdate.inputmask", compositionupdateEvent);
-
+                    
+                    if (PasteEventType === "paste") {
+                     	$el.bind("input.inputmask", inputFallBackEvent);
+                    }
                     if (android || androidfirefox || androidchrome || kindle) {
                     if (android || androidfirefox || androidchrome || kindle) {
                         if (PasteEventType == "input") {
                         if (PasteEventType == "input") {
                             $el.unbind(PasteEventType + ".inputmask");
                             $el.unbind(PasteEventType + ".inputmask");
@@ -1863,7 +1886,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 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
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -1990,7 +2013,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 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
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2484,7 +2507,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 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
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2743,7 +2766,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 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
 Regex extensions on the jquery.inputmask base
 Allows for using regular expressions as a mask
 Allows for using regular expressions as a mask
@@ -2936,7 +2959,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.65
+Version: 3.0.66
 
 
 Phone extension.
 Phone extension.
 When using this extension make sure you specify the correct url to get the masks
 When using this extension make sure you specify the correct url to get the masks

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


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 30 - 7
js/jquery.inputmask.js

@@ -1380,17 +1380,37 @@
                 }
                 }
                 e.preventDefault();
                 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 () {
                 setTimeout(function () {
-                    caret(that, caret(that).begin - 1);
+                    caret(input, caret(input).begin - 1);
                     var keypress = $.Event("keypress");
                     var keypress = $.Event("keypress");
                     keypress.which = e.originalEvent.data.charCodeAt(0);
                     keypress.which = e.originalEvent.data.charCodeAt(0);
                     skipKeyPressEvent = false;
                     skipKeyPressEvent = false;
-                     ignorable = false;
-                    keypressEvent.call(that, keypress, undefined, undefined, false);
+                    ignorable = false;
+                    keypressEvent.call(input, keypress, undefined, undefined, false);
                     var forwardPosition = getMaskSet()["p"];
                     var forwardPosition = getMaskSet()["p"];
-                    writeBuffer(that, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
+                    writeBuffer(input, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
                 }, 0);
                 }, 0);
                 return false;
                 return false;
             }
             }
@@ -1528,7 +1548,10 @@
                     ).bind("keypress.inputmask", keypressEvent
                     ).bind("keypress.inputmask", keypressEvent
                     ).bind("keyup.inputmask", keyupEvent
                     ).bind("keyup.inputmask", keyupEvent
                     ).bind("compositionupdate.inputmask", compositionupdateEvent);
                     ).bind("compositionupdate.inputmask", compositionupdateEvent);
-
+                    
+                    if (PasteEventType === "paste") {
+                     	$el.bind("input.inputmask", inputFallBackEvent);
+                    }
                     if (android || androidfirefox || androidchrome || kindle) {
                     if (android || androidfirefox || androidchrome || kindle) {
                         if (PasteEventType == "input") {
                         if (PasteEventType == "input") {
                             $el.unbind(PasteEventType + ".inputmask");
                             $el.unbind(PasteEventType + ".inputmask");

+ 1 - 1
package.json

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