Browse Source

another update for the numeric extensions

Robin Herbots 11 years ago
parent
commit
5c736ab150

+ 3 - 3
dist/inputmask/jquery.inputmask.numeric.extensions.js

@@ -134,9 +134,9 @@
             },
             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 || radixPosition >= pos) && 0 == matchRslt[0].indexOf("0")) {
+                if (matchRslt && !strict && (-1 == radixPosition || radixPosition >= pos)) if (0 == matchRslt[0].indexOf("0")) {
                     pos < opts.prefix.length && (pos = matchRslt.index);
-                    var digitsMatch = maskset._buffer && maskset.buffer.slice(radixPosition).join("") == maskset._buffer.slice(radixPosition).join(""), integerMatch = maskset._buffer && maskset.buffer.slice(opts.prefix.length, radixPosition).join("") == maskset._buffer.slice(opts.prefix.length, radixPosition).join("");
+                    var _radixPosition = $.inArray(opts.radixPoint, maskset._buffer), digitsMatch = maskset._buffer && maskset.buffer.slice(radixPosition).join("") == maskset._buffer.slice(_radixPosition).join(""), integerMatch = maskset._buffer && maskset.buffer.slice(matchRslt.index, radixPosition).join("") == maskset._buffer.slice(opts.prefix.length, _radixPosition).join("");
                     if (-1 == radixPosition || digitsMatch && integerMatch) return maskset.buffer.splice(matchRslt.index, 1), 
                     pos = pos > matchRslt.index ? pos - 1 : matchRslt.index, {
                         pos: pos,
@@ -147,7 +147,7 @@
                         pos: pos,
                         remove: matchRslt.index
                     };
-                }
+                } else if ("0" === chrs && pos <= matchRslt.index) return !1;
                 return !0;
             },
             definitions: {

+ 3 - 3
dist/jquery.inputmask.bundle.js

@@ -1946,9 +1946,9 @@
             },
             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 || radixPosition >= pos) && 0 == matchRslt[0].indexOf("0")) {
+                if (matchRslt && !strict && (-1 == radixPosition || radixPosition >= pos)) if (0 == matchRslt[0].indexOf("0")) {
                     pos < opts.prefix.length && (pos = matchRslt.index);
-                    var digitsMatch = maskset._buffer && maskset.buffer.slice(radixPosition).join("") == maskset._buffer.slice(radixPosition).join(""), integerMatch = maskset._buffer && maskset.buffer.slice(opts.prefix.length, radixPosition).join("") == maskset._buffer.slice(opts.prefix.length, radixPosition).join("");
+                    var _radixPosition = $.inArray(opts.radixPoint, maskset._buffer), digitsMatch = maskset._buffer && maskset.buffer.slice(radixPosition).join("") == maskset._buffer.slice(_radixPosition).join(""), integerMatch = maskset._buffer && maskset.buffer.slice(matchRslt.index, radixPosition).join("") == maskset._buffer.slice(opts.prefix.length, _radixPosition).join("");
                     if (-1 == radixPosition || digitsMatch && integerMatch) return maskset.buffer.splice(matchRslt.index, 1), 
                     pos = pos > matchRslt.index ? pos - 1 : matchRslt.index, {
                         pos: pos,
@@ -1959,7 +1959,7 @@
                         pos: pos,
                         remove: matchRslt.index
                     };
-                }
+                } else if ("0" === chrs && pos <= matchRslt.index) return !1;
                 return !0;
             },
             definitions: {

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


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

@@ -177,8 +177,9 @@ Optional extensions on the jquery.inputmask base
                 if (matchRslt && !strict && (radixPosition == -1 || pos <= radixPosition)) {
                     if (matchRslt["0"].indexOf("0") == 0) {
                         if (pos < opts.prefix.length) pos = matchRslt.index; //position
-                        var digitsMatch = maskset._buffer && maskset.buffer.slice(radixPosition).join('') == maskset._buffer.slice(radixPosition).join('');
-                        var integerMatch = maskset._buffer && maskset.buffer.slice(opts.prefix.length, radixPosition).join('') == maskset._buffer.slice(opts.prefix.length, radixPosition).join('');
+                        var _radixPosition = $.inArray(opts.radixPoint, maskset._buffer);
+                        var digitsMatch = maskset._buffer && maskset.buffer.slice(radixPosition).join('') == maskset._buffer.slice(_radixPosition).join('');
+                        var integerMatch = maskset._buffer && maskset.buffer.slice(matchRslt.index, radixPosition).join('') == maskset._buffer.slice(opts.prefix.length, _radixPosition).join('');
 
                         if (radixPosition == -1 || digitsMatch && integerMatch) {
                             maskset.buffer.splice(matchRslt.index, 1);
@@ -189,6 +190,8 @@ Optional extensions on the jquery.inputmask base
                             pos = matchRslt.index;
                             return { "pos": pos, "remove": matchRslt.index };
                         }
+                    } else if (chrs === "0" && pos <= matchRslt.index) {
+                        return false;
                     }
                 }
                 return true;