Robin Herbots 7 年之前
父节点
当前提交
47bc03af5e

+ 11 - 0
CHANGELOG.md

@@ -1,5 +1,16 @@
 # Change Log
 
+## [4.0.4 - 2018-12-03]
+### Addition
+- add url as supported input type
+
+### Updates
+- rework jit enabled quantifiers
+
+### Fixed
+- restore greedy functionality
+- fix focus and mouseenter behavior in IE
+
 ## [4.0.3 - 2018-11-07]
 
 ### Addition

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "4.0.3",
+  "version": "4.0.4",
   "main": [
 	  "./index.js",
     "./css/inputmask.css"

+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
   "name": "robinherbots/inputmask",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
-  "version": "4.0.3",
+  "version": "4.0.4",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/Inputmask",

+ 1 - 1
dist/inputmask/bindings/inputmask.binding.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.3
+* Version: 4.0.4
 */
 
 (function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.3
+* Version: 4.0.4
 */
 
 (function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.3
+* Version: 4.0.4
 */
 
 (function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.3
+* Version: 4.0.4
 */
 
 (function(factory) {

+ 1 - 1
dist/inputmask/global/window.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.3
+* Version: 4.0.4
 */
 
 if (typeof define === "function" && define.amd) define(function() {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.3
+* Version: 4.0.4
 */
 
 (function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.3
+* Version: 4.0.4
 */
 
 (function(factory) {

+ 33 - 24
dist/inputmask/inputmask.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.3
+* Version: 4.0.4
 */
 
 (function(factory) {
@@ -80,7 +80,7 @@
             keepStatic: null,
             positionCaretOnTab: true,
             tabThrough: false,
-            supportsInputType: [ "text", "tel", "password", "search" ],
+            supportsInputType: [ "text", "tel", "url", "password", "search" ],
             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,
             preValidation: null,
@@ -668,7 +668,8 @@
                     tests: {},
                     excludes: {},
                     metadata: metadata,
-                    maskLength: undefined
+                    maskLength: undefined,
+                    jitOffset: {}
                 };
                 if (nocache !== true) {
                     Inputmask.prototype.masksCache[maskdefKey] = masksetDefinition;
@@ -803,7 +804,7 @@
                 var tst = tests[ndx];
                 tstLocator = getLocator(tst, targetLocator.length);
                 var distance = Math.abs(tstLocator - targetLocator);
-                if (closest === undefined || tstLocator !== "" && distance < closest || bestMatch && bestMatch.match.optionality && bestMatch.match.newBlockMarker === "master" && (!tst.match.optionality || !tst.match.newBlockMarker) || bestMatch && bestMatch.match.optionalQuantifier && !tst.match.optionalQuantifier) {
+                if (closest === undefined || tstLocator !== "" && distance < closest || bestMatch && !opts.greedy && bestMatch.match.optionality && bestMatch.match.newBlockMarker === "master" && (!tst.match.optionality || !tst.match.newBlockMarker) || bestMatch && bestMatch.match.optionalQuantifier && !tst.match.optionalQuantifier) {
                     closest = distance;
                     bestMatch = tst;
                 }
@@ -1020,15 +1021,15 @@
                                 match = handleMatch(tokenGroup, [ qndx ].concat(loopNdx), tokenGroup);
                                 if (match) {
                                     latestMatch = matches[matches.length - 1].match;
-                                    latestMatch.optionalQuantifier = qndx > qt.quantifier.min - 1;
+                                    latestMatch.optionalQuantifier = qndx >= qt.quantifier.min;
                                     latestMatch.jit = (qndx || 1) * tokenGroup.matches.indexOf(latestMatch) >= qt.quantifier.jit;
                                     if (latestMatch.optionalQuantifier && isFirstMatch(latestMatch, tokenGroup)) {
                                         insertStop = true;
                                         testPos = pos;
                                         break;
                                     }
-                                    if (latestMatch.jit && !latestMatch.optionalQuantifier) {
-                                        latestMatch.jitOffset = tokenGroup.matches.indexOf(latestMatch);
+                                    if (latestMatch.jit) {
+                                        getMaskSet().jitOffset[pos] = tokenGroup.matches.indexOf(latestMatch);
                                     }
                                     return true;
                                 }
@@ -1344,13 +1345,18 @@
                             result = {
                                 caret: seekNext(maskPos)
                             };
-                        } else if ((opts.insertMode || getMaskSet().validPositions[seekNext(maskPos)] === undefined) && !isMask(maskPos, true)) {
-                            for (var nPos = maskPos + 1, snPos = seekNext(maskPos); nPos <= snPos; nPos++) {
-                                result = _isValid(nPos, c, strict);
-                                if (result !== false) {
-                                    result = trackbackPositions(maskPos, result.pos !== undefined ? result.pos : nPos) || result;
-                                    maskPos = nPos;
-                                    break;
+                        } else {
+                            if ((opts.insertMode || getMaskSet().validPositions[seekNext(maskPos)] === undefined) && (!isMask(maskPos, true) || getMaskSet().jitOffset[maskPos])) {
+                                if (getMaskSet().jitOffset[maskPos] && getMaskSet().validPositions[seekNext(maskPos)] === undefined) {
+                                    result = isValid(maskPos + getMaskSet().jitOffset[maskPos], c, strict);
+                                    if (result !== false) result.caret = maskPos;
+                                } else for (var nPos = maskPos + 1, snPos = seekNext(maskPos); nPos <= snPos; nPos++) {
+                                    result = _isValid(nPos, c, strict);
+                                    if (result !== false) {
+                                        result = trackbackPositions(maskPos, result.pos !== undefined ? result.pos : nPos) || result;
+                                        maskPos = nPos;
+                                        break;
+                                    }
                                 }
                             }
                         }
@@ -1570,15 +1576,18 @@
             return opts.placeholder.charAt(pos % opts.placeholder.length);
         }
         function HandleNativePlaceholder(npt, value) {
-            if (ie && npt.inputmask._valueGet() !== value) {
-                var buffer = getBuffer().slice(), nptValue = npt.inputmask._valueGet();
-                if (nptValue !== value) {
-                    if (getLastValidPosition() === -1 && nptValue === getBufferTemplate().join("")) {
-                        buffer = [];
-                    } else {
-                        clearOptionalTail(buffer);
+            if (ie) {
+                if (npt.inputmask._valueGet() !== value) {
+                    var buffer = getBuffer().slice(), nptValue = npt.inputmask._valueGet();
+                    if (nptValue !== value) {
+                        var lvp = getLastValidPosition();
+                        if (lvp === -1 && nptValue === getBufferTemplate().join("")) {
+                            buffer = [];
+                        } else if (lvp !== -1) {
+                            clearOptionalTail(buffer);
+                        }
+                        writeBuffer(npt, buffer);
                     }
-                    writeBuffer(npt, buffer);
                 }
             } else if (npt.placeholder !== value) {
                 npt.placeholder = value;
@@ -1908,8 +1917,8 @@
             },
             focusEvent: function(e) {
                 var input = this, nptValue = input.inputmask._valueGet();
-                if (opts.showMaskOnFocus && (!opts.showMaskOnHover || opts.showMaskOnHover && nptValue === "")) {
-                    if (input.inputmask._valueGet() !== getBuffer().join("")) {
+                if (opts.showMaskOnFocus) {
+                    if (nptValue !== getBuffer().join("")) {
                         writeBuffer(input, getBuffer(), seekNext(getLastValidPosition()));
                     } else if (mouseEnter === false) {
                         caret(input, seekNext(getLastValidPosition()));

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.3
+* Version: 4.0.4
 */
 
 (function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.3
+* Version: 4.0.4
 */
 
 (function(factory) {

+ 33 - 24
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.3
+* Version: 4.0.4
 */
 
 (function(modules) {
@@ -265,7 +265,7 @@
                 keepStatic: null,
                 positionCaretOnTab: true,
                 tabThrough: false,
-                supportsInputType: [ "text", "tel", "password", "search" ],
+                supportsInputType: [ "text", "tel", "url", "password", "search" ],
                 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,
                 preValidation: null,
@@ -853,7 +853,8 @@
                         tests: {},
                         excludes: {},
                         metadata: metadata,
-                        maskLength: undefined
+                        maskLength: undefined,
+                        jitOffset: {}
                     };
                     if (nocache !== true) {
                         Inputmask.prototype.masksCache[maskdefKey] = masksetDefinition;
@@ -990,7 +991,7 @@
                     var tst = tests[ndx];
                     tstLocator = getLocator(tst, targetLocator.length);
                     var distance = Math.abs(tstLocator - targetLocator);
-                    if (closest === undefined || tstLocator !== "" && distance < closest || bestMatch && bestMatch.match.optionality && bestMatch.match.newBlockMarker === "master" && (!tst.match.optionality || !tst.match.newBlockMarker) || bestMatch && bestMatch.match.optionalQuantifier && !tst.match.optionalQuantifier) {
+                    if (closest === undefined || tstLocator !== "" && distance < closest || bestMatch && !opts.greedy && bestMatch.match.optionality && bestMatch.match.newBlockMarker === "master" && (!tst.match.optionality || !tst.match.newBlockMarker) || bestMatch && bestMatch.match.optionalQuantifier && !tst.match.optionalQuantifier) {
                         closest = distance;
                         bestMatch = tst;
                     }
@@ -1209,15 +1210,15 @@
                                     match = handleMatch(tokenGroup, [ qndx ].concat(loopNdx), tokenGroup);
                                     if (match) {
                                         latestMatch = matches[matches.length - 1].match;
-                                        latestMatch.optionalQuantifier = qndx > qt.quantifier.min - 1;
+                                        latestMatch.optionalQuantifier = qndx >= qt.quantifier.min;
                                         latestMatch.jit = (qndx || 1) * tokenGroup.matches.indexOf(latestMatch) >= qt.quantifier.jit;
                                         if (latestMatch.optionalQuantifier && isFirstMatch(latestMatch, tokenGroup)) {
                                             insertStop = true;
                                             testPos = pos;
                                             break;
                                         }
-                                        if (latestMatch.jit && !latestMatch.optionalQuantifier) {
-                                            latestMatch.jitOffset = tokenGroup.matches.indexOf(latestMatch);
+                                        if (latestMatch.jit) {
+                                            getMaskSet().jitOffset[pos] = tokenGroup.matches.indexOf(latestMatch);
                                         }
                                         return true;
                                     }
@@ -1535,13 +1536,18 @@
                                 result = {
                                     caret: seekNext(maskPos)
                                 };
-                            } else if ((opts.insertMode || getMaskSet().validPositions[seekNext(maskPos)] === undefined) && !isMask(maskPos, true)) {
-                                for (var nPos = maskPos + 1, snPos = seekNext(maskPos); nPos <= snPos; nPos++) {
-                                    result = _isValid(nPos, c, strict);
-                                    if (result !== false) {
-                                        result = trackbackPositions(maskPos, result.pos !== undefined ? result.pos : nPos) || result;
-                                        maskPos = nPos;
-                                        break;
+                            } else {
+                                if ((opts.insertMode || getMaskSet().validPositions[seekNext(maskPos)] === undefined) && (!isMask(maskPos, true) || getMaskSet().jitOffset[maskPos])) {
+                                    if (getMaskSet().jitOffset[maskPos] && getMaskSet().validPositions[seekNext(maskPos)] === undefined) {
+                                        result = isValid(maskPos + getMaskSet().jitOffset[maskPos], c, strict);
+                                        if (result !== false) result.caret = maskPos;
+                                    } else for (var nPos = maskPos + 1, snPos = seekNext(maskPos); nPos <= snPos; nPos++) {
+                                        result = _isValid(nPos, c, strict);
+                                        if (result !== false) {
+                                            result = trackbackPositions(maskPos, result.pos !== undefined ? result.pos : nPos) || result;
+                                            maskPos = nPos;
+                                            break;
+                                        }
                                     }
                                 }
                             }
@@ -1761,15 +1767,18 @@
                 return opts.placeholder.charAt(pos % opts.placeholder.length);
             }
             function HandleNativePlaceholder(npt, value) {
-                if (ie && npt.inputmask._valueGet() !== value) {
-                    var buffer = getBuffer().slice(), nptValue = npt.inputmask._valueGet();
-                    if (nptValue !== value) {
-                        if (getLastValidPosition() === -1 && nptValue === getBufferTemplate().join("")) {
-                            buffer = [];
-                        } else {
-                            clearOptionalTail(buffer);
+                if (ie) {
+                    if (npt.inputmask._valueGet() !== value) {
+                        var buffer = getBuffer().slice(), nptValue = npt.inputmask._valueGet();
+                        if (nptValue !== value) {
+                            var lvp = getLastValidPosition();
+                            if (lvp === -1 && nptValue === getBufferTemplate().join("")) {
+                                buffer = [];
+                            } else if (lvp !== -1) {
+                                clearOptionalTail(buffer);
+                            }
+                            writeBuffer(npt, buffer);
                         }
-                        writeBuffer(npt, buffer);
                     }
                 } else if (npt.placeholder !== value) {
                     npt.placeholder = value;
@@ -2099,8 +2108,8 @@
                 },
                 focusEvent: function focusEvent(e) {
                     var input = this, nptValue = input.inputmask._valueGet();
-                    if (opts.showMaskOnFocus && (!opts.showMaskOnHover || opts.showMaskOnHover && nptValue === "")) {
-                        if (input.inputmask._valueGet() !== getBuffer().join("")) {
+                    if (opts.showMaskOnFocus) {
+                        if (nptValue !== getBuffer().join("")) {
                             writeBuffer(input, getBuffer(), seekNext(getLastValidPosition()));
                         } else if (mouseEnter === false) {
                             caret(input, seekNext(getLastValidPosition()));

文件差异内容过多而无法显示
+ 1 - 1
dist/min/inputmask/bindings/inputmask.binding.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.jqlite.min.js


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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.3
+* Version: 4.0.4
 */
 
 (function(factory){if(typeof define==="function"&&define.amd){define(["jquery"],factory)}else if(typeof exports==="object"){module.exports=factory(require("jquery"))}else{window.dependencyLib=factory(jQuery)}})(function($){return $});

文件差异内容过多而无法显示
+ 1 - 1
dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.min.js


+ 1 - 1
dist/min/inputmask/global/window.min.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.3
+* Version: 4.0.4
 */
 
 if(typeof define==="function"&&define.amd)define(function(){return typeof window!=="undefined"?window:new(eval("require('jsdom').JSDOM"))("").window});else if(typeof exports==="object")module.exports=typeof window!=="undefined"?window:new(eval("require('jsdom').JSDOM"))("").window;

文件差异内容过多而无法显示
+ 1 - 1
dist/min/inputmask/inputmask.date.extensions.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/min/inputmask/inputmask.extensions.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/min/inputmask/inputmask.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/min/inputmask/inputmask.numeric.extensions.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/min/inputmask/jquery.inputmask.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/min/jquery.inputmask.bundle.min.js


文件差异内容过多而无法显示
+ 2880 - 2871
js/inputmask.js


+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "4.0.3",
+  "version": "4.0.4",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
   "main": "index.js",
   "files": [