浏览代码

Another showMaskOnHover and showMaskOnFocus problem #601

Robin Herbots 11 年之前
父节点
当前提交
8ab71dc21d

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "jquery.inputmask",
   "name": "jquery.inputmask",
-  "version": "3.0.60",
+  "version": "3.0.61",
   "main": "./dist/jquery.inputmask.bundle.js",
   "main": "./dist/jquery.inputmask.bundle.js",
   "keywords" : ["jQuery", "plugins", "input", "form", "inputmask", "mask"],
   "keywords" : ["jQuery", "plugins", "input", "form", "inputmask", "mask"],
   "description": "jquery.inputmask is a jquery plugin which create an input 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 = 3
 build.major = 3
 build.minor = 0
 build.minor = 0
-build.revision = 60
+build.revision = 61
 
 
 target = jquery.inputmask.bundle.js
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js
 target.min = jquery.inputmask.bundle.min.js

+ 24 - 16
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.60
+* Version: 3.0.61
 */
 */
 
 
 (function (factory) {
 (function (factory) {
@@ -448,8 +448,8 @@
             function getTests(pos, ndxIntlzr, tstPs) {
             function getTests(pos, ndxIntlzr, tstPs) {
                 var maskTokens = getMaskSet()["maskToken"], testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr || [0], matches = [], insertStop = false;
                 var maskTokens = getMaskSet()["maskToken"], testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr || [0], matches = [], insertStop = false;
                 function ResolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) { //ndxInitilizer contains a set of indexes to speedup searches in the mtokens
                 function ResolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) { //ndxInitilizer contains a set of indexes to speedup searches in the mtokens
-
                     function handleMatch(match, loopNdx, quantifierRecurse) {
                     function handleMatch(match, loopNdx, quantifierRecurse) {
+                        if (testPos > 10000) alert("jquery.inputmask: There is probably an error in your mask definition or in the code. Create an issue on github with an example of the mask you are using.");
                         if (testPos == pos && match.matches == undefined) {
                         if (testPos == pos && match.matches == undefined) {
                             matches.push({ "match": match, "locator": loopNdx.reverse() });
                             matches.push({ "match": match, "locator": loopNdx.reverse() });
                             return true;
                             return true;
@@ -1022,8 +1022,8 @@
                 }
                 }
                 function InstallNativeValueSetFallback(npt) {
                 function InstallNativeValueSetFallback(npt) {
                     $(npt).bind("mouseenter.inputmask", function (event) {
                     $(npt).bind("mouseenter.inputmask", function (event) {
-                        var $input = $(this), input = this;
-                        if (input._valueGet() != getBuffer().join('')) {
+                        var $input = $(this), input = this, value = input._valueGet();
+                        if (value != "" && value != getBuffer().join('')) {
                             $input.trigger("setvalue");
                             $input.trigger("setvalue");
                         }
                         }
                     });
                     });
@@ -1666,12 +1666,12 @@
                         definitionSymbol: "*"
                         definitionSymbol: "*"
                     },
                     },
                     'a': {
                     'a': {
-                        validator: "[A-Za-z\u0410-\u044F\u0401\u0451]",
+                        validator: "[A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
                         cardinality: 1,
                         cardinality: 1,
                         definitionSymbol: "*"
                         definitionSymbol: "*"
                     },
                     },
                     '*': {
                     '*': {
-                        validator: "[A-Za-z\u0410-\u044F\u0401\u04510-9]",
+                        validator: "[0-9A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
                         cardinality: 1
                         cardinality: 1
                     }
                     }
                 },
                 },
@@ -1812,7 +1812,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.60
+* Version: 3.0.61
 *
 *
 *  THIS IS A TEMPORARY HACK TO BE COMPATIBLE WITH MULTIPLE MASKS LIKE IN VERSION 2.X - WHEN THE ALTERNATOR SYNTAX IS IMPLEMENTED inputmask-multi WILL BE DELETED!!
 *  THIS IS A TEMPORARY HACK TO BE COMPATIBLE WITH MULTIPLE MASKS LIKE IN VERSION 2.X - WHEN THE ALTERNATOR SYNTAX IS IMPLEMENTED inputmask-multi WILL BE DELETED!!
 *
 *
@@ -2117,7 +2117,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.60
+Version: 3.0.61
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2131,12 +2131,12 @@ Optional extensions on the jquery.inputmask base
     //extra definitions
     //extra definitions
     $.extend($.inputmask.defaults.definitions, {
     $.extend($.inputmask.defaults.definitions, {
         'A': {
         'A': {
-            validator: "[A-Za-z]",
+            validator: "[A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
             cardinality: 1,
             cardinality: 1,
             casing: "upper" //auto uppercasing
             casing: "upper" //auto uppercasing
         },
         },
         '#': {
         '#': {
-            validator: "[A-Za-z\u0410-\u044F\u0401\u04510-9]",
+            validator: "[0-9A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
             cardinality: 1,
             cardinality: 1,
             casing: "upper"
             casing: "upper"
         }
         }
@@ -2231,7 +2231,7 @@ Optional extensions on the jquery.inputmask base
             },
             },
             definitions: {
             definitions: {
                 '*': {
                 '*': {
-                    validator: "[A-Za-z\u0410-\u044F\u0401\u04510-9!#$%&'*+/=?^_`{|}~\-]",
+                    validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~\-]",
                     cardinality: 1,
                     cardinality: 1,
                     casing: "lower"
                     casing: "lower"
                 }
                 }
@@ -2244,7 +2244,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.60
+Version: 3.0.61
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2738,7 +2738,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.60
+Version: 3.0.61
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2833,7 +2833,15 @@ Optional extensions on the jquery.inputmask base
                 return { pos: newPos, "refreshFromBuffer": needsRefresh };
                 return { pos: newPos, "refreshFromBuffer": needsRefresh };
             },
             },
             onKeyDown: function (e, buffer, caretPos, opts) {
             onKeyDown: function (e, buffer, caretPos, opts) {
-                if (opts.autoGroup && (e.keyCode == opts.keyCode.DELETE || e.keyCode == opts.keyCode.BACKSPACE)) {
+                if (e.keyCode == opts.keyCode.TAB && opts.placeholder.charAt(0) != "0") {
+                    var radixPosition = $.inArray(opts.radixPoint, buffer);
+                    if (radixPosition != -1 && isFinite(opts.digits)) {
+                        for (var i = 1; i <= opts.digits; i++) {
+                            if (buffer[radixPosition + i] == undefined || buffer[radixPosition + i] == opts.placeholder.charAt(0)) buffer[radixPosition + i] = "0";
+                        }
+                        return { "refreshFromBuffer": { start: ++radixPosition, end: radixPosition + opts.digits } };
+                    }
+                } else if (opts.autoGroup && (e.keyCode == opts.keyCode.DELETE || e.keyCode == opts.keyCode.BACKSPACE)) {
                     var rslt = opts.postFormat(buffer, caretPos - 1, true, opts);
                     var rslt = opts.postFormat(buffer, caretPos - 1, true, opts);
                     rslt.caret = rslt.pos + 1;
                     rslt.caret = rslt.pos + 1;
                     return rslt;
                     return rslt;
@@ -2988,7 +2996,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.60
+Version: 3.0.61
 
 
 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
@@ -3181,7 +3189,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.60
+Version: 3.0.61
 
 
 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

文件差异内容过多而无法显示
+ 103 - 101
dist/jquery.inputmask.bundle.min.js


+ 1 - 1
dist/min/jquery.inputmask-multi.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.60
+ Version: 3.0.61
 
 
   THIS IS A TEMPORARY HACK TO BE COMPATIBLE WITH MULTIPLE MASKS LIKE IN VERSION 2.X - WHEN THE ALTERNATOR SYNTAX IS IMPLEMENTED inputmask-multi WILL BE DELETED!!
   THIS IS A TEMPORARY HACK TO BE COMPATIBLE WITH MULTIPLE MASKS LIKE IN VERSION 2.X - WHEN THE ALTERNATOR SYNTAX IS IMPLEMENTED inputmask-multi WILL BE DELETED!!
 
 

文件差异内容过多而无法显示
+ 4 - 4
dist/min/jquery.inputmask.extensions.js


文件差异内容过多而无法显示
+ 41 - 41
dist/min/jquery.inputmask.js


文件差异内容过多而无法显示
+ 10 - 9
dist/min/jquery.inputmask.numeric.extensions.js


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 3 - 3
js/jquery.inputmask.js

@@ -448,8 +448,8 @@
             function getTests(pos, ndxIntlzr, tstPs) {
             function getTests(pos, ndxIntlzr, tstPs) {
                 var maskTokens = getMaskSet()["maskToken"], testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr || [0], matches = [], insertStop = false;
                 var maskTokens = getMaskSet()["maskToken"], testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr || [0], matches = [], insertStop = false;
                 function ResolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) { //ndxInitilizer contains a set of indexes to speedup searches in the mtokens
                 function ResolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) { //ndxInitilizer contains a set of indexes to speedup searches in the mtokens
-
                     function handleMatch(match, loopNdx, quantifierRecurse) {
                     function handleMatch(match, loopNdx, quantifierRecurse) {
+                        if (testPos > 10000) alert("jquery.inputmask: There is probably an error in your mask definition or in the code. Create an issue on github with an example of the mask you are using.");
                         if (testPos == pos && match.matches == undefined) {
                         if (testPos == pos && match.matches == undefined) {
                             matches.push({ "match": match, "locator": loopNdx.reverse() });
                             matches.push({ "match": match, "locator": loopNdx.reverse() });
                             return true;
                             return true;
@@ -1022,8 +1022,8 @@
                 }
                 }
                 function InstallNativeValueSetFallback(npt) {
                 function InstallNativeValueSetFallback(npt) {
                     $(npt).bind("mouseenter.inputmask", function (event) {
                     $(npt).bind("mouseenter.inputmask", function (event) {
-                        var $input = $(this), input = this;
-                        if (input._valueGet() != getBuffer().join('')) {
+                        var $input = $(this), input = this, value = input._valueGet();
+                        if (value != "" && value != getBuffer().join('')) {
                             $input.trigger("setvalue");
                             $input.trigger("setvalue");
                         }
                         }
                     });
                     });

+ 9 - 1
js/jquery.inputmask.numeric.extensions.js

@@ -98,7 +98,15 @@ Optional extensions on the jquery.inputmask base
                 return { pos: newPos, "refreshFromBuffer": needsRefresh };
                 return { pos: newPos, "refreshFromBuffer": needsRefresh };
             },
             },
             onKeyDown: function (e, buffer, caretPos, opts) {
             onKeyDown: function (e, buffer, caretPos, opts) {
-                if (opts.autoGroup && (e.keyCode == opts.keyCode.DELETE || e.keyCode == opts.keyCode.BACKSPACE)) {
+                if (e.keyCode == opts.keyCode.TAB && opts.placeholder.charAt(0) != "0") {
+                    var radixPosition = $.inArray(opts.radixPoint, buffer);
+                    if (radixPosition != -1 && isFinite(opts.digits)) {
+                        for (var i = 1; i <= opts.digits; i++) {
+                            if (buffer[radixPosition + i] == undefined || buffer[radixPosition + i] == opts.placeholder.charAt(0)) buffer[radixPosition + i] = "0";
+                        }
+                        return { "refreshFromBuffer": { start: ++radixPosition, end: radixPosition + opts.digits } };
+                    }
+                } else if (opts.autoGroup && (e.keyCode == opts.keyCode.DELETE || e.keyCode == opts.keyCode.BACKSPACE)) {
                     var rslt = opts.postFormat(buffer, caretPos - 1, true, opts);
                     var rslt = opts.postFormat(buffer, caretPos - 1, true, opts);
                     rslt.caret = rslt.pos + 1;
                     rslt.caret = rslt.pos + 1;
                     return rslt;
                     return rslt;

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "jquery.inputmask",
   "name": "jquery.inputmask",
-  "version": "3.0.60",
+  "version": "3.0.61",
   "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": "dist/jquery.inputmask.bundle.js",
   "main": "dist/jquery.inputmask.bundle.js",
   "scripts": {
   "scripts": {

+ 13 - 0
qunit/tests_numeric.js

@@ -671,4 +671,17 @@ test("decimal alias set value with val() - kochelmonster", function () {
 
 
     equal($("#testmask").val(), "39.399.392,22 €", "Result " + $("#testmask").val());
     equal($("#testmask").val(), "39.399.392,22 €", "Result " + $("#testmask").val());
     $("#testmask").remove();
     $("#testmask").remove();
+});
+
+test("inputmask(\"decimal\") - value=\"123.1\" tab out", function () {
+    var $fixture = $("#qunit-fixture");
+    $fixture.append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask("decimal", { digits: 3 });
+
+    $("#testmask")[0].focus();
+    $("#testmask").Type("123.1");
+    $("#testmask").SendKey(keyCodes.TAB);
+
+    equal($("#testmask").val(), "123.100", "Result " + $("#testmask").val());
+    $("#testmask").remove();
 });
 });