浏览代码

add inputmask.binding + fix unmask for email

Robin Herbots 10 年之前
父节点
当前提交
af65eb567b

+ 1 - 0
CHANGELOG.md

@@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
 ## [UNRELEASED]
 
 ### Added
+- inputmask.binding => automated inputmask binding for html attributes
 - Add tooltip option
 
 ### Updates

+ 42 - 23
README.md

@@ -32,35 +32,14 @@ Demo page see [http://robinherbots.github.io/jquery.inputmask](http://robinherbo
 ## Usage:
 Include the js-files which you can find in the dist-folder.
 
-The minimum to include is inputmask.js && jquery.inputmask.js
+via Inputmask class
 
 ```html
 <script src="jquery.js" type="text/javascript"></script>
 <script src="inputmask.js" type="text/javascript"></script>
-<script src="jquery.inputmask.js" type="text/javascript"></script>
+<script src="inputmask.???.Extensions.js" type="text/javascript"></script>
 ```
 
-If you use a module loader like requireJS, use the js-files in dist/inputmask
-
-```javascript
-paths: {
-  ...
-  "inputmask.dependencyLib": "../dist/inputmask/inputmask.dependencyLib.jquery",
-  "inputmask": "../dist/inputmask/inputmask",
-  ...
-}
-```
-
-As dependencyLib you can choose between the supported libraries.
-- inputmask.dependencyLib (vanilla)
-- inputmask.dependencyLib.jquery
-- inputmask.dependencyLib.jqlite (WIP)
-- .... (others are welcome)
-
-Define your masks:
-
-via Inputmask class
-
 ```javascript
    var selector = document.getElementById("selector");
 
@@ -74,6 +53,19 @@ via Inputmask class
 
 via jquery plugin
 
+```html
+<script src="jquery.js" type="text/javascript"></script>
+<script src="inputmask.js" type="text/javascript"></script>
+<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
@@ -111,6 +103,33 @@ $(document).ready(function(){
 });
 ```
 
+If you like to automatically bind the inputmask to the inputs marked with the data-inputmask- ... attributes you may also want to include the inputmask.binding.js
+
+```html
+...
+<script src="inputmask.binding.js" type="text/javascript"></script>
+...
+```
+
+If you use a module loader like requireJS
+
+Add in your config.js
+
+```javascript
+paths: {
+  ...
+  "inputmask.dependencyLib": "../dist/inputmask/inputmask.dependencyLib.jquery",
+  "inputmask": "../dist/inputmask/inputmask",
+  ...
+}
+```
+
+As dependencyLib you can choose between the supported libraries.
+- inputmask.dependencyLib (vanilla)
+- inputmask.dependencyLib.jquery
+- inputmask.dependencyLib.jqlite (WIP)
+- .... (others are welcome)
+
 ### Allowed HTML-elements
 - input type="text"
 - input type="tel"

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.2.3-13",
+  "version": "3.2.3-15",
   "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-13",
+  "version": "3.2.3-15",
   "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-13",
+  "version": "3.2.3-15",
   "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-13
+* Version: 3.2.3-15
 */
 !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-13
+* Version: 3.2.3-15
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery")) : factory(jQuery);

+ 7 - 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-13
+* Version: 3.2.3-15
 */
 !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);
@@ -92,6 +92,9 @@
                     },
                     cardinality: 1
                 }
+            },
+            onUnMask: function(maskedValue, unmaskedValue, opts) {
+                return maskedValue;
             }
         },
         email: {
@@ -106,6 +109,9 @@
                     cardinality: 1,
                     casing: "lower"
                 }
+            },
+            onUnMask: function(maskedValue, unmaskedValue, opts) {
+                return maskedValue;
             }
         },
         mac: {

+ 2 - 4
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-13
+* Version: 3.2.3-15
 */
 !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);
@@ -767,7 +767,6 @@
         }
         function wrapEventRuler(eventHandler) {
             return function(e) {
-                console.log("triggered " + e.type);
                 var inComposition = !1, keydownPressed = !1;
                 if (void 0 === this.inputmask) {
                     var imOpts = $.data(this, "_inputmask_opts");
@@ -992,7 +991,6 @@
         }
         function compositionUpdateEvent(e) {
             var input = this, ev = e.originalEvent || e;
-            caret(input);
             0 === ev.data.indexOf(compositionData) && (resetMaskSet(), getMaskSet().p = seekNext(-1), 
             skipInputEvent = !0);
             for (var newData = ev.data, i = 0; i < newData.length; i++) {
@@ -1003,7 +1001,7 @@
             setTimeout(function() {
                 var forwardPosition = getMaskSet().p;
                 writeBuffer(input, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
-            }, 0), compositionData = evt.data;
+            }, 0), compositionData = ev.data;
         }
         function compositionEndEvent(e) {}
         function setValueEvent(e) {

+ 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-13
+* Version: 3.2.3-15
 */
 !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-13
+* Version: 3.2.3-15
 */
 !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-13
+* Version: 3.2.3-15
 */
 !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-13
+* Version: 3.2.3-15
 */
 !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);

+ 8 - 4
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-13
+* Version: 3.2.3-15
 */
 !function($) {
     function Inputmask(alias, options) {
@@ -765,7 +765,6 @@
         }
         function wrapEventRuler(eventHandler) {
             return function(e) {
-                console.log("triggered " + e.type);
                 var inComposition = !1, keydownPressed = !1;
                 if (void 0 === this.inputmask) {
                     var imOpts = $.data(this, "_inputmask_opts");
@@ -990,7 +989,6 @@
         }
         function compositionUpdateEvent(e) {
             var input = this, ev = e.originalEvent || e;
-            caret(input);
             0 === ev.data.indexOf(compositionData) && (resetMaskSet(), getMaskSet().p = seekNext(-1), 
             skipInputEvent = !0);
             for (var newData = ev.data, i = 0; i < newData.length; i++) {
@@ -1001,7 +999,7 @@
             setTimeout(function() {
                 var forwardPosition = getMaskSet().p;
                 writeBuffer(input, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
-            }, 0), compositionData = evt.data;
+            }, 0), compositionData = ev.data;
         }
         function compositionEndEvent(e) {}
         function setValueEvent(e) {
@@ -2004,6 +2002,9 @@
                     },
                     cardinality: 1
                 }
+            },
+            onUnMask: function(maskedValue, unmaskedValue, opts) {
+                return maskedValue;
             }
         },
         email: {
@@ -2018,6 +2019,9 @@
                     cardinality: 1,
                     casing: "lower"
                 }
+            },
+            onUnMask: function(maskedValue, unmaskedValue, opts) {
+                return maskedValue;
             }
         },
         mac: {

文件差异内容过多而无法显示
+ 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-13
+* Version: 3.2.3-15
 */
 !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});

文件差异内容过多而无法显示
+ 2 - 2
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


+ 26 - 0
extra/bindings/inputmask.binding.js

@@ -0,0 +1,26 @@
+(function(factory) {
+		if (typeof define === "function" && define.amd) {
+			define(["jquery", "inputmask"], factory);
+		} else if (typeof exports === "object") {
+			module.exports = factory(require("jquery"), require("./inputmask"));
+		} else {
+			factory(jQuery, window.Inputmask);
+		}
+	}
+	(function($, Inputmask) {
+		$(document).ajaxComplete(function(event, xmlHttpRequest, ajaxOptions) {
+			if ($.inArray("html", ajaxOptions.dataTypes) !== -1) {
+				$(":input").each(function(ndx, lmnt) {
+					if (lmnt.inputmask === undefined) {
+						Inputmask().mask(lmnt);
+					}
+				});
+			}
+		}).ready(function() {
+			$(":input").each(function(ndx, lmnt) {
+				if (lmnt.inputmask === undefined) {
+					Inputmask().mask(lmnt);
+				}
+			});
+		});
+	}));

+ 1 - 1
extra/phone-codes/phone-nl.js

@@ -102,7 +102,7 @@
     { "mask": "+31-497-###-###", "cc": "NL", "cd": "Netherlands", "city": "Eersel" },
     { "mask": "+31-499-###-###", "cc": "NL", "cd": "Netherlands", "city": "Best" },
     { "mask": "+31-50-###-####", "cc": "NL", "cd": "Netherlands", "city": "Groningen" },
-    { "mask": "+31-511-###-###", "cc": "NL", "cd": "Netherlands", "city": "Feanwâlden" },
+    { "mask": "+31-511-###-###", "cc": "NL", "cd": "Netherlands", "city": "Feanw�lden" },
     { "mask": "+31-512-###-###", "cc": "NL", "cd": "Netherlands", "city": "Drachten" },
     { "mask": "+31-513-###-###", "cc": "NL", "cd": "Netherlands", "city": "Heerenveen" },
     { "mask": "+31-514-###-###", "cc": "NL", "cd": "Netherlands", "city": "Balk" },

+ 123 - 117
js/inputmask.extensions.js

@@ -17,130 +17,136 @@ Optional extensions on the jquery.inputmask base
 		}
 	}
 	(function($, Inputmask) {
-	//extra definitions
-	Inputmask.extendDefinitions({
-		"A": {
-			validator: "[A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
-			cardinality: 1,
-			casing: "upper" //auto uppercasing
-		},
-		"&": { //alfanumeric uppercasing
-			validator: "[0-9A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
-			cardinality: 1,
-			casing: "upper"
-		},
-		"#": { //hexadecimal
-			validator: "[0-9A-Fa-f]",
-			cardinality: 1,
-			casing: "upper"
-		}
-	});
-	Inputmask.extendAliases({
-		"url": {
-			mask: "ir",
-			placeholder: "",
-			separator: "",
-			defaultPrefix: "http://",
-			regex: {
-				urlpre1: new RegExp("[fh]"),
-				urlpre2: new RegExp("(ft|ht)"),
-				urlpre3: new RegExp("(ftp|htt)"),
-				urlpre4: new RegExp("(ftp:|http|ftps)"),
-				urlpre5: new RegExp("(ftp:/|ftps:|http:|https)"),
-				urlpre6: new RegExp("(ftp://|ftps:/|http:/|https:)"),
-				urlpre7: new RegExp("(ftp://|ftps://|http://|https:/)"),
-				urlpre8: new RegExp("(ftp://|ftps://|http://|https://)")
+		//extra definitions
+		Inputmask.extendDefinitions({
+			"A": {
+				validator: "[A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
+				cardinality: 1,
+				casing: "upper" //auto uppercasing
 			},
-			definitions: {
-				"i": {
-					validator: function(chrs, maskset, pos, strict, opts) {
-						return true;
-					},
-					cardinality: 8,
-					prevalidator: (function() {
-						var result = [],
-							prefixLimit = 8;
-						for (var i = 0; i < prefixLimit; i++) {
-							result[i] = (function() {
-								var j = i;
-								return {
-									validator: function(chrs, maskset, pos, strict, opts) {
-										if (opts.regex["urlpre" + (j + 1)]) {
-											var tmp = chrs,
-												k;
-											if (((j + 1) - chrs.length) > 0) {
-												tmp = maskset.buffer.join('').substring(0, ((j + 1) - chrs.length)) + "" + tmp;
-											}
-											var isValid = opts.regex["urlpre" + (j + 1)].test(tmp);
-											if (!strict && !isValid) {
-												pos = pos - j;
-												for (k = 0; k < opts.defaultPrefix.length; k++) {
-													maskset.buffer[pos] = opts.defaultPrefix[k];
-													pos++;
+			"&": { //alfanumeric uppercasing
+				validator: "[0-9A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
+				cardinality: 1,
+				casing: "upper"
+			},
+			"#": { //hexadecimal
+				validator: "[0-9A-Fa-f]",
+				cardinality: 1,
+				casing: "upper"
+			}
+		});
+		Inputmask.extendAliases({
+			"url": {
+				mask: "ir",
+				placeholder: "",
+				separator: "",
+				defaultPrefix: "http://",
+				regex: {
+					urlpre1: new RegExp("[fh]"),
+					urlpre2: new RegExp("(ft|ht)"),
+					urlpre3: new RegExp("(ftp|htt)"),
+					urlpre4: new RegExp("(ftp:|http|ftps)"),
+					urlpre5: new RegExp("(ftp:/|ftps:|http:|https)"),
+					urlpre6: new RegExp("(ftp://|ftps:/|http:/|https:)"),
+					urlpre7: new RegExp("(ftp://|ftps://|http://|https:/)"),
+					urlpre8: new RegExp("(ftp://|ftps://|http://|https://)")
+				},
+				definitions: {
+					"i": {
+						validator: function(chrs, maskset, pos, strict, opts) {
+							return true;
+						},
+						cardinality: 8,
+						prevalidator: (function() {
+							var result = [],
+								prefixLimit = 8;
+							for (var i = 0; i < prefixLimit; i++) {
+								result[i] = (function() {
+									var j = i;
+									return {
+										validator: function(chrs, maskset, pos, strict, opts) {
+											if (opts.regex["urlpre" + (j + 1)]) {
+												var tmp = chrs,
+													k;
+												if (((j + 1) - chrs.length) > 0) {
+													tmp = maskset.buffer.join('').substring(0, ((j + 1) - chrs.length)) + "" + tmp;
 												}
-												for (k = 0; k < tmp.length - 1; k++) {
-													maskset.buffer[pos] = tmp[k];
-													pos++;
+												var isValid = opts.regex["urlpre" + (j + 1)].test(tmp);
+												if (!strict && !isValid) {
+													pos = pos - j;
+													for (k = 0; k < opts.defaultPrefix.length; k++) {
+														maskset.buffer[pos] = opts.defaultPrefix[k];
+														pos++;
+													}
+													for (k = 0; k < tmp.length - 1; k++) {
+														maskset.buffer[pos] = tmp[k];
+														pos++;
+													}
+													return {
+														"pos": pos
+													};
 												}
-												return {
-													"pos": pos
-												};
+												return isValid;
+											} else {
+												return false;
 											}
-											return isValid;
-										} else {
-											return false;
-										}
-									},
-									cardinality: j
-								};
-							})();
-						}
-						return result;
-					})()
+										},
+										cardinality: j
+									};
+								})();
+							}
+							return result;
+						})()
+					},
+					"r": {
+						validator: ".",
+						cardinality: 50
+					}
 				},
-				"r": {
-					validator: ".",
-					cardinality: 50
-				}
+				insertMode: false,
+				autoUnmask: false
 			},
-			insertMode: false,
-			autoUnmask: false
-		},
-		"ip": { //ip-address mask
-			mask: "i[i[i]].i[i[i]].i[i[i]].i[i[i]]",
-			definitions: {
-				"i": {
-					validator: function(chrs, maskset, pos, strict, opts) {
-						if (pos - 1 > -1 && maskset.buffer[pos - 1] !== ".") {
-							chrs = maskset.buffer[pos - 1] + chrs;
-							if (pos - 2 > -1 && maskset.buffer[pos - 2] !== ".") {
-								chrs = maskset.buffer[pos - 2] + chrs;
-							} else chrs = "0" + chrs;
-						} else chrs = "00" + chrs;
-						return new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]").test(chrs);
-					},
-					cardinality: 1
+			"ip": { //ip-address mask
+				mask: "i[i[i]].i[i[i]].i[i[i]].i[i[i]]",
+				definitions: {
+					"i": {
+						validator: function(chrs, maskset, pos, strict, opts) {
+							if (pos - 1 > -1 && maskset.buffer[pos - 1] !== ".") {
+								chrs = maskset.buffer[pos - 1] + chrs;
+								if (pos - 2 > -1 && maskset.buffer[pos - 2] !== ".") {
+									chrs = maskset.buffer[pos - 2] + chrs;
+								} else chrs = "0" + chrs;
+							} else chrs = "00" + chrs;
+							return new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]").test(chrs);
+						},
+						cardinality: 1
+					}
+				},
+				onUnMask: function(maskedValue, unmaskedValue, opts) {
+					return maskedValue;
 				}
-			}
-		},
-		"email": {
-			mask: "*{1,64}[.*{1,64}][.*{1,64}][.*{1,64}]@*{1,64}[.*{2,64}][.*{2,6}][.*{1,2}]",
-			greedy: false,
-			onBeforePaste: function(pastedValue, opts) {
-				pastedValue = pastedValue.toLowerCase();
-				return pastedValue.replace("mailto:", "");
 			},
-			definitions: {
-				"*": {
-					validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~\-]",
-					cardinality: 1,
-					casing: "lower"
+			"email": {
+				mask: "*{1,64}[.*{1,64}][.*{1,64}][.*{1,64}]@*{1,64}[.*{2,64}][.*{2,6}][.*{1,2}]",
+				greedy: false,
+				onBeforePaste: function(pastedValue, opts) {
+					pastedValue = pastedValue.toLowerCase();
+					return pastedValue.replace("mailto:", "");
+				},
+				definitions: {
+					"*": {
+						validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~\-]",
+						cardinality: 1,
+						casing: "lower"
+					}
+				},
+				onUnMask: function(maskedValue, unmaskedValue, opts) {
+					return maskedValue;
 				}
+			},
+			"mac": {
+				mask: "##:##:##:##:##:##"
 			}
-		},
-		"mac": {
-			mask: "##:##:##:##:##:##"
-		}
-	});
-	return Inputmask;
-}));
+		});
+		return Inputmask;
+	}));

+ 3 - 8
js/inputmask.js

@@ -718,8 +718,6 @@
 		function maskScope(actionObj, maskset, opts) {
 			var isRTL = false,
 				undoValue,
-				// compositionValidPos,
-				compositionCaretPos,
 				compositionData,
 				el, $el,
 				skipKeyPressEvent = false, //Safari 5.1.x - modal dialog fires keypress twice workaround
@@ -1799,7 +1797,7 @@
 
 			function wrapEventRuler(eventHandler) {
 				return function(e) {
-					console.log("triggered " + e.type);
+					// console.log("triggered " + e.type);
 					var inComposition = false,
 						keydownPressed = false;
 					if (this.inputmask === undefined) { //happens when cloning an object with jquery.clone
@@ -2265,16 +2263,13 @@
 
 			function compositionUpdateEvent(e) {
 				var input = this,
-					ev = e.originalEvent || e,
-					caretPos = caret(input);
+					ev = e.originalEvent || e;
 				if (ev.data.indexOf(compositionData) === 0) {
 					resetMaskSet();
 					getMaskSet().p = seekNext(-1); //needs check
 					skipInputEvent = true;
-					// caretPos = compositionCaretPos;
 				}
 				var newData = ev.data;
-				// caret(input, caretPos.begin, caretPos.end);
 				for (var i = 0; i < newData.length; i++) {
 					var keypress = $.Event("keypress");
 					keypress.which = newData.charCodeAt(i);
@@ -2286,7 +2281,7 @@
 					var forwardPosition = getMaskSet().p;
 					writeBuffer(input, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
 				}, 0);
-				compositionData = evt.data;
+				compositionData = ev.data;
 			}
 
 			function compositionEndEvent(e) {

+ 1 - 1
package.json

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