Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: node_js
node_js: "7"

# Before running the script, make sure that grunt is installed.
before_script:
- npm install -g grunt-cli

# Run gulp validate to run all the tests.
script: grunt validate

# Cache the node modules directory.
cache:
directories:
- "node_modules"
2 changes: 1 addition & 1 deletion js/inputmask.extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"vin": {
mask: "V{13}9{4}",
definitions: {
'V': {
"V": {
validator: "[A-HJ-NPR-Za-hj-npr-z\\d]",
cardinality: 1,
casing: "upper"
Expand Down
10 changes: 6 additions & 4 deletions js/inputmask.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,19 @@
});
return elems && elems[0] ? (elems[0].inputmask || this) : this;
},
option: function (options, noremask) { //set extra options || retrieve value of a current option
option: function (options, noremask) {
// Set extra options || retrieve value of a current option.
if (typeof options === "string") {
return this.opts[options];
} else if (typeof options === "object") {
$.extend(this.userOptions, options); //user passed options
//remask
// Remask.
if (this.el && noremask !== true) {
this.mask(this.el);
}
return this;
}
return this;
},
unmaskedvalue: function (value) {
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
Expand Down Expand Up @@ -1137,7 +1139,7 @@
break;
} else if (staticCanMatchDefinition(altMatch, altMatch2) || isSubsetOf(altMatch, altMatch2)) {
// console.log("case 5");
if (altMatch.alternation == altMatch2.alternation &&
if (altMatch.alternation === altMatch2.alternation &&
altMatch.locator[altMatch.alternation].toString().indexOf(altMatch2.locator[altMatch2.alternation].toString().split("")[0]) === -1) {

//no alternation marker
Expand Down Expand Up @@ -1736,7 +1738,7 @@
if (getMaskSet().validPositions[pndx]) break;
}
////fill missing nonmask and valid placeholders
var testTemplate, testsFromPos;
var testTemplate, testsFromPos, result;
for (pndx++; pndx < maskPos; pndx++) {
if (getMaskSet().validPositions[pndx] === undefined && (opts.jitMasking === false || opts.jitMasking > pndx)) {
testsFromPos = getTests(pndx, getTestTemplate(pndx - 1).locator, pndx - 1).slice();
Expand Down
38 changes: 25 additions & 13 deletions js/inputmask.numeric.extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@
opts.quantifiermarker.end === txt.charAt(i) ||
opts.groupmarker.start === txt.charAt(i) ||
opts.groupmarker.end === txt.charAt(i) ||
opts.alternatormarker === txt.charAt(i))
opts.alternatormarker === txt.charAt(i)) {
escapedTxt += "\\" + txt.charAt(i)
else escapedTxt += txt.charAt(i);
}
else {
escapedTxt += txt.charAt(i);
}
}
return escapedTxt;
}
Expand Down Expand Up @@ -137,7 +140,7 @@
unmaskAsNumber: false,
inputmode: "numeric",
preValidation: function (buffer, pos, c, isSelection, opts) {
if (c === "-" || c == opts.negationSymbol.front) {
if (c === "-" || c === opts.negationSymbol.front) {
if (opts.allowMinus !== true) return false;
opts.isNegative = opts.isNegative === undefined ? true : !opts.isNegative;
if (buffer.join("") === "") return true;
Expand Down Expand Up @@ -172,9 +175,9 @@

var suffix = opts.suffix.split(""), prefix = opts.prefix.split("");

if (currentResult.pos == undefined && currentResult.caret !== undefined && currentResult.dopost !== true) return currentResult;
if (currentResult.pos === undefined && currentResult.caret !== undefined && currentResult.dopost !== true) return currentResult;

var caretPos = currentResult.caret != undefined ? currentResult.caret : currentResult.pos;
var caretPos = currentResult.caret !== undefined ? currentResult.caret : currentResult.pos;
var maskedValue = buffer.slice();
if (opts.numericInput) {
caretPos = maskedValue.length - caretPos - 1;
Expand All @@ -188,7 +191,9 @@
}


if (caretPos == maskedValue.length - opts.suffix.length - 1 && charAtPos === opts.radixPoint) return currentResult;
if (caretPos === maskedValue.length - opts.suffix.length - 1 && charAtPos === opts.radixPoint) {
return currentResult;
}

if (charAtPos !== undefined) {
if (charAtPos !== opts.radixPoint &&
Expand Down Expand Up @@ -279,9 +284,12 @@
if (charAtPos !== undefined) {
if (charAtPos !== opts.radixPoint && charAtPos !== opts.negationSymbol.front && charAtPos !== opts.negationSymbol.back) {
caretPos = $.inArray("?", processValue);
if (caretPos > -1)
if (caretPos > -1) {
processValue[caretPos] = charAtPos;
else caretPos = currentResult.caret || 0;
}
else {
caretPos = currentResult.caret || 0;
}
} else if (charAtPos === opts.radixPoint ||
charAtPos === opts.negationSymbol.front ||
charAtPos === opts.negationSymbol.back) {
Expand Down Expand Up @@ -395,11 +403,13 @@
processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), "");
//filter 0 after radixpoint
var pvRadixSplit = processValue.split(opts.radixPoint);
if (pvRadixSplit.length > 1)
if (pvRadixSplit.length > 1) {
pvRadixSplit[1] = pvRadixSplit[1].replace(/0/g, opts.placeholder.charAt(0));
}
//filter 0 before radixpoint
if (pvRadixSplit[0] === "0")
if (pvRadixSplit[0] === "0") {
pvRadixSplit[0] = pvRadixSplit[0].replace(/0/g, opts.placeholder.charAt(0));
}
processValue = pvRadixSplit[0] + opts.radixPoint + pvRadixSplit[1] || "";
var bufferTemplate = maskset._buffer.join(""); //getBuffer().slice(lvp).join('');
if (processValue === opts.radixPoint) {
Expand Down Expand Up @@ -472,8 +482,9 @@
var processValue = maskedValue.replace(opts.prefix, "");
processValue = processValue.replace(opts.suffix, "");
processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
if (opts.placeholder.charAt(0) !== "")
if (opts.placeholder.charAt(0) !== "") {
processValue = processValue.replace(new RegExp(opts.placeholder.charAt(0), "g"), "0");
}
if (opts.unmaskAsNumber) {
if (opts.radixPoint !== "" && processValue.indexOf(opts.radixPoint) !== -1) processValue = processValue.replace(Inputmask.escapeRegex.call(this, opts.radixPoint), ".");
processValue = processValue.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), "-");
Expand Down Expand Up @@ -507,8 +518,9 @@
if (opts.radixPoint !== "" && isFinite(initialValue)) {
var vs = initialValue.split("."),
groupSize = opts.groupSeparator !== "" ? parseInt(opts.groupSize) : 0;
if (vs.length === 2 && (vs[0].length > groupSize || vs[1].length > groupSize || (vs[0].length <= groupSize && vs[1].length < groupSize)))
if (vs.length === 2 && (vs[0].length > groupSize || vs[1].length > groupSize || (vs[0].length <= groupSize && vs[1].length < groupSize))) {
initialValue = initialValue.replace(".", opts.radixPoint);
}
}
var kommaMatches = initialValue.match(/,/g);
var dotMatches = initialValue.match(/\./g);
Expand Down Expand Up @@ -564,7 +576,7 @@
vp.input === opts.negationSymbol.front ||
vp.input === opts.negationSymbol.back;

if (canClear && (vp.match.nativeDef == "+" || vp.match.nativeDef == "-")) {
if (canClear && (vp.match.nativeDef === "+" || vp.match.nativeDef === "-")) {
opts.isNegative = false;
}

Expand Down
8 changes: 5 additions & 3 deletions js/inputmask.phone.extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
function reduceVariations(masks, previousVariation, previousmaskGroup) {
previousVariation = previousVariation || "";
previousmaskGroup = previousmaskGroup || maskGroups;
if (previousVariation !== "")
if (previousVariation !== "") {
previousmaskGroup[previousVariation] = {};
}
var variation = "", maskGroup = previousmaskGroup[previousVariation] || previousmaskGroup;
for (var i = masks.length - 1; i >= 0; i--) {
mask = masks[i].mask || masks[i];
Expand All @@ -56,10 +57,11 @@
var mask = "", submasks = [];
for (var ndx in maskGroup) {
if ($.isArray(maskGroup[ndx])) {
if (maskGroup[ndx].length === 1)
if (maskGroup[ndx].length === 1) {
submasks.push(ndx + maskGroup[ndx]);
else
} else {
submasks.push(ndx + opts.groupmarker.start + maskGroup[ndx].join(opts.groupmarker.end + opts.alternatormarker + opts.groupmarker.start) + opts.groupmarker.end);
}
} else {
submasks.push(ndx + rebuild(maskGroup[ndx]));
}
Expand Down
2 changes: 1 addition & 1 deletion js/inputmask.regex.extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
}
} else {
var testExp;
if (matchToken.charAt(0) == "[") {
if (matchToken.charAt(0) === "[") {
testExp = regexPart;
testExp += matchToken;
for (var j = 0; j < openGroupCount; j++) {
Expand Down
4 changes: 3 additions & 1 deletion js/jquery.inputmask.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@
return this.each(function () {
if (this.inputmask !== undefined) {
return this.inputmask.option(fn);
} else nptmask.mask(this);
} else {
return nptmask.mask(this);
}
});
} else {
return this.each(function () {
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
"use strict";

let webpack = require('webpack');
let path = require('path');
Expand Down