Browse Source

fix clearMaskOnLostFocus + added unittest

Robin Herbots 12 years ago
parent
commit
9f7dbe4203

+ 1 - 1
build.properties

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

+ 1 - 1
component.json

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

BIN
dist/jQuery.InputMask.2.2.68.nupkg


BIN
dist/jQuery.InputMask.2.2.69.nupkg


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

@@ -3,7 +3,7 @@
 * 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: 2.2.68
+* Version: 2.2.69
 */
 
 (function ($) {
@@ -952,6 +952,8 @@
                         } else {
                             clearOptionalTail(el);
                         }
+                    } else {
+                        writeBuffer(el, getActiveBuffer());
                     }
 
                     installEventRuler(el);
@@ -1481,7 +1483,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: 2.2.68
+Version: 2.2.69
 
 Optional extensions on the jquery.inputmask base
 */
@@ -1583,7 +1585,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: 2.2.68
+Version: 2.2.69
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2052,7 +2054,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: 2.2.68
+Version: 2.2.69
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2219,7 +2221,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: 2.2.68
+Version: 2.2.69
 
 Regex extensions on the jquery.inputmask base
 Allows for using regular expressions as a mask

File diff suppressed because it is too large
+ 29 - 29
dist/jquery.inputmask.bundle.min.js


File diff suppressed because it is too large
+ 28 - 28
dist/min/jquery.inputmask.js


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 2 - 0
js/jquery.inputmask.js

@@ -952,6 +952,8 @@
                         } else {
                             clearOptionalTail(el);
                         }
+                    } else {
+                        writeBuffer(el, getActiveBuffer());
                     }
 
                     installEventRuler(el);

BIN
qunit/JSRobot.jar


+ 2 - 1
qunit/qunit.html

@@ -10,7 +10,8 @@
   <div id="qunit-fixture"></div>
   <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
   <script src="http://code.jquery.com/qunit/qunit-1.12.0.js"></script>
-  <script src="https://rawgithub.com/RobinHerbots/jquery.inputmask/2.x/dist/jquery.inputmask.bundle.js"></script>
+  <script src="./robot.js"></script>
+  <script src="../dist/jquery.inputmask.bundle.js"></script>
   <script src="./tests.js"></script>
 </body>
 </html>

+ 110 - 0
qunit/robot.js

@@ -0,0 +1,110 @@
+/*
+   Copyright 2010 Ephox Corporation
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+*/
+(function() {
+	if (window.robot) {
+		// Don't load if there's already a version of robot loaded.
+		return;
+	}
+	
+	window.robot = {
+			
+		onload: function(userCallback) {
+			if (this.ready) {
+				userCallback();
+			} else {
+				this.userCallback = userCallback;
+			}
+		},
+		
+		init: function() {
+			var jarUrl = "JSRobot.jar";
+			var scripts = document.getElementsByTagName('script');
+			for (var i = 0; i < scripts.length; i++) {
+				var src = scripts[i].src;
+				var regex = /^(.*\/?)robot.js(\?|$)/;
+				if (src && regex.test(src)) {
+					jarUrl = regex.exec(src)[1] + "JSRobot.jar";
+				}
+			}
+			document.write('<applet archive="' + jarUrl + '" code="com.ephox.jsrobot.JSRobot" id="robotApplet" width="10" height="10" mayscript="true"><param name="mayscript" value="true" /></applet>');
+			this.appletInstance = document.getElementById('robotApplet');
+		},
+		
+		callback: function() {
+			this.ready = true;
+			if (this.userCallback) {
+				this.userCallback();
+			}
+		},
+		
+		type: function(key, shiftKey, callback) {
+			shiftKey = !!shiftKey;
+			this.appletAction(this.getApplet().typeKey(this.getKeycode(key), shiftKey), callback);
+		},
+		
+		forwardDelete: function(callback) {
+			this.type(0x7F, false, callback);
+		},
+		
+		cut: function(callback) {
+			this.typeAsShortcut('x', callback);
+		},
+		
+		copy: function(callback) {
+			this.typeAsShortcut('c', callback);
+		},
+		
+		paste: function(callback) {
+			this.typeAsShortcut('v', callback);
+		},
+		
+		typeAsShortcut: function(key, callback) {
+			this.appletAction(this.getApplet().typeAsShortcut(this.getKeycode(key)), callback);
+		},
+		
+		getKeycode: function(key) {
+			if (key.toUpperCase && key.charCodeAt) {
+				if (/^[a-zA-Z\n\b\t]$/.test(key)) {
+					return key.toUpperCase().charCodeAt(0);
+				} else {
+					throw { message: 'Invalid character to type. Must be a-z or A-Z, otherwise use the key code directly.' };
+				}
+			}
+			return key;
+		},
+		
+		captureScreenShot: function() {
+			return this.getApplet().captureScreenShot();
+		},
+		
+		setScreenShotDirectory: function(dir) {
+			this.getApplet().setScreenShotDirectory(dir);
+		},
+		
+		getApplet: function() {
+			return this.appletInstance;
+		},
+		
+		appletAction: function(actionResult, callback) {
+			if (actionResult) {
+				throw { message: "JSRobot error: " + actionResult };
+			}
+			setTimeout(callback, 100);
+		}
+	};
+	
+	window.robot.init();
+})();

+ 31 - 14
qunit/tests.js

@@ -1,3 +1,34 @@
+module("Simple masking");
+
+test( "inputmask(\"99-99-99\", { clearMaskOnLostFocus: false}", function() {
+  $('body').append('<input type="text" id="testmask" />');
+  $("#testmask").inputmask("99-99-99", { clearMaskOnLostFocus: false});
+  
+  equal(document.getElementById("testmask").value, "__-__-__", "Result " + document.getElementById("testmask").value);
+  
+  $("#testmask").remove();
+});
+
+asyncTest( "inputmask(\"999.999.999\")", 1, function() {
+	window.robot.onload(function(){
+		$('body').append('<input type="text" id="testmask" />');
+		$("#testmask").inputmask("999.999.999");
+  
+		$("#testmask")[0].focus();
+  
+		window.robot.type(97, true, $.noop);
+		window.robot.type(98, true, $.noop);
+		window.robot.type(99, true, $.noop);
+  
+		equal( $("#testmask").val(), "123.___.___", "Result " + $("#testmask").val());
+  
+		$("#testmask").remove();
+		start();
+  });
+});
+
+
+
 module("Initial value setting");
 
 test( "inputmask(\"999:99\", { placeholder: \"0\"}) value=\"007:20\"", function() {
@@ -33,17 +64,3 @@ test( "inputmask(\"\\D\\E***\") ~ value=\"DE001\"", function() {
   $("#testmask").remove();
 });
 
-module("Simple masking");
-
-test( "inputmask(\"999.999.999\")", function() {
-  $('body').append('<input type="text" id="testmask" />');
-  $("#testmask").inputmask("999.999.999");
-  
-  $("#testmask")[0].focus();
-  
-  //need keystrokes
-  
-  equal( $("#testmask").val(), "123.___.___", "Result " + $("#testmask").val());
-  
-  $("#testmask").remove();
-});