ソースを参照

Merge branch '2.x' into 2.6

Robin Herbots 11 年 前
コミット
307767e1f8
3 ファイル変更49 行追加2 行削除
  1. 15 0
      build.properties~
  2. 17 2
      js/jquery.inputmask.js
  3. 17 0
      qunit/tests.js

+ 15 - 0
build.properties~

@@ -0,0 +1,15 @@
+# Path for the Google Compiler jar file. By default in the same directory as this properties file.
+GoogleCompiler = tools/compiler.jar
+NugetExe = NuGet.exe
+
+srcdir = js
+distdir = dist
+
+build.major = 2
+build.minor = 4
+build.revision = 20
+
+target = jquery.inputmask.bundle.js
+target.min = jquery.inputmask.bundle.min.js
+nuspec = jquery.inputmask.nuspec
+nuspeclinux = jquery.inputmask.linux.nuspec

+ 17 - 2
js/jquery.inputmask.js

@@ -1336,6 +1336,8 @@
                                 } else if (isSlctn) {
                                     getActiveMaskSet()["buffer"] = getActiveMaskSet()["undoBuffer"].split('');
                                 }
+                            } else if (isSlctn) {
+                                getActiveMaskSet()["buffer"] = getActiveMaskSet()["undoBuffer"].split('');
                             }
                         }
 
@@ -1391,20 +1393,27 @@
                 }, 0);
             }
 
+            //not used - attempt to support android 
             function mobileInputEvent(e) {
                 var input = this, $input = $(input);
 
                 //backspace in chrome32 only fires input event - detect & treat
                 var caretPos = caret(input),
                     currentValue = input._valueGet();
-
+                    
+                currentValue = currentValue.replace(new RegExp("(" + escapeRegex(getActiveBufferTemplate().join('')) + ")*"), "");
+                //correct caretposition for chrome
+                if (caretPos.begin > currentValue.length) {
+                    caret(input, currentValue.length);
+                    caretPos = caret(input);
+                }
                 if ((getActiveBuffer().length - currentValue.length) == 1 && currentValue.charAt(caretPos.begin) != getActiveBuffer()[caretPos.begin]
                     && currentValue.charAt(caretPos.begin + 1) != getActiveBuffer()[caretPos.begin]
                     && !isMask(caretPos.begin)) {
                     e.keyCode = opts.keyCode.BACKSPACE;
                     keydownEvent.call(input, e);
                 } else { //nonnumerics don't fire keypress 
-                    checkVal(input, false, false);
+                    checkVal(input, false, false, currentValue.split(''));
                     writeBuffer(input, getActiveBuffer());
                     if (isComplete(getActiveBuffer()) === true)
                         $input.trigger("complete");
@@ -1586,6 +1595,11 @@
                     // as the other inputevents aren't reliable for the moment we only base on the input event
                     // needs follow-up
                     if (android || androidfirefox || androidchrome) {
+                        $el.attr("autocomplete","off")
+                        .attr("autocorrect","off")
+                        .attr("autocapitalize","off")
+                        .attr("spellcheck",false);
+                    /*
                         $el.unbind("keydown.inputmask", keydownEvent
                          	).unbind("keypress.inputmask", keypressEvent
                          	).unbind("keyup.inputmask", keyupEvent);
@@ -1593,6 +1607,7 @@
                             $el.unbind(PasteEventType + ".inputmask");
                         }
                         $el.bind("input.inputmask", mobileInputEvent);
+                    */
                     }
 
                     if (msie1x)

+ 17 - 0
qunit/tests.js

@@ -1177,6 +1177,23 @@ test("inputmask(\"decimal\") - value=\"123.45\" Replace last integer", function
     $("#testmask").remove();
 });
 
+test("inputmask(\"decimal\", { digits: 2 }) - value=\"123\" - RomeroMsk", function () {
+    $('body').append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask("decimal", { digits: 2 });
+
+    $("#testmask")[0].focus();
+    $("#testmask").Type("123");
+    caret($("#testmask"), 0, 3);
+    $("#testmask").SendKey(",,..");
+	$("#testmask").SendKey(keyCodes.RIGHT);
+	$("#testmask").SendKey(keyCodes.RIGHT); //needed in test
+	$("#testmask").SendKey(keyCodes.RIGHT); //needed in test
+	$("#testmask").Type("45");
+
+    equal($("#testmask").val(), "12345", "Result " + $("#testmask").val());
+    $("#testmask").remove();
+});
+
 test("inputmask - Multiple inputs masked, Integer mask doesn't allow typing - #402 - albatrocity", function () {
     $('body').append('<input type="text" id="testmask" />');
     $('body').append('<input type="text" id="testmask2" />');