Browse Source

#502 fix getmasktemplate

Robin Herbots 11 years ago
parent
commit
448eb6ee89

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
 {
     "name": "jquery.inputmask",
     "name": "jquery.inputmask",
-    "version": "3.0.0",
+    "version": "3.0.1",
     "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 = 0
+build.revision = 1
 
 
 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.0.nupkg


BIN
dist/jQuery.InputMask.3.0.1.nupkg


+ 13 - 8
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2014 Robin Herbots
 * Copyright (c) 2010 - 2014 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.0.0
+* Version: 3.0.1
 */
 */
 
 
 (function ($) {
 (function ($) {
@@ -40,11 +40,12 @@
                 var tokenizer = /(?:[?*+]|\{[0-9]+(?:,[0-9\+\*]*)?\})\??|[^.?*+^${[]()|\\]+|./g,
                 var tokenizer = /(?:[?*+]|\{[0-9]+(?:,[0-9\+\*]*)?\})\??|[^.?*+^${[]()|\\]+|./g,
                     escaped = false;
                     escaped = false;
 
 
-                function maskToken(isGroup, isOptional, isQuantifier) {
+                function maskToken(isGroup, isOptional, isQuantifier, isAlternator) {
                     this.matches = [];
                     this.matches = [];
                     this.isGroup = isGroup || false;
                     this.isGroup = isGroup || false;
                     this.isOptional = isOptional || false;
                     this.isOptional = isOptional || false;
                     this.isQuantifier = isQuantifier || false;
                     this.isQuantifier = isQuantifier || false;
+                    this.isAlternator = isAlternator || false;
                     this.quantifier = { min: 1, max: 1 };
                     this.quantifier = { min: 1, max: 1 };
                 };
                 };
 
 
@@ -125,6 +126,9 @@
                         case opts.escapeChar:
                         case opts.escapeChar:
                             escaped = true;
                             escaped = true;
                             break;
                             break;
+                        case opts.alternatormarker:
+                            console.log("alternator");
+                            break;
                         default:
                         default:
                             if (openenings.length > 0) {
                             if (openenings.length > 0) {
                                 insertTestDefinition(openenings[openenings.length - 1], m);
                                 insertTestDefinition(openenings[openenings.length - 1], m);
@@ -238,7 +242,7 @@
                         ndxIntlzr = validPos["locator"].slice();
                         ndxIntlzr = validPos["locator"].slice();
                         maskTemplate.push(test["fn"] == null ? test["def"] : (includeInput === true ? validPos["input"] : opts.placeholder.charAt(pos % opts.placeholder.length)));
                         maskTemplate.push(test["fn"] == null ? test["def"] : (includeInput === true ? validPos["input"] : opts.placeholder.charAt(pos % opts.placeholder.length)));
                     } else {
                     } else {
-                        var testPos = getTests(pos, false, ndxIntlzr, pos - 1);
+                        var testPos = getTests(pos, true, ndxIntlzr, pos - 1);
                         testPos = testPos[opts.greedy || minimalPos > pos ? 0 : (testPos.length - 1)];
                         testPos = testPos[opts.greedy || minimalPos > pos ? 0 : (testPos.length - 1)];
                         test = testPos["match"];
                         test = testPos["match"];
                         ndxIntlzr = testPos["locator"].slice();
                         ndxIntlzr = testPos["locator"].slice();
@@ -1589,6 +1593,7 @@
                 optionalmarker: { start: "[", end: "]" },
                 optionalmarker: { start: "[", end: "]" },
                 quantifiermarker: { start: "{", end: "}" },
                 quantifiermarker: { start: "{", end: "}" },
                 groupmarker: { start: "(", end: ")" },
                 groupmarker: { start: "(", end: ")" },
+                alternatormarker: "|",
                 escapeChar: "\\",
                 escapeChar: "\\",
                 mask: null,
                 mask: null,
                 oncomplete: $.noop, //executes when the mask is complete
                 oncomplete: $.noop, //executes when the mask is complete
@@ -1804,7 +1809,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.0
+Version: 3.0.1
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -1914,7 +1919,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.0
+Version: 3.0.1
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2411,7 +2416,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.0
+Version: 3.0.1
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2578,7 +2583,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.0
+Version: 3.0.1
 
 
 Regex extensions on the jquery.inputmask base
 Regex extensions on the jquery.inputmask base
 Allows for using regular expressions as a mask
 Allows for using regular expressions as a mask
@@ -2765,7 +2770,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.0
+Version: 3.0.1
 
 
 Phone extension.
 Phone extension.
 When using this extension make sure you specify the correct url to get the masks
 When using this extension make sure you specify the correct url to get the masks

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


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


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 7 - 2
js/jquery.inputmask.js

@@ -40,11 +40,12 @@
                 var tokenizer = /(?:[?*+]|\{[0-9]+(?:,[0-9\+\*]*)?\})\??|[^.?*+^${[]()|\\]+|./g,
                 var tokenizer = /(?:[?*+]|\{[0-9]+(?:,[0-9\+\*]*)?\})\??|[^.?*+^${[]()|\\]+|./g,
                     escaped = false;
                     escaped = false;
 
 
-                function maskToken(isGroup, isOptional, isQuantifier) {
+                function maskToken(isGroup, isOptional, isQuantifier, isAlternator) {
                     this.matches = [];
                     this.matches = [];
                     this.isGroup = isGroup || false;
                     this.isGroup = isGroup || false;
                     this.isOptional = isOptional || false;
                     this.isOptional = isOptional || false;
                     this.isQuantifier = isQuantifier || false;
                     this.isQuantifier = isQuantifier || false;
+                    this.isAlternator = isAlternator || false;
                     this.quantifier = { min: 1, max: 1 };
                     this.quantifier = { min: 1, max: 1 };
                 };
                 };
 
 
@@ -125,6 +126,9 @@
                         case opts.escapeChar:
                         case opts.escapeChar:
                             escaped = true;
                             escaped = true;
                             break;
                             break;
+                        case opts.alternatormarker:
+                            console.log("alternator");
+                            break;
                         default:
                         default:
                             if (openenings.length > 0) {
                             if (openenings.length > 0) {
                                 insertTestDefinition(openenings[openenings.length - 1], m);
                                 insertTestDefinition(openenings[openenings.length - 1], m);
@@ -238,7 +242,7 @@
                         ndxIntlzr = validPos["locator"].slice();
                         ndxIntlzr = validPos["locator"].slice();
                         maskTemplate.push(test["fn"] == null ? test["def"] : (includeInput === true ? validPos["input"] : opts.placeholder.charAt(pos % opts.placeholder.length)));
                         maskTemplate.push(test["fn"] == null ? test["def"] : (includeInput === true ? validPos["input"] : opts.placeholder.charAt(pos % opts.placeholder.length)));
                     } else {
                     } else {
-                        var testPos = getTests(pos, false, ndxIntlzr, pos - 1);
+                        var testPos = getTests(pos, true, ndxIntlzr, pos - 1);
                         testPos = testPos[opts.greedy || minimalPos > pos ? 0 : (testPos.length - 1)];
                         testPos = testPos[opts.greedy || minimalPos > pos ? 0 : (testPos.length - 1)];
                         test = testPos["match"];
                         test = testPos["match"];
                         ndxIntlzr = testPos["locator"].slice();
                         ndxIntlzr = testPos["locator"].slice();
@@ -1589,6 +1593,7 @@
                 optionalmarker: { start: "[", end: "]" },
                 optionalmarker: { start: "[", end: "]" },
                 quantifiermarker: { start: "{", end: "}" },
                 quantifiermarker: { start: "{", end: "}" },
                 groupmarker: { start: "(", end: ")" },
                 groupmarker: { start: "(", end: ")" },
+                alternatormarker: "|",
                 escapeChar: "\\",
                 escapeChar: "\\",
                 mask: null,
                 mask: null,
                 oncomplete: $.noop, //executes when the mask is complete
                 oncomplete: $.noop, //executes when the mask is complete

+ 28 - 0
qunit/tests.js

@@ -307,6 +307,34 @@ test("inputmask(\"A.\", { repeat: \"*\" }) - type abc - joostburg", function ()
     $("#testmask").remove();
     $("#testmask").remove();
 });
 });
 
 
+test("{ mask: \"A\", placeholder: \"\", repeat: 16 }) - type testtest - glosswordteam", function () {
+    var $fixture = $("#qunit-fixture");
+    $fixture.append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask({ mask: "A", placeholder: "", repeat: 16 });
+
+    $("#testmask")[0].focus();
+
+    $("#testmask").Type("testtest");
+
+    equal($("#testmask").val(), "TESTTEST", "Result " + $("#testmask").val());
+
+    $("#testmask").remove();
+});
+
+test("{ mask: \"A\", repeat: 16, greedy: false }) - type testtest - glosswordteam", function () {
+    var $fixture = $("#qunit-fixture");
+    $fixture.append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask({ mask: "A", repeat: 16, greedy: false });
+
+    $("#testmask")[0].focus();
+
+    $("#testmask").Type("testtest");
+
+    equal($("#testmask").val(), "TESTTEST", "Result " + $("#testmask").val());
+
+    $("#testmask").remove();
+});
+
 module("greedy masks");
 module("greedy masks");
 test("inputmask(\"*\", { greedy: true, repeat: 10, clearMaskOnLostFocus: false  })", function () {
 test("inputmask(\"*\", { greedy: true, repeat: 10, clearMaskOnLostFocus: false  })", function () {
     var $fixture = $("#qunit-fixture");
     var $fixture = $("#qunit-fixture");