ソースを参照

Cannot delete after fill up all the mask Android Chrome browser Jsfiddle fix #1637

Robin Herbots 8 年 前
コミット
0857dd164c
43 ファイル変更161 行追加143 行削除
  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. 21 17
      dist/inputmask/inputmask.js
  14. 1 1
      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. 21 17
      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. 3 3
      dist/min/inputmask/inputmask.min.js
  32. 1 1
      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. 3 3
      dist/min/jquery.inputmask.bundle.min.js
  41. 30 21
      js/inputmask.js
  42. 1 1
      package.json
  43. 46 46
      qunit/tests_inputeventonly.js

+ 1 - 0
CHANGELOG.md

@@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
 
 
 ### Fixes
 ### Fixes
 - Numeric suffix makes radixPoint disappear on preset value #1638
 - Numeric suffix makes radixPoint disappear on preset value #1638
+- Cannot delete after fill up all the mask Android Chrome browser Jsfiddle #1637
 
 
 ## [3.3.7 - 2017-06-09]
 ## [3.3.7 - 2017-06-09]
 ### added
 ### added

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "inputmask",
   "name": "inputmask",
-  "version": "4.0.1-9",
+  "version": "4.0.1-10",
   "main": [
   "main": [
 	  "./dist/inputmask/inputmask.js",
 	  "./dist/inputmask/inputmask.js",
 	  "./dist/inputmask/inputmask.extensions.js",
 	  "./dist/inputmask/inputmask.extensions.js",

+ 1 - 1
component.json

@@ -2,7 +2,7 @@
 	"name": "inputmask",
 	"name": "inputmask",
 	"repository": "robinherbots/Inputmask",
 	"repository": "robinherbots/Inputmask",
 	"description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
 	"description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
-	"version": "4.0.1-9",
+	"version": "4.0.1-10",
 	"keywords": [
 	"keywords": [
 		"jquery",
 		"jquery",
 		"plugins",
 		"plugins",

+ 1 - 1
composer.json

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

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 !function(factory) {
 !function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 !function(factory) {
 !function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 !function(factory) {
 !function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 !function(factory) {
 !function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 "function" == typeof define && define.amd ? define(function() {
 "function" == typeof define && define.amd ? define(function() {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 "function" == typeof define && define.amd ? define(function() {
 "function" == typeof define && define.amd ? define(function() {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 !function(factory) {
 !function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 !function(factory) {
 !function(factory) {

+ 21 - 17
dist/inputmask/inputmask.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 !function(factory) {
 !function(factory) {
@@ -744,21 +744,23 @@
                 isStatic || null !== test.fn && testPos.input !== undefined ? isStatic && (null !== test.fn && testPos.input !== undefined || "" === test.def) && (isStatic = !1, 
                 isStatic || null !== test.fn && testPos.input !== undefined ? isStatic && (null !== test.fn && testPos.input !== undefined || "" === test.def) && (isStatic = !1, 
                 maskTemplate += "</span>") : (isStatic = !0, maskTemplate += "<span class='im-static'>");
                 maskTemplate += "</span>") : (isStatic = !0, maskTemplate += "<span class='im-static'>");
             }
             }
-            var test, testPos, maskTemplate = "", isStatic = !1;
+            function handleCaret(force) {
+                !0 !== force && pos !== caretPos.begin || document.activeElement !== input || (maskTemplate += "<span class='im-caret' style='border-right-width: 1px;border-right-style: solid;'></span>");
+            }
+            var test, testPos, ndxIntlzr, maskTemplate = "", isStatic = !1, pos = 0;
             if (colorMask !== undefined) {
             if (colorMask !== undefined) {
                 if (caretPos === undefined ? caretPos = caret(input) : caretPos.begin === undefined && (caretPos = {
                 if (caretPos === undefined ? caretPos = caret(input) : caretPos.begin === undefined && (caretPos = {
                     begin: caretPos,
                     begin: caretPos,
                     end: caretPos
                     end: caretPos
                 }), !0 !== clear) {
                 }), !0 !== clear) {
-                    var ndxIntlzr, pos = 0, lvp = getLastValidPosition();
+                    var lvp = getLastValidPosition();
                     do {
                     do {
-                        pos === caretPos.begin && document.activeElement === input && (maskTemplate += "<span class='im-caret' style='border-right-width: 1px;border-right-style: solid;'></span>"), 
-                        getMaskSet().validPositions[pos] ? (testPos = getMaskSet().validPositions[pos], 
+                        handleCaret(), getMaskSet().validPositions[pos] ? (testPos = getMaskSet().validPositions[pos], 
                         test = testPos.match, ndxIntlzr = testPos.locator.slice(), handleStatic(), maskTemplate += testPos.input) : (testPos = getTestTemplate(pos, ndxIntlzr, pos - 1), 
                         test = testPos.match, ndxIntlzr = testPos.locator.slice(), handleStatic(), maskTemplate += testPos.input) : (testPos = getTestTemplate(pos, ndxIntlzr, pos - 1), 
                         test = testPos.match, ndxIntlzr = testPos.locator.slice(), (!1 === opts.jitMasking || pos < lvp || "number" == typeof opts.jitMasking && isFinite(opts.jitMasking) && opts.jitMasking > pos) && (handleStatic(), 
                         test = testPos.match, ndxIntlzr = testPos.locator.slice(), (!1 === opts.jitMasking || pos < lvp || "number" == typeof opts.jitMasking && isFinite(opts.jitMasking) && opts.jitMasking > pos) && (handleStatic(), 
                         maskTemplate += getPlaceholder(pos, test))), pos++;
                         maskTemplate += getPlaceholder(pos, test))), pos++;
-                    } while ((maxLength === undefined || pos < maxLength) && (null !== test.fn || "" !== test.def) || lvp > pos);
-                    isStatic && handleStatic();
+                    } while ((maxLength === undefined || pos < maxLength) && (null !== test.fn || "" !== test.def) || lvp > pos || isStatic);
+                    -1 === maskTemplate.indexOf("im-caret") && handleCaret(!0), isStatic && handleStatic();
                 }
                 }
                 var oldTemplate = colorMask.getElementsByTagName("div")[0], template = document.createElement("div");
                 var oldTemplate = colorMask.getElementsByTagName("div")[0], template = document.createElement("div");
                 template.innerHTML = maskTemplate, oldTemplate && colorMask.removeChild(oldTemplate), 
                 template.innerHTML = maskTemplate, oldTemplate && colorMask.removeChild(oldTemplate), 
@@ -918,18 +920,20 @@
                         }
                         }
                     }(input, inputValue, caretPos)) return !1;
                     }(input, inputValue, caretPos)) return !1;
                     caretPos.begin > inputValue.length && (caret(input, inputValue.length), caretPos = caret(input));
                     caretPos.begin > inputValue.length && (caret(input, inputValue.length), caretPos = caret(input));
-                    var buffer = getBuffer().join(""), frontPart = inputValue.substr(0, caretPos.begin), backPart = inputValue.substr(caretPos.begin), frontBufferPart = buffer.substr(0, caretPos.begin), backBufferPart = buffer.substr(caretPos.begin), selection = {
-                        begin: frontPart.length
-                    }, endOffset = 0;
-                    if (frontPart[frontPart.length - 1] !== frontBufferPart[frontBufferPart.length - 1] && (selection.begin--, 
-                    endOffset++), backPart.length > backBufferPart.length) selection.end = selection.begin; else {
-                        var selectedPart = backBufferPart.replace(new RegExp(Inputmask.escapeRegex(backPart) + "$"), "");
-                        selection.end = selection.begin + selectedPart.length + endOffset;
+                    var buffer = getBuffer().join(""), frontPart = inputValue.substr(0, caretPos.begin), backPart = inputValue.substr(caretPos.begin), frontBufferPart = buffer.substr(0, caretPos.begin), backBufferPart = buffer.substr(caretPos.begin), selection = caretPos, endOffset = 0;
+                    if (backPart === backBufferPart || frontPart === frontBufferPart) {
+                        if (selection = {
+                            begin: frontPart.length
+                        }, frontPart[frontPart.length - 1] !== frontBufferPart[frontBufferPart.length - 1] && (selection.begin--, 
+                        endOffset++), backPart.length > backBufferPart.length) selection.end = selection.begin; else {
+                            var selectedPart = backBufferPart.replace(new RegExp(Inputmask.escapeRegex(backPart) + "$"), "");
+                            selection.end = selection.begin + selectedPart.length + endOffset;
+                        }
+                        selection.begin !== selection.end || isMask(selection.begin) || (selection.end = caretPos.end);
                     }
                     }
-                    if (selection.begin != selection.end || isMask(selection.begin) || (selection.end = caretPos.end), 
-                    "" !== backPart && selection.begin < selection.end) writeBuffer(input, getBuffer(), selection), 
+                    if (selection.begin < selection.end) writeBuffer(input, getBuffer(), selection), 
                     frontPart.charCodeAt(frontPart.length - 1) !== frontBufferPart.charCodeAt(frontBufferPart.length - 1) ? (e.which = frontPart.charCodeAt(frontPart.length - 1), 
                     frontPart.charCodeAt(frontPart.length - 1) !== frontBufferPart.charCodeAt(frontBufferPart.length - 1) ? (e.which = frontPart.charCodeAt(frontPart.length - 1), 
-                    ignorable = !1, EventHandlers.keypressEvent.call(input, e)) : (selection.begin == selection.end - 1 && caret(input, seekPrevious(selection.begin + 1), selection.end), 
+                    ignorable = !1, EventHandlers.keypressEvent.call(input, e)) : (selection.begin === selection.end - 1 && caret(input, seekPrevious(selection.begin + 1), selection.end), 
                     e.keyCode = Inputmask.keyCode.DELETE, EventHandlers.keydownEvent.call(input, e)); else {
                     e.keyCode = Inputmask.keyCode.DELETE, EventHandlers.keydownEvent.call(input, e)); else {
                         for (var bufferTemplate = getBufferTemplate().join(""); null === inputValue.match(Inputmask.escapeRegex(bufferTemplate) + "$"); ) bufferTemplate = bufferTemplate.slice(1);
                         for (var bufferTemplate = getBufferTemplate().join(""); null === inputValue.match(Inputmask.escapeRegex(bufferTemplate) + "$"); ) bufferTemplate = bufferTemplate.slice(1);
                         inputValue = inputValue.replace(bufferTemplate, ""), $.isFunction(opts.onBeforeMask) && (inputValue = opts.onBeforeMask(inputValue, opts) || inputValue), 
                         inputValue = inputValue.replace(bufferTemplate, ""), $.isFunction(opts.onBeforeMask) && (inputValue = opts.onBeforeMask(inputValue, opts) || inputValue), 

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 !function(factory) {
 !function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 !function(factory) {
 !function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 !function(factory) {
 !function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 !function(factory) {
 !function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 !function(factory) {
 !function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 !function(factory) {
 !function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 !function(factory) {
 !function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 !function(factory) {
 !function(factory) {

+ 21 - 17
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 !function(modules) {
 !function(modules) {
@@ -792,21 +792,23 @@
                     isStatic || null !== test.fn && testPos.input !== undefined ? isStatic && (null !== test.fn && testPos.input !== undefined || "" === test.def) && (isStatic = !1, 
                     isStatic || null !== test.fn && testPos.input !== undefined ? isStatic && (null !== test.fn && testPos.input !== undefined || "" === test.def) && (isStatic = !1, 
                     maskTemplate += "</span>") : (isStatic = !0, maskTemplate += "<span class='im-static'>");
                     maskTemplate += "</span>") : (isStatic = !0, maskTemplate += "<span class='im-static'>");
                 }
                 }
-                var test, testPos, maskTemplate = "", isStatic = !1;
+                function handleCaret(force) {
+                    !0 !== force && pos !== caretPos.begin || document.activeElement !== input || (maskTemplate += "<span class='im-caret' style='border-right-width: 1px;border-right-style: solid;'></span>");
+                }
+                var test, testPos, ndxIntlzr, maskTemplate = "", isStatic = !1, pos = 0;
                 if (colorMask !== undefined) {
                 if (colorMask !== undefined) {
                     if (caretPos === undefined ? caretPos = caret(input) : caretPos.begin === undefined && (caretPos = {
                     if (caretPos === undefined ? caretPos = caret(input) : caretPos.begin === undefined && (caretPos = {
                         begin: caretPos,
                         begin: caretPos,
                         end: caretPos
                         end: caretPos
                     }), !0 !== clear) {
                     }), !0 !== clear) {
-                        var ndxIntlzr, pos = 0, lvp = getLastValidPosition();
+                        var lvp = getLastValidPosition();
                         do {
                         do {
-                            pos === caretPos.begin && document.activeElement === input && (maskTemplate += "<span class='im-caret' style='border-right-width: 1px;border-right-style: solid;'></span>"), 
-                            getMaskSet().validPositions[pos] ? (testPos = getMaskSet().validPositions[pos], 
+                            handleCaret(), getMaskSet().validPositions[pos] ? (testPos = getMaskSet().validPositions[pos], 
                             test = testPos.match, ndxIntlzr = testPos.locator.slice(), handleStatic(), maskTemplate += testPos.input) : (testPos = getTestTemplate(pos, ndxIntlzr, pos - 1), 
                             test = testPos.match, ndxIntlzr = testPos.locator.slice(), handleStatic(), maskTemplate += testPos.input) : (testPos = getTestTemplate(pos, ndxIntlzr, pos - 1), 
                             test = testPos.match, ndxIntlzr = testPos.locator.slice(), (!1 === opts.jitMasking || pos < lvp || "number" == typeof opts.jitMasking && isFinite(opts.jitMasking) && opts.jitMasking > pos) && (handleStatic(), 
                             test = testPos.match, ndxIntlzr = testPos.locator.slice(), (!1 === opts.jitMasking || pos < lvp || "number" == typeof opts.jitMasking && isFinite(opts.jitMasking) && opts.jitMasking > pos) && (handleStatic(), 
                             maskTemplate += getPlaceholder(pos, test))), pos++;
                             maskTemplate += getPlaceholder(pos, test))), pos++;
-                        } while ((maxLength === undefined || pos < maxLength) && (null !== test.fn || "" !== test.def) || lvp > pos);
-                        isStatic && handleStatic();
+                        } while ((maxLength === undefined || pos < maxLength) && (null !== test.fn || "" !== test.def) || lvp > pos || isStatic);
+                        -1 === maskTemplate.indexOf("im-caret") && handleCaret(!0), isStatic && handleStatic();
                     }
                     }
                     var oldTemplate = colorMask.getElementsByTagName("div")[0], template = document.createElement("div");
                     var oldTemplate = colorMask.getElementsByTagName("div")[0], template = document.createElement("div");
                     template.innerHTML = maskTemplate, oldTemplate && colorMask.removeChild(oldTemplate), 
                     template.innerHTML = maskTemplate, oldTemplate && colorMask.removeChild(oldTemplate), 
@@ -966,18 +968,20 @@
                             }
                             }
                         }(input, inputValue, caretPos)) return !1;
                         }(input, inputValue, caretPos)) return !1;
                         caretPos.begin > inputValue.length && (caret(input, inputValue.length), caretPos = caret(input));
                         caretPos.begin > inputValue.length && (caret(input, inputValue.length), caretPos = caret(input));
-                        var buffer = getBuffer().join(""), frontPart = inputValue.substr(0, caretPos.begin), backPart = inputValue.substr(caretPos.begin), frontBufferPart = buffer.substr(0, caretPos.begin), backBufferPart = buffer.substr(caretPos.begin), selection = {
-                            begin: frontPart.length
-                        }, endOffset = 0;
-                        if (frontPart[frontPart.length - 1] !== frontBufferPart[frontBufferPart.length - 1] && (selection.begin--, 
-                        endOffset++), backPart.length > backBufferPart.length) selection.end = selection.begin; else {
-                            var selectedPart = backBufferPart.replace(new RegExp(Inputmask.escapeRegex(backPart) + "$"), "");
-                            selection.end = selection.begin + selectedPart.length + endOffset;
+                        var buffer = getBuffer().join(""), frontPart = inputValue.substr(0, caretPos.begin), backPart = inputValue.substr(caretPos.begin), frontBufferPart = buffer.substr(0, caretPos.begin), backBufferPart = buffer.substr(caretPos.begin), selection = caretPos, endOffset = 0;
+                        if (backPart === backBufferPart || frontPart === frontBufferPart) {
+                            if (selection = {
+                                begin: frontPart.length
+                            }, frontPart[frontPart.length - 1] !== frontBufferPart[frontBufferPart.length - 1] && (selection.begin--, 
+                            endOffset++), backPart.length > backBufferPart.length) selection.end = selection.begin; else {
+                                var selectedPart = backBufferPart.replace(new RegExp(Inputmask.escapeRegex(backPart) + "$"), "");
+                                selection.end = selection.begin + selectedPart.length + endOffset;
+                            }
+                            selection.begin !== selection.end || isMask(selection.begin) || (selection.end = caretPos.end);
                         }
                         }
-                        if (selection.begin != selection.end || isMask(selection.begin) || (selection.end = caretPos.end), 
-                        "" !== backPart && selection.begin < selection.end) writeBuffer(input, getBuffer(), selection), 
+                        if (selection.begin < selection.end) writeBuffer(input, getBuffer(), selection), 
                         frontPart.charCodeAt(frontPart.length - 1) !== frontBufferPart.charCodeAt(frontBufferPart.length - 1) ? (e.which = frontPart.charCodeAt(frontPart.length - 1), 
                         frontPart.charCodeAt(frontPart.length - 1) !== frontBufferPart.charCodeAt(frontBufferPart.length - 1) ? (e.which = frontPart.charCodeAt(frontPart.length - 1), 
-                        ignorable = !1, EventHandlers.keypressEvent.call(input, e)) : (selection.begin == selection.end - 1 && caret(input, seekPrevious(selection.begin + 1), selection.end), 
+                        ignorable = !1, EventHandlers.keypressEvent.call(input, e)) : (selection.begin === selection.end - 1 && caret(input, seekPrevious(selection.begin + 1), selection.end), 
                         e.keyCode = Inputmask.keyCode.DELETE, EventHandlers.keydownEvent.call(input, e)); else {
                         e.keyCode = Inputmask.keyCode.DELETE, EventHandlers.keydownEvent.call(input, e)); else {
                             for (var bufferTemplate = getBufferTemplate().join(""); null === inputValue.match(Inputmask.escapeRegex(bufferTemplate) + "$"); ) bufferTemplate = bufferTemplate.slice(1);
                             for (var bufferTemplate = getBufferTemplate().join(""); null === inputValue.match(Inputmask.escapeRegex(bufferTemplate) + "$"); ) bufferTemplate = bufferTemplate.slice(1);
                             inputValue = inputValue.replace(bufferTemplate, ""), $.isFunction(opts.onBeforeMask) && (inputValue = opts.onBeforeMask(inputValue, opts) || inputValue), 
                             inputValue = inputValue.replace(bufferTemplate, ""), $.isFunction(opts.onBeforeMask) && (inputValue = opts.onBeforeMask(inputValue, opts) || inputValue), 

ファイルの差分が大きいため隠しています
+ 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
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 !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});
 !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
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 "function"==typeof define&&define.amd?define(function(){return document}):"object"==typeof exports&&(module.exports=document);
 "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
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Copyright (c) 2010 - 2017 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: 4.0.1-9
+* Version: 4.0.1-10
 */
 */
 
 
 "function"==typeof define&&define.amd?define(function(){return window}):"object"==typeof exports&&(module.exports=window);
 "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


ファイルの差分が大きいため隠しています
+ 3 - 3
dist/min/inputmask/inputmask.min.js


ファイルの差分が大きいため隠しています
+ 1 - 1
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


ファイルの差分が大きいため隠しています
+ 3 - 3
dist/min/jquery.inputmask.bundle.min.js


+ 30 - 21
js/inputmask.js

@@ -2602,32 +2602,36 @@
                             backBufferPart = buffer.substr(caretPos.begin);
                             backBufferPart = buffer.substr(caretPos.begin);
 
 
                         //check if thare was a selection
                         //check if thare was a selection
-                        var selection = {begin: frontPart.length}, endOffset = 0;
-                        if (frontPart[frontPart.length - 1] !== frontBufferPart[frontBufferPart.length - 1]) {
-                            selection.begin--;
-                            endOffset++;
-                        }
-                        if (backPart.length > backBufferPart.length) {
-                            selection.end = selection.begin;
-                        } else {
-                            var selectedPart = backBufferPart.replace(new RegExp(Inputmask.escapeRegex(backPart) + "$"), "");
-                            selection.end = selection.begin + selectedPart.length + endOffset;
-                        }
+                        var selection = caretPos, endOffset = 0;
+                        if (backPart === backBufferPart || frontPart === frontBufferPart) {
+                            selection = {begin: frontPart.length};
+                            if (frontPart[frontPart.length - 1] !== frontBufferPart[frontBufferPart.length - 1]) {
+                                selection.begin--;
+                                endOffset++;
+                            }
+                            if (backPart.length > backBufferPart.length) {
+                                selection.end = selection.begin;
+                            } else {
+                                var selectedPart = backBufferPart.replace(new RegExp(Inputmask.escapeRegex(backPart) + "$"), "");
+                                selection.end = selection.begin + selectedPart.length + endOffset;
+                            }
 
 
-                        if (selection.begin == selection.end && !isMask(selection.begin)) {
-                            selection.end = caretPos.end;
+                            if (selection.begin === selection.end && !isMask(selection.begin)) {
+                                selection.end = caretPos.end;
+                            }
                         }
                         }
 
 
                         //is selection
                         //is selection
-                        if (backPart !== "" && selection.begin < selection.end) {
+                        if (selection.begin < selection.end) {
                             writeBuffer(input, getBuffer(), selection);
                             writeBuffer(input, getBuffer(), selection);
                             if (frontPart.charCodeAt(frontPart.length - 1) !== frontBufferPart.charCodeAt(frontBufferPart.length - 1)) {
                             if (frontPart.charCodeAt(frontPart.length - 1) !== frontBufferPart.charCodeAt(frontBufferPart.length - 1)) {
                                 e.which = frontPart.charCodeAt(frontPart.length - 1);
                                 e.which = frontPart.charCodeAt(frontPart.length - 1);
                                 ignorable = false; //make sure ignorable is ignored ;-)
                                 ignorable = false; //make sure ignorable is ignored ;-)
                                 EventHandlers.keypressEvent.call(input, e);
                                 EventHandlers.keypressEvent.call(input, e);
                             } else {
                             } else {
-                                if (selection.begin == selection.end - 1)
+                                if (selection.begin === selection.end - 1) {
                                     caret(input, seekPrevious(selection.begin + 1), selection.end);
                                     caret(input, seekPrevious(selection.begin + 1), selection.end);
+                                }
                                 e.keyCode = Inputmask.keyCode.DELETE;
                                 e.keyCode = Inputmask.keyCode.DELETE;
                                 EventHandlers.keydownEvent.call(input, e);
                                 EventHandlers.keydownEvent.call(input, e);
                             }
                             }
@@ -2924,7 +2928,7 @@
             }
             }
 
 
             function renderColorMask(input, caretPos, clear) {
             function renderColorMask(input, caretPos, clear) {
-                var maskTemplate = "", isStatic = false, test, testPos;
+                var maskTemplate = "", isStatic = false, test, testPos, ndxIntlzr, pos = 0;
 
 
                 function handleStatic() {
                 function handleStatic() {
                     if (!isStatic && (test.fn === null || testPos.input === undefined)) {
                     if (!isStatic && (test.fn === null || testPos.input === undefined)) {
@@ -2936,6 +2940,12 @@
                     }
                     }
                 }
                 }
 
 
+                function handleCaret(force) {
+                    if ((force === true || pos === caretPos.begin) && document.activeElement === input) {
+                        maskTemplate += "<span class='im-caret' style='border-right-width: 1px;border-right-style: solid;'></span>";
+                    }
+                }
+
                 if (colorMask !== undefined) {
                 if (colorMask !== undefined) {
                     if (caretPos === undefined) {
                     if (caretPos === undefined) {
                         caretPos = caret(input);
                         caretPos = caret(input);
@@ -2944,11 +2954,9 @@
                     }
                     }
 
 
                     if (clear !== true) {
                     if (clear !== true) {
-                        var ndxIntlzr, pos = 0, lvp = getLastValidPosition();
+                        var lvp = getLastValidPosition();
                         do {
                         do {
-                            if (pos === caretPos.begin && document.activeElement === input) {
-                                maskTemplate += "<span class='im-caret' style='border-right-width: 1px;border-right-style: solid;'></span>";
-                            }
+                            handleCaret();
                             if (getMaskSet().validPositions[pos]) {
                             if (getMaskSet().validPositions[pos]) {
                                 testPos = getMaskSet().validPositions[pos];
                                 testPos = getMaskSet().validPositions[pos];
                                 test = testPos.match;
                                 test = testPos.match;
@@ -2965,7 +2973,8 @@
                                 }
                                 }
                             }
                             }
                             pos++;
                             pos++;
-                        } while ((maxLength === undefined || pos < maxLength) && (test.fn !== null || test.def !== "") || lvp > pos);
+                        } while ((maxLength === undefined || pos < maxLength) && (test.fn !== null || test.def !== "") || lvp > pos || isStatic);
+                        if (maskTemplate.indexOf("im-caret") === -1) handleCaret(true);
                         if (isStatic) handleStatic();
                         if (isStatic) handleStatic();
                     }
                     }
 
 

+ 1 - 1
package.json

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

+ 46 - 46
qunit/tests_inputeventonly.js

@@ -1,55 +1,55 @@
 export default function (qunit, $, Inputmask) {
 export default function (qunit, $, Inputmask) {
-	qunit.module("inputEventOnly: true");
+    qunit.module("inputEventOnly: true");
 
 
-	qunit.test("XXX-9999-9999-XXX-XXX - gersteba", function (assert) {
-		var $fixture = $("#qunit-fixture");
-		$fixture.append('<input type="text" id="testmask" />');
-		var testmask = document.getElementById("testmask");
-		Inputmask({
-			inputEventOnly: true,
-			mask: "XXX-9999-9999-XXX-XXX",
-			definitions: {
-				"X": {
-					validator: "[A-Ha-hJ-Nj-nPpR-Zr-z2-9]",
-					cardinality: 1,
-					casing: "upper"
-				}
-			}
-		}).mask(testmask);
+    qunit.test("XXX-9999-9999-XXX-XXX - gersteba", function (assert) {
+        var $fixture = $("#qunit-fixture");
+        $fixture.append('<input type="text" id="testmask" />');
+        var testmask = document.getElementById("testmask");
+        Inputmask({
+            inputEventOnly: true,
+            mask: "XXX-9999-9999-XXX-XXX",
+            definitions: {
+                "X": {
+                    validator: "[A-Ha-hJ-Nj-nPpR-Zr-z2-9]",
+                    cardinality: 1,
+                    casing: "upper"
+                }
+            }
+        }).mask(testmask);
 
 
-		testmask.focus();
-		//simulate input
-		$(testmask).input("abc12341234abcabc");
+        testmask.focus();
+        //simulate input
+        $(testmask).input("abc12341234abcabc");
 
 
-		assert.equal(testmask.value, "ABC-1234-1234-ABC-ABC", "Result " + testmask.value);
-	});
+        assert.equal(testmask.value, "ABC-1234-1234-ABC-ABC", "Result " + testmask.value);
+    });
 
 
-	qunit.test("(999) 999-9999", function (assert) {
-		var $fixture = $("#qunit-fixture");
-		$fixture.append('<input type="text" id="testmask" />');
-		var testmask = document.getElementById("testmask");
-		Inputmask("(999) 999-9999", {inputEventOnly: true}).mask(testmask);
+    qunit.test("(999) 999-9999", function (assert) {
+        var $fixture = $("#qunit-fixture");
+        $fixture.append('<input type="text" id="testmask" />');
+        var testmask = document.getElementById("testmask");
+        Inputmask("(999) 999-9999", {inputEventOnly: true}).mask(testmask);
 
 
-		testmask.focus();
-		//simulate input
-		$(testmask).input("1231231234");
+        testmask.focus();
+        //simulate input
+        $(testmask).input("1231231234");
 
 
-		assert.equal(testmask.value, "(123) 123-1234", "Result " + testmask.value);
-	});
+        assert.equal(testmask.value, "(123) 123-1234", "Result " + testmask.value);
+    });
 
 
-	qunit.test("(999) 999-9999 - type 123 + backspace", function (assert) {
-		var $fixture = $("#qunit-fixture");
-		$fixture.append('<input type="text" id="testmask" />');
-		var testmask = document.getElementById("testmask");
-		Inputmask("(999) 999-9999", {inputEventOnly: true}).mask(testmask);
+    qunit.test("(999) 999-9999 - type 123 + backspace", function (assert) {
+        var $fixture = $("#qunit-fixture");
+        $fixture.append('<input type="text" id="testmask" />');
+        var testmask = document.getElementById("testmask");
+        Inputmask("(999) 999-9999", {inputEventOnly: true}).mask(testmask);
 
 
-		testmask.focus();
-		//simulate input
-		$(testmask).input("123");
-		//simulate backspace
-		$(testmask).input("(12) ___-____", 3);
-		assert.ok($.caret(testmask).begin == 3, "Caret " + $.caret(testmask).begin);
-	});
+        testmask.focus();
+        //simulate input
+        $(testmask).input("123");
+        //simulate backspace
+        $(testmask).input("(12) ___-____", 3);
+        assert.ok($.caret(testmask).begin == 3, "Caret " + $.caret(testmask).begin);
+    });
 
 
 
 
     qunit.test("9999\\9\\9 - type 1234 + backspace - NightsDream", function (assert) {
     qunit.test("9999\\9\\9 - type 1234 + backspace - NightsDream", function (assert) {
@@ -66,9 +66,9 @@ export default function (qunit, $, Inputmask) {
 
 
         testmask.focus();
         testmask.focus();
         //simulate input
         //simulate input
-        $(testmask).input("1234");
+        $(testmask).input("123499");
         //simulate backspace
         //simulate backspace
-        $(testmask).input("1234X", 5);
-        assert.ok($.caret(testmask).begin == 5, "Caret " + $.caret(testmask).begin);
+        $(testmask).input("12349", 5);
+        assert.ok($.caret(testmask).begin == 3, "Caret " + $.caret(testmask).begin);
     });
     });
 };
 };