浏览代码

selection and insert fixes

Robin Herbots 11 年之前
父节点
当前提交
4bd925d838

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
     "name": "jquery.inputmask",
-    "version": "3.0.21",
+    "version": "3.0.22",
     "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 = 3
 build.minor = 0
-build.revision = 21
+build.revision = 22
 
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js

二进制
dist/jQuery.InputMask.3.0.21.nupkg


二进制
dist/jQuery.InputMask.3.0.22.nupkg


+ 29 - 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: 3.0.21
+* Version: 3.0.22
 */
 
 (function ($) {
@@ -249,6 +249,8 @@
                 maxLength;
 
             //maskset helperfunctions
+
+
             function getMaskTemplate(baseOnInput, minimalPos, includeInput) {
                 minimalPos = minimalPos || 0;
                 var maskTemplate = [], ndxIntlzr, pos = 0, test, testPos;
@@ -312,20 +314,15 @@
                     }
                     getMaskSet()["validPositions"][pos] = validTest;
                     var valid = true;
-                    for (i = pos; i <= lvp ;) {
-                        var j = seekNext(i);
-                        if (i == j) valid = false;
+                    for (i = pos; i <= lvp ; i++) {
                         var t = positionsClone[i];
                         if (t != undefined) {
-                            var nextTest = getTest(j);
-                            if (nextTest.fn == null && nextTest.def == "")
-                                valid = false;
-                            else if (t["match"].fn == null || t["match"].def == nextTest.def) {
+                            var j = t["match"].fn == null ? i + 1 : seekNext(i);
+                            if (positionCanMatchDefinition(j, t["match"].def)) {
                                 valid = valid && isValid(j, t["input"], true, true) !== false;
-                            }
+                            } else valid = false;
                         }
                         if (!valid) break;
-                        i = j;
                     }
 
                     if (!valid) {
@@ -339,22 +336,23 @@
             }
 
             function stripValidPositions(start, end) {
-                var i, ml, startPos = seekNext(start - 1), lvp;
+                var i, startPos = start, lvp;
                 for (i = start; i < end; i++) { //clear selection
                     delete getMaskSet()["validPositions"][i];
                 }
 
-                for (i = seekNext(end - 1) ; i <= getLastValidPosition() ; i = seekNext(i)) {
+                for (i = end ; i <= getLastValidPosition() ;) {
                     var t = getMaskSet()["validPositions"][i];
                     var s = getMaskSet()["validPositions"][startPos];
                     if (t != undefined && s == undefined) {
-                        if (getTest(startPos).def == t.match.def && isValid(startPos, t["input"], true) !== false) {
+                        if (positionCanMatchDefinition(startPos, t.match.def) && isValid(startPos, t["input"], true) !== false) {
                             delete getMaskSet()["validPositions"][i];
+                            i++;
                         }
-                        startPos = seekNext(startPos);
-                    }
+                        startPos++;
+                    } else i++;
                 }
-                var lvp = getLastValidPosition();
+                lvp = getLastValidPosition();
                 //catchup
                 while (lvp > 0 && (getMaskSet()["validPositions"][lvp] == undefined || getMaskSet()["validPositions"][lvp].match.fn == null)) {
                     delete getMaskSet()["validPositions"][lvp];
@@ -380,7 +378,16 @@
                 }
                 return getTests(pos)[0]["match"];
             }
-
+            function positionCanMatchDefinition(pos, def) {
+                var valid = false, tests = getTests(pos);
+                for (var tndx in tests) {
+                    if (tests[tndx]["match"].def == def) {
+                        valid = true;
+                        break;
+                    }
+                }
+                return valid;
+            };
             function getTests(pos, ndxIntlzr, tstPs) {
                 var maskTokens = getMaskSet()["maskToken"], testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr || [0], matches = [], insertStop = false;
 
@@ -1845,7 +1852,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.21
+Version: 3.0.22
 
 Optional extensions on the jquery.inputmask base
 */
@@ -1955,7 +1962,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.21
+Version: 3.0.22
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2418,7 +2425,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.21
+Version: 3.0.22
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2572,7 +2579,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.21
+Version: 3.0.22
 
 Regex extensions on the jquery.inputmask base
 Allows for using regular expressions as a mask
@@ -2759,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.21
+Version: 3.0.22
 
 Phone extension.
 When using this extension make sure you specify the correct url to get the masks

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


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


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 23 - 16
js/jquery.inputmask.js

@@ -249,6 +249,8 @@
                 maxLength;
 
             //maskset helperfunctions
+
+
             function getMaskTemplate(baseOnInput, minimalPos, includeInput) {
                 minimalPos = minimalPos || 0;
                 var maskTemplate = [], ndxIntlzr, pos = 0, test, testPos;
@@ -312,20 +314,15 @@
                     }
                     getMaskSet()["validPositions"][pos] = validTest;
                     var valid = true;
-                    for (i = pos; i <= lvp ;) {
-                        var j = seekNext(i);
-                        if (i == j) valid = false;
+                    for (i = pos; i <= lvp ; i++) {
                         var t = positionsClone[i];
                         if (t != undefined) {
-                            var nextTest = getTest(j);
-                            if (nextTest.fn == null && nextTest.def == "")
-                                valid = false;
-                            else if (t["match"].fn == null || t["match"].def == nextTest.def) {
+                            var j = t["match"].fn == null ? i + 1 : seekNext(i);
+                            if (positionCanMatchDefinition(j, t["match"].def)) {
                                 valid = valid && isValid(j, t["input"], true, true) !== false;
-                            }
+                            } else valid = false;
                         }
                         if (!valid) break;
-                        i = j;
                     }
 
                     if (!valid) {
@@ -339,22 +336,23 @@
             }
 
             function stripValidPositions(start, end) {
-                var i, ml, startPos = seekNext(start - 1), lvp;
+                var i, startPos = start, lvp;
                 for (i = start; i < end; i++) { //clear selection
                     delete getMaskSet()["validPositions"][i];
                 }
 
-                for (i = seekNext(end - 1) ; i <= getLastValidPosition() ; i = seekNext(i)) {
+                for (i = end ; i <= getLastValidPosition() ;) {
                     var t = getMaskSet()["validPositions"][i];
                     var s = getMaskSet()["validPositions"][startPos];
                     if (t != undefined && s == undefined) {
-                        if (getTest(startPos).def == t.match.def && isValid(startPos, t["input"], true) !== false) {
+                        if (positionCanMatchDefinition(startPos, t.match.def) && isValid(startPos, t["input"], true) !== false) {
                             delete getMaskSet()["validPositions"][i];
+                            i++;
                         }
-                        startPos = seekNext(startPos);
-                    }
+                        startPos++;
+                    } else i++;
                 }
-                var lvp = getLastValidPosition();
+                lvp = getLastValidPosition();
                 //catchup
                 while (lvp > 0 && (getMaskSet()["validPositions"][lvp] == undefined || getMaskSet()["validPositions"][lvp].match.fn == null)) {
                     delete getMaskSet()["validPositions"][lvp];
@@ -380,7 +378,16 @@
                 }
                 return getTests(pos)[0]["match"];
             }
-
+            function positionCanMatchDefinition(pos, def) {
+                var valid = false, tests = getTests(pos);
+                for (var tndx in tests) {
+                    if (tests[tndx]["match"].def == def) {
+                        valid = true;
+                        break;
+                    }
+                }
+                return valid;
+            };
             function getTests(pos, ndxIntlzr, tstPs) {
                 var maskTokens = getMaskSet()["maskToken"], testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr || [0], matches = [], insertStop = false;
 

+ 1 - 0
qunit/tests.js

@@ -1299,6 +1299,7 @@ test("inputmask(\"decimal\", { autoGroup: false, groupSeparator: \",\" }\") - in
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
+    $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").Type(".789");
 
     equal($("#testmask").val(), "12345.789", "Result " + $("#testmask").val());