ソースを参照

fix for NumericInput + change default radixpoint to none

Robin Herbots 12 年 前
コミット
664936b8a4

+ 8 - 0
README.md

@@ -153,6 +153,14 @@ $(document).ready(function(){
 });
 ```
 
+If you define a radixPoint the caret will always jump to the integer part, until you type the radixpoint.  
+
+```javascript
+$(document).ready(function(){
+    $('#test').inputmask('€ 999.999.999,99', { numericInput: true, radixPoint: "," });
+});
+```
+
 ### remove the inputmask
 
 ```javascript

+ 1 - 1
build.properties

@@ -7,7 +7,7 @@ distdir = dist
 
 build.major = 1
 build.minor = 3
-build.revision = 4
+build.revision = 5
 
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js

+ 2 - 1
build.xml

@@ -14,7 +14,8 @@
 	   <replaceregexp file="${srcdir}/jquery.inputmask.extensions.js" match="Version:.*" replace="Version: ${build.major}.${build.minor}.${build.revision}"  byline="true"/>
 	   <replaceregexp file="${srcdir}/jquery.inputmask.date.extensions.js" match="Version:.*" replace="Version: ${build.major}.${build.minor}.${build.revision}"  byline="true"/>
 	   <replaceregexp file="${srcdir}/jquery.inputmask.numeric.extensions.js" match="Version:.*" replace="Version: ${build.major}.${build.minor}.${build.revision}"  byline="true"/>
-    </target>
+	   <replaceregexp file="./jquery.inputmask.jquery.json" match="&quot;version&quot;:.*" replace="&quot;version&quot;: &quot;${build.major}.${build.minor}.${build.revision}&quot;"  byline="true"/>
+	</target>
 
 	<target name="resetVersions">
        <replaceregexp file="nuget/jquery.inputmask.nuspec" match="&lt;version&gt;.*&lt;/version&gt;" replace="&lt;version&gt;0.0.0&lt;/version&gt;" />

BIN
dist/jQuery.InputMask.1.3.4.nupkg


BIN
dist/jQuery.InputMask.1.3.5.nupkg


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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2012 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 1.3.4
+* Version: 1.3.5
 */
 
 (function ($) {
@@ -34,7 +34,7 @@
                 onKeyValidation: $.noop, //executes on every key-press with the result of isValid
                 //numeric basic properties
                 numericInput: false, //numericInput input direction style (input shifts to the left while holding the caret position)
-                radixPoint: ".", // | ","
+                radixPoint: "", //".", // | ","
                 //numeric basic properties
                 definitions: {
                     '9': {
@@ -484,7 +484,7 @@
                 if (clearInvalid) {
                     writeBuffer(input, buffer);
                 }
-                return isRTL ? (opts.numericInput ? ($.inArray(opts.radixPoint, buffer) != -1 && skipRadixHandling !== true ? $.inArray(opts.radixPoint, buffer) : seekNext(buffer, maskL)) : seekNext(buffer, rtlMatch)) : seekNext(buffer, lastMatch);
+                return isRTL ? (opts.numericInput ? (opts.radixPoint != "" && $.inArray(opts.radixPoint, buffer) != -1 && skipRadixHandling !== true ? $.inArray(opts.radixPoint, buffer) : seekNext(buffer, maskL)) : seekNext(buffer, rtlMatch)) : seekNext(buffer, lastMatch);
             }
 
             function escapeRegex(str) {
@@ -892,7 +892,7 @@
                     var input = this, k = e.keyCode, pos = caret(input);
 
                     //set input direction according the position to the radixPoint
-                    if (opts.numericInput) {
+                    if (opts.numericInput && opts.radixPoint != "") {
                         var nptStr = input._valueGet();
                         var radixPosition = nptStr.indexOf(opts.radixPoint);
                         if (radixPosition != -1) {
@@ -917,9 +917,13 @@
                                 beginPos = firstMaskPos;
                             }
                             if (beginPos >= firstMaskPos) {
+                                console.log('before delete ' + buffer);
                                 if (opts.numericInput && opts.greedy && k == opts.keyCode.DELETE && buffer[beginPos] == opts.radixPoint) {
                                     beginPos = seekNext(buffer, beginPos);
                                     isRTL = false;
+                                } else if (opts.numericInput && opts.greedy && k == opts.keyCode.BACKSPACE && buffer[beginPos] == opts.radixPoint) {
+                                    beginPos--;
+                                    isRTL = true;
                                 }
                                 if (isRTL) {
                                     beginPos = shiftR(firstMaskPos, beginPos, getPlaceHolder(beginPos), true);
@@ -1020,7 +1024,7 @@
                                         } else writeOutBuffer = false;
                                     } else setBufferElement(buffer, p, c);
                                     if (writeOutBuffer) {
-                                        writeBuffer(input, buffer, opts.numericInput ? seekNext(buffer, p) : p);
+                                        writeBuffer(input, buffer, opts.numericInput ? p + 1 : p);
                                         setTimeout(function () { //timeout needed for IE
                                             if (isComplete(input))
                                                 $input.trigger("complete");
@@ -1085,7 +1089,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 1.3.4
+Version: 1.3.5
 
 Optional extensions on the jquery.inputmask base
 */
@@ -1182,7 +1186,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2012 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 1.3.4
+Version: 1.3.5
 
 Optional extensions on the jquery.inputmask base
 */
@@ -1660,7 +1664,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2012 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 1.3.4
+Version: 1.3.5
 
 Optional extensions on the jquery.inputmask base
 */

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


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


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 8 - 4
js/jquery.inputmask.js

@@ -34,7 +34,7 @@
                 onKeyValidation: $.noop, //executes on every key-press with the result of isValid
                 //numeric basic properties
                 numericInput: false, //numericInput input direction style (input shifts to the left while holding the caret position)
-                radixPoint: ".", // | ","
+                radixPoint: "", //".", // | ","
                 //numeric basic properties
                 definitions: {
                     '9': {
@@ -484,7 +484,7 @@
                 if (clearInvalid) {
                     writeBuffer(input, buffer);
                 }
-                return isRTL ? (opts.numericInput ? ($.inArray(opts.radixPoint, buffer) != -1 && skipRadixHandling !== true ? $.inArray(opts.radixPoint, buffer) : seekNext(buffer, maskL)) : seekNext(buffer, rtlMatch)) : seekNext(buffer, lastMatch);
+                return isRTL ? (opts.numericInput ? (opts.radixPoint != "" && $.inArray(opts.radixPoint, buffer) != -1 && skipRadixHandling !== true ? $.inArray(opts.radixPoint, buffer) : seekNext(buffer, maskL)) : seekNext(buffer, rtlMatch)) : seekNext(buffer, lastMatch);
             }
 
             function escapeRegex(str) {
@@ -892,7 +892,7 @@
                     var input = this, k = e.keyCode, pos = caret(input);
 
                     //set input direction according the position to the radixPoint
-                    if (opts.numericInput) {
+                    if (opts.numericInput && opts.radixPoint != "") {
                         var nptStr = input._valueGet();
                         var radixPosition = nptStr.indexOf(opts.radixPoint);
                         if (radixPosition != -1) {
@@ -917,9 +917,13 @@
                                 beginPos = firstMaskPos;
                             }
                             if (beginPos >= firstMaskPos) {
+                                console.log('before delete ' + buffer);
                                 if (opts.numericInput && opts.greedy && k == opts.keyCode.DELETE && buffer[beginPos] == opts.radixPoint) {
                                     beginPos = seekNext(buffer, beginPos);
                                     isRTL = false;
+                                } else if (opts.numericInput && opts.greedy && k == opts.keyCode.BACKSPACE && buffer[beginPos] == opts.radixPoint) {
+                                    beginPos--;
+                                    isRTL = true;
                                 }
                                 if (isRTL) {
                                     beginPos = shiftR(firstMaskPos, beginPos, getPlaceHolder(beginPos), true);
@@ -1020,7 +1024,7 @@
                                         } else writeOutBuffer = false;
                                     } else setBufferElement(buffer, p, c);
                                     if (writeOutBuffer) {
-                                        writeBuffer(input, buffer, opts.numericInput ? seekNext(buffer, p) : p);
+                                        writeBuffer(input, buffer, opts.numericInput ? p + 1 : p);
                                         setTimeout(function () { //timeout needed for IE
                                             if (isComplete(input))
                                                 $input.trigger("complete");