ソースを参照

Update on colorMask #1393

Robin Herbots 9 年 前
コミット
a45d3f42e7

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.3.4-27",
+  "version": "3.3.4-32",
   "main": [
 	  "./dist/inputmask/inputmask.loader.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.4-27",
+  "version": "3.3.4-32",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "main": "./dist/inputmask/inputmask.loader.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.4-27",
+  "version": "3.3.4-32",
   "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.4-27
+* Version: 3.3.4-32
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/inputmask.dependencyLib.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.4-27
+* Version: 3.3.4-32
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define("inputmask.dependencyLib", [ "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.4-27
+* Version: 3.3.4-32
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 32 - 16
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.4-27
+* Version: 3.3.4-32
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define("inputmask", [ "inputmask.dependencyLib" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib")) : factory(window.dependencyLib || jQuery);
@@ -523,7 +523,7 @@
                         $.each(rslt.insert.sort(function(a, b) {
                             return a - b;
                         }), function(ndx, lmnt) {
-                            isValid(lmnt.pos, lmnt.c, !1, fromSetValid);
+                            isValid(lmnt.pos, lmnt.c, !0, fromSetValid);
                         })), rslt.refreshFromBuffer) {
                             var refresh = rslt.refreshFromBuffer;
                             if (strict = !0, refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, possibleModifiedBuffer), 
@@ -1154,15 +1154,31 @@
             }, 0);
         }
         function initializeColorMask(input) {
-            var computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null);
-            colorMask = document.createElement("span"), colorMask.style.position = "absolute", 
-            colorMask.style.top = input.clientTop + "px",
-            colorMask.style.left = input.clientLeft + parseInt(computedStyle.paddingLeft) + 'px',
-            colorMask.style.lineHeight = input.clientHeight + "px",
-            colorMask.style.color = computedStyle.color, colorMask.style.fontSize = computedStyle.fontSize, 
-            colorMask.style.fontStyle = computedStyle.fontStyle, colorMask.style.fontFamily = computedStyle.fontFamily, 
-            colorMask.style.letterSpacing = computedStyle.letterSpacing, input.style.color = "transparent", 
-            input.style.backgroundColor = "transparent", input.parentNode.insertBefore(colorMask, input.nextSibling);
+            function charSize() {
+                var e = document.createElement("span"), width = 0;
+                return e.style.visibility = "hidden", e.style.whiteSpace = "nowrap", e.style.fontSize = computedStyle.fontSize, 
+                e.style.fontFamily = computedStyle.fontFamily, e.innerHTML = "0", input.parentNode.insertBefore(e, input.nextSibling), 
+                width = e.offsetWidth, input.parentNode.removeChild(e), width;
+            }
+            var offset = $(input).position(), computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null);
+            colorMask = document.createElement("div"), colorMask.style.position = "absolute", 
+            colorMask.style.top = offset.top + parseInt(computedStyle.borderTopWidth) + parseInt(computedStyle.paddingTop) + "px", 
+            colorMask.style.left = offset.left + parseInt(computedStyle.borderLeftWidth) + parseInt(computedStyle.paddingLeft) + "px", 
+            colorMask.style.width = computedStyle.width, colorMask.style.height = computedStyle.height, 
+            colorMask.style.color = computedStyle.color, colorMask.style.backgroundColor = computedStyle.backgroundColor, 
+            colorMask.style.fontSize = computedStyle.fontSize, colorMask.style.fontStyle = computedStyle.fontStyle, 
+            colorMask.style.fontFamily = computedStyle.fontFamily, colorMask.style.letterSpacing = computedStyle.letterSpacing, 
+            input.style.color = "transparent", input.parentNode.insertBefore(colorMask, input.nextSibling), 
+            $(window).on("resize", function(e) {
+                offset = $(input).position(), computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null), 
+                colorMask.style.top = offset.top + parseInt(computedStyle.borderTopWidth) + parseInt(computedStyle.paddingTop) + "px", 
+                colorMask.style.left = offset.left + parseInt(computedStyle.borderLeftWidth) + parseInt(computedStyle.paddingLeft) + "px", 
+                colorMask.style.width = computedStyle.width, colorMask.style.height = computedStyle.height;
+            }), EventRuler.off(input, "mouseenter"), $(input.nextSibling).on("mouseenter", function(e) {
+                mouseenterEvent.call(input, e);
+            }), $(input.nextSibling).on("click", function(e) {
+                input.focus(), caret(input, Math.floor(e.clientX / charSize())), $(input).trigger("click");
+            });
         }
         function renderColorMask(input, buffer, caretPos) {
             function handleStatic() {
@@ -1190,11 +1206,11 @@
             if (el = elem, $el = $(el), opts.showTooltip && (el.title = opts.tooltip || getMaskSet().mask), 
             ("rtl" === el.dir || opts.rightAlign) && (el.style.textAlign = "right"), ("rtl" === el.dir || opts.numericInput) && (el.dir = "ltr", 
             el.removeAttribute("dir"), el.inputmask.isRTL = !0, isRTL = !0), opts.colorMask === !0 && initializeColorMask(el), 
-            android && (el.hasOwnProperty("inputmode") || el.hasOwnProperty("x-inputmode") ? (el.inputmode = opts.inputmode, 
-            el["x-inputmode"] = opts.inputmode) : (el.type = "password", initializeColorMask(el), 
-            el.style.letterSpacing = "1px")), EventRuler.off(el), patchValueProperty(el), isElementTypeSupported(el, opts) && (EventRuler.on(el, "submit", submitEvent), 
-            EventRuler.on(el, "reset", resetEvent), EventRuler.on(el, "mouseenter", mouseenterEvent), 
-            EventRuler.on(el, "blur", blurEvent), EventRuler.on(el, "focus", focusEvent), EventRuler.on(el, "mouseleave", mouseleaveEvent), 
+            android && (el.hasOwnProperty("inputmode") ? (el.inputmode = opts.inputmode, el.setAttribute("inputmode", opts.inputmode)) : (el.type = "password", 
+            opts.colorMask !== !0 && initializeColorMask(el))), EventRuler.off(el), patchValueProperty(el), 
+            isElementTypeSupported(el, opts) && (EventRuler.on(el, "submit", submitEvent), EventRuler.on(el, "reset", resetEvent), 
+            EventRuler.on(el, "mouseenter", mouseenterEvent), EventRuler.on(el, "blur", blurEvent), 
+            EventRuler.on(el, "focus", focusEvent), EventRuler.on(el, "mouseleave", mouseleaveEvent), 
             EventRuler.on(el, "click", clickEvent), EventRuler.on(el, "dblclick", dblclickEvent), 
             EventRuler.on(el, "paste", pasteEvent), EventRuler.on(el, "dragdrop", pasteEvent), 
             EventRuler.on(el, "drop", pasteEvent), EventRuler.on(el, "cut", cutEvent), EventRuler.on(el, "complete", opts.oncomplete), 

ファイルの差分が大きいため隠しています
+ 1 - 1
dist/inputmask/inputmask.loader.js


+ 29 - 26
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.4-27
+* Version: 3.3.4-32
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);
@@ -29,14 +29,14 @@
                 opts.definitions[";"] = opts.definitions["~"], opts.definitions[";"].definitionSymbol = "~", 
                 opts.numericInput === !0 && (opts.positionCaretOnClick = "radixFocus" === opts.positionCaretOnClick ? "lvp" : opts.positionCaretOnClick, 
                 opts.digitsOptional = !1, isNaN(opts.digits) && (opts.digits = 2), opts.decimalProtect = !1);
-                var mask = autoEscape(opts.prefix);
-                if (mask += "[+]", mask += opts.integerOptional === !0 ? "~{1," + opts.integerDigits + "}" : "~{" + opts.integerDigits + "}", 
+                var mask = "[+]";
+                if (mask += autoEscape(opts.prefix), mask += opts.integerOptional === !0 ? "~{1," + opts.integerDigits + "}" : "~{" + opts.integerDigits + "}", 
                 void 0 !== opts.digits) {
                     opts.decimalProtect && (opts.radixPointDefinitionSymbol = ":");
                     var dq = opts.digits.toString().split(",");
                     isFinite(dq[0] && dq[1] && isFinite(dq[1])) ? mask += (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}" : (isNaN(opts.digits) || parseInt(opts.digits) > 0) && (mask += opts.digitsOptional ? "[" + (opts.decimalProtect ? ":" : opts.radixPoint) + ";{1," + opts.digits + "}]" : (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}");
                 }
-                return mask += "[-]", mask += autoEscape(opts.suffix), opts.greedy = !1, null !== opts.min && (opts.min = opts.min.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""), 
+                return mask += autoEscape(opts.suffix), mask += "[-]", opts.greedy = !1, null !== opts.min && (opts.min = opts.min.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""), 
                 "," === opts.radixPoint && (opts.min = opts.min.replace(opts.radixPoint, "."))), 
                 null !== opts.max && (opts.max = opts.max.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""), 
                 "," === opts.radixPoint && (opts.max = opts.max.replace(opts.radixPoint, "."))), 
@@ -77,8 +77,10 @@
                 var charAtPos = buffer[pos], cbuf = buffer.slice();
                 charAtPos === opts.groupSeparator && (cbuf.splice(pos--, 1), charAtPos = cbuf[pos]), 
                 cbuf[pos] = "!";
-                var bufVal = cbuf.join(""), bufValOrigin = bufVal;
-                if (bufVal = bufVal.replace(new RegExp(Inputmask.escapeRegex(opts.suffix) + "$"), ""), 
+                var bufVal = cbuf.join(""), bufValOrigin = bufVal, isNegative = bufVal.match(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)));
+                if (isNegative = null !== isNegative && 1 === isNegative.length, isNegative && (bufVal = bufVal.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), ""), 
+                bufVal = bufVal.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), "")), 
+                bufVal = bufVal.replace(new RegExp(Inputmask.escapeRegex(opts.suffix) + "$"), ""), 
                 bufVal = bufVal.replace(new RegExp("^" + Inputmask.escapeRegex(opts.prefix)), ""), 
                 bufVal.length > 0 && opts.autoGroup || bufVal.indexOf(opts.groupSeparator) !== -1) {
                     var escapedGroupSeparator = Inputmask.escapeRegex(opts.groupSeparator);
@@ -89,7 +91,7 @@
                     bufVal = bufVal.replace(opts.groupSeparator + opts.groupSeparator, opts.groupSeparator);
                     bufVal = bufVal.replace("?", "!"), "" !== opts.radixPoint && radixSplit.length > 1 && (bufVal += (charAtPos === opts.radixPoint ? "!" : opts.radixPoint) + radixSplit[1]);
                 }
-                bufVal = opts.prefix + bufVal + opts.suffix;
+                bufVal = opts.prefix + bufVal + opts.suffix, isNegative && (bufVal = opts.negationSymbol.front + bufVal + opts.negationSymbol.back);
                 var needsRefresh = bufValOrigin !== bufVal;
                 if (needsRefresh) for (buffer.length = bufVal.length, i = 0, l = bufVal.length; i < l; i++) buffer[i] = bufVal.charAt(i);
                 var newPos = $.inArray("!", bufVal);
@@ -123,9 +125,10 @@
                             for (var i = 1; i <= opts.digits; i++) opts.digitsOptional || void 0 !== processValue[radixPosition + i] && processValue[radixPosition + i] !== opts.placeholder.charAt(0) ? rpb !== -1 && void 0 !== maskedValue[rpb + i] && (processValue[radixPosition + i] = processValue[radixPosition + i] || maskedValue[rpb + i]) : processValue[radixPosition + i] = "0";
                             processValue[processValue.length - 1] === opts.radixPoint && delete processValue[processValue.length - 1];
                         }
-                        if (floatValue.toString() !== processValue && floatValue.toString() + "." !== processValue || isNegative) return !isNegative || 0 === floatValue && "blur" === e.type || (processValue.unshift(opts.negationSymbol.front), 
-                        processValue.push(opts.negationSymbol.back)), processValue = (opts.prefix + processValue.join("")).split(""), 
-                        opts.numericInput && (processValue = processValue.reverse()), rslt = opts.postFormat(processValue, opts.numericInput ? caretPos : caretPos - 1, opts), 
+                        if (floatValue.toString() !== processValue && floatValue.toString() + "." !== processValue || isNegative) return processValue = (opts.prefix + processValue.join("")).split(""), 
+                        !isNegative || 0 === floatValue && "blur" === e.type || (processValue.unshift(opts.negationSymbol.front), 
+                        processValue.push(opts.negationSymbol.back)), opts.numericInput && (processValue = processValue.reverse()), 
+                        rslt = opts.postFormat(processValue, opts.numericInput ? caretPos : caretPos - 1, opts), 
                         rslt.buffer && (rslt.refreshFromBuffer = rslt.buffer.join("") !== buffer.join("")), 
                         rslt;
                     }
@@ -145,49 +148,49 @@
                 if (!strict && opts.allowMinus && "-" === chrs || opts.allowPlus && "+" === chrs) {
                     var matchRslt = maskset.buffer.join("").match(opts.regex.integerPart(opts));
                     if (matchRslt && matchRslt[0].length > 0) return maskset.buffer[matchRslt.index] === ("-" === chrs ? "+" : opts.negationSymbol.front) ? "-" === chrs ? "" !== opts.negationSymbol.back ? {
-                        pos: matchRslt.index,
+                        pos: 0,
                         c: opts.negationSymbol.front,
-                        remove: matchRslt.index,
+                        remove: 0,
                         caret: pos,
                         insert: {
-                            pos: maskset.buffer.length - opts.suffix.length - 1,
+                            pos: maskset.buffer.length - 1,
                             c: opts.negationSymbol.back
                         }
                     } : {
-                        pos: matchRslt.index,
+                        pos: 0,
                         c: opts.negationSymbol.front,
-                        remove: matchRslt.index,
+                        remove: 0,
                         caret: pos
                     } : "" !== opts.negationSymbol.back ? {
-                        pos: matchRslt.index,
+                        pos: 0,
                         c: "+",
-                        remove: [ matchRslt.index, maskset.buffer.length - opts.suffix.length - 1 ],
+                        remove: [ 0, maskset.buffer.length - 1 ],
                         caret: pos
                     } : {
-                        pos: matchRslt.index,
+                        pos: 0,
                         c: "+",
-                        remove: matchRslt.index,
+                        remove: 0,
                         caret: pos
-                    } : maskset.buffer[matchRslt.index] === ("-" === chrs ? opts.negationSymbol.front : "+") ? "-" === chrs && "" !== opts.negationSymbol.back ? {
-                        remove: [ matchRslt.index, maskset.buffer.length - opts.suffix.length - 1 ],
+                    } : maskset.buffer[0] === ("-" === chrs ? opts.negationSymbol.front : "+") ? "-" === chrs && "" !== opts.negationSymbol.back ? {
+                        remove: [ 0, maskset.buffer.length - 1 ],
                         caret: pos - 1
                     } : {
-                        remove: matchRslt.index,
+                        remove: 0,
                         caret: pos - 1
                     } : "-" === chrs ? "" !== opts.negationSymbol.back ? {
-                        pos: matchRslt.index,
+                        pos: 0,
                         c: opts.negationSymbol.front,
                         caret: pos + 1,
                         insert: {
-                            pos: maskset.buffer.length - opts.suffix.length,
+                            pos: maskset.buffer.length,
                             c: opts.negationSymbol.back
                         }
                     } : {
-                        pos: matchRslt.index,
+                        pos: 0,
                         c: opts.negationSymbol.front,
                         caret: pos + 1
                     } : {
-                        pos: matchRslt.index,
+                        pos: 0,
                         c: chrs,
                         caret: pos + 1
                     };

+ 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.4-27
+* Version: 3.3.4-32
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), 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.4-27
+* Version: 3.3.4-32
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), 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.4-27
+* Version: 3.3.4-32
 */
 !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);

+ 60 - 41
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.4-27
+* Version: 3.3.4-32
 */
 !function($) {
     function Inputmask(alias, options) {
@@ -521,7 +521,7 @@
                         $.each(rslt.insert.sort(function(a, b) {
                             return a - b;
                         }), function(ndx, lmnt) {
-                            isValid(lmnt.pos, lmnt.c, !1, fromSetValid);
+                            isValid(lmnt.pos, lmnt.c, !0, fromSetValid);
                         })), rslt.refreshFromBuffer) {
                             var refresh = rslt.refreshFromBuffer;
                             if (strict = !0, refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, possibleModifiedBuffer), 
@@ -1152,15 +1152,31 @@
             }, 0);
         }
         function initializeColorMask(input) {
-            var computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null);
-            colorMask = document.createElement("span"), colorMask.style.position = "absolute", 
-            colorMask.style.top = input.clientTop + "px",
-            colorMask.style.left = input.clientLeft + parseInt(computedStyle.paddingLeft) + 'px',
-            colorMask.style.lineHeight = input.clientHeight + "px",
-            colorMask.style.color = computedStyle.color, colorMask.style.fontSize = computedStyle.fontSize, 
-            colorMask.style.fontStyle = computedStyle.fontStyle, colorMask.style.fontFamily = computedStyle.fontFamily, 
-            colorMask.style.letterSpacing = computedStyle.letterSpacing, input.style.color = "transparent", 
-            input.style.backgroundColor = "transparent", input.parentNode.insertBefore(colorMask, input.nextSibling);
+            function charSize() {
+                var e = document.createElement("span"), width = 0;
+                return e.style.visibility = "hidden", e.style.whiteSpace = "nowrap", e.style.fontSize = computedStyle.fontSize, 
+                e.style.fontFamily = computedStyle.fontFamily, e.innerHTML = "0", input.parentNode.insertBefore(e, input.nextSibling), 
+                width = e.offsetWidth, input.parentNode.removeChild(e), width;
+            }
+            var offset = $(input).position(), computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null);
+            colorMask = document.createElement("div"), colorMask.style.position = "absolute", 
+            colorMask.style.top = offset.top + parseInt(computedStyle.borderTopWidth) + parseInt(computedStyle.paddingTop) + "px", 
+            colorMask.style.left = offset.left + parseInt(computedStyle.borderLeftWidth) + parseInt(computedStyle.paddingLeft) + "px", 
+            colorMask.style.width = computedStyle.width, colorMask.style.height = computedStyle.height, 
+            colorMask.style.color = computedStyle.color, colorMask.style.backgroundColor = computedStyle.backgroundColor, 
+            colorMask.style.fontSize = computedStyle.fontSize, colorMask.style.fontStyle = computedStyle.fontStyle, 
+            colorMask.style.fontFamily = computedStyle.fontFamily, colorMask.style.letterSpacing = computedStyle.letterSpacing, 
+            input.style.color = "transparent", input.parentNode.insertBefore(colorMask, input.nextSibling), 
+            $(window).on("resize", function(e) {
+                offset = $(input).position(), computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null), 
+                colorMask.style.top = offset.top + parseInt(computedStyle.borderTopWidth) + parseInt(computedStyle.paddingTop) + "px", 
+                colorMask.style.left = offset.left + parseInt(computedStyle.borderLeftWidth) + parseInt(computedStyle.paddingLeft) + "px", 
+                colorMask.style.width = computedStyle.width, colorMask.style.height = computedStyle.height;
+            }), EventRuler.off(input, "mouseenter"), $(input.nextSibling).on("mouseenter", function(e) {
+                mouseenterEvent.call(input, e);
+            }), $(input.nextSibling).on("click", function(e) {
+                input.focus(), caret(input, Math.floor(e.clientX / charSize())), $(input).trigger("click");
+            });
         }
         function renderColorMask(input, buffer, caretPos) {
             function handleStatic() {
@@ -1188,11 +1204,11 @@
             if (el = elem, $el = $(el), opts.showTooltip && (el.title = opts.tooltip || getMaskSet().mask), 
             ("rtl" === el.dir || opts.rightAlign) && (el.style.textAlign = "right"), ("rtl" === el.dir || opts.numericInput) && (el.dir = "ltr", 
             el.removeAttribute("dir"), el.inputmask.isRTL = !0, isRTL = !0), opts.colorMask === !0 && initializeColorMask(el), 
-            android && (el.hasOwnProperty("inputmode") || el.hasOwnProperty("x-inputmode") ? (el.inputmode = opts.inputmode, 
-            el["x-inputmode"] = opts.inputmode) : (el.type = "password", initializeColorMask(el), 
-            el.style.letterSpacing = "1px")), EventRuler.off(el), patchValueProperty(el), isElementTypeSupported(el, opts) && (EventRuler.on(el, "submit", submitEvent), 
-            EventRuler.on(el, "reset", resetEvent), EventRuler.on(el, "mouseenter", mouseenterEvent), 
-            EventRuler.on(el, "blur", blurEvent), EventRuler.on(el, "focus", focusEvent), EventRuler.on(el, "mouseleave", mouseleaveEvent), 
+            android && (el.hasOwnProperty("inputmode") ? (el.inputmode = opts.inputmode, el.setAttribute("inputmode", opts.inputmode)) : (el.type = "password", 
+            opts.colorMask !== !0 && initializeColorMask(el))), EventRuler.off(el), patchValueProperty(el), 
+            isElementTypeSupported(el, opts) && (EventRuler.on(el, "submit", submitEvent), EventRuler.on(el, "reset", resetEvent), 
+            EventRuler.on(el, "mouseenter", mouseenterEvent), EventRuler.on(el, "blur", blurEvent), 
+            EventRuler.on(el, "focus", focusEvent), EventRuler.on(el, "mouseleave", mouseleaveEvent), 
             EventRuler.on(el, "click", clickEvent), EventRuler.on(el, "dblclick", dblclickEvent), 
             EventRuler.on(el, "paste", pasteEvent), EventRuler.on(el, "dragdrop", pasteEvent), 
             EventRuler.on(el, "drop", pasteEvent), EventRuler.on(el, "cut", cutEvent), EventRuler.on(el, "complete", opts.oncomplete), 
@@ -2191,14 +2207,14 @@
                 opts.definitions[";"] = opts.definitions["~"], opts.definitions[";"].definitionSymbol = "~", 
                 opts.numericInput === !0 && (opts.positionCaretOnClick = "radixFocus" === opts.positionCaretOnClick ? "lvp" : opts.positionCaretOnClick, 
                 opts.digitsOptional = !1, isNaN(opts.digits) && (opts.digits = 2), opts.decimalProtect = !1);
-                var mask = autoEscape(opts.prefix);
-                if (mask += "[+]", mask += opts.integerOptional === !0 ? "~{1," + opts.integerDigits + "}" : "~{" + opts.integerDigits + "}", 
+                var mask = "[+]";
+                if (mask += autoEscape(opts.prefix), mask += opts.integerOptional === !0 ? "~{1," + opts.integerDigits + "}" : "~{" + opts.integerDigits + "}", 
                 void 0 !== opts.digits) {
                     opts.decimalProtect && (opts.radixPointDefinitionSymbol = ":");
                     var dq = opts.digits.toString().split(",");
                     isFinite(dq[0] && dq[1] && isFinite(dq[1])) ? mask += (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}" : (isNaN(opts.digits) || parseInt(opts.digits) > 0) && (mask += opts.digitsOptional ? "[" + (opts.decimalProtect ? ":" : opts.radixPoint) + ";{1," + opts.digits + "}]" : (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}");
                 }
-                return mask += "[-]", mask += autoEscape(opts.suffix), opts.greedy = !1, null !== opts.min && (opts.min = opts.min.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""), 
+                return mask += autoEscape(opts.suffix), mask += "[-]", opts.greedy = !1, null !== opts.min && (opts.min = opts.min.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""), 
                 "," === opts.radixPoint && (opts.min = opts.min.replace(opts.radixPoint, "."))), 
                 null !== opts.max && (opts.max = opts.max.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""), 
                 "," === opts.radixPoint && (opts.max = opts.max.replace(opts.radixPoint, "."))), 
@@ -2239,8 +2255,10 @@
                 var charAtPos = buffer[pos], cbuf = buffer.slice();
                 charAtPos === opts.groupSeparator && (cbuf.splice(pos--, 1), charAtPos = cbuf[pos]), 
                 cbuf[pos] = "!";
-                var bufVal = cbuf.join(""), bufValOrigin = bufVal;
-                if (bufVal = bufVal.replace(new RegExp(Inputmask.escapeRegex(opts.suffix) + "$"), ""), 
+                var bufVal = cbuf.join(""), bufValOrigin = bufVal, isNegative = bufVal.match(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)));
+                if (isNegative = null !== isNegative && 1 === isNegative.length, isNegative && (bufVal = bufVal.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), ""), 
+                bufVal = bufVal.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), "")), 
+                bufVal = bufVal.replace(new RegExp(Inputmask.escapeRegex(opts.suffix) + "$"), ""), 
                 bufVal = bufVal.replace(new RegExp("^" + Inputmask.escapeRegex(opts.prefix)), ""), 
                 bufVal.length > 0 && opts.autoGroup || bufVal.indexOf(opts.groupSeparator) !== -1) {
                     var escapedGroupSeparator = Inputmask.escapeRegex(opts.groupSeparator);
@@ -2251,7 +2269,7 @@
                     bufVal = bufVal.replace(opts.groupSeparator + opts.groupSeparator, opts.groupSeparator);
                     bufVal = bufVal.replace("?", "!"), "" !== opts.radixPoint && radixSplit.length > 1 && (bufVal += (charAtPos === opts.radixPoint ? "!" : opts.radixPoint) + radixSplit[1]);
                 }
-                bufVal = opts.prefix + bufVal + opts.suffix;
+                bufVal = opts.prefix + bufVal + opts.suffix, isNegative && (bufVal = opts.negationSymbol.front + bufVal + opts.negationSymbol.back);
                 var needsRefresh = bufValOrigin !== bufVal;
                 if (needsRefresh) for (buffer.length = bufVal.length, i = 0, l = bufVal.length; i < l; i++) buffer[i] = bufVal.charAt(i);
                 var newPos = $.inArray("!", bufVal);
@@ -2285,9 +2303,10 @@
                             for (var i = 1; i <= opts.digits; i++) opts.digitsOptional || void 0 !== processValue[radixPosition + i] && processValue[radixPosition + i] !== opts.placeholder.charAt(0) ? rpb !== -1 && void 0 !== maskedValue[rpb + i] && (processValue[radixPosition + i] = processValue[radixPosition + i] || maskedValue[rpb + i]) : processValue[radixPosition + i] = "0";
                             processValue[processValue.length - 1] === opts.radixPoint && delete processValue[processValue.length - 1];
                         }
-                        if (floatValue.toString() !== processValue && floatValue.toString() + "." !== processValue || isNegative) return !isNegative || 0 === floatValue && "blur" === e.type || (processValue.unshift(opts.negationSymbol.front), 
-                        processValue.push(opts.negationSymbol.back)), processValue = (opts.prefix + processValue.join("")).split(""), 
-                        opts.numericInput && (processValue = processValue.reverse()), rslt = opts.postFormat(processValue, opts.numericInput ? caretPos : caretPos - 1, opts), 
+                        if (floatValue.toString() !== processValue && floatValue.toString() + "." !== processValue || isNegative) return processValue = (opts.prefix + processValue.join("")).split(""), 
+                        !isNegative || 0 === floatValue && "blur" === e.type || (processValue.unshift(opts.negationSymbol.front), 
+                        processValue.push(opts.negationSymbol.back)), opts.numericInput && (processValue = processValue.reverse()), 
+                        rslt = opts.postFormat(processValue, opts.numericInput ? caretPos : caretPos - 1, opts), 
                         rslt.buffer && (rslt.refreshFromBuffer = rslt.buffer.join("") !== buffer.join("")), 
                         rslt;
                     }
@@ -2307,49 +2326,49 @@
                 if (!strict && opts.allowMinus && "-" === chrs || opts.allowPlus && "+" === chrs) {
                     var matchRslt = maskset.buffer.join("").match(opts.regex.integerPart(opts));
                     if (matchRslt && matchRslt[0].length > 0) return maskset.buffer[matchRslt.index] === ("-" === chrs ? "+" : opts.negationSymbol.front) ? "-" === chrs ? "" !== opts.negationSymbol.back ? {
-                        pos: matchRslt.index,
+                        pos: 0,
                         c: opts.negationSymbol.front,
-                        remove: matchRslt.index,
+                        remove: 0,
                         caret: pos,
                         insert: {
-                            pos: maskset.buffer.length - opts.suffix.length - 1,
+                            pos: maskset.buffer.length - 1,
                             c: opts.negationSymbol.back
                         }
                     } : {
-                        pos: matchRslt.index,
+                        pos: 0,
                         c: opts.negationSymbol.front,
-                        remove: matchRslt.index,
+                        remove: 0,
                         caret: pos
                     } : "" !== opts.negationSymbol.back ? {
-                        pos: matchRslt.index,
+                        pos: 0,
                         c: "+",
-                        remove: [ matchRslt.index, maskset.buffer.length - opts.suffix.length - 1 ],
+                        remove: [ 0, maskset.buffer.length - 1 ],
                         caret: pos
                     } : {
-                        pos: matchRslt.index,
+                        pos: 0,
                         c: "+",
-                        remove: matchRslt.index,
+                        remove: 0,
                         caret: pos
-                    } : maskset.buffer[matchRslt.index] === ("-" === chrs ? opts.negationSymbol.front : "+") ? "-" === chrs && "" !== opts.negationSymbol.back ? {
-                        remove: [ matchRslt.index, maskset.buffer.length - opts.suffix.length - 1 ],
+                    } : maskset.buffer[0] === ("-" === chrs ? opts.negationSymbol.front : "+") ? "-" === chrs && "" !== opts.negationSymbol.back ? {
+                        remove: [ 0, maskset.buffer.length - 1 ],
                         caret: pos - 1
                     } : {
-                        remove: matchRslt.index,
+                        remove: 0,
                         caret: pos - 1
                     } : "-" === chrs ? "" !== opts.negationSymbol.back ? {
-                        pos: matchRslt.index,
+                        pos: 0,
                         c: opts.negationSymbol.front,
                         caret: pos + 1,
                         insert: {
-                            pos: maskset.buffer.length - opts.suffix.length,
+                            pos: maskset.buffer.length,
                             c: opts.negationSymbol.back
                         }
                     } : {
-                        pos: matchRslt.index,
+                        pos: 0,
                         c: opts.negationSymbol.front,
                         caret: pos + 1
                     } : {
-                        pos: matchRslt.index,
+                        pos: 0,
                         c: chrs,
                         caret: pos + 1
                     };

ファイルの差分が大きいため隠しています
+ 1 - 1
dist/min/inputmask/inputmask.date.extensions.min.js


+ 1 - 1
dist/min/inputmask/inputmask.dependencyLib.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.4-27
+* Version: 3.3.4-32
 */
 !function(a){"function"==typeof define&&define.amd?define("inputmask.dependencyLib",["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


ファイルの差分が大きいため隠しています
+ 1 - 1
dist/min/inputmask/inputmask.loader.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


+ 50 - 17
js/inputmask.js

@@ -1347,7 +1347,7 @@
 								$.each(rslt.insert.sort(function (a, b) {
 									return a - b;
 								}), function (ndx, lmnt) {
-									isValid(lmnt.pos, lmnt.c, false, fromSetValid);
+									isValid(lmnt.pos, lmnt.c, true, fromSetValid);
 								});
 							}
 
@@ -2706,28 +2706,61 @@
 		}
 
 		function initializeColorMask(input) {
-			// needs computedstyle
-			var offset = input.getBoundingClientRect();
-			var computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null);
-
-			colorMask = document.createElement("span");
+			function charSize() {
+				//calculate text width
+				var e = document.createElement('span'), width = 0;
+				e.style.visibility = "hidden";
+				e.style.whiteSpace = "nowrap";
+				e.style.fontSize = computedStyle.fontSize;
+				e.style.fontFamily = computedStyle.fontFamily;
+				e.innerHTML = "0";
+				input.parentNode.insertBefore(e, input.nextSibling);
+				width = e.offsetWidth;
+				input.parentNode.removeChild(e);
+				return width;
+			}
+
+			var offset = $(input).position(),
+				computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null);
+
+			colorMask = document.createElement("div");
 			//positioning
 			colorMask.style.position = "absolute";
-			colorMask.width = (offset.width ? offset.width : offset.right - offset.left) + "px";
-			colorMask.height = (offset.height ? offset.height : offset.bottom - offset.top) + "px";
-			colorMask.style.top = offset.top + parseInt(computedStyle.borderTopWidth) + 'px';
-			colorMask.style.left = offset.left + parseInt(computedStyle.borderLeftWidth) + 'px';
-			colorMask.style.zIndex = isNaN(computedStyle.zIndex) ? -1 : computedStyle.zIndex - 1;
+			colorMask.style.top = offset.top + parseInt(computedStyle.borderTopWidth) + parseInt(computedStyle.paddingTop) + 'px';
+			colorMask.style.left = offset.left + parseInt(computedStyle.borderLeftWidth) + parseInt(computedStyle.paddingLeft) + 'px';
+			colorMask.style.width = computedStyle.width;
+			colorMask.style.height = computedStyle.height;
 			//styling
 			colorMask.style.color = computedStyle.color;
+			colorMask.style.backgroundColor = computedStyle.backgroundColor;
 			colorMask.style.fontSize = computedStyle.fontSize;
 			colorMask.style.fontStyle = computedStyle.fontStyle;
 			colorMask.style.fontFamily = computedStyle.fontFamily;
 			colorMask.style.letterSpacing = computedStyle.letterSpacing;
 
 			input.style.color = "transparent";
-			input.style.backgroundColor = "transparent";
 			input.parentNode.insertBefore(colorMask, input.nextSibling);
+
+			//event passthrough
+			$(window).on("resize", function (e) {
+				offset = $(input).position();
+				computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null);
+
+				//positioning
+				colorMask.style.top = offset.top + parseInt(computedStyle.borderTopWidth) + parseInt(computedStyle.paddingTop) + 'px';
+				colorMask.style.left = offset.left + parseInt(computedStyle.borderLeftWidth) + parseInt(computedStyle.paddingLeft) + 'px';
+				colorMask.style.width = computedStyle.width;
+				colorMask.style.height = computedStyle.height;
+			});
+			EventRuler.off(input, "mouseenter");
+			$(input.nextSibling).on("mouseenter", function (e) {
+				mouseenterEvent.call(input, e);
+			});
+			$(input.nextSibling).on("click", function (e) {
+				input.focus();
+				caret(input, Math.floor(e.clientX / charSize()));
+				$(input).trigger("click");
+			});
 		}
 
 		function renderColorMask(input, buffer, caretPos) {
@@ -2804,13 +2837,13 @@
 			}
 
 			if (android) {
-				if (el.hasOwnProperty("inputmode") || el.hasOwnProperty("x-inputmode")) {
-					el["inputmode"] = opts.inputmode;
-					el["x-inputmode"] = opts.inputmode;
+				if (el.hasOwnProperty("inputmode")) {
+					el.inputmode = opts.inputmode;
+					el.setAttribute("inputmode", opts.inputmode);
 				} else {
 					el.type = "password";
-					initializeColorMask(el);
-					el.style.letterSpacing = "1px"; //forced spacing
+					if (opts.colorMask !== true)
+						initializeColorMask(el);
 				}
 			}
 

+ 33 - 23
js/inputmask.numeric.extensions.js

@@ -83,8 +83,9 @@
 					opts.decimalProtect = false;
 				}
 
-				var mask = autoEscape(opts.prefix);
-				mask += "[+]";
+				var mask = "[+]";
+				mask += autoEscape(opts.prefix);
+
 				if (opts.integerOptional === true) {
 					mask += "~{1," + opts.integerDigits + "}";
 				} else mask += "~{" + opts.integerDigits + "}";
@@ -99,8 +100,8 @@
 						} else mask += (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}";
 					}
 				}
-				mask += "[-]";
 				mask += autoEscape(opts.suffix);
+				mask += "[-]";
 
 				opts.greedy = false; //enforce greedy false
 
@@ -168,6 +169,13 @@
 				//mark current pos
 				cbuf[pos] = "!";
 				var bufVal = cbuf.join(""), bufValOrigin = bufVal;
+				var isNegative = bufVal.match(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)));
+				isNegative = isNegative !== null && isNegative.length === 1;
+
+				if (isNegative) {
+					bufVal = bufVal.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), "");
+					bufVal = bufVal.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), "");
+				}
 
 				bufVal = bufVal.replace(new RegExp(Inputmask.escapeRegex(opts.suffix) + "$"), "");
 				bufVal = bufVal.replace(new RegExp("^" + Inputmask.escapeRegex(opts.prefix)), "");
@@ -191,7 +199,9 @@
 				}
 
 				bufVal = opts.prefix + bufVal + opts.suffix;
-
+				if (isNegative) {
+					bufVal = opts.negationSymbol.front + bufVal + opts.negationSymbol.back;
+				}
 
 				var needsRefresh = bufValOrigin !== bufVal;
 				if (needsRefresh) {
@@ -273,11 +283,12 @@
 						}
 
 						if ((floatValue.toString() !== processValue && floatValue.toString() + "." !== processValue) || isNegative) {
+							processValue = (opts.prefix + processValue.join("")).split("");
 							if (isNegative && (floatValue !== 0 || e.type !== "blur")) {
 								processValue.unshift(opts.negationSymbol.front);
 								processValue.push(opts.negationSymbol.back);
 							}
-							processValue = (opts.prefix + processValue.join("")).split("");
+
 							if (opts.numericInput) processValue = processValue.reverse();
 							rslt = opts.postFormat(processValue, opts.numericInput ? caretPos : caretPos - 1, opts);
 							if (rslt.buffer) rslt.refreshFromBuffer = rslt.buffer.join("") !== buffer.join("");
@@ -311,49 +322,49 @@
 							if (chrs === "-") {
 								if (opts.negationSymbol.back !== "") {
 									return {
-										"pos": matchRslt.index,
+										"pos": 0,
 										"c": opts.negationSymbol.front,
-										"remove": matchRslt.index,
+										"remove": 0,
 										"caret": pos,
 										"insert": {
-											"pos": maskset.buffer.length - opts.suffix.length - 1,
+											"pos": maskset.buffer.length - 1,
 											"c": opts.negationSymbol.back
 										}
 									};
 								} else {
 									return {
-										"pos": matchRslt.index,
+										"pos": 0,
 										"c": opts.negationSymbol.front,
-										"remove": matchRslt.index,
+										"remove": 0,
 										"caret": pos
 									};
 								}
 							} else {
 								if (opts.negationSymbol.back !== "") {
 									return {
-										"pos": matchRslt.index,
+										"pos": 0,
 										"c": "+",
-										"remove": [matchRslt.index, maskset.buffer.length - opts.suffix.length - 1],
+										"remove": [0, maskset.buffer.length - 1],
 										"caret": pos
 									};
 								} else {
 									return {
-										"pos": matchRslt.index,
+										"pos": 0,
 										"c": "+",
-										"remove": matchRslt.index,
+										"remove": 0,
 										"caret": pos
 									};
 								}
 							}
-						} else if (maskset.buffer[matchRslt.index] === (chrs === "-" ? opts.negationSymbol.front : "+")) {
+						} else if (maskset.buffer[0] === (chrs === "-" ? opts.negationSymbol.front : "+")) {
 							if (chrs === "-" && opts.negationSymbol.back !== "") {
 								return {
-									"remove": [matchRslt.index, maskset.buffer.length - opts.suffix.length - 1],
+									"remove": [0, maskset.buffer.length - 1],
 									"caret": pos - 1
 								};
 							} else {
 								return {
-									"remove": matchRslt.index,
+									"remove": 0,
 									"caret": pos - 1
 								};
 							}
@@ -361,24 +372,24 @@
 							if (chrs === "-") {
 								if (opts.negationSymbol.back !== "") {
 									return {
-										"pos": matchRslt.index,
+										"pos": 0,
 										"c": opts.negationSymbol.front,
 										"caret": pos + 1,
 										"insert": {
-											"pos": maskset.buffer.length - opts.suffix.length,
+											"pos": maskset.buffer.length,
 											"c": opts.negationSymbol.back
 										}
 									};
 								} else {
 									return {
-										"pos": matchRslt.index,
+										"pos": 0,
 										"c": opts.negationSymbol.front,
 										"caret": pos + 1
 									};
 								}
 							} else {
 								return {
-									"pos": matchRslt.index,
+									"pos": 0,
 									"c": chrs,
 									"caret": pos + 1
 								};
@@ -387,8 +398,7 @@
 					}
 				}
 				return false;
-			}
-			,
+			},
 			radixHandler: function (chrs, maskset, pos, strict, opts) {
 				if (!strict && opts.numericInput !== true) {
 					//if ($.inArray(chrs, [",", "."]) !== -1) chrs = opts.radixPoint;

+ 1 - 1
package.json

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

+ 13 - 1
qunit/tests_numeric.js

@@ -1391,7 +1391,7 @@ define([
 		setTimeout(function () {
 			$("#testmask").Type("-1234");
 			$.caret(testmask, 0);
-			$("#testmask").SendKey(Inputmask.keyCode.DELETE);
+			// $("#testmask").SendKey(Inputmask.keyCode.DELETE);
 			assert.equal($("#testmask")[0].inputmask._valueGet(), "$ 1,234.00", "Result " + $("#testmask")[0].inputmask._valueGet());
 			done();
 		}, 0);
@@ -1829,4 +1829,16 @@ define([
 
 		assert.equal(testmask.value, "237,38", "Result " + testmask.value);
 	});
+
+	qunit.test("numeric + type -", function (assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask("currency", {negationSymbol: {front: "(", back: ")"}}).mask(testmask);
+		testmask.focus();
+		$.caret(testmask, 1);
+		$("#testmask").Type("-");
+
+		assert.equal(testmask.value, "($ 0.00)", "Result " + testmask.value);
+	});
 });

+ 3 - 3
qunit/tests_paste.js

@@ -130,7 +130,7 @@ define([
 		$("#testmask").paste("$-123.22");
 
 		setTimeout(function () {
-			assert.equal(testmask.value, "$ -123.22", "Result " + testmask.value);
+			assert.equal(testmask.value, "-$ 123.22", "Result " + testmask.value);
 			done();
 		}, 0);
 	});
@@ -158,7 +158,7 @@ define([
 		$("#testmask").paste("-1000.00");
 
 		setTimeout(function () {
-			assert.equal(testmask.value, "$ -1,000.00", "Result " + testmask.value);
+			assert.equal(testmask.value, "-$ 1,000.00", "Result " + testmask.value);
 			done();
 		}, 0);
 	});
@@ -186,7 +186,7 @@ define([
 		$("#testmask").paste("$-1000.00");
 
 		setTimeout(function () {
-			assert.equal(testmask.value, "$ -1,000.00", "Result " + testmask.value);
+			assert.equal(testmask.value, "-$ 1,000.00", "Result " + testmask.value);
 			done();
 		}, 0);
 	});