浏览代码

Decimal editing problems fix #1603

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

+ 1 - 0
CHANGELOG.md

@@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
 - fix undoValue initialization 
 
 ### Fixed
+- Decimal editing problems #1603
 - UX problem with email mask #1600
 - Force numeric to empty (on blur) with '0' as value #215
 - ndxInitializer.shift is not a function

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "3.3.7-19",
+  "version": "3.3.7-20",
   "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": "3.3.7-19",
+	"version": "3.3.7-20",
 	"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": "3.3.7-19",
+  "version": "3.3.7-20",
   "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 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.7-19
+* Version: 3.3.7-20
 */
 
 !function(factory) {

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

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

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

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

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

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

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.7-19
+* Version: 3.3.7-20
 */
 
 "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 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.7-19
+* Version: 3.3.7-20
 */
 
 "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 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.7-19
+* Version: 3.3.7-20
 */
 
 !function(factory) {

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

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

+ 3 - 3
dist/inputmask/inputmask.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.7-19
+* Version: 3.3.7-20
 */
 
 !function(factory) {
@@ -688,8 +688,8 @@
                 pos.end = pos.begin, pos.begin = pend;
             }
             k === Inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || !1 === opts.insertMode) ? (pos.begin = seekPrevious(pos.begin), 
-            getMaskSet().validPositions[pos.begin] === undefined || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.begin--) : k === Inputmask.keyCode.DELETE && pos.begin === pos.end && (pos.end = isMask(pos.end, !0) ? pos.end + 1 : seekNext(pos.end) + 1, 
-            getMaskSet().validPositions[pos.begin] === undefined || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.end++), 
+            getMaskSet().validPositions[pos.begin] !== undefined && getMaskSet().validPositions[pos.begin].input === opts.groupSeparator && pos.begin--) : k === Inputmask.keyCode.DELETE && pos.begin === pos.end && (pos.end = isMask(pos.end, !0) && getMaskSet().validPositions[pos.end] && getMaskSet().validPositions[pos.end].input !== opts.radixPoint ? pos.end + 1 : seekNext(pos.end) + 1, 
+            getMaskSet().validPositions[pos.begin] !== undefined && getMaskSet().validPositions[pos.begin].input === opts.groupSeparator && pos.end++), 
             stripValidPositions(pos.begin, pos.end, !1, strict), !0 !== strict && function() {
                 if (opts.keepStatic) {
                     for (var validInputs = [], lastAlt = getLastValidPosition(-1, !0), positionsClone = $.extend(!0, {}, getMaskSet().validPositions), prevAltPos = getMaskSet().validPositions[lastAlt]; lastAlt >= 0; lastAlt--) {

+ 6 - 3
dist/inputmask/inputmask.numeric.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.7-19
+* Version: 3.3.7-20
 */
 
 !function(factory) {
@@ -203,8 +203,11 @@
                             if (!0 !== opts.numericInput && maskset.validPositions[pos] !== undefined && "~" === maskset.validPositions[pos].match.def && !isSelection) {
                                 var processValue = maskset.buffer.join("");
                                 processValue = processValue.replace(new RegExp("[-" + Inputmask.escapeRegex(opts.negationSymbol.front) + "]", "g"), ""), 
-                                processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), ""), 
-                                processValue = processValue.replace(/0/g, opts.placeholder.charAt(0));
+                                processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), "");
+                                var pvRadixSplit = processValue.split(opts.radixPoint);
+                                pvRadixSplit.length > 1 && (pvRadixSplit[1] = pvRadixSplit[1].replace(/0/g, opts.placeholder.charAt(0))), 
+                                "0" === pvRadixSplit[0] && (pvRadixSplit[0] = pvRadixSplit[0].replace(/0/g, opts.placeholder.charAt(0))), 
+                                processValue = pvRadixSplit[0] + opts.radixPoint + pvRadixSplit[1] || "";
                                 var bufferTemplate = maskset._buffer.join("");
                                 for (processValue === opts.radixPoint && (processValue = bufferTemplate); null === processValue.match(Inputmask.escapeRegex(bufferTemplate) + "$"); ) bufferTemplate = bufferTemplate.slice(1);
                                 processValue = processValue.replace(bufferTemplate, ""), processValue = processValue.split(""), 

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

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

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

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

+ 1 - 1
dist/inputmask/phone-codes/phone-be.js

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

+ 1 - 1
dist/inputmask/phone-codes/phone-nl.js

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

+ 1 - 1
dist/inputmask/phone-codes/phone-ru.js

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

+ 1 - 1
dist/inputmask/phone-codes/phone-uk.js

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

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

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

+ 8 - 5
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.7-19
+* Version: 3.3.7-20
 */
 
 !function(modules) {
@@ -726,8 +726,8 @@
                     pos.end = pos.begin, pos.begin = pend;
                 }
                 k === Inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || !1 === opts.insertMode) ? (pos.begin = seekPrevious(pos.begin), 
-                getMaskSet().validPositions[pos.begin] === undefined || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.begin--) : k === Inputmask.keyCode.DELETE && pos.begin === pos.end && (pos.end = isMask(pos.end, !0) ? pos.end + 1 : seekNext(pos.end) + 1, 
-                getMaskSet().validPositions[pos.begin] === undefined || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.end++), 
+                getMaskSet().validPositions[pos.begin] !== undefined && getMaskSet().validPositions[pos.begin].input === opts.groupSeparator && pos.begin--) : k === Inputmask.keyCode.DELETE && pos.begin === pos.end && (pos.end = isMask(pos.end, !0) && getMaskSet().validPositions[pos.end] && getMaskSet().validPositions[pos.end].input !== opts.radixPoint ? pos.end + 1 : seekNext(pos.end) + 1, 
+                getMaskSet().validPositions[pos.begin] !== undefined && getMaskSet().validPositions[pos.begin].input === opts.groupSeparator && pos.end++), 
                 stripValidPositions(pos.begin, pos.end, !1, strict), !0 !== strict && function() {
                     if (opts.keepStatic) {
                         for (var validInputs = [], lastAlt = getLastValidPosition(-1, !0), positionsClone = $.extend(!0, {}, getMaskSet().validPositions), prevAltPos = getMaskSet().validPositions[lastAlt]; lastAlt >= 0; lastAlt--) {
@@ -2465,8 +2465,11 @@
                                 if (!0 !== opts.numericInput && maskset.validPositions[pos] !== undefined && "~" === maskset.validPositions[pos].match.def && !isSelection) {
                                     var processValue = maskset.buffer.join("");
                                     processValue = processValue.replace(new RegExp("[-" + Inputmask.escapeRegex(opts.negationSymbol.front) + "]", "g"), ""), 
-                                    processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), ""), 
-                                    processValue = processValue.replace(/0/g, opts.placeholder.charAt(0));
+                                    processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), "");
+                                    var pvRadixSplit = processValue.split(opts.radixPoint);
+                                    pvRadixSplit.length > 1 && (pvRadixSplit[1] = pvRadixSplit[1].replace(/0/g, opts.placeholder.charAt(0))), 
+                                    "0" === pvRadixSplit[0] && (pvRadixSplit[0] = pvRadixSplit[0].replace(/0/g, opts.placeholder.charAt(0))), 
+                                    processValue = pvRadixSplit[0] + opts.radixPoint + pvRadixSplit[1] || "";
                                     var bufferTemplate = maskset._buffer.join("");
                                     for (processValue === opts.radixPoint && (processValue = bufferTemplate); null === processValue.match(Inputmask.escapeRegex(bufferTemplate) + "$"); ) bufferTemplate = bufferTemplate.slice(1);
                                     processValue = processValue.replace(bufferTemplate, ""), processValue = processValue.split(""), 

文件差异内容过多而无法显示
+ 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 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.7-19
+* Version: 3.3.7-20
 */
 
 !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):window.dependencyLib=a(jQuery)}(function(a){return a});

文件差异内容过多而无法显示
+ 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 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.7-19
+* Version: 3.3.7-20
 */
 
 "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 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.7-19
+* Version: 3.3.7-20
 */
 
 "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-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


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


+ 5 - 3
js/inputmask.js

@@ -2217,12 +2217,14 @@
 
                 if (k === Inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || opts.insertMode === false)) {
                     pos.begin = seekPrevious(pos.begin);
-                    if (getMaskSet().validPositions[pos.begin] !== undefined && (getMaskSet().validPositions[pos.begin].input === opts.groupSeparator || getMaskSet().validPositions[pos.begin].input === opts.radixPoint)) {
+                    if (getMaskSet().validPositions[pos.begin] !== undefined && getMaskSet().validPositions[pos.begin].input === opts.groupSeparator) {
                         pos.begin--;
                     }
                 } else if (k === Inputmask.keyCode.DELETE && pos.begin === pos.end) {
-                    pos.end = isMask(pos.end, true) ? pos.end + 1 : seekNext(pos.end) + 1;
-                    if (getMaskSet().validPositions[pos.begin] !== undefined && (getMaskSet().validPositions[pos.begin].input === opts.groupSeparator || getMaskSet().validPositions[pos.begin].input === opts.radixPoint)) {
+                    pos.end = isMask(pos.end, true) && (getMaskSet().validPositions[pos.end] && getMaskSet().validPositions[pos.end].input !== opts.radixPoint  ) ?
+                        pos.end + 1 :
+                        seekNext(pos.end) + 1;
+                    if (getMaskSet().validPositions[pos.begin] !== undefined && getMaskSet().validPositions[pos.begin].input === opts.groupSeparator) {
                         pos.end++;
                     }
                 }

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


+ 1 - 1
package.json

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

+ 190 - 170
qunit/simulator.js

@@ -1,182 +1,202 @@
 export default function ($, Inputmask) {
-	$.caret = function (input, begin, end) {
-		input = input.nodeName ? input : input[0];
-		var range;
-		if (typeof begin === "number") {
-			end = (typeof end == "number") ? end : begin;
-			// if (!$(input).is(":visible")) {
-			// 	return;
-			// }
+    $.caret = function (input, begin, end) {
+        input = input.nodeName ? input : input[0];
+        input.focus();
+        var range;
+        if (typeof begin === "number") {
+            end = (typeof end == "number") ? end : begin;
+            // if (!$(input).is(":visible")) {
+            // 	return;
+            // }
 
-			if (input.setSelectionRange) {
-				input.selectionStart = begin;
-				input.selectionEnd = end;
-			} else if (window.getSelection) {
-				range = document.createRange();
-				if (input.firstChild === undefined) {
-					var textNode = document.createTextNode("");
-					input.appendChild(textNode);
-				}
-				range.setStart(input.firstChild, begin < input.value.length ? begin : input.value.length);
-				range.setEnd(input.firstChild, end < input.value.length ? end : input.value.length);
-				range.collapse(true);
-				var sel = window.getSelection();
-				sel.removeAllRanges();
-				sel.addRange(range);
-				//input.focus();
-			} else if (input.createTextRange) {
-				range = input.createTextRange();
-				range.collapse(true);
-				range.moveEnd("character", end);
-				range.moveStart("character", begin);
-				range.select();
+            if (input.setSelectionRange) {
+                input.selectionStart = begin;
+                input.selectionEnd = end;
+            } else if (window.getSelection) {
+                range = document.createRange();
+                if (input.firstChild === undefined) {
+                    var textNode = document.createTextNode("");
+                    input.appendChild(textNode);
+                }
+                range.setStart(input.firstChild, begin < input.value.length ? begin : input.value.length);
+                range.setEnd(input.firstChild, end < input.value.length ? end : input.value.length);
+                range.collapse(true);
+                var sel = window.getSelection();
+                sel.removeAllRanges();
+                sel.addRange(range);
+                //input.focus();
+            } else if (input.createTextRange) {
+                range = input.createTextRange();
+                range.collapse(true);
+                range.moveEnd("character", end);
+                range.moveStart("character", begin);
+                range.select();
 
-			}
-		} else {
-			if (input.setSelectionRange) {
-				begin = input.selectionStart;
-				end = input.selectionEnd;
-			} else if (window.getSelection) {
-				range = window.getSelection().getRangeAt(0);
-				if (range.commonAncestorContainer.parentNode === input || range.commonAncestorContainer === input) {
-					begin = range.startOffset;
-					end = range.endOffset;
-				}
-			} else if (document.selection && document.selection.createRange) {
-				range = document.selection.createRange();
-				begin = 0 - range.duplicate().moveStart("character", -100000);
-				end = begin + range.text.length;
-			}
-			/*eslint-disable consistent-return */
-			return {
-				"begin": begin,
-				"end": end
-			};
-			/*eslint-enable consistent-return */
-		}
-	};
-	$.fn = $.fn || $.prototype;
-	$.fn.SendKey = function (keyCode, modifier) {
-		function trigger(elem, evnt) {
-			elem.focus();
-			if ($ === window.jQuery) {
-				$(elem).trigger(evnt);
-			} else {
-				if (document.createEvent) {
-					elem.dispatchEvent(evnt);
-				} else {
-					elem.fireEvent("on" + evnt.eventType, evnt);
-				}
-			}
-		}
+            }
+        } else {
+            if (input.setSelectionRange) {
+                begin = input.selectionStart;
+                end = input.selectionEnd;
+            } else if (window.getSelection) {
+                range = window.getSelection().getRangeAt(0);
+                if (range.commonAncestorContainer.parentNode === input || range.commonAncestorContainer === input) {
+                    begin = range.startOffset;
+                    end = range.endOffset;
+                }
+            } else if (document.selection && document.selection.createRange) {
+                range = document.selection.createRange();
+                begin = 0 - range.duplicate().moveStart("character", -100000);
+                end = begin + range.text.length;
+            }
+            /*eslint-disable consistent-return */
+            return {
+                "begin": begin,
+                "end": end
+            };
+            /*eslint-enable consistent-return */
+        }
+    };
+    $.fn = $.fn || $.prototype;
+    $.fn.SendKey = function (keyCode, modifier) {
+        function trigger(elem, evnt) {
+            elem.focus();
+            if ($ === window.jQuery) {
+                $(elem).trigger(evnt);
+            } else {
+                if (document.createEvent) {
+                    elem.dispatchEvent(evnt);
+                } else {
+                    elem.fireEvent("on" + evnt.eventType, evnt);
+                }
+            }
+        }
 
-		var sendDummyKeydown = false;
-		if (Object.prototype.toString.call(keyCode) == '[object String]') {
-			keyCode = keyCode.charCodeAt(0);
-			sendDummyKeydown = true;
-		}
+        var sendDummyKeydown = false;
+        if (Object.prototype.toString.call(keyCode) == '[object String]') {
+            keyCode = keyCode.charCodeAt(0);
+            sendDummyKeydown = true;
+        }
 
-		switch (keyCode) {
-			case Inputmask.keyCode.LEFT: {
-				if (modifier == undefined) {
-					var pos = $.caret(this);
-					$.caret(this, pos.begin - 1);
-					break;
-				}
-			}
-			case Inputmask.keyCode.RIGHT: {
-				if (modifier == undefined) {
-					var pos = $.caret(this);
-					$.caret(this, pos.begin + 1);
-					break;
-				}
-			}
-			default: {
-				var keydown = new $.Event("keydown"),
-					keypress = new $.Event("keypress"),
-					keyup = new $.Event("keyup");
+        switch (keyCode) {
+            case Inputmask.keyCode.LEFT: {
+                if (modifier == undefined) {
+                    var pos = $.caret(this);
+                    $.caret(this, pos.begin - 1);
+                    break;
+                }
+            }
+            case Inputmask.keyCode.RIGHT: {
+                if (modifier == undefined) {
+                    var pos = $.caret(this);
+                    $.caret(this, pos.begin + 1);
+                    break;
+                }
+            }
+            default: {
+                if (window.Inputmask && window.Inputmask.prototype.defaults.inputEventOnly === true) {
+                    var input = new $.Event("input"),
+                        elem = this.nodeName ? this : this[0],
+                        currentValue = elem.inputmask.__valueGet ? elem.inputmask.__valueGet.call(elem) : elem.value,
+                        caretPos = $.caret(elem);
 
-				if (!sendDummyKeydown) {
-					keydown.keyCode = keyCode;
-					if (modifier == Inputmask.keyCode.CONTROL)
-						keydown.ctrlKey = true;
-				}
-				trigger(this.nodeName ? this : this[0], keydown);
-				if (!keydown.defaultPrevented) {
-					keypress.keyCode = keyCode;
-					if (modifier == Inputmask.keyCode.CONTROL)
-						keypress.ctrlKey = true;
-					trigger(this.nodeName ? this : this[0], keypress);
-					//if (!keypress.isDefaultPrevented()) {
-					keyup.keyCode = keyCode;
-					if (modifier == Inputmask.keyCode.CONTROL)
-						keyup.ctrlKey = true;
-					trigger(this.nodeName ? this : this[0], keyup);
-					//}
-				}
-			}
-		}
-	}
-	if (!('append' in $.fn)) {
-		$.fn.append = function (child) {
-			var input = this.nodeName ? this : this[0];
-			input.insertAdjacentHTML('beforeend', child);
-		};
-	}
-	if (!('remove' in $.fn)) {
-		$.fn.remove = function () {
-			var input = this.nodeName ? this : this[0];
-			if (input !== undefined && input !== null) {
-				input.parentElement.removeChild(input);
-				input = undefined;
-			}
-		};
-	}
-	if (!('val' in $.fn)) {
-		$.fn.val = function (value) {
-			var input = this.nodeName ? this : this[0];
-			if (value !== undefined) {
-				if (input.inputmask) {
-					input.inputmask._valueSet(value, true);
-					$(input).trigger("setvalue");
-				} else input.value = value;
-			}
+                    console.log(currentValue);
+                    console.log(caretPos);
 
-			return input.value;
-		};
-	}
+                    var front = currentValue.substring(0, caretPos.begin),
+                        back = currentValue.substring(caretPos.end);
+                    if (elem.inputmask.__valueSet)
+                        elem.inputmask.__valueSet.call(elem, front + String.fromCharCode(keyCode) + back);
+                    else elem.value = front + String.fromCharCode(keyCode) + back;
 
-	$.fn.Type = function (inputStr) {
-		var input = this.nodeName ? this : this[0],
-			$input = $(input);
-		$.each(inputStr.split(''), function (ndx, lmnt) {
-			$input.SendKey(lmnt);
-		});
-	}
+                    console.log(front + String.fromCharCode(keyCode) + back);
+                    trigger(this.nodeName ? this : this[0], input);
+                } else {
+                    var keydown = new $.Event("keydown"),
+                        keypress = new $.Event("keypress"),
+                        keyup = new $.Event("keyup");
 
-	$.fn.paste = function (inputStr) {
-		var input = this.nodeName ? this : this[0],
-			$input = $(input);
-		if (window.clipboardData) {
-			window.clipboardData.setData('Text', inputStr);
-		} else {
-			$.data($input, "clipboard", inputStr);
-			window.clipboardData = {
-				getData: function () {
-					window.clipboardData = undefined;
-					return $.data($input, "clipboard");
-				}
-			}
-		}
+                    if (!sendDummyKeydown) {
+                        keydown.keyCode = keyCode;
+                        if (modifier == Inputmask.keyCode.CONTROL)
+                            keydown.ctrlKey = true;
+                    }
+                    trigger(this.nodeName ? this : this[0], keydown);
+                    if (!keydown.defaultPrevented) {
+                        keypress.keyCode = keyCode;
+                        if (modifier == Inputmask.keyCode.CONTROL)
+                            keypress.ctrlKey = true;
+                        trigger(this.nodeName ? this : this[0], keypress);
+                        //if (!keypress.isDefaultPrevented()) {
+                        keyup.keyCode = keyCode;
+                        if (modifier == Inputmask.keyCode.CONTROL)
+                            keyup.ctrlKey = true;
+                        trigger(this.nodeName ? this : this[0], keyup);
+                        //}
+                    }
+                }
+            }
+        }
+    }
+    if (!('append' in $.fn)) {
+        $.fn.append = function (child) {
+            var input = this.nodeName ? this : this[0];
+            input.insertAdjacentHTML('beforeend', child);
+        };
+    }
+    if (!('remove' in $.fn)) {
+        $.fn.remove = function () {
+            var input = this.nodeName ? this : this[0];
+            if (input !== undefined && input !== null) {
+                input.parentElement.removeChild(input);
+                input = undefined;
+            }
+        };
+    }
+    if (!('val' in $.fn)) {
+        $.fn.val = function (value) {
+            var input = this.nodeName ? this : this[0];
+            if (value !== undefined) {
+                if (input.inputmask) {
+                    input.inputmask._valueSet(value, true);
+                    $(input).trigger("setvalue");
+                } else input.value = value;
+            }
 
-		$input.trigger('paste');
-	}
+            return input.value;
+        };
+    }
 
-	$.fn.input = function (inputStr, caretBegin, caretEnd) {
-		var input = this.nodeName ? this : this[0];
-		input.inputmask.__valueSet.call(input, inputStr);
-		if (caretBegin !== undefined)
-			$.caret(input, caretBegin, caretEnd);
-		$(input).trigger("input");
-	}
+    $.fn.Type = function (inputStr) {
+        var input = this.nodeName ? this : this[0],
+            $input = $(input);
+        $.each(inputStr.split(''), function (ndx, lmnt) {
+            $input.SendKey(lmnt);
+        });
+    }
+
+    $.fn.paste = function (inputStr) {
+        var input = this.nodeName ? this : this[0],
+            $input = $(input);
+        if (window.clipboardData) {
+            window.clipboardData.setData('Text', inputStr);
+        } else {
+            $.data($input, "clipboard", inputStr);
+            window.clipboardData = {
+                getData: function () {
+                    window.clipboardData = undefined;
+                    return $.data($input, "clipboard");
+                }
+            }
+        }
+
+        $input.trigger('paste');
+    }
+
+    $.fn.input = function (inputStr, caretBegin, caretEnd) {
+        var input = this.nodeName ? this : this[0];
+        input.inputmask.__valueSet.call(input, inputStr);
+        if (caretBegin !== undefined)
+            $.caret(input, caretBegin, caretEnd);
+        $(input).trigger("input");
+    }
 };

文件差异内容过多而无法显示
+ 1976 - 1948
qunit/tests_numeric.js