Browse Source

Update alternation handling + update event handling for android

Robin Herbots 9 years ago
parent
commit
e5c004314f

+ 1 - 1
README.md

@@ -27,7 +27,7 @@ Highlights:
 - value formatting / validating without input element
 - AMD/CommonJS support
 - dependencyLibs: vanilla javascript, jQuery, jqlite
-- [Android support](README_android.md)
+- <strike>[Android support](README_android.md)</strike>
 
 Demo page see [http://robinherbots.github.io/Inputmask](http://robinherbots.github.io/Inputmask)
 

+ 5 - 0
README_android.md

@@ -13,6 +13,11 @@ When browsers would implement the inputmode attribute, disabling will be possibl
 [Inputmode html spec](https://html.spec.whatwg.org/multipage/forms.html#input-modalities:-the-inputmode-attribute)
 [Inputmode chromestatus](https://www.chromestatus.com/feature/6225984592281600)
 
+##Update 18/01/2017
+
+It seems that the GBoard fires the keydown event only with 229 as keycode.  This behavior is not considered a bug as others means should be used to handle input.  (when available offcourse ;-) )
+See https://github.com/w3c/input-events
+
 ##The workaround, the patchwork, the bad and ugly ;-)
 
 This is not enabled by default, because I find that the developer should be aware of what it does and what you need to take into account when using this hack.

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.3.5-19",
+  "version": "3.3.5-23",
   "main": [
 	  "./dist/inputmask/inputmask.dependencyLib",
 	  "./dist/inputmask/inputmask",

+ 1 - 1
component.json

@@ -2,7 +2,7 @@
 	"name": "jquery_inputmask",
 	"repository": "robinherbots/jquery.inputmask",
 	"description": "jquery.inputmask is a jquery plugin which create an input mask.",
-	"version": "3.3.5-19",
+	"version": "3.3.5-23",
 	"keywords": [
 		"jquery",
 		"plugins",

+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
   "name": "robinherbots/jquery.inputmask",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
-  "version": "3.3.5-19",
+  "version": "3.3.5-23",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/jquery.inputmask",

+ 1 - 1
dist/inputmask/inputmask.date.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-19
+* Version: 3.3.5-23
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/inputmask.dependencyLib.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-19
+* Version: 3.3.5-23
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define("inputmask.dependencyLib", [ "jquery" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery")) : factory(jQuery);

+ 1 - 1
dist/inputmask/inputmask.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-19
+* Version: 3.3.5-23
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 21 - 26
dist/inputmask/inputmask.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-19
+* Version: 3.3.5-23
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define("inputmask", [ "inputmask.dependencyLib" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib")) : factory(window.dependencyLib || jQuery);
@@ -297,8 +297,9 @@
             }
             return elem;
         }
-        function checkAlternationMatch(altArr1, altArr2) {
-            for (var altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1), isMatch = !1, alndx = 0; alndx < altArr1.length; alndx++) if ($.inArray(altArr1[alndx], altArrC) !== -1) {
+        function checkAlternationMatch(altArr1, altArr2, na) {
+            for (var naNdx, altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1), isMatch = !1, naArr = void 0 !== na ? na.split(",") : [], i = 0; i < naArr.length; i++) (naNdx = altArr1.indexOf(naArr[i])) !== -1 && altArr1.splice(naNdx, 1);
+            for (var alndx = 0; alndx < altArr1.length; alndx++) if ($.inArray(altArr1[alndx], altArrC) !== -1) {
                 isMatch = !0;
                 break;
             }
@@ -398,13 +399,14 @@
             function trackbackAlternations(originalPos, newPos) {
                 var vp = getMaskSet().validPositions[newPos];
                 if (vp) for (var targetLocator = vp.locator, tll = targetLocator.length, ps = originalPos; ps < newPos; ps++) if (void 0 === getMaskSet().validPositions[ps] && !isMask(ps, !0)) {
-                    var tests = getTests(ps), bestMatch = tests[0], equality = -1;
-                    $.each(tests, function(ndx, tst) {
-                        for (var i = 0; i < tll && (void 0 !== tst.locator[i] && checkAlternationMatch(tst.locator[i].toString().split(","), targetLocator[i].toString().split(","))); i++) equality < i && (equality = i, 
-                        bestMatch = tst);
-                    }), setValidPosition(ps, $.extend({}, bestMatch, {
+                    var tests = getTests(ps).slice(), bestMatch = determineTestTemplate(tests, !0), equality = -1;
+                    "" === tests[tests.length - 1].match.def && tests.pop(), $.each(tests, function(ndx, tst) {
+                        for (var i = 0; i < tll && (void 0 !== tst.locator[i] && checkAlternationMatch(tst.locator[i].toString().split(","), targetLocator[i].toString().split(","), tst.na)); i++) equality < i ? (equality = i, 
+                        bestMatch = tst) : equality == i && (bestMatch = determineTestTemplate(tests, !0));
+                    }), bestMatch = $.extend({}, bestMatch, {
                         input: getPlaceholder(ps, bestMatch.match, !0) || bestMatch.match.def
-                    }), !0);
+                    }), bestMatch.generatedInput = !0, setValidPosition(ps, bestMatch, !0), getMaskSet().validPositions[newPos] = void 0, 
+                    _isValid(newPos, vp.input, !0);
                 }
             }
             function setValidPosition(pos, validTest, fromSetValid, isSelection) {
@@ -422,7 +424,7 @@
                                 var result = isValid(posMatch, t.input, !0, !0);
                                 valid = result !== !1, j = result.caret || result.insert ? getLastValidPosition() : posMatch, 
                                 needsValidation = !0;
-                            } else valid = t.generatedInput === !0;
+                            } else if (valid = t.generatedInput === !0, !valid && posMatch >= getMaskSet().maskLength - 1) break;
                             if (getMaskSet().maskLength < initialLength && (getMaskSet().maskLength = initialLength), 
                             valid) break;
                         }
@@ -450,17 +452,10 @@
             (!strict || fromSetValid === !0) && result === !1)) {
                 var currentPosValid = getMaskSet().validPositions[maskPos];
                 if (!currentPosValid || null !== currentPosValid.match.fn || currentPosValid.match.def !== c && c !== opts.skipOptionalPartCharacter) {
-                    if ((opts.insertMode || void 0 === getMaskSet().validPositions[seekNext(maskPos)]) && !isMask(maskPos, !0)) {
-                        var testsFromPos = getTests(maskPos).slice();
-                        "" === testsFromPos[testsFromPos.length - 1].match.def && testsFromPos.pop();
-                        var staticChar = determineTestTemplate(testsFromPos, !0);
-                        staticChar && null === staticChar.match.fn && (staticChar = getPlaceholder(void 0, staticChar.match, !0) || staticChar.match.def, 
-                        _isValid(maskPos, staticChar, strict), getMaskSet().validPositions[maskPos].generatedInput = !0);
-                        for (var nPos = maskPos + 1, snPos = seekNext(maskPos); nPos <= snPos; nPos++) if (result = _isValid(nPos, c, strict), 
-                        result !== !1) {
-                            trackbackAlternations(maskPos, void 0 !== result.pos ? result.pos : nPos), maskPos = nPos;
-                            break;
-                        }
+                    if ((opts.insertMode || void 0 === getMaskSet().validPositions[seekNext(maskPos)]) && !isMask(maskPos, !0)) for (var nPos = maskPos + 1, snPos = seekNext(maskPos); nPos <= snPos; nPos++) if (result = _isValid(nPos, c, strict), 
+                    result !== !1) {
+                        trackbackAlternations(maskPos, void 0 !== result.pos ? result.pos : nPos), maskPos = nPos;
+                        break;
                     }
                 } else result = {
                     caret: seekNext(maskPos)
@@ -849,12 +844,12 @@
             EventRuler.on(el, "dragdrop", EventHandlers.pasteEvent), EventRuler.on(el, "drop", EventHandlers.pasteEvent), 
             EventRuler.on(el, "cut", EventHandlers.cutEvent), EventRuler.on(el, "complete", opts.oncomplete), 
             EventRuler.on(el, "incomplete", opts.onincomplete), EventRuler.on(el, "cleared", opts.oncleared), 
-            opts.inputEventOnly !== !0 && (EventRuler.on(el, "keydown", EventHandlers.keydownEvent), 
+            android && opts.inputEventOnly === !0 || (EventRuler.on(el, "keydown", EventHandlers.keydownEvent), 
             EventRuler.on(el, "keypress", EventHandlers.keypressEvent)), EventRuler.on(el, "compositionstart", $.noop), 
             EventRuler.on(el, "compositionupdate", $.noop), EventRuler.on(el, "compositionend", $.noop), 
-            EventRuler.on(el, "keyup", $.noop), EventRuler.on(el, "input", EventHandlers.inputFallBackEvent)), 
-            EventRuler.on(el, "setvalue", EventHandlers.setValueEvent), getBufferTemplate(), 
-            "" !== el.inputmask._valueGet() || opts.clearMaskOnLostFocus === !1 || document.activeElement === el)) {
+            EventRuler.on(el, "keyup", $.noop), EventRuler.on(el, "input", EventHandlers.inputFallBackEvent), 
+            EventRuler.on(el, "beforeinput", $.noop)), EventRuler.on(el, "setvalue", EventHandlers.setValueEvent), 
+            getBufferTemplate(), "" !== el.inputmask._valueGet() || opts.clearMaskOnLostFocus === !1 || document.activeElement === el)) {
                 var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(el.inputmask._valueGet(), opts) || el.inputmask._valueGet() : el.inputmask._valueGet();
                 checkVal(el, !0, !1, initialValue.split(""));
                 var buffer = getBuffer().slice();
@@ -1230,7 +1225,7 @@
             positionCaretOnTab: !0,
             tabThrough: !1,
             supportsInputType: [ "text", "tel", "password" ],
-            ignorables: [ 8, 9, 13, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123 ],
+            ignorables: [ 8, 9, 13, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 0, 229 ],
             isComplete: null,
             canClearPosition: $.noop,
             postValidation: null,

+ 1 - 1
dist/inputmask/inputmask.numeric.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-19
+* Version: 3.3.5-23
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 2 - 2
dist/inputmask/inputmask.phone.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-19
+* Version: 3.3.5-23
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);
@@ -30,7 +30,7 @@
         var maskGroups = {};
         opts.phoneCodes && opts.phoneCodes.length > 1e3 && (mask = mask.substr(1, mask.length - 2), 
         reduceVariations(mask.split(opts.groupmarker.end + opts.alternatormarker + opts.groupmarker.start)), 
-        mask = rebuild(maskGroups));
+        mask = rebuild(maskGroups)), mask = mask.replace(/9/g, "\\9");
         var mt = analyseMaskBase.call(this, mask, opts);
         return mt;
     }, Inputmask.extendAliases({

+ 1 - 1
dist/inputmask/inputmask.regex.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-19
+* Version: 3.3.5-23
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/jquery.inputmask.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-19
+* Version: 3.3.5-23
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./inputmask")) : factory(jQuery, window.Inputmask);

+ 22 - 27
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-19
+* Version: 3.3.5-23
 */
 !function($) {
     function Inputmask(alias, options, internal) {
@@ -295,8 +295,9 @@
             }
             return elem;
         }
-        function checkAlternationMatch(altArr1, altArr2) {
-            for (var altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1), isMatch = !1, alndx = 0; alndx < altArr1.length; alndx++) if ($.inArray(altArr1[alndx], altArrC) !== -1) {
+        function checkAlternationMatch(altArr1, altArr2, na) {
+            for (var naNdx, altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1), isMatch = !1, naArr = void 0 !== na ? na.split(",") : [], i = 0; i < naArr.length; i++) (naNdx = altArr1.indexOf(naArr[i])) !== -1 && altArr1.splice(naNdx, 1);
+            for (var alndx = 0; alndx < altArr1.length; alndx++) if ($.inArray(altArr1[alndx], altArrC) !== -1) {
                 isMatch = !0;
                 break;
             }
@@ -396,13 +397,14 @@
             function trackbackAlternations(originalPos, newPos) {
                 var vp = getMaskSet().validPositions[newPos];
                 if (vp) for (var targetLocator = vp.locator, tll = targetLocator.length, ps = originalPos; ps < newPos; ps++) if (void 0 === getMaskSet().validPositions[ps] && !isMask(ps, !0)) {
-                    var tests = getTests(ps), bestMatch = tests[0], equality = -1;
-                    $.each(tests, function(ndx, tst) {
-                        for (var i = 0; i < tll && (void 0 !== tst.locator[i] && checkAlternationMatch(tst.locator[i].toString().split(","), targetLocator[i].toString().split(","))); i++) equality < i && (equality = i, 
-                        bestMatch = tst);
-                    }), setValidPosition(ps, $.extend({}, bestMatch, {
+                    var tests = getTests(ps).slice(), bestMatch = determineTestTemplate(tests, !0), equality = -1;
+                    "" === tests[tests.length - 1].match.def && tests.pop(), $.each(tests, function(ndx, tst) {
+                        for (var i = 0; i < tll && (void 0 !== tst.locator[i] && checkAlternationMatch(tst.locator[i].toString().split(","), targetLocator[i].toString().split(","), tst.na)); i++) equality < i ? (equality = i, 
+                        bestMatch = tst) : equality == i && (bestMatch = determineTestTemplate(tests, !0));
+                    }), bestMatch = $.extend({}, bestMatch, {
                         input: getPlaceholder(ps, bestMatch.match, !0) || bestMatch.match.def
-                    }), !0);
+                    }), bestMatch.generatedInput = !0, setValidPosition(ps, bestMatch, !0), getMaskSet().validPositions[newPos] = void 0, 
+                    _isValid(newPos, vp.input, !0);
                 }
             }
             function setValidPosition(pos, validTest, fromSetValid, isSelection) {
@@ -420,7 +422,7 @@
                                 var result = isValid(posMatch, t.input, !0, !0);
                                 valid = result !== !1, j = result.caret || result.insert ? getLastValidPosition() : posMatch, 
                                 needsValidation = !0;
-                            } else valid = t.generatedInput === !0;
+                            } else if (valid = t.generatedInput === !0, !valid && posMatch >= getMaskSet().maskLength - 1) break;
                             if (getMaskSet().maskLength < initialLength && (getMaskSet().maskLength = initialLength), 
                             valid) break;
                         }
@@ -448,17 +450,10 @@
             (!strict || fromSetValid === !0) && result === !1)) {
                 var currentPosValid = getMaskSet().validPositions[maskPos];
                 if (!currentPosValid || null !== currentPosValid.match.fn || currentPosValid.match.def !== c && c !== opts.skipOptionalPartCharacter) {
-                    if ((opts.insertMode || void 0 === getMaskSet().validPositions[seekNext(maskPos)]) && !isMask(maskPos, !0)) {
-                        var testsFromPos = getTests(maskPos).slice();
-                        "" === testsFromPos[testsFromPos.length - 1].match.def && testsFromPos.pop();
-                        var staticChar = determineTestTemplate(testsFromPos, !0);
-                        staticChar && null === staticChar.match.fn && (staticChar = getPlaceholder(void 0, staticChar.match, !0) || staticChar.match.def, 
-                        _isValid(maskPos, staticChar, strict), getMaskSet().validPositions[maskPos].generatedInput = !0);
-                        for (var nPos = maskPos + 1, snPos = seekNext(maskPos); nPos <= snPos; nPos++) if (result = _isValid(nPos, c, strict), 
-                        result !== !1) {
-                            trackbackAlternations(maskPos, void 0 !== result.pos ? result.pos : nPos), maskPos = nPos;
-                            break;
-                        }
+                    if ((opts.insertMode || void 0 === getMaskSet().validPositions[seekNext(maskPos)]) && !isMask(maskPos, !0)) for (var nPos = maskPos + 1, snPos = seekNext(maskPos); nPos <= snPos; nPos++) if (result = _isValid(nPos, c, strict), 
+                    result !== !1) {
+                        trackbackAlternations(maskPos, void 0 !== result.pos ? result.pos : nPos), maskPos = nPos;
+                        break;
                     }
                 } else result = {
                     caret: seekNext(maskPos)
@@ -847,12 +842,12 @@
             EventRuler.on(el, "dragdrop", EventHandlers.pasteEvent), EventRuler.on(el, "drop", EventHandlers.pasteEvent), 
             EventRuler.on(el, "cut", EventHandlers.cutEvent), EventRuler.on(el, "complete", opts.oncomplete), 
             EventRuler.on(el, "incomplete", opts.onincomplete), EventRuler.on(el, "cleared", opts.oncleared), 
-            opts.inputEventOnly !== !0 && (EventRuler.on(el, "keydown", EventHandlers.keydownEvent), 
+            android && opts.inputEventOnly === !0 || (EventRuler.on(el, "keydown", EventHandlers.keydownEvent), 
             EventRuler.on(el, "keypress", EventHandlers.keypressEvent)), EventRuler.on(el, "compositionstart", $.noop), 
             EventRuler.on(el, "compositionupdate", $.noop), EventRuler.on(el, "compositionend", $.noop), 
-            EventRuler.on(el, "keyup", $.noop), EventRuler.on(el, "input", EventHandlers.inputFallBackEvent)), 
-            EventRuler.on(el, "setvalue", EventHandlers.setValueEvent), getBufferTemplate(), 
-            "" !== el.inputmask._valueGet() || opts.clearMaskOnLostFocus === !1 || document.activeElement === el)) {
+            EventRuler.on(el, "keyup", $.noop), EventRuler.on(el, "input", EventHandlers.inputFallBackEvent), 
+            EventRuler.on(el, "beforeinput", $.noop)), EventRuler.on(el, "setvalue", EventHandlers.setValueEvent), 
+            getBufferTemplate(), "" !== el.inputmask._valueGet() || opts.clearMaskOnLostFocus === !1 || document.activeElement === el)) {
                 var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(el.inputmask._valueGet(), opts) || el.inputmask._valueGet() : el.inputmask._valueGet();
                 checkVal(el, !0, !1, initialValue.split(""));
                 var buffer = getBuffer().slice();
@@ -1228,7 +1223,7 @@
             positionCaretOnTab: !0,
             tabThrough: !1,
             supportsInputType: [ "text", "tel", "password" ],
-            ignorables: [ 8, 9, 13, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123 ],
+            ignorables: [ 8, 9, 13, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 0, 229 ],
             isComplete: null,
             canClearPosition: $.noop,
             postValidation: null,
@@ -2571,7 +2566,7 @@
         var maskGroups = {};
         opts.phoneCodes && opts.phoneCodes.length > 1e3 && (mask = mask.substr(1, mask.length - 2), 
         reduceVariations(mask.split(opts.groupmarker.end + opts.alternatormarker + opts.groupmarker.start)), 
-        mask = rebuild(maskGroups));
+        mask = rebuild(maskGroups)), mask = mask.replace(/9/g, "\\9");
         var mt = analyseMaskBase.call(this, mask, opts);
         return mt;
     }, Inputmask.extendAliases({

File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/inputmask.date.extensions.min.js


+ 1 - 1
dist/min/inputmask/inputmask.dependencyLib.min.js

@@ -3,6 +3,6 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-19
+* Version: 3.3.5-23
 */
 !function(a){"function"==typeof define&&define.amd?define("inputmask.dependencyLib",["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){return window.dependencyLib=a,a});

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


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


File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/inputmask.numeric.extensions.min.js


File diff suppressed because it is too large
+ 2 - 2
dist/min/inputmask/inputmask.phone.extensions.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/inputmask.regex.extensions.min.js


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


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


+ 35 - 17
js/inputmask.js

@@ -103,7 +103,7 @@
 			tabThrough: false, //allows for tabbing through the different parts of the masked field
 			supportsInputType: ["text", "tel", "password"], //list with the supported input types
 			//specify keyCodes which should not be considered in the keypress event, otherwise the preventDefault will stop their default behavior especially in FF
-			ignorables: [8, 9, 13, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123],
+			ignorables: [8, 9, 13, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 0, 229],
 			isComplete: null, //override for isComplete - args => buffer, opts - return true || false
 			canClearPosition: $.noop, //hook to alter the clear behavior in the stripValidPositions args => maskset, position, lastValidPosition, opts => return true|false
 			postValidation: null, //hook to postValidate the result from isValid.	Usefull for validating the entry as a whole.	args => buffer, currentResult, opts => return true/false
@@ -1253,9 +1253,17 @@
 			return elem;
 		}
 
-		function checkAlternationMatch(altArr1, altArr2) {
+		function checkAlternationMatch(altArr1, altArr2, na) {
 			var altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1),
-				isMatch = false;
+				isMatch = false, naArr = na !== undefined ? na.split(",") : [],
+				naNdx;
+
+			//remove no alternate indexes from alternation array
+			for (var i = 0; i < naArr.length; i++) {
+				if ((naNdx = altArr1.indexOf(naArr[i])) !== -1)
+					altArr1.splice(naNdx, 1);
+			}
+
 			for (var alndx = 0; alndx < altArr1.length; alndx++) {
 				if ($.inArray(altArr1[alndx], altArrC) !== -1) {
 					isMatch = true;
@@ -1475,22 +1483,30 @@
 
 					for (var ps = originalPos; ps < newPos; ps++) {
 						if (getMaskSet().validPositions[ps] === undefined && !isMask(ps, true)) {
-							var tests = getTests(ps),
-								bestMatch = tests[0],
+							var tests = getTests(ps).slice(),
+								bestMatch = determineTestTemplate(tests, true),
 								equality = -1;
+							if (tests[tests.length - 1].match.def === "") tests.pop();
 							$.each(tests, function (ndx, tst) { //find best matching
 								for (var i = 0; i < tll; i++) {
-									if (tst.locator[i] !== undefined && checkAlternationMatch(tst.locator[i].toString().split(","), targetLocator[i].toString().split(","))) {
+									if (tst.locator[i] !== undefined && checkAlternationMatch(tst.locator[i].toString().split(","), targetLocator[i].toString().split(","), tst.na)) {
 										if (equality < i) {
 											equality = i;
 											bestMatch = tst;
+										} else if (equality == i) {
+											bestMatch = determineTestTemplate(tests, true);
 										}
 									} else break;
 								}
 							});
-							setValidPosition(ps, $.extend({}, bestMatch, {
+							bestMatch = $.extend({}, bestMatch, {
 								"input": getPlaceholder(ps, bestMatch.match, true) || bestMatch.match.def
-							}), true);
+							});
+							bestMatch.generatedInput = true;
+							setValidPosition(ps, bestMatch, true);
+							//revalidate the new position to update the locator value
+							getMaskSet().validPositions[newPos]=undefined;
+							_isValid(newPos, vp.input, true);
 						}
 					}
 				}
@@ -1528,6 +1544,7 @@
 									needsValidation = true;
 								} else {
 									valid = t.generatedInput === true;
+									if (!valid && posMatch >= getMaskSet().maskLength - 1) break;
 								}
 								if (getMaskSet().maskLength < initialLength) getMaskSet().maskLength = initialLength; //a bit hacky but the masklength is corrected later on
 								if (valid) break;
@@ -1594,14 +1611,14 @@
 							"caret": seekNext(maskPos)
 						};
 					} else if ((opts.insertMode || getMaskSet().validPositions[seekNext(maskPos)] === undefined) && !isMask(maskPos, true)) { //does the input match on a further position?
-						var testsFromPos = getTests(maskPos).slice();
-						if (testsFromPos[testsFromPos.length - 1].match.def === "") testsFromPos.pop();
-						var staticChar = determineTestTemplate(testsFromPos, true);
-						if (staticChar && staticChar.match.fn === null) {
-							staticChar = getPlaceholder(undefined, staticChar.match, true) || staticChar.match.def;
-							_isValid(maskPos, staticChar, strict);
-							getMaskSet().validPositions[maskPos].generatedInput = true;
-						}
+						// var testsFromPos = getTests(maskPos).slice();
+						// if (testsFromPos[testsFromPos.length - 1].match.def === "") testsFromPos.pop();
+						// var staticChar = determineTestTemplate(testsFromPos, true);
+						// if (staticChar && staticChar.match.fn === null) {
+						// 	staticChar = getPlaceholder(undefined, staticChar.match, true) || staticChar.match.def;
+						// 	_isValid(maskPos, staticChar, strict);
+						// 	getMaskSet().validPositions[maskPos].generatedInput = true;
+						// }
 						for (var nPos = maskPos + 1, snPos = seekNext(maskPos); nPos <= snPos; nPos++) {
 							result = _isValid(nPos, c, strict);
 							if (result !== false) {
@@ -2892,7 +2909,7 @@
 					EventRuler.on(el, "complete", opts.oncomplete);
 					EventRuler.on(el, "incomplete", opts.onincomplete);
 					EventRuler.on(el, "cleared", opts.oncleared);
-					if (opts.inputEventOnly !== true) {
+					if (!android || opts.inputEventOnly !== true) {
 						EventRuler.on(el, "keydown", EventHandlers.keydownEvent);
 						EventRuler.on(el, "keypress", EventHandlers.keypressEvent);
 					}
@@ -2901,6 +2918,7 @@
 					EventRuler.on(el, "compositionend", $.noop);
 					EventRuler.on(el, "keyup", $.noop);
 					EventRuler.on(el, "input", EventHandlers.inputFallBackEvent);
+					EventRuler.on(el, "beforeinput", $.noop); //https://github.com/w3c/input-events - to implement
 				}
 				EventRuler.on(el, "setvalue", EventHandlers.setValueEvent);
 

+ 2 - 0
js/inputmask.phone.extensions.js

@@ -80,6 +80,8 @@
 			mask = rebuild(maskGroups);
 		}
 		// console.log(mask);
+		//escape 9 definition
+		mask = mask.replace(/9/g, "\\9");
 		var mt = analyseMaskBase.call(this, mask, opts);
 		return mt;
 	};

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 	"name": "jquery.inputmask",
-	"version": "3.3.5-19",
+	"version": "3.3.5-23",
 	"description": "jquery.inputmask is a jquery plugin which create an input mask.",
 	"main": "index.js",
 	"files": [

+ 20 - 0
qunit/tests_alternations.js

@@ -164,4 +164,24 @@ define([
 		testmask.focus();
 		assert.equal(testmask.inputmask._valueGet(), "((S)", "Result " + testmask.inputmask._valueGet());
 	});
+
+	qunit.test("+371-99-999-999 - artemkaint", function (assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+
+		Inputmask([
+			"+371-99-999-999",
+			"+370(999)99-999",
+			"+375(99)999-99-99",
+			"+374-99-999-999",
+			"+380(99)999-99-99",
+			"+358(999)999-99-99",
+			"+373-9999-9999",
+			"+381-99-999-9999"
+		]).mask(testmask);
+		testmask.focus();
+		$("#testmask").Type("112123123");
+		assert.equal(testmask.inputmask._valueGet(), "+371-12-123-123", "Result " + testmask.inputmask._valueGet());
+	});
 });