Browse Source

Decimal mask drops digits

Robin Herbots 12 years ago
parent
commit
8b25cc6b3c

+ 1 - 1
build.properties

@@ -7,7 +7,7 @@ distdir = dist
 
 build.major = 2
 build.minor = 1
-build.revision = 11
+build.revision = 12
 
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js

BIN
dist/jQuery.InputMask.2.1.12.nupkg


BIN
dist/jQuery.InputMask.2.1.8.nupkg


+ 10 - 11
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2013 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 2.1.11
+* Version: 2.1.12
 */
 
 (function ($) {
@@ -1276,7 +1276,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.1.11
+Version: 2.1.12
 
 Optional extensions on the jquery.inputmask base
 */
@@ -1373,7 +1373,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2012 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.1.11
+Version: 2.1.12
 
 Optional extensions on the jquery.inputmask base
 */
@@ -1866,7 +1866,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.1.11
+Version: 2.1.12
 
 Optional extensions on the jquery.inputmask base
 */
@@ -1933,15 +1933,14 @@ Optional extensions on the jquery.inputmask base
             onKeyDown: function (e, buffer, opts) {
                 var $input = $(this), input = this;
                 if (e.keyCode == opts.keyCode.TAB) {
-                    var nptStr = input._valueGet();
-                    var radixPosition = nptStr.indexOf(opts.radixPoint);
+                    var radixPosition = $.inArray(opts.radixPoint, buffer);
                     if (radixPosition != -1) {
-                        for (var i = 1; i < opts.digits; i++) {
-                            if (nptStr[radixPosition + i]) nptStr = nptStr + "0";
-                        }
-                        if (nptStr !== $input.val()) {
-                            $input.val(nptStr);
+                        var masksets = $input.data('inputmask')['masksets'];
+                        var activeMasksetIndex = $input.data('inputmask')['activeMasksetIndex'];
+                        for (var i = 1; i <= opts.digits && i < opts.getMaskLength(masksets[activeMasksetIndex]["_buffer"], masksets[activeMasksetIndex]["greedy"], masksets[activeMasksetIndex]["repeat"], buffer, opts) ; i++) {
+                            if (buffer[radixPosition + i] == undefined) buffer[radixPosition + i] = "0";
                         }
+                        input._valueSet(buffer.join(''));
                     }
                 } else if (e.keyCode == opts.keyCode.DELETE || e.keyCode == opts.keyCode.BACKSPACE) {
                     opts.postFormat(buffer, 0, true, opts);

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


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


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


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 6 - 7
js/jquery.inputmask.numeric.extensions.js

@@ -70,15 +70,14 @@ Optional extensions on the jquery.inputmask base
             onKeyDown: function (e, buffer, opts) {
                 var $input = $(this), input = this;
                 if (e.keyCode == opts.keyCode.TAB) {
-                    var nptStr = input._valueGet();
-                    var radixPosition = nptStr.indexOf(opts.radixPoint);
+                    var radixPosition = $.inArray(opts.radixPoint, buffer);
                     if (radixPosition != -1) {
-                        for (var i = 1; i < opts.digits; i++) {
-                            if (nptStr[radixPosition + i]) nptStr = nptStr + "0";
-                        }
-                        if (nptStr !== $input.val()) {
-                            $input.val(nptStr);
+                        var masksets = $input.data('inputmask')['masksets'];
+                        var activeMasksetIndex = $input.data('inputmask')['activeMasksetIndex'];
+                        for (var i = 1; i <= opts.digits && i < opts.getMaskLength(masksets[activeMasksetIndex]["_buffer"], masksets[activeMasksetIndex]["greedy"], masksets[activeMasksetIndex]["repeat"], buffer, opts) ; i++) {
+                            if (buffer[radixPosition + i] == undefined) buffer[radixPosition + i] = "0";
                         }
+                        input._valueSet(buffer.join(''));
                     }
                 } else if (e.keyCode == opts.keyCode.DELETE || e.keyCode == opts.keyCode.BACKSPACE) {
                     opts.postFormat(buffer, 0, true, opts);