浏览代码

add jit enabled dynamic masks

Robin Herbots 7 年之前
父节点
当前提交
9f6238d83e
共有 49 个文件被更改,包括 123 次插入84 次删除
  1. 1 0
      CHANGELOG.md
  2. 17 1
      README.md
  3. 1 1
      bower.json
  4. 1 1
      component.json
  5. 1 1
      composer.json
  6. 1 1
      dist/inputmask/bindings/inputmask.binding.js
  7. 1 1
      dist/inputmask/dependencyLibs/inputmask.dependencyLib.jqlite.js
  8. 1 1
      dist/inputmask/dependencyLibs/inputmask.dependencyLib.jquery.js
  9. 1 1
      dist/inputmask/dependencyLibs/inputmask.dependencyLib.js
  10. 1 1
      dist/inputmask/global/document.js
  11. 1 1
      dist/inputmask/global/window.js
  12. 1 1
      dist/inputmask/inputmask.date.extensions.js
  13. 1 1
      dist/inputmask/inputmask.extensions.js
  14. 23 13
      dist/inputmask/inputmask.js
  15. 3 4
      dist/inputmask/inputmask.numeric.extensions.js
  16. 1 1
      dist/inputmask/inputmask.phone.extensions.js
  17. 1 1
      dist/inputmask/jquery.inputmask.js
  18. 1 1
      dist/inputmask/phone-codes/phone-be.js
  19. 1 1
      dist/inputmask/phone-codes/phone-ca.js
  20. 1 1
      dist/inputmask/phone-codes/phone-hu.js
  21. 1 1
      dist/inputmask/phone-codes/phone-mx.js
  22. 1 1
      dist/inputmask/phone-codes/phone-nl.js
  23. 1 1
      dist/inputmask/phone-codes/phone-ru.js
  24. 1 1
      dist/inputmask/phone-codes/phone-uk.js
  25. 1 1
      dist/inputmask/phone-codes/phone.js
  26. 25 16
      dist/jquery.inputmask.bundle.js
  27. 1 1
      dist/min/inputmask/bindings/inputmask.binding.min.js
  28. 1 1
      dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.jqlite.min.js
  29. 1 1
      dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.jquery.min.js
  30. 1 1
      dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.min.js
  31. 1 1
      dist/min/inputmask/global/document.min.js
  32. 1 1
      dist/min/inputmask/global/window.min.js
  33. 1 1
      dist/min/inputmask/inputmask.date.extensions.min.js
  34. 1 1
      dist/min/inputmask/inputmask.extensions.min.js
  35. 2 2
      dist/min/inputmask/inputmask.min.js
  36. 2 2
      dist/min/inputmask/inputmask.numeric.extensions.min.js
  37. 1 1
      dist/min/inputmask/inputmask.phone.extensions.min.js
  38. 1 1
      dist/min/inputmask/jquery.inputmask.min.js
  39. 1 1
      dist/min/inputmask/phone-codes/phone-be.min.js
  40. 1 1
      dist/min/inputmask/phone-codes/phone-ca.min.js
  41. 1 1
      dist/min/inputmask/phone-codes/phone-hu.min.js
  42. 1 1
      dist/min/inputmask/phone-codes/phone-mx.min.js
  43. 1 1
      dist/min/inputmask/phone-codes/phone-nl.min.js
  44. 1 1
      dist/min/inputmask/phone-codes/phone-ru.min.js
  45. 1 1
      dist/min/inputmask/phone-codes/phone-uk.min.js
  46. 1 1
      dist/min/inputmask/phone-codes/phone.min.js
  47. 2 2
      dist/min/jquery.inputmask.bundle.min.js
  48. 8 4
      js/inputmask.js
  49. 1 1
      package.json

+ 1 - 0
CHANGELOG.md

@@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
 
 ## [UNRELEASED - 4.x]
 ### added
+- jit enabled dynamic masks
 - add support for input type search
 - new datetime alias
 - extend positionCaretOnClick with "select" to select the whole input on focus

+ 17 - 1
README.md

@@ -267,7 +267,10 @@ The initial mask shown will be "**_**" instead of "**_**-____".
 ### Dynamic masks
 Dynamic masks can change during the input.  To define a dynamic part use { }.
 
-{n} => n repeats<br>{n,m} => from n to m repeats
+{n} => n repeats  
+{n|j} => n repeats, with j jitmasking  
+{n,m} => from n to m repeats  
+{n,m|j} => from n to m repeats, with j jitmasking
 
 Also {+} and {*} is allowed. + start from 1 and * start from 0.
 
@@ -291,6 +294,19 @@ $(document).ready(function(){
       }
     }
   });
+  //decimal mask
+   Inputmask("(.999){+|1},00", {
+        positionCaretOnClick: "radixFocus",
+        radixPoint: ",",
+        _radixDance: true,
+        numericInput: true,
+        placeholder: "0",
+        definitions: {
+            "0": {
+                validator: "[0-9\uFF11-\uFF19]"
+            }
+        }
+   }).mask(selector);
 });
 ```
 

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "4.0.0-beta.5",
+  "version": "4.0.0-beta.6",
   "main": [
 	  "./dist/inputmask/inputmask.js",
 	  "./dist/inputmask/inputmask.extensions.js",

+ 1 - 1
component.json

@@ -2,7 +2,7 @@
 	"name": "inputmask",
 	"repository": "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.0-beta.5",
+	"version": "4.0.0-beta.6",
 	"keywords": [
 		"jquery",
 		"plugins",

+ 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.0-beta.5",
+  "version": "4.0.0-beta.6",
   "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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 !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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 !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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 !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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/global/document.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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 "function" == typeof define && define.amd ? define(function() {

+ 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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 "function" == typeof define && 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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 !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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 !function(factory) {

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


+ 3 - 4
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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 !function(factory) {
@@ -33,9 +33,8 @@
                 var mask = "[+]";
                 if (mask += autoEscape(opts.prefix, opts), !0 === opts.integerOptional ? mask += "~{1," + opts.integerDigits + "}" : mask += "~{" + opts.integerDigits + "}", 
                 opts.digits !== undefined) {
-                    opts.radixPointDefinitionSymbol = opts.decimalProtect ? ":" : opts.radixPoint;
-                    var dq = opts.digits.toString().split(",");
-                    isFinite(dq[0] && dq[1] && isFinite(dq[1])) ? mask += opts.radixPointDefinitionSymbol + ";{" + opts.digits + "}" : (isNaN(opts.digits) || parseInt(opts.digits) > 0) && (opts.digitsOptional ? mask += "[" + opts.radixPointDefinitionSymbol + ";{1," + opts.digits + "}]" : mask += opts.radixPointDefinitionSymbol + ";{" + opts.digits + "}");
+                    var radixDef = opts.decimalProtect ? ":" : opts.radixPoint, dq = opts.digits.toString().split(",");
+                    isFinite(dq[0] && dq[1] && isFinite(dq[1])) ? mask += radixDef + ";{" + opts.digits + "}" : (isNaN(opts.digits) || parseInt(opts.digits) > 0) && (opts.digitsOptional ? mask += "[" + radixDef + ";{1," + opts.digits + "}]" : mask += radixDef + ";{" + opts.digits + "}");
                 }
                 return mask += autoEscape(opts.suffix, opts), mask += "[-]", opts.greedy = !1, mask;
             },

+ 1 - 1
dist/inputmask/inputmask.phone.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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 !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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone-be.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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone-ca.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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone-hu.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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone-mx.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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone-nl.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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone-ru.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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone-uk.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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone.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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 !function(factory) {

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


文件差异内容过多而无法显示
+ 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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 !function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?module.exports=e(require("jquery")):window.dependencyLib=e(jQuery)}(function(e){return e});

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


+ 1 - 1
dist/min/inputmask/global/document.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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 "function"==typeof define&&define.amd?define(function(){return document}):"object"==typeof exports&&(module.exports=document);

+ 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.0-beta.5
+* Version: 4.0.0-beta.6
 */
 
 "function"==typeof define&&define.amd?define(function(){return window}):"object"==typeof exports&&(module.exports=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


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


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


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


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


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


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


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


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


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


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


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


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


+ 8 - 4
js/inputmask.js

@@ -287,7 +287,7 @@
                 });
             },
             analyseMask: function (mask, regexMask, opts) {
-                var tokenizer = /(?:[?*+]|\{[0-9\+\*]+(?:,[0-9\+\*]*)?\})|[^.?*+^${[]()|\\]+|./g,
+                var tokenizer = /(?:[?*+]|\{[0-9\+\*]+(?:,[0-9\+\*]*)?(?:\|[0-9\+\*]*)?\})|[^.?*+^${[]()|\\]+|./g,
                     //Thx to https://github.com/slevithan/regex-colorizer for the regexTokenizer regex
                     regexTokenizer = /\[\^?]?(?:[^\\\]]+|\\[\S\s]?)*]?|\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9][0-9]*|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|c[A-Za-z]|[\S\s]?)|\((?:\?[:=!]?)?|(?:[?*+]|\{[0-9]+(?:,[0-9]*)?\})\??|[^.?*+^${[()|\\]+|./g,
                     escaped = false,
@@ -517,7 +517,8 @@
                             var quantifier = new MaskToken(false, false, true);
 
                             m = m.replace(/[{}]/g, "");
-                            var mq = m.split(","),
+                            var mqj = m.split("|"),
+                                mq = mqj[0].split(","),
                                 mq0 = isNaN(mq[0]) ? mq[0] : parseInt(mq[0]),
                                 mq1 = mq.length === 1 ? mq0 : (isNaN(mq[1]) ? mq[1] : parseInt(mq[1]));
                             if (mq1 === "*" || mq1 === "+") {
@@ -525,7 +526,8 @@
                             }
                             quantifier.quantifier = {
                                 min: mq0,
-                                max: mq1
+                                max: mq1,
+                                jit: mqj[1]
                             };
                             if (openenings.length > 0) {
                                 var matches = openenings[openenings.length - 1].matches;
@@ -805,7 +807,8 @@
                         testPos = getTestTemplate(pos, ndxIntlzr, pos - 1);
                         test = testPos.match;
                         ndxIntlzr = testPos.locator.slice();
-                        if (opts.jitMasking === false || pos < lvp || (typeof opts.jitMasking === "number" && isFinite(opts.jitMasking) && opts.jitMasking > pos)) {
+                        var jitMasking = opts.jitMasking !== false ? opts.jitMasking : test.jit;
+                        if (jitMasking === false || jitMasking === undefined || pos < lvp || (typeof jitMasking === "number" && isFinite(jitMasking) && jitMasking > pos)) {
                             maskTemplate.push(includeMode === false ? test.nativeDef : getPlaceholder(pos, test));
                         }
                     }
@@ -1223,6 +1226,7 @@
                                         //get latest match
                                         latestMatch = matches[matches.length - 1].match;
                                         latestMatch.optionalQuantifier = qndx > (qt.quantifier.min - 1);
+                                        latestMatch.jit = qndx + tokenGroup.matches.indexOf(latestMatch) >= qt.quantifier.jit;
                                         if (isFirstMatch(latestMatch, tokenGroup)) { //search for next possible match
                                             if (qndx > (qt.quantifier.min - 1)) {
                                                 insertStop = true;

+ 1 - 1
package.json

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