Robin Herbots 11 年 前
コミット
80cc64e2c5

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
 {
     "name": "jquery.inputmask",
     "name": "jquery.inputmask",
-    "version": "3.0.30",
+    "version": "3.0.31",
     "main": "./dist/jquery.inputmask.bundle.js",
     "main": "./dist/jquery.inputmask.bundle.js",
 	"keywords" : ["jQuery", "plugins", "input", "form", "inputmask", "mask"],
 	"keywords" : ["jQuery", "plugins", "input", "form", "inputmask", "mask"],
 	"description": "jquery.inputmask is a jquery plugin which create an input mask.",
 	"description": "jquery.inputmask is a jquery plugin which create an input mask.",

+ 1 - 1
build.properties

@@ -7,7 +7,7 @@ distdir = dist
 
 
 build.major = 3
 build.major = 3
 build.minor = 0
 build.minor = 0
-build.revision = 30
+build.revision = 31
 
 
 target = jquery.inputmask.bundle.js
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js
 target.min = jquery.inputmask.bundle.min.js

BIN
dist/jQuery.InputMask.3.0.30.nupkg


BIN
dist/jQuery.InputMask.3.0.31.nupkg


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


ファイルの差分が大きいため隠しています
+ 97 - 87
dist/jquery.inputmask.bundle.min.js


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


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


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


+ 1 - 1
jquery.inputmask.jquery.json

@@ -8,7 +8,7 @@
 		"inputmask",
 		"inputmask",
 		"mask"
 		"mask"
     ],
     ],
-    "version": "3.0.30",
+    "version": "3.0.31",
     "author": {
     "author": {
         "name": "Robin Herbots",
         "name": "Robin Herbots",
         "url": "http://github.com/RobinHerbots/jquery.inputmask"
         "url": "http://github.com/RobinHerbots/jquery.inputmask"

+ 3 - 6
js/jquery.inputmask-multi.js

@@ -166,7 +166,7 @@
                     if ($el.attr("dir")) elMaskStr += 'dir="' + $el.attr("dir") + '" ';
                     if ($el.attr("dir")) elMaskStr += 'dir="' + $el.attr("dir") + '" ';
                     elMaskStr += '/>';
                     elMaskStr += '/>';
                     var elmask = $(elMaskStr)[0];
                     var elmask = $(elMaskStr)[0];
-                    $(elmask).inputmask(msk.mask, opts);
+                    $(elmask).inputmask($.extend({}, opts, { mask: msk.mask }));
                     return elmask;
                     return elmask;
                 });
                 });
 
 
@@ -350,16 +350,13 @@
 
 
         $.inputmask._fn = $.fn.inputmask;
         $.inputmask._fn = $.fn.inputmask;
         $.fn.inputmask = function (fn, options) {
         $.fn.inputmask = function (fn, options) {
-            var opts = $.extend(true, {}, $.inputmask.defaults, options);
-
             if (typeof fn === "string") {
             if (typeof fn === "string") {
-                opts.mask = fn;
-                if ($.inputmask._fn("_detectScope", opts))
+                if ($.inputmask._fn("_detectScope", options, undefined, undefined, fn))
                     return $.inputmask._fn.call(this, fn, options, multiMaskScope, "_inputmask-multi");
                     return $.inputmask._fn.call(this, fn, options, multiMaskScope, "_inputmask-multi");
                 else return $.inputmask._fn.call(this, fn, options);
                 else return $.inputmask._fn.call(this, fn, options);
             } else if (typeof fn == "object") {
             } else if (typeof fn == "object") {
                 opts = $.extend(true, {}, $.inputmask.defaults, fn);
                 opts = $.extend(true, {}, $.inputmask.defaults, fn);
-                if ($.inputmask._fn("_detectScope", opts))
+                if ($.inputmask._fn("_detectScope", fn))
                     return $.inputmask._fn.call(this, fn, options, multiMaskScope, "_inputmask-multi");
                     return $.inputmask._fn.call(this, fn, options, multiMaskScope, "_inputmask-multi");
                 else return $.inputmask._fn.call(this, fn, options);
                 else return $.inputmask._fn.call(this, fn, options);
             } else if (fn == undefined)
             } else if (fn == undefined)

+ 22 - 15
js/jquery.inputmask.js

@@ -104,8 +104,7 @@
                                 mq0 = isNaN(mq[0]) ? mq[0] : parseInt(mq[0]),
                                 mq0 = isNaN(mq[0]) ? mq[0] : parseInt(mq[0]),
                                 mq1 = mq.length == 1 ? mq0 : (isNaN(mq[1]) ? mq[1] : parseInt(mq[1]));
                                 mq1 = mq.length == 1 ? mq0 : (isNaN(mq[1]) ? mq[1] : parseInt(mq[1]));
                             if (mq1 == "*" || mq1 == "+") {
                             if (mq1 == "*" || mq1 == "+") {
-                                mq0 = mq0 == "*" ? 0 : 1;
-                                opts.greedy = false;
+                                mq0 = mq1 == "*" ? 0 : 1;
                             }
                             }
                             quantifier.quantifier = { min: mq0, max: mq1 };
                             quantifier.quantifier = { min: mq0, max: mq1 };
                             if (openenings.length > 0) {
                             if (openenings.length > 0) {
@@ -160,9 +159,9 @@
             }
             }
 
 
             function generateMask(mask, metadata) {
             function generateMask(mask, metadata) {
-                if (opts.numericInput) { //TODO FIX FOR DYNAMIC MASKS WITH QUANTIFIERS
+                if (opts.numericInput && opts.multi !== true) { //TODO FIX FOR DYNAMIC MASKS WITH QUANTIFIERS
                     mask = mask.split('').reverse();
                     mask = mask.split('').reverse();
-                    for (var ndx in mask) {
+                    for (var ndx = 0; ndx < mask.length; ndx++) {
                         if (mask[ndx] == opts.optionalmarker.start)
                         if (mask[ndx] == opts.optionalmarker.start)
                             mask[ndx] = opts.optionalmarker.end;
                             mask[ndx] = opts.optionalmarker.end;
                         else if (mask[ndx] == opts.optionalmarker.end)
                         else if (mask[ndx] == opts.optionalmarker.end)
@@ -191,7 +190,8 @@
                             "tests": {},
                             "tests": {},
                             "metadata": metadata
                             "metadata": metadata
                         };
                         };
-                    }
+                    }
+
                     return $.extend(true, {}, $.inputmask.masksCache[mask]);
                     return $.extend(true, {}, $.inputmask.masksCache[mask]);
                 }
                 }
             }
             }
@@ -369,7 +369,7 @@
 
 
             function getTestTemplate(pos, ndxIntlzr, tstPs) {
             function getTestTemplate(pos, ndxIntlzr, tstPs) {
                 var testPositions = getTests(pos, ndxIntlzr, tstPs), testPos;
                 var testPositions = getTests(pos, ndxIntlzr, tstPs), testPos;
-                for (var ndx in testPositions) {
+                for (var ndx = 0; ndx < testPositions.length; ndx++) {
                     testPos = testPositions[ndx];
                     testPos = testPositions[ndx];
                     if (opts.greedy || (testPos["match"] && (testPos["match"].optionality === false || testPos["match"].newBlockMarker === false) && testPos["match"].optionalQuantifier !== true)) {
                     if (opts.greedy || (testPos["match"] && (testPos["match"].optionality === false || testPos["match"].newBlockMarker === false) && testPos["match"].optionalQuantifier !== true)) {
                         break;
                         break;
@@ -386,7 +386,7 @@
             }
             }
             function positionCanMatchDefinition(pos, def) {
             function positionCanMatchDefinition(pos, def) {
                 var valid = false, tests = getTests(pos);
                 var valid = false, tests = getTests(pos);
-                for (var tndx in tests) {
+                for (var tndx = 0; tndx < tests.length; tndx++) {
                     if (tests[tndx]["match"] && tests[tndx]["match"].def == def) {
                     if (tests[tndx]["match"] && tests[tndx]["match"].def == def) {
                         valid = true;
                         valid = true;
                         break;
                         break;
@@ -421,7 +421,8 @@
                             } else if (match.isAlternator) {
                             } else if (match.isAlternator) {
                                 //TODO
                                 //TODO
                             } else if (match.isQuantifier && quantifierRecurse !== true) {
                             } else if (match.isQuantifier && quantifierRecurse !== true) {
-                                var qt = match;
+                                var qt = match;
+                                opts.greedy = opts.greedy && !isNaN(qt.quantifier.max); //greedy must be off when * or + is used (always!!)
                                 for (var qndx = (ndxInitializer.length > 0 && quantifierRecurse !== true) ? ndxInitializer.shift() : 0; (qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max)) && testPos <= pos; qndx++) {
                                 for (var qndx = (ndxInitializer.length > 0 && quantifierRecurse !== true) ? ndxInitializer.shift() : 0; (qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max)) && testPos <= pos; qndx++) {
                                     var tokenGroup = maskToken.matches[$.inArray(qt, maskToken.matches) - 1];
                                     var tokenGroup = maskToken.matches[$.inArray(qt, maskToken.matches) - 1];
                                     match = handleMatch(tokenGroup, [qndx].concat(loopNdx), true);
                                     match = handleMatch(tokenGroup, [qndx].concat(loopNdx), true);
@@ -707,7 +708,7 @@
             function clearOptionalTail(input) {
             function clearOptionalTail(input) {
                 var buffer = getBuffer(), tmpBuffer = buffer.slice(),
                 var buffer = getBuffer(), tmpBuffer = buffer.slice(),
                     pos, lvp = getLastValidPosition(), positions = {},
                     pos, lvp = getLastValidPosition(), positions = {},
-                    ndxIntlzr = getMaskSet()["validPositions"][lvp]["locator"].slice(), testPos;
+                    ndxIntlzr = getMaskSet()["validPositions"][lvp] != undefined ? getMaskSet()["validPositions"][lvp]["locator"].slice() : undefined, testPos;
                 for (pos = lvp + 1; pos < tmpBuffer.length; pos++) {
                 for (pos = lvp + 1; pos < tmpBuffer.length; pos++) {
                     testPos = getTestTemplate(pos, ndxIntlzr, pos - 1);
                     testPos = getTestTemplate(pos, ndxIntlzr, pos - 1);
                     ndxIntlzr = testPos["locator"].slice();
                     ndxIntlzr = testPos["locator"].slice();
@@ -1519,16 +1520,16 @@
             format: function (value, options) {
             format: function (value, options) {
                 var opts = $.extend(true, {}, $.inputmask.defaults, options);
                 var opts = $.extend(true, {}, $.inputmask.defaults, options);
                 resolveAlias(opts.alias, options, opts);
                 resolveAlias(opts.alias, options, opts);
-                return maskScope(generateMaskSet(opts), opts, { "action": "format", "value": value });
+                return maskScope({ "action": "format", "value": value }, generateMaskSet(opts), opts);
             },
             },
             isValid: function (value, options) {
             isValid: function (value, options) {
                 var opts = $.extend(true, {}, $.inputmask.defaults, options);
                 var opts = $.extend(true, {}, $.inputmask.defaults, options);
                 resolveAlias(opts.alias, options, opts);
                 resolveAlias(opts.alias, options, opts);
-                return maskScope(generateMaskSet(opts), opts, { "action": "isValid", "value": value });
+                return maskScope({ "action": "isValid", "value": value }, generateMaskSet(opts), opts);
             }
             }
         };
         };
 
 
-        $.fn.inputmask = function (fn, options, targetScope, targetData) {
+        $.fn.inputmask = function (fn, options, targetScope, targetData, msk) {
             targetScope = targetScope || maskScope;
             targetScope = targetScope || maskScope;
             targetData = targetData || "_inputmask";
             targetData = targetData || "_inputmask";
             function importAttributeOptions(npt, opts) {
             function importAttributeOptions(npt, opts) {
@@ -1583,9 +1584,15 @@
                             return maskset['metadata'];
                             return maskset['metadata'];
                         }
                         }
                         else return undefined;
                         else return undefined;
-                    case "_detectScope":
-                        resolveAlias(opts.alias, fn, opts); //resolve aliases
-                        return $.isArray(generateMaskSet(opts));
+                    case "_detectScope":
+                        resolveAlias(opts.alias, options, opts);
+                        if (msk != undefined && !resolveAlias(msk, options, opts) && $.inArray(msk, ["mask", "unmaskedvalue", "remove", "getemptymask", "hasMaskedValue", "isComplete", "getmetadata", "_detectScope"]) == -1) {
+                            opts.mask = msk;
+                        }
+                        if ($.isFunction(opts.mask)) {
+                            opts.mask = opts.mask.call(this, opts);
+                        }
+                        return $.isArray(opts.mask);
                     default:
                     default:
                         //check if the fn is an alias
                         //check if the fn is an alias
                         if (!resolveAlias(fn, options, opts)) {
                         if (!resolveAlias(fn, options, opts)) {