Browse Source

Merge pull request #1210 from vsn4ik/3.x-jshint-warnings

Refactoring minmax block in numeric
Robin Herbots 9 years ago
parent
commit
b0d388e73d
2 changed files with 9 additions and 16 deletions
  1. 1 1
      README_other.md
  2. 8 15
      js/inputmask.numeric.extensions.js

+ 1 - 1
README_other.md

@@ -37,7 +37,7 @@ Inputmask("mac").mask(selector);
 An VIN mask for entering valid VIN codes.
 
 ```javascript
-  Inputmask("vin").mask(selector);
+Inputmask("vin").mask(selector);
 ```
 
 You can find/modify/extend these aliases in the inputmask.extensions.js

+ 8 - 15
js/inputmask.numeric.extensions.js

@@ -1,7 +1,7 @@
 /*
  Input Mask plugin extensions
  http://github.com/RobinHerbots/jquery.inputmask
- Copyright (c) 2010 -  Robin Herbots
+ Copyright (c) 2010 - Robin Herbots
  Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
  Version: 0.0.0-dev
 
@@ -198,8 +198,7 @@
 				var rslt;
 				if (e && (e.type === "blur" || e.type === "checkval" || e.type === "keydown")) {
 					var maskedValue = opts.numericInput ? buffer.slice().reverse().join("") : buffer.join(""),
-						processValue = maskedValue.replace(opts.prefix, ""),
-						minmaxed = false;
+						processValue = maskedValue.replace(opts.prefix, "");
 					processValue = processValue.replace(opts.suffix, "");
 					processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
 					if (opts.radixPoint === ",") processValue = processValue.replace(opts.radixPoint, ".");
@@ -213,19 +212,13 @@
 					if (processValue !== "" && isFinite(processValue)) {
 						var floatValue = parseFloat(processValue),
 							signedFloatValue = isNegative ? floatValue * -1 : floatValue;
-						if (opts.min !== null && isFinite(opts.min)) {
-							if (signedFloatValue < parseFloat(opts.min)) {
-								floatValue = Math.abs(opts.min);
-								isNegative = opts.min < 0;
-								minmaxed = true;
-							}
+						if (opts.min !== null && isFinite(opts.min) && signedFloatValue < parseFloat(opts.min)) {
+							floatValue = Math.abs(opts.min);
+							isNegative = opts.min < 0;
 						}
-						if (!minmaxed && opts.max !== null && isFinite(opts.max)) {
-							if (signedFloatValue > parseFloat(opts.max)) {
-								floatValue = Math.abs(opts.max);
-								isNegative = opts.max < 0;
-								minmaxed = true;
-							}
+						else if (opts.max !== null && isFinite(opts.max) && signedFloatValue > parseFloat(opts.max)) {
+							floatValue = Math.abs(opts.max);
+							isNegative = opts.max < 0;
 						}
 
 						processValue = floatValue.toString().replace(".", opts.radixPoint).split('');