Browse Source

improve placeholder handling

Robin Herbots 10 years ago
parent
commit
e9f48a2ce9

+ 2 - 1
CHANGELOG.md

@@ -1,9 +1,10 @@
 # Change Log
 # Change Log
 All notable changes to this project will be documented in this file.
 All notable changes to this project will be documented in this file.
 
 
-## UNRELEASED
+## [3.2.5] - 2015-11-27
 
 
 ### Updates
 ### Updates
+- improve cursor positioning and placeholder handling
 - remove $("selector").inputmask("mask", { mask: "99-999 ..." }) format from plugin
 - remove $("selector").inputmask("mask", { mask: "99-999 ..." }) format from plugin
 
 
 ### Fixed
 ### Fixed

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "jquery.inputmask",
   "name": "jquery.inputmask",
-  "version": "3.2.5-7",
+  "version": "3.2.5-18",
   "main": [
   "main": [
     "./dist/inputmask/inputmask.js"
     "./dist/inputmask/inputmask.js"
   ],
   ],

+ 1 - 1
component.json

@@ -2,7 +2,7 @@
   "name": "jquery_inputmask",
   "name": "jquery_inputmask",
   "repository": "robinherbots/jquery.inputmask",
   "repository": "robinherbots/jquery.inputmask",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
-  "version": "3.2.5-7",
+  "version": "3.2.5-18",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "main": "./dist/jquery.inputmask.bundle.js",
   "main": "./dist/jquery.inputmask.bundle.js",
   "scripts": [
   "scripts": [

+ 1 - 1
composer.json

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

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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Copyright (c) 2010 - 2015 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.2.5-7
+* Version: 3.2.5-18
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Copyright (c) 2010 - 2015 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.2.5-7
+* Version: 3.2.5-18
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery")) : factory(jQuery);
     "function" == typeof define && define.amd ? define([ "jquery" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery")) : factory(jQuery);

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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Copyright (c) 2010 - 2015 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.2.5-7
+* Version: 3.2.5-18
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);
@@ -26,58 +26,7 @@
         }
         }
     }), Inputmask.extendAliases({
     }), Inputmask.extendAliases({
         url: {
         url: {
-            mask: "ir",
-            placeholder: "",
-            separator: "",
-            defaultPrefix: "http://",
-            regex: {
-                urlpre1: new RegExp("[fh]"),
-                urlpre2: new RegExp("(ft|ht)"),
-                urlpre3: new RegExp("(ftp|htt)"),
-                urlpre4: new RegExp("(ftp:|http|ftps)"),
-                urlpre5: new RegExp("(ftp:/|ftps:|http:|https)"),
-                urlpre6: new RegExp("(ftp://|ftps:/|http:/|https:)"),
-                urlpre7: new RegExp("(ftp://|ftps://|http://|https:/)"),
-                urlpre8: new RegExp("(ftp://|ftps://|http://|https://)")
-            },
-            definitions: {
-                i: {
-                    validator: function(chrs, maskset, pos, strict, opts) {
-                        return !0;
-                    },
-                    cardinality: 8,
-                    prevalidator: function() {
-                        for (var result = [], prefixLimit = 8, i = 0; prefixLimit > i; i++) result[i] = function() {
-                            var j = i;
-                            return {
-                                validator: function(chrs, maskset, pos, strict, opts) {
-                                    if (opts.regex["urlpre" + (j + 1)]) {
-                                        var k, tmp = chrs;
-                                        j + 1 - chrs.length > 0 && (tmp = maskset.buffer.join("").substring(0, j + 1 - chrs.length) + "" + tmp);
-                                        var isValid = opts.regex["urlpre" + (j + 1)].test(tmp);
-                                        if (!strict && !isValid) {
-                                            for (pos -= j, k = 0; k < opts.defaultPrefix.length; k++) maskset.buffer[pos] = opts.defaultPrefix[k], 
-                                            pos++;
-                                            for (k = 0; k < tmp.length - 1; k++) maskset.buffer[pos] = tmp[k], pos++;
-                                            return {
-                                                pos: pos
-                                            };
-                                        }
-                                        return isValid;
-                                    }
-                                    return !1;
-                                },
-                                cardinality: j
-                            };
-                        }();
-                        return result;
-                    }()
-                },
-                r: {
-                    validator: ".",
-                    cardinality: 50
-                }
-            },
+            mask: "(\\http://)|(\\http\\s://)|(ftp://)|(ftp\\s://)*{+}",
             insertMode: !1,
             insertMode: !1,
             autoUnmask: !1
             autoUnmask: !1
         },
         },

+ 9 - 14
dist/inputmask/inputmask.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Copyright (c) 2010 - 2015 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.2.5-7
+* Version: 3.2.5-18
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery")) : factory(window.dependencyLib || jQuery);
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery")) : factory(window.dependencyLib || jQuery);
@@ -564,7 +564,7 @@
                 return !1;
                 return !1;
             }
             }
             function trackbackAlternations(originalPos, newPos) {
             function trackbackAlternations(originalPos, newPos) {
-                for (var vp = getMaskSet().validPositions[newPos], targetLocator = vp.locator, tll = targetLocator.length, ps = originalPos; newPos > ps; ps++) if (!isMask(ps)) {
+                for (var vp = getMaskSet().validPositions[newPos], targetLocator = vp.locator, tll = targetLocator.length, ps = originalPos; newPos > ps; ps++) if (!isMask(ps, !0)) {
                     var tests = getTests(ps), bestMatch = tests[0], equality = -1;
                     var tests = getTests(ps), bestMatch = tests[0], equality = -1;
                     $.each(tests, function(ndx, tst) {
                     $.each(tests, function(ndx, tst) {
                         for (var i = 0; tll > i; i++) tst.locator[i] && checkAlternationMatch(tst.locator[i].toString().split(","), targetLocator[i].toString().split(",")) && i > equality && (equality = i, 
                         for (var i = 0; tll > i; i++) tst.locator[i] && checkAlternationMatch(tst.locator[i].toString().split(","), targetLocator[i].toString().split(",")) && i > equality && (equality = i, 
@@ -582,7 +582,7 @@
             (!strict || fromSetValid) && result === !1)) {
             (!strict || fromSetValid) && result === !1)) {
                 var currentPosValid = getMaskSet().validPositions[maskPos];
                 var currentPosValid = getMaskSet().validPositions[maskPos];
                 if (!currentPosValid || null !== currentPosValid.match.fn || currentPosValid.match.def !== c && c !== opts.skipOptionalPartCharacter) {
                 if (!currentPosValid || null !== currentPosValid.match.fn || currentPosValid.match.def !== c && c !== opts.skipOptionalPartCharacter) {
-                    if ((opts.insertMode || void 0 === getMaskSet().validPositions[seekNext(maskPos)]) && !isMask(maskPos)) for (var nPos = maskPos + 1, snPos = seekNext(maskPos); snPos >= nPos; nPos++) if (result = _isValid(nPos, c, strict, fromSetValid), 
+                    if ((opts.insertMode || void 0 === getMaskSet().validPositions[seekNext(maskPos)]) && !isMask(maskPos, !0)) for (var nPos = maskPos + 1, snPos = seekNext(maskPos); snPos >= nPos; nPos++) if (result = _isValid(nPos, c, strict, fromSetValid), 
                     result !== !1) {
                     result !== !1) {
                         trackbackAlternations(maskPos, nPos), maskPos = nPos;
                         trackbackAlternations(maskPos, nPos), maskPos = nPos;
                         break;
                         break;
@@ -607,10 +607,10 @@
             }
             }
             return result;
             return result;
         }
         }
-        function isMask(pos) {
+        function isMask(pos, strict) {
             var test = getTest(pos);
             var test = getTest(pos);
             if (null != test.fn) return test.fn;
             if (null != test.fn) return test.fn;
-            if (pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
+            if (strict !== !0 && pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
                 var tests = getTests(pos, void 0, void 0, !0);
                 var tests = getTests(pos, void 0, void 0, !0);
                 return tests.length > 2;
                 return tests.length > 2;
             }
             }
@@ -659,14 +659,9 @@
             if (test = test || getTest(pos), void 0 !== test.placeholder) return test.placeholder;
             if (test = test || getTest(pos), void 0 !== test.placeholder) return test.placeholder;
             if (null === test.fn) {
             if (null === test.fn) {
                 if (pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
                 if (pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
-                    for (var prevTest, tests = getTests(pos), hasAlternations = !1, i = 0; i < tests.length; i++) {
-                        if (prevTest && "" !== tests[i].match.def && tests[i].match.def !== prevTest.match.def && (void 0 === tests[i].alternation || tests[i].alternation === prevTest.alternation)) {
-                            hasAlternations = !0;
-                            break;
-                        }
-                        tests[i].match.optionality !== !0 && tests[i].match.optionalQuantifier !== !0 && (prevTest = tests[i]);
-                    }
-                    if (hasAlternations) return opts.placeholder.charAt(pos % opts.placeholder.length);
+                    var prevTest, tests = getTests(pos), staticAlternations = 0;
+                    if (tests.length > 2) for (var i = 0; i < tests.length; i++) if (tests[i].match.optionality !== !0 && tests[i].match.optionalQuantifier !== !0 && (null === tests[i].match.fn || void 0 === prevTest || tests[i].match.fn.test(prevTest.match.def, getMaskSet(), pos, !0, opts) !== !1) && (staticAlternations++, 
+                    null === tests[i].match.fn && (prevTest = tests[i]), staticAlternations > 1)) return opts.placeholder.charAt(pos % opts.placeholder.length);
                 }
                 }
                 return test.def;
                 return test.def;
             }
             }
@@ -1071,7 +1066,7 @@
                 var selectedCaret = caret(input);
                 var selectedCaret = caret(input);
                 if (selectedCaret.begin === selectedCaret.end) if (doRadixFocus(selectedCaret.begin)) caret(input, $.inArray(opts.radixPoint, getBuffer())); else {
                 if (selectedCaret.begin === selectedCaret.end) if (doRadixFocus(selectedCaret.begin)) caret(input, $.inArray(opts.radixPoint, getBuffer())); else {
                     var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition), lastPosition = seekNext(lvclickPosition);
                     var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition), lastPosition = seekNext(lvclickPosition);
-                    lastPosition > clickPosition ? caret(input, isMask(clickPosition) || isMask(clickPosition - 1) ? clickPosition : seekNext(clickPosition)) : (getBuffer()[lastPosition] !== getPlaceholder(lastPosition) && (lastPosition = seekNext(lastPosition)), 
+                    lastPosition > clickPosition ? caret(input, isMask(clickPosition) || isMask(clickPosition - 1) ? clickPosition : seekNext(clickPosition)) : ((getBuffer()[lastPosition] !== getPlaceholder(lastPosition) || !isMask(lastPosition, !0) && getTest(lastPosition).def === getPlaceholder(lastPosition)) && (lastPosition = seekNext(lastPosition)), 
                     caret(input, opts.numericInput ? 0 : lastPosition));
                     caret(input, opts.numericInput ? 0 : lastPosition));
                 }
                 }
             }
             }

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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Copyright (c) 2010 - 2015 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.2.5-7
+* Version: 3.2.5-18
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Copyright (c) 2010 - 2015 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.2.5-7
+* Version: 3.2.5-18
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);
     "function" == typeof define && define.amd ? define([ "jquery", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Copyright (c) 2010 - 2015 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.2.5-7
+* Version: 3.2.5-18
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Copyright (c) 2010 - 2015 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.2.5-7
+* Version: 3.2.5-18
 */
 */
 !function(factory) {
 !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);
     "function" == typeof define && define.amd ? define([ "jquery", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./inputmask")) : factory(jQuery, window.Inputmask);

+ 10 - 66
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Copyright (c) 2010 - 2015 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.2.5-7
+* Version: 3.2.5-18
 */
 */
 !function($) {
 !function($) {
     function Inputmask(alias, options) {
     function Inputmask(alias, options) {
@@ -562,7 +562,7 @@
                 return !1;
                 return !1;
             }
             }
             function trackbackAlternations(originalPos, newPos) {
             function trackbackAlternations(originalPos, newPos) {
-                for (var vp = getMaskSet().validPositions[newPos], targetLocator = vp.locator, tll = targetLocator.length, ps = originalPos; newPos > ps; ps++) if (!isMask(ps)) {
+                for (var vp = getMaskSet().validPositions[newPos], targetLocator = vp.locator, tll = targetLocator.length, ps = originalPos; newPos > ps; ps++) if (!isMask(ps, !0)) {
                     var tests = getTests(ps), bestMatch = tests[0], equality = -1;
                     var tests = getTests(ps), bestMatch = tests[0], equality = -1;
                     $.each(tests, function(ndx, tst) {
                     $.each(tests, function(ndx, tst) {
                         for (var i = 0; tll > i; i++) tst.locator[i] && checkAlternationMatch(tst.locator[i].toString().split(","), targetLocator[i].toString().split(",")) && i > equality && (equality = i, 
                         for (var i = 0; tll > i; i++) tst.locator[i] && checkAlternationMatch(tst.locator[i].toString().split(","), targetLocator[i].toString().split(",")) && i > equality && (equality = i, 
@@ -580,7 +580,7 @@
             (!strict || fromSetValid) && result === !1)) {
             (!strict || fromSetValid) && result === !1)) {
                 var currentPosValid = getMaskSet().validPositions[maskPos];
                 var currentPosValid = getMaskSet().validPositions[maskPos];
                 if (!currentPosValid || null !== currentPosValid.match.fn || currentPosValid.match.def !== c && c !== opts.skipOptionalPartCharacter) {
                 if (!currentPosValid || null !== currentPosValid.match.fn || currentPosValid.match.def !== c && c !== opts.skipOptionalPartCharacter) {
-                    if ((opts.insertMode || void 0 === getMaskSet().validPositions[seekNext(maskPos)]) && !isMask(maskPos)) for (var nPos = maskPos + 1, snPos = seekNext(maskPos); snPos >= nPos; nPos++) if (result = _isValid(nPos, c, strict, fromSetValid), 
+                    if ((opts.insertMode || void 0 === getMaskSet().validPositions[seekNext(maskPos)]) && !isMask(maskPos, !0)) for (var nPos = maskPos + 1, snPos = seekNext(maskPos); snPos >= nPos; nPos++) if (result = _isValid(nPos, c, strict, fromSetValid), 
                     result !== !1) {
                     result !== !1) {
                         trackbackAlternations(maskPos, nPos), maskPos = nPos;
                         trackbackAlternations(maskPos, nPos), maskPos = nPos;
                         break;
                         break;
@@ -605,10 +605,10 @@
             }
             }
             return result;
             return result;
         }
         }
-        function isMask(pos) {
+        function isMask(pos, strict) {
             var test = getTest(pos);
             var test = getTest(pos);
             if (null != test.fn) return test.fn;
             if (null != test.fn) return test.fn;
-            if (pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
+            if (strict !== !0 && pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
                 var tests = getTests(pos, void 0, void 0, !0);
                 var tests = getTests(pos, void 0, void 0, !0);
                 return tests.length > 2;
                 return tests.length > 2;
             }
             }
@@ -657,14 +657,9 @@
             if (test = test || getTest(pos), void 0 !== test.placeholder) return test.placeholder;
             if (test = test || getTest(pos), void 0 !== test.placeholder) return test.placeholder;
             if (null === test.fn) {
             if (null === test.fn) {
                 if (pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
                 if (pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
-                    for (var prevTest, tests = getTests(pos), hasAlternations = !1, i = 0; i < tests.length; i++) {
-                        if (prevTest && "" !== tests[i].match.def && tests[i].match.def !== prevTest.match.def && (void 0 === tests[i].alternation || tests[i].alternation === prevTest.alternation)) {
-                            hasAlternations = !0;
-                            break;
-                        }
-                        tests[i].match.optionality !== !0 && tests[i].match.optionalQuantifier !== !0 && (prevTest = tests[i]);
-                    }
-                    if (hasAlternations) return opts.placeholder.charAt(pos % opts.placeholder.length);
+                    var prevTest, tests = getTests(pos), staticAlternations = 0;
+                    if (tests.length > 2) for (var i = 0; i < tests.length; i++) if (tests[i].match.optionality !== !0 && tests[i].match.optionalQuantifier !== !0 && (null === tests[i].match.fn || void 0 === prevTest || tests[i].match.fn.test(prevTest.match.def, getMaskSet(), pos, !0, opts) !== !1) && (staticAlternations++, 
+                    null === tests[i].match.fn && (prevTest = tests[i]), staticAlternations > 1)) return opts.placeholder.charAt(pos % opts.placeholder.length);
                 }
                 }
                 return test.def;
                 return test.def;
             }
             }
@@ -1069,7 +1064,7 @@
                 var selectedCaret = caret(input);
                 var selectedCaret = caret(input);
                 if (selectedCaret.begin === selectedCaret.end) if (doRadixFocus(selectedCaret.begin)) caret(input, $.inArray(opts.radixPoint, getBuffer())); else {
                 if (selectedCaret.begin === selectedCaret.end) if (doRadixFocus(selectedCaret.begin)) caret(input, $.inArray(opts.radixPoint, getBuffer())); else {
                     var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition), lastPosition = seekNext(lvclickPosition);
                     var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition), lastPosition = seekNext(lvclickPosition);
-                    lastPosition > clickPosition ? caret(input, isMask(clickPosition) || isMask(clickPosition - 1) ? clickPosition : seekNext(clickPosition)) : (getBuffer()[lastPosition] !== getPlaceholder(lastPosition) && (lastPosition = seekNext(lastPosition)), 
+                    lastPosition > clickPosition ? caret(input, isMask(clickPosition) || isMask(clickPosition - 1) ? clickPosition : seekNext(clickPosition)) : ((getBuffer()[lastPosition] !== getPlaceholder(lastPosition) || !isMask(lastPosition, !0) && getTest(lastPosition).def === getPlaceholder(lastPosition)) && (lastPosition = seekNext(lastPosition)), 
                     caret(input, opts.numericInput ? 0 : lastPosition));
                     caret(input, opts.numericInput ? 0 : lastPosition));
                 }
                 }
             }
             }
@@ -1965,58 +1960,7 @@
         }
         }
     }), Inputmask.extendAliases({
     }), Inputmask.extendAliases({
         url: {
         url: {
-            mask: "ir",
-            placeholder: "",
-            separator: "",
-            defaultPrefix: "http://",
-            regex: {
-                urlpre1: new RegExp("[fh]"),
-                urlpre2: new RegExp("(ft|ht)"),
-                urlpre3: new RegExp("(ftp|htt)"),
-                urlpre4: new RegExp("(ftp:|http|ftps)"),
-                urlpre5: new RegExp("(ftp:/|ftps:|http:|https)"),
-                urlpre6: new RegExp("(ftp://|ftps:/|http:/|https:)"),
-                urlpre7: new RegExp("(ftp://|ftps://|http://|https:/)"),
-                urlpre8: new RegExp("(ftp://|ftps://|http://|https://)")
-            },
-            definitions: {
-                i: {
-                    validator: function(chrs, maskset, pos, strict, opts) {
-                        return !0;
-                    },
-                    cardinality: 8,
-                    prevalidator: function() {
-                        for (var result = [], prefixLimit = 8, i = 0; prefixLimit > i; i++) result[i] = function() {
-                            var j = i;
-                            return {
-                                validator: function(chrs, maskset, pos, strict, opts) {
-                                    if (opts.regex["urlpre" + (j + 1)]) {
-                                        var k, tmp = chrs;
-                                        j + 1 - chrs.length > 0 && (tmp = maskset.buffer.join("").substring(0, j + 1 - chrs.length) + "" + tmp);
-                                        var isValid = opts.regex["urlpre" + (j + 1)].test(tmp);
-                                        if (!strict && !isValid) {
-                                            for (pos -= j, k = 0; k < opts.defaultPrefix.length; k++) maskset.buffer[pos] = opts.defaultPrefix[k], 
-                                            pos++;
-                                            for (k = 0; k < tmp.length - 1; k++) maskset.buffer[pos] = tmp[k], pos++;
-                                            return {
-                                                pos: pos
-                                            };
-                                        }
-                                        return isValid;
-                                    }
-                                    return !1;
-                                },
-                                cardinality: j
-                            };
-                        }();
-                        return result;
-                    }()
-                },
-                r: {
-                    validator: ".",
-                    cardinality: 50
-                }
-            },
+            mask: "(\\http://)|(\\http\\s://)|(ftp://)|(ftp\\s://)*{+}",
             insertMode: !1,
             insertMode: !1,
             autoUnmask: !1
             autoUnmask: !1
         },
         },

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.jquery.min.js

@@ -3,6 +3,6 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Copyright (c) 2010 - 2015 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.2.5-7
+* Version: 3.2.5-18
 */
 */
 !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){return window.dependencyLib=a,a});
 !function(a){"function"==typeof define&&define.amd?define(["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
+ 2 - 2
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
+ 1 - 1
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


+ 1 - 66
js/inputmask.extensions.js

@@ -37,72 +37,7 @@ Optional extensions on the jquery.inputmask base
 		});
 		});
 		Inputmask.extendAliases({
 		Inputmask.extendAliases({
 			"url": {
 			"url": {
-				mask: "ir",
-				placeholder: "",
-				separator: "",
-				defaultPrefix: "http://",
-				regex: {
-					urlpre1: new RegExp("[fh]"),
-					urlpre2: new RegExp("(ft|ht)"),
-					urlpre3: new RegExp("(ftp|htt)"),
-					urlpre4: new RegExp("(ftp:|http|ftps)"),
-					urlpre5: new RegExp("(ftp:/|ftps:|http:|https)"),
-					urlpre6: new RegExp("(ftp://|ftps:/|http:/|https:)"),
-					urlpre7: new RegExp("(ftp://|ftps://|http://|https:/)"),
-					urlpre8: new RegExp("(ftp://|ftps://|http://|https://)")
-				},
-				definitions: {
-					"i": {
-						validator: function(chrs, maskset, pos, strict, opts) {
-							return true;
-						},
-						cardinality: 8,
-						prevalidator: (function() {
-							var result = [],
-								prefixLimit = 8;
-							for (var i = 0; i < prefixLimit; i++) {
-								result[i] = (function() {
-									var j = i;
-									return {
-										validator: function(chrs, maskset, pos, strict, opts) {
-											if (opts.regex["urlpre" + (j + 1)]) {
-												var tmp = chrs,
-													k;
-												if (((j + 1) - chrs.length) > 0) {
-													tmp = maskset.buffer.join("").substring(0, ((j + 1) - chrs.length)) + "" + tmp;
-												}
-												var isValid = opts.regex["urlpre" + (j + 1)].test(tmp);
-												if (!strict && !isValid) {
-													pos = pos - j;
-													for (k = 0; k < opts.defaultPrefix.length; k++) {
-														maskset.buffer[pos] = opts.defaultPrefix[k];
-														pos++;
-													}
-													for (k = 0; k < tmp.length - 1; k++) {
-														maskset.buffer[pos] = tmp[k];
-														pos++;
-													}
-													return {
-														"pos": pos
-													};
-												}
-												return isValid;
-											} else {
-												return false;
-											}
-										},
-										cardinality: j
-									};
-								})();
-							}
-							return result;
-						})()
-					},
-					"r": {
-						validator: ".",
-						cardinality: 50
-					}
-				},
+				mask: "(\\http://)|(\\http\\s://)|(ftp://)|(ftp\\s://)*{+}",
 				insertMode: false,
 				insertMode: false,
 				autoUnmask: false
 				autoUnmask: false
 			},
 			},

+ 14 - 18
js/inputmask.js

@@ -1436,7 +1436,7 @@
 						tll = targetLocator.length;
 						tll = targetLocator.length;
 
 
 					for (var ps = originalPos; ps < newPos; ps++) {
 					for (var ps = originalPos; ps < newPos; ps++) {
-						if (!isMask(ps)) {
+						if (!isMask(ps, true)) {
 							var tests = getTests(ps),
 							var tests = getTests(ps),
 								bestMatch = tests[0],
 								bestMatch = tests[0],
 								equality = -1;
 								equality = -1;
@@ -1489,7 +1489,7 @@
 							result = {
 							result = {
 								"caret": seekNext(maskPos)
 								"caret": seekNext(maskPos)
 							};
 							};
-						} else if ((opts.insertMode || getMaskSet().validPositions[seekNext(maskPos)] === undefined) && !isMask(maskPos)) { //does the input match on a further position?
+						} else if ((opts.insertMode || getMaskSet().validPositions[seekNext(maskPos)] === undefined) && !isMask(maskPos, true)) { //does the input match on a further position?
 							for (var nPos = maskPos + 1, snPos = seekNext(maskPos); nPos <= snPos; nPos++) {
 							for (var nPos = maskPos + 1, snPos = seekNext(maskPos); nPos <= snPos; nPos++) {
 								result = _isValid(nPos, c, strict, fromSetValid);
 								result = _isValid(nPos, c, strict, fromSetValid);
 								if (result !== false) {
 								if (result !== false) {
@@ -1526,11 +1526,11 @@
 				return result;
 				return result;
 			}
 			}
 
 
-			function isMask(pos) {
+			function isMask(pos, strict) {
 				var test = getTest(pos);
 				var test = getTest(pos);
 				if (test.fn != null) {
 				if (test.fn != null) {
 					return test.fn;
 					return test.fn;
-				} else if (pos > -1 && !opts.keepStatic && getMaskSet().validPositions[pos] === undefined) {
+				} else if (strict !== true && pos > -1 && !opts.keepStatic && getMaskSet().validPositions[pos] === undefined) {
 					var tests = getTests(pos, undefined, undefined, true);
 					var tests = getTests(pos, undefined, undefined, true);
 					return tests.length > 2;
 					return tests.length > 2;
 				}
 				}
@@ -1605,22 +1605,18 @@
 				} else if (test.fn === null) {
 				} else if (test.fn === null) {
 					if (pos > -1 && !opts.keepStatic && getMaskSet().validPositions[pos] === undefined) {
 					if (pos > -1 && !opts.keepStatic && getMaskSet().validPositions[pos] === undefined) {
 						var tests = getTests(pos),
 						var tests = getTests(pos),
-							hasAlternations = false,
+							staticAlternations = 0,
 							prevTest;
 							prevTest;
-						for (var i = 0; i < tests.length; i++) {
-							if (prevTest && tests[i].match.def !== "" && (tests[i].match.def !== prevTest.match.def && (tests[i].alternation === undefined || tests[i].alternation === prevTest.alternation))) {
-								hasAlternations = true;
-								break;
-							}
-
-							if (tests[i].match.optionality !== true && tests[i].match.optionalQuantifier !== true) {
-								prevTest = tests[i];
+						if (tests.length > 2) {
+							for (var i = 0; i < tests.length; i++) {
+								if (tests[i].match.optionality !== true && tests[i].match.optionalQuantifier !== true &&
+									(tests[i].match.fn === null || (prevTest === undefined || tests[i].match.fn.test(prevTest.match.def, getMaskSet(), pos, true, opts) !== false))) {
+									staticAlternations++;
+									if (tests[i].match.fn === null) prevTest = tests[i];
+									if (staticAlternations > 1) return opts.placeholder.charAt(pos % opts.placeholder.length);
+								}
 							}
 							}
 						}
 						}
-
-						if (hasAlternations) {
-							return opts.placeholder.charAt(pos % opts.placeholder.length);
-						}
 					}
 					}
 					return test.def;
 					return test.def;
 				}
 				}
@@ -2440,7 +2436,7 @@
 							if (clickPosition < lastPosition) {
 							if (clickPosition < lastPosition) {
 								caret(input, !isMask(clickPosition) && !isMask(clickPosition - 1) ? seekNext(clickPosition) : clickPosition);
 								caret(input, !isMask(clickPosition) && !isMask(clickPosition - 1) ? seekNext(clickPosition) : clickPosition);
 							} else {
 							} else {
-								if (getBuffer()[lastPosition] !== getPlaceholder(lastPosition)) {
+								if (getBuffer()[lastPosition] !== getPlaceholder(lastPosition) || (!isMask(lastPosition, true) && getTest(lastPosition).def === getPlaceholder(lastPosition))) {
 									lastPosition = seekNext(lastPosition);
 									lastPosition = seekNext(lastPosition);
 								}
 								}
 								caret(input, opts.numericInput ? 0 : lastPosition);
 								caret(input, opts.numericInput ? 0 : lastPosition);

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "jquery.inputmask",
   "name": "jquery.inputmask",
-  "version": "3.2.5-7",
+  "version": "3.2.5-18",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "main": "./dist/inputmask/jquery.inputmask.js",
   "main": "./dist/inputmask/jquery.inputmask.js",
   "files": [
   "files": [