浏览代码

fix edge bug when overtyping a selection at the start

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

+ 2 - 0
README.md

@@ -564,6 +564,8 @@ $(document).ready(function(){
    $("#numeric").inputmask("decimal", { digits: 3 });
    $("#numeric").inputmask("decimal", { digits: 3 });
 });
 });
 ```
 ```
+When TAB out of the input the digits autocomplate with 0 if the digits option is given a valid number.
+
 Grouping support through:  autoGroup, groupSeparator, groupSize
 Grouping support through:  autoGroup, groupSeparator, groupSize
 ```javascript
 ```javascript
 $(document).ready(function(){
 $(document).ready(function(){

+ 1 - 1
build.properties

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

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


+ 8 - 14
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.2.35
+* Version: 2.2.36
 */
 */
 
 
 (function ($) {
 (function ($) {
@@ -1280,12 +1280,6 @@
                         var k = k || e.which || e.charCode || e.keyCode,
                         var k = k || e.which || e.charCode || e.keyCode,
                             c = String.fromCharCode(k);
                             c = String.fromCharCode(k);
 
 
-                        if (opts.numericInput && c == opts.radixPoint) {
-                            var nptStr = input._valueGet();
-                            var radixPosition = nptStr.indexOf(opts.radixPoint);
-                            caret(input, seekNext(radixPosition != -1 ? radixPosition : getMaskLength()));
-                        }
-
                         if ((e.ctrlKey || e.metaKey || ignorable) && checkval !== true) {
                         if ((e.ctrlKey || e.metaKey || ignorable) && checkval !== true) {
                             return true;
                             return true;
                         } else {
                         } else {
@@ -1348,7 +1342,7 @@
                                                     if (firstUnmaskedPosition <= p && (getActiveMaskSet()['greedy'] || (buffer.length < maskL || getBufferElement(buffer, p) == getPlaceHolder(p)))) {
                                                     if (firstUnmaskedPosition <= p && (getActiveMaskSet()['greedy'] || (buffer.length < maskL || getBufferElement(buffer, p) == getPlaceHolder(p)))) {
                                                         if (buffer[firstMaskPos] != getPlaceHolder(firstMaskPos) && buffer.length < maskL) {
                                                         if (buffer[firstMaskPos] != getPlaceHolder(firstMaskPos) && buffer.length < maskL) {
                                                             var offset = prepareBuffer(buffer, -1, isRTL);
                                                             var offset = prepareBuffer(buffer, -1, isRTL);
-                                                            if (pos.end != 0) p = p + offset;
+                                                            if ((selectionCleared ? pos.begin : pos.end) != 0) p = p + offset;
                                                             maskL = buffer.length;
                                                             maskL = buffer.length;
                                                         }
                                                         }
                                                         shiftL(firstUnmaskedPosition, p, c);
                                                         shiftL(firstUnmaskedPosition, p, c);
@@ -1447,7 +1441,7 @@
                         }
                         }
                     }
                     }
 
 
-                    function keyupEvent(e) { //TODO have a relook of the keyup behavior
+                    function keyupEvent(e) { 
                         var $input = $(this), input = this, k = e.keyCode, buffer = getActiveBuffer();
                         var $input = $(this), input = this, k = e.keyCode, buffer = getActiveBuffer();
                         opts.onKeyUp.call(this, e, buffer, opts); //extra stuff to execute on keyup
                         opts.onKeyUp.call(this, e, buffer, opts); //extra stuff to execute on keyup
                         if (k == opts.keyCode.TAB && $input.hasClass('focus.inputmask') && input._valueGet().length == 0 && opts.showMaskOnFocus) {
                         if (k == opts.keyCode.TAB && $input.hasClass('focus.inputmask') && input._valueGet().length == 0 && opts.showMaskOnFocus) {
@@ -1469,7 +1463,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.2.35
+Version: 2.2.36
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -1566,7 +1560,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.2.35
+Version: 2.2.36
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2059,7 +2053,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.2.35
+Version: 2.2.36
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2159,7 +2153,7 @@ Optional extensions on the jquery.inputmask base
 
 
                         var cbuf = strict ? buffer.slice(0, pos) : buffer.slice();
                         var cbuf = strict ? buffer.slice(0, pos) : buffer.slice();
 
 
-                        cbuf.splice(pos + 1, 0, chrs);
+                        cbuf.splice(pos == 0 ? pos : pos + 1, 0, chrs);
                         var bufferStr = cbuf.join('');
                         var bufferStr = cbuf.join('');
                         if (opts.autoGroup && !strict) { //strip groupseparator
                         if (opts.autoGroup && !strict) { //strip groupseparator
                             var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
                             var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
@@ -2221,7 +2215,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.2.35
+Version: 2.2.36
 
 
 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

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


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


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


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 2 - 8
js/jquery.inputmask.js

@@ -1280,12 +1280,6 @@
                         var k = k || e.which || e.charCode || e.keyCode,
                         var k = k || e.which || e.charCode || e.keyCode,
                             c = String.fromCharCode(k);
                             c = String.fromCharCode(k);
 
 
-                        if (opts.numericInput && c == opts.radixPoint) {
-                            var nptStr = input._valueGet();
-                            var radixPosition = nptStr.indexOf(opts.radixPoint);
-                            caret(input, seekNext(radixPosition != -1 ? radixPosition : getMaskLength()));
-                        }
-
                         if ((e.ctrlKey || e.metaKey || ignorable) && checkval !== true) {
                         if ((e.ctrlKey || e.metaKey || ignorable) && checkval !== true) {
                             return true;
                             return true;
                         } else {
                         } else {
@@ -1348,7 +1342,7 @@
                                                     if (firstUnmaskedPosition <= p && (getActiveMaskSet()['greedy'] || (buffer.length < maskL || getBufferElement(buffer, p) == getPlaceHolder(p)))) {
                                                     if (firstUnmaskedPosition <= p && (getActiveMaskSet()['greedy'] || (buffer.length < maskL || getBufferElement(buffer, p) == getPlaceHolder(p)))) {
                                                         if (buffer[firstMaskPos] != getPlaceHolder(firstMaskPos) && buffer.length < maskL) {
                                                         if (buffer[firstMaskPos] != getPlaceHolder(firstMaskPos) && buffer.length < maskL) {
                                                             var offset = prepareBuffer(buffer, -1, isRTL);
                                                             var offset = prepareBuffer(buffer, -1, isRTL);
-                                                            if (pos.end != 0) p = p + offset;
+                                                            if ((selectionCleared ? pos.begin : pos.end) != 0) p = p + offset;
                                                             maskL = buffer.length;
                                                             maskL = buffer.length;
                                                         }
                                                         }
                                                         shiftL(firstUnmaskedPosition, p, c);
                                                         shiftL(firstUnmaskedPosition, p, c);
@@ -1447,7 +1441,7 @@
                         }
                         }
                     }
                     }
 
 
-                    function keyupEvent(e) { //TODO have a relook of the keyup behavior
+                    function keyupEvent(e) { 
                         var $input = $(this), input = this, k = e.keyCode, buffer = getActiveBuffer();
                         var $input = $(this), input = this, k = e.keyCode, buffer = getActiveBuffer();
                         opts.onKeyUp.call(this, e, buffer, opts); //extra stuff to execute on keyup
                         opts.onKeyUp.call(this, e, buffer, opts); //extra stuff to execute on keyup
                         if (k == opts.keyCode.TAB && $input.hasClass('focus.inputmask') && input._valueGet().length == 0 && opts.showMaskOnFocus) {
                         if (k == opts.keyCode.TAB && $input.hasClass('focus.inputmask') && input._valueGet().length == 0 && opts.showMaskOnFocus) {

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

@@ -103,7 +103,7 @@ Optional extensions on the jquery.inputmask base
 
 
                         var cbuf = strict ? buffer.slice(0, pos) : buffer.slice();
                         var cbuf = strict ? buffer.slice(0, pos) : buffer.slice();
 
 
-                        cbuf.splice(pos + 1, 0, chrs);
+                        cbuf.splice(pos == 0 ? pos : pos + 1, 0, chrs);
                         var bufferStr = cbuf.join('');
                         var bufferStr = cbuf.join('');
                         if (opts.autoGroup && !strict) { //strip groupseparator
                         if (opts.autoGroup && !strict) { //strip groupseparator
                             var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
                             var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);