ソースを参照

CTRL-x / Cut issue fix #948

Robin Herbots 10 年 前
コミット
2bd34dbfcb

+ 1 - 0
CHANGELOG.md

@@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file.
 - improve extendAliases, extendDefinitions, extendDefaults
 
 ### Fixed
+- CTRL-x / Cut issue #948
 - Double "Change" action when pressing Enter in Firefox #1070
 - upper/lower case handling in data-inputmask-* #1079
 - IE8 Null values after submit #1076

+ 16 - 4
README.md

@@ -59,13 +59,14 @@ via jquery plugin
 <script src="inputmask.???.Extensions.js" type="text/javascript"></script>
 <script src="jquery.inputmask.js" type="text/javascript"></script>
 ```
+
 or with the bundled version
+
 ```html
 <script src="jquery.js" type="text/javascript"></script>
 <script src="jquery.inputmask.bundle.js" type="text/javascript"></script>
 ```
 
-
 ```javascript
 $(document).ready(function(){
    $(selector).inputmask("99-9999999");  //static mask
@@ -412,15 +413,21 @@ Create a mask for the input.
 ```javascript
    $(selector).inputmask('mask', { mask: "99-999-99"});
 ```
+
    or
+
 ```javascript
    Inputmask({ mask: "99-999-99"}).mask(document.querySelectorAll(selector));
 ```
+
    or
+
 ```javascript
    Inputmask("99-999-99").mask(document.querySelectorAll(selector));
 ```
+
 or
+
 ```javascript
 var im : new Inputmask("99-999-99");
 im.mask(document.querySelectorAll(selector));
@@ -432,18 +439,20 @@ Get the unmaskedvalue
 ```javascript
    $(selector).inputmask('unmaskedvalue');
 ```
+
 or
+
 ```javascript
 var input = document.getElementById(selector);
 if(input.inputmask)
   input.inputmask.unmaskedvalue()
 ```
+
 #### Value unmasking
 Unmask a given value against the mask.
 
 ```javascript
-var unformattedDate = Inputmask.unmask("23/03/1973", { alias: "dd/mm/yyyy"}); //23031973  
-
+var unformattedDate = Inputmask.unmask("23/03/1973", { alias: "dd/mm/yyyy"}); //23031973
 ```
 
 ### remove
@@ -452,7 +461,9 @@ Remove the inputmask.
 ```javascript
     $(selector).inputmask('remove');
 ```
+
 or
+
 ```javascript
 var input = document.getElementById(selector);
 if(input.inputmask)
@@ -516,12 +527,14 @@ $("#CellPhone").inputmask("option", {
 })
 $("#CellPhone").inputmask("option", "onBeforePaste")
 ```
+
 ### format
 Instead of masking an input element it is also possible to use the inputmask for formatting given values. Think of formatting values to show in jqGrid or on other elements then inputs.
 
 ```javascript
 var formattedDate = Inputmask.format("2331973", { alias: "dd/mm/yyyy"});
 ```
+
 ### isValid
 Validate a given value against the mask.
 
@@ -816,7 +829,6 @@ Show the current mask definition as a tooltip.
 ```
 
 ### tooltip
-
 Specify the tooltip to show.  By default the mask definition will be taken.
 
 ### numericInput

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.2.3-18",
+  "version": "3.2.3-20",
   "main": [
     "./dist/inputmask/inputmask.dependencyLib.jquery.js",
     "./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.2.3-18",
+  "version": "3.2.3-20",
   "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.2.3-18",
+  "version": "3.2.3-20",
   "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 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.3-18
+* Version: 3.2.3-20
 */
 !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(jQuery, window.Inputmask);

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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.3-18
+* Version: 3.2.3-20
 */
 !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 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.3-18
+* Version: 3.2.3-20
 */
 !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(jQuery, window.Inputmask);

+ 10 - 10
dist/inputmask/inputmask.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.3-18
+* Version: 3.2.3-20
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery")) : factory(window.dependencyLib || jQuery);
@@ -36,8 +36,7 @@
     function importAttributeOptions(npt, opts, userOptions) {
         function importOption(option, optionData) {
             optionData = void 0 !== optionData ? optionData : npt.getAttribute("data-inputmask-" + option), 
-            null !== optionData && (optionData = "boolean" == typeof optionData ? optionData : optionData.toString(), 
-            "string" != typeof optionData || 0 !== option.indexOf("on") && "false" !== optionData && "true" !== optionData || (optionData = eval("(" + optionData + ")")), 
+            null !== optionData && ("string" != typeof optionData || 0 !== option.indexOf("on") && "false" !== optionData && "true" !== optionData || (optionData = eval("(" + optionData + ")")), 
             "mask" === option && 0 === optionData.indexOf("[") ? (userOptions[option] = optionData.replace(/[\s[\]]/g, "").split(","), 
             userOptions[option][0] = userOptions[option][0].replace("'", ""), userOptions[option][userOptions[option].length - 1] = userOptions[option][userOptions[option].length - 1].replace("'", "")) : userOptions[option] = optionData);
         }
@@ -805,6 +804,10 @@
 
                           case "compositionend":
                             inComposition = !1, keydownPressed = !1;
+                            break;
+
+                          case "cut":
+                            skipInputEvent = !0;
                         }
                         return eventHandler.apply(this, arguments);
                     }
@@ -1063,13 +1066,10 @@
             }, 0);
         }
         function cutEvent(e) {
-            skipInputEvent = !0;
-            var input = this, $input = $(input), pos = caret(input), ev = e.originalEvent || e;
-            if (isRTL) {
-                var clipboardData = window.clipboardData || ev.clipboardData, clipData = clipboardData.getData("text").split("").reverse().join("");
-                clipboardData.setData("text", clipData);
-            }
-            handleRemove(input, Inputmask.keyCode.DELETE, pos), writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")), 
+            var input = this, $input = $(input), pos = caret(input), ev = e.originalEvent || e, clipboardData = window.clipboardData || ev.clipboardData, clipData = isRTL ? getBuffer().slice(pos.end, pos.begin) : getBuffer().slice(pos.begin, pos.end);
+            clipboardData.setData("text", isRTL ? clipData.reverse().join("") : clipData.join("")), 
+            document.execCommand && document.execCommand("copy"), handleRemove(input, Inputmask.keyCode.DELETE, pos), 
+            writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")), 
             input.inputmask._valueGet() === getBufferTemplate().join("") && $input.trigger("cleared"), 
             opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask);
         }

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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.3-18
+* Version: 3.2.3-20
 */
 !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(jQuery, window.Inputmask);

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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.3-18
+* Version: 3.2.3-20
 */
 !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);

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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.3-18
+* Version: 3.2.3-20
 */
 !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(jQuery, window.Inputmask);

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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.3-18
+* Version: 3.2.3-20
 */
 !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);

+ 10 - 10
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.3-18
+* Version: 3.2.3-20
 */
 !function($) {
     function Inputmask(alias, options) {
@@ -34,8 +34,7 @@
     function importAttributeOptions(npt, opts, userOptions) {
         function importOption(option, optionData) {
             optionData = void 0 !== optionData ? optionData : npt.getAttribute("data-inputmask-" + option), 
-            null !== optionData && (optionData = "boolean" == typeof optionData ? optionData : optionData.toString(), 
-            "string" != typeof optionData || 0 !== option.indexOf("on") && "false" !== optionData && "true" !== optionData || (optionData = eval("(" + optionData + ")")), 
+            null !== optionData && ("string" != typeof optionData || 0 !== option.indexOf("on") && "false" !== optionData && "true" !== optionData || (optionData = eval("(" + optionData + ")")), 
             "mask" === option && 0 === optionData.indexOf("[") ? (userOptions[option] = optionData.replace(/[\s[\]]/g, "").split(","), 
             userOptions[option][0] = userOptions[option][0].replace("'", ""), userOptions[option][userOptions[option].length - 1] = userOptions[option][userOptions[option].length - 1].replace("'", "")) : userOptions[option] = optionData);
         }
@@ -803,6 +802,10 @@
 
                           case "compositionend":
                             inComposition = !1, keydownPressed = !1;
+                            break;
+
+                          case "cut":
+                            skipInputEvent = !0;
                         }
                         return eventHandler.apply(this, arguments);
                     }
@@ -1061,13 +1064,10 @@
             }, 0);
         }
         function cutEvent(e) {
-            skipInputEvent = !0;
-            var input = this, $input = $(input), pos = caret(input), ev = e.originalEvent || e;
-            if (isRTL) {
-                var clipboardData = window.clipboardData || ev.clipboardData, clipData = clipboardData.getData("text").split("").reverse().join("");
-                clipboardData.setData("text", clipData);
-            }
-            handleRemove(input, Inputmask.keyCode.DELETE, pos), writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")), 
+            var input = this, $input = $(input), pos = caret(input), ev = e.originalEvent || e, clipboardData = window.clipboardData || ev.clipboardData, clipData = isRTL ? getBuffer().slice(pos.end, pos.begin) : getBuffer().slice(pos.begin, pos.end);
+            clipboardData.setData("text", isRTL ? clipData.reverse().join("") : clipData.join("")), 
+            document.execCommand && document.execCommand("copy"), handleRemove(input, Inputmask.keyCode.DELETE, pos), 
+            writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")), 
             input.inputmask._valueGet() === getBufferTemplate().join("") && $input.trigger("cleared"), 
             opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask);
         }

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


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

@@ -3,6 +3,6 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.3-18
+* Version: 3.2.3-20
 */
 !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 - 3
dist/min/inputmask/inputmask.min.js


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


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


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


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


+ 9 - 7
js/inputmask.js

@@ -324,7 +324,7 @@
 			function importOption(option, optionData) {
 				optionData = optionData !== undefined ? optionData : npt.getAttribute("data-inputmask-" + option);
 				if (optionData !== null) {
-					optionData = typeof optionData == "boolean" ? optionData : optionData.toString();
+					// optionData = typeof optionData == "boolean" ? optionData : optionData.toString();
 					/*eslint-disable no-eval */
 					if (typeof optionData === "string" && (option.indexOf("on") === 0 || optionData === "false" || optionData === "true")) {
 						optionData = eval("(" + optionData + ")");
@@ -1851,6 +1851,9 @@
 								inComposition = false;
 								keydownPressed = false;
 								break;
+							case "cut":
+								skipInputEvent = true;
+								break;
 						}
 						//console.log("executed " + e.type);
 						return eventHandler.apply(this, arguments);
@@ -2395,18 +2398,17 @@
 			}
 
 			function cutEvent(e) {
-				skipInputEvent = true; //stop inputFallback
 				var input = this,
 					$input = $(input),
 					pos = caret(input),
 					ev = e.originalEvent || e;
 
 				//correct clipboardData
-				if (isRTL) {
-					var clipboardData = window.clipboardData || ev.clipboardData,
-						clipData = clipboardData.getData("text").split("").reverse().join("");
-					clipboardData.setData("text", clipData);
-				}
+				var clipboardData = window.clipboardData || ev.clipboardData,
+					clipData = isRTL ? getBuffer().slice(pos.end, pos.begin) : getBuffer().slice(pos.begin, pos.end);
+				clipboardData.setData("text", isRTL ? clipData.reverse().join("") : clipData.join(""));
+				if(document.execCommand) document.execCommand("copy"); // copy selected content to system clipbaord
+
 				handleRemove(input, Inputmask.keyCode.DELETE, pos);
 				writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join(""));
 

+ 10 - 8
package.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.2.3-18",
+  "version": "3.2.3-20",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "main": "./dist/inputmask/jquery.inputmask.js",
   "files": [
@@ -39,7 +39,7 @@
   },
   "devDependencies": {
     "browserify": "^11.1.0",
-    "browserify-shim": "^3.8.10",
+    "browserify-shim": "^3.8.11",
     "grunt": "^0.4.5",
     "grunt-available-tasks": "^0.6.0",
     "grunt-browserify": "^4.0.1",
@@ -47,19 +47,21 @@
     "grunt-cli": "^0.1.13",
     "grunt-contrib-clean": "^0.6.0",
     "grunt-contrib-uglify": "^0.9.1",
-    "grunt-eslint": "^17.0.0",
+    "grunt-eslint": "^17.3.1",
     "grunt-karma": "^0.12.0",
-    "grunt-nuget": "^0.1.4",
+    "grunt-nuget": "^0.1.5",
     "grunt-release": "^0.13.0",
     "grunt-shell": "^1.1.2",
-    "jqlite": "^0.2.19",
-    "karma": "^0.13.10",
+    "jqlite": "^0.2.25",
+    "karma": "^0.13.14",
     "karma-chrome-launcher": "^0.2.0",
     "karma-firefox-launcher": "^0.1.6",
+    "karma-ie-launcher": "^0.2.0",
     "karma-phantomjs-launcher": "^0.2.0",
-    "karma-qunit": "^0.1.5",
+    "karma-qunit": "^0.1.7",
+    "karma-requirejs": "^0.2.2",
     "load-grunt-tasks": "^3.2.0",
-    "qunitjs": "^1.19.0",
+    "qunitjs": "^1.20.0",
     "requirejs": "^2.1.20"
   }
 }

+ 1 - 10
qunit/config.js

@@ -1,4 +1,4 @@
-requirejs.config({
+require.config({
 	baseUrl: "./",
 	paths: {
 		"jquery": "../node_modules/jquery/dist/jquery",
@@ -12,14 +12,5 @@ requirejs.config({
 		// "inputmask.dependencyLib": "../extra/dependencyLibs/inputmask.dependencyLib",
 		// "inputmask.dependencyLib": "../extra/dependencyLibs/inputmask.dependencyLib.jqlite",
 		"inputmask": "../dist/inputmask/inputmask"
-	},
-	shim: {
-		'qunit': {
-			exports: 'QUnit',
-			init: function() {
-				QUnit.config.autoload = false;
-				QUnit.config.autostart = false;
-			}
-		}
 	}
 });

+ 9 - 5
qunit/simulator.js

@@ -1,7 +1,11 @@
-define([
-	"inputmask.dependencyLib",
-	"inputmask"
-], function($, 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;
@@ -153,4 +157,4 @@ define([
 		window.clipboardData ? window.clipboardData.setData("Text", inputStr) : $input[0].inputmask._valueSet(isRTL ? inputStr.split('').reverse().join('') : inputStr);
 		$input.trigger('paste');
 	}
-});
+}));