Browse Source

HandleRemove => strict depending #masks

Robin Herbots 12 years ago
parent
commit
0fe48c7273

+ 1 - 1
build.properties

@@ -7,7 +7,7 @@ distdir = dist
 
 build.major = 2
 build.minor = 3
-build.revision = 63
+build.revision = 64
 
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js

+ 1 - 1
component.json

@@ -1,6 +1,6 @@
 {
     "name": "jquery.inputmask",
-    "version": "2.3.63",
+    "version": "2.3.64",
     "main": "./dist/jquery.inputmask.bundle.js",
     "dependencies": {
         "jquery": ">=1.7"

BIN
dist/jQuery.InputMask.2.3.63.nupkg


BIN
dist/jQuery.InputMask.2.3.64.nupkg


+ 14 - 12
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2013 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 2.3.63
+* Version: 2.3.64
 */
 
 (function ($) {
@@ -246,7 +246,7 @@
                 }
                 var escaped = false, outCount = 0, greedy = opts.greedy, repeat = opts.repeat;
                 if (repeat == "*") greedy = false;
-                if (greedy == true && opts.placeholder == "") opts.placeholder = " ";
+                //if (greedy == true && opts.placeholder == "") opts.placeholder = " ";
                 if (mask.length == 1 && greedy == false) { opts.placeholder = ""; } //hide placeholder with single non-greedy mask
                 var singleMask = $.map(mask.split(""), function (element, index) {
                     var outElem = [];
@@ -663,8 +663,8 @@
                                         var newValidPosition = result.pos || maskPos;
                                         if (getActiveMaskSet()['lastValidPosition'] < newValidPosition)
                                             getActiveMaskSet()['lastValidPosition'] = newValidPosition; //set new position from isValid
-                                        //console.log("pos " + pos + " ndx " + activeMasksetIndex + " validate " + getActiveBuffer().join('') + " lv " + getActiveMaskSet()['lastValidPosition']);
                                     }
+                                    //console.log("pos " + pos + " ndx " + activeMasksetIndex + " validate " + getActiveBuffer().join('') + " lv " + getActiveMaskSet()['lastValidPosition']);
                                     results.push({ "activeMasksetIndex": index, "result": result });
                                 }
                             }
@@ -748,7 +748,7 @@
 
                     var test = getActiveTests()[determineTestPosition(position)];
                     var elem = element;
-                    if (elem != undefined) {
+                    if (elem != undefined && test != undefined) {
                         switch (test.casing) {
                             case "upper":
                                 elem = element.toUpperCase();
@@ -824,8 +824,10 @@
                         var lvp = getActiveMaskSet()["lastValidPosition"],
                         pos = lvp == -1 ? ndx : seekNext(lvp);
 
-                        if ($.isArray(opts.mask) || $.inArray(charCode, getActiveBufferTemplate().slice(lvp + 1, pos)) == -1)
+                        if ($.isArray(opts.mask) || $.inArray(charCode, getActiveBufferTemplate().slice(lvp + 1, pos)) == -1) {
+                            //console.log("trigger " + charCode);
                             $(input).trigger("_keypress", [true, charCode.charCodeAt(0), writeOut, strict, ndx]);
+                        }
                     });
 
                     if (strict === true && getActiveMaskSet()["p"] != -1) {
@@ -872,7 +874,7 @@
                 }
 
                 function TranslatePosition(pos) {
-                    if (isRTL && typeof pos == 'number') {
+                    if (isRTL && typeof pos == 'number' && (!opts.greedy || opts.placeholder != "")) {
                         var bffrLght = getActiveBuffer().length;
                         pos = bffrLght - pos;
                     }
@@ -1396,7 +1398,7 @@
                         }
                         var firstMaskPos = seekNext(-1);
                         clearBuffer(getActiveBuffer(), pos.begin, pos.end, true);
-                        checkVal(input, false, false, getActiveBuffer());
+                        checkVal(input, false, masksets[1] == undefined, getActiveBuffer());
                         if (getActiveMaskSet()['lastValidPosition'] < firstMaskPos) {
                             getActiveMaskSet()["lastValidPosition"] = -1;
                             getActiveMaskSet()["p"] = firstMaskPos;
@@ -1635,7 +1637,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.3.63
+Version: 2.3.64
 
 Optional extensions on the jquery.inputmask base
 */
@@ -1737,7 +1739,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2012 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.3.63
+Version: 2.3.64
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2221,7 +2223,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.3.63
+Version: 2.3.64
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2398,7 +2400,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.3.63
+Version: 2.3.64
 
 Regex extensions on the jquery.inputmask base
 Allows for using regular expressions as a mask
@@ -2568,7 +2570,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.3.63
+Version: 2.3.64
 
 Phone extension.
 When using this extension make sure you specify the correct url to get the masks

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


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


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 8 - 6
js/jquery.inputmask.js

@@ -246,7 +246,7 @@
                 }
                 var escaped = false, outCount = 0, greedy = opts.greedy, repeat = opts.repeat;
                 if (repeat == "*") greedy = false;
-                if (greedy == true && opts.placeholder == "") opts.placeholder = " ";
+                //if (greedy == true && opts.placeholder == "") opts.placeholder = " ";
                 if (mask.length == 1 && greedy == false) { opts.placeholder = ""; } //hide placeholder with single non-greedy mask
                 var singleMask = $.map(mask.split(""), function (element, index) {
                     var outElem = [];
@@ -663,8 +663,8 @@
                                         var newValidPosition = result.pos || maskPos;
                                         if (getActiveMaskSet()['lastValidPosition'] < newValidPosition)
                                             getActiveMaskSet()['lastValidPosition'] = newValidPosition; //set new position from isValid
-                                        //console.log("pos " + pos + " ndx " + activeMasksetIndex + " validate " + getActiveBuffer().join('') + " lv " + getActiveMaskSet()['lastValidPosition']);
                                     }
+                                    //console.log("pos " + pos + " ndx " + activeMasksetIndex + " validate " + getActiveBuffer().join('') + " lv " + getActiveMaskSet()['lastValidPosition']);
                                     results.push({ "activeMasksetIndex": index, "result": result });
                                 }
                             }
@@ -748,7 +748,7 @@
 
                     var test = getActiveTests()[determineTestPosition(position)];
                     var elem = element;
-                    if (elem != undefined) {
+                    if (elem != undefined && test != undefined) {
                         switch (test.casing) {
                             case "upper":
                                 elem = element.toUpperCase();
@@ -824,8 +824,10 @@
                         var lvp = getActiveMaskSet()["lastValidPosition"],
                         pos = lvp == -1 ? ndx : seekNext(lvp);
 
-                        if ($.isArray(opts.mask) || $.inArray(charCode, getActiveBufferTemplate().slice(lvp + 1, pos)) == -1)
+                        if ($.isArray(opts.mask) || $.inArray(charCode, getActiveBufferTemplate().slice(lvp + 1, pos)) == -1) {
+                            //console.log("trigger " + charCode);
                             $(input).trigger("_keypress", [true, charCode.charCodeAt(0), writeOut, strict, ndx]);
+                        }
                     });
 
                     if (strict === true && getActiveMaskSet()["p"] != -1) {
@@ -872,7 +874,7 @@
                 }
 
                 function TranslatePosition(pos) {
-                    if (isRTL && typeof pos == 'number') {
+                    if (isRTL && typeof pos == 'number' && (!opts.greedy || opts.placeholder != "")) {
                         var bffrLght = getActiveBuffer().length;
                         pos = bffrLght - pos;
                     }
@@ -1396,7 +1398,7 @@
                         }
                         var firstMaskPos = seekNext(-1);
                         clearBuffer(getActiveBuffer(), pos.begin, pos.end, true);
-                        checkVal(input, false, false, getActiveBuffer());
+                        checkVal(input, false, masksets[1] == undefined, getActiveBuffer());
                         if (getActiveMaskSet()['lastValidPosition'] < firstMaskPos) {
                             getActiveMaskSet()["lastValidPosition"] = -1;
                             getActiveMaskSet()["p"] = firstMaskPos;

+ 1 - 1
qunit/tests.js

@@ -354,7 +354,7 @@ test("inputmask({ mask: \"9\", repeat: 10, placeholder: \"\", numericInput: true
 
     $("#testmask").Type("12345");
 
-    equal($("#testmask").val(), "     12345", "Result " + $("#testmask").val());
+    equal($("#testmask").val(), "12345", "Result " + $("#testmask").val());
 
     $("#testmask").remove();
 });