Browse Source

jquery.inputmask 3.1.32

Robin Herbots 11 years ago
parent
commit
c64fafc961

+ 1 - 1
bower.json

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

+ 1 - 1
dist/inputmask/jquery.inputmask.date.extensions.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.1.31
+* Version: 3.1.32
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : factory(jQuery);

+ 1 - 1
dist/inputmask/jquery.inputmask.extensions.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.1.31
+* Version: 3.1.32
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : factory(jQuery);

+ 2 - 2
dist/inputmask/jquery.inputmask.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.1.31
+* Version: 3.1.32
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery" ], factory) : factory(jQuery);
@@ -222,7 +222,7 @@
             var before = lastValidPosition, after = lastValidPosition;
             for (var posNdx in valids) {
                 var psNdx = parseInt(posNdx);
-                (-1 == closestTo || null != valids[psNdx].match.fn) && (closestTo > psNdx && (before = psNdx), 
+                (-1 == closestTo || null != valids[psNdx].match.fn) && (closestTo >= psNdx && (before = psNdx), 
                 psNdx >= closestTo && (after = psNdx));
             }
             return lastValidPosition = closestTo - before > 1 || closestTo > after ? before : after;

+ 6 - 2
dist/inputmask/jquery.inputmask.numeric.extensions.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.1.31
+* Version: 3.1.32
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : factory(jQuery);
@@ -132,7 +132,7 @@
             },
             leadingZeroHandler: function(chrs, maskset, pos, strict, opts) {
                 var matchRslt = maskset.buffer.join("").match(opts.regex.integerNPart(opts)), radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
-                if (matchRslt && !strict && (-1 == radixPosition || matchRslt.index < radixPosition)) if (0 == matchRslt[0].indexOf("0") && pos >= opts.prefix.length) {
+                if (matchRslt && !strict && (-1 == radixPosition || matchRslt.index < radixPosition)) if ("0" == matchRslt[0] && pos >= opts.prefix.length) {
                     if (-1 == radixPosition || radixPosition >= pos && void 0 == maskset.validPositions[radixPosition]) return maskset.buffer.splice(matchRslt.index, 1), 
                     pos = pos > matchRslt.index ? pos - 1 : matchRslt.index, {
                         pos: pos,
@@ -143,6 +143,10 @@
                         pos: pos,
                         remove: matchRslt.index
                     };
+                    if (void 0 == maskset.validPositions[radixPosition]) return maskset.buffer[pos] = chrs, 
+                    {
+                        refreshFromBuffer: !0
+                    };
                 } else if ("0" == chrs && pos <= matchRslt.index) return !1;
                 return !0;
             },

+ 1 - 1
dist/inputmask/jquery.inputmask.phone.extensions.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.1.31
+* Version: 3.1.32
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : factory(jQuery);

+ 1 - 1
dist/inputmask/jquery.inputmask.regex.extensions.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.1.31
+* Version: 3.1.32
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : factory(jQuery);

+ 7 - 3
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.1.31
+* Version: 3.1.32
 */
 !function($) {
     function isInputEventSupported(eventName) {
@@ -220,7 +220,7 @@
             var before = lastValidPosition, after = lastValidPosition;
             for (var posNdx in valids) {
                 var psNdx = parseInt(posNdx);
-                (-1 == closestTo || null != valids[psNdx].match.fn) && (closestTo > psNdx && (before = psNdx), 
+                (-1 == closestTo || null != valids[psNdx].match.fn) && (closestTo >= psNdx && (before = psNdx), 
                 psNdx >= closestTo && (after = psNdx));
             }
             return lastValidPosition = closestTo - before > 1 || closestTo > after ? before : after;
@@ -1863,7 +1863,7 @@
             },
             leadingZeroHandler: function(chrs, maskset, pos, strict, opts) {
                 var matchRslt = maskset.buffer.join("").match(opts.regex.integerNPart(opts)), radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
-                if (matchRslt && !strict && (-1 == radixPosition || matchRslt.index < radixPosition)) if (0 == matchRslt[0].indexOf("0") && pos >= opts.prefix.length) {
+                if (matchRslt && !strict && (-1 == radixPosition || matchRslt.index < radixPosition)) if ("0" == matchRslt[0] && pos >= opts.prefix.length) {
                     if (-1 == radixPosition || radixPosition >= pos && void 0 == maskset.validPositions[radixPosition]) return maskset.buffer.splice(matchRslt.index, 1), 
                     pos = pos > matchRslt.index ? pos - 1 : matchRslt.index, {
                         pos: pos,
@@ -1874,6 +1874,10 @@
                         pos: pos,
                         remove: matchRslt.index
                     };
+                    if (void 0 == maskset.validPositions[radixPosition]) return maskset.buffer[pos] = chrs, 
+                    {
+                        refreshFromBuffer: !0
+                    };
                 } else if ("0" == chrs && pos <= matchRslt.index) return !1;
                 return !0;
             },

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


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 1 - 1
js/jquery.inputmask.js

@@ -383,7 +383,7 @@
                 for (var posNdx in valids) {
                     var psNdx = parseInt(posNdx);
                     if (closestTo == -1 || valids[psNdx]["match"].fn != null) {
-                        if (psNdx < closestTo) before = psNdx;
+                        if (psNdx <= closestTo) before = psNdx;
                         if (psNdx >= closestTo) after = psNdx;
                     }
                 }

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

@@ -160,7 +160,7 @@ Optional extensions on the jquery.inputmask base
             leadingZeroHandler: function (chrs, maskset, pos, strict, opts) {
                 var matchRslt = maskset.buffer.join('').match(opts.regex.integerNPart(opts)), radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
                 if (matchRslt && !strict && (radixPosition == -1 || matchRslt.index < radixPosition)) {
-                    if (matchRslt["0"].indexOf("0") == 0 && pos >= opts.prefix.length) {
+                    if (matchRslt["0"] == "0" && pos >= opts.prefix.length) {
                         if (radixPosition == -1 || (pos <= radixPosition && maskset["validPositions"][radixPosition] == undefined)) {
                             maskset.buffer.splice(matchRslt.index, 1);
                             pos = pos > matchRslt.index ? pos - 1 : matchRslt.index;
@@ -169,6 +169,9 @@ Optional extensions on the jquery.inputmask base
                             maskset.buffer.splice(matchRslt.index, 1);
                             pos = pos > matchRslt.index ? pos - 1 : matchRslt.index;
                             return { "pos": pos, "remove": matchRslt.index };
+                        } if (maskset["validPositions"][radixPosition] == undefined) {
+                            maskset["buffer"][pos] = chrs;
+                            return { "refreshFromBuffer": true };
                         }
                     } else if (chrs == "0" && pos <= matchRslt.index) {
                         return false;

+ 17 - 0
qunit/tests_numeric.js

@@ -718,4 +718,21 @@ test("inputmask(\"decimal\") - value=\"123.1\" tab out", function () {
 
     equal($("#testmask").val(), "123.100", "Result " + $("#testmask").val());
     $("#testmask").remove();
+});
+
+asyncTest("currency alias - 200000 => replace 2 to 3", function () {
+    var $fixture = $("#qunit-fixture");
+    $fixture.append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask("currency");
+
+    $("#testmask")[0].focus();
+    $("#testmask").click();
+    setTimeout(function () {
+        $("#testmask").Type("200000");
+        $.caret($("#testmask"), 2, 3);
+        $("#testmask").Type("3");
+        start();
+        equal($("#testmask").val(), "$ 300,000.00", "Result " + $("#testmask").val());
+        $("#testmask").remove();
+    }, 5);
 });