ソースを参照

update inputfallback + checkval #1357

Robin Herbots 9 年 前
コミット
7117b9a667

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.3.2-109",
+  "version": "3.3.2-115",
   "main": [
     "./dist/inputmask/inputmask.js"
   ],

+ 1 - 1
component.json

@@ -2,7 +2,7 @@
   "name": "jquery_inputmask",
   "repository": "robinherbots/jquery.inputmask",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
-  "version": "3.3.2-109",
+  "version": "3.3.2-115",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "main": "./dist/jquery.inputmask.bundle.js",
   "scripts": [

+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
   "name": "robinherbots/jquery.inputmask",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
-  "version": "3.3.2-109",
+  "version": "3.3.2-115",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/jquery.inputmask",

+ 1 - 1
dist/inputmask/inputmask.date.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-109
+* Version: 3.3.2-115
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/inputmask.dependencyLib.jquery.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-109
+* Version: 3.3.2-115
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery")) : factory(jQuery);

+ 1 - 1
dist/inputmask/inputmask.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-109
+* Version: 3.3.2-115
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

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


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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-109
+* Version: 3.3.2-115
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 3 - 3
dist/inputmask/inputmask.phone.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-109
+* Version: 3.3.2-115
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);
@@ -17,8 +17,8 @@
                     "#": opts.definitions[9]
                 };
                 var masks = opts.phoneCodes.sort(function(a, b) {
-                    var maska = (a.mask || a).replace(/#/g, "9").replace(/[\+\(\)#-]/g, ""), maskb = (b.mask || b).replace(/#/g, "9").replace(/[\+\(\)#-]/g, "");
-                    return maska < maskb ? -1 : 1;
+                    var maska = (a.mask || a).replace(/#/g, "9").replace(/[\+\(\)#-]/g, ""), maskb = (b.mask || b).replace(/#/g, "9").replace(/[\+\(\)#-]/g, ""), maskas = (a.mask || a).split("#")[0], maskbs = (b.mask || b).split("#")[0];
+                    return 0 === maskbs.indexOf(maskas) ? -1 : 0 === maskas.indexOf(maskbs) ? 1 : maska.localeCompare(maskb);
                 });
                 return masks;
             },

+ 1 - 1
dist/inputmask/inputmask.regex.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-109
+* Version: 3.3.2-115
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/jquery.inputmask.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-109
+* Version: 3.3.2-115
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./inputmask")) : factory(jQuery, window.Inputmask);

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


+ 1 - 1
dist/min/inputmask/inputmask.date.extensions.min.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-109
+* Version: 3.3.2-115
 */
 /*
  Input Mask plugin extensions

+ 1 - 1
dist/min/inputmask/inputmask.dependencyLib.jquery.min.js

@@ -3,6 +3,6 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-109
+* Version: 3.3.2-115
 */
 !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){return window.dependencyLib=a,a});

+ 1 - 1
dist/min/inputmask/inputmask.extensions.min.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-109
+* Version: 3.3.2-115
 */
 /*
  Input Mask plugin extensions

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


+ 1 - 1
dist/min/inputmask/inputmask.numeric.extensions.min.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-109
+* Version: 3.3.2-115
 */
 /*
  Input Mask plugin extensions

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


+ 1 - 1
dist/min/inputmask/inputmask.regex.extensions.min.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-109
+* Version: 3.3.2-115
 */
 /*
  Input Mask plugin extensions

+ 1 - 1
dist/min/inputmask/jquery.inputmask.min.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-109
+* Version: 3.3.2-115
 */
 /*
  * Input Mask plugin for jquery

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


+ 18 - 12
js/inputmask.js

@@ -643,7 +643,7 @@
 			if (opts.numericInput) {
 				reverseTokens(maskTokens[0]);
 			}
-			// console.log(JSON.stringify(maskTokens));
+			//console.log(JSON.stringify(maskTokens));
 			return maskTokens;
 		}
 
@@ -918,9 +918,9 @@
 			resetMaskSet(true);
 		}
 
-		function determineTestTemplate(tests, ignoreGreedy) {
-			var testPos;
-			var testPositions = tests,
+		function determineTestTemplate(tests, guessNextBest) {
+			var testPos,
+				testPositions = tests,
 				lvp = getLastValidPosition(),
 				lvTest = getMaskSet().validPositions[lvp] || getTests(0)[0],
 				lvTestAltArr = (lvTest.alternation !== undefined) ? lvTest.locator[lvTest.alternation].toString().split(",") : [];
@@ -928,10 +928,12 @@
 				testPos = testPositions[ndx];
 
 				if (testPos.match &&
-					((((opts.greedy || ignoreGreedy) && testPos.match.optionalQuantifier !== true) || (testPos.match.optionality === false || testPos.match.newBlockMarker === false) && testPos.match.optionalQuantifier !== true) &&
+					(((opts.greedy && testPos.match.optionalQuantifier !== true) || (testPos.match.optionality === false || testPos.match.newBlockMarker === false) && testPos.match.optionalQuantifier !== true) &&
 					((lvTest.alternation === undefined || lvTest.alternation !== testPos.alternation) ||
 					(testPos.locator[lvTest.alternation] !== undefined && checkAlternationMatch(testPos.locator[lvTest.alternation].toString().split(","), lvTestAltArr))))) {
-					break;
+
+					if (guessNextBest !== true || (testPos.match.fn === null && !/[0-9a-bA-Z]/.test(testPos.match.def)))
+						break;
 				}
 			}
 
@@ -1745,7 +1747,7 @@
 			return opts.placeholder.charAt(pos % opts.placeholder.length);
 		}
 
-		function checkVal(input, writeOut, strict, nptvl, initiatingEvent) {
+		function checkVal(input, writeOut, strict, nptvl, initiatingEvent, stickyCaret) {
 			var inputValue = nptvl.slice(),
 				charCodes = "",
 				initialNdx = 0, result = undefined;
@@ -1815,9 +1817,13 @@
 				}
 			});
 			if (writeOut) {
-				var caretPos = (document.activeElement === input && (initiatingEvent || result)) ? (initiatingEvent ? caret(input).begin : result.forwardPosition) : undefined,
-					offset = getBuffer().length - input.inputmask._valueGet().length;
-				writeBuffer(input, getBuffer(), caretPos + offset, initiatingEvent || new $.Event("checkval"));
+				var caretPos = undefined, lvp = getLastValidPosition();
+				if (document.activeElement === input && (initiatingEvent || result)) {
+					caretPos = caret(input).begin - (stickyCaret === true ? 1 : 0);
+					if (result && stickyCaret !== true && (caretPos < lvp + 1 || lvp === -1))
+						caretPos = (opts.numericInput && result.caret === undefined) ? seekPrevious(result.forwardPosition) : result.forwardPosition;
+				}
+				writeBuffer(input, getBuffer(), caretPos, initiatingEvent || new $.Event("checkval"));
 			}
 		}
 
@@ -2194,7 +2200,7 @@
 					for (; lastAlt >= 0; lastAlt--) {
 						var altPos = getMaskSet().validPositions[lastAlt];
 						if (altPos) {
-							if (/*altPos.generatedInput !== true &&*/ /[0-9a-bA-Z]/.test(altPos.input)) {
+							if (altPos.generatedInput !== true && /[0-9a-bA-Z]/.test(altPos.input)) {
 								validInputs.push(altPos.input);
 							}
 							delete getMaskSet().validPositions[lastAlt];
@@ -2468,7 +2474,7 @@
 					inputValue = inputValue.replace(bufferTemplate, "");
 					inputValue = inputValue.split("");
 
-					checkVal(input, true, false, inputValue, e);
+					checkVal(input, true, false, inputValue, e, caretPos.begin < lvp);
 
 					if (isComplete(getBuffer()) === true) {
 						$(input).trigger("complete");

+ 5 - 2
js/inputmask.phone.extensions.js

@@ -26,10 +26,13 @@
 				opts.definitions = {"#": opts.definitions["9"]};
 				var masks = opts.phoneCodes.sort(function (a, b) {
 					var maska = (a.mask || a).replace(/#/g, "9").replace(/[\+\(\)#-]/g, ""),
-						maskb = (b.mask || b).replace(/#/g, "9").replace(/[\+\(\)#-]/g, "");
+						maskb = (b.mask || b).replace(/#/g, "9").replace(/[\+\(\)#-]/g, ""),
+						maskas = (a.mask || a).split("#")[0],
+						maskbs = (b.mask || b).split("#")[0];
 
-					return maska < maskb ? -1 : 1;
+					return maskbs.indexOf(maskas) === 0 ? -1 : (maskas.indexOf(maskbs) === 0 ? 1 : maska.localeCompare(maskb));
 				});
+				//console.log(JSON.stringify(masks));
 				return masks;
 			},
 			keepStatic: true,

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.3.2-109",
+  "version": "3.3.2-115",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "main": "./dist/inputmask/jquery.inputmask.js",
   "files": [

+ 168 - 156
qunit/simulator.js

@@ -1,172 +1,184 @@
-(function(factory) {
-		if (typeof define === "function" && define.amd) {
-			define(["inputmask.dependencyLib", "inputmask"], factory);
-		} else {
-			factory(window.dependencyLib || jQuery, window.Inputmask);
-		}
+(function (factory) {
+	if (typeof define === "function" && define.amd) {
+		define(["inputmask.dependencyLib", "inputmask"], factory);
+	} else {
+		factory(window.dependencyLib || jQuery, window.Inputmask);
 	}
-	(function($, Inputmask) {
-		$.caret = function(input, begin, end) {
-			input = input.nodeName ? input : input[0];
-			var range;
-			if (typeof begin === "number") {
-				end = (typeof end == "number") ? end : begin;
-				// if (!$(input).is(":visible")) {
-				// 	return;
-				// }
-
-				if (input.setSelectionRange) {
-					input.selectionStart = begin;
-					input.selectionEnd = end;
-				} else if (window.getSelection) {
-					range = document.createRange();
-					if (input.firstChild === undefined) {
-						var textNode = document.createTextNode("");
-						input.appendChild(textNode);
-					}
-					range.setStart(input.firstChild, begin < input.value.length ? begin : input.value.length);
-					range.setEnd(input.firstChild, end < input.value.length ? end : input.value.length);
-					range.collapse(true);
-					var sel = window.getSelection();
-					sel.removeAllRanges();
-					sel.addRange(range);
-					//input.focus();
-				} else if (input.createTextRange) {
-					range = input.createTextRange();
-					range.collapse(true);
-					range.moveEnd("character", end);
-					range.moveStart("character", begin);
-					range.select();
+}
+(function ($, Inputmask) {
+	$.caret = function (input, begin, end) {
+		input = input.nodeName ? input : input[0];
+		var range;
+		if (typeof begin === "number") {
+			end = (typeof end == "number") ? end : begin;
+			// if (!$(input).is(":visible")) {
+			// 	return;
+			// }
 
+			if (input.setSelectionRange) {
+				input.selectionStart = begin;
+				input.selectionEnd = end;
+			} else if (window.getSelection) {
+				range = document.createRange();
+				if (input.firstChild === undefined) {
+					var textNode = document.createTextNode("");
+					input.appendChild(textNode);
 				}
-			} else {
-				if (input.setSelectionRange) {
-					begin = input.selectionStart;
-					end = input.selectionEnd;
-				} else if (window.getSelection) {
-					range = window.getSelection().getRangeAt(0);
-					if (range.commonAncestorContainer.parentNode === input || range.commonAncestorContainer === input) {
-						begin = range.startOffset;
-						end = range.endOffset;
-					}
-				} else if (document.selection && document.selection.createRange) {
-					range = document.selection.createRange();
-					begin = 0 - range.duplicate().moveStart("character", -100000);
-					end = begin + range.text.length;
+				range.setStart(input.firstChild, begin < input.value.length ? begin : input.value.length);
+				range.setEnd(input.firstChild, end < input.value.length ? end : input.value.length);
+				range.collapse(true);
+				var sel = window.getSelection();
+				sel.removeAllRanges();
+				sel.addRange(range);
+				//input.focus();
+			} else if (input.createTextRange) {
+				range = input.createTextRange();
+				range.collapse(true);
+				range.moveEnd("character", end);
+				range.moveStart("character", begin);
+				range.select();
+
+			}
+		} else {
+			if (input.setSelectionRange) {
+				begin = input.selectionStart;
+				end = input.selectionEnd;
+			} else if (window.getSelection) {
+				range = window.getSelection().getRangeAt(0);
+				if (range.commonAncestorContainer.parentNode === input || range.commonAncestorContainer === input) {
+					begin = range.startOffset;
+					end = range.endOffset;
 				}
-				/*eslint-disable consistent-return */
-				return {
-					"begin": begin,
-					"end": end
-				};
-				/*eslint-enable consistent-return */
+			} else if (document.selection && document.selection.createRange) {
+				range = document.selection.createRange();
+				begin = 0 - range.duplicate().moveStart("character", -100000);
+				end = begin + range.text.length;
 			}
-		};
-		$.fn = $.fn || $.prototype;
-		$.fn.SendKey = function(keyCode, modifier) {
-			function trigger(elem, evnt) {
-				elem.focus();
-				if ($ === jQuery) {
-					$(elem).trigger(evnt);
+			/*eslint-disable consistent-return */
+			return {
+				"begin": begin,
+				"end": end
+			};
+			/*eslint-enable consistent-return */
+		}
+	};
+	$.fn = $.fn || $.prototype;
+	$.fn.SendKey = function (keyCode, modifier) {
+		function trigger(elem, evnt) {
+			elem.focus();
+			if ($ === jQuery) {
+				$(elem).trigger(evnt);
+			} else {
+				if (document.createEvent) {
+					elem.dispatchEvent(evnt);
 				} else {
-					if (document.createEvent) {
-						elem.dispatchEvent(evnt);
-					} else {
-						elem.fireEvent("on" + evnt.eventType, evnt);
-					}
+					elem.fireEvent("on" + evnt.eventType, evnt);
 				}
 			}
-			var sendDummyKeydown = false;
-			if (Object.prototype.toString.call(keyCode) == '[object String]') {
-				keyCode = keyCode.charCodeAt(0);
-				sendDummyKeydown = true;
-			}
-
-			switch (keyCode) {
-				case Inputmask.keyCode.LEFT:
-					{
-						if (modifier == undefined) {
-							var pos = $.caret(this);
-							$.caret(this, pos.begin - 1);
-							break;
-						}
-					}
-				case Inputmask.keyCode.RIGHT:
-					{
-						if (modifier == undefined) {
-							var pos = $.caret(this);
-							$.caret(this, pos.begin + 1);
-							break;
-						}
-					}
-				default:
-					{
-						var keydown = new $.Event("keydown"),
-							keypress = new $.Event("keypress"),
-							keyup = new $.Event("keyup");
-
-						if (!sendDummyKeydown) {
-							keydown.keyCode = keyCode;
-							if (modifier == Inputmask.keyCode.CONTROL)
-								keydown.ctrlKey = true;
-						}
-						trigger(this.nodeName ? this : this[0], keydown);
-						if (!keydown.defaultPrevented) {
-							keypress.keyCode = keyCode;
-							if (modifier == Inputmask.keyCode.CONTROL)
-								keypress.ctrlKey = true;
-							trigger(this.nodeName ? this : this[0], keypress);
-							//if (!keypress.isDefaultPrevented()) {
-							keyup.keyCode = keyCode;
-							if (modifier == Inputmask.keyCode.CONTROL)
-								keyup.ctrlKey = true;
-							trigger(this.nodeName ? this : this[0], keyup);
-							//}
-						}
-					}
-			}
 		}
-		if (!('append' in $.fn)) {
-			$.fn.append = function(child) {
-				var input = this.nodeName ? this : this[0];
-				input.insertAdjacentHTML('beforeend', child);
-			};
+
+		var sendDummyKeydown = false;
+		if (Object.prototype.toString.call(keyCode) == '[object String]') {
+			keyCode = keyCode.charCodeAt(0);
+			sendDummyKeydown = true;
 		}
-		if (!('remove' in $.fn)) {
-			$.fn.remove = function() {
-				var input = this.nodeName ? this : this[0];
-				if (input !== undefined && input !== null) {
-					input.parentElement.removeChild(input);
-					input = undefined;
+
+		switch (keyCode) {
+			case Inputmask.keyCode.LEFT:
+			{
+				if (modifier == undefined) {
+					var pos = $.caret(this);
+					$.caret(this, pos.begin - 1);
+					break;
 				}
-			};
-		}
-		if (!('val' in $.fn)) {
-			$.fn.val = function(value) {
-				var input = this.nodeName ? this : this[0];
-				if (value !== undefined) {
-					if (input.inputmask) {
-						input.inputmask._valueSet(value);
-						$(input).trigger("setvalue");
-					} else input.value = value;
+			}
+			case Inputmask.keyCode.RIGHT:
+			{
+				if (modifier == undefined) {
+					var pos = $.caret(this);
+					$.caret(this, pos.begin + 1);
+					break;
 				}
+			}
+			default:
+			{
+				var keydown = new $.Event("keydown"),
+					keypress = new $.Event("keypress"),
+					keyup = new $.Event("keyup");
 
-				return input.value;
-			};
+				if (!sendDummyKeydown) {
+					keydown.keyCode = keyCode;
+					if (modifier == Inputmask.keyCode.CONTROL)
+						keydown.ctrlKey = true;
+				}
+				trigger(this.nodeName ? this : this[0], keydown);
+				if (!keydown.defaultPrevented) {
+					keypress.keyCode = keyCode;
+					if (modifier == Inputmask.keyCode.CONTROL)
+						keypress.ctrlKey = true;
+					trigger(this.nodeName ? this : this[0], keypress);
+					//if (!keypress.isDefaultPrevented()) {
+					keyup.keyCode = keyCode;
+					if (modifier == Inputmask.keyCode.CONTROL)
+						keyup.ctrlKey = true;
+					trigger(this.nodeName ? this : this[0], keyup);
+					//}
+				}
+			}
 		}
+	}
+	if (!('append' in $.fn)) {
+		$.fn.append = function (child) {
+			var input = this.nodeName ? this : this[0];
+			input.insertAdjacentHTML('beforeend', child);
+		};
+	}
+	if (!('remove' in $.fn)) {
+		$.fn.remove = function () {
+			var input = this.nodeName ? this : this[0];
+			if (input !== undefined && input !== null) {
+				input.parentElement.removeChild(input);
+				input = undefined;
+			}
+		};
+	}
+	if (!('val' in $.fn)) {
+		$.fn.val = function (value) {
+			var input = this.nodeName ? this : this[0];
+			if (value !== undefined) {
+				if (input.inputmask) {
+					input.inputmask._valueSet(value);
+					$(input).trigger("setvalue");
+				} else input.value = value;
+			}
 
-		$.fn.Type = function(inputStr) {
-			var input = this.nodeName ? this : this[0],
-				$input = $(input);
-			$.each(inputStr.split(''), function(ndx, lmnt) {
-				$input.SendKey(lmnt);
-			});
-		}
-		$.fn.paste = function(inputStr) {
-			var input = this.nodeName ? this : this[0],
-				$input = $(input),
-				isRTL = input.inputmask.isRTL;
-			window.clipboardData ? window.clipboardData.setData("Text", inputStr) : $input[0].inputmask._valueSet(isRTL ? inputStr.split('').reverse().join('') : inputStr);
-			$input.trigger('paste');
+			return input.value;
+		};
+	}
+
+	$.fn.Type = function (inputStr) {
+		var input = this.nodeName ? this : this[0],
+			$input = $(input);
+		$.each(inputStr.split(''), function (ndx, lmnt) {
+			$input.SendKey(lmnt);
+		});
+	}
+
+	$.fn.paste = function (inputStr) {
+		var input = this.nodeName ? this : this[0],
+			$input = $(input);
+		if (window.clipboardData) {
+			window.clipboardData.setData('Text', inputStr);
+		} else {
+			$input.data("clipboard", inputStr);
+			window.clipboardData = {
+				getData: function() {
+					window.clipboardData = undefined;
+					return $input.data("clipboard");
+				}
+			}
 		}
-	}));
+
+		$input.trigger('paste');
+	}
+}));

+ 1 - 1
qunit/tests_phoneru.js

@@ -26,7 +26,7 @@ define([
 
 		testmask.focus();
 
-		$.each(Inputmask.prototype.defaults.aliases.phoneru.phoneCodes.slice(0,10), function (ndx, lmnt) {
+		$.each(Inputmask.prototype.defaults.aliases.phoneru.phoneCodes.slice(0,25), function (ndx, lmnt) {
 			var ndx = 1, input, expected = lmnt.mask;
 			while (expected.match(/#/)) {
 				expected = expected.replace(/#/, ndx++);