浏览代码

fix for greedy: true with empty placeholder

Robin Herbots 12 年之前
父节点
当前提交
ac321014d3

+ 1 - 1
build.properties

@@ -7,7 +7,7 @@ distdir = dist
 
 
 build.major = 2
 build.major = 2
 build.minor = 3
 build.minor = 3
-build.revision = 18
+build.revision = 19
 
 
 target = jquery.inputmask.bundle.js
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js
 target.min = jquery.inputmask.bundle.min.js

+ 1 - 1
component.json

@@ -1,6 +1,6 @@
 {
 {
     "name": "jquery.inputmask",
     "name": "jquery.inputmask",
-    "version": "2.3.18",
+    "version": "2.3.19",
     "main": "./dist/jquery.inputmask.bundle.js",
     "main": "./dist/jquery.inputmask.bundle.js",
     "dependencies": {
     "dependencies": {
         "jquery": ">=1.5"
         "jquery": ">=1.5"

二进制
dist/jQuery.InputMask.2.3.18.nupkg


二进制
dist/jQuery.InputMask.2.3.19.nupkg


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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2013 Robin Herbots
 * Copyright (c) 2010 - 2013 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: 2.3.18
+* Version: 2.3.19
 */
 */
 
 
 (function ($) {
 (function ($) {
@@ -237,6 +237,7 @@
             function getMaskTemplate(mask) {
             function getMaskTemplate(mask) {
                 var escaped = false, outCount = 0, greedy = opts.greedy, repeat = opts.repeat;
                 var escaped = false, outCount = 0, greedy = opts.greedy, repeat = opts.repeat;
                 if (repeat == "*") greedy = false;
                 if (repeat == "*") greedy = false;
+                if (greedy == true && opts.placeholder == "") opts.placeholder = " ";
                 if (mask.length == 1 && greedy == false) { opts.placeholder = ""; } //hide placeholder with single non-greedy mask
                 if (mask.length == 1 && greedy == false) { opts.placeholder = ""; } //hide placeholder with single non-greedy mask
                 var singleMask = $.map(mask.split(""), function (element, index) {
                 var singleMask = $.map(mask.split(""), function (element, index) {
                     var outElem = [];
                     var outElem = [];
@@ -1559,7 +1560,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Copyright (c) 2010 - 2013 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: 2.3.18
+Version: 2.3.19
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -1661,7 +1662,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2012 Robin Herbots
 Copyright (c) 2010 - 2012 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: 2.3.18
+Version: 2.3.19
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2138,7 +2139,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Copyright (c) 2010 - 2013 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: 2.3.18
+Version: 2.3.19
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2307,7 +2308,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Copyright (c) 2010 - 2013 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: 2.3.18
+Version: 2.3.19
 
 
 Regex extensions on the jquery.inputmask base
 Regex extensions on the jquery.inputmask base
 Allows for using regular expressions as a mask
 Allows for using regular expressions as a mask

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


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


+ 1 - 1
jquery.inputmask.jquery.json

@@ -8,7 +8,7 @@
 		"inputmask",
 		"inputmask",
 		"mask"
 		"mask"
     ],
     ],
-    "version": "2.3.18",
+    "version": "2.3.19",
     "author": {
     "author": {
         "name": "Robin Herbots",
         "name": "Robin Herbots",
         "url": "http://github.com/RobinHerbots/jquery.inputmask"
         "url": "http://github.com/RobinHerbots/jquery.inputmask"

+ 1 - 0
js/jquery.inputmask.js

@@ -237,6 +237,7 @@
             function getMaskTemplate(mask) {
             function getMaskTemplate(mask) {
                 var escaped = false, outCount = 0, greedy = opts.greedy, repeat = opts.repeat;
                 var escaped = false, outCount = 0, greedy = opts.greedy, repeat = opts.repeat;
                 if (repeat == "*") greedy = false;
                 if (repeat == "*") greedy = false;
+                if (greedy == true && opts.placeholder == "") opts.placeholder = " ";
                 if (mask.length == 1 && greedy == false) { opts.placeholder = ""; } //hide placeholder with single non-greedy mask
                 if (mask.length == 1 && greedy == false) { opts.placeholder = ""; } //hide placeholder with single non-greedy mask
                 var singleMask = $.map(mask.split(""), function (element, index) {
                 var singleMask = $.map(mask.split(""), function (element, index) {
                     var outElem = [];
                     var outElem = [];

+ 13 - 0
qunit/tests.js

@@ -308,6 +308,19 @@ test("inputmask(\"9,99\", { greedy: true, repeat: 5 }) - type 123456789012345678
     $("#testmask").remove();
     $("#testmask").remove();
 });
 });
 
 
+test("inputmask({ mask: \"9\", repeat: 10, placeholder: \"\", numericInput: true }) - greedy true with empty placeholder - type 12345", function () {
+    $('body').append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask({ "mask": "9", repeat: 10, placeholder: "", numericInput: true });
+
+    $("#testmask")[0].focus();
+
+    $("#testmask").Type("12345");
+
+    equal($("#testmask").val(), "     12345", "Result " + $("#testmask").val());
+
+    $("#testmask").remove();
+});
+
 module("Initial value setting");
 module("Initial value setting");
 
 
 test("inputmask(\"999:99\", { placeholder: \"0\"}) value=\"007:20\"", function () {
 test("inputmask(\"999:99\", { placeholder: \"0\"}) value=\"007:20\"", function () {