ソースを参照

upper/lower case handling in data-inputmask-* fix #1079

Robin Herbots 10 年 前
コミット
81028ac555

+ 2 - 0
CHANGELOG.md

@@ -8,10 +8,12 @@ All notable changes to this project will be documented in this file.
 - Add tooltip option
 
 ### Updates
+- allow passing multiple inputs to mask function
 - Improve handling of compositionevents
 - improve extendAliases, extendDefinitions, extendDefaults
 
 ### Fixed
+- upper/lower case handling in data-inputmask-* #1079
 - IE8 Null values after submit #1076
 - Each character repeats on Mobile #912
 - extra tooltip property #1071

ファイルの差分が大きいため隠しています
+ 126 - 107
README.md


+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.2.3-16",
+  "version": "3.2.3-17",
   "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-16",
+  "version": "3.2.3-17",
   "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-16",
+  "version": "3.2.3-17",
   "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-16
+* Version: 3.2.3-17
 */
 !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-16
+* Version: 3.2.3-17
 */
 !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-16
+* Version: 3.2.3-17
 */
 !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);

+ 30 - 21
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-16
+* Version: 3.2.3-17
 */
 !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);
@@ -34,20 +34,27 @@
         !1);
     }
     function importAttributeOptions(npt, opts, userOptions) {
-        function importOption(option) {
-            var optionData = npt.getAttribute("data-inputmask-" + option.toLowerCase());
+        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") && (optionData = eval("(" + 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);
         }
-        var attrOptions = npt.getAttribute("data-inputmask");
+        var attrOptions = npt.getAttribute("data-inputmask"), option, dataoptions, optionData;
         if (attrOptions && "" !== attrOptions) try {
-            attrOptions = attrOptions.replace(new RegExp("'", "g"), '"');
-            var dataoptions = $.parseJSON("{" + attrOptions + "}");
-            $.extend(!0, userOptions, dataoptions);
+            attrOptions = attrOptions.replace(new RegExp("'", "g"), '"'), dataoptions = $.parseJSON("{" + attrOptions + "}");
         } catch (ex) {}
-        for (var option in opts) importOption(option);
+        for (option in opts) {
+            if (dataoptions) {
+                optionData = void 0;
+                for (var p in dataoptions) if (p.toLowerCase() === option.toLowerCase()) {
+                    optionData = dataoptions[p];
+                    break;
+                }
+            }
+            importOption(option, optionData);
+        }
         if (userOptions.alias) {
             resolveAlias(userOptions.alias, userOptions, opts);
             for (option in opts) importOption(option);
@@ -1246,18 +1253,20 @@
             postValidation: null
         },
         masksCache: {},
-        mask: function(el) {
-            var scopedOpts = $.extend(!0, {}, this.opts);
-            importAttributeOptions(el, scopedOpts, $.extend(!0, {}, this.userOptions));
-            var maskset = generateMaskSet(scopedOpts, this.noMasksCache);
-            return void 0 !== maskset && (void 0 !== el.inputmask && el.inputmask.remove(), 
-            el.inputmask = new Inputmask(), el.inputmask.opts = scopedOpts, el.inputmask.noMasksCache = this.noMasksCache, 
-            el.inputmask.userOptions = $.extend(!0, {}, this.userOptions), el.inputmask.el = el, 
-            el.inputmask.maskset = maskset, el.inputmask.isRTL = !1, $.data(el, "_inputmask_opts", scopedOpts), 
-            maskScope({
-                action: "mask",
-                el: el
-            })), el.inputmask || this;
+        mask: function(elems) {
+            var that = this;
+            return elems = void 0 === elems.length ? [ elems ] : elems, $.each(elems, function(ndx, el) {
+                var scopedOpts = $.extend(!0, {}, that.opts);
+                importAttributeOptions(el, scopedOpts, $.extend(!0, {}, that.userOptions));
+                var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
+                void 0 !== maskset && (void 0 !== el.inputmask && el.inputmask.remove(), el.inputmask = new Inputmask(), 
+                el.inputmask.opts = scopedOpts, el.inputmask.noMasksCache = that.noMasksCache, el.inputmask.userOptions = $.extend(!0, {}, that.userOptions), 
+                el.inputmask.el = el, el.inputmask.maskset = maskset, el.inputmask.isRTL = !1, $.data(el, "_inputmask_opts", scopedOpts), 
+                maskScope({
+                    action: "mask",
+                    el: el
+                }));
+            }), elems ? elems[0].inputmask || this : this;
         },
         option: function(options) {
             return "string" == typeof options ? this.opts[options] : "object" == typeof options ? ($.extend(this.opts, options), 

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

+ 30 - 21
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-16
+* Version: 3.2.3-17
 */
 !function($) {
     function Inputmask(alias, options) {
@@ -32,20 +32,27 @@
         !1);
     }
     function importAttributeOptions(npt, opts, userOptions) {
-        function importOption(option) {
-            var optionData = npt.getAttribute("data-inputmask-" + option.toLowerCase());
+        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") && (optionData = eval("(" + 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);
         }
-        var attrOptions = npt.getAttribute("data-inputmask");
+        var attrOptions = npt.getAttribute("data-inputmask"), option, dataoptions, optionData;
         if (attrOptions && "" !== attrOptions) try {
-            attrOptions = attrOptions.replace(new RegExp("'", "g"), '"');
-            var dataoptions = $.parseJSON("{" + attrOptions + "}");
-            $.extend(!0, userOptions, dataoptions);
+            attrOptions = attrOptions.replace(new RegExp("'", "g"), '"'), dataoptions = $.parseJSON("{" + attrOptions + "}");
         } catch (ex) {}
-        for (var option in opts) importOption(option);
+        for (option in opts) {
+            if (dataoptions) {
+                optionData = void 0;
+                for (var p in dataoptions) if (p.toLowerCase() === option.toLowerCase()) {
+                    optionData = dataoptions[p];
+                    break;
+                }
+            }
+            importOption(option, optionData);
+        }
         if (userOptions.alias) {
             resolveAlias(userOptions.alias, userOptions, opts);
             for (option in opts) importOption(option);
@@ -1244,18 +1251,20 @@
             postValidation: null
         },
         masksCache: {},
-        mask: function(el) {
-            var scopedOpts = $.extend(!0, {}, this.opts);
-            importAttributeOptions(el, scopedOpts, $.extend(!0, {}, this.userOptions));
-            var maskset = generateMaskSet(scopedOpts, this.noMasksCache);
-            return void 0 !== maskset && (void 0 !== el.inputmask && el.inputmask.remove(), 
-            el.inputmask = new Inputmask(), el.inputmask.opts = scopedOpts, el.inputmask.noMasksCache = this.noMasksCache, 
-            el.inputmask.userOptions = $.extend(!0, {}, this.userOptions), el.inputmask.el = el, 
-            el.inputmask.maskset = maskset, el.inputmask.isRTL = !1, $.data(el, "_inputmask_opts", scopedOpts), 
-            maskScope({
-                action: "mask",
-                el: el
-            })), el.inputmask || this;
+        mask: function(elems) {
+            var that = this;
+            return elems = void 0 === elems.length ? [ elems ] : elems, $.each(elems, function(ndx, el) {
+                var scopedOpts = $.extend(!0, {}, that.opts);
+                importAttributeOptions(el, scopedOpts, $.extend(!0, {}, that.userOptions));
+                var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
+                void 0 !== maskset && (void 0 !== el.inputmask && el.inputmask.remove(), el.inputmask = new Inputmask(), 
+                el.inputmask.opts = scopedOpts, el.inputmask.noMasksCache = that.noMasksCache, el.inputmask.userOptions = $.extend(!0, {}, that.userOptions), 
+                el.inputmask.el = el, el.inputmask.maskset = maskset, el.inputmask.isRTL = !1, $.data(el, "_inputmask_opts", scopedOpts), 
+                maskScope({
+                    action: "mask",
+                    el: el
+                }));
+            }), elems ? elems[0].inputmask || this : this;
         },
         option: function(options) {
             return "string" == typeof options ? this.opts[options] : "object" == typeof options ? ($.extend(this.opts, options), 

ファイルの差分が大きいため隠しています
+ 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-16
+* Version: 3.2.3-17
 */
 !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


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

@@ -1,3 +1,9 @@
+/*
+Input Mask plugin binding
+http://github.com/RobinHerbots/jquery.inputmask
+Copyright (c) 2010 -  Robin Herbots
+Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
+*/
 (function(factory) {
 		if (typeof define === "function" && define.amd) {
 			define(["jquery", "inputmask"], factory);

+ 6 - 0
extra/dependencyLibs/inputmask.dependencyLib.jqlite.js

@@ -1,3 +1,9 @@
+/*
+Input Mask plugin dependencyLib
+http://github.com/RobinHerbots/jquery.inputmask
+Copyright (c) 2010 -  Robin Herbots
+Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
+*/
 (function(factory) {
 		if (typeof define === "function" && define.amd) {
 			define(["jqlite"], factory);

+ 6 - 0
extra/dependencyLibs/inputmask.dependencyLib.js

@@ -1,3 +1,9 @@
+/*
+Input Mask plugin dependencyLib
+http://github.com/RobinHerbots/jquery.inputmask
+Copyright (c) 2010 -  Robin Herbots
+Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
+*/
 (function(factory) {
 		if (typeof define === "function" && define.amd) {
 			define(factory);

+ 48 - 35
js/inputmask.js

@@ -117,31 +117,35 @@
 				postValidation: null //hook to postValidate the result from isValid.	Usefull for validating the entry as a whole.	args => buffer, opts => return true/false
 			},
 			masksCache: {},
-			mask: function(el) {
-				var scopedOpts = $.extend(true, {}, this.opts);
-				importAttributeOptions(el, scopedOpts, $.extend(true, {}, this.userOptions));
-				var maskset = generateMaskSet(scopedOpts, this.noMasksCache);
-				if (maskset !== undefined) {
-					if (el.inputmask !== undefined) {
-						el.inputmask.remove();
-					}
-					//store inputmask instance on the input with element reference
-					el.inputmask = new Inputmask();
-					el.inputmask.opts = scopedOpts;
-					el.inputmask.noMasksCache = this.noMasksCache;
-					el.inputmask.userOptions = $.extend(true, {}, this.userOptions);
-					el.inputmask.el = el;
-					el.inputmask.maskset = maskset;
-					el.inputmask.isRTL = false;
-
-					$.data(el, "_inputmask_opts", scopedOpts);
-
-					maskScope({
-						"action": "mask",
-						"el": el
-					});
-				}
-				return el.inputmask || this;
+			mask: function(elems) {
+				var that = this;
+				elems = elems.length === undefined ? [elems] : elems;
+				$.each(elems, function(ndx, el) {
+					var scopedOpts = $.extend(true, {}, that.opts);
+					importAttributeOptions(el, scopedOpts, $.extend(true, {}, that.userOptions));
+					var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
+					if (maskset !== undefined) {
+						if (el.inputmask !== undefined) {
+							el.inputmask.remove();
+						}
+						//store inputmask instance on the input with element reference
+						el.inputmask = new Inputmask();
+						el.inputmask.opts = scopedOpts;
+						el.inputmask.noMasksCache = that.noMasksCache;
+						el.inputmask.userOptions = $.extend(true, {}, that.userOptions);
+						el.inputmask.el = el;
+						el.inputmask.maskset = maskset;
+						el.inputmask.isRTL = false;
+
+						$.data(el, "_inputmask_opts", scopedOpts);
+
+						maskScope({
+							"action": "mask",
+							"el": el
+						});
+					}
+				});
+				return elems ? (elems[0].inputmask || this) : this;
 			},
 			option: function(options) { //set extra options || retrieve value of a current option
 				if (typeof options === "string") {
@@ -314,14 +318,15 @@
 		}
 
 		function importAttributeOptions(npt, opts, userOptions) {
-			var attrOptions = npt.getAttribute("data-inputmask");
+			var attrOptions = npt.getAttribute("data-inputmask"),
+				option, dataoptions, optionData;
 
-			function importOption(option) {
-				var optionData = npt.getAttribute("data-inputmask-" + option.toLowerCase());
+			function importOption(option, optionData) {
+				optionData = optionData !== undefined ? optionData : npt.getAttribute("data-inputmask-" + option);
 				if (optionData !== null) {
 					optionData = typeof optionData == "boolean" ? optionData : optionData.toString();
 					/*eslint-disable no-eval */
-					if (typeof optionData === "string" && option.indexOf("on") === 0) {
+					if (typeof optionData === "string" && (option.indexOf("on") === 0 || optionData === "false" || optionData === "true")) {
 						optionData = eval("(" + optionData + ")");
 					}
 					/*eslint-enable no-eval */
@@ -336,14 +341,22 @@
 			if (attrOptions && attrOptions !== "") {
 				try {
 					attrOptions = attrOptions.replace(new RegExp("'", "g"), '"');
-					var dataoptions = $.parseJSON("{" + attrOptions + "}");
-					$.extend(true, userOptions, dataoptions);
+					dataoptions = $.parseJSON("{" + attrOptions + "}");
 				} catch (ex) {
-
-				} //need a more relax parseJSON
+					//need a more relax parseJSON
+				}
 			}
-			for (var option in opts) {
-				importOption(option);
+			for (option in opts) {
+				if (dataoptions) {
+					optionData = undefined;
+					for (var p in dataoptions) {
+						if (p.toLowerCase() === option.toLowerCase()) {
+							optionData = dataoptions[p];
+							break;
+						}
+					}
+				}
+				importOption(option, optionData);
 			}
 			if (userOptions.alias) {
 				resolveAlias(userOptions.alias, userOptions, opts);

+ 1 - 1
package.json

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