Browse Source

fix submit

Robin Herbots 10 years ago
parent
commit
1b6750f893

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.2.6-25",
+  "version": "3.2.6-26",
   "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.2.6-25",
+  "version": "3.2.6-26",
   "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.2.6-25",
+  "version": "3.2.6-26",
   "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 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.6-25
+* Version: 3.2.6-26
 */
 !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 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.6-25
+* Version: 3.2.6-26
 */
 !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 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.6-25
+* Version: 3.2.6-26
 */
 !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);

+ 2 - 2
dist/inputmask/inputmask.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.6-25
+* Version: 3.2.6-26
 */
 !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);
@@ -1123,7 +1123,7 @@
             on: function(input, eventName, eventHandler) {
                 var ev = function(e) {
                     var inComposition = !1, keydownPressed = !1;
-                    if (void 0 === this.inputmask) {
+                    if (void 0 === this.inputmask && "FORM" !== this.nodeName) {
                         var imOpts = $.data(this, "_inputmask_opts");
                         imOpts ? new Inputmask(imOpts).mask(this) : EventRuler.off(this);
                     } else {

File diff suppressed because it is too large
+ 20 - 112
dist/inputmask/inputmask.numeric.extensions.js


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

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

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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.6-25
+* Version: 3.2.6-26
 */
 !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 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.6-25
+* Version: 3.2.6-26
 */
 !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);

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


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


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

@@ -3,6 +3,6 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.6-25
+* Version: 3.2.6-26
 */
 !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});

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


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


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


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


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


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


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


+ 2 - 2
js/inputmask.js

@@ -117,7 +117,7 @@
 				canClearPosition: $.noop, //hook to alter the clear behavior in the stripValidPositions args => maskset, position, lastValidPosition, opts => return true|false
 				postValidation: null, //hook to postValidate the result from isValid.	Usefull for validating the entry as a whole.	args => buffer, opts => return true/false
 				staticDefinitionSymbol: undefined, //specify a definitionSymbol for static content, used to make matches for alternators
-				jitMasking: false, //just in time masking ~ only mask while typing, can n (number), true or false
+				jitMasking: false //just in time masking ~ only mask while typing, can n (number), true or false
 			},
 			masksCache: {},
 			mask: function(elems) {
@@ -1904,7 +1904,7 @@
 						// console.log("triggered " + e.type);
 						var inComposition = false,
 							keydownPressed = false;
-						if (this.inputmask === undefined) { //happens when cloning an object with jquery.clone
+						if (this.inputmask === undefined && this.nodeName !== "FORM") { //happens when cloning an object with jquery.clone
 							var imOpts = $.data(this, "_inputmask_opts");
 							if (imOpts)(new Inputmask(imOpts)).mask(this);
 							else EventRuler.off(this);

+ 124 - 181
js/inputmask.numeric.extensions.js

@@ -143,201 +143,148 @@ Optional extensions on the jquery.inputmask base
 								};
 							}
 						}
-						if (opts.numericInput !== true) {
-							var tmpBufSplit = opts.radixPoint !== "" ? buffer.join("").split(opts.radixPoint) : [buffer.join("")],
-								matchRslt = tmpBufSplit[0].match(opts.regex.integerPart(opts)),
-								matchRsltDigits = tmpBufSplit.length === 2 ? tmpBufSplit[1].match(opts.regex.integerNPart(opts)) : undefined;
-							if (matchRslt) {
-								if ((matchRslt[0] === opts.negationSymbol.front + "0" || matchRslt[0] === opts.negationSymbol.front || matchRslt[0] === "+") && (matchRsltDigits === undefined || matchRsltDigits[0].match(/^0+$/))) {
-									buffer.splice(matchRslt.index, 1);
-								}
-								var radixPosition = $.inArray(opts.radixPoint, buffer);
-								if (radixPosition !== -1) {
-									if (isFinite(opts.digits) && !opts.digitsOptional) {
-										for (var i = 1; i <= opts.digits; i++) {
-											if (buffer[radixPosition + i] === undefined || buffer[radixPosition + i] === opts.placeholder.charAt(0)) {
-												buffer[radixPosition + i] = "0";
-											}
+						var tmpBufSplit = opts.radixPoint !== "" ? buffer.join("").split(opts.radixPoint) : [buffer.join("")],
+							matchRslt = tmpBufSplit[0].match(opts.regex.integerPart(opts)),
+							matchRsltDigits = tmpBufSplit.length === 2 ? tmpBufSplit[1].match(opts.regex.integerNPart(opts)) : undefined;
+						if (matchRslt) {
+							if ((matchRslt[0] === opts.negationSymbol.front + "0" || matchRslt[0] === opts.negationSymbol.front || matchRslt[0] === "+") && (matchRsltDigits === undefined || matchRsltDigits[0].match(/^0+$/))) {
+								buffer.splice(matchRslt.index, 1);
+							}
+							var radixPosition = $.inArray(opts.radixPoint, buffer);
+							if (radixPosition !== -1) {
+								if (isFinite(opts.digits) && !opts.digitsOptional) {
+									for (var i = 1; i <= opts.digits; i++) {
+										if (buffer[radixPosition + i] === undefined || buffer[radixPosition + i] === opts.placeholder.charAt(0)) {
+											buffer[radixPosition + i] = "0";
 										}
-										return {
-											"refreshFromBuffer": maskedValue !== buffer.join(""),
-											"buffer": buffer
-										};
-									} else if (radixPosition === buffer.length - opts.suffix.length - 1) {
-										buffer.splice(radixPosition, 1);
-										return {
-											"refreshFromBuffer": true,
-											"buffer": buffer
-										};
 									}
+									return {
+										"refreshFromBuffer": maskedValue !== buffer.join(""),
+										"buffer": buffer
+									};
+								} else if (radixPosition === buffer.length - opts.suffix.length - 1) {
+									buffer.splice(radixPosition, 1);
+									return {
+										"refreshFromBuffer": true,
+										"buffer": buffer
+									};
 								}
 							}
 						}
 					}
-
 				},
 				regex: {
 					integerPart: function(opts) {
-						return new RegExp("[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "\+]?\\d+");
+						return new RegExp("[\\d" + Inputmask.escapeRegex(opts.groupSeparator) + "]+[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "\+]?$");
 					},
 					integerNPart: function(opts) {
 						return new RegExp("[\\d" + Inputmask.escapeRegex(opts.groupSeparator) + "]+");
 					}
 				},
 				signHandler: function(chrs, maskset, pos, strict, opts) {
-					if (!strict && (opts.allowMinus && chrs === "-") || (opts.allowPlus && chrs === "+")) {
-						var matchRslt = maskset.buffer.join("").match(opts.regex.integerPart(opts));
-
-						if (matchRslt && matchRslt[0].length > 0) {
-							if (maskset.buffer[matchRslt.index] === (chrs === "-" ? "+" : opts.negationSymbol.front)) {
-								if (chrs === "-") {
-									if (opts.negationSymbol.back !== "") {
-										return {
-											"pos": matchRslt.index,
-											"c": opts.negationSymbol.front,
-											"remove": matchRslt.index,
-											"caret": pos,
-											"insert": {
-												"pos": maskset.buffer.length - opts.suffix.length - 1,
-												"c": opts.negationSymbol.back
-											}
-										};
-									} else {
-										return {
-											"pos": matchRslt.index,
-											"c": opts.negationSymbol.front,
-											"remove": matchRslt.index,
-											"caret": pos
-										};
-									}
-								} else {
-									if (opts.negationSymbol.back !== "") {
-										return {
-											"pos": matchRslt.index,
-											"c": "+",
-											"remove": [matchRslt.index, maskset.buffer.length - opts.suffix.length - 1],
-											"caret": pos
-										};
-									} else {
-										return {
-											"pos": matchRslt.index,
-											"c": "+",
-											"remove": matchRslt.index,
-											"caret": pos
-										};
-									}
-								}
-							} else if (maskset.buffer[matchRslt.index] === (chrs === "-" ? opts.negationSymbol.front : "+")) {
-								if (chrs === "-" && opts.negationSymbol.back !== "") {
-									return {
-										"remove": [matchRslt.index, maskset.buffer.length - opts.suffix.length - 1],
-										"caret": pos - 1
-									};
-								} else {
-									return {
-										"remove": matchRslt.index,
-										"caret": pos - 1
-									};
-								}
-							} else {
-								if (chrs === "-") {
-									if (opts.negationSymbol.back !== "") {
-										return {
-											"pos": matchRslt.index,
-											"c": opts.negationSymbol.front,
-											"caret": pos + 1,
-											"insert": {
-												"pos": maskset.buffer.length - opts.suffix.length,
-												"c": opts.negationSymbol.back
-											}
-										};
-									} else {
-										return {
-											"pos": matchRslt.index,
-											"c": opts.negationSymbol.front,
-											"caret": pos + 1
-										};
-									}
-								} else {
-									return {
-										"pos": matchRslt.index,
-										"c": chrs,
-										"caret": pos + 1
-									};
-								}
-							}
-						}
-					}
+					// if (!strict && (opts.allowMinus && chrs === "-") || (opts.allowPlus && chrs === "+")) {
+					// 	var matchRslt = maskset.buffer.join("").match(opts.regex.integerPart(opts));
+					//
+					// 	if (matchRslt && matchRslt[0].length > 0) {
+					// 		if (maskset.buffer[matchRslt.index] === (chrs === "-" ? "+" : opts.negationSymbol.front)) {
+					// 			if (chrs === "-") {
+					// 				if (opts.negationSymbol.back !== "") {
+					// 					return {
+					// 						"pos": matchRslt.index,
+					// 						"c": opts.negationSymbol.front,
+					// 						"remove": matchRslt.index,
+					// 						"caret": pos,
+					// 						"insert": {
+					// 							"pos": maskset.buffer.length - opts.suffix.length - 1,
+					// 							"c": opts.negationSymbol.back
+					// 						}
+					// 					};
+					// 				} else {
+					// 					return {
+					// 						"pos": matchRslt.index,
+					// 						"c": opts.negationSymbol.front,
+					// 						"remove": matchRslt.index,
+					// 						"caret": pos
+					// 					};
+					// 				}
+					// 			} else {
+					// 				if (opts.negationSymbol.back !== "") {
+					// 					return {
+					// 						"pos": matchRslt.index,
+					// 						"c": "+",
+					// 						"remove": [matchRslt.index, maskset.buffer.length - opts.suffix.length - 1],
+					// 						"caret": pos
+					// 					};
+					// 				} else {
+					// 					return {
+					// 						"pos": matchRslt.index,
+					// 						"c": "+",
+					// 						"remove": matchRslt.index,
+					// 						"caret": pos
+					// 					};
+					// 				}
+					// 			}
+					// 		} else if (maskset.buffer[matchRslt.index] === (chrs === "-" ? opts.negationSymbol.front : "+")) {
+					// 			if (chrs === "-" && opts.negationSymbol.back !== "") {
+					// 				return {
+					// 					"remove": [matchRslt.index, maskset.buffer.length - opts.suffix.length - 1],
+					// 					"caret": pos - 1
+					// 				};
+					// 			} else {
+					// 				return {
+					// 					"remove": matchRslt.index,
+					// 					"caret": pos - 1
+					// 				};
+					// 			}
+					// 		} else {
+					// 			if (chrs === "-") {
+					// 				if (opts.negationSymbol.back !== "") {
+					// 					return {
+					// 						"pos": matchRslt.index,
+					// 						"c": opts.negationSymbol.front,
+					// 						"caret": pos + 1,
+					// 						"insert": {
+					// 							"pos": maskset.buffer.length - opts.suffix.length,
+					// 							"c": opts.negationSymbol.back
+					// 						}
+					// 					};
+					// 				} else {
+					// 					return {
+					// 						"pos": matchRslt.index,
+					// 						"c": opts.negationSymbol.front,
+					// 						"caret": pos + 1
+					// 					};
+					// 				}
+					// 			} else {
+					// 				return {
+					// 					"pos": matchRslt.index,
+					// 					"c": chrs,
+					// 					"caret": pos + 1
+					// 				};
+					// 			}
+					// 		}
+					// 	}
+					// }
 					return false;
 				},
 				radixHandler: function(chrs, maskset, pos, strict, opts) {
-					if (!strict) {
-						if ($.inArray(chrs, [",", "."]) !== -1) chrs = opts.radixPoint;
-						if (chrs === opts.radixPoint && (opts.digits !== undefined && (isNaN(opts.digits) || parseInt(opts.digits) > 0))) {
-							var radixPos = $.inArray(opts.radixPoint, maskset.buffer),
-								integerValue = (opts.numericInput ? maskset.buffer.slice().reverse() : maskset.buffer).join("").match(opts.regex.integerPart(opts));
-
-							if (radixPos !== -1 && maskset.validPositions[radixPos]) {
-								if (maskset.validPositions[radixPos - 1]) {
-									return {
-										"caret": radixPos + 1
-									};
-								} else {
-									return {
-										"pos": integerValue.index,
-										c: integerValue[0],
-										"caret": radixPos + 1
-									};
-								}
-							} else if (!integerValue || (integerValue["0"] === "0" && (integerValue.index + 1) !== pos)) {
-								maskset.buffer[integerValue ? integerValue.index : pos] = "0";
-								return {
-									"pos": (integerValue ? integerValue.index : pos) + 1,
-									c: opts.radixPoint
-								};
-							}
-						}
-					}
+					// if (!strict) {
+					// 	if ($.inArray(chrs, [",", "."]) !== -1) chrs = opts.radixPoint;
+					// 	if (chrs === opts.radixPoint && (opts.digits !== undefined && (isNaN(opts.digits) || parseInt(opts.digits) > 0))) {
+					// 		var radixPos = $.inArray(opts.radixPoint, maskset.buffer),
+					// 			integerValue = maskset.buffer.join("").match(opts.regex.integerPart(opts));
+					//
+					// 	}
+					// }
 					return false;
 				},
 				leadingZeroHandler: function(chrs, maskset, pos, strict, opts) {
-					if (opts.numericInput === true) {
-						if (maskset.buffer[maskset.buffer.length - opts.prefix.length - 1] === "0") {
-							return {
-								"pos": pos,
-								"remove": maskset.buffer.length - opts.prefix.length - 1
-							};
-						}
-					} else {
-						var matchRslt = maskset.buffer.join("").match(opts.regex.integerNPart(opts)),
-							radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
-						if (matchRslt && !strict && (radixPosition === -1 || pos <= radixPosition)) {
-							if (matchRslt["0"].indexOf("0") === 0) {
-								if (pos < opts.prefix.length) pos = matchRslt.index; //position
-								var _radixPosition = $.inArray(opts.radixPoint, maskset._buffer);
-								var digitsMatch = maskset._buffer && maskset.buffer.slice(radixPosition).join("") === maskset._buffer.slice(_radixPosition).join("") || parseInt(maskset.buffer.slice(radixPosition + 1).join("")) === 0;
-								var integerMatch = maskset._buffer && maskset.buffer.slice(matchRslt.index, radixPosition).join("") === maskset._buffer.slice(opts.prefix.length, _radixPosition).join("") || maskset.buffer.slice(matchRslt.index, radixPosition).join("") === "0";
-
-								if (radixPosition === -1 || digitsMatch && integerMatch) {
-									maskset.buffer.splice(matchRslt.index, 1);
-									pos = pos > matchRslt.index ? pos - 1 : matchRslt.index;
-									return {
-										"pos": pos,
-										"remove": matchRslt.index
-									};
-								} else if (matchRslt.index + 1 === pos || chrs === "0") {
-									maskset.buffer.splice(matchRslt.index, 1);
-									pos = matchRslt.index;
-									return {
-										"pos": pos,
-										"remove": matchRslt.index
-									};
-								}
-							} else if (chrs === "0" && pos <= matchRslt.index && matchRslt["0"] !== opts.groupSeparator) {
-								return false;
-							}
-						}
-					}
+					// if (maskset.buffer[maskset.buffer.length - opts.prefix.length - 1] === "0") {
+					// 	return {
+					// 		"pos": pos,
+					// 		"remove": maskset.buffer.length - opts.prefix.length - 1
+					// 	};
+					// }
 					return true;
 				},
 				postValidation: function(buffer, opts) {
@@ -383,14 +330,10 @@ Optional extensions on the jquery.inputmask base
 										if (isValid === true) {
 											//handle overwrite when fixed precision
 											var radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
-											if (radixPosition !== -1 && opts.digitsOptional === false && opts.numericInput !== true && pos > radixPosition && !strict) {
+											if (radixPosition !== -1 && opts.digitsOptional === false && pos > radixPosition + 1 && !strict) {
 												isValid = {
-													"pos": pos,
-													"remove": pos
-												};
-											} else {
-												isValid = {
-													pos: pos
+													"pos": pos - 1,
+													"remove": pos - 1
 												};
 											}
 										}

+ 1 - 1
package.json

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