Browse Source

fix for numeric

Robin Herbots 11 years ago
parent
commit
ffca4a133b

+ 1 - 1
bower.json

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

BIN
dist/jQuery.InputMask.3.0.15.nupkg


+ 14 - 11
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.15
+* Version: 3.0.16
 */
 
 (function ($) {
@@ -1879,7 +1879,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.15
+Version: 3.0.16
 
 Optional extensions on the jquery.inputmask base
 */
@@ -1989,7 +1989,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.15
+Version: 3.0.16
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2452,7 +2452,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.15
+Version: 3.0.16
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2468,8 +2468,11 @@ Optional extensions on the jquery.inputmask base
                 var mask = opts.prefix;
                 mask += "[+]";
                 mask += "~{1," + opts.integerDigits + "}";
-                if (opts.digits != undefined && (isNaN(opts.digits) || parseInt(opts.digits) > 0))
-                    mask += "[" + opts.radixPoint + "={" + opts.digits + "}]";
+                if (opts.digits != undefined && (isNaN(opts.digits) || parseInt(opts.digits) > 0)) {
+                    if (opts.digitsOptional)
+                        mask += "[" + opts.radixPoint + "={" + opts.digits + "}]";
+                    else mask += opts.radixPoint + "={" + opts.digits + "}";
+                }
                 mask += opts.suffix;
                 return mask;
             },
@@ -2478,6 +2481,7 @@ Optional extensions on the jquery.inputmask base
             numericInput: false,
             isNumeric: true,
             digits: "*", //number of fractionalDigits
+            digitsOptional: true,
             groupSeparator: "",//",", // | "."
             radixPoint: ".",
             groupSize: 3,
@@ -2490,8 +2494,7 @@ Optional extensions on the jquery.inputmask base
             suffix: "",
             postFormat: function (buffer, pos, reformatOnly, opts) {
                 if (opts.groupSeparator == "") return pos;
-                var cbuf = buffer.slice(),
-                    radixPos = $.inArray(opts.radixPoint, buffer);
+                var cbuf = buffer.slice();
                 if (!reformatOnly) {
                     cbuf.splice(pos, 0, "?"); //set position indicator
                 }
@@ -2548,7 +2551,7 @@ Optional extensions on the jquery.inputmask base
                         }
                         var isValid = strict ? new RegExp("[0-9" + $.inputmask.escapeRegex.call(this, opts.groupSeparator) + "]").test(chrs) : new RegExp("[0-9]").test(chrs);
 
-                        if (isValid != false && !strict && chrs != opts.radixPoint) {
+                        if (isValid != false && !strict && chrs != opts.radixPoint && opts.autoGroup === true) {
                             var newPos = opts.postFormat(buffer, pos, (chrs == "-" || chrs == "+") ? true : false, opts);
                             return { "pos": newPos, "refreshFromBuffer": true };
                         }
@@ -2611,7 +2614,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.15
+Version: 3.0.16
 
 Regex extensions on the jquery.inputmask base
 Allows for using regular expressions as a mask
@@ -2798,7 +2801,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.15
+Version: 3.0.16
 
 Phone extension.
 When using this extension make sure you specify the correct url to get the masks

File diff suppressed because it is too large
+ 7 - 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 - 5
dist/min/jquery.inputmask.numeric.extensions.js


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 8 - 5
js/jquery.inputmask.numeric.extensions.js

@@ -19,8 +19,11 @@ Optional extensions on the jquery.inputmask base
                 var mask = opts.prefix;
                 mask += "[+]";
                 mask += "~{1," + opts.integerDigits + "}";
-                if (opts.digits != undefined && (isNaN(opts.digits) || parseInt(opts.digits) > 0))
-                    mask += "[" + opts.radixPoint + "={" + opts.digits + "}]";
+                if (opts.digits != undefined && (isNaN(opts.digits) || parseInt(opts.digits) > 0)) {
+                    if (opts.digitsOptional)
+                        mask += "[" + opts.radixPoint + "={" + opts.digits + "}]";
+                    else mask += opts.radixPoint + "={" + opts.digits + "}";
+                }
                 mask += opts.suffix;
                 return mask;
             },
@@ -29,6 +32,7 @@ Optional extensions on the jquery.inputmask base
             numericInput: false,
             isNumeric: true,
             digits: "*", //number of fractionalDigits
+            digitsOptional: true,
             groupSeparator: "",//",", // | "."
             radixPoint: ".",
             groupSize: 3,
@@ -41,8 +45,7 @@ Optional extensions on the jquery.inputmask base
             suffix: "",
             postFormat: function (buffer, pos, reformatOnly, opts) {
                 if (opts.groupSeparator == "") return pos;
-                var cbuf = buffer.slice(),
-                    radixPos = $.inArray(opts.radixPoint, buffer);
+                var cbuf = buffer.slice();
                 if (!reformatOnly) {
                     cbuf.splice(pos, 0, "?"); //set position indicator
                 }
@@ -99,7 +102,7 @@ Optional extensions on the jquery.inputmask base
                         }
                         var isValid = strict ? new RegExp("[0-9" + $.inputmask.escapeRegex.call(this, opts.groupSeparator) + "]").test(chrs) : new RegExp("[0-9]").test(chrs);
 
-                        if (isValid != false && !strict && chrs != opts.radixPoint) {
+                        if (isValid != false && !strict && chrs != opts.radixPoint && opts.autoGroup === true) {
                             var newPos = opts.postFormat(buffer, pos, (chrs == "-" || chrs == "+") ? true : false, opts);
                             return { "pos": newPos, "refreshFromBuffer": true };
                         }