Browse Source

add i18n to prototype + fix december input #2751

Robin Herbots 2 years ago
parent
commit
b2387d5b3e

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "5.0.9-beta.40",
+  "version": "5.0.9-beta.41",
   "main": [
 	  "./index.js",
     "./css/inputmask.css"

+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
   "name": "robinherbots/inputmask",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
-  "version": "5.0.9-beta.40",
+  "version": "5.0.9-beta.41",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/Inputmask",

+ 19 - 12
dist/inputmask.js

@@ -3,7 +3,7 @@
  * https://github.com/RobinHerbots/Inputmask
  * Copyright (c) 2010 - 2023 Robin Herbots
  * Licensed under the MIT license
- * Version: 5.0.9-beta.40
+ * Version: 5.0.9-beta.41
  */
 !function(e, t) {
     if ("object" == typeof exports && "object" == typeof module) module.exports = t(); else if ("function" == typeof define && define.amd) define([], t); else {
@@ -1045,6 +1045,7 @@
                         default: e
                     };
                 }
+                n(1313);
                 var d = i.default.dependencyLib, h = function() {
                     function e(t, n, i) {
                         !function(e, t) {
@@ -1099,11 +1100,7 @@
                     } ]) && f(t.prototype, n), i && f(t, i), Object.defineProperty(t, "prototype", {
                         writable: !1
                     }), e;
-                }(), v = (new Date).getFullYear(), m = {
-                    dayNames: [ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ],
-                    monthNames: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ],
-                    ordinalSuffix: [ "st", "nd", "rd", "th" ]
-                }, g = !1, y = {
+                }(), v = (new Date).getFullYear(), m = i.default.prototype.i18n, g = !1, y = {
                     d: [ "[1-9]|[12][0-9]|3[01]", Date.prototype.setDate, "day", Date.prototype.getDate ],
                     dd: [ "0[1-9]|[12][0-9]|3[01]", Date.prototype.setDate, "day", function() {
                         return _(Date.prototype.getDate.call(this), 2);
@@ -1122,16 +1119,16 @@
                     }, "month", function() {
                         return _(Date.prototype.getMonth.call(this) + 1, 2);
                     } ],
-                    mmm: [ m.monthNames.slice(0, 11).join("|"), function(e) {
-                        var t = m.monthNames.slice(0, 11).findIndex((function(t) {
+                    mmm: [ m.monthNames.slice(0, 12).join("|"), function(e) {
+                        var t = m.monthNames.slice(0, 12).findIndex((function(t) {
                             return e.toLowerCase() === t.toLowerCase();
                         }));
                         return Date.prototype.setMonth.call(this, t);
                     }, "month", function() {
                         return _(Date.prototype.getMonth.call(this) + 1, 2);
                     } ],
-                    mmmm: [ m.monthNames.slice(12, 23).join("|"), function(e) {
-                        var t = m.monthNames.slice(12, 23).findIndex((function(t) {
+                    mmmm: [ m.monthNames.slice(12, 24).join("|"), function(e) {
+                        var t = m.monthNames.slice(12, 24).findIndex((function(t) {
                             return e.toLowerCase() === t.toLowerCase();
                         }));
                         return Date.prototype.setMonth.call(this, t);
@@ -1290,7 +1287,7 @@
                 i.default.extendAliases({
                     datetime: {
                         mask: function(e) {
-                            return e.numericInput = !1, y.S = e.i18n.ordinalSuffix.join("|"), e.inputFormat = k[e.inputFormat] || e.inputFormat, 
+                            return e.numericInput = !1, y.S = m.ordinalSuffix.join("|"), e.inputFormat = k[e.inputFormat] || e.inputFormat, 
                             e.displayFormat = k[e.displayFormat] || e.displayFormat || e.inputFormat, e.outputFormat = k[e.outputFormat] || e.outputFormat || e.inputFormat, 
                             e.placeholder = "" !== e.placeholder ? e.placeholder : e.inputFormat.replace(/[[\]]/, ""), 
                             e.regex = O(e.inputFormat, void 0, e), e.min = M(e.min, e.inputFormat, e), e.max = M(e.max, e.inputFormat, e), 
@@ -1303,7 +1300,6 @@
                         min: null,
                         max: null,
                         skipOptionalPartCharacter: "",
-                        i18n: m,
                         preValidation: function(e, t, n, i, a, r, o, l) {
                             if (l) return !0;
                             if (isNaN(n) && e[t] !== n) {
@@ -1408,6 +1404,16 @@
                     }
                 });
             },
+            1313: function(e, t, n) {
+                var i, a = (i = n(2394)) && i.__esModule ? i : {
+                    default: i
+                };
+                a.default.dependencyLib.extend(!0, a.default.prototype.i18n, {
+                    dayNames: [ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ],
+                    monthNames: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ],
+                    ordinalSuffix: [ "st", "nd", "rd", "th" ]
+                });
+            },
             3851: function(e, t, n) {
                 var i, a = (i = n(2394)) && i.__esModule ? i : {
                     default: i
@@ -2072,6 +2078,7 @@
                     definitions: p.default,
                     aliases: {},
                     masksCache: {},
+                    i18n: {},
                     get isRTL() {
                         return this.opts.isRTL || this.opts.numericInput;
                     },

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


+ 19 - 12
dist/jquery.inputmask.js

@@ -3,7 +3,7 @@
  * https://github.com/RobinHerbots/Inputmask
  * Copyright (c) 2010 - 2023 Robin Herbots
  * Licensed under the MIT license
- * Version: 5.0.9-beta.40
+ * Version: 5.0.9-beta.41
  */
 !function(e, t) {
     if ("object" == typeof exports && "object" == typeof module) module.exports = t(require("jquery")); else if ("function" == typeof define && define.amd) define([ "jquery" ], t); else {
@@ -876,6 +876,7 @@
                         default: e
                     };
                 }
+                i(1313);
                 var d = n.default.dependencyLib, h = function() {
                     function e(t, i, n) {
                         !function(e, t) {
@@ -930,11 +931,7 @@
                     } ]) && f(t.prototype, i), n && f(t, n), Object.defineProperty(t, "prototype", {
                         writable: !1
                     }), e;
-                }(), v = (new Date).getFullYear(), m = {
-                    dayNames: [ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ],
-                    monthNames: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ],
-                    ordinalSuffix: [ "st", "nd", "rd", "th" ]
-                }, g = !1, y = {
+                }(), v = (new Date).getFullYear(), m = n.default.prototype.i18n, g = !1, y = {
                     d: [ "[1-9]|[12][0-9]|3[01]", Date.prototype.setDate, "day", Date.prototype.getDate ],
                     dd: [ "0[1-9]|[12][0-9]|3[01]", Date.prototype.setDate, "day", function() {
                         return M(Date.prototype.getDate.call(this), 2);
@@ -953,16 +950,16 @@
                     }, "month", function() {
                         return M(Date.prototype.getMonth.call(this) + 1, 2);
                     } ],
-                    mmm: [ m.monthNames.slice(0, 11).join("|"), function(e) {
-                        var t = m.monthNames.slice(0, 11).findIndex((function(t) {
+                    mmm: [ m.monthNames.slice(0, 12).join("|"), function(e) {
+                        var t = m.monthNames.slice(0, 12).findIndex((function(t) {
                             return e.toLowerCase() === t.toLowerCase();
                         }));
                         return Date.prototype.setMonth.call(this, t);
                     }, "month", function() {
                         return M(Date.prototype.getMonth.call(this) + 1, 2);
                     } ],
-                    mmmm: [ m.monthNames.slice(12, 23).join("|"), function(e) {
-                        var t = m.monthNames.slice(12, 23).findIndex((function(t) {
+                    mmmm: [ m.monthNames.slice(12, 24).join("|"), function(e) {
+                        var t = m.monthNames.slice(12, 24).findIndex((function(t) {
                             return e.toLowerCase() === t.toLowerCase();
                         }));
                         return Date.prototype.setMonth.call(this, t);
@@ -1121,7 +1118,7 @@
                 n.default.extendAliases({
                     datetime: {
                         mask: function(e) {
-                            return e.numericInput = !1, y.S = e.i18n.ordinalSuffix.join("|"), e.inputFormat = k[e.inputFormat] || e.inputFormat, 
+                            return e.numericInput = !1, y.S = m.ordinalSuffix.join("|"), e.inputFormat = k[e.inputFormat] || e.inputFormat, 
                             e.displayFormat = k[e.displayFormat] || e.displayFormat || e.inputFormat, e.outputFormat = k[e.outputFormat] || e.outputFormat || e.inputFormat, 
                             e.placeholder = "" !== e.placeholder ? e.placeholder : e.inputFormat.replace(/[[\]]/, ""), 
                             e.regex = O(e.inputFormat, void 0, e), e.min = _(e.min, e.inputFormat, e), e.max = _(e.max, e.inputFormat, e), 
@@ -1134,7 +1131,6 @@
                         min: null,
                         max: null,
                         skipOptionalPartCharacter: "",
-                        i18n: m,
                         preValidation: function(e, t, i, n, a, r, o, s) {
                             if (s) return !0;
                             if (isNaN(i) && e[t] !== i) {
@@ -1239,6 +1235,16 @@
                     }
                 });
             },
+            1313: function(e, t, i) {
+                var n, a = (n = i(2394)) && n.__esModule ? n : {
+                    default: n
+                };
+                a.default.dependencyLib.extend(!0, a.default.prototype.i18n, {
+                    dayNames: [ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ],
+                    monthNames: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ],
+                    ordinalSuffix: [ "st", "nd", "rd", "th" ]
+                });
+            },
             3851: function(e, t, i) {
                 var n, a = (n = i(2394)) && n.__esModule ? n : {
                     default: n
@@ -1903,6 +1909,7 @@
                     definitions: p.default,
                     aliases: {},
                     masksCache: {},
+                    i18n: {},
                     get isRTL() {
                         return this.opts.isRTL || this.opts.numericInput;
                     },

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


+ 8 - 18
lib/extensions/inputmask.date.extensions.js

@@ -1,6 +1,6 @@
 /*
  Input Mask plugin extensions
- http://github.com/RobinHerbots/jquery.inputmask
+ http://github.com/RobinHerbots/inputmask
  Copyright (c) Robin Herbots
  Licensed under the MIT license
  */
@@ -9,6 +9,7 @@ import {keys} from "../keycode.js";
 import escapeRegex from "../escapeRegex";
 import {seekNext} from "../positioning";
 import {getMaskTemplate} from "../validation-tests";
+import "./inputmask.date.i18n";
 
 const $ = Inputmask.dependencyLib;
 
@@ -95,16 +96,7 @@ class DateObject {
 }
 
 let currentYear = new Date().getFullYear(),
-	i18n = {
-		dayNames: [
-			"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",
-			"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
-		],
-		monthNames: [
-			"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
-			"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
-		], ordinalSuffix: ["st", "nd", "rd", "th"]
-	},
+	i18n = Inputmask.prototype.i18n,
 	useDateObject = false,
 	//supported codes for formatting
 	//http://blog.stevenlevithan.com/archives/date-time-format
@@ -130,14 +122,14 @@ let currentYear = new Date().getFullYear(),
 		}, "month", function () {
 			return pad(Date.prototype.getMonth.call(this) + 1, 2);
 		}], //Month as digits; leading zero for single-digit months.
-		mmm: [i18n.monthNames.slice(0, 11).join("|"), function (val) {
-			let mval = i18n.monthNames.slice(0, 11).findIndex(item => val.toLowerCase() === item.toLowerCase());
+		mmm: [i18n.monthNames.slice(0, 12).join("|"), function (val) {
+			let mval = i18n.monthNames.slice(0, 12).findIndex(item => val.toLowerCase() === item.toLowerCase());
 			return Date.prototype.setMonth.call(this, mval);
 		}, "month", function () {
 			return pad(Date.prototype.getMonth.call(this) + 1, 2);
 		}],//Month as a three-letter abbreviation.
-		mmmm: [i18n.monthNames.slice(12, 23).join("|"), function (val) {
-			let mval = i18n.monthNames.slice(12, 23).findIndex(item => val.toLowerCase() === item.toLowerCase());
+		mmmm: [i18n.monthNames.slice(12, 24).join("|"), function (val) {
+			let mval = i18n.monthNames.slice(12, 24).findIndex(item => val.toLowerCase() === item.toLowerCase());
 			return Date.prototype.setMonth.call(this, mval);
 		}, "month", function () {
 			return pad(Date.prototype.getMonth.call(this) + 1, 2);
@@ -449,7 +441,7 @@ Inputmask.extendAliases({
 			opts.numericInput = false;
 
 			//localize
-			formatCode.S = opts.i18n.ordinalSuffix.join("|");
+			formatCode.S = i18n.ordinalSuffix.join("|");
 
 			opts.inputFormat = formatAlias[opts.inputFormat] || opts.inputFormat; //resolve possible formatAlias
 			opts.displayFormat = formatAlias[opts.displayFormat] || opts.displayFormat || opts.inputFormat; //resolve possible formatAlias
@@ -467,8 +459,6 @@ Inputmask.extendAliases({
 		min: null, //needs to be in the same format as the inputfornat
 		max: null, //needs to be in the same format as the inputfornat,
 		skipOptionalPartCharacter: "",
-		// Internationalization strings
-		i18n: i18n,
 		preValidation: function (buffer, pos, c, isSelection, opts, maskset, caretPos, strict) {
 			if (strict) return true;
 			if (isNaN(c) && buffer[pos] !== c) {

+ 20 - 0
lib/extensions/inputmask.date.i18n.js

@@ -0,0 +1,20 @@
+/*
+ Input Mask plugin extensions
+ http://github.com/RobinHerbots/inputmask
+ Copyright (c) Robin Herbots
+ Licensed under the MIT license
+ */
+import Inputmask from "../inputmask";
+
+const $ = Inputmask.dependencyLib;
+
+$.extend(true, Inputmask.prototype.i18n, {
+	dayNames: [
+		"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",
+		"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
+	],
+	monthNames: [
+		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
+		"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
+	], ordinalSuffix: ["st", "nd", "rd", "th"]
+});

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

@@ -1,6 +1,6 @@
 /*
  Input Mask plugin extensions
- http://github.com/RobinHerbots/jquery.inputmask
+ http://github.com/RobinHerbots/inputmask
  Copyright (c) Robin Herbots
  Licensed under the MIT license
  */

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

@@ -1,6 +1,6 @@
 /*
  Input Mask plugin extensions
- http://github.com/RobinHerbots/jquery.inputmask
+ http://github.com/RobinHerbots/inputmask
  Copyright (c) Robin Herbots
  Licensed under the MIT license
  */

+ 277 - 276
lib/inputmask.js

@@ -20,326 +20,327 @@ import defaults from "./defaults";
 const document = window.document, dataKey = "_inputmask_opts";
 
 function Inputmask(alias, options, internal) {
-    //allow instanciating without new
-    if (!(this instanceof Inputmask)) {
-        return new Inputmask(alias, options, internal);
-    }
+	//allow instanciating without new
+	if (!(this instanceof Inputmask)) {
+		return new Inputmask(alias, options, internal);
+	}
 
-    this.dependencyLib = $;
-    this.el = undefined;
-    this.events = {};
-    this.maskset = undefined;
+	this.dependencyLib = $;
+	this.el = undefined;
+	this.events = {};
+	this.maskset = undefined;
 
-    if (internal !== true) {
-        //init options
-        if (Object.prototype.toString.call(alias) === "[object Object]") {
-            options = alias;
-        } else {
-            options = options || {};
-            if (alias) options.alias = alias;
-        }
-        this.opts = $.extend(true, {}, this.defaults, options);
-        this.noMasksCache = options && options.definitions !== undefined;
-        this.userOptions = options || {}; //user passed options
-        resolveAlias(this.opts.alias, options, this.opts);
-    }
+	if (internal !== true) {
+		//init options
+		if (Object.prototype.toString.call(alias) === "[object Object]") {
+			options = alias;
+		} else {
+			options = options || {};
+			if (alias) options.alias = alias;
+		}
+		this.opts = $.extend(true, {}, this.defaults, options);
+		this.noMasksCache = options && options.definitions !== undefined;
+		this.userOptions = options || {}; //user passed options
+		resolveAlias(this.opts.alias, options, this.opts);
+	}
 
-    //maskscope properties
-    this.refreshValue = false; //indicate a refresh from the inputvalue is needed (form.reset)
-    this.undoValue = undefined;
-    this.$el = undefined;
-    this.skipInputEvent = false; //skip when triggered from within inputmask
-    this.validationEvent = false;
-    this.ignorable = false;
-    this.maxLength;
-    this.mouseEnter = false;
-    this.clicked = 0;
-    this.originalPlaceholder = undefined; //needed for FF
-    this.isComposing = false, //keydowncode == 229  compositionevent fallback
-    this.hasAlternator = false;
+	//maskscope properties
+	this.refreshValue = false; //indicate a refresh from the inputvalue is needed (form.reset)
+	this.undoValue = undefined;
+	this.$el = undefined;
+	this.skipInputEvent = false; //skip when triggered from within inputmask
+	this.validationEvent = false;
+	this.ignorable = false;
+	this.maxLength;
+	this.mouseEnter = false;
+	this.clicked = 0;
+	this.originalPlaceholder = undefined; //needed for FF
+	this.isComposing = false, //keydowncode == 229  compositionevent fallback
+		this.hasAlternator = false;
 }
 
 Inputmask.prototype = {
-    dataAttribute: "data-inputmask", //data attribute prefix used for attribute binding
-    //options default
-    defaults: defaults,
-    definitions: definitions,
-    aliases: {}, //aliases definitions
-    masksCache: {},
-    get isRTL() {
-        return this.opts.isRTL || this.opts.numericInput;
-    },
-    mask: function (elems) {
-        var that = this;
-        if (typeof elems === "string") {
-            elems = (document.getElementById(elems) || document.querySelectorAll(elems));
-        }
-        elems = elems.nodeName ? [elems] : (Array.isArray(elems) ? elems : [].slice.call(elems)); //[].slice as alternate for Array.from (Yandex browser)
-        elems.forEach(function (el, ndx) {
-            var scopedOpts = $.extend(true, {}, that.opts);
-            if (importAttributeOptions(el, scopedOpts, $.extend(true, {}, that.userOptions), that.dataAttribute)) {
-                var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
-                if (maskset !== undefined) {
-                    if (el.inputmask !== undefined) {
-                        el.inputmask.opts.autoUnmask = true; //force autounmasking when remasking
-                        el.inputmask.remove();
-                    }
-                    //store inputmask instance on the input with element reference
-                    el.inputmask = new Inputmask(undefined, undefined, true);
-                    el.inputmask.opts = scopedOpts;
-                    el.inputmask.noMasksCache = that.noMasksCache;
-                    el.inputmask.userOptions = $.extend(true, {}, that.userOptions);
-                    // el.inputmask.isRTL = scopedOpts.isRTL || scopedOpts.numericInput;
-                    el.inputmask.el = el;
-                    el.inputmask.$el = $(el);
-                    el.inputmask.maskset = maskset;
+	dataAttribute: "data-inputmask", //data attribute prefix used for attribute binding
+	//options default
+	defaults: defaults,
+	definitions: definitions,
+	aliases: {}, //aliases definitions
+	masksCache: {},
+	i18n: {},
+	get isRTL() {
+		return this.opts.isRTL || this.opts.numericInput;
+	},
+	mask: function (elems) {
+		var that = this;
+		if (typeof elems === "string") {
+			elems = (document.getElementById(elems) || document.querySelectorAll(elems));
+		}
+		elems = elems.nodeName ? [elems] : (Array.isArray(elems) ? elems : [].slice.call(elems)); //[].slice as alternate for Array.from (Yandex browser)
+		elems.forEach(function (el, ndx) {
+			var scopedOpts = $.extend(true, {}, that.opts);
+			if (importAttributeOptions(el, scopedOpts, $.extend(true, {}, that.userOptions), that.dataAttribute)) {
+				var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
+				if (maskset !== undefined) {
+					if (el.inputmask !== undefined) {
+						el.inputmask.opts.autoUnmask = true; //force autounmasking when remasking
+						el.inputmask.remove();
+					}
+					//store inputmask instance on the input with element reference
+					el.inputmask = new Inputmask(undefined, undefined, true);
+					el.inputmask.opts = scopedOpts;
+					el.inputmask.noMasksCache = that.noMasksCache;
+					el.inputmask.userOptions = $.extend(true, {}, that.userOptions);
+					// el.inputmask.isRTL = scopedOpts.isRTL || scopedOpts.numericInput;
+					el.inputmask.el = el;
+					el.inputmask.$el = $(el);
+					el.inputmask.maskset = maskset;
 
-                    $.data(el, dataKey, that.userOptions);
-                    mask.call(el.inputmask);
-                }
-            }
-        });
-        return elems && elems[0] ? (elems[0].inputmask || this) : this;
-    },
-    option: function (options, noremask) { //set extra options || retrieve value of a current option
-        if (typeof options === "string") {
-            return this.opts[options];
-        } else if (typeof options === "object") {
-            $.extend(this.userOptions, options); //user passed options
-            //remask
-            if (this.el && noremask !== true) {
-                this.mask(this.el);
-            }
-            return this;
-        }
-    },
-    unmaskedvalue: function (value) {
-        this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
-        if (this.el === undefined || value !== undefined) {
-            var valueBuffer = (typeof this.opts.onBeforeMask === "function" ? (this.opts.onBeforeMask.call(this, value, this.opts) || value) : value).split("");
-            checkVal.call(this, undefined, false, false, valueBuffer);
-            if (typeof this.opts.onBeforeWrite === "function") this.opts.onBeforeWrite.call(this, undefined, getBuffer.call(this), 0, this.opts);
-        }
-        return unmaskedvalue.call(this, this.el);
-    },
-    remove: function () {
-        if (this.el) {
-            $.data(this.el, dataKey, null); //invalidate
-            //writeout the value
-            var cv = this.opts.autoUnmask ? unmaskedvalue(this.el) : this._valueGet(this.opts.autoUnmask);
-            if (cv !== getBufferTemplate.call(this).join("")) this._valueSet(cv, this.opts.autoUnmask); else this._valueSet("");
-            //unbind all events
-            EventRuler.off(this.el);
+					$.data(el, dataKey, that.userOptions);
+					mask.call(el.inputmask);
+				}
+			}
+		});
+		return elems && elems[0] ? (elems[0].inputmask || this) : this;
+	},
+	option: function (options, noremask) { //set extra options || retrieve value of a current option
+		if (typeof options === "string") {
+			return this.opts[options];
+		} else if (typeof options === "object") {
+			$.extend(this.userOptions, options); //user passed options
+			//remask
+			if (this.el && noremask !== true) {
+				this.mask(this.el);
+			}
+			return this;
+		}
+	},
+	unmaskedvalue: function (value) {
+		this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
+		if (this.el === undefined || value !== undefined) {
+			var valueBuffer = (typeof this.opts.onBeforeMask === "function" ? (this.opts.onBeforeMask.call(this, value, this.opts) || value) : value).split("");
+			checkVal.call(this, undefined, false, false, valueBuffer);
+			if (typeof this.opts.onBeforeWrite === "function") this.opts.onBeforeWrite.call(this, undefined, getBuffer.call(this), 0, this.opts);
+		}
+		return unmaskedvalue.call(this, this.el);
+	},
+	remove: function () {
+		if (this.el) {
+			$.data(this.el, dataKey, null); //invalidate
+			//writeout the value
+			var cv = this.opts.autoUnmask ? unmaskedvalue(this.el) : this._valueGet(this.opts.autoUnmask);
+			if (cv !== getBufferTemplate.call(this).join("")) this._valueSet(cv, this.opts.autoUnmask); else this._valueSet("");
+			//unbind all events
+			EventRuler.off(this.el);
 
-            //restore the value property
-            var valueProperty;
-            if (Object.getOwnPropertyDescriptor && Object.getPrototypeOf) {
-                valueProperty = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this.el), "value");
-                if (valueProperty) {
-                    if (this.__valueGet) {
-                        Object.defineProperty(this.el, "value", {
-                            get: this.__valueGet,
-                            set: this.__valueSet,
-                            configurable: true
-                        });
-                    }
-                }
-            } else if (document.__lookupGetter__ && this.el.__lookupGetter__("value")) {
-                if (this.__valueGet) {
-                    this.el.__defineGetter__("value", this.__valueGet);
-                    this.el.__defineSetter__("value", this.__valueSet);
-                }
-            }
-            //clear data
-            this.el.inputmask = undefined;
-        }
-        return this.el;
-    },
-    getemptymask: function () { //return the default (empty) mask value, usefull for setting the default value in validation
-        this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
-        return (this.isRTL ? getBufferTemplate.call(this).reverse() : getBufferTemplate.call(this)).join("");
-    },
-    hasMaskedValue: function () { //check wheter the returned value is masked or not; currently only works reliable when using jquery.val fn to retrieve the value
-        return !this.opts.autoUnmask;
-    },
-    isComplete: function () {
-        this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
-        return isComplete.call(this, getBuffer.call(this));
-    },
-    getmetadata: function () { //return mask metadata if exists
-        this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
-        if (Array.isArray(this.maskset.metadata)) {
-            var maskTarget = getMaskTemplate.call(this, true, 0, false).join("");
-            this.maskset.metadata.forEach(function (mtdt) {
-                if (mtdt.mask === maskTarget) {
-                    maskTarget = mtdt;
-                    return false;
-                }
+			//restore the value property
+			var valueProperty;
+			if (Object.getOwnPropertyDescriptor && Object.getPrototypeOf) {
+				valueProperty = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this.el), "value");
+				if (valueProperty) {
+					if (this.__valueGet) {
+						Object.defineProperty(this.el, "value", {
+							get: this.__valueGet,
+							set: this.__valueSet,
+							configurable: true
+						});
+					}
+				}
+			} else if (document.__lookupGetter__ && this.el.__lookupGetter__("value")) {
+				if (this.__valueGet) {
+					this.el.__defineGetter__("value", this.__valueGet);
+					this.el.__defineSetter__("value", this.__valueSet);
+				}
+			}
+			//clear data
+			this.el.inputmask = undefined;
+		}
+		return this.el;
+	},
+	getemptymask: function () { //return the default (empty) mask value, usefull for setting the default value in validation
+		this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
+		return (this.isRTL ? getBufferTemplate.call(this).reverse() : getBufferTemplate.call(this)).join("");
+	},
+	hasMaskedValue: function () { //check wheter the returned value is masked or not; currently only works reliable when using jquery.val fn to retrieve the value
+		return !this.opts.autoUnmask;
+	},
+	isComplete: function () {
+		this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
+		return isComplete.call(this, getBuffer.call(this));
+	},
+	getmetadata: function () { //return mask metadata if exists
+		this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
+		if (Array.isArray(this.maskset.metadata)) {
+			var maskTarget = getMaskTemplate.call(this, true, 0, false).join("");
+			this.maskset.metadata.forEach(function (mtdt) {
+				if (mtdt.mask === maskTarget) {
+					maskTarget = mtdt;
+					return false;
+				}
 
-                return true;
-            });
-            return maskTarget;
-        }
-        return this.maskset.metadata;
-    },
-    isValid: function (value) {
-        this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
-        if (value) {
-            var valueBuffer = (typeof this.opts.onBeforeMask === "function" ? (this.opts.onBeforeMask.call(this, value, this.opts) || value) : value).split("");
-            checkVal.call(this, undefined, true, false, valueBuffer);
-        } else {
-            value = this.isRTL ? getBuffer.call(this).slice().reverse().join("") : getBuffer.call(this).join("");
-        }
-        var buffer = getBuffer.call(this);
-        var rl = determineLastRequiredPosition.call(this),
-            lmib = buffer.length - 1;
-        for (; lmib > rl; lmib--) {
-            if (isMask.call(this, lmib)) break;
-        }
-        buffer.splice(rl, lmib + 1 - rl);
+				return true;
+			});
+			return maskTarget;
+		}
+		return this.maskset.metadata;
+	},
+	isValid: function (value) {
+		this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
+		if (value) {
+			var valueBuffer = (typeof this.opts.onBeforeMask === "function" ? (this.opts.onBeforeMask.call(this, value, this.opts) || value) : value).split("");
+			checkVal.call(this, undefined, true, false, valueBuffer);
+		} else {
+			value = this.isRTL ? getBuffer.call(this).slice().reverse().join("") : getBuffer.call(this).join("");
+		}
+		var buffer = getBuffer.call(this);
+		var rl = determineLastRequiredPosition.call(this),
+			lmib = buffer.length - 1;
+		for (; lmib > rl; lmib--) {
+			if (isMask.call(this, lmib)) break;
+		}
+		buffer.splice(rl, lmib + 1 - rl);
 
-        return isComplete.call(this, buffer) && value === (this.isRTL ? getBuffer.call(this).slice().reverse().join("") : getBuffer.call(this).join(""));
+		return isComplete.call(this, buffer) && value === (this.isRTL ? getBuffer.call(this).slice().reverse().join("") : getBuffer.call(this).join(""));
 
-    },
-    format: function (value, metadata) {
-        this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
-        let valueBuffer = (typeof this.opts.onBeforeMask === "function" ? (this.opts.onBeforeMask.call(this, value, this.opts) || value) : value).split("");
-        checkVal.call(this, undefined, true, false, valueBuffer);
-        let formattedValue = this.isRTL ? getBuffer.call(this).slice().reverse().join("") : getBuffer.call(this).join("");
-        return metadata ? {
-            value: formattedValue,
-            metadata: this.getmetadata()
-        } : formattedValue;
-    },
-    setValue: function (value) {
-        if (this.el) {
-            $(this.el).trigger("setvalue", [value]);
-        }
-    },
-    analyseMask: analyseMask
+	},
+	format: function (value, metadata) {
+		this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
+		let valueBuffer = (typeof this.opts.onBeforeMask === "function" ? (this.opts.onBeforeMask.call(this, value, this.opts) || value) : value).split("");
+		checkVal.call(this, undefined, true, false, valueBuffer);
+		let formattedValue = this.isRTL ? getBuffer.call(this).slice().reverse().join("") : getBuffer.call(this).join("");
+		return metadata ? {
+			value: formattedValue,
+			metadata: this.getmetadata()
+		} : formattedValue;
+	},
+	setValue: function (value) {
+		if (this.el) {
+			$(this.el).trigger("setvalue", [value]);
+		}
+	},
+	analyseMask: analyseMask
 };
 
 function resolveAlias(aliasStr, options, opts) {
-    var aliasDefinition = Inputmask.prototype.aliases[aliasStr];
-    if (aliasDefinition) {
-        if (aliasDefinition.alias) resolveAlias(aliasDefinition.alias, undefined, opts); //alias is another alias
-        $.extend(true, opts, aliasDefinition); //merge alias definition in the options
-        $.extend(true, opts, options); //reapply extra given options
-        return true;
-    } else //alias not found - try as mask
-    if (opts.mask === null) {
-        opts.mask = aliasStr;
-    }
+	var aliasDefinition = Inputmask.prototype.aliases[aliasStr];
+	if (aliasDefinition) {
+		if (aliasDefinition.alias) resolveAlias(aliasDefinition.alias, undefined, opts); //alias is another alias
+		$.extend(true, opts, aliasDefinition); //merge alias definition in the options
+		$.extend(true, opts, options); //reapply extra given options
+		return true;
+	} else //alias not found - try as mask
+	if (opts.mask === null) {
+		opts.mask = aliasStr;
+	}
 
-    return false;
+	return false;
 }
 
 function importAttributeOptions(npt, opts, userOptions, dataAttribute) {
-    function importOption(option, optionData) {
-        const attrOption = dataAttribute === "" ? option : dataAttribute + "-" + option;
-        optionData = optionData !== undefined ? optionData : npt.getAttribute(attrOption);
-        if (optionData !== null) {
-            if (typeof optionData === "string") {
-                if (option.indexOf("on") === 0) {
-                    optionData = window[optionData];
-                }//get function definition
-                else if (optionData === "false") {
-                    optionData = false;
-                } else if (optionData === "true") optionData = true;
-            }
-            userOptions[option] = optionData;
-        }
-    }
+	function importOption(option, optionData) {
+		const attrOption = dataAttribute === "" ? option : dataAttribute + "-" + option;
+		optionData = optionData !== undefined ? optionData : npt.getAttribute(attrOption);
+		if (optionData !== null) {
+			if (typeof optionData === "string") {
+				if (option.indexOf("on") === 0) {
+					optionData = window[optionData];
+				}//get function definition
+				else if (optionData === "false") {
+					optionData = false;
+				} else if (optionData === "true") optionData = true;
+			}
+			userOptions[option] = optionData;
+		}
+	}
 
-    if (opts.importDataAttributes === true) {
-        var attrOptions = npt.getAttribute(dataAttribute), option, dataoptions, optionData, p;
+	if (opts.importDataAttributes === true) {
+		var attrOptions = npt.getAttribute(dataAttribute), option, dataoptions, optionData, p;
 
-        if (attrOptions && attrOptions !== "") {
-            attrOptions = attrOptions.replace(/'/g, "\"");
-            dataoptions = JSON.parse("{" + attrOptions + "}");
-        }
+		if (attrOptions && attrOptions !== "") {
+			attrOptions = attrOptions.replace(/'/g, "\"");
+			dataoptions = JSON.parse("{" + attrOptions + "}");
+		}
 
-        //resolve aliases
-        if (dataoptions) { //pickup alias from dataAttribute
-            optionData = undefined;
-            for (p in dataoptions) {
-                if (p.toLowerCase() === "alias") {
-                    optionData = dataoptions[p];
-                    break;
-                }
-            }
-        }
-        importOption("alias", optionData); //pickup alias from dataAttribute-alias
-        if (userOptions.alias) {
-            resolveAlias(userOptions.alias, userOptions, opts);
-        }
+		//resolve aliases
+		if (dataoptions) { //pickup alias from dataAttribute
+			optionData = undefined;
+			for (p in dataoptions) {
+				if (p.toLowerCase() === "alias") {
+					optionData = dataoptions[p];
+					break;
+				}
+			}
+		}
+		importOption("alias", optionData); //pickup alias from dataAttribute-alias
+		if (userOptions.alias) {
+			resolveAlias(userOptions.alias, userOptions, opts);
+		}
 
-        for (option in opts) {
-            if (dataoptions) {
-                optionData = undefined;
-                for (p in dataoptions) {
-                    if (p.toLowerCase() === option.toLowerCase()) {
-                        optionData = dataoptions[p];
-                        break;
-                    }
-                }
-            }
-            importOption(option, optionData);
-        }
-    }
-    $.extend(true, opts, userOptions);
+		for (option in opts) {
+			if (dataoptions) {
+				optionData = undefined;
+				for (p in dataoptions) {
+					if (p.toLowerCase() === option.toLowerCase()) {
+						optionData = dataoptions[p];
+						break;
+					}
+				}
+			}
+			importOption(option, optionData);
+		}
+	}
+	$.extend(true, opts, userOptions);
 
-    //handle dir=rtl
-    if (npt.dir === "rtl" || opts.rightAlign) {
-        npt.style.textAlign = "right";
-    }
+	//handle dir=rtl
+	if (npt.dir === "rtl" || opts.rightAlign) {
+		npt.style.textAlign = "right";
+	}
 
-    if (npt.dir === "rtl" || opts.numericInput) {
-        npt.dir = "ltr";
-        npt.removeAttribute("dir");
-        opts.isRTL = true;
-    }
+	if (npt.dir === "rtl" || opts.numericInput) {
+		npt.dir = "ltr";
+		npt.removeAttribute("dir");
+		opts.isRTL = true;
+	}
 
-    return Object.keys(userOptions).length;
+	return Object.keys(userOptions).length;
 }
 
 //apply defaults, definitions, aliases
 Inputmask.extendDefaults = function (options) {
-    $.extend(true, Inputmask.prototype.defaults, options);
+	$.extend(true, Inputmask.prototype.defaults, options);
 };
 Inputmask.extendDefinitions = function (definition) {
-    $.extend(true, Inputmask.prototype.definitions, definition);
+	$.extend(true, Inputmask.prototype.definitions, definition);
 };
 Inputmask.extendAliases = function (alias) {
-    $.extend(true, Inputmask.prototype.aliases, alias);
+	$.extend(true, Inputmask.prototype.aliases, alias);
 };
 //static fn on inputmask
 Inputmask.format = function (value, options, metadata) {
-    return Inputmask(options).format(value, metadata);
+	return Inputmask(options).format(value, metadata);
 };
 Inputmask.unmask = function (value, options) {
-    return Inputmask(options).unmaskedvalue(value);
+	return Inputmask(options).unmaskedvalue(value);
 };
 Inputmask.isValid = function (value, options) {
-    return Inputmask(options).isValid(value);
+	return Inputmask(options).isValid(value);
 };
 Inputmask.remove = function (elems) {
-    if (typeof elems === "string") {
-        elems = document.getElementById(elems) || document.querySelectorAll(elems);
-    }
-    elems = elems.nodeName ? [elems] : elems;
-    elems.forEach(function (el) {
-        if (el.inputmask) el.inputmask.remove();
-    });
+	if (typeof elems === "string") {
+		elems = document.getElementById(elems) || document.querySelectorAll(elems);
+	}
+	elems = elems.nodeName ? [elems] : elems;
+	elems.forEach(function (el) {
+		if (el.inputmask) el.inputmask.remove();
+	});
 };
 Inputmask.setValue = function (elems, value) {
-    if (typeof elems === "string") {
-        elems = document.getElementById(elems) || document.querySelectorAll(elems);
-    }
-    elems = elems.nodeName ? [elems] : elems;
-    elems.forEach(function (el) {
-        if (el.inputmask) el.inputmask.setValue(value); else $(el).trigger("setvalue", [value]);
-    });
+	if (typeof elems === "string") {
+		elems = document.getElementById(elems) || document.querySelectorAll(elems);
+	}
+	elems = elems.nodeName ? [elems] : elems;
+	elems.forEach(function (el) {
+		if (el.inputmask) el.inputmask.setValue(value); else $(el).trigger("setvalue", [value]);
+	});
 };
 
 Inputmask.dependencyLib = $;

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "5.0.9-beta.40",
+  "version": "5.0.9-beta.41",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
   "main": "dist/inputmask.js",
   "exports": {