Browse Source

Merge branch '2.x' into dev

Robin Herbots 12 years ago
parent
commit
e4ae5d6648

+ 1 - 1
build.properties

@@ -7,7 +7,7 @@ distdir = dist
 
 build.major = 2
 build.minor = 3
-build.revision = 4
+build.revision = 7
 
 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.4",
+    "version": "2.3.7",
     "main": "./dist/jquery.inputmask.bundle.js",
     "dependencies": {
         "jquery": ">=1.5"

BIN
dist/jQuery.InputMask.2.3.4.nupkg


BIN
dist/jQuery.InputMask.2.3.7.nupkg


+ 67 - 54
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.4
+* Version: 2.3.7
 */
 
 (function ($) {
@@ -117,39 +117,37 @@
                     case "remove":
                         return this.each(function () {
                             var $input = $(this), input = this;
-                            setTimeout(function () {
-                                if ($input.data('_inputmask')) {
-                                    masksets = $input.data('_inputmask')['masksets'];
-                                    activeMasksetIndex = $input.data('_inputmask')['activeMasksetIndex'];
-                                    opts = $input.data('_inputmask')['opts'];
-                                    //writeout the unmaskedvalue
-                                    input._valueSet(maskScope(masksets, activeMasksetIndex).unmaskedvalue($input, true));
-                                    //clear data
-                                    $input.removeData('_inputmask');
-                                    //unbind all events
-                                    $input.unbind(".inputmask");
-                                    $input.removeClass('focus.inputmask');
-                                    //restore the value property
-                                    var valueProperty;
-                                    if (Object.getOwnPropertyDescriptor)
-                                        valueProperty = Object.getOwnPropertyDescriptor(input, "value");
-                                    if (valueProperty && valueProperty.get) {
-                                        if (input._valueGet) {
-                                            Object.defineProperty(input, "value", {
-                                                get: input._valueGet,
-                                                set: input._valueSet
-                                            });
-                                        }
-                                    } else if (document.__lookupGetter__ && input.__lookupGetter__("value")) {
-                                        if (input._valueGet) {
-                                            input.__defineGetter__("value", input._valueGet);
-                                            input.__defineSetter__("value", input._valueSet);
-                                        }
+                            if ($input.data('_inputmask')) {
+                                masksets = $input.data('_inputmask')['masksets'];
+                                activeMasksetIndex = $input.data('_inputmask')['activeMasksetIndex'];
+                                opts = $input.data('_inputmask')['opts'];
+                                //writeout the unmaskedvalue
+                                input._valueSet(maskScope(masksets, activeMasksetIndex).unmaskedvalue($input, true));
+                                //clear data
+                                $input.removeData('_inputmask');
+                                //unbind all events
+                                $input.unbind(".inputmask");
+                                $input.removeClass('focus.inputmask');
+                                //restore the value property
+                                var valueProperty;
+                                if (Object.getOwnPropertyDescriptor)
+                                    valueProperty = Object.getOwnPropertyDescriptor(input, "value");
+                                if (valueProperty && valueProperty.get) {
+                                    if (input._valueGet) {
+                                        Object.defineProperty(input, "value", {
+                                            get: input._valueGet,
+                                            set: input._valueSet
+                                        });
+                                    }
+                                } else if (document.__lookupGetter__ && input.__lookupGetter__("value")) {
+                                    if (input._valueGet) {
+                                        input.__defineGetter__("value", input._valueGet);
+                                        input.__defineSetter__("value", input._valueSet);
                                     }
-                                    delete input._valueGet;
-                                    delete input._valueSet;
                                 }
-                            }, 0);
+                                delete input._valueGet;
+                                delete input._valueSet;
+                            }
                         });
                         break;
                     case "getemptymask": //return the default (empty) mask value, usefull for setting the default value in validation
@@ -486,9 +484,12 @@
                                     }
                                     var newValidPosition = result.pos || maskPos;
                                     if (activeMaskset['lastValidPosition'] == undefined ||
-                                        (isRTL ? (opts.greedy ? activeMaskset['lastValidPosition'] > newValidPosition : newValidPosition == getActiveBuffer().length - 1)
-                                            : activeMaskset['lastValidPosition'] < newValidPosition))
-                                        activeMaskset['lastValidPosition'] = newValidPosition; //set new position from isValid
+                                        (isRTL ?
+                                            (opts.greedy ?
+                                                activeMaskset['lastValidPosition'] > newValidPosition :
+                                                newValidPosition == getActiveBuffer().length - 1) :
+                                             activeMaskset['lastValidPosition'] < newValidPosition))
+                                        activeMaskset['lastValidPosition'] = opts.numericInput ? 0 : newValidPosition; //set new position from isValid
                                 }
                                 results.push({ "activeMasksetIndex": index, "result": result });
                             }
@@ -640,7 +641,7 @@
                     $.each(masksets, function (ndx, ms) {
                         ms["buffer"] = ms["_buffer"].slice();
                         ms["lastValidPosition"] = undefined;
-                        ms["p"] = isRTL ? getMaskLength() : 0;
+                        ms["p"] = (isRTL && ms["greedy"] == true) ? getMaskLength() : -1;
                     });
                     if (strict !== true) activeMasksetIndex = 0;
                     if (writeOut) input._valueSet(""); //initial clear
@@ -650,7 +651,7 @@
 
                     var ml = getMaskLength();
                     $.each(inputValue, function (ndx, charCode) {
-                        var index = isRTL ? (opts.numericInput ? ml : ml - ndx) : ndx,
+                        var index = (isRTL && getActiveMaskSet()["greedy"] == true) ? (opts.numericInput ? ml : ml - ndx) : ndx,
                             lvp = getActiveMaskSet()["lastValidPosition"],
                             pos = getActiveMaskSet()["p"];
 
@@ -665,7 +666,7 @@
                         }
                     });
                     if (strict === true) {
-                        getActiveMaskSet()["lastValidPosition"] = isRTL ? seekNext(getActiveMaskSet()["p"]) : seekPrevious(getActiveMaskSet()["p"]);
+                        getActiveMaskSet()["lastValidPosition"] = isRTL ? (opts.numericInput ? 0 : seekNext(getActiveMaskSet()["p"])) : seekPrevious(getActiveMaskSet()["p"]);
                     }
                 }
 
@@ -798,13 +799,23 @@
                     getActiveMaskSet()['greedy'] = getActiveMaskSet()['greedy'] ? getActiveMaskSet()['greedy'] : getActiveMaskSet()['repeat'] == 0;
 
                     //handle maxlength attribute
-                    var maxLength = $input.prop('maxLength');
-                    if (getMaskLength() > maxLength && maxLength > -1) { //FF sets no defined max length to -1 
-                        if (maxLength < getActiveBufferTemplate().length) getActiveBufferTemplate().length = maxLength;
-                        if (getActiveMaskSet()['greedy'] == false) {
-                            getActiveMaskSet()['repeat'] = Math.round(maxLength / getActiveBufferTemplate().length);
+                    if ($input.attr("maxLength") != null) //only when the attribute is set
+                    {
+                        var maxLength = $input.prop('maxLength');
+                        if (maxLength > -1) { //handle *-repeat
+                            $.each(masksets, function (ndx, ms) {
+                                if (ms["repeat"] == "*") {
+                                    ms["repeat"] = maxLength;
+                                }
+                            });
+                        }
+                        if (getMaskLength() > maxLength && maxLength > -1) { //FF sets no defined max length to -1 
+                            if (maxLength < getActiveBufferTemplate().length) getActiveBufferTemplate().length = maxLength;
+                            if (getActiveMaskSet()['greedy'] == false) {
+                                getActiveMaskSet()['repeat'] = Math.round(maxLength / getActiveBufferTemplate().length);
+                            }
+                            $input.prop('maxLength', getMaskLength() * 2);
                         }
-                        $input.prop('maxLength', getMaskLength() * 2);
                     }
 
                     patchValueProperty(el);
@@ -1329,6 +1340,11 @@
                                         activeMasksetIndex = ndx;
                                         getActiveMaskSet()["undoBuffer"] = getActiveBuffer().join(''); //init undobuffer for recovery when not valid
                                         var posend = pos.end < getMaskLength() ? pos.end : getMaskLength();
+                                        if (getActiveMaskSet()["lastValidPosition"] > pos.begin && getActiveMaskSet()["lastValidPosition"] < posend) {
+                                            getActiveMaskSet()["lastValidPosition"] = isRTL ? seekNext(posend) : seekPrevious(pos.begin);
+                                        } else {
+                                            redetermineLVP = true;
+                                        }
                                         clearBuffer(getActiveBuffer(), pos.begin, posend);
                                         var ml = getMaskLength();
                                         if (opts.greedy == false) {
@@ -1339,11 +1355,6 @@
                                                     isRTL ? shiftR(0, posend - 1, getPlaceHolder(posend - 1), true) : shiftL(pos.begin, ml);
                                             }
                                         }
-                                        if (getActiveMaskSet()["lastValidPosition"] > pos.begin && getActiveMaskSet()["lastValidPosition"] < posend) {
-                                            getActiveMaskSet()["lastValidPosition"] = isRTL ? seekNext(posend) : seekPrevious(pos.begin);
-                                        } else {
-                                            redetermineLVP = true;
-                                        }
                                     });
                                     if (redetermineLVP === true) {
                                         activeMasksetIndex = initialIndex;
@@ -1360,7 +1371,7 @@
                                 }
 
                                 if (isRTL) {
-                                    var p = seekPrevious(pos.end);
+                                    var p = seekPrevious(isSelection ? pos.begin : pos.end);
                                     results = isValid(p, c, strict, isRTL);
                                     if (strict === true) results = [{ "activeMasksetIndex": activeMasksetIndex, "result": results }];
                                     $.each(results, function (index, result) {
@@ -1495,7 +1506,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.4
+Version: 2.3.7
 
 Optional extensions on the jquery.inputmask base
 */
@@ -1597,7 +1608,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.4
+Version: 2.3.7
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2066,7 +2077,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.4
+Version: 2.3.7
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2233,11 +2244,13 @@ 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.4
+Version: 2.3.7
 
 Regex extensions on the jquery.inputmask base
 Allows for using regular expressions as a mask
 */
+
+/* EXPERIMENTAL */
 (function ($) {
     $.extend($.inputmask.defaults.aliases, { // $(selector).inputmask("Regex", { regex: "[0-9]*"}
         'Regex': {

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


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


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 60 - 49
js/jquery.inputmask.js

@@ -117,39 +117,37 @@
                     case "remove":
                         return this.each(function () {
                             var $input = $(this), input = this;
-                            setTimeout(function () {
-                                if ($input.data('_inputmask')) {
-                                    masksets = $input.data('_inputmask')['masksets'];
-                                    activeMasksetIndex = $input.data('_inputmask')['activeMasksetIndex'];
-                                    opts = $input.data('_inputmask')['opts'];
-                                    //writeout the unmaskedvalue
-                                    input._valueSet(maskScope(masksets, activeMasksetIndex).unmaskedvalue($input, true));
-                                    //clear data
-                                    $input.removeData('_inputmask');
-                                    //unbind all events
-                                    $input.unbind(".inputmask");
-                                    $input.removeClass('focus.inputmask');
-                                    //restore the value property
-                                    var valueProperty;
-                                    if (Object.getOwnPropertyDescriptor)
-                                        valueProperty = Object.getOwnPropertyDescriptor(input, "value");
-                                    if (valueProperty && valueProperty.get) {
-                                        if (input._valueGet) {
-                                            Object.defineProperty(input, "value", {
-                                                get: input._valueGet,
-                                                set: input._valueSet
-                                            });
-                                        }
-                                    } else if (document.__lookupGetter__ && input.__lookupGetter__("value")) {
-                                        if (input._valueGet) {
-                                            input.__defineGetter__("value", input._valueGet);
-                                            input.__defineSetter__("value", input._valueSet);
-                                        }
+                            if ($input.data('_inputmask')) {
+                                masksets = $input.data('_inputmask')['masksets'];
+                                activeMasksetIndex = $input.data('_inputmask')['activeMasksetIndex'];
+                                opts = $input.data('_inputmask')['opts'];
+                                //writeout the unmaskedvalue
+                                input._valueSet(maskScope(masksets, activeMasksetIndex).unmaskedvalue($input, true));
+                                //clear data
+                                $input.removeData('_inputmask');
+                                //unbind all events
+                                $input.unbind(".inputmask");
+                                $input.removeClass('focus.inputmask');
+                                //restore the value property
+                                var valueProperty;
+                                if (Object.getOwnPropertyDescriptor)
+                                    valueProperty = Object.getOwnPropertyDescriptor(input, "value");
+                                if (valueProperty && valueProperty.get) {
+                                    if (input._valueGet) {
+                                        Object.defineProperty(input, "value", {
+                                            get: input._valueGet,
+                                            set: input._valueSet
+                                        });
+                                    }
+                                } else if (document.__lookupGetter__ && input.__lookupGetter__("value")) {
+                                    if (input._valueGet) {
+                                        input.__defineGetter__("value", input._valueGet);
+                                        input.__defineSetter__("value", input._valueSet);
                                     }
-                                    delete input._valueGet;
-                                    delete input._valueSet;
                                 }
-                            }, 0);
+                                delete input._valueGet;
+                                delete input._valueSet;
+                            }
                         });
                         break;
                     case "getemptymask": //return the default (empty) mask value, usefull for setting the default value in validation
@@ -486,9 +484,12 @@
                                     }
                                     var newValidPosition = result.pos || maskPos;
                                     if (activeMaskset['lastValidPosition'] == undefined ||
-                                        (isRTL ? (opts.greedy ? activeMaskset['lastValidPosition'] > newValidPosition : newValidPosition == getActiveBuffer().length - 1)
-                                            : activeMaskset['lastValidPosition'] < newValidPosition))
-                                        activeMaskset['lastValidPosition'] = newValidPosition; //set new position from isValid
+                                        (isRTL ?
+                                            (opts.greedy ?
+                                                activeMaskset['lastValidPosition'] > newValidPosition :
+                                                newValidPosition == getActiveBuffer().length - 1) :
+                                             activeMaskset['lastValidPosition'] < newValidPosition))
+                                        activeMaskset['lastValidPosition'] = opts.numericInput ? 0 : newValidPosition; //set new position from isValid
                                 }
                                 results.push({ "activeMasksetIndex": index, "result": result });
                             }
@@ -640,7 +641,7 @@
                     $.each(masksets, function (ndx, ms) {
                         ms["buffer"] = ms["_buffer"].slice();
                         ms["lastValidPosition"] = undefined;
-                        ms["p"] = isRTL ? getMaskLength() : 0;
+                        ms["p"] = (isRTL && ms["greedy"] == true) ? getMaskLength() : -1;
                     });
                     if (strict !== true) activeMasksetIndex = 0;
                     if (writeOut) input._valueSet(""); //initial clear
@@ -650,7 +651,7 @@
 
                     var ml = getMaskLength();
                     $.each(inputValue, function (ndx, charCode) {
-                        var index = isRTL ? (opts.numericInput ? ml : ml - ndx) : ndx,
+                        var index = (isRTL && getActiveMaskSet()["greedy"] == true) ? (opts.numericInput ? ml : ml - ndx) : ndx,
                             lvp = getActiveMaskSet()["lastValidPosition"],
                             pos = getActiveMaskSet()["p"];
 
@@ -665,7 +666,7 @@
                         }
                     });
                     if (strict === true) {
-                        getActiveMaskSet()["lastValidPosition"] = isRTL ? seekNext(getActiveMaskSet()["p"]) : seekPrevious(getActiveMaskSet()["p"]);
+                        getActiveMaskSet()["lastValidPosition"] = isRTL ? (opts.numericInput ? 0 : seekNext(getActiveMaskSet()["p"])) : seekPrevious(getActiveMaskSet()["p"]);
                     }
                 }
 
@@ -798,13 +799,23 @@
                     getActiveMaskSet()['greedy'] = getActiveMaskSet()['greedy'] ? getActiveMaskSet()['greedy'] : getActiveMaskSet()['repeat'] == 0;
 
                     //handle maxlength attribute
-                    var maxLength = $input.prop('maxLength');
-                    if (getMaskLength() > maxLength && maxLength > -1) { //FF sets no defined max length to -1 
-                        if (maxLength < getActiveBufferTemplate().length) getActiveBufferTemplate().length = maxLength;
-                        if (getActiveMaskSet()['greedy'] == false) {
-                            getActiveMaskSet()['repeat'] = Math.round(maxLength / getActiveBufferTemplate().length);
+                    if ($input.attr("maxLength") != null) //only when the attribute is set
+                    {
+                        var maxLength = $input.prop('maxLength');
+                        if (maxLength > -1) { //handle *-repeat
+                            $.each(masksets, function (ndx, ms) {
+                                if (ms["repeat"] == "*") {
+                                    ms["repeat"] = maxLength;
+                                }
+                            });
+                        }
+                        if (getMaskLength() > maxLength && maxLength > -1) { //FF sets no defined max length to -1 
+                            if (maxLength < getActiveBufferTemplate().length) getActiveBufferTemplate().length = maxLength;
+                            if (getActiveMaskSet()['greedy'] == false) {
+                                getActiveMaskSet()['repeat'] = Math.round(maxLength / getActiveBufferTemplate().length);
+                            }
+                            $input.prop('maxLength', getMaskLength() * 2);
                         }
-                        $input.prop('maxLength', getMaskLength() * 2);
                     }
 
                     patchValueProperty(el);
@@ -1329,6 +1340,11 @@
                                         activeMasksetIndex = ndx;
                                         getActiveMaskSet()["undoBuffer"] = getActiveBuffer().join(''); //init undobuffer for recovery when not valid
                                         var posend = pos.end < getMaskLength() ? pos.end : getMaskLength();
+                                        if (getActiveMaskSet()["lastValidPosition"] > pos.begin && getActiveMaskSet()["lastValidPosition"] < posend) {
+                                            getActiveMaskSet()["lastValidPosition"] = isRTL ? seekNext(posend) : seekPrevious(pos.begin);
+                                        } else {
+                                            redetermineLVP = true;
+                                        }
                                         clearBuffer(getActiveBuffer(), pos.begin, posend);
                                         var ml = getMaskLength();
                                         if (opts.greedy == false) {
@@ -1339,11 +1355,6 @@
                                                     isRTL ? shiftR(0, posend - 1, getPlaceHolder(posend - 1), true) : shiftL(pos.begin, ml);
                                             }
                                         }
-                                        if (getActiveMaskSet()["lastValidPosition"] > pos.begin && getActiveMaskSet()["lastValidPosition"] < posend) {
-                                            getActiveMaskSet()["lastValidPosition"] = isRTL ? seekNext(posend) : seekPrevious(pos.begin);
-                                        } else {
-                                            redetermineLVP = true;
-                                        }
                                     });
                                     if (redetermineLVP === true) {
                                         activeMasksetIndex = initialIndex;
@@ -1360,7 +1371,7 @@
                                 }
 
                                 if (isRTL) {
-                                    var p = seekPrevious(pos.end);
+                                    var p = seekPrevious(isSelection ? pos.begin : pos.end);
                                     results = isValid(p, c, strict, isRTL);
                                     if (strict === true) results = [{ "activeMasksetIndex": activeMasksetIndex, "result": results }];
                                     $.each(results, function (index, result) {

+ 2 - 0
js/jquery.inputmask.regex.extensions.js

@@ -8,6 +8,8 @@ Version: 0.0.0
 Regex extensions on the jquery.inputmask base
 Allows for using regular expressions as a mask
 */
+
+/* EXPERIMENTAL */
 (function ($) {
     $.extend($.inputmask.defaults.aliases, { // $(selector).inputmask("Regex", { regex: "[0-9]*"}
         'Regex': {

+ 166 - 37
qunit/tests.js

@@ -2,7 +2,39 @@ var keyCodes = {
     ALT: 18, BACKSPACE: 8, CAPS_LOCK: 20, COMMA: 188, COMMAND: 91, COMMAND_LEFT: 91, COMMAND_RIGHT: 93, CONTROL: 17, DELETE: 46, DOWN: 40, END: 35, ENTER: 13, ESCAPE: 27, HOME: 36, INSERT: 45, LEFT: 37, MENU: 93, NUMPAD_ADD: 107, NUMPAD_DECIMAL: 110, NUMPAD_DIVIDE: 111, NUMPAD_ENTER: 108,
     NUMPAD_MULTIPLY: 106, NUMPAD_SUBTRACT: 109, PAGE_DOWN: 34, PAGE_UP: 33, PERIOD: 190, RIGHT: 39, SHIFT: 16, SPACE: 32, TAB: 9, UP: 38, WINDOWS: 91
 }
-
+function caret(input, begin, end) {
+    var npt = input.jquery && input.length > 0 ? input[0] : input, range;
+    if (typeof begin == 'number') {
+        if (!$(input).is(':visible')) {
+            return;
+        }
+        end = (typeof end == 'number') ? end : begin;
+        if (npt.setSelectionRange) {
+            npt.selectionStart = begin;
+            npt.selectionEnd = end;
+
+        } else if (npt.createTextRange) {
+            range = npt.createTextRange();
+            range.collapse(true);
+            range.moveEnd('character', end);
+            range.moveStart('character', begin);
+            range.select();
+        }
+    } else {
+        if (!$(input).is(':visible')) {
+            return { "begin": 0, "end": 0 };
+        }
+        if (npt.setSelectionRange) {
+            begin = npt.selectionStart;
+            end = npt.selectionEnd;
+        } else if (document.selection && document.selection.createRange) {
+            range = document.selection.createRange();
+            begin = 0 - range.duplicate().moveStart('character', -100000);
+            end = begin + range.text.length;
+        }
+        return { "begin": begin, "end": end };
+    }
+};
 $.fn.SendKey = function (keyCode, modifier) {
     var sendDummyKeydown = false;
     if (Object.prototype.toString.call(keyCode) == '[object String]') {
@@ -10,40 +42,6 @@ $.fn.SendKey = function (keyCode, modifier) {
         sendDummyKeydown = true;
     }
 
-    function caret(input, begin, end) {
-        var npt = input.jquery && input.length > 0 ? input[0] : input, range;
-        if (typeof begin == 'number') {
-            if (!$(input).is(':visible')) {
-                return;
-            }
-            end = (typeof end == 'number') ? end : begin;
-            if (npt.setSelectionRange) {
-                npt.selectionStart = begin;
-                npt.selectionEnd = end;
-
-            } else if (npt.createTextRange) {
-                range = npt.createTextRange();
-                range.collapse(true);
-                range.moveEnd('character', end);
-                range.moveStart('character', begin);
-                range.select();
-            }
-        } else {
-            if (!$(input).is(':visible')) {
-                return { "begin": 0, "end": 0 };
-            }
-            if (npt.setSelectionRange) {
-                begin = npt.selectionStart;
-                end = npt.selectionEnd;
-            } else if (document.selection && document.selection.createRange) {
-                range = document.selection.createRange();
-                begin = 0 - range.duplicate().moveStart('character', -100000);
-                end = begin + range.text.length;
-            }
-            return { "begin": begin, "end": end };
-        }
-    };
-
     switch (keyCode) {
         case keyCodes.LEFT: {
             if (modifier == undefined) {
@@ -253,6 +251,33 @@ test("inputmask(\"*****\")", function () {
     $("#testmask").remove();
 });
 
+module("Non-greedy masks");
+test("inputmask(\"*\", { greedy: false, repeat: \"*\" }) - replace cd with 1", function () {
+    $('body').append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask("*", { greedy: false, repeat: "*" });
+
+    $("#testmask")[0].focus();
+
+    $("#testmask").Type("abcdef");
+    caret($("#testmask"), 2, 4);
+    $("#testmask").SendKey("1");
+    equal($("#testmask").val(), "ab1ef", "Result " + $("#testmask").val());
+
+    $("#testmask").remove();
+});
+
+test("inputmask(\"*\", { greedy: false, repeat: \"*\" }) - type abcdef", function () {
+    $('body').append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask("*", { greedy: false, repeat: "*" });
+
+    $("#testmask")[0].focus();
+
+    $("#testmask").Type("abcdef");
+
+    equal($("#testmask").val(), "abcdef", "Result " + $("#testmask").val());
+
+    $("#testmask").remove();
+});
 
 module("Initial value setting");
 
@@ -369,7 +394,7 @@ test("inputmask({ mask: [\"999.999.999-99\", \"99.999.999/9999-99\"]}) - input 1
 
     $("#testmask")[0].focus();
     $("#testmask").Type("12312312312");
-    
+
     equal($("#testmask").val(), "123.123.123-12", "Result " + $("#testmask").val());
 
     $("#testmask").remove();
@@ -380,7 +405,7 @@ test("inputmask({ mask: [\"999.999.999-99\", \"99.999.999/9999-99\"]}) - input 1
 
     $("#testmask")[0].focus();
     $("#testmask").Type("12.123123123412");
- 
+
     equal($("#testmask").val(), "12.123.123/1234-12", "Result " + $("#testmask").val());
 
     $("#testmask").remove();
@@ -659,6 +684,20 @@ test("inputmask(\"dd/mm/yyyy\") - input 2331973 BACKSPACE x4 2013", function ()
 
     $("#testmask").remove();
 });
+test("inputmask(\"hh:mm\") - add remove add", function () {
+    $('body').append('<input type="text" id="testmask" />');
+    $('#testmask').inputmask('hh:mm', { clearIncomplete: true });
+    $('#testmask').inputmask('remove');
+    $('#testmask').inputmask('hh:mm', { clearIncomplete: true });
+
+    $("#testmask")[0].focus();
+    $("#testmask").Type("abcdef");
+    $("#testmask").Type("23:50");
+   
+    equal($("#testmask").val(), "23:50", "Result " + $("#testmask").val());
+
+    $("#testmask").remove();
+});
 
 module("Numeric.Extensions");
 test("inputmask(\"decimal\", { autoGroup: true, groupSeparator: \",\" }\") - input 12345.123", function () {
@@ -764,6 +803,96 @@ test("inputmask(\"decimal\", { autoGroup: false, groupSeparator: \",\" }\") - in
     $("#testmask").remove();
 });
 
+test("inputmask(\"decimal\") - maxlength 10", function () {
+    $('body').append('<input type="text" id="testmask" maxlength="10" />');
+    $("#testmask").inputmask("decimal");
+
+    $("#testmask")[0].focus();
+
+    $("#testmask").Type("123456789012345");
+
+    equal($("#testmask").val(), "1234567890", "Result " + $("#testmask").val());
+    $("#testmask").remove();
+});
+
+test("inputmask(\"decimal, { repeat: 15 }\") - maxlength 10", function () {
+    $('body').append('<input type="text" id="testmask" maxlength="10" />');
+    $("#testmask").inputmask("decimal", { repeat: 15 });
+
+    $("#testmask")[0].focus();
+
+    $("#testmask").Type("123456789012345");
+
+    equal($("#testmask").val(), "1234567890", "Result " + $("#testmask").val());
+    $("#testmask").remove();
+});
+
+test("inputmask(\"decimal, { repeat: 5 }\") - maxlength 10", function () {
+    $('body').append('<input type="text" id="testmask" maxlength="10" />');
+    $("#testmask").inputmask("decimal", { repeat: 5 });
+
+    $("#testmask")[0].focus();
+
+    $("#testmask").Type("123456789012345");
+
+    equal($("#testmask").val(), "12345", "Result " + $("#testmask").val());
+    $("#testmask").remove();
+});
+
+test("inputmask(\"decimal\")", function () {
+    $('body').append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask("decimal");
+
+    $("#testmask")[0].focus();
+
+    $("#testmask").Type("1234567890");
+    caret($("#testmask"), 0, 10);
+    $("#testmask").Type("12345");
+
+    equal($("#testmask").val(), "12345", "Result " + $("#testmask").val());
+    $("#testmask").remove();
+});
+
+test("inputmask(\"decimal\") - value=\"1234567890\"", function () {
+    $('body').append('<input type="text" id="testmask" value="1234567890" />');
+    $("#testmask").inputmask("decimal");
+
+    $("#testmask")[0].focus();
+
+    caret($("#testmask"), 0, 10);
+    $("#testmask").Type("12345");
+
+    equal($("#testmask").val(), "12345", "Result " + $("#testmask").val());
+    $("#testmask").remove();
+});
+
+test("inputmask(\"decimal\")", function () {
+    $('body').append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask("decimal");
+
+    $("#testmask")[0].focus();
+
+    $("#testmask").Type("1234567890");
+    caret($("#testmask"), 3, 5);
+    $("#testmask").SendKey("0");
+
+    equal($("#testmask").val(), "123067890", "Result " + $("#testmask").val());
+    $("#testmask").remove();
+});
+
+test("inputmask(\"decimal\") - value=\"1234567890\"", function () {
+    $('body').append('<input type="text" id="testmask" value="1234567890" />');
+    $("#testmask").inputmask("decimal");
+
+    $("#testmask")[0].focus();
+
+    caret($("#testmask"), 3, 5);
+    $("#testmask").SendKey("0");
+
+    equal($("#testmask").val(), "123067890", "Result " + $("#testmask").val());
+    $("#testmask").remove();
+});
+
 module("Direction RTL");
 test("inputmask(\"999.999.999\") - delete 2nd with backspace, continue the mask", function () {
     $('body').append('<input type="text" id="testmask" dir="rtl" />');