mirror of
https://github.com/itflow-org/itflow
synced 2026-03-03 04:14:54 +00:00
added input masks
This commit is contained in:
26
vendor/Inputmask/lib/bindings/inputmask.binding.js
vendored
Normal file
26
vendor/Inputmask/lib/bindings/inputmask.binding.js
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
Input Mask plugin binding
|
||||
http://github.com/RobinHerbots/jquery.inputmask
|
||||
Copyright (c) Robin Herbots
|
||||
Licensed under the MIT license
|
||||
*/
|
||||
(function (factory) {
|
||||
factory(jQuery, window.Inputmask, window);
|
||||
}
|
||||
(function ($, Inputmask, window) {
|
||||
$(window.document).ajaxComplete(function (event, xmlHttpRequest, ajaxOptions) {
|
||||
if ($.inArray("html", ajaxOptions.dataTypes) !== -1) {
|
||||
$(".inputmask, [data-inputmask], [data-inputmask-mask], [data-inputmask-alias], [data-inputmask-regex]").each(function (ndx, lmnt) {
|
||||
if (lmnt.inputmask === undefined) {
|
||||
Inputmask().mask(lmnt);
|
||||
}
|
||||
});
|
||||
}
|
||||
}).ready(function () {
|
||||
$(".inputmask, [data-inputmask], [data-inputmask-mask], [data-inputmask-alias],[data-inputmask-regex]").each(function (ndx, lmnt) {
|
||||
if (lmnt.inputmask === undefined) {
|
||||
Inputmask().mask(lmnt);
|
||||
}
|
||||
});
|
||||
});
|
||||
}));
|
||||
170
vendor/Inputmask/lib/dependencyLibs/inputmask.dependencyLib.jqlite.js
vendored
Normal file
170
vendor/Inputmask/lib/dependencyLibs/inputmask.dependencyLib.jqlite.js
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
Input Mask plugin dependencyLib
|
||||
http://github.com/RobinHerbots/jquery.inputmask
|
||||
Copyright (c) Robin Herbots
|
||||
Licensed under the MIT license
|
||||
*/
|
||||
var $ = require("jqlite"), window = require("../global/window"), document = window.document;
|
||||
// Use a stripped-down indexOf as it's faster than native
|
||||
// http://jsperf.com/thor-indexof-vs-for/5
|
||||
function indexOf(list, elem) {
|
||||
var i = 0,
|
||||
len = list.length;
|
||||
for (; i < len; i++) {
|
||||
if (list[i] === elem) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
function isWindow(obj) {
|
||||
return obj != null && obj === obj.window;
|
||||
}
|
||||
|
||||
function isArraylike(obj) {
|
||||
// Support: iOS 8.2 (not reproducible in simulator)
|
||||
// `in` check used to prevent JIT error (gh-2145)
|
||||
// hasOwn isn't used here due to false negatives
|
||||
// regarding Nodelist length in IE
|
||||
var length = "length" in obj && obj.length,
|
||||
ltype = typeof obj;
|
||||
|
||||
if (ltype === "function" || isWindow(obj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (obj.nodeType === 1 && length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return ltype === "array" || length === 0 ||
|
||||
typeof length === "number" && length > 0 && (length - 1) in obj;
|
||||
}
|
||||
|
||||
$.inArray = function (elem, arr, i) {
|
||||
return arr == null ? -1 : indexOf(arr, elem, i);
|
||||
};
|
||||
$.isFunction = function (obj) {
|
||||
return typeof obj === "function";
|
||||
};
|
||||
$.isArray = Array.isArray;
|
||||
$.isPlainObject = function (obj) {
|
||||
// Not plain objects:
|
||||
// - Any object or value whose internal [[Class]] property is not "[object Object]"
|
||||
// - DOM nodes
|
||||
// - window
|
||||
if (typeof obj !== "object" || obj.nodeType || isWindow(obj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (obj.constructor && !Object.hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the function hasn't returned already, we're confident that
|
||||
// |obj| is a plain object, created by {} or constructed with new Object
|
||||
return true;
|
||||
};
|
||||
$.extend = function () {
|
||||
var options, name, src, copy, copyIsArray, clone,
|
||||
target = arguments[0] || {},
|
||||
i = 1,
|
||||
length = arguments.length,
|
||||
deep = false;
|
||||
|
||||
// Handle a deep copy situation
|
||||
if (typeof target === "boolean") {
|
||||
deep = target;
|
||||
|
||||
// Skip the boolean and the target
|
||||
target = arguments[i] || {};
|
||||
i++;
|
||||
}
|
||||
|
||||
// Handle case when target is a string or something (possible in deep copy)
|
||||
if (typeof target !== "object" && !$.isFunction(target)) {
|
||||
target = {};
|
||||
}
|
||||
|
||||
// Extend jQuery itself if only one argument is passed
|
||||
if (i === length) {
|
||||
target = this;
|
||||
i--;
|
||||
}
|
||||
|
||||
for (; i < length; i++) {
|
||||
// Only deal with non-null/undefined values
|
||||
if ((options = arguments[i]) != null) {
|
||||
// Extend the base object
|
||||
for (name in options) {
|
||||
src = target[name];
|
||||
copy = options[name];
|
||||
|
||||
// Prevent never-ending loop
|
||||
if (target === copy) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Recurse if we're merging plain objects or arrays
|
||||
if (deep && copy && ($.isPlainObject(copy) || (copyIsArray = $.isArray(copy)))) {
|
||||
if (copyIsArray) {
|
||||
copyIsArray = false;
|
||||
clone = src && $.isArray(src) ? src : [];
|
||||
|
||||
} else {
|
||||
clone = src && $.isPlainObject(src) ? src : {};
|
||||
}
|
||||
|
||||
// Never move original objects, clone them
|
||||
target[name] = $.extend(deep, clone, copy);
|
||||
|
||||
// Don't bring in undefined values
|
||||
} else if (copy !== undefined) {
|
||||
target[name] = copy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return the modified object
|
||||
return target;
|
||||
};
|
||||
$.each = function (obj, callback) {
|
||||
var value, i = 0;
|
||||
|
||||
if (isArraylike(obj)) {
|
||||
for (var length = obj.length; i < length; i++) {
|
||||
value = callback.call(obj[i], i, obj[i]);
|
||||
if (value === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i in obj) {
|
||||
value = callback.call(obj[i], i, obj[i]);
|
||||
if (value === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
$.data = function (elem, name, data) {
|
||||
return $(elem).data(name, data);
|
||||
};
|
||||
$.Event = $.Event || function CustomEvent(event, params) {
|
||||
params = params || {
|
||||
bubbles: false,
|
||||
cancelable: false,
|
||||
detail: undefined
|
||||
};
|
||||
var evt = document.createEvent("CustomEvent");
|
||||
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
||||
return evt;
|
||||
};
|
||||
$.Event.prototype = window.Event.prototype;
|
||||
|
||||
module.exports = $;
|
||||
8
vendor/Inputmask/lib/dependencyLibs/inputmask.dependencyLib.jquery.js
vendored
Normal file
8
vendor/Inputmask/lib/dependencyLibs/inputmask.dependencyLib.jquery.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Input Mask plugin dependencyLib
|
||||
http://github.com/RobinHerbots/jquery.inputmask
|
||||
Copyright (c) Robin Herbots
|
||||
Licensed under the MIT license
|
||||
*/
|
||||
|
||||
module.exports = require("jquery");
|
||||
372
vendor/Inputmask/lib/dependencyLibs/inputmask.dependencyLib.js
vendored
Normal file
372
vendor/Inputmask/lib/dependencyLibs/inputmask.dependencyLib.js
vendored
Normal file
@@ -0,0 +1,372 @@
|
||||
/*
|
||||
Input Mask plugin dependencyLib
|
||||
http://github.com/RobinHerbots/jquery.inputmask
|
||||
Copyright (c) Robin Herbots
|
||||
Licensed under the MIT license
|
||||
*/
|
||||
|
||||
var window = require("../global/window"), document = window.document;
|
||||
//helper functions
|
||||
|
||||
// Use a stripped-down indexOf as it's faster than native
|
||||
// http://jsperf.com/thor-indexof-vs-for/5
|
||||
function indexOf(list, elem) {
|
||||
var i = 0,
|
||||
len = list.length;
|
||||
for (; i < len; i++) {
|
||||
if (list[i] === elem) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function isWindow(obj) {
|
||||
return obj != null && obj === obj["window"];
|
||||
}
|
||||
|
||||
function isArraylike(obj) {
|
||||
// Support: iOS 8.2 (not reproducible in simulator)
|
||||
// `in` check used to prevent JIT error (gh-2145)
|
||||
// hasOwn isn't used here due to false negatives
|
||||
// regarding Nodelist length in IE
|
||||
var length = "length" in obj && obj.length,
|
||||
ltype = typeof obj;
|
||||
|
||||
if (ltype === "function" || isWindow(obj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (obj.nodeType === 1 && length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return ltype === "array" || length === 0 ||
|
||||
typeof length === "number" && length > 0 && (length - 1) in obj;
|
||||
}
|
||||
|
||||
function isValidElement(elem) {
|
||||
return elem instanceof Element;
|
||||
}
|
||||
|
||||
function DependencyLib(elem) {
|
||||
if (elem instanceof DependencyLib) {
|
||||
return elem;
|
||||
}
|
||||
if (!(this instanceof DependencyLib)) {
|
||||
return new DependencyLib(elem);
|
||||
}
|
||||
if (elem !== undefined && elem !== null && elem !== window) {
|
||||
this[0] = elem.nodeName ? elem : (elem[0] !== undefined && elem[0].nodeName ? elem[0] : document.querySelector(elem));
|
||||
if (this[0] !== undefined && this[0] !== null) {
|
||||
this[0].eventRegistry = this[0].eventRegistry || {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DependencyLib.prototype = {
|
||||
on: function (events, handler) {
|
||||
function addEvent(ev, namespace) {
|
||||
//register domevent
|
||||
if (elem.addEventListener) { // all browsers except IE before version 9
|
||||
elem.addEventListener(ev, handler, false);
|
||||
} else if (elem.attachEvent) { // IE before version 9
|
||||
elem.attachEvent("on" + ev, handler);
|
||||
}
|
||||
eventRegistry[ev] = eventRegistry[ev] || {};
|
||||
eventRegistry[ev][namespace] = eventRegistry[ev][namespace] || [];
|
||||
eventRegistry[ev][namespace].push(handler);
|
||||
}
|
||||
|
||||
if (isValidElement(this[0])) {
|
||||
var eventRegistry = this[0].eventRegistry,
|
||||
elem = this[0];
|
||||
|
||||
|
||||
var _events = events.split(" ");
|
||||
for (var endx = 0; endx < _events.length; endx++) {
|
||||
var nsEvent = _events[endx].split("."),
|
||||
ev = nsEvent[0],
|
||||
namespace = nsEvent[1] || "global";
|
||||
addEvent(ev, namespace);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
},
|
||||
off: function (events, handler) {
|
||||
var eventRegistry, elem;
|
||||
|
||||
function removeEvent(ev, namespace, handler) {
|
||||
if (ev in eventRegistry === true) {
|
||||
//unbind to dom events
|
||||
if (elem.removeEventListener) { // all browsers except IE before version 9
|
||||
elem.removeEventListener(ev, handler, false);
|
||||
} else if (elem.detachEvent) { // IE before version 9
|
||||
elem.detachEvent("on" + ev, handler);
|
||||
}
|
||||
if (namespace === "global") {
|
||||
for (var nmsp in eventRegistry[ev]) {
|
||||
eventRegistry[ev][nmsp].splice(eventRegistry[ev][nmsp].indexOf(handler), 1);
|
||||
}
|
||||
} else {
|
||||
eventRegistry[ev][namespace].splice(eventRegistry[ev][namespace].indexOf(handler), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function resolveNamespace(ev, namespace) {
|
||||
var evts = [],
|
||||
hndx, hndL;
|
||||
if (ev.length > 0) {
|
||||
if (handler === undefined) {
|
||||
for (hndx = 0, hndL = eventRegistry[ev][namespace].length; hndx < hndL; hndx++) {
|
||||
evts.push({
|
||||
ev: ev,
|
||||
namespace: namespace && namespace.length > 0 ? namespace : "global",
|
||||
handler: eventRegistry[ev][namespace][hndx]
|
||||
});
|
||||
}
|
||||
} else {
|
||||
evts.push({
|
||||
ev: ev,
|
||||
namespace: namespace && namespace.length > 0 ? namespace : "global",
|
||||
handler: handler
|
||||
});
|
||||
}
|
||||
} else if (namespace.length > 0) {
|
||||
for (var evNdx in eventRegistry) {
|
||||
for (var nmsp in eventRegistry[evNdx]) {
|
||||
if (nmsp === namespace) {
|
||||
if (handler === undefined) {
|
||||
for (hndx = 0, hndL = eventRegistry[evNdx][nmsp].length; hndx < hndL; hndx++) {
|
||||
evts.push({
|
||||
ev: evNdx,
|
||||
namespace: nmsp,
|
||||
handler: eventRegistry[evNdx][nmsp][hndx]
|
||||
});
|
||||
}
|
||||
} else {
|
||||
evts.push({
|
||||
ev: evNdx,
|
||||
namespace: nmsp,
|
||||
handler: handler
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return evts;
|
||||
}
|
||||
|
||||
if (isValidElement(this[0])) {
|
||||
eventRegistry = this[0].eventRegistry;
|
||||
elem = this[0];
|
||||
|
||||
|
||||
var _events = events.split(" ");
|
||||
for (var endx = 0; endx < _events.length; endx++) {
|
||||
var nsEvent = _events[endx].split("."),
|
||||
offEvents = resolveNamespace(nsEvent[0], nsEvent[1]);
|
||||
for (var i = 0, offEventsL = offEvents.length; i < offEventsL; i++) {
|
||||
removeEvent(offEvents[i].ev, offEvents[i].namespace, offEvents[i].handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
},
|
||||
trigger: function (events /* , args... */) {
|
||||
if (isValidElement(this[0])) {
|
||||
var eventRegistry = this[0].eventRegistry,
|
||||
elem = this[0];
|
||||
var _events = typeof events === "string" ? events.split(" ") : [events.type];
|
||||
for (var endx = 0; endx < _events.length; endx++) {
|
||||
var nsEvent = _events[endx].split("."),
|
||||
ev = nsEvent[0],
|
||||
namespace = nsEvent[1] || "global";
|
||||
if (document !== undefined && namespace === "global") {
|
||||
//trigger domevent
|
||||
var evnt, i, params = {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
detail: arguments[1]
|
||||
};
|
||||
// The custom event that will be created
|
||||
if (document.createEvent) {
|
||||
try {
|
||||
evnt = new CustomEvent(ev, params);
|
||||
} catch (e) {
|
||||
evnt = document.createEvent("CustomEvent");
|
||||
evnt.initCustomEvent(ev, params.bubbles, params.cancelable, params.detail);
|
||||
}
|
||||
if (events.type) DependencyLib.extend(evnt, events);
|
||||
elem.dispatchEvent(evnt);
|
||||
} else {
|
||||
evnt = document.createEventObject();
|
||||
evnt.eventType = ev;
|
||||
evnt.detail = arguments[1];
|
||||
if (events.type) DependencyLib.extend(evnt, events);
|
||||
elem.fireEvent("on" + evnt.eventType, evnt);
|
||||
}
|
||||
} else if (eventRegistry[ev] !== undefined) {
|
||||
arguments[0] = arguments[0].type ? arguments[0] : DependencyLib.Event(arguments[0]);
|
||||
arguments[0].detail = arguments.slice(1);
|
||||
if (namespace === "global") {
|
||||
for (var nmsp in eventRegistry[ev]) {
|
||||
for (i = 0; i < eventRegistry[ev][nmsp].length; i++) {
|
||||
eventRegistry[ev][nmsp][i].apply(elem, arguments);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < eventRegistry[ev][namespace].length; i++) {
|
||||
eventRegistry[ev][namespace][i].apply(elem, arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
//static
|
||||
DependencyLib.isFunction = function (obj) {
|
||||
return typeof obj === "function";
|
||||
};
|
||||
DependencyLib.noop = function () {
|
||||
};
|
||||
DependencyLib.isArray = Array.isArray;
|
||||
DependencyLib.inArray = function (elem, arr, i) {
|
||||
return arr == null ? -1 : indexOf(arr, elem, i);
|
||||
};
|
||||
DependencyLib.valHooks = undefined;
|
||||
|
||||
|
||||
DependencyLib.isPlainObject = function (obj) {
|
||||
// Not plain objects:
|
||||
// - Any object or value whose internal [[Class]] property is not "[object Object]"
|
||||
// - DOM nodes
|
||||
// - window
|
||||
if (typeof obj !== "object" || obj.nodeType || isWindow(obj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (obj.constructor && !Object.hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the function hasn't returned already, we're confident that
|
||||
// |obj| is a plain object, created by {} or constructed with new Object
|
||||
return true;
|
||||
};
|
||||
|
||||
DependencyLib.extend = function () {
|
||||
var options, name, src, copy, copyIsArray, clone,
|
||||
target = arguments[0] || {},
|
||||
i = 1,
|
||||
length = arguments.length,
|
||||
deep = false;
|
||||
|
||||
// Handle a deep copy situation
|
||||
if (typeof target === "boolean") {
|
||||
deep = target;
|
||||
|
||||
// Skip the boolean and the target
|
||||
target = arguments[i] || {};
|
||||
i++;
|
||||
}
|
||||
|
||||
// Handle case when target is a string or something (possible in deep copy)
|
||||
if (typeof target !== "object" && !DependencyLib.isFunction(target)) {
|
||||
target = {};
|
||||
}
|
||||
|
||||
// Extend jQuery itself if only one argument is passed
|
||||
if (i === length) {
|
||||
target = this;
|
||||
i--;
|
||||
}
|
||||
|
||||
for (; i < length; i++) {
|
||||
// Only deal with non-null/undefined values
|
||||
if ((options = arguments[i]) != null) {
|
||||
// Extend the base object
|
||||
for (name in options) {
|
||||
src = target[name];
|
||||
copy = options[name];
|
||||
|
||||
// Prevent never-ending loop
|
||||
if (target === copy) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Recurse if we're merging plain objects or arrays
|
||||
if (deep && copy && (DependencyLib.isPlainObject(copy) || (copyIsArray = DependencyLib.isArray(copy)))) {
|
||||
if (copyIsArray) {
|
||||
copyIsArray = false;
|
||||
clone = src && DependencyLib.isArray(src) ? src : [];
|
||||
|
||||
} else {
|
||||
clone = src && DependencyLib.isPlainObject(src) ? src : {};
|
||||
}
|
||||
|
||||
// Never move original objects, clone them
|
||||
target[name] = DependencyLib.extend(deep, clone, copy);
|
||||
|
||||
// Don't bring in undefined values
|
||||
} else if (copy !== undefined) {
|
||||
target[name] = copy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return the modified object
|
||||
return target;
|
||||
};
|
||||
|
||||
DependencyLib.each = function (obj, callback) {
|
||||
var value, i = 0;
|
||||
|
||||
if (isArraylike(obj)) {
|
||||
for (var length = obj.length; i < length; i++) {
|
||||
value = callback.call(obj[i], i, obj[i]);
|
||||
if (value === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i in obj) {
|
||||
value = callback.call(obj[i], i, obj[i]);
|
||||
if (value === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
DependencyLib.data = function (owner, key, value) {
|
||||
if (value === undefined) {
|
||||
return owner.__data ? owner.__data[key] : null;
|
||||
} else {
|
||||
owner.__data = owner.__data || {};
|
||||
owner.__data[key] = value;
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof window.CustomEvent === "function") {
|
||||
DependencyLib.Event = window.CustomEvent;
|
||||
} else {
|
||||
DependencyLib.Event = function (event, params) {
|
||||
params = params || {bubbles: false, cancelable: false, detail: undefined};
|
||||
var evt = document.createEvent("CustomEvent");
|
||||
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
||||
return evt;
|
||||
};
|
||||
DependencyLib.Event.prototype = window.Event.prototype;
|
||||
}
|
||||
|
||||
module.exports = DependencyLib;
|
||||
323
vendor/Inputmask/lib/extensions/inputmask.date.extensions.js
vendored
Normal file
323
vendor/Inputmask/lib/extensions/inputmask.date.extensions.js
vendored
Normal file
@@ -0,0 +1,323 @@
|
||||
/*
|
||||
Input Mask plugin extensions
|
||||
http://github.com/RobinHerbots/jquery.inputmask
|
||||
Copyright (c) Robin Herbots
|
||||
Licensed under the MIT license
|
||||
*/
|
||||
var Inputmask = require("../inputmask"), $ = Inputmask.dependencyLib,
|
||||
//supported codes for formatting
|
||||
//http://blog.stevenlevithan.com/archives/date-time-format
|
||||
//https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings?view=netframework-4.7
|
||||
formatCode = { //regex, valueSetter, type, displayformatter
|
||||
d: ["[1-9]|[12][0-9]|3[01]", Date.prototype.setDate, "day", Date.prototype.getDate], //Day of the month as digits; no leading zero for single-digit days.
|
||||
dd: ["0[1-9]|[12][0-9]|3[01]", Date.prototype.setDate, "day", function () {
|
||||
return pad(Date.prototype.getDate.call(this), 2);
|
||||
}], //Day of the month as digits; leading zero for single-digit days.
|
||||
ddd: [""], //Day of the week as a three-letter abbreviation.
|
||||
dddd: [""], //Day of the week as its full name.
|
||||
m: ["[1-9]|1[012]", Date.prototype.setMonth, "month", function () {
|
||||
return Date.prototype.getMonth.call(this) + 1;
|
||||
}], //Month as digits; no leading zero for single-digit months.
|
||||
mm: ["0[1-9]|1[012]", Date.prototype.setMonth, "month", function () {
|
||||
return pad(Date.prototype.getMonth.call(this) + 1, 2);
|
||||
}], //Month as digits; leading zero for single-digit months.
|
||||
mmm: [""], //Month as a three-letter abbreviation.
|
||||
mmmm: [""], //Month as its full name.
|
||||
yy: ["[0-9]{2}", Date.prototype.setFullYear, "year", function () {
|
||||
return pad(Date.prototype.getFullYear.call(this), 2);
|
||||
}], //Year as last two digits; leading zero for years less than 10.
|
||||
yyyy: ["[0-9]{4}", Date.prototype.setFullYear, "year", function () {
|
||||
return pad(Date.prototype.getFullYear.call(this), 4);
|
||||
}],
|
||||
h: ["[1-9]|1[0-2]", Date.prototype.setHours, "hours", Date.prototype.getHours], //Hours; no leading zero for single-digit hours (12-hour clock).
|
||||
hh: ["0[1-9]|1[0-2]", Date.prototype.setHours, "hours", function () {
|
||||
return pad(Date.prototype.getHours.call(this), 2);
|
||||
}], //Hours; leading zero for single-digit hours (12-hour clock).
|
||||
hhh: ["[0-9]+", Date.prototype.setHours, "hours", Date.prototype.getHours], //Hours; no limit
|
||||
H: ["1?[0-9]|2[0-3]", Date.prototype.setHours, "hours", Date.prototype.getHours], //Hours; no leading zero for single-digit hours (24-hour clock).
|
||||
HH: ["0[0-9]|1[0-9]|2[0-3]", Date.prototype.setHours, "hours", function () {
|
||||
return pad(Date.prototype.getHours.call(this), 2);
|
||||
}], //Hours; leading zero for single-digit hours (24-hour clock).
|
||||
HHH: ["[0-9]+", Date.prototype.setHours, "hours", Date.prototype.getHours], //Hours; no limit
|
||||
M: ["[1-5]?[0-9]", Date.prototype.setMinutes, "minutes", Date.prototype.getMinutes], //Minutes; no leading zero for single-digit minutes. Uppercase M unlike CF timeFormat's m to avoid conflict with months.
|
||||
MM: ["0[0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]", Date.prototype.setMinutes, "minutes", function () {
|
||||
return pad(Date.prototype.getMinutes.call(this), 2);
|
||||
}], //Minutes; leading zero for single-digit minutes. Uppercase MM unlike CF timeFormat's mm to avoid conflict with months.
|
||||
s: ["[1-5]?[0-9]", Date.prototype.setSeconds, "seconds", Date.prototype.getSeconds], //Seconds; no leading zero for single-digit seconds.
|
||||
ss: ["0[0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]", Date.prototype.setSeconds, "seconds", function () {
|
||||
return pad(Date.prototype.getSeconds.call(this), 2);
|
||||
}], //Seconds; leading zero for single-digit seconds.
|
||||
l: ["[0-9]{3}", Date.prototype.setMilliseconds, "milliseconds", function () {
|
||||
return pad(Date.prototype.getMilliseconds.call(this), 3);
|
||||
}], //Milliseconds. 3 digits.
|
||||
L: ["[0-9]{2}", Date.prototype.setMilliseconds, "milliseconds", function () {
|
||||
return pad(Date.prototype.getMilliseconds.call(this), 2);
|
||||
}], //Milliseconds. 2 digits.
|
||||
t: ["[ap]"], //Lowercase, single-character time marker string: a or p.
|
||||
tt: ["[ap]m"], //two-character time marker string: am or pm.
|
||||
T: ["[AP]"], //single-character time marker string: A or P.
|
||||
TT: ["[AP]M"], //two-character time marker string: AM or PM.
|
||||
Z: [""], //US timezone abbreviation, e.g. EST or MDT. With non-US timezones or in the Opera browser, the GMT/UTC offset is returned, e.g. GMT-0500
|
||||
o: [""], //GMT/UTC timezone offset, e.g. -0500 or +0230.
|
||||
S: [""] //The date's ordinal suffix (st, nd, rd, or th).
|
||||
},
|
||||
formatAlias = {
|
||||
isoDate: "yyyy-mm-dd", //2007-06-09
|
||||
isoTime: "HH:MM:ss", //17:46:21
|
||||
isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", //2007-06-09T17:46:21
|
||||
isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" //2007-06-09T22:46:21Z
|
||||
};
|
||||
|
||||
function getTokenizer(opts) {
|
||||
if (!opts.tokenizer) {
|
||||
var tokens = [];
|
||||
for (var ndx in formatCode) {
|
||||
if (tokens.indexOf(ndx[0]) === -1) {
|
||||
tokens.push(ndx[0]);
|
||||
}
|
||||
}
|
||||
opts.tokenizer = "(" + tokens.join("+|") + ")+?|.";
|
||||
opts.tokenizer = new RegExp(opts.tokenizer, "g");
|
||||
}
|
||||
|
||||
return opts.tokenizer;
|
||||
}
|
||||
|
||||
function isValidDate(dateParts, currentResult) {
|
||||
return !isFinite(dateParts.rawday)
|
||||
|| (dateParts.day == "29" && !isFinite(dateParts.rawyear))
|
||||
|| new Date(dateParts.date.getFullYear(), isFinite(dateParts.rawmonth) ? dateParts.month : dateParts.date.getMonth() + 1, 0).getDate() >= dateParts.day
|
||||
? currentResult
|
||||
: false; //take corrective action if possible
|
||||
}
|
||||
|
||||
function isDateInRange(dateParts, opts) {
|
||||
var result = true;
|
||||
if (opts.min) {
|
||||
if (dateParts["rawyear"]) {
|
||||
var rawYear = dateParts["rawyear"].replace(/[^0-9]/g, ""),
|
||||
minYear = opts.min.year.substr(0, rawYear.length);
|
||||
result = minYear <= rawYear;
|
||||
}
|
||||
if (dateParts["year"] === dateParts["rawyear"]) {
|
||||
if (opts.min.date.getTime() === opts.min.date.getTime()) {
|
||||
result = opts.min.date.getTime() <= dateParts.date.getTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result && opts.max && opts.max.date.getTime() === opts.max.date.getTime()) {
|
||||
result = opts.max.date.getTime() >= dateParts.date.getTime();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//parse the given format and return a mask pattern
|
||||
//when a dateObjValue is passed a datestring in the requested format is returned
|
||||
function parse(format, dateObjValue, opts, raw) {
|
||||
//parse format to regex string
|
||||
var mask = "", match;
|
||||
while ((match = getTokenizer(opts).exec(format))) {
|
||||
if (dateObjValue === undefined) {
|
||||
if (formatCode[match[0]]) {
|
||||
mask += "(" + formatCode[match[0]][0] + ")";
|
||||
} else {
|
||||
switch (match[0]) {
|
||||
case "[":
|
||||
mask += "(";
|
||||
break;
|
||||
case "]":
|
||||
mask += ")?";
|
||||
break;
|
||||
default:
|
||||
mask += Inputmask.escapeRegex(match[0]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (formatCode[match[0]]) {
|
||||
if (raw !== true && formatCode[match[0]][3]) {
|
||||
var getFn = formatCode[match[0]][3];
|
||||
mask += getFn.call(dateObjValue.date);
|
||||
} else if (formatCode[match[0]][2]) {
|
||||
mask += dateObjValue["raw" + formatCode[match[0]][2]];
|
||||
} else {
|
||||
mask += match[0];
|
||||
}
|
||||
} else {
|
||||
mask += match[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
//padding function
|
||||
function pad(val, len) {
|
||||
val = String(val);
|
||||
len = len || 2;
|
||||
while (val.length < len) val = "0" + val;
|
||||
return val;
|
||||
}
|
||||
|
||||
function analyseMask(maskString, format, opts) {
|
||||
var dateObj = {"date": new Date(1, 0, 1)}, targetProp, mask = maskString, match, dateOperation;
|
||||
|
||||
function extendProperty(value) {
|
||||
var correctedValue = value.replace(/[^0-9]/g, "0");
|
||||
// if (correctedValue != value) { //only do correction on incomplete values
|
||||
// //determine best validation match
|
||||
// var enteredPart = value.replace(/[^0-9]/g, ""),
|
||||
// enteredPartIndex = value.indexOf(enteredPart),
|
||||
// minPart = (opts.min && opts.min[targetProp] || value).slice(enteredPartIndex, enteredPartIndex + enteredPart.length),
|
||||
// maxPart = (opts.max && opts.max[targetProp] || value).slice(enteredPartIndex, enteredPartIndex + enteredPart.length),
|
||||
// correctedPart = enteredPart < minPart ? minPart : (enteredPart > maxPart ? maxPart : correctedValue.slice(enteredPartIndex, enteredPartIndex + enteredPart.length));
|
||||
// correctedValue = correctedValue.split("");
|
||||
// correctedValue.splice(enteredPartIndex, 1, correctedPart);
|
||||
// correctedValue = correctedValue.join("");
|
||||
// }
|
||||
return correctedValue;
|
||||
}
|
||||
|
||||
function setValue(dateObj, value, opts) {
|
||||
dateObj[targetProp] = extendProperty(value);
|
||||
dateObj["raw" + targetProp] = value;
|
||||
|
||||
if (dateOperation !== undefined) {
|
||||
dateOperation.call(dateObj.date, targetProp == "month" ? parseInt(dateObj[targetProp]) - 1 : dateObj[targetProp]);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof mask === "string") {
|
||||
while ((match = getTokenizer(opts).exec(format))) {
|
||||
var value = mask.slice(0, match[0].length);
|
||||
if (formatCode.hasOwnProperty(match[0])) {
|
||||
// targetValidator = formatCode[match[0]][0];
|
||||
targetProp = formatCode[match[0]][2];
|
||||
dateOperation = formatCode[match[0]][1];
|
||||
setValue(dateObj, value, opts);
|
||||
}
|
||||
mask = mask.slice(value.length);
|
||||
}
|
||||
|
||||
return dateObj;
|
||||
} else if (mask && typeof mask === "object" && mask.hasOwnProperty("date")) {
|
||||
return mask;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Inputmask.extendAliases({
|
||||
"datetime": {
|
||||
mask: function (opts) {
|
||||
//localize
|
||||
formatCode.S = opts.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
|
||||
opts.outputFormat = formatAlias[opts.outputFormat] || opts.outputFormat || opts.inputFormat; //resolve possible formatAlias
|
||||
opts.placeholder = opts.placeholder !== "" ? opts.placeholder : opts.inputFormat.replace(/[[\]]/, "");
|
||||
opts.regex = parse(opts.inputFormat, undefined, opts);
|
||||
// console.log(opts.regex);
|
||||
return null; //migrate to regex mask
|
||||
},
|
||||
placeholder: "", //set default as none (~ auto); when a custom placeholder is passed it will be used
|
||||
inputFormat: "isoDateTime", //format used to input the date
|
||||
displayFormat: undefined, //visual format when the input looses focus
|
||||
outputFormat: undefined, //unmasking format
|
||||
min: null, //needs to be in the same format as the inputfornat
|
||||
max: null, //needs to be in the same format as the inputfornat,
|
||||
// Internationalization strings
|
||||
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"]
|
||||
},
|
||||
preValidation: function (buffer, pos, c, isSelection, opts, maskset) {
|
||||
var calcPos = 0, targetMatch, match;
|
||||
if (isNaN(c) && buffer[pos] !== c) {
|
||||
while ((match = getTokenizer(opts).exec(opts.inputFormat))) {
|
||||
calcPos += match[0].length;
|
||||
if (calcPos >= pos) {
|
||||
targetMatch = match;
|
||||
match = getTokenizer(opts).exec(opts.inputFormat);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match && match[0] === c && targetMatch[0].length > 1) {
|
||||
buffer[pos] = buffer[pos - 1];
|
||||
buffer[pos - 1] = "0";
|
||||
return {
|
||||
fuzzy: true,
|
||||
buffer: buffer,
|
||||
refreshFromBuffer: {start: pos - 1, end: pos + 1},
|
||||
pos: pos + 1
|
||||
};
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
postValidation: function (buffer, pos, currentResult, opts) {
|
||||
opts.min = analyseMask(opts.min, opts.inputFormat, opts);
|
||||
opts.max = analyseMask(opts.max, opts.inputFormat, opts);
|
||||
|
||||
if (currentResult.fuzzy) {
|
||||
buffer = currentResult.buffer;
|
||||
pos = currentResult.pos;
|
||||
}
|
||||
|
||||
var result = currentResult, dateParts = analyseMask(buffer.join(""), opts.inputFormat, opts);
|
||||
if (result && dateParts.date.getTime() === dateParts.date.getTime()) { //check for a valid date ~ an invalid date returns NaN which isn't equal
|
||||
result = isValidDate(dateParts, result);
|
||||
result = result && isDateInRange(dateParts, opts);
|
||||
}
|
||||
|
||||
if (pos && result && currentResult.pos !== pos) {
|
||||
return {
|
||||
buffer: parse(opts.inputFormat, dateParts, opts),
|
||||
refreshFromBuffer: {start: pos, end: currentResult.pos}
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
onKeyDown: function (e, buffer, caretPos, opts) {
|
||||
var input = this;
|
||||
if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
|
||||
var today = new Date(), match, date = "";
|
||||
|
||||
while ((match = getTokenizer(opts).exec(opts.inputFormat))) {
|
||||
if (match[0].charAt(0) === "d") {
|
||||
date += pad(today.getDate(), match[0].length);
|
||||
} else if (match[0].charAt(0) === "m") {
|
||||
date += pad((today.getMonth() + 1), match[0].length);
|
||||
} else if (match[0] === "yyyy") {
|
||||
date += today.getFullYear().toString();
|
||||
} else if (match[0].charAt(0) === "y") {
|
||||
date += pad(today.getYear(), match[0].length);
|
||||
}
|
||||
}
|
||||
|
||||
input.inputmask._valueSet(date);
|
||||
$(input).trigger("setvalue");
|
||||
}
|
||||
},
|
||||
onUnMask: function (maskedValue, unmaskedValue, opts) {
|
||||
return unmaskedValue ? parse(opts.outputFormat, analyseMask(maskedValue, opts.inputFormat, opts), opts, true) : unmaskedValue;
|
||||
},
|
||||
casing: function (elem, test, pos, validPositions) {
|
||||
if (test.nativeDef.indexOf("[ap]") == 0) return elem.toLowerCase();
|
||||
if (test.nativeDef.indexOf("[AP]") == 0) return elem.toUpperCase();
|
||||
return elem;
|
||||
},
|
||||
insertMode: false,
|
||||
shiftPositions: false
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = Inputmask;
|
||||
92
vendor/Inputmask/lib/extensions/inputmask.extensions.js
vendored
Normal file
92
vendor/Inputmask/lib/extensions/inputmask.extensions.js
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
Input Mask plugin extensions
|
||||
http://github.com/RobinHerbots/jquery.inputmask
|
||||
Copyright (c) Robin Herbots
|
||||
Licensed under the MIT license
|
||||
*/
|
||||
var Inputmask = require("../inputmask");
|
||||
//extra definitions
|
||||
Inputmask.extendDefinitions({
|
||||
"A": {
|
||||
validator: "[A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
|
||||
casing: "upper" //auto uppercasing
|
||||
},
|
||||
"&": { //alfanumeric uppercasing
|
||||
validator: "[0-9A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
|
||||
casing: "upper"
|
||||
},
|
||||
"#": { //hexadecimal
|
||||
validator: "[0-9A-Fa-f]",
|
||||
casing: "upper"
|
||||
}
|
||||
});
|
||||
Inputmask.extendAliases({
|
||||
"cssunit": {
|
||||
regex: "[+-]?[0-9]+\\.?([0-9]+)?(px|em|rem|ex|%|in|cm|mm|pt|pc)"
|
||||
},
|
||||
"url": { //needs update => https://en.wikipedia.org/wiki/URL
|
||||
regex: "(https?|ftp)//.*",
|
||||
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);
|
||||
}
|
||||
}
|
||||
},
|
||||
onUnMask: function (maskedValue, unmaskedValue, opts) {
|
||||
return maskedValue;
|
||||
},
|
||||
inputmode: "numeric",
|
||||
},
|
||||
"email": {
|
||||
//https://en.wikipedia.org/wiki/Domain_name#Domain_name_space
|
||||
//https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names
|
||||
//should be extended with the toplevel domains at the end
|
||||
mask: "*{1,64}[.*{1,64}][.*{1,64}][.*{1,63}]@-{1,63}.-{1,63}[.-{1,63}][.-{1,63}]",
|
||||
greedy: false,
|
||||
casing: "lower",
|
||||
onBeforePaste: function (pastedValue, opts) {
|
||||
pastedValue = pastedValue.toLowerCase();
|
||||
return pastedValue.replace("mailto:", "");
|
||||
},
|
||||
definitions: {
|
||||
"*": {
|
||||
validator: "[0-9\uFF11-\uFF19A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5!#$%&'*+/=?^_`{|}~-]"
|
||||
},
|
||||
"-": {
|
||||
validator: "[0-9A-Za-z-]"
|
||||
}
|
||||
},
|
||||
onUnMask: function (maskedValue, unmaskedValue, opts) {
|
||||
return maskedValue;
|
||||
},
|
||||
inputmode: "email"
|
||||
},
|
||||
"mac": {
|
||||
mask: "##:##:##:##:##:##"
|
||||
},
|
||||
//https://en.wikipedia.org/wiki/Vehicle_identification_number
|
||||
// see issue #1199
|
||||
"vin": {
|
||||
mask: "V{13}9{4}",
|
||||
definitions: {
|
||||
"V": {
|
||||
validator: "[A-HJ-NPR-Za-hj-npr-z\\d]",
|
||||
casing: "upper"
|
||||
}
|
||||
},
|
||||
clearIncomplete: true,
|
||||
autoUnmask: true
|
||||
}
|
||||
});
|
||||
module.exports = Inputmask;
|
||||
454
vendor/Inputmask/lib/extensions/inputmask.numeric.extensions.js
vendored
Executable file
454
vendor/Inputmask/lib/extensions/inputmask.numeric.extensions.js
vendored
Executable file
@@ -0,0 +1,454 @@
|
||||
/*
|
||||
Input Mask plugin extensions
|
||||
http://github.com/RobinHerbots/jquery.inputmask
|
||||
Copyright (c) Robin Herbots
|
||||
Licensed under the MIT license
|
||||
*/
|
||||
var Inputmask = require("../inputmask"), $ = Inputmask.dependencyLib;
|
||||
|
||||
function autoEscape(txt, opts) {
|
||||
var escapedTxt = "";
|
||||
for (var i = 0; i < txt.length; i++) {
|
||||
if (Inputmask.prototype.definitions[txt.charAt(i)] ||
|
||||
opts.definitions[txt.charAt(i)] ||
|
||||
opts.optionalmarker.start === txt.charAt(i) ||
|
||||
opts.optionalmarker.end === txt.charAt(i) ||
|
||||
opts.quantifiermarker.start === txt.charAt(i) ||
|
||||
opts.quantifiermarker.end === txt.charAt(i) ||
|
||||
opts.groupmarker.start === txt.charAt(i) ||
|
||||
opts.groupmarker.end === txt.charAt(i) ||
|
||||
opts.alternatormarker === txt.charAt(i)) {
|
||||
escapedTxt += "\\" + txt.charAt(i);
|
||||
} else {
|
||||
escapedTxt += txt.charAt(i);
|
||||
}
|
||||
}
|
||||
return escapedTxt;
|
||||
}
|
||||
|
||||
function alignDigits(buffer, digits, opts) {
|
||||
if (digits > 0 && !opts.digitsOptional && buffer.length > 0) {
|
||||
var radixPosition = $.inArray(opts.radixPoint, buffer);
|
||||
if (radixPosition === -1) {
|
||||
buffer.push(opts.radixPoint);
|
||||
radixPosition = buffer.length - 1;
|
||||
}
|
||||
for (var i = 1; i <= digits; i++) {
|
||||
buffer[radixPosition + i] = buffer[radixPosition + i] || "0";
|
||||
}
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
function findValidator(symbol, maskset) {
|
||||
var posNdx = 0;
|
||||
if (symbol === "+") {
|
||||
for (posNdx in maskset.validPositions) ;
|
||||
posNdx = parseInt(posNdx);
|
||||
}
|
||||
for (var tstNdx in maskset.tests) {
|
||||
tstNdx = parseInt(tstNdx);
|
||||
if (tstNdx >= posNdx) {
|
||||
for (var ndx = 0, ndxl = maskset.tests[tstNdx].length; ndx < ndxl; ndx++) {
|
||||
if ((maskset.validPositions[tstNdx] === undefined || symbol === "-") && maskset.tests[tstNdx][ndx].match.def === symbol) {
|
||||
return tstNdx + ((maskset.validPositions[tstNdx] !== undefined && symbol !== "-") ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return posNdx;
|
||||
}
|
||||
|
||||
function findValid(symbol, maskset) {
|
||||
var ret = -1;
|
||||
$.each(maskset.validPositions, function (ndx, tst) {
|
||||
if (tst.match.def === symbol) {
|
||||
ret = parseInt(ndx);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
function parseMinMaxOptions(opts) {
|
||||
if (opts.parseMinMaxOptions === undefined) {
|
||||
// convert min and max options
|
||||
if (opts.min !== null) {
|
||||
opts.min = opts.min.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
|
||||
if (opts.radixPoint === ",") opts.min = opts.min.replace(opts.radixPoint, ".");
|
||||
opts.min = isFinite(opts.min) ? parseFloat(opts.min) : NaN;
|
||||
if (isNaN(opts.min)) opts.min = Number.MIN_VALUE;
|
||||
}
|
||||
if (opts.max !== null) {
|
||||
opts.max = opts.max.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
|
||||
if (opts.radixPoint === ",") opts.max = opts.max.replace(opts.radixPoint, ".");
|
||||
opts.max = isFinite(opts.max) ? parseFloat(opts.max) : NaN;
|
||||
if (isNaN(opts.max)) opts.max = Number.MAX_VALUE;
|
||||
}
|
||||
opts.parseMinMaxOptions = "done";
|
||||
}
|
||||
}
|
||||
|
||||
function genMask(opts) {
|
||||
opts.repeat = 0;
|
||||
//treat equal separator and radixpoint
|
||||
if (opts.groupSeparator === opts.radixPoint && opts.digits && opts.digits !== "0") {
|
||||
if (opts.radixPoint === ".") {
|
||||
opts.groupSeparator = ",";
|
||||
} else if (opts.radixPoint === ",") {
|
||||
opts.groupSeparator = ".";
|
||||
} else {
|
||||
opts.groupSeparator = "";
|
||||
}
|
||||
}
|
||||
//prevent conflict with default skipOptionalPartCharacter
|
||||
if (opts.groupSeparator === " ") {
|
||||
opts.skipOptionalPartCharacter = undefined;
|
||||
}
|
||||
|
||||
//enforce placeholder to single
|
||||
if (opts.placeholder.length > 1) {
|
||||
opts.placeholder = opts.placeholder.charAt(0);
|
||||
}
|
||||
//only allow radixfocus when placeholder = 0
|
||||
if (opts.positionCaretOnClick === "radixFocus" && opts.placeholder === "") {
|
||||
opts.positionCaretOnClick = "lvp";
|
||||
}
|
||||
|
||||
var decimalDef = "0";
|
||||
if (opts.numericInput === true && opts.__financeInput === undefined) { //finance people input style
|
||||
decimalDef = "1";
|
||||
opts.positionCaretOnClick = opts.positionCaretOnClick === "radixFocus" ? "lvp" : opts.positionCaretOnClick;
|
||||
// opts.digitsOptional = false;
|
||||
if (isNaN(opts.digits)) opts.digits = 2;
|
||||
opts._radixDance = false;
|
||||
} else {
|
||||
opts.__financeInput = false; //needed to keep original selection when remasking
|
||||
opts.numericInput = true;
|
||||
}
|
||||
|
||||
var mask = "[+]", altMask;
|
||||
mask += autoEscape(opts.prefix, opts);
|
||||
if (opts.groupSeparator !== "") {
|
||||
mask += opts._mask(opts);
|
||||
} else {
|
||||
mask += "9{+}";
|
||||
}
|
||||
if (opts.digits !== undefined) {
|
||||
var dq = opts.digits.toString().split(",");
|
||||
if (isFinite(dq[0]) && dq[1] && isFinite(dq[1])) {
|
||||
mask += opts.radixPoint + decimalDef + "{" + opts.digits + "}";
|
||||
} else if (isNaN(opts.digits) || parseInt(opts.digits) > 0) {
|
||||
if (opts.digitsOptional) {
|
||||
altMask = mask + opts.radixPoint + decimalDef + "{0," + opts.digits + "}";
|
||||
// mask += "[" + opts.radixPoint + "]";
|
||||
opts.keepStatic = true;
|
||||
} else {
|
||||
mask += opts.radixPoint + decimalDef + "{" + opts.digits + "}";
|
||||
}
|
||||
}
|
||||
}
|
||||
mask += autoEscape(opts.suffix, opts);
|
||||
mask += "[-]";
|
||||
|
||||
if (altMask) {
|
||||
mask = [(altMask + autoEscape(opts.suffix, opts) + "[-]"), mask];
|
||||
}
|
||||
|
||||
|
||||
opts.greedy = false; //enforce greedy false
|
||||
|
||||
parseMinMaxOptions(opts);
|
||||
return mask;
|
||||
}
|
||||
|
||||
function hanndleRadixDance(pos, c, radixPos, opts) {
|
||||
if (opts._radixDance && opts.numericInput && c !== opts.negationSymbol.back) {
|
||||
if (pos <= radixPos && (radixPos > 0 || c == opts.radixPoint)) {
|
||||
pos -= 1;
|
||||
}
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
function decimalValidator(chrs, maskset, pos, strict, opts) {
|
||||
var radixPos = maskset.buffer.indexOf(opts.radixPoint),
|
||||
result = radixPos !== -1 && new RegExp("[0-9\uFF11-\uFF19]").test(chrs);
|
||||
if (opts._radixDance && result && maskset.validPositions[radixPos] == undefined) {
|
||||
return {
|
||||
insert: {
|
||||
pos: radixPos === pos ? radixPos + 1 : radixPos,
|
||||
c: opts.radixPoint
|
||||
},
|
||||
pos: pos
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//number aliases
|
||||
Inputmask.extendAliases({
|
||||
"numeric": {
|
||||
mask: genMask,
|
||||
_mask: function (opts) {
|
||||
return "(" + opts.groupSeparator + "999){+|1}";
|
||||
},
|
||||
placeholder: "0",
|
||||
greedy: false,
|
||||
digits: "*", //number of fractionalDigits
|
||||
digitsOptional: true,
|
||||
enforceDigitsOnBlur: false,
|
||||
radixPoint: ".",
|
||||
positionCaretOnClick: "radixFocus",
|
||||
_radixDance: true,
|
||||
groupSeparator: "",
|
||||
allowMinus: true,
|
||||
negationSymbol: {
|
||||
front: "-", //"("
|
||||
back: "" //")"
|
||||
},
|
||||
prefix: "",
|
||||
suffix: "",
|
||||
rightAlign: true,
|
||||
min: null, //minimum value
|
||||
max: null, //maximum value
|
||||
step: 1,
|
||||
insertMode: true,
|
||||
autoUnmask: false,
|
||||
unmaskAsNumber: false,
|
||||
inputmode: "numeric",
|
||||
definitions: {
|
||||
"0": {
|
||||
validator: decimalValidator
|
||||
},
|
||||
"1": {
|
||||
validator: decimalValidator,
|
||||
definitionSymbol: "*"
|
||||
},
|
||||
"+": {
|
||||
validator: function (chrs, maskset, pos, strict, opts) {
|
||||
return (opts.allowMinus && (chrs === "-" || chrs === opts.negationSymbol.front));
|
||||
|
||||
}
|
||||
},
|
||||
"-": {
|
||||
validator: function (chrs, maskset, pos, strict, opts) {
|
||||
return (opts.allowMinus && chrs === opts.negationSymbol.back);
|
||||
}
|
||||
}
|
||||
},
|
||||
preValidation: function (buffer, pos, c, isSelection, opts, maskset) {
|
||||
var radixPos = $.inArray(opts.radixPoint, buffer);
|
||||
pos = hanndleRadixDance(pos, c, radixPos, opts);
|
||||
if (c === "-" || c === opts.negationSymbol.front) {
|
||||
if (opts.allowMinus !== true) return false;
|
||||
var isNegative = false,
|
||||
front = findValid("+", maskset), back = findValid("-", maskset);
|
||||
if (front !== -1) {
|
||||
isNegative = [front, back];
|
||||
}
|
||||
|
||||
return isNegative !== false ? {
|
||||
remove: isNegative,
|
||||
caret: radixPos > pos ? pos + 1 : pos
|
||||
} : {
|
||||
insert: [
|
||||
{pos: findValidator("+", maskset), c: opts.negationSymbol.front, fromIsValid: true},
|
||||
{pos: findValidator("-", maskset), c: opts.negationSymbol.back, fromIsValid: undefined}],
|
||||
caret: radixPos > pos ? pos + 1 : pos
|
||||
};
|
||||
}
|
||||
if (radixPos !== -1 && (opts._radixDance === true && isSelection === false && c === opts.radixPoint && (opts.digits !== undefined && (isNaN(opts.digits) || parseInt(opts.digits) > 0)) && radixPos !== pos)) {
|
||||
return {
|
||||
"caret": opts._radixDance && pos === radixPos - 1 ? radixPos + 1 : radixPos
|
||||
};
|
||||
}
|
||||
|
||||
return {rewritePosition: pos};
|
||||
},
|
||||
postValidation: function (buffer, pos, currentResult, opts) {
|
||||
if (opts.min !== null || opts.max !== null) {
|
||||
var unmasked = opts.onUnMask(buffer.slice().reverse().join(""), undefined, $.extend({}, opts, {
|
||||
unmaskAsNumber: true
|
||||
}));
|
||||
if (opts.min !== null && unmasked < opts.min && unmasked.toString().length >= opts.min.toString().length) {
|
||||
return false;
|
||||
}
|
||||
if (opts.max !== null && unmasked > opts.max) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return currentResult;
|
||||
},
|
||||
onUnMask: function (maskedValue, unmaskedValue, opts) {
|
||||
if (unmaskedValue === "" && opts.nullable === true) {
|
||||
return unmaskedValue;
|
||||
}
|
||||
var processValue = maskedValue.replace(opts.prefix, "");
|
||||
processValue = processValue.replace(opts.suffix, "");
|
||||
processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
|
||||
if (opts.placeholder.charAt(0) !== "") {
|
||||
processValue = processValue.replace(new RegExp(opts.placeholder.charAt(0), "g"), "0");
|
||||
}
|
||||
if (opts.unmaskAsNumber) {
|
||||
if (opts.radixPoint !== "" && processValue.indexOf(opts.radixPoint) !== -1) processValue = processValue.replace(Inputmask.escapeRegex.call(this, opts.radixPoint), ".");
|
||||
processValue = processValue.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), "-");
|
||||
processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), "");
|
||||
return Number(processValue);
|
||||
}
|
||||
return processValue;
|
||||
},
|
||||
isComplete: function (buffer, opts) {
|
||||
var maskedValue = (opts.numericInput ? buffer.slice().reverse() : buffer).join("");
|
||||
maskedValue = maskedValue.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), "-");
|
||||
maskedValue = maskedValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), "");
|
||||
maskedValue = maskedValue.replace(opts.prefix, "");
|
||||
maskedValue = maskedValue.replace(opts.suffix, "");
|
||||
maskedValue = maskedValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator) + "([0-9]{3})", "g"), "$1");
|
||||
if (opts.radixPoint === ",") maskedValue = maskedValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".");
|
||||
return isFinite(maskedValue);
|
||||
},
|
||||
onBeforeMask: function (initialValue, opts) {
|
||||
var radixPoint = opts.radixPoint || ",";
|
||||
|
||||
if ((typeof initialValue == "number" || opts.inputType === "number") && radixPoint !== "") {
|
||||
initialValue = initialValue.toString().replace(".", radixPoint);
|
||||
}
|
||||
|
||||
var valueParts = initialValue.split(radixPoint),
|
||||
integerPart = valueParts[0].replace(/[^\-0-9]/g, ""),
|
||||
decimalPart = valueParts.length > 1 ? valueParts[1].replace(/[^0-9]/g, "") : "";
|
||||
|
||||
initialValue = integerPart + (decimalPart !== "" ? radixPoint + decimalPart : decimalPart);
|
||||
|
||||
var digits = 0;
|
||||
if (radixPoint !== "") {
|
||||
digits = decimalPart.length;
|
||||
if (decimalPart !== "") {
|
||||
var digitsFactor = Math.pow(10, digits || 1);
|
||||
if (isFinite(opts.digits)) {
|
||||
digits = parseInt(opts.digits);
|
||||
digitsFactor = Math.pow(10, digits);
|
||||
}
|
||||
|
||||
//make the initialValue a valid javascript number for the parsefloat
|
||||
initialValue = initialValue.replace(Inputmask.escapeRegex(radixPoint), ".");
|
||||
if (isFinite(initialValue)) {
|
||||
initialValue = Math.round(parseFloat(initialValue) * digitsFactor) / digitsFactor;
|
||||
}
|
||||
initialValue = initialValue.toString().replace(".", radixPoint);
|
||||
}
|
||||
}
|
||||
//this needs to be in a separate part and not directly in decimalPart to allow rounding
|
||||
if (opts.digits === 0 && initialValue.indexOf(Inputmask.escapeRegex(radixPoint)) !== -1) {
|
||||
initialValue = initialValue.substring(0, initialValue.indexOf(Inputmask.escapeRegex(radixPoint)));
|
||||
}
|
||||
return alignDigits(initialValue.toString().split(""), digits, opts).join("");
|
||||
},
|
||||
onBeforeWrite: function (e, buffer, caretPos, opts) {
|
||||
var result;
|
||||
//check leading zeros
|
||||
var numberMatches = new RegExp("^" + (opts.negationSymbol.front != "" ? Inputmask.escapeRegex(opts.negationSymbol.front) + "?" : "") + Inputmask.escapeRegex(opts.prefix) + "(?<number>.*)" + Inputmask.escapeRegex(opts.suffix) + (opts.negationSymbol.back != "" ? Inputmask.escapeRegex(opts.negationSymbol.back) + "?" : "") + "$").exec(buffer.slice().reverse().join("")),
|
||||
number = numberMatches ? numberMatches.groups.number : "";
|
||||
if (false && number) {
|
||||
number = number.split(opts.radixPoint.charAt(0))[0];
|
||||
|
||||
var leadingzeroes = new RegExp("^[0" + opts.groupSeparator + "]*").exec(number);
|
||||
|
||||
if (leadingzeroes[0].length > 1 || leadingzeroes[0].length > 0 && leadingzeroes[0].length < number.length) {
|
||||
var buf = buffer.slice().reverse(), caretNdx = buf.join("").indexOf(leadingzeroes[0]);
|
||||
buf.splice(caretNdx, leadingzeroes[0].length);
|
||||
var newCaretPos = buf.length - caretNdx;
|
||||
result = {
|
||||
refreshFromBuffer: true,
|
||||
buffer: buf.reverse(),
|
||||
caret: caretPos < newCaretPos ? caretPos : newCaretPos
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (e) {
|
||||
switch (e.type) {
|
||||
case "blur":
|
||||
case "checkval":
|
||||
if (opts.radixPoint !== "" && buffer[0] === opts.radixPoint) {
|
||||
if (result && result.buffer) {
|
||||
result.buffer.shift();
|
||||
} else {
|
||||
buffer.shift();
|
||||
result =
|
||||
{refreshFromBuffer: true, buffer: buffer};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
onKeyDown: function (e, buffer, caretPos, opts) {
|
||||
var $input = $(this);
|
||||
if (e.ctrlKey) {
|
||||
switch (e.keyCode) {
|
||||
case Inputmask.keyCode.UP:
|
||||
this.inputmask.__valueSet.call(this, parseFloat(this.inputmask.unmaskedvalue()) + parseInt(opts.step));
|
||||
$input.trigger("setvalue");
|
||||
return false;
|
||||
case Inputmask.keyCode.DOWN:
|
||||
this.inputmask.__valueSet.call(this, parseFloat(this.inputmask.unmaskedvalue()) - parseInt(opts.step));
|
||||
$input.trigger("setvalue");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (e.keyCode === Inputmask.keyCode.DELETE || e.keyCode === Inputmask.keyCode.BACKSPACE || e.keyCode === Inputmask.keyCode.BACKSPACE_SAFARI) {
|
||||
if (opts._radixDance === true && !opts.digitsOptional) {
|
||||
var radixPos = $.inArray(opts.radixPoint, buffer);
|
||||
if (radixPos !== -1 && (caretPos < radixPos || (e.keyCode === Inputmask.keyCode.DELETE && caretPos === radixPos))) {
|
||||
if (e.keyCode === Inputmask.keyCode.BACKSPACE || e.keyCode === Inputmask.keyCode.BACKSPACE_SAFARI) {
|
||||
caretPos++;
|
||||
}
|
||||
var bffr = buffer.slice().reverse();
|
||||
bffr.splice(bffr.length - caretPos, 1);
|
||||
$input.trigger("setvalue", [alignDigits(bffr, opts.digits, opts).join(""), caretPos]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"currency": {
|
||||
prefix: "$ ",
|
||||
groupSeparator: ",",
|
||||
alias: "numeric",
|
||||
placeholder: "0",
|
||||
digits: 2,
|
||||
digitsOptional: false
|
||||
},
|
||||
"decimal": {
|
||||
alias: "numeric"
|
||||
},
|
||||
"integer": {
|
||||
alias: "numeric",
|
||||
digits: 0
|
||||
},
|
||||
"percentage": {
|
||||
alias: "integer",
|
||||
min: 0,
|
||||
max: 100,
|
||||
suffix: " %",
|
||||
allowMinus: false
|
||||
},
|
||||
"indianns": { //indian numbering system
|
||||
alias: "numeric",
|
||||
_mask: function (opts) {
|
||||
return "(" + opts.groupSeparator + "99){*|1}(" + opts.groupSeparator + "999){1|1}";
|
||||
},
|
||||
groupSeparator: ",",
|
||||
radixPoint: ".",
|
||||
placeholder: "0",
|
||||
digits: 2,
|
||||
digitsOptional: false
|
||||
}
|
||||
});
|
||||
module.exports = Inputmask;
|
||||
7
vendor/Inputmask/lib/global/window.js
vendored
Normal file
7
vendor/Inputmask/lib/global/window.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
if (typeof define === "function" && define.amd)
|
||||
define(function () {
|
||||
return typeof window !== "undefined" ? window : new (eval("require('jsdom').JSDOM"))("").window;
|
||||
});
|
||||
else if (typeof exports === "object")
|
||||
module.exports = typeof window !== "undefined" ? window : new (eval("require('jsdom').JSDOM"))("").window;
|
||||
|
||||
374
vendor/Inputmask/lib/inputmask.js
vendored
Normal file
374
vendor/Inputmask/lib/inputmask.js
vendored
Normal file
@@ -0,0 +1,374 @@
|
||||
/*
|
||||
* Input Mask Core
|
||||
* http://github.com/RobinHerbots/jquery.inputmask
|
||||
* Copyright (c) Robin Herbots
|
||||
* Licensed under the MIT license
|
||||
*/
|
||||
var $ = require("./dependencyLibs/inputmask.dependencyLib"), window = require("./global/window"),
|
||||
document = window.document,
|
||||
generateMaskSet = require("./maskset").generateMaskSet,
|
||||
analyseMask = require("./maskset").analyseMask,
|
||||
maskScope = require("./maskScope");
|
||||
|
||||
|
||||
function Inputmask(alias, options, internal) {
|
||||
//allow instanciating without new
|
||||
if (!(this instanceof Inputmask)) {
|
||||
return new Inputmask(alias, options, internal);
|
||||
}
|
||||
|
||||
this.el = undefined;
|
||||
this.events = {};
|
||||
this.maskset = undefined;
|
||||
this.refreshValue = false; //indicate a refresh from the inputvalue is needed (form.reset)
|
||||
|
||||
if (internal !== true) {
|
||||
//init options
|
||||
if ($.isPlainObject(alias)) {
|
||||
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);
|
||||
this.isRTL = this.opts.numericInput;
|
||||
}
|
||||
}
|
||||
|
||||
Inputmask.prototype = {
|
||||
dataAttribute: "data-inputmask", //data attribute prefix used for attribute binding
|
||||
//options default
|
||||
defaults: {
|
||||
placeholder: "_",
|
||||
optionalmarker: ["[", "]"],
|
||||
quantifiermarker: ["{", "}"],
|
||||
groupmarker: ["(", ")"],
|
||||
alternatormarker: "|",
|
||||
escapeChar: "\\",
|
||||
mask: null, //needs tobe null instead of undefined as the extend method does not consider props with the undefined value
|
||||
regex: null, //regular expression as a mask
|
||||
oncomplete: $.noop, //executes when the mask is complete
|
||||
onincomplete: $.noop, //executes when the mask is incomplete and focus is lost
|
||||
oncleared: $.noop, //executes when the mask is cleared
|
||||
repeat: 0, //repetitions of the mask: * ~ forever, otherwise specify an integer
|
||||
greedy: false, //true: allocated buffer for the mask and repetitions - false: allocate only if needed
|
||||
autoUnmask: false, //automatically unmask when retrieving the value with $.fn.val or value if the browser supports __lookupGetter__ or getOwnPropertyDescriptor
|
||||
removeMaskOnSubmit: false, //remove the mask before submitting the form.
|
||||
clearMaskOnLostFocus: true,
|
||||
insertMode: true, //insert the input or overwrite the input
|
||||
clearIncomplete: false, //clear the incomplete input on blur
|
||||
alias: null,
|
||||
onKeyDown: $.noop, //callback to implement autocomplete on certain keys for example. args => event, buffer, caretPos, opts
|
||||
onBeforeMask: null, //executes before masking the initial value to allow preprocessing of the initial value. args => initialValue, opts => return processedValue
|
||||
onBeforePaste: function (pastedValue, opts) {
|
||||
return $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(this, pastedValue, opts) : pastedValue;
|
||||
}, //executes before masking the pasted value to allow preprocessing of the pasted value. args => pastedValue, opts => return processedValue
|
||||
onBeforeWrite: null, //executes before writing to the masked element. args => event, opts
|
||||
onUnMask: null, //executes after unmasking to allow postprocessing of the unmaskedvalue. args => maskedValue, unmaskedValue, opts
|
||||
showMaskOnFocus: true, //show the mask-placeholder when the input has focus
|
||||
showMaskOnHover: true, //show the mask-placeholder when hovering the empty input
|
||||
onKeyValidation: $.noop, //executes on every key-press with the result of isValid. Params: key, result, opts
|
||||
skipOptionalPartCharacter: " ", //a character which can be used to skip an optional part of a mask
|
||||
numericInput: false, //numericInput input direction style (input shifts to the left while holding the caret position)
|
||||
rightAlign: false, //align to the right
|
||||
undoOnEscape: true, //pressing escape reverts the value to the value before focus
|
||||
//numeric basic properties
|
||||
radixPoint: "", //".", // | ","
|
||||
_radixDance: false, //dance around the radixPoint
|
||||
groupSeparator: "", //",", // | "."
|
||||
//numeric basic properties
|
||||
keepStatic: null, //try to keep the mask static while typing. Decisions to alter the mask will be posponed if possible - null see auto selection for multi masks
|
||||
positionCaretOnTab: true, //when enabled the caret position is set after the latest valid position on TAB
|
||||
tabThrough: false, //allows for tabbing through the different parts of the masked field
|
||||
supportsInputType: ["text", "tel", "url", "password", "search"], //list with the supported input types
|
||||
//specify keyCodes which should not be considered in the keypress event, otherwise the preventDefault will stop their default behavior especially in FF
|
||||
ignorables: [8, 9, 13, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 0, 229],
|
||||
isComplete: null, //override for isComplete - args => buffer, opts - return true || false
|
||||
preValidation: null, //hook to preValidate the input. Usefull for validating regardless the definition. args => buffer, pos, char, isSelection, opts => return true/false/command object
|
||||
postValidation: null, //hook to postValidate the result from isValid. Usefull for validating the entry as a whole. args => buffer, pos, currentResult, opts => return true/false/json
|
||||
staticDefinitionSymbol: undefined, //specify a definitionSymbol for static content, used to make matches for alternators
|
||||
jitMasking: false, //just in time masking ~ only mask while typing, can n (number), true or false
|
||||
nullable: true, //return nothing instead of the buffertemplate when the user hasn't entered anything.
|
||||
inputEventOnly: false, //dev option - testing inputfallback behavior
|
||||
noValuePatching: false, //disable value property patching
|
||||
positionCaretOnClick: "lvp", //none, lvp (based on the last valid position (default), radixFocus (position caret to radixpoint on initial click), select (select the whole input), ignore (ignore the click and continue the mask)
|
||||
casing: null, //mask-level casing. Options: null, "upper", "lower" or "title" or callback args => elem, test, pos, validPositions return charValue
|
||||
inputmode: "verbatim", //specify the inputmode - already in place for when browsers will support it
|
||||
colorMask: false, //enable css styleable mask
|
||||
disablePredictiveText: false, //disable Predictive Text on mobile devices
|
||||
importDataAttributes: true, //import data-inputmask attributes
|
||||
shiftPositions: true //shift position of the mask entries on entry and deletion.
|
||||
},
|
||||
definitions: {
|
||||
"9": { //\uFF11-\uFF19 #1606
|
||||
validator: "[0-9\uFF11-\uFF19]",
|
||||
definitionSymbol: "*"
|
||||
},
|
||||
"a": { //\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5 #76
|
||||
validator: "[A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
|
||||
definitionSymbol: "*"
|
||||
},
|
||||
"*": {
|
||||
validator: "[0-9\uFF11-\uFF19A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]"
|
||||
}
|
||||
},
|
||||
aliases: {}, //aliases definitions
|
||||
masksCache: {},
|
||||
mask: function (elems) {
|
||||
var that = this;
|
||||
if (typeof elems === "string") {
|
||||
elems = document.getElementById(elems) || document.querySelectorAll(elems);
|
||||
}
|
||||
elems = elems.nodeName ? [elems] : elems;
|
||||
$.each(elems, function (ndx, el) {
|
||||
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.maskset = maskset;
|
||||
|
||||
$.data(el, "_inputmask_opts", scopedOpts);
|
||||
|
||||
maskScope.call(el.inputmask, {
|
||||
"action": "mask"
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
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);
|
||||
return maskScope.call(this, {
|
||||
"action": "unmaskedvalue",
|
||||
"value": value
|
||||
});
|
||||
},
|
||||
remove: function () {
|
||||
return maskScope.call(this, {
|
||||
"action": "remove"
|
||||
});
|
||||
},
|
||||
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 maskScope.call(this, {
|
||||
"action": "getemptymask"
|
||||
});
|
||||
},
|
||||
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 maskScope.call(this, {
|
||||
"action": "isComplete"
|
||||
});
|
||||
},
|
||||
getmetadata: function () { //return mask metadata if exists
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
return maskScope.call(this, {
|
||||
"action": "getmetadata"
|
||||
});
|
||||
},
|
||||
isValid: function (value) {
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
return maskScope.call(this, {
|
||||
"action": "isValid",
|
||||
"value": value
|
||||
});
|
||||
},
|
||||
format: function (value, metadata) {
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
return maskScope.call(this, {
|
||||
"action": "format",
|
||||
"value": value,
|
||||
"metadata": metadata //true/false getmetadata
|
||||
});
|
||||
},
|
||||
setValue: function (value) {
|
||||
if (this.el) {
|
||||
$(this.el).trigger("setvalue", [value]);
|
||||
}
|
||||
},
|
||||
analyseMask: analyseMask,
|
||||
positionColorMask: function (input, template) {
|
||||
input.style.left = template.offsetLeft + "px";
|
||||
}
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function importAttributeOptions(npt, opts, userOptions, dataAttribute) {
|
||||
function importOption(option, optionData) {
|
||||
optionData = optionData !== undefined ? optionData : npt.getAttribute(dataAttribute + "-" + option);
|
||||
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 (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);
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
if (npt.dir === "rtl" || opts.numericInput) {
|
||||
npt.dir = "ltr";
|
||||
npt.removeAttribute("dir");
|
||||
opts.isRTL = true;
|
||||
}
|
||||
|
||||
return Object.keys(userOptions).length;
|
||||
}
|
||||
|
||||
//apply defaults, definitions, aliases
|
||||
Inputmask.extendDefaults = function (options) {
|
||||
$.extend(true, Inputmask.prototype.defaults, options);
|
||||
};
|
||||
Inputmask.extendDefinitions = function (definition) {
|
||||
$.extend(true, Inputmask.prototype.definitions, definition);
|
||||
};
|
||||
Inputmask.extendAliases = function (alias) {
|
||||
$.extend(true, Inputmask.prototype.aliases, alias);
|
||||
};
|
||||
//static fn on inputmask
|
||||
Inputmask.format = function (value, options, metadata) {
|
||||
return Inputmask(options).format(value, metadata);
|
||||
};
|
||||
Inputmask.unmask = function (value, options) {
|
||||
return Inputmask(options).unmaskedvalue(value);
|
||||
};
|
||||
Inputmask.isValid = function (value, options) {
|
||||
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;
|
||||
$.each(elems, function (ndx, 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;
|
||||
$.each(elems, function (ndx, el) {
|
||||
if (el.inputmask) el.inputmask.setValue(value); else $(el).trigger("setvalue", [value]);
|
||||
});
|
||||
};
|
||||
Inputmask.escapeRegex = function (str) {
|
||||
var specials = ["/", ".", "*", "+", "?", "|", "(", ")", "[", "]", "{", "}", "\\", "$", "^"];
|
||||
return str.replace(new RegExp("(\\" + specials.join("|\\") + ")", "gim"), "\\$1");
|
||||
};
|
||||
Inputmask.keyCode = {
|
||||
BACKSPACE: 8,
|
||||
BACKSPACE_SAFARI: 127,
|
||||
DELETE: 46,
|
||||
DOWN: 40,
|
||||
END: 35,
|
||||
ENTER: 13,
|
||||
ESCAPE: 27,
|
||||
HOME: 36,
|
||||
INSERT: 45,
|
||||
LEFT: 37,
|
||||
PAGE_DOWN: 34,
|
||||
PAGE_UP: 33,
|
||||
RIGHT: 39,
|
||||
SPACE: 32,
|
||||
TAB: 9,
|
||||
UP: 38,
|
||||
X: 88,
|
||||
CONTROL: 17
|
||||
};
|
||||
Inputmask.dependencyLib = $;
|
||||
|
||||
//make inputmask available
|
||||
window.Inputmask = Inputmask;
|
||||
module.exports = Inputmask;
|
||||
79
vendor/Inputmask/lib/jquery.inputmask.js
vendored
Normal file
79
vendor/Inputmask/lib/jquery.inputmask.js
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Input Mask plugin for jquery
|
||||
* http://github.com/RobinHerbots/jquery.inputmask
|
||||
* Copyright (c) Robin Herbots
|
||||
* Licensed under the MIT license
|
||||
*/
|
||||
var $ = require("jquery"), Inputmask = require("./inputmask");
|
||||
if ($.fn.inputmask === undefined) {
|
||||
//jquery plugin
|
||||
$.fn.inputmask = function (fn, options) {
|
||||
var nptmask, input = this[0];
|
||||
if (options === undefined) options = {};
|
||||
if (typeof fn === "string") {
|
||||
switch (fn) {
|
||||
case "unmaskedvalue":
|
||||
return input && input.inputmask ? input.inputmask.unmaskedvalue() : $(input).val();
|
||||
case "remove":
|
||||
return this.each(function () {
|
||||
if (this.inputmask) this.inputmask.remove();
|
||||
});
|
||||
case "getemptymask":
|
||||
return input && input.inputmask ? input.inputmask.getemptymask() : "";
|
||||
case "hasMaskedValue": //check whether the returned value is masked or not; currently only works reliable when using jquery.val fn to retrieve the value
|
||||
return input && input.inputmask ? input.inputmask.hasMaskedValue() : false;
|
||||
case "isComplete":
|
||||
return input && input.inputmask ? input.inputmask.isComplete() : true;
|
||||
case "getmetadata": //return mask metadata if exists
|
||||
return input && input.inputmask ? input.inputmask.getmetadata() : undefined;
|
||||
case "setvalue":
|
||||
Inputmask.setValue(input, options);
|
||||
break;
|
||||
case "option":
|
||||
if (typeof options === "string") {
|
||||
if (input && input.inputmask !== undefined) {
|
||||
return input.inputmask.option(options);
|
||||
}
|
||||
} else {
|
||||
return this.each(function () {
|
||||
if (this.inputmask !== undefined) {
|
||||
return this.inputmask.option(options);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
options.alias = fn;
|
||||
nptmask = new Inputmask(options);
|
||||
return this.each(function () {
|
||||
nptmask.mask(this);
|
||||
});
|
||||
}
|
||||
} else if (Array.isArray(fn)) {
|
||||
options.alias = fn;
|
||||
nptmask = new Inputmask(options);
|
||||
return this.each(function () {
|
||||
nptmask.mask(this);
|
||||
});
|
||||
} else if (typeof fn == "object") {
|
||||
nptmask = new Inputmask(fn);
|
||||
if (fn.mask === undefined && fn.alias === undefined) {
|
||||
return this.each(function () {
|
||||
if (this.inputmask !== undefined) {
|
||||
return this.inputmask.option(fn);
|
||||
} else nptmask.mask(this);
|
||||
});
|
||||
} else {
|
||||
return this.each(function () {
|
||||
nptmask.mask(this);
|
||||
});
|
||||
}
|
||||
} else if (fn === undefined) {
|
||||
//look for data-inputmask atributes
|
||||
return this.each(function () {
|
||||
nptmask = new Inputmask(options);
|
||||
nptmask.mask(this);
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
2527
vendor/Inputmask/lib/maskScope.js
vendored
Normal file
2527
vendor/Inputmask/lib/maskScope.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
471
vendor/Inputmask/lib/maskset.js
vendored
Normal file
471
vendor/Inputmask/lib/maskset.js
vendored
Normal file
@@ -0,0 +1,471 @@
|
||||
var $ = require("./dependencyLibs/inputmask.dependencyLib");
|
||||
|
||||
function generateMaskSet(opts, nocache) {
|
||||
var ms;
|
||||
|
||||
function generateMask(mask, metadata, opts) {
|
||||
var regexMask = false;
|
||||
if (mask === null || mask === "") {
|
||||
regexMask = opts.regex !== null;
|
||||
if (regexMask) {
|
||||
mask = opts.regex;
|
||||
mask = mask.replace(/^(\^)(.*)(\$)$/, "$2");
|
||||
} else {
|
||||
regexMask = true;
|
||||
mask = ".*";
|
||||
}
|
||||
}
|
||||
if (mask.length === 1 && opts.greedy === false && opts.repeat !== 0) {
|
||||
opts.placeholder = "";
|
||||
} //hide placeholder with single non-greedy mask
|
||||
if (opts.repeat > 0 || opts.repeat === "*" || opts.repeat === "+") {
|
||||
var repeatStart = opts.repeat === "*" ? 0 : (opts.repeat === "+" ? 1 : opts.repeat);
|
||||
mask = opts.groupmarker[0] + mask + opts.groupmarker[1] + opts.quantifiermarker[0] + repeatStart + "," + opts.repeat + opts.quantifiermarker[1];
|
||||
}
|
||||
|
||||
// console.log(mask);
|
||||
var masksetDefinition, maskdefKey;
|
||||
maskdefKey = regexMask ? "regex_" + opts.regex : opts.numericInput ? mask.split("").reverse().join("") : mask;
|
||||
if (opts.keepStatic !== false) { //keepstatic modifies the output from the testdefinitions ~ so differentiate in the maskcache
|
||||
maskdefKey = "ks_" + maskdefKey;
|
||||
}
|
||||
|
||||
if (Inputmask.prototype.masksCache[maskdefKey] === undefined || nocache === true) {
|
||||
masksetDefinition = {
|
||||
"mask": mask,
|
||||
"maskToken": Inputmask.prototype.analyseMask(mask, regexMask, opts),
|
||||
"validPositions": {},
|
||||
"_buffer": undefined,
|
||||
"buffer": undefined,
|
||||
"tests": {},
|
||||
"excludes": {}, //excluded alternations
|
||||
"metadata": metadata,
|
||||
"maskLength": undefined,
|
||||
"jitOffset": {}
|
||||
};
|
||||
if (nocache !== true) {
|
||||
Inputmask.prototype.masksCache[maskdefKey] = masksetDefinition;
|
||||
masksetDefinition = $.extend(true, {}, Inputmask.prototype.masksCache[maskdefKey]);
|
||||
}
|
||||
} else {
|
||||
masksetDefinition = $.extend(true, {}, Inputmask.prototype.masksCache[maskdefKey]);
|
||||
}
|
||||
|
||||
return masksetDefinition;
|
||||
}
|
||||
|
||||
if ($.isFunction(opts.mask)) { //allow mask to be a preprocessing fn - should return a valid mask
|
||||
opts.mask = opts.mask(opts);
|
||||
}
|
||||
if ($.isArray(opts.mask)) {
|
||||
if (opts.mask.length > 1) {
|
||||
if (opts.keepStatic === null) { //enable by default when passing multiple masks when the option is not explicitly specified
|
||||
opts.keepStatic = "auto";
|
||||
for (var i = 0; i < opts.mask.length; i++) {
|
||||
if (opts.mask[i].charAt(0) !== opts.mask[0].charAt(0)) {
|
||||
opts.keepStatic = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
var altMask = opts.groupmarker[0];
|
||||
$.each(opts.isRTL ? opts.mask.reverse() : opts.mask, function (ndx, msk) {
|
||||
if (altMask.length > 1) {
|
||||
altMask += opts.groupmarker[1] + opts.alternatormarker + opts.groupmarker[0];
|
||||
}
|
||||
if (msk.mask !== undefined && !$.isFunction(msk.mask)) {
|
||||
altMask += msk.mask;
|
||||
} else {
|
||||
altMask += msk;
|
||||
}
|
||||
});
|
||||
altMask += opts.groupmarker[1];
|
||||
// console.log(altMask);
|
||||
return generateMask(altMask, opts.mask, opts);
|
||||
} else {
|
||||
opts.mask = opts.mask.pop();
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.mask && opts.mask.mask !== undefined && !$.isFunction(opts.mask.mask)) {
|
||||
ms = generateMask(opts.mask.mask, opts.mask, opts);
|
||||
} else {
|
||||
ms = generateMask(opts.mask, opts.mask, opts);
|
||||
}
|
||||
|
||||
return ms;
|
||||
}
|
||||
|
||||
function analyseMask(mask, regexMask, opts) {
|
||||
var tokenizer = /(?:[?*+]|\{[0-9+*]+(?:,[0-9+*]*)?(?:\|[0-9+*]*)?\})|[^.?*+^${[]()|\\]+|./g,
|
||||
//Thx to https://github.com/slevithan/regex-colorizer for the regexTokenizer regex
|
||||
regexTokenizer = /\[\^?]?(?:[^\\\]]+|\\[\S\s]?)*]?|\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9][0-9]*|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|c[A-Za-z]|[\S\s]?)|\((?:\?[:=!]?)?|(?:[?*+]|\{[0-9]+(?:,[0-9]*)?\})\??|[^.?*+^${[()|\\]+|./g,
|
||||
escaped = false,
|
||||
currentToken = new MaskToken(),
|
||||
match,
|
||||
m,
|
||||
openenings = [],
|
||||
maskTokens = [],
|
||||
openingToken,
|
||||
currentOpeningToken,
|
||||
alternator,
|
||||
lastMatch,
|
||||
closeRegexGroup = false;
|
||||
|
||||
function MaskToken(isGroup, isOptional, isQuantifier, isAlternator) {
|
||||
this.matches = [];
|
||||
this.openGroup = isGroup || false;
|
||||
this.alternatorGroup = false;
|
||||
this.isGroup = isGroup || false;
|
||||
this.isOptional = isOptional || false;
|
||||
this.isQuantifier = isQuantifier || false;
|
||||
this.isAlternator = isAlternator || false;
|
||||
this.quantifier = {
|
||||
min: 1,
|
||||
max: 1
|
||||
};
|
||||
}
|
||||
|
||||
//test definition => {fn: RegExp/function, static: true/false optionality: bool, newBlockMarker: bool, casing: null/upper/lower, def: definitionSymbol, placeholder: placeholder, mask: real maskDefinition}
|
||||
function insertTestDefinition(mtoken, element, position) {
|
||||
position = position !== undefined ? position : mtoken.matches.length;
|
||||
var prevMatch = mtoken.matches[position - 1];
|
||||
if (regexMask) {
|
||||
if (element.indexOf("[") === 0 || (escaped && /\\d|\\s|\\w]/i.test(element)) || element === ".") {
|
||||
mtoken.matches.splice(position++, 0, {
|
||||
fn: new RegExp(element, opts.casing ? "i" : ""),
|
||||
static: false,
|
||||
optionality: false,
|
||||
newBlockMarker: prevMatch === undefined ? "master" : prevMatch.def !== element,
|
||||
casing: null,
|
||||
def: element,
|
||||
placeholder: undefined,
|
||||
nativeDef: element
|
||||
});
|
||||
} else {
|
||||
if (escaped) element = element[element.length - 1];
|
||||
$.each(element.split(""), function (ndx, lmnt) {
|
||||
prevMatch = mtoken.matches[position - 1];
|
||||
mtoken.matches.splice(position++, 0, {
|
||||
fn: /[a-z]/i.test((opts.staticDefinitionSymbol || lmnt)) ? new RegExp("[" + (opts.staticDefinitionSymbol || lmnt) + "]", opts.casing ? "i" : "") : null,
|
||||
static: true,
|
||||
optionality: false,
|
||||
newBlockMarker: prevMatch === undefined ? "master" : (prevMatch.def !== lmnt && prevMatch.static !== true),
|
||||
casing: null,
|
||||
def: opts.staticDefinitionSymbol || lmnt,
|
||||
placeholder: opts.staticDefinitionSymbol !== undefined ? lmnt : undefined,
|
||||
nativeDef: (escaped ? "'" : "") + lmnt
|
||||
});
|
||||
});
|
||||
}
|
||||
escaped = false;
|
||||
} else {
|
||||
var maskdef = (opts.definitions ? opts.definitions[element] : undefined) || Inputmask.prototype.definitions[element];
|
||||
if (maskdef && !escaped) {
|
||||
mtoken.matches.splice(position++, 0, {
|
||||
fn: maskdef.validator ? typeof maskdef.validator == "string" ? new RegExp(maskdef.validator, opts.casing ? "i" : "") : new function () {
|
||||
this.test = maskdef.validator;
|
||||
} : new RegExp("."),
|
||||
static: false,
|
||||
optionality: false,
|
||||
newBlockMarker: prevMatch === undefined ? "master" : prevMatch.def !== (maskdef.definitionSymbol || element),
|
||||
casing: maskdef.casing,
|
||||
def: maskdef.definitionSymbol || element,
|
||||
placeholder: maskdef.placeholder,
|
||||
nativeDef: element
|
||||
});
|
||||
} else {
|
||||
mtoken.matches.splice(position++, 0, {
|
||||
fn: /[a-z]/i.test((opts.staticDefinitionSymbol || element)) ? new RegExp("[" + (opts.staticDefinitionSymbol || element) + "]", opts.casing ? "i" : "") : null,
|
||||
static: true,
|
||||
optionality: false,
|
||||
newBlockMarker: prevMatch === undefined ? "master" : (prevMatch.def !== element && prevMatch.static !== true),
|
||||
casing: null,
|
||||
def: opts.staticDefinitionSymbol || element,
|
||||
placeholder: opts.staticDefinitionSymbol !== undefined ? element : undefined,
|
||||
nativeDef: (escaped ? "'" : "") + element
|
||||
});
|
||||
escaped = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function verifyGroupMarker(maskToken) {
|
||||
if (maskToken && maskToken.matches) {
|
||||
$.each(maskToken.matches, function (ndx, token) {
|
||||
var nextToken = maskToken.matches[ndx + 1];
|
||||
if ((nextToken === undefined || (nextToken.matches === undefined || nextToken.isQuantifier === false)) && token && token.isGroup) { //this is not a group but a normal mask => convert
|
||||
token.isGroup = false;
|
||||
if (!regexMask) {
|
||||
insertTestDefinition(token, opts.groupmarker[0], 0);
|
||||
if (token.openGroup !== true) {
|
||||
insertTestDefinition(token, opts.groupmarker[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
verifyGroupMarker(token);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function defaultCase() {
|
||||
if (openenings.length > 0) {
|
||||
currentOpeningToken = openenings[openenings.length - 1];
|
||||
insertTestDefinition(currentOpeningToken, m);
|
||||
if (currentOpeningToken.isAlternator) { //handle alternator a | b case
|
||||
alternator = openenings.pop();
|
||||
for (var mndx = 0; mndx < alternator.matches.length; mndx++) {
|
||||
if (alternator.matches[mndx].isGroup) alternator.matches[mndx].isGroup = false; //don't mark alternate groups as group
|
||||
}
|
||||
if (openenings.length > 0) {
|
||||
currentOpeningToken = openenings[openenings.length - 1];
|
||||
currentOpeningToken.matches.push(alternator);
|
||||
} else {
|
||||
currentToken.matches.push(alternator);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
insertTestDefinition(currentToken, m);
|
||||
}
|
||||
}
|
||||
|
||||
function reverseTokens(maskToken) {
|
||||
function reverseStatic(st) {
|
||||
if (st === opts.optionalmarker[0]) {
|
||||
st = opts.optionalmarker[1];
|
||||
} else if (st === opts.optionalmarker[1]) {
|
||||
st = opts.optionalmarker[0];
|
||||
} else if (st === opts.groupmarker[0]) {
|
||||
st = opts.groupmarker[1];
|
||||
} else if (st === opts.groupmarker[1]) st = opts.groupmarker[0];
|
||||
|
||||
return st;
|
||||
}
|
||||
|
||||
maskToken.matches = maskToken.matches.reverse();
|
||||
for (var match in maskToken.matches) {
|
||||
if (maskToken.matches.hasOwnProperty(match)) {
|
||||
var intMatch = parseInt(match);
|
||||
if (maskToken.matches[match].isQuantifier && maskToken.matches[intMatch + 1] && maskToken.matches[intMatch + 1].isGroup) { //reposition quantifier
|
||||
var qt = maskToken.matches[match];
|
||||
maskToken.matches.splice(match, 1);
|
||||
maskToken.matches.splice(intMatch + 1, 0, qt);
|
||||
}
|
||||
if (maskToken.matches[match].matches !== undefined) {
|
||||
maskToken.matches[match] = reverseTokens(maskToken.matches[match]);
|
||||
} else {
|
||||
maskToken.matches[match] = reverseStatic(maskToken.matches[match]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return maskToken;
|
||||
}
|
||||
|
||||
function groupify(matches) {
|
||||
var groupToken = new MaskToken(true);
|
||||
groupToken.openGroup = false;
|
||||
groupToken.matches = matches;
|
||||
return groupToken;
|
||||
}
|
||||
|
||||
function closeGroup() {
|
||||
// Group closing
|
||||
openingToken = openenings.pop();
|
||||
openingToken.openGroup = false; //mark group as complete
|
||||
if (openingToken !== undefined) {
|
||||
if (openenings.length > 0) {
|
||||
currentOpeningToken = openenings[openenings.length - 1];
|
||||
currentOpeningToken.matches.push(openingToken);
|
||||
if (currentOpeningToken.isAlternator) { //handle alternator (a) | (b) case
|
||||
alternator = openenings.pop();
|
||||
for (var mndx = 0; mndx < alternator.matches.length; mndx++) {
|
||||
alternator.matches[mndx].isGroup = false; //don't mark alternate groups as group
|
||||
alternator.matches[mndx].alternatorGroup = false;
|
||||
}
|
||||
if (openenings.length > 0) {
|
||||
currentOpeningToken = openenings[openenings.length - 1];
|
||||
currentOpeningToken.matches.push(alternator);
|
||||
} else {
|
||||
currentToken.matches.push(alternator);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
currentToken.matches.push(openingToken);
|
||||
}
|
||||
} else {
|
||||
defaultCase();
|
||||
}
|
||||
}
|
||||
|
||||
function groupQuantifier(matches) {
|
||||
var lastMatch = matches.pop();
|
||||
if (lastMatch.isQuantifier) {
|
||||
lastMatch = groupify([matches.pop(), lastMatch]);
|
||||
}
|
||||
return lastMatch;
|
||||
}
|
||||
|
||||
if (regexMask) {
|
||||
opts.optionalmarker[0] = undefined;
|
||||
opts.optionalmarker[1] = undefined;
|
||||
}
|
||||
while ((match = regexMask ? regexTokenizer.exec(mask) : tokenizer.exec(mask))) {
|
||||
m = match[0];
|
||||
|
||||
if (regexMask) {
|
||||
switch (m.charAt(0)) {
|
||||
//Quantifier
|
||||
case "?":
|
||||
m = "{0,1}";
|
||||
break;
|
||||
case "+":
|
||||
case "*":
|
||||
m = "{" + m + "}";
|
||||
break;
|
||||
case "|":
|
||||
//regex mask alternator ex: [01][0-9]|2[0-3] => ([01][0-9]|2[0-3])
|
||||
if (openenings.length === 0) { //wrap the mask in a group to form a regex alternator ([01][0-9]|2[0-3])
|
||||
var altRegexGroup = groupify(currentToken.matches);
|
||||
altRegexGroup.openGroup = true;
|
||||
openenings.push(altRegexGroup);
|
||||
currentToken.matches = [];
|
||||
closeRegexGroup = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (escaped) {
|
||||
defaultCase();
|
||||
continue;
|
||||
}
|
||||
switch (m.charAt(0)) {
|
||||
case "(?=": //lookahead
|
||||
break;
|
||||
case "(?!": //negative lookahead
|
||||
break;
|
||||
case "(?<=": //lookbehind
|
||||
break;
|
||||
case "(?<!": //negative lookbehind
|
||||
break;
|
||||
case opts.escapeChar:
|
||||
escaped = true;
|
||||
if (regexMask) {
|
||||
defaultCase();
|
||||
}
|
||||
break;
|
||||
// optional closing
|
||||
case opts.optionalmarker[1]:
|
||||
case opts.groupmarker[1]:
|
||||
closeGroup();
|
||||
break;
|
||||
case opts.optionalmarker[0]:
|
||||
// optional opening
|
||||
openenings.push(new MaskToken(false, true));
|
||||
break;
|
||||
case opts.groupmarker[0]:
|
||||
// Group opening
|
||||
openenings.push(new MaskToken(true));
|
||||
break;
|
||||
case opts.quantifiermarker[0]:
|
||||
//Quantifier
|
||||
var quantifier = new MaskToken(false, false, true);
|
||||
|
||||
m = m.replace(/[{}]/g, "");
|
||||
var mqj = m.split("|"),
|
||||
mq = mqj[0].split(","),
|
||||
mq0 = isNaN(mq[0]) ? mq[0] : parseInt(mq[0]),
|
||||
mq1 = mq.length === 1 ? mq0 : (isNaN(mq[1]) ? mq[1] : parseInt(mq[1]));
|
||||
if (mq0 === "*" || mq0 === "+") {
|
||||
mq0 = mq1 === "*" ? 0 : 1;
|
||||
}
|
||||
quantifier.quantifier = {
|
||||
min: mq0,
|
||||
max: mq1,
|
||||
jit: mqj[1]
|
||||
};
|
||||
var matches = openenings.length > 0 ? openenings[openenings.length - 1].matches : currentToken.matches;
|
||||
match = matches.pop();
|
||||
if (match.isAlternator) { //handle quantifier in an alternation [0-9]{2}|[0-9]{3}
|
||||
matches.push(match); //push back alternator
|
||||
matches = match.matches; //remap target matches
|
||||
var groupToken = new MaskToken(true);
|
||||
var tmpMatch = matches.pop();
|
||||
matches.push(groupToken); //push the group
|
||||
matches = groupToken.matches;
|
||||
match = tmpMatch;
|
||||
}
|
||||
if (!match.isGroup) {
|
||||
// if (regexMask && match.fn === null) { //why is this needed???
|
||||
// if (match.def === ".") match.fn = new RegExp(match.def, opts.casing ? "i" : "");
|
||||
// }
|
||||
|
||||
match = groupify([match]);
|
||||
}
|
||||
matches.push(match);
|
||||
matches.push(quantifier);
|
||||
|
||||
break;
|
||||
case opts.alternatormarker:
|
||||
|
||||
|
||||
if (openenings.length > 0) {
|
||||
currentOpeningToken = openenings[openenings.length - 1];
|
||||
var subToken = currentOpeningToken.matches[currentOpeningToken.matches.length - 1];
|
||||
if (currentOpeningToken.openGroup && //regexp alt syntax
|
||||
(subToken.matches === undefined || (subToken.isGroup === false && subToken.isAlternator === false))) { //alternations within group
|
||||
lastMatch = openenings.pop();
|
||||
} else {
|
||||
lastMatch = groupQuantifier(currentOpeningToken.matches);
|
||||
}
|
||||
} else {
|
||||
lastMatch = groupQuantifier(currentToken.matches);
|
||||
}
|
||||
if (lastMatch.isAlternator) {
|
||||
openenings.push(lastMatch);
|
||||
} else {
|
||||
if (lastMatch.alternatorGroup) {
|
||||
alternator = openenings.pop();
|
||||
lastMatch.alternatorGroup = false;
|
||||
} else {
|
||||
alternator = new MaskToken(false, false, false, true);
|
||||
}
|
||||
alternator.matches.push(lastMatch);
|
||||
openenings.push(alternator);
|
||||
if (lastMatch.openGroup) { //regexp alt syntax
|
||||
lastMatch.openGroup = false;
|
||||
var alternatorGroup = new MaskToken(true);
|
||||
alternatorGroup.alternatorGroup = true;
|
||||
openenings.push(alternatorGroup);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
defaultCase();
|
||||
}
|
||||
}
|
||||
|
||||
if (closeRegexGroup) closeGroup();
|
||||
|
||||
while (openenings.length > 0) {
|
||||
openingToken = openenings.pop();
|
||||
currentToken.matches.push(openingToken);
|
||||
}
|
||||
if (currentToken.matches.length > 0) {
|
||||
verifyGroupMarker(currentToken);
|
||||
maskTokens.push(currentToken);
|
||||
}
|
||||
|
||||
if (opts.numericInput || opts.isRTL) {
|
||||
reverseTokens(maskTokens[0]);
|
||||
}
|
||||
// console.log(JSON.stringify(maskTokens));
|
||||
return maskTokens;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
generateMaskSet: generateMaskSet,
|
||||
analyseMask: analyseMask
|
||||
};
|
||||
Reference in New Issue
Block a user