Robin Herbots 11 years ago
parent
commit
79a7782861

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
 {
     "name": "jquery.inputmask",
     "name": "jquery.inputmask",
-    "version": "3.0.7",
+    "version": "3.0.8",
     "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 = 7
+build.revision = 8
 
 
 target = jquery.inputmask.bundle.js
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js
 target.min = jquery.inputmask.bundle.min.js

BIN
dist/jQuery.InputMask.3.0.7.nupkg


BIN
dist/jQuery.InputMask.3.0.8.nupkg


+ 22 - 12
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.7
+* Version: 3.0.8
 */
 */
 
 
 (function ($) {
 (function ($) {
@@ -620,8 +620,8 @@
                 }
                 }
             }
             }
 
 
-            function getPlaceholder(pos) {
-                var test = getTest(pos);
+            function getPlaceholder(pos, test) {
+                test = test || getTest(pos);
                 return test["fn"] == null ? test["def"] : opts.placeholder.charAt(pos % opts.placeholder.length);
                 return test["fn"] == null ? test["def"] : opts.placeholder.charAt(pos % opts.placeholder.length);
             }
             }
 
 
@@ -655,10 +655,20 @@
             }
             }
 
 
             function clearOptionalTail(input) {
             function clearOptionalTail(input) {
-                var buffer = getBuffer(), tmpBuffer = buffer.slice(), pos;
-                for (pos = tmpBuffer.length - 1; pos >= 0; pos--) {
-                    var test = getTest(pos);
-                    if ((test.optionality || test.optionalQuantifier) && tmpBuffer[pos] == getPlaceholder(pos)) {
+                var buffer = getBuffer(), tmpBuffer = buffer.slice(),
+                    pos, lvp = getLastValidPosition(), positions = {},
+                    ndxIntlzr = getMaskSet()["validPositions"][lvp]["locator"].slice(), testPos;
+                for (pos = lvp + 1; pos < tmpBuffer.length; pos++) {
+                    testPos = getTests(pos, ndxIntlzr, pos - 1);
+                    var firstMatch = testPos[0]["match"];
+                    testPos = testPos[(opts.greedy || (firstMatch.optionality === true && firstMatch.newBlockMarker === false && firstMatch.optionalQuantifier !== true)) ? 0 : (testPos.length - 1)];
+                    positions[pos] = testPos;
+                    ndxIntlzr = testPos["locator"].slice();
+                }
+
+                for (pos = tmpBuffer.length - 1; pos > lvp; pos--) {
+                    testPos = positions[pos]["match"];
+                    if (testPos.optionality && tmpBuffer[pos] == getPlaceholder(pos, testPos)) {
                         tmpBuffer.pop();
                         tmpBuffer.pop();
                     } else break;
                     } else break;
                 }
                 }
@@ -1827,7 +1837,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.7
+Version: 3.0.8
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -1937,7 +1947,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.7
+Version: 3.0.8
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2400,7 +2410,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.7
+Version: 3.0.8
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2663,7 +2673,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.7
+Version: 3.0.8
 
 
 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
@@ -2850,7 +2860,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.7
+Version: 3.0.8
 
 
 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
+ 91 - 91
dist/jquery.inputmask.bundle.min.js


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


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 16 - 6
js/jquery.inputmask.js

@@ -620,8 +620,8 @@
                 }
                 }
             }
             }
 
 
-            function getPlaceholder(pos) {
-                var test = getTest(pos);
+            function getPlaceholder(pos, test) {
+                test = test || getTest(pos);
                 return test["fn"] == null ? test["def"] : opts.placeholder.charAt(pos % opts.placeholder.length);
                 return test["fn"] == null ? test["def"] : opts.placeholder.charAt(pos % opts.placeholder.length);
             }
             }
 
 
@@ -655,10 +655,20 @@
             }
             }
 
 
             function clearOptionalTail(input) {
             function clearOptionalTail(input) {
-                var buffer = getBuffer(), tmpBuffer = buffer.slice(), pos;
-                for (pos = tmpBuffer.length - 1; pos >= 0; pos--) {
-                    var test = getTest(pos);
-                    if ((test.optionality || test.optionalQuantifier) && tmpBuffer[pos] == getPlaceholder(pos)) {
+                var buffer = getBuffer(), tmpBuffer = buffer.slice(),
+                    pos, lvp = getLastValidPosition(), positions = {},
+                    ndxIntlzr = getMaskSet()["validPositions"][lvp]["locator"].slice(), testPos;
+                for (pos = lvp + 1; pos < tmpBuffer.length; pos++) {
+                    testPos = getTests(pos, ndxIntlzr, pos - 1);
+                    var firstMatch = testPos[0]["match"];
+                    testPos = testPos[(opts.greedy || (firstMatch.optionality === true && firstMatch.newBlockMarker === false && firstMatch.optionalQuantifier !== true)) ? 0 : (testPos.length - 1)];
+                    positions[pos] = testPos;
+                    ndxIntlzr = testPos["locator"].slice();
+                }
+
+                for (pos = tmpBuffer.length - 1; pos > lvp; pos--) {
+                    testPos = positions[pos]["match"];
+                    if (testPos.optionality && tmpBuffer[pos] == getPlaceholder(pos, testPos)) {
                         tmpBuffer.pop();
                         tmpBuffer.pop();
                     } else break;
                     } else break;
                 }
                 }

+ 15 - 2
qunit/tests.js

@@ -2338,7 +2338,7 @@ test("email mask greedy false", function () {
 
 
     $("#testmask")[0].focus();
     $("#testmask")[0].focus();
     $("#testmask").Type("some.body@mail.com");
     $("#testmask").Type("some.body@mail.com");
-
+    $("#testmask").blur();
     equal($("#testmask").val(), "some.body@mail.com", "Result " + $("#testmask").val());
     equal($("#testmask").val(), "some.body@mail.com", "Result " + $("#testmask").val());
 
 
     $("#testmask").remove();
     $("#testmask").remove();
@@ -2350,8 +2350,21 @@ test("email mask greedy true", function () {
 
 
     $("#testmask")[0].focus();
     $("#testmask")[0].focus();
     $("#testmask").Type("some.body@mail.com");
     $("#testmask").Type("some.body@mail.com");
+    $("#testmask").blur();
+    equal($("#testmask").val(), "some.body@mail.com___", "Result " + $("#testmask").val());
 
 
-    equal($("#testmask").val(), "some.body@mail.com", "Result " + $("#testmask").val());
+    $("#testmask").remove();
+});
+
+test("email mask - partial input", function () {
+    var $fixture = $("#qunit-fixture");
+    $fixture.append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask("email");
+
+    $("#testmask")[0].focus();
+    $("#testmask").Type("some.");
+    $("#testmask").blur();
+    equal($("#testmask").val(), "some._@_.__", "Result " + $("#testmask").val());
 
 
     $("#testmask").remove();
     $("#testmask").remove();
 });
 });