浏览代码

fix currency with " " as groupseparator

Robin Herbots 9 年之前
父节点
当前提交
6af81e3538

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.3.2-27",
+  "version": "3.3.2-34",
   "main": [
     "./dist/inputmask/inputmask.js"
   ],

+ 1 - 1
component.json

@@ -2,7 +2,7 @@
   "name": "jquery_inputmask",
   "repository": "robinherbots/jquery.inputmask",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
-  "version": "3.3.2-27",
+  "version": "3.3.2-34",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "main": "./dist/jquery.inputmask.bundle.js",
   "scripts": [

+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
   "name": "robinherbots/jquery.inputmask",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
-  "version": "3.3.2-27",
+  "version": "3.3.2-34",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/jquery.inputmask",

+ 1 - 1
dist/inputmask/inputmask.date.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-27
+* Version: 3.3.2-34
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/inputmask.dependencyLib.jquery.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-27
+* Version: 3.3.2-34
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery")) : factory(jQuery);

+ 1 - 1
dist/inputmask/inputmask.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-27
+* Version: 3.3.2-34
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 4 - 3
dist/inputmask/inputmask.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-27
+* Version: 3.3.2-34
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery")) : factory(window.dependencyLib || jQuery);
@@ -685,9 +685,10 @@
             return position;
         }
         function seekPrevious(pos, newBlock) {
-            var position = pos;
+            var tests, position = pos;
             if (0 >= position) return 0;
-            for (;--position > 0 && (newBlock === !0 && getTest(position).match.newBlockMarker !== !0 || newBlock !== !0 && !isMask(position) && getTests(position).length < 2); ) ;
+            for (;--position > 0 && (newBlock === !0 && getTest(position).match.newBlockMarker !== !0 || newBlock !== !0 && !isMask(position) && (tests = getTests(position), 
+            tests.length < 2 || 2 === tests.length && "" === tests[1].match.def)); ) ;
             return position;
         }
         function getBufferElement(position) {

+ 38 - 32
dist/inputmask/inputmask.numeric.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-27
+* Version: 3.3.2-34
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);
@@ -68,27 +68,28 @@
             unmaskAsNumber: !1,
             postFormat: function(buffer, pos, opts) {
                 opts.numericInput === !0 && (buffer = buffer.reverse(), isFinite(pos) && (pos = buffer.join("").length - pos - 1));
-                var i, l, suffixStripped = !1;
-                buffer.length >= opts.suffix.length && buffer.join("").indexOf(opts.suffix) === buffer.length - opts.suffix.length && (buffer.length = buffer.length - opts.suffix.length, 
-                suffixStripped = !0), pos = pos >= buffer.length ? buffer.length - 1 : pos < opts.prefix.length ? opts.prefix.length : pos;
-                var needsRefresh = !1, charAtPos = buffer[pos], cbuf = buffer.slice();
+                var i, l;
+                pos = pos >= buffer.length ? buffer.length - 1 : pos < opts.prefix.length ? opts.prefix.length : pos;
+                var charAtPos = buffer[pos], cbuf = buffer.slice();
                 charAtPos === opts.groupSeparator && (cbuf.splice(pos--, 1), charAtPos = cbuf[pos]), 
-                charAtPos !== opts.radixPoint && charAtPos !== opts.negationSymbol.front && charAtPos !== opts.negationSymbol.back && (cbuf[pos] = "?");
+                cbuf[pos] = "!";
                 var bufVal = cbuf.join(""), bufValOrigin = bufVal;
-                if (bufVal.length > 0 && opts.autoGroup || -1 !== bufVal.indexOf(opts.groupSeparator)) {
+                if (bufVal = bufVal.replace(new RegExp(Inputmask.escapeRegex(opts.suffix) + "$"), ""), 
+                bufVal = bufVal.replace(new RegExp("^" + Inputmask.escapeRegex(opts.prefix)), ""), 
+                bufVal.length > 0 && opts.autoGroup || -1 !== bufVal.indexOf(opts.groupSeparator)) {
                     var escapedGroupSeparator = Inputmask.escapeRegex(opts.groupSeparator);
-                    needsRefresh = 0 === bufVal.indexOf(opts.groupSeparator), bufVal = bufVal.replace(new RegExp(escapedGroupSeparator, "g"), "");
-                    var radixSplit = bufVal.split(opts.radixPoint);
-                    if (bufVal = "" === opts.radixPoint ? bufVal : radixSplit[0], bufVal !== opts.prefix + "?0" && bufVal.length >= opts.groupSize + opts.prefix.length) for (var reg = new RegExp("([-+]?[\\d?]+)([\\d?]{" + opts.groupSize + "})"); reg.test(bufVal) && "" !== opts.groupSeparator; ) bufVal = bufVal.replace(reg, "$1" + opts.groupSeparator + "$2"), 
+                    bufVal = bufVal.replace(new RegExp(escapedGroupSeparator, "g"), "");
+                    var radixSplit = bufVal.split(charAtPos === opts.radixPoint ? "!" : opts.radixPoint);
+                    if (bufVal = "" === opts.radixPoint ? bufVal : radixSplit[0], charAtPos !== opts.negationSymbol.front && (bufVal = bufVal.replace("!", "?")), 
+                    bufVal.length > opts.groupSize) for (var reg = new RegExp("([-+]?[\\d?]+)([\\d?]{" + opts.groupSize + "})"); reg.test(bufVal) && "" !== opts.groupSeparator; ) bufVal = bufVal.replace(reg, "$1" + opts.groupSeparator + "$2"), 
                     bufVal = bufVal.replace(opts.groupSeparator + opts.groupSeparator, opts.groupSeparator);
-                    "" !== opts.radixPoint && radixSplit.length > 1 && (bufVal += opts.radixPoint + radixSplit[1]);
+                    bufVal = bufVal.replace("?", "!"), "" !== opts.radixPoint && radixSplit.length > 1 && (bufVal += (charAtPos === opts.radixPoint ? "!" : opts.radixPoint) + radixSplit[1]);
                 }
-                for (needsRefresh = bufValOrigin !== bufVal, buffer.length = bufVal.length, i = 0, 
-                l = bufVal.length; l > i; i++) buffer[i] = bufVal.charAt(i);
-                var newPos = $.inArray("?", buffer);
-                if (-1 === newPos && (newPos = $.inArray(charAtPos, buffer)), buffer[newPos] = charAtPos, 
-                !needsRefresh && suffixStripped) for (i = 0, l = opts.suffix.length; l > i; i++) buffer.push(opts.suffix.charAt(i));
-                return newPos = opts.numericInput && isFinite(pos) ? buffer.join("").length - newPos - 1 : newPos, 
+                bufVal = opts.prefix + bufVal + opts.suffix;
+                var needsRefresh = bufValOrigin !== bufVal;
+                if (needsRefresh) for (buffer.length = bufVal.length, i = 0, l = bufVal.length; l > i; i++) buffer[i] = bufVal.charAt(i);
+                var newPos = $.inArray("!", bufVal);
+                return buffer[newPos] = charAtPos, newPos = opts.numericInput && isFinite(pos) ? buffer.join("").length - newPos - 1 : newPos, 
                 opts.numericInput && (buffer = buffer.reverse(), $.inArray(opts.radixPoint, buffer) < newPos && buffer.join("").length - opts.suffix.length !== newPos && (newPos -= 1)), 
                 {
                     pos: newPos,
@@ -208,22 +209,27 @@
                 return !1;
             },
             leadingZeroHandler: function(chrs, maskset, pos, strict, opts, isSelection) {
-                if (!strict) if (opts.numericInput === !0) {
-                    var buffer = maskset.buffer.slice("").reverse(), bufferChar = buffer[opts.prefix.length];
-                    if ("0" === bufferChar && void 0 === maskset.validPositions[pos - 1]) return {
-                        pos: pos,
-                        remove: buffer.length - opts.prefix.length - 1
-                    };
-                } else {
-                    var radixPosition = $.inArray(opts.radixPoint, maskset.buffer), matchRslt = maskset.buffer.slice(0, -1 !== radixPosition ? radixPosition : void 0).join("").match(opts.regex.integerNPart(opts));
-                    if (matchRslt && (-1 === radixPosition || radixPosition >= pos)) {
-                        var decimalPart = -1 === radixPosition ? 0 : parseInt(maskset.buffer.slice(radixPosition + 1).join(""));
-                        if (0 === matchRslt[0].indexOf("" !== opts.placeholder ? opts.placeholder.charAt(0) : "0") && (matchRslt.index + 1 === pos || isSelection !== !0 && 0 === decimalPart)) return maskset.buffer.splice(matchRslt.index, 1), 
-                        {
-                            pos: matchRslt.index,
-                            remove: matchRslt.index
+                if (!strict) {
+                    var buffer = maskset.buffer.slice("");
+                    if (buffer.splice(0, opts.prefix.length), buffer.splice(buffer.length - opts.suffix.length, opts.suffix.length), 
+                    opts.numericInput === !0) {
+                        var buffer = buffer.reverse(), bufferChar = buffer[0];
+                        if ("0" === bufferChar && void 0 === maskset.validPositions[pos - 1]) return {
+                            pos: pos,
+                            remove: buffer.length - 1
                         };
-                        if ("0" === chrs && pos <= matchRslt.index && matchRslt[0] !== opts.groupSeparator) return !1;
+                    } else {
+                        pos -= opts.prefix.length;
+                        var radixPosition = $.inArray(opts.radixPoint, buffer), matchRslt = buffer.slice(0, -1 !== radixPosition ? radixPosition : void 0).join("").match(opts.regex.integerNPart(opts));
+                        if (matchRslt && (-1 === radixPosition || radixPosition >= pos)) {
+                            var decimalPart = -1 === radixPosition ? 0 : parseInt(buffer.slice(radixPosition + 1).join(""));
+                            if (0 === matchRslt[0].indexOf("" !== opts.placeholder ? opts.placeholder.charAt(0) : "0") && (matchRslt.index + 1 === pos || isSelection !== !0 && 0 === decimalPart)) return maskset.buffer.splice(matchRslt.index + opts.prefix.length, 1), 
+                            {
+                                pos: matchRslt.index + opts.prefix.length,
+                                remove: matchRslt.index + opts.prefix.length
+                            };
+                            if ("0" === chrs && pos <= matchRslt.index && matchRslt[0] !== opts.groupSeparator) return !1;
+                        }
                     }
                 }
                 return !0;

+ 1 - 1
dist/inputmask/inputmask.phone.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-27
+* Version: 3.3.2-34
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/inputmask.regex.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-27
+* Version: 3.3.2-34
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/jquery.inputmask.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-27
+* Version: 3.3.2-34
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./inputmask")) : factory(jQuery, window.Inputmask);

+ 41 - 34
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-27
+* Version: 3.3.2-34
 */
 !function($) {
     function Inputmask(alias, options) {
@@ -683,9 +683,10 @@
             return position;
         }
         function seekPrevious(pos, newBlock) {
-            var position = pos;
+            var tests, position = pos;
             if (0 >= position) return 0;
-            for (;--position > 0 && (newBlock === !0 && getTest(position).match.newBlockMarker !== !0 || newBlock !== !0 && !isMask(position) && getTests(position).length < 2); ) ;
+            for (;--position > 0 && (newBlock === !0 && getTest(position).match.newBlockMarker !== !0 || newBlock !== !0 && !isMask(position) && (tests = getTests(position), 
+            tests.length < 2 || 2 === tests.length && "" === tests[1].match.def)); ) ;
             return position;
         }
         function getBufferElement(position) {
@@ -2174,27 +2175,28 @@
             unmaskAsNumber: !1,
             postFormat: function(buffer, pos, opts) {
                 opts.numericInput === !0 && (buffer = buffer.reverse(), isFinite(pos) && (pos = buffer.join("").length - pos - 1));
-                var i, l, suffixStripped = !1;
-                buffer.length >= opts.suffix.length && buffer.join("").indexOf(opts.suffix) === buffer.length - opts.suffix.length && (buffer.length = buffer.length - opts.suffix.length, 
-                suffixStripped = !0), pos = pos >= buffer.length ? buffer.length - 1 : pos < opts.prefix.length ? opts.prefix.length : pos;
-                var needsRefresh = !1, charAtPos = buffer[pos], cbuf = buffer.slice();
+                var i, l;
+                pos = pos >= buffer.length ? buffer.length - 1 : pos < opts.prefix.length ? opts.prefix.length : pos;
+                var charAtPos = buffer[pos], cbuf = buffer.slice();
                 charAtPos === opts.groupSeparator && (cbuf.splice(pos--, 1), charAtPos = cbuf[pos]), 
-                charAtPos !== opts.radixPoint && charAtPos !== opts.negationSymbol.front && charAtPos !== opts.negationSymbol.back && (cbuf[pos] = "?");
+                cbuf[pos] = "!";
                 var bufVal = cbuf.join(""), bufValOrigin = bufVal;
-                if (bufVal.length > 0 && opts.autoGroup || -1 !== bufVal.indexOf(opts.groupSeparator)) {
+                if (bufVal = bufVal.replace(new RegExp(Inputmask.escapeRegex(opts.suffix) + "$"), ""), 
+                bufVal = bufVal.replace(new RegExp("^" + Inputmask.escapeRegex(opts.prefix)), ""), 
+                bufVal.length > 0 && opts.autoGroup || -1 !== bufVal.indexOf(opts.groupSeparator)) {
                     var escapedGroupSeparator = Inputmask.escapeRegex(opts.groupSeparator);
-                    needsRefresh = 0 === bufVal.indexOf(opts.groupSeparator), bufVal = bufVal.replace(new RegExp(escapedGroupSeparator, "g"), "");
-                    var radixSplit = bufVal.split(opts.radixPoint);
-                    if (bufVal = "" === opts.radixPoint ? bufVal : radixSplit[0], bufVal !== opts.prefix + "?0" && bufVal.length >= opts.groupSize + opts.prefix.length) for (var reg = new RegExp("([-+]?[\\d?]+)([\\d?]{" + opts.groupSize + "})"); reg.test(bufVal) && "" !== opts.groupSeparator; ) bufVal = bufVal.replace(reg, "$1" + opts.groupSeparator + "$2"), 
+                    bufVal = bufVal.replace(new RegExp(escapedGroupSeparator, "g"), "");
+                    var radixSplit = bufVal.split(charAtPos === opts.radixPoint ? "!" : opts.radixPoint);
+                    if (bufVal = "" === opts.radixPoint ? bufVal : radixSplit[0], charAtPos !== opts.negationSymbol.front && (bufVal = bufVal.replace("!", "?")), 
+                    bufVal.length > opts.groupSize) for (var reg = new RegExp("([-+]?[\\d?]+)([\\d?]{" + opts.groupSize + "})"); reg.test(bufVal) && "" !== opts.groupSeparator; ) bufVal = bufVal.replace(reg, "$1" + opts.groupSeparator + "$2"), 
                     bufVal = bufVal.replace(opts.groupSeparator + opts.groupSeparator, opts.groupSeparator);
-                    "" !== opts.radixPoint && radixSplit.length > 1 && (bufVal += opts.radixPoint + radixSplit[1]);
+                    bufVal = bufVal.replace("?", "!"), "" !== opts.radixPoint && radixSplit.length > 1 && (bufVal += (charAtPos === opts.radixPoint ? "!" : opts.radixPoint) + radixSplit[1]);
                 }
-                for (needsRefresh = bufValOrigin !== bufVal, buffer.length = bufVal.length, i = 0, 
-                l = bufVal.length; l > i; i++) buffer[i] = bufVal.charAt(i);
-                var newPos = $.inArray("?", buffer);
-                if (-1 === newPos && (newPos = $.inArray(charAtPos, buffer)), buffer[newPos] = charAtPos, 
-                !needsRefresh && suffixStripped) for (i = 0, l = opts.suffix.length; l > i; i++) buffer.push(opts.suffix.charAt(i));
-                return newPos = opts.numericInput && isFinite(pos) ? buffer.join("").length - newPos - 1 : newPos, 
+                bufVal = opts.prefix + bufVal + opts.suffix;
+                var needsRefresh = bufValOrigin !== bufVal;
+                if (needsRefresh) for (buffer.length = bufVal.length, i = 0, l = bufVal.length; l > i; i++) buffer[i] = bufVal.charAt(i);
+                var newPos = $.inArray("!", bufVal);
+                return buffer[newPos] = charAtPos, newPos = opts.numericInput && isFinite(pos) ? buffer.join("").length - newPos - 1 : newPos, 
                 opts.numericInput && (buffer = buffer.reverse(), $.inArray(opts.radixPoint, buffer) < newPos && buffer.join("").length - opts.suffix.length !== newPos && (newPos -= 1)), 
                 {
                     pos: newPos,
@@ -2314,22 +2316,27 @@
                 return !1;
             },
             leadingZeroHandler: function(chrs, maskset, pos, strict, opts, isSelection) {
-                if (!strict) if (opts.numericInput === !0) {
-                    var buffer = maskset.buffer.slice("").reverse(), bufferChar = buffer[opts.prefix.length];
-                    if ("0" === bufferChar && void 0 === maskset.validPositions[pos - 1]) return {
-                        pos: pos,
-                        remove: buffer.length - opts.prefix.length - 1
-                    };
-                } else {
-                    var radixPosition = $.inArray(opts.radixPoint, maskset.buffer), matchRslt = maskset.buffer.slice(0, -1 !== radixPosition ? radixPosition : void 0).join("").match(opts.regex.integerNPart(opts));
-                    if (matchRslt && (-1 === radixPosition || radixPosition >= pos)) {
-                        var decimalPart = -1 === radixPosition ? 0 : parseInt(maskset.buffer.slice(radixPosition + 1).join(""));
-                        if (0 === matchRslt[0].indexOf("" !== opts.placeholder ? opts.placeholder.charAt(0) : "0") && (matchRslt.index + 1 === pos || isSelection !== !0 && 0 === decimalPart)) return maskset.buffer.splice(matchRslt.index, 1), 
-                        {
-                            pos: matchRslt.index,
-                            remove: matchRslt.index
+                if (!strict) {
+                    var buffer = maskset.buffer.slice("");
+                    if (buffer.splice(0, opts.prefix.length), buffer.splice(buffer.length - opts.suffix.length, opts.suffix.length), 
+                    opts.numericInput === !0) {
+                        var buffer = buffer.reverse(), bufferChar = buffer[0];
+                        if ("0" === bufferChar && void 0 === maskset.validPositions[pos - 1]) return {
+                            pos: pos,
+                            remove: buffer.length - 1
                         };
-                        if ("0" === chrs && pos <= matchRslt.index && matchRslt[0] !== opts.groupSeparator) return !1;
+                    } else {
+                        pos -= opts.prefix.length;
+                        var radixPosition = $.inArray(opts.radixPoint, buffer), matchRslt = buffer.slice(0, -1 !== radixPosition ? radixPosition : void 0).join("").match(opts.regex.integerNPart(opts));
+                        if (matchRslt && (-1 === radixPosition || radixPosition >= pos)) {
+                            var decimalPart = -1 === radixPosition ? 0 : parseInt(buffer.slice(radixPosition + 1).join(""));
+                            if (0 === matchRslt[0].indexOf("" !== opts.placeholder ? opts.placeholder.charAt(0) : "0") && (matchRslt.index + 1 === pos || isSelection !== !0 && 0 === decimalPart)) return maskset.buffer.splice(matchRslt.index + opts.prefix.length, 1), 
+                            {
+                                pos: matchRslt.index + opts.prefix.length,
+                                remove: matchRslt.index + opts.prefix.length
+                            };
+                            if ("0" === chrs && pos <= matchRslt.index && matchRslt[0] !== opts.groupSeparator) return !1;
+                        }
                     }
                 }
                 return !0;

文件差异内容过多而无法显示
+ 1 - 1
dist/min/inputmask/inputmask.date.extensions.min.js


+ 1 - 1
dist/min/inputmask/inputmask.dependencyLib.jquery.min.js

@@ -3,6 +3,6 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-27
+* Version: 3.3.2-34
 */
 !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){return window.dependencyLib=a,a});

文件差异内容过多而无法显示
+ 1 - 1
dist/min/inputmask/inputmask.extensions.min.js


文件差异内容过多而无法显示
+ 3 - 3
dist/min/inputmask/inputmask.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/min/inputmask/inputmask.numeric.extensions.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/min/inputmask/inputmask.phone.extensions.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/min/inputmask/inputmask.regex.extensions.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/min/inputmask/jquery.inputmask.min.js


文件差异内容过多而无法显示
+ 4 - 4
dist/min/jquery.inputmask.bundle.min.js


+ 3 - 2
js/inputmask.js

@@ -1689,12 +1689,13 @@
 		}
 
 		function seekPrevious(pos, newBlock) {
-			var position = pos;
+			var position = pos, tests;
 			if (position <= 0) return 0;
 
 			while (--position > 0 &&
 			((newBlock === true && getTest(position).match.newBlockMarker !== true) ||
-			(newBlock !== true && !isMask(position) && getTests(position).length < 2))) {
+			(newBlock !== true && !isMask(position) &&
+			(tests = getTests(position), tests.length < 2 || (tests.length === 2 && tests[1].match.def === ""))))) {
 			}
 
 			return position;

+ 38 - 36
js/inputmask.numeric.extensions.js

@@ -146,58 +146,56 @@
 						pos = buffer.join("").length - pos - 1;
 					}
 				}
-				var suffixStripped = false,
-					i, l;
-				if (buffer.length >= opts.suffix.length && buffer.join("").indexOf(opts.suffix) === (buffer.length - opts.suffix.length)) {
-					buffer.length = buffer.length - opts.suffix.length; //strip suffix
-					suffixStripped = true;
-				}
+				var i, l;
+
 				//position overflow corrections
 				pos = pos >= buffer.length ? buffer.length - 1 : (pos < opts.prefix.length ? opts.prefix.length : pos);
 
-				var needsRefresh = false,
-					charAtPos = buffer[pos];
+				var charAtPos = buffer[pos];
 
 				var cbuf = buffer.slice();
 				if (charAtPos === opts.groupSeparator) {
 					cbuf.splice(pos--, 1);
 					charAtPos = cbuf[pos];
 				}
-				if (charAtPos !== opts.radixPoint && charAtPos !== opts.negationSymbol.front && charAtPos !== opts.negationSymbol.back) cbuf[pos] = "?";
-				var bufVal = cbuf.join(""),
-					bufValOrigin = bufVal;
+				//mark current pos
+				cbuf[pos] = "!";
+				var bufVal = cbuf.join(""), bufValOrigin = bufVal;
+
+				bufVal = bufVal.replace(new RegExp(Inputmask.escapeRegex(opts.suffix) + "$"), "");
+				bufVal = bufVal.replace(new RegExp("^" + Inputmask.escapeRegex(opts.prefix)), "");
 				if (bufVal.length > 0 && opts.autoGroup || bufVal.indexOf(opts.groupSeparator) !== -1) {
 					var escapedGroupSeparator = Inputmask.escapeRegex(opts.groupSeparator);
-					needsRefresh = bufVal.indexOf(opts.groupSeparator) === 0;
 					bufVal = bufVal.replace(new RegExp(escapedGroupSeparator, "g"), "");
-					var radixSplit = bufVal.split(opts.radixPoint);
+					var radixSplit = bufVal.split(charAtPos === opts.radixPoint ? "!" : opts.radixPoint);
 					bufVal = opts.radixPoint === "" ? bufVal : radixSplit[0];
-					if (bufVal !== (opts.prefix + "?0") && bufVal.length >= (opts.groupSize + opts.prefix.length)) {
-						//needsRefresh = true;
+					if (charAtPos !== opts.negationSymbol.front) bufVal = bufVal.replace("!", "?");
+					if (bufVal.length > opts.groupSize) {
 						var reg = new RegExp("([-\+]?[\\d\?]+)([\\d\?]{" + opts.groupSize + "})");
 						while (reg.test(bufVal) && opts.groupSeparator !== "") {
 							bufVal = bufVal.replace(reg, "$1" + opts.groupSeparator + "$2");
 							bufVal = bufVal.replace(opts.groupSeparator + opts.groupSeparator, opts.groupSeparator);
 						}
 					}
+					bufVal = bufVal.replace("?", "!");
 					if (opts.radixPoint !== "" && radixSplit.length > 1) {
-						bufVal += opts.radixPoint + radixSplit[1];
+						bufVal += (charAtPos === opts.radixPoint ? "!" : opts.radixPoint) + radixSplit[1];
 					}
 				}
-				needsRefresh = bufValOrigin !== bufVal;
-				buffer.length = bufVal.length; //align the length
-				for (i = 0, l = bufVal.length; i < l; i++) {
-					buffer[i] = bufVal.charAt(i);
-				}
-				var newPos = $.inArray("?", buffer);
-				if (newPos === -1) newPos = $.inArray(charAtPos, buffer);
-				buffer[newPos] = charAtPos;
 
-				if (!needsRefresh && suffixStripped) {
-					for (i = 0, l = opts.suffix.length; i < l; i++) {
-						buffer.push(opts.suffix.charAt(i));
+				bufVal = opts.prefix + bufVal + opts.suffix;
+
+
+				var needsRefresh = bufValOrigin !== bufVal;
+				if (needsRefresh) {
+					buffer.length = bufVal.length; //align the length
+					for (i = 0, l = bufVal.length; i < l; i++) {
+						buffer[i] = bufVal.charAt(i);
 					}
 				}
+				var newPos = $.inArray("!", bufVal);
+				buffer[newPos] = charAtPos;
+
 				// console.log("formatted " + buffer + " refresh " + needsRefresh);
 				newPos = (opts.numericInput && isFinite(pos)) ? buffer.join("").length - newPos - 1 : newPos;
 				if (opts.numericInput) {
@@ -411,26 +409,30 @@
 			},
 			leadingZeroHandler: function (chrs, maskset, pos, strict, opts, isSelection) {
 				if (!strict) {
+					var buffer = maskset.buffer.slice("");
+					buffer.splice(0, opts.prefix.length);
+					buffer.splice(buffer.length - opts.suffix.length, opts.suffix.length);
 					if (opts.numericInput === true) {
-						var buffer = maskset.buffer.slice("").reverse();
-						var bufferChar = buffer[opts.prefix.length];
+						var buffer = buffer.reverse();
+						var bufferChar = buffer[0];
 						if (bufferChar === "0" && maskset.validPositions[pos - 1] === undefined) {
 							return {
 								"pos": pos,
-								"remove": buffer.length - opts.prefix.length - 1
+								"remove": buffer.length - 1
 							};
 						}
 					} else {
-						var radixPosition = $.inArray(opts.radixPoint, maskset.buffer),
-							matchRslt = maskset.buffer.slice(0, radixPosition !== -1 ? radixPosition : undefined).join("").match(opts.regex.integerNPart(opts));
+						pos = pos - opts.prefix.length;
+						var radixPosition = $.inArray(opts.radixPoint, buffer),
+							matchRslt = buffer.slice(0, radixPosition !== -1 ? radixPosition : undefined).join("").match(opts.regex.integerNPart(opts));
 						if (matchRslt && (radixPosition === -1 || pos <= radixPosition)) {
-							var decimalPart = radixPosition === -1 ? 0 : parseInt(maskset.buffer.slice(radixPosition + 1).join(""));
+							var decimalPart = radixPosition === -1 ? 0 : parseInt(buffer.slice(radixPosition + 1).join(""));
 							if (matchRslt["0"].indexOf(opts.placeholder !== "" ? opts.placeholder.charAt(0) : "0") === 0 &&
 								(matchRslt.index + 1 === pos || (isSelection !== true && decimalPart === 0))) {
-								maskset.buffer.splice(matchRslt.index, 1);
+								maskset.buffer.splice(matchRslt.index + opts.prefix.length, 1);
 								return {
-									"pos": matchRslt.index,
-									"remove": matchRslt.index
+									"pos": matchRslt.index + opts.prefix.length,
+									"remove": matchRslt.index + opts.prefix.length
 								};
 							} else if (chrs === "0" && pos <= matchRslt.index && matchRslt["0"] !== opts.groupSeparator) {
 								return false;

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.3.2-27",
+  "version": "3.3.2-34",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "main": "./dist/inputmask/jquery.inputmask.js",
   "files": [

+ 10 - 0
qunit/tests_numeric.js

@@ -1813,4 +1813,14 @@ define([
 		assert.equal($("#testmask")[0].inputmask._valueGet(), "52 €", "Result " + $("#testmask")[0].inputmask._valueGet());
 	});
 
+	qunit.test("currency + groupSeparator \" \"", function (assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask('currency', {
+			groupSeparator: ' '
+		}).mask(testmask);
+		testmask.focus();
+		assert.equal($("#testmask")[0].inputmask._valueGet(), "$ 0.00", "Result " + $("#testmask")[0].inputmask._valueGet());
+	});
 });

+ 23 - 7
qunit/tests_phone.js

@@ -19,7 +19,7 @@ define([
 	qunit.module("Phone masks");
 
 	qunit.test("inputmask(\"phone be\") - type \"473890428\"", 1, function (assert) {
-		var done = assert.async(), $fixture =$("#qunit-fixture");
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" />');
 		var testmask = document.getElementById("testmask");
 
@@ -34,7 +34,7 @@ define([
 	});
 
 	qunit.test("inputmask(\"phone be\") - value \"+32473890428\"", 1, function (assert) {
-		var done = assert.async(), $fixture =$("#qunit-fixture");
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" value="+32473890428" />');
 		Inputmask("phonebe").mask(testmask);
 		testmask.focus();
@@ -45,7 +45,7 @@ define([
 	});
 
 	qunit.test("inputmask(\"phone\") - value=\"+32(473)890-428\"", 1, function (assert) {
-		var done = assert.async(), $fixture =$("#qunit-fixture");
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" value="+32(473)890-428" />');
 		Inputmask("phone").mask(testmask);
 
@@ -56,7 +56,7 @@ define([
 	});
 
 	qunit.test("inputmask(\"phone\") - value=\"32473890428\"", 1, function (assert) {
-		var done = assert.async(), $fixture =$("#qunit-fixture");
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" value="32473890428" />');
 		Inputmask("phone").mask(testmask);
 
@@ -67,7 +67,7 @@ define([
 	});
 
 	qunit.test("inputmask(\"phone\") - Brazil new", 1, function (assert) {
-		var done = assert.async(), $fixture =$("#qunit-fixture");
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" value="5512123451234" />');
 		Inputmask("phone").mask(testmask);
 
@@ -78,7 +78,7 @@ define([
 	});
 
 	qunit.test("inputmask(\"phone\") - Brazil old", 1, function (assert) {
-		var done = assert.async(), $fixture =$("#qunit-fixture");
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" value="55121234-1234" />');
 		Inputmask("phone").mask(testmask);
 
@@ -89,7 +89,7 @@ define([
 	});
 
 	qunit.test("inputmask(\"phone\") - Brazil switch", 1, function (assert) {
-		var done = assert.async(), $fixture =$("#qunit-fixture");
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" value="55121234-1234" />');
 		Inputmask("phone").mask(testmask);
 
@@ -108,4 +108,20 @@ define([
 		}, 0);
 	});
 
+	qunit.test("inputmask(\"phone\") - russian backspace", 1, function (assert) {
+		var done = assert.async(), $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		Inputmask("phone", { nullable: false }).mask(testmask);
+
+		testmask.focus();
+		$("#testmask").Type("71");
+		$("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
+		$("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
+
+		setTimeout(function () {
+			equal(testmask.value, "+_(___)___-____", "Result " + testmask.value);
+			done();
+		}, 0);
+	});
+
 });