1/*! 2* jquery.inputmask.bundle.js 3* https://github.com/RobinHerbots/Inputmask 4* Copyright (c) 2010 - 2018 Robin Herbots 5* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php) 6* Version: 4.0.3-beta.3 7*/ 8 9(function(modules) { 10 var installedModules = {}; 11 function __webpack_require__(moduleId) { 12 if (installedModules[moduleId]) { 13 return installedModules[moduleId].exports; 14 } 15 var module = installedModules[moduleId] = { 16 i: moduleId, 17 l: false, 18 exports: {} 19 }; 20 modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 module.l = true; 22 return module.exports; 23 } 24 __webpack_require__.m = modules; 25 __webpack_require__.c = installedModules; 26 __webpack_require__.d = function(exports, name, getter) { 27 if (!__webpack_require__.o(exports, name)) { 28 Object.defineProperty(exports, name, { 29 enumerable: true, 30 get: getter 31 }); 32 } 33 }; 34 __webpack_require__.r = function(exports) { 35 if (typeof Symbol !== "undefined" && Symbol.toStringTag) { 36 Object.defineProperty(exports, Symbol.toStringTag, { 37 value: "Module" 38 }); 39 } 40 Object.defineProperty(exports, "__esModule", { 41 value: true 42 }); 43 }; 44 __webpack_require__.t = function(value, mode) { 45 if (mode & 1) value = __webpack_require__(value); 46 if (mode & 8) return value; 47 if (mode & 4 && typeof value === "object" && value && value.__esModule) return value; 48 var ns = Object.create(null); 49 __webpack_require__.r(ns); 50 Object.defineProperty(ns, "default", { 51 enumerable: true, 52 value: value 53 }); 54 if (mode & 2 && typeof value != "string") for (var key in value) __webpack_require__.d(ns, key, function(key) { 55 return value[key]; 56 }.bind(null, key)); 57 return ns; 58 }; 59 __webpack_require__.n = function(module) { 60 var getter = module && module.__esModule ? function getDefault() { 61 return module["default"]; 62 } : function getModuleExports() { 63 return module; 64 }; 65 __webpack_require__.d(getter, "a", getter); 66 return getter; 67 }; 68 __webpack_require__.o = function(object, property) { 69 return Object.prototype.hasOwnProperty.call(object, property); 70 }; 71 __webpack_require__.p = ""; 72 return __webpack_require__(__webpack_require__.s = 0); 73})([ function(module, exports, __webpack_require__) { 74 "use strict"; 75 __webpack_require__(1); 76 __webpack_require__(6); 77 __webpack_require__(7); 78 var _inputmask = __webpack_require__(2); 79 var _inputmask2 = _interopRequireDefault(_inputmask); 80 var _inputmask3 = __webpack_require__(3); 81 var _inputmask4 = _interopRequireDefault(_inputmask3); 82 var _jquery = __webpack_require__(4); 83 var _jquery2 = _interopRequireDefault(_jquery); 84 function _interopRequireDefault(obj) { 85 return obj && obj.__esModule ? obj : { 86 default: obj 87 }; 88 } 89 if (_inputmask4.default === _jquery2.default) { 90 __webpack_require__(8); 91 } 92 window.Inputmask = _inputmask2.default; 93}, function(module, exports, __webpack_require__) { 94 "use strict"; 95 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__; 96 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) { 97 return typeof obj; 98 } : function(obj) { 99 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 100 }; 101 (function(factory) { 102 if (true) { 103 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(2) ], __WEBPACK_AMD_DEFINE_FACTORY__ = factory, 104 __WEBPACK_AMD_DEFINE_RESULT__ = typeof __WEBPACK_AMD_DEFINE_FACTORY__ === "function" ? __WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__) : __WEBPACK_AMD_DEFINE_FACTORY__, 105 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 106 } else {} 107 })(function(Inputmask) { 108 Inputmask.extendDefinitions({ 109 A: { 110 validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]", 111 casing: "upper" 112 }, 113 "&": { 114 validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]", 115 casing: "upper" 116 }, 117 "#": { 118 validator: "[0-9A-Fa-f]", 119 casing: "upper" 120 } 121 }); 122 Inputmask.extendAliases({ 123 cssunit: { 124 regex: "[+-]?[0-9]+\\.?([0-9]+)?(px|em|rem|ex|%|in|cm|mm|pt|pc)" 125 }, 126 url: { 127 regex: "(https?|ftp)://.*", 128 autoUnmask: false 129 }, 130 ip: { 131 mask: "i[i[i]].i[i[i]].i[i[i]].i[i[i]]", 132 definitions: { 133 i: { 134 validator: function validator(chrs, maskset, pos, strict, opts) { 135 if (pos - 1 > -1 && maskset.buffer[pos - 1] !== ".") { 136 chrs = maskset.buffer[pos - 1] + chrs; 137 if (pos - 2 > -1 && maskset.buffer[pos - 2] !== ".") { 138 chrs = maskset.buffer[pos - 2] + chrs; 139 } else chrs = "0" + chrs; 140 } else chrs = "00" + chrs; 141 return new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]").test(chrs); 142 } 143 } 144 }, 145 onUnMask: function onUnMask(maskedValue, unmaskedValue, opts) { 146 return maskedValue; 147 }, 148 inputmode: "numeric" 149 }, 150 email: { 151 mask: "*{1,64}[.*{1,64}][.*{1,64}][.*{1,63}]@-{1,63}.-{1,63}[.-{1,63}][.-{1,63}]",
152 greedy: false, 153 casing: "lower", 154 onBeforePaste: function onBeforePaste(pastedValue, opts) { 155 pastedValue = pastedValue.toLowerCase(); 156 return pastedValue.replace("mailto:", ""); 157 }, 158 definitions: { 159 "*": { 160 validator: "[0-9\uff11-\uff19A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5!#$%&'*+/=?^_`{|}~-]" 161 }, 162 "-": { 163 validator: "[0-9A-Za-z-]" 164 } 165 }, 166 onUnMask: function onUnMask(maskedValue, unmaskedValue, opts) { 167 return maskedValue; 168 }, 169 inputmode: "email" 170 }, 171 mac: { 172 mask: "##:##:##:##:##:##" 173 }, 174 vin: { 175 mask: "V{13}9{4}", 176 definitions: { 177 V: { 178 validator: "[A-HJ-NPR-Za-hj-npr-z\\d]", 179 casing: "upper" 180 } 181 }, 182 clearIncomplete: true, 183 autoUnmask: true 184 } 185 }); 186 return Inputmask; 187 }); 188}, function(module, exports, __webpack_require__) { 189 "use strict"; 190 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__; 191 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) { 192 return typeof obj; 193 } : function(obj) { 194 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 195 }; 196 (function(factory) { 197 if (true) { 198 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(3), __webpack_require__(5) ], 199 __WEBPACK_AMD_DEFINE_FACTORY__ = factory, __WEBPACK_AMD_DEFINE_RESULT__ = typeof __WEBPACK_AMD_DEFINE_FACTORY__ === "function" ? __WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__) : __WEBPACK_AMD_DEFINE_FACTORY__, 200 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 201 } else {} 202 })(function($, window, undefined) { 203 var document = window.document, ua = navigator.userAgent, ie = ua.indexOf("MSIE ") > 0 || ua.indexOf("Trident/") > 0, mobile = isInputEventSupported("touchstart"), iemobile = /iemobile/i.test(ua), iphone = /iphone/i.test(ua) && !iemobile; 204 function Inputmask(alias, options, internal) { 205 if (!(this instanceof Inputmask)) { 206 return new Inputmask(alias, options, internal); 207 } 208 this.el = undefined; 209 this.events = {}; 210 this.maskset = undefined; 211 this.refreshValue = false; 212 if (internal !== true) { 213 if ($.isPlainObject(alias)) { 214 options = alias; 215 } else { 216 options = options || {}; 217 if (alias) options.alias = alias; 218 } 219 this.opts = $.extend(true, {}, this.defaults, options); 220 this.noMasksCache = options && options.definitions !== undefined; 221 this.userOptions = options || {}; 222 this.isRTL = this.opts.numericInput; 223 resolveAlias(this.opts.alias, options, this.opts); 224 } 225 } 226 Inputmask.prototype = { 227 dataAttribute: "data-inputmask", 228 defaults: { 229 placeholder: "_", 230 optionalmarker: [ "[", "]" ], 231 quantifiermarker: [ "{", "}" ], 232 groupmarker: [ "(", ")" ], 233 alternatormarker: "|", 234 escapeChar: "\\", 235 mask: null, 236 regex: null, 237 oncomplete: $.noop, 238 onincomplete: $.noop, 239 oncleared: $.noop, 240 repeat: 0, 241 greedy: false, 242 autoUnmask: false, 243 removeMaskOnSubmit: false, 244 clearMaskOnLostFocus: true, 245 insertMode: true, 246 clearIncomplete: false, 247 alias: null, 248 onKeyDown: $.noop, 249 onBeforeMask: null, 250 onBeforePaste: function onBeforePaste(pastedValue, opts) { 251 return $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(this, pastedValue, opts) : pastedValue; 252 }, 253 onBeforeWrite: null, 254 onUnMask: null, 255 showMaskOnFocus: true, 256 showMaskOnHover: true, 257 onKeyValidation: $.noop, 258 skipOptionalPartCharacter: " ", 259 numericInput: false, 260 rightAlign: false, 261 undoOnEscape: true, 262 radixPoint: "", 263 _radixDance: false, 264 groupSeparator: "", 265 keepStatic: null, 266 positionCaretOnTab: true, 267 tabThrough: false, 268 supportsInputType: [ "text", "tel", "password", "search" ], 269 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 ], 270 isComplete: null, 271 preValidation: null, 272 postValidation: null, 273 staticDefinitionSymbol: undefined, 274 jitMasking: false, 275 nullable: true, 276 inputEventOnly: false, 277 noValuePatching: false, 278 positionCaretOnClick: "lvp", 279 casing: null, 280 inputmode: "verbatim", 281 colorMask: false, 282 disablePredictiveText: false, 283 importDataAttributes: true, 284 shiftPositions: true 285 }, 286 definitions: { 287 9: { 288 validator: "[0-9\uff11-\uff19]", 289 definitionSymbol: "*" 290 }, 291 a: { 292 validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]", 293 definitionSymbol: "*" 294 }, 295 "*": { 296 validator: "[0-9\uff11-\uff19A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]" 297 } 298 }, 299 aliases: {}, 300 masksCache: {}, 301 mask: function mask(elems) { 302 var that = this; 303 function importAttributeOptions(npt, opts, userOptions, dataAttribute) { 304 if (opts.importDataAttributes === true) { 305 var importOption = function importOption(option, optionData) { 306 optionData = optionData !== undefined ? optionData : npt.getAttribute(dataAttribute + "-" + option); 307 if (optionData !== null) { 308 if (typeof optionData === "string") { 309 if (option.indexOf("on") === 0) optionData = window[optionData];
309 else if (optionData === "false") optionData = false; else if (optionData === "true") optionData = true; 310 } 311 userOptions[option] = optionData; 312 } 313 }; 314 var attrOptions = npt.getAttribute(dataAttribute), option, dataoptions, optionData, p; 315 if (attrOptions && attrOptions !== "") { 316 attrOptions = attrOptions.replace(/'/g, '"'); 317 dataoptions = JSON.parse("{" + attrOptions + "}"); 318 } 319 if (dataoptions) { 320 optionData = undefined; 321 for (p in dataoptions) { 322 if (p.toLowerCase() === "alias") { 323 optionData = dataoptions[p]; 324 break; 325 } 326 } 327 } 328 importOption("alias", optionData); 329 if (userOptions.alias) { 330 resolveAlias(userOptions.alias, userOptions, opts); 331 } 332 for (option in opts) { 333 if (dataoptions) { 334 optionData = undefined; 335 for (p in dataoptions) { 336 if (p.toLowerCase() === option.toLowerCase()) { 337 optionData = dataoptions[p]; 338 break; 339 } 340 } 341 } 342 importOption(option, optionData); 343 } 344 } 345 $.extend(true, opts, userOptions); 346 if (npt.dir === "rtl" || opts.rightAlign) { 347 npt.style.textAlign = "right"; 348 } 349 if (npt.dir === "rtl" || opts.numericInput) { 350 npt.dir = "ltr"; 351 npt.removeAttribute("dir"); 352 opts.isRTL = true; 353 } 354 return Object.keys(userOptions).length; 355 } 356 if (typeof elems === "string") { 357 elems = document.getElementById(elems) || document.querySelectorAll(elems); 358 } 359 elems = elems.nodeName ? [ elems ] : elems; 360 $.each(elems, function(ndx, el) { 361 var scopedOpts = $.extend(true, {}, that.opts); 362 if (importAttributeOptions(el, scopedOpts, $.extend(true, {}, that.userOptions), that.dataAttribute)) { 363 var maskset = generateMaskSet(scopedOpts, that.noMasksCache); 364 if (maskset !== undefined) { 365 if (el.inputmask !== undefined) { 366 el.inputmask.opts.autoUnmask = true; 367 el.inputmask.remove(); 368 } 369 el.inputmask = new Inputmask(undefined, undefined, true); 370 el.inputmask.opts = scopedOpts; 371 el.inputmask.noMasksCache = that.noMasksCache; 372 el.inputmask.userOptions = $.extend(true, {}, that.userOptions); 373 el.inputmask.isRTL = scopedOpts.isRTL || scopedOpts.numericInput; 374 el.inputmask.el = el; 375 el.inputmask.maskset = maskset; 376 $.data(el, "_inputmask_opts", scopedOpts); 377 maskScope.call(el.inputmask, { 378 action: "mask" 379 }); 380 } 381 } 382 }); 383 return elems && elems[0] ? elems[0].inputmask || this : this; 384 }, 385 option: function option(options, noremask) { 386 if (typeof options === "string") { 387 return this.opts[options]; 388 } else if ((typeof options === "undefined" ? "undefined" : _typeof(options)) === "object") { 389 $.extend(this.userOptions, options); 390 if (this.el && noremask !== true) { 391 this.mask(this.el); 392 } 393 return this; 394 } 395 }, 396 unmaskedvalue: function unmaskedvalue(value) { 397 this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache); 398 return maskScope.call(this, { 399 action: "unmaskedvalue", 400 value: value 401 }); 402 }, 403 remove: function remove() { 404 return maskScope.call(this, { 405 action: "remove" 406 }); 407 }, 408 getemptymask: function getemptymask() { 409 this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache); 410 return maskScope.call(this, { 411 action: "getemptymask" 412 }); 413 }, 414 hasMaskedValue: function hasMaskedValue() { 415 return !this.opts.autoUnmask; 416 }, 417 isComplete: function isComplete() { 418 this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache); 419 return maskScope.call(this, { 420 action: "isComplete" 421 }); 422 }, 423 getmetadata: function getmetadata() { 424 this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache); 425 return maskScope.call(this, { 426 action: "getmetadata" 427 }); 428 }, 429 isValid: function isValid(value) { 430 this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache); 431 return maskScope.call(this, { 432 action: "isValid", 433 value: value 434 }); 435 }, 436 format: function format(value, metadata) { 437 this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache); 438 return maskScope.call(this, { 439 action: "format", 440 value: value, 441 metadata: metadata 442 }); 443 }, 444 setValue: function setValue(value) { 445 if (this.el) { 446 $(this.el).trigger("setvalue", [ value ]); 447 } 448 }, 449 analyseMask: function analyseMask(mask, regexMask, opts) { 450 var tokenizer = /(?:[?*+]|\{[0-9\+\*]+(?:,[0-9\+\*]*)?(?:\|[0-9\+\*]*)?\})|[^.?*+^${[]()|\\]+|./g, 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, groupToken; 451 function MaskToken(isGroup, isOptional, isQuantifier, isAlternator) { 452 this.matches = []; 453 this.openGroup = isGroup || false; 454 this.alternatorGroup = false;
455 this.isGroup = isGroup || false; 456 this.isOptional = isOptional || false; 457 this.isQuantifier = isQuantifier || false; 458 this.isAlternator = isAlternator || false; 459 this.quantifier = { 460 min: 1, 461 max: 1 462 }; 463 } 464 function insertTestDefinition(mtoken, element, position) { 465 position = position !== undefined ? position : mtoken.matches.length; 466 var prevMatch = mtoken.matches[position - 1]; 467 if (regexMask) { 468 if (element.indexOf("[") === 0 || escaped && /\\d|\\s|\\w]/i.test(element) || element === ".") { 469 mtoken.matches.splice(position++, 0, { 470 fn: new RegExp(element, opts.casing ? "i" : ""), 471 optionality: false, 472 newBlockMarker: prevMatch === undefined ? "master" : prevMatch.def !== element, 473 casing: null, 474 def: element, 475 placeholder: undefined, 476 nativeDef: element 477 }); 478 } else { 479 if (escaped) element = element[element.length - 1]; 480 $.each(element.split(""), function(ndx, lmnt) { 481 prevMatch = mtoken.matches[position - 1]; 482 mtoken.matches.splice(position++, 0, { 483 fn: null, 484 optionality: false, 485 newBlockMarker: prevMatch === undefined ? "master" : prevMatch.def !== lmnt && prevMatch.fn !== null, 486 casing: null, 487 def: opts.staticDefinitionSymbol || lmnt, 488 placeholder: opts.staticDefinitionSymbol !== undefined ? lmnt : undefined, 489 nativeDef: (escaped ? "'" : "") + lmnt 490 }); 491 }); 492 } 493 escaped = false; 494 } else { 495 var maskdef = (opts.definitions ? opts.definitions[element] : undefined) || Inputmask.prototype.definitions[element]; 496 if (maskdef && !escaped) { 497 mtoken.matches.splice(position++, 0, { 498 fn: maskdef.validator ? typeof maskdef.validator == "string" ? new RegExp(maskdef.validator, opts.casing ? "i" : "") : new function() { 499 this.test = maskdef.validator; 500 }() : new RegExp("."), 501 optionality: false, 502 newBlockMarker: prevMatch === undefined ? "master" : prevMatch.def !== (maskdef.definitionSymbol || element), 503 casing: maskdef.casing, 504 def: maskdef.definitionSymbol || element, 505 placeholder: maskdef.placeholder, 506 nativeDef: element 507 }); 508 } else { 509 mtoken.matches.splice(position++, 0, { 510 fn: null, 511 optionality: false, 512 newBlockMarker: prevMatch === undefined ? "master" : prevMatch.def !== element && prevMatch.fn !== null, 513 casing: null, 514 def: opts.staticDefinitionSymbol || element, 515 placeholder: opts.staticDefinitionSymbol !== undefined ? element : undefined, 516 nativeDef: (escaped ? "'" : "") + element 517 }); 518 escaped = false;
vendor: 5,552 bytes, lines 519-633
519 } 520 } 521 } 522 function verifyGroupMarker(maskToken) { 523 if (maskToken && maskToken.matches) { 524 $.each(maskToken.matches, function(ndx, token) { 525 var nextToken = maskToken.matches[ndx + 1]; 526 if ((nextToken === undefined || nextToken.matches === undefined || nextToken.isQuantifier === false) && token && token.isGroup) { 527 token.isGroup = false; 528 if (!regexMask) { 529 insertTestDefinition(token, opts.groupmarker[0], 0); 530 if (token.openGroup !== true) { 531 insertTestDefinition(token, opts.groupmarker[1]); 532 } 533 } 534 } 535 verifyGroupMarker(token); 536 }); 537 } 538 } 539 function defaultCase() { 540 if (openenings.length > 0) { 541 currentOpeningToken = openenings[openenings.length - 1]; 542 insertTestDefinition(currentOpeningToken, m); 543 if (currentOpeningToken.isAlternator) { 544 alternator = openenings.pop(); 545 for (var mndx = 0; mndx < alternator.matches.length; mndx++) { 546 if (alternator.matches[mndx].isGroup) alternator.matches[mndx].isGroup = false; 547 } 548 if (openenings.length > 0) { 549 currentOpeningToken = openenings[openenings.length - 1]; 550 currentOpeningToken.matches.push(alternator); 551 } else { 552 currentToken.matches.push(alternator); 553 } 554 } 555 } else { 556 insertTestDefinition(currentToken, m); 557 } 558 } 559 function reverseTokens(maskToken) { 560 function reverseStatic(st) { 561 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]; 562 return st; 563 } 564 maskToken.matches = maskToken.matches.reverse(); 565 for (var match in maskToken.matches) { 566 if (maskToken.matches.hasOwnProperty(match)) { 567 var intMatch = parseInt(match); 568 if (maskToken.matches[match].isQuantifier && maskToken.matches[intMatch + 1] && maskToken.matches[intMatch + 1].isGroup) { 569 var qt = maskToken.matches[match]; 570 maskToken.matches.splice(match, 1); 571 maskToken.matches.splice(intMatch + 1, 0, qt); 572 } 573 if (maskToken.matches[match].matches !== undefined) { 574 maskToken.matches[match] = reverseTokens(maskToken.matches[match]); 575 } else { 576 maskToken.matches[match] = reverseStatic(maskToken.matches[match]); 577 } 578 } 579 } 580 return maskToken; 581 } 582 function groupify(matches) { 583 var groupToken = new MaskToken(true); 584 groupToken.openGroup = false; 585 groupToken.matches = matches; 586 return groupToken; 587 } 588 if (regexMask) { 589 opts.optionalmarker[0] = undefined; 590 opts.optionalmarker[1] = undefined; 591 } 592 while (match = regexMask ? regexTokenizer.exec(mask) : tokenizer.exec(mask)) { 593 m = match[0]; 594 if (regexMask) { 595 switch (m.charAt(0)) { 596 case "?": 597 m = "{0,1}"; 598 break; 599 600 case "+": 601 case "*": 602 m = "{" + m + "}"; 603 break; 604 } 605 } 606 if (escaped) { 607 defaultCase(); 608 continue; 609 } 610 switch (m.charAt(0)) { 611 case "(?=": 612 break; 613 614 case "(?!": 615 break; 616 617 case "(?<=": 618 break; 619 620 case "(?<!": 621 break; 622 623 case opts.escapeChar: 624 escaped = true; 625 if (regexMask) { 626 defaultCase(); 627 } 628 break; 629 630 case opts.optionalmarker[1]: 631 case opts.groupmarker[1]: 632 openingToken = openenings.pop(); 633 openingToken.openGroup = false;
634 if (openingToken !== undefined) { 635 if (openenings.length > 0) { 636 currentOpeningToken = openenings[openenings.length - 1]; 637 currentOpeningToken.matches.push(openingToken); 638 if (currentOpeningToken.isAlternator) { 639 alternator = openenings.pop(); 640 for (var mndx = 0; mndx < alternator.matches.length; mndx++) { 641 alternator.matches[mndx].isGroup = false; 642 alternator.matches[mndx].alternatorGroup = false; 643 } 644 if (openenings.length > 0) { 645 currentOpeningToken = openenings[openenings.length - 1]; 646 currentOpeningToken.matches.push(alternator); 647 } else { 648 currentToken.matches.push(alternator); 649 } 650 } 651 } else { 652 currentToken.matches.push(openingToken); 653 } 654 } else defaultCase(); 655 break; 656 657 case opts.optionalmarker[0]: 658 openenings.push(new MaskToken(false, true)); 659 break; 660 661 case opts.groupmarker[0]: 662 openenings.push(new MaskToken(true)); 663 break; 664 665 case opts.quantifiermarker[0]: 666 var quantifier = new MaskToken(false, false, true); 667 m = m.replace(/[{}]/g, ""); 668 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]); 669 if (mq0 === "*" || mq0 === "+") { 670 mq0 = mq1 === "*" ? 0 : 1; 671 } 672 quantifier.quantifier = { 673 min: mq0, 674 max: mq1, 675 jit: mqj[1] 676 }; 677 var matches = openenings.length > 0 ? openenings[openenings.length - 1].matches : currentToken.matches; 678 match = matches.pop(); 679 if (match.isAlternator) { 680 matches.push(match); 681 matches = match.matches; 682 var groupToken = new MaskToken(true); 683 var tmpMatch = matches.pop(); 684 matches.push(groupToken); 685 matches = groupToken.matches; 686 match = tmpMatch; 687 } 688 if (!match.isGroup) { 689 match = groupify([ match ]); 690 } 691 matches.push(match); 692 matches.push(quantifier); 693 break; 694 695 case opts.alternatormarker: 696 var groupQuantifier = function groupQuantifier(matches) { 697 var lastMatch = matches.pop(); 698 if (lastMatch.isQuantifier) { 699 lastMatch = groupify([ matches.pop(), lastMatch ]); 700 } 701 return lastMatch; 702 }; 703 if (openenings.length > 0) { 704 currentOpeningToken = openenings[openenings.length - 1]; 705 var subToken = currentOpeningToken.matches[currentOpeningToken.matches.length - 1]; 706 if (currentOpeningToken.openGroup && (subToken.matches === undefined || subToken.isGroup === false && subToken.isAlternator === false)) { 707 lastMatch = openenings.pop(); 708 } else { 709 lastMatch = groupQuantifier(currentOpeningToken.matches); 710 } 711 } else { 712 lastMatch = groupQuantifier(currentToken.matches); 713 } 714 if (lastMatch.isAlternator) { 715 openenings.push(lastMatch); 716 } else { 717 if (lastMatch.alternatorGroup) { 718 alternator = openenings.pop(); 719 lastMatch.alternatorGroup = false;
720 } else { 721 alternator = new MaskToken(false, false, false, true); 722 } 723 alternator.matches.push(lastMatch); 724 openenings.push(alternator); 725 if (lastMatch.openGroup) { 726 lastMatch.openGroup = false; 727 var alternatorGroup = new MaskToken(true); 728 alternatorGroup.alternatorGroup = true; 729 openenings.push(alternatorGroup); 730 } 731 } 732 break; 733 734 default: 735 defaultCase(); 736 } 737 } 738 while (openenings.length > 0) { 739 openingToken = openenings.pop(); 740 currentToken.matches.push(openingToken); 741 } 742 if (currentToken.matches.length > 0) { 743 verifyGroupMarker(currentToken); 744 maskTokens.push(currentToken); 745 } 746 if (opts.numericInput || opts.isRTL) { 747 reverseTokens(maskTokens[0]); 748 } 749 return maskTokens; 750 } 751 }; 752 Inputmask.extendDefaults = function(options) { 753 $.extend(true, Inputmask.prototype.defaults, options); 754 }; 755 Inputmask.extendDefinitions = function(definition) { 756 $.extend(true, Inputmask.prototype.definitions, definition); 757 }; 758 Inputmask.extendAliases = function(alias) { 759 $.extend(true, Inputmask.prototype.aliases, alias); 760 }; 761 Inputmask.format = function(value, options, metadata) { 762 return Inputmask(options).format(value, metadata); 763 }; 764 Inputmask.unmask = function(value, options) { 765 return Inputmask(options).unmaskedvalue(value); 766 }; 767 Inputmask.isValid = function(value, options) { 768 return Inputmask(options).isValid(value); 769 }; 770 Inputmask.remove = function(elems) { 771 if (typeof elems === "string") { 772 elems = document.getElementById(elems) || document.querySelectorAll(elems); 773 } 774 elems = elems.nodeName ? [ elems ] : elems; 775 $.each(elems, function(ndx, el) { 776 if (el.inputmask) el.inputmask.remove(); 777 }); 778 }; 779 Inputmask.setValue = function(elems, value) { 780 if (typeof elems === "string") { 781 elems = document.getElementById(elems) || document.querySelectorAll(elems); 782 } 783 elems = elems.nodeName ? [ elems ] : elems; 784 $.each(elems, function(ndx, el) { 785 if (el.inputmask) el.inputmask.setValue(value); else $(el).trigger("setvalue", [ value ]); 786 }); 787 }; 788 Inputmask.escapeRegex = function(str) { 789 var specials = [ "/", ".", "*", "+", "?", "|", "(", ")", "[", "]", "{", "}", "\\", "$", "^" ]; 790 return str.replace(new RegExp("(\\" + specials.join("|\\") + ")", "gim"), "\\$1"); 791 }; 792 Inputmask.keyCode = { 793 BACKSPACE: 8, 794 BACKSPACE_SAFARI: 127, 795 DELETE: 46, 796 DOWN: 40, 797 END: 35, 798 ENTER: 13, 799 ESCAPE: 27, 800 HOME: 36, 801 INSERT: 45, 802 LEFT: 37, 803 PAGE_DOWN: 34, 804 PAGE_UP: 33, 805 RIGHT: 39, 806 SPACE: 32, 807 TAB: 9, 808 UP: 38, 809 X: 88, 810 CONTROL: 17 811 }; 812 Inputmask.dependencyLib = $; 813 function resolveAlias(aliasStr, options, opts) { 814 var aliasDefinition = Inputmask.prototype.aliases[aliasStr]; 815 if (aliasDefinition) { 816 if (aliasDefinition.alias) resolveAlias(aliasDefinition.alias, undefined, opts); 817 $.extend(true, opts, aliasDefinition); 818 $.extend(true, opts, options); 819 return true; 820 } else if (opts.mask === null) { 821 opts.mask = aliasStr; 822 } 823 return false;
824 } 825 function generateMaskSet(opts, nocache) { 826 function generateMask(mask, metadata, opts) { 827 var regexMask = false; 828 if (mask === null || mask === "") { 829 regexMask = opts.regex !== null; 830 if (regexMask) { 831 mask = opts.regex; 832 mask = mask.replace(/^(\^)(.*)(\$)$/, "$2"); 833 } else { 834 regexMask = true; 835 mask = ".*"; 836 } 837 } 838 if (mask.length === 1 && opts.greedy === false && opts.repeat !== 0) { 839 opts.placeholder = ""; 840 } 841 if (opts.repeat > 0 || opts.repeat === "*" || opts.repeat === "+") { 842 var repeatStart = opts.repeat === "*" ? 0 : opts.repeat === "+" ? 1 : opts.repeat; 843 mask = opts.groupmarker[0] + mask + opts.groupmarker[1] + opts.quantifiermarker[0] + repeatStart + "," + opts.repeat + opts.quantifiermarker[1]; 844 } 845 var masksetDefinition, maskdefKey = regexMask ? "regex_" + opts.regex : opts.numericInput ? mask.split("").reverse().join("") : mask; 846 if (Inputmask.prototype.masksCache[maskdefKey] === undefined || nocache === true) { 847 masksetDefinition = { 848 mask: mask, 849 maskToken: Inputmask.prototype.analyseMask(mask, regexMask, opts), 850 validPositions: {}, 851 _buffer: undefined, 852 buffer: undefined, 853 tests: {}, 854 excludes: {}, 855 metadata: metadata, 856 maskLength: undefined 857 }; 858 if (nocache !== true) { 859 Inputmask.prototype.masksCache[maskdefKey] = masksetDefinition; 860 masksetDefinition = $.extend(true, {}, Inputmask.prototype.masksCache[maskdefKey]); 861 } 862 } else masksetDefinition = $.extend(true, {}, Inputmask.prototype.masksCache[maskdefKey]); 863 return masksetDefinition; 864 } 865 var ms; 866 if ($.isFunction(opts.mask)) { 867 opts.mask = opts.mask(opts); 868 } 869 if ($.isArray(opts.mask)) { 870 if (opts.mask.length > 1) { 871 if (opts.keepStatic === null) { 872 opts.keepStatic = "auto"; 873 for (var i = 0; i < opts.mask.length; i++) { 874 if (opts.mask[i].charAt(0) !== opts.mask[0].charAt(0)) { 875 opts.keepStatic = true; 876 break; 877 } 878 } 879 } 880 var altMask = opts.groupmarker[0]; 881 $.each(opts.isRTL ? opts.mask.reverse() : opts.mask, function(ndx, msk) { 882 if (altMask.length > 1) { 883 altMask += opts.groupmarker[1] + opts.alternatormarker + opts.groupmarker[0]; 884 } 885 if (msk.mask !== undefined && !$.isFunction(msk.mask)) { 886 altMask += msk.mask; 887 } else { 888 altMask += msk; 889 } 890 }); 891 altMask += opts.groupmarker[1]; 892 return generateMask(altMask, opts.mask, opts); 893 } else opts.mask = opts.mask.pop(); 894 } 895 if (opts.mask && opts.mask.mask !== undefined && !$.isFunction(opts.mask.mask)) { 896 ms = generateMask(opts.mask.mask, opts.mask, opts); 897 } else { 898 ms = generateMask(opts.mask, opts.mask, opts); 899 } 900 return ms; 901 } 902 function isInputEventSupported(eventName) { 903 var el = document.createElement("input"), evName = "on" + eventName, isSupported = evName in el; 904 if (!isSupported) { 905 el.setAttribute(evName, "return;"); 906 isSupported = typeof el[evName] === "function"; 907 } 908 el = null; 909 return isSupported; 910 } 911 function maskScope(actionObj, maskset, opts) { 912 maskset = maskset || this.maskset; 913 opts = opts || this.opts; 914 var inputmask = this, el = this.el, isRTL = this.isRTL, undoValue, $el, skipKeyPressEvent = false, skipInputEvent = false, ignorable = false, maxLength, mouseEnter = false, colorMask, originalPlaceholder; 915 function getMaskTemplate(baseOnInput, minimalPos, includeMode, noJit, clearOptionalTail) { 916 var greedy = opts.greedy; 917 if (clearOptionalTail) opts.greedy = false;
918 minimalPos = minimalPos || 0; 919 var maskTemplate = [], ndxIntlzr, pos = 0, test, testPos, lvp = getLastValidPosition(); 920 do { 921 if (baseOnInput === true && getMaskSet().validPositions[pos]) { 922 testPos = clearOptionalTail && getMaskSet().validPositions[pos].match.optionality === true && getMaskSet().validPositions[pos + 1] === undefined && (getMaskSet().validPositions[pos].generatedInput === true || getMaskSet().validPositions[pos].input == opts.skipOptionalPartCharacter && pos > 0) ? determineTestTemplate(pos, getTests(pos, ndxIntlzr, pos - 1)) : getMaskSet().validPositions[pos]; 923 test = testPos.match; 924 ndxIntlzr = testPos.locator.slice(); 925 maskTemplate.push(includeMode === true ? testPos.input : includeMode === false ? test.nativeDef : getPlaceholder(pos, test)); 926 } else { 927 testPos = getTestTemplate(pos, ndxIntlzr, pos - 1); 928 test = testPos.match; 929 ndxIntlzr = testPos.locator.slice(); 930 var jitMasking = noJit === true ? false : opts.jitMasking !== false ? opts.jitMasking : test.jit; 931 if (jitMasking === false || jitMasking === undefined || typeof jitMasking === "number" && isFinite(jitMasking) && jitMasking > pos) { 932 maskTemplate.push(includeMode === false ? test.nativeDef : getPlaceholder(pos, test)); 933 } 934 } 935 if (opts.keepStatic === "auto") { 936 if (test.newBlockMarker && test.fn !== null) { 937 opts.keepStatic = pos - 1; 938 } 939 } 940 pos++; 941 } while ((maxLength === undefined || pos < maxLength) && (test.fn !== null || test.def !== "") || minimalPos > pos); 942 if (maskTemplate[maskTemplate.length - 1] === "") { 943 maskTemplate.pop(); 944 } 945 if (includeMode !== false || getMaskSet().maskLength === undefined) getMaskSet().maskLength = pos - 1; 946 opts.greedy = greedy; 947 return maskTemplate; 948 } 949 function getMaskSet() { 950 return maskset; 951 } 952 function resetMaskSet(soft) { 953 var maskset = getMaskSet(); 954 maskset.buffer = undefined; 955 if (soft !== true) { 956 maskset.validPositions = {}; 957 maskset.p = 0; 958 } 959 } 960 function getLastValidPosition(closestTo, strict, validPositions) { 961 var before = -1, after = -1, valids = validPositions || getMaskSet().validPositions; 962 if (closestTo === undefined) closestTo = -1; 963 for (var posNdx in valids) { 964 var psNdx = parseInt(posNdx); 965 if (valids[psNdx] && (strict || valids[psNdx].generatedInput !== true)) { 966 if (psNdx <= closestTo) before = psNdx; 967 if (psNdx >= closestTo) after = psNdx; 968 } 969 } 970 return before === -1 || before == closestTo ? after : after == -1 ? before : closestTo - before < after - closestTo ? before : after; 971 } 972 function getDecisionTaker(tst) { 973 var decisionTaker = tst.locator[tst.alternation]; 974 if (typeof decisionTaker == "string" && decisionTaker.length > 0) { 975 decisionTaker = decisionTaker.split(",")[0]; 976 } 977 return decisionTaker !== undefined ? decisionTaker.toString() : ""; 978 } 979 function getLocator(tst, align) { 980 var locator = (tst.alternation != undefined ? tst.mloc[getDecisionTaker(tst)] : tst.locator).join(""); 981 if (locator !== "") while (locator.length < align) { 982 locator += "0"; 983 } 984 return locator; 985 } 986 function determineTestTemplate(pos, tests) { 987 pos = pos > 0 ? pos - 1 : 0;
988 var altTest = getTest(pos), targetLocator = getLocator(altTest), tstLocator, closest, bestMatch; 989 for (var ndx = 0; ndx < tests.length; ndx++) { 990 var tst = tests[ndx]; 991 tstLocator = getLocator(tst, targetLocator.length); 992 var distance = Math.abs(tstLocator - targetLocator); 993 if (closest === undefined || tstLocator !== "" && distance < closest || bestMatch && bestMatch.match.optionality && bestMatch.match.newBlockMarker === "master" && (!tst.match.optionality || !tst.match.newBlockMarker) || bestMatch && bestMatch.match.optionalQuantifier && !tst.match.optionalQuantifier) { 994 closest = distance; 995 bestMatch = tst; 996 } 997 } 998 return bestMatch; 999 } 1000 function getTestTemplate(pos, ndxIntlzr, tstPs) { 1001 return getMaskSet().validPositions[pos] || determineTestTemplate(pos, getTests(pos, ndxIntlzr ? ndxIntlzr.slice() : ndxIntlzr, tstPs)); 1002 } 1003 function getTest(pos, tests) { 1004 if (getMaskSet().validPositions[pos]) { 1005 return getMaskSet().validPositions[pos]; 1006 } 1007 return (tests || getTests(pos))[0]; 1008 } 1009 function positionCanMatchDefinition(pos, def) { 1010 var valid = false, tests = getTests(pos); 1011 for (var tndx = 0; tndx < tests.length; tndx++) { 1012 if (tests[tndx].match && tests[tndx].match.def === def) { 1013 valid = true; 1014 break; 1015 } 1016 } 1017 return valid; 1018 } 1019 function getTests(pos, ndxIntlzr, tstPs) { 1020 var maskTokens = getMaskSet().maskToken, testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr ? ndxIntlzr.slice() : [ 0 ], matches = [], insertStop = false, latestMatch, cacheDependency = ndxIntlzr ? ndxIntlzr.join("") : "", offset = 0; 1021 function resolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) { 1022 function handleMatch(match, loopNdx, quantifierRecurse) { 1023 function isFirstMatch(latestMatch, tokenGroup) { 1024 var firstMatch = $.inArray(latestMatch, tokenGroup.matches) === 0; 1025 if (!firstMatch) { 1026 $.each(tokenGroup.matches, function(ndx, match) { 1027 if (match.isQuantifier === true) firstMatch = isFirstMatch(latestMatch, tokenGroup.matches[ndx - 1]); else if (match.hasOwnProperty("matches")) firstMatch = isFirstMatch(latestMatch, match); 1028 if (firstMatch) return false; 1029 }); 1030 } 1031 return firstMatch; 1032 } 1033 function resolveNdxInitializer(pos, alternateNdx, targetAlternation) { 1034 var bestMatch, indexPos; 1035 if (getMaskSet().tests[pos] || getMaskSet().validPositions[pos]) { 1036 $.each(getMaskSet().tests[pos] || [ getMaskSet().validPositions[pos] ], function(ndx, lmnt) { 1037 if (lmnt.mloc[alternateNdx]) { 1038 bestMatch = lmnt; 1039 return false; 1040 } 1041 var alternation = targetAlternation !== undefined ? targetAlternation : lmnt.alternation, ndxPos = lmnt.locator[alternation] !== undefined ? lmnt.locator[alternation].toString().indexOf(alternateNdx) : -1; 1042 if ((indexPos === undefined || ndxPos < indexPos) && ndxPos !== -1) { 1043 bestMatch = lmnt; 1044 indexPos = ndxPos; 1045 } 1046 }); 1047 } 1048 if (bestMatch) { 1049 var bestMatchAltIndex = bestMatch.locator[bestMatch.alternation]; 1050 var locator = bestMatch.mloc[alternateNdx] || bestMatch.mloc[bestMatchAltIndex] || bestMatch.locator; 1051 return locator.slice((targetAlternation !== undefined ? targetAlternation : bestMatch.alternation) + 1); 1052 } else { 1053 return targetAlternation !== undefined ? resolveNdxInitializer(pos, alternateNdx) : undefined; 1054 } 1055 } 1056 function isSubsetOf(source, target) { 1057 function expand(pattern) { 1058 var expanded = [], start, end; 1059 for (var i = 0, l = pattern.length; i < l; i++) { 1060 if (pattern.charAt(i) === "-") {
1061 end = pattern.charCodeAt(i + 1); 1062 while (++start < end) { 1063 expanded.push(String.fromCharCode(start)); 1064 } 1065 } else { 1066 start = pattern.charCodeAt(i); 1067 expanded.push(pattern.charAt(i)); 1068 } 1069 } 1070 return expanded.join(""); 1071 } 1072 if (opts.regex && source.match.fn !== null && target.match.fn !== null) { 1073 return expand(target.match.def.replace(/[\[\]]/g, "")).indexOf(expand(source.match.def.replace(/[\[\]]/g, ""))) !== -1; 1074 } 1075 return source.match.def === target.match.nativeDef; 1076 } 1077 function staticCanMatchDefinition(source, target) { 1078 var sloc = source.locator.slice(source.alternation).join(""), tloc = target.locator.slice(target.alternation).join(""), canMatch = sloc == tloc, canMatch = canMatch && source.match.fn === null && target.match.fn !== null ? target.match.fn.test(source.match.def, getMaskSet(), pos, false, opts, false) : false; 1079 return canMatch; 1080 } 1081 function setMergeLocators(targetMatch, altMatch) { 1082 if (altMatch === undefined || targetMatch.alternation === altMatch.alternation && targetMatch.locator[targetMatch.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) === -1) { 1083 targetMatch.mloc = targetMatch.mloc || {}; 1084 var locNdx = targetMatch.locator[targetMatch.alternation]; 1085 if (locNdx === undefined) targetMatch.alternation = undefined; else { 1086 if (typeof locNdx === "string") locNdx = locNdx.split(",")[0]; 1087 if (targetMatch.mloc[locNdx] === undefined) targetMatch.mloc[locNdx] = targetMatch.locator.slice(); 1088 if (altMatch !== undefined) { 1089 for (var ndx in altMatch.mloc) { 1090 if (typeof ndx === "string") ndx = ndx.split(",")[0]; 1091 if (targetMatch.mloc[ndx] === undefined) targetMatch.mloc[ndx] = altMatch.mloc[ndx]; 1092 } 1093 targetMatch.locator[targetMatch.alternation] = Object.keys(targetMatch.mloc).join(","); 1094 } 1095 return true; 1096 } 1097 } 1098 return false; 1099 } 1100 if (testPos > 500 && quantifierRecurse !== undefined) { 1101 throw "Inputmask: There is probably an error in your mask definition or in the code. Create an issue on github with an example of the mask you are using. " + getMaskSet().mask; 1102 } 1103 if (testPos === pos && match.matches === undefined) { 1104 matches.push({ 1105 match: match, 1106 locator: loopNdx.reverse(), 1107 cd: cacheDependency, 1108 mloc: {} 1109 }); 1110 return true; 1111 } else if (match.matches !== undefined) { 1112 if (match.isGroup && quantifierRecurse !== match) { 1113 match = handleMatch(maskToken.matches[$.inArray(match, maskToken.matches) + 1], loopNdx, quantifierRecurse); 1114 if (match) return true; 1115 } else if (match.isOptional) { 1116 var optionalToken = match; 1117 match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse); 1118 if (match) { 1119 $.each(matches, function(ndx, mtch) { 1120 mtch.match.optionality = true; 1121 }); 1122 latestMatch = matches[matches.length - 1].match; 1123 if (quantifierRecurse === undefined && isFirstMatch(latestMatch, optionalToken)) { 1124 insertStop = true; 1125 testPos = pos; 1126 } else return true; 1127 } 1128 } else if (match.isAlternator) { 1129 var alternateToken = match, malternateMatches = [], maltMatches, currentMatches = matches.slice(), loopNdxCnt = loopNdx.length; 1130 var altIndex = ndxInitializer.length > 0 ? ndxInitializer.shift() : -1; 1131 if (altIndex === -1 || typeof altIndex === "string") { 1132 var currentPos = testPos, ndxInitializerClone = ndxInitializer.slice(), altIndexArr = [], amndx; 1133 if (typeof altIndex == "string") { 1134 altIndexArr = altIndex.split(","); 1135 } else { 1136 for (amndx = 0;
1136 amndx < alternateToken.matches.length; amndx++) { 1137 altIndexArr.push(amndx.toString()); 1138 } 1139 } 1140 if (getMaskSet().excludes[pos]) { 1141 var altIndexArrClone = altIndexArr.slice(); 1142 for (var i = 0, el = getMaskSet().excludes[pos].length; i < el; i++) { 1143 altIndexArr.splice(altIndexArr.indexOf(getMaskSet().excludes[pos][i].toString()), 1); 1144 } 1145 if (altIndexArr.length === 0) { 1146 getMaskSet().excludes[pos] = undefined; 1147 altIndexArr = altIndexArrClone; 1148 } 1149 } 1150 if (opts.keepStatic === true || isFinite(parseInt(opts.keepStatic)) && currentPos >= opts.keepStatic) altIndexArr = altIndexArr.slice(0, 1); 1151 var unMatchedAlternation = false; 1152 for (var ndx = 0; ndx < altIndexArr.length; ndx++) { 1153 amndx = parseInt(altIndexArr[ndx]); 1154 matches = []; 1155 ndxInitializer = typeof altIndex === "string" ? resolveNdxInitializer(testPos, amndx, loopNdxCnt) || ndxInitializerClone.slice() : ndxInitializerClone.slice(); 1156 if (alternateToken.matches[amndx] && handleMatch(alternateToken.matches[amndx], [ amndx ].concat(loopNdx), quantifierRecurse)) match = true; else if (ndx === 0) { 1157 unMatchedAlternation = true; 1158 } 1159 maltMatches = matches.slice(); 1160 testPos = currentPos; 1161 matches = []; 1162 for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) { 1163 var altMatch = maltMatches[ndx1], dropMatch = false; 1164 altMatch.match.jit = altMatch.match.jit || unMatchedAlternation; 1165 altMatch.alternation = altMatch.alternation || loopNdxCnt; 1166 setMergeLocators(altMatch); 1167 for (var ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) { 1168 var altMatch2 = malternateMatches[ndx2]; 1169 if (typeof altIndex !== "string" || altMatch.alternation !== undefined && $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr) !== -1) { 1170 if (altMatch.match.nativeDef === altMatch2.match.nativeDef) { 1171 dropMatch = true; 1172 setMergeLocators(altMatch2, altMatch); 1173 break; 1174 } else if (isSubsetOf(altMatch, altMatch2)) { 1175 if (setMergeLocators(altMatch, altMatch2)) { 1176 dropMatch = true; 1177 malternateMatches.splice(malternateMatches.indexOf(altMatch2), 0, altMatch); 1178 } 1179 break; 1180 } else if (isSubsetOf(altMatch2, altMatch)) { 1181 setMergeLocators(altMatch2, altMatch); 1182 break; 1183 } else if (staticCanMatchDefinition(altMatch, altMatch2)) { 1184 if (setMergeLocators(altMatch, altMatch2)) { 1185 dropMatch = true; 1186 malternateMatches.splice(malternateMatches.indexOf(altMatch2), 0, altMatch); 1187 } 1188 break; 1189 } 1190 } 1191 } 1192 if (!dropMatch) { 1193 malternateMatches.push(altMatch); 1194 } 1195 } 1196 } 1197 matches = currentMatches.concat(malternateMatches); 1198 testPos = pos; 1199 insertStop = matches.length > 0; 1200 match = malternateMatches.length > 0; 1201 ndxInitializer = ndxInitializerClone.slice(); 1202 } else match = handleMatch(alternateToken.matches[altIndex] || maskToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse); 1203 if (match) return true; 1204 } else if (match.isQuantifier && quantifierRecurse !== maskToken.matches[$.inArray(match, maskToken.matches) - 1]) { 1205 var qt = match; 1206 for (var qndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max) && testPos <= pos; qndx++) { 1207 var tokenGroup = maskToken.matches[$.inArray(qt, maskToken.matches) - 1]; 1208 match = handleMatch(tokenGroup, [ qndx ].concat(loopNdx), tokenGroup); 1209 if (match) { 1210 latestMatch = matches[matches.length - 1].match; 1211 latestMatch.optionalQuantifier = qndx > qt.quantifier.min - 1; 1212 latestMatch.jit = (qndx || 1) * tokenGroup.matches.indexOf(latestMatch) >= qt.quantifier.jit; 1213 if (latestMatch.optionalQuantifier && isFirstMatch(latestMatch, tokenGroup)) { 1214 insertStop = true; 1215 testPos = pos; 1216 break; 1217 } 1218 if (latestMatch.jit && !latestMatch.optionalQuantifier) { 1219 offset = tokenGroup.matches.indexOf(latestMatch); 1220 testPos = pos; 1221 insertStop = true; 1222 break; 1223 } 1224 return true; 1225 } 1226 } 1227 } else { 1228 match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse); 1229 if (match) return true; 1230 } 1231 } else { 1232 testPos++; 1233 } 1234 } 1235 for (var tndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; tndx < maskToken.matches.length; tndx = tndx + 1 + offset) { 1236 offset = 0; 1237 if (maskToken.matches[tndx].isQuantifier !== true) { 1238 var match = handleMatch(maskToken.matches[tndx], [ tndx ].concat(loopNdx), quantifierRecurse); 1239 if (match && testPos === pos) { 1240 return match; 1241 } else if (testPos > pos) { 1242 break; 1243 } 1244 } 1245 } 1246 } 1247 function mergeLocators(pos, tests) { 1248 var locator = []; 1249 if (!$.isArray(tests)) tests = [ tests ]; 1250 if (tests.length > 0) { 1251 if (tests[0].alternation === undefined) { 1252 locator = determineTestTemplate(pos, tests.slice()).locator.slice(); 1253 if (locator.length === 0) locator = tests[0].locator.slice(); 1254 } else { 1255 $.each(tests, function(ndx, tst) { 1256 if (tst.def !== "") { 1257 if (locator.length === 0) locator = t
1257st.locator.slice(); else { 1258 for (var i = 0; i < locator.length; i++) { 1259 if (tst.locator[i] && locator[i].toString().indexOf(tst.locator[i]) === -1) { 1260 locator[i] += "," + tst.locator[i]; 1261 } 1262 } 1263 } 1264 } 1265 }); 1266 } 1267 } 1268 return locator; 1269 } 1270 if (pos > -1) { 1271 if (ndxIntlzr === undefined) { 1272 var previousPos = pos - 1, test; 1273 while ((test = getMaskSet().validPositions[previousPos] || getMaskSet().tests[previousPos]) === undefined && previousPos > -1) { 1274 previousPos--; 1275 } 1276 if (test !== undefined && previousPos > -1) { 1277 ndxInitializer = mergeLocators(previousPos, test); 1278 cacheDependency = ndxInitializer.join(""); 1279 testPos = previousPos; 1280 } 1281 } 1282 if (getMaskSet().tests[pos] && getMaskSet().tests[pos][0].cd === cacheDependency) { 1283 return getMaskSet().tests[pos]; 1284 } 1285 for (var mtndx = ndxInitializer.shift(); mtndx < maskTokens.length; mtndx++) { 1286 var match = resolveTestFromToken(maskTokens[mtndx], ndxInitializer, [ mtndx ]); 1287 if (match && testPos === pos || testPos > pos) { 1288 break; 1289 } 1290 } 1291 } 1292 if (matches.length === 0 || insertStop) { 1293 matches.push({ 1294 match: { 1295 fn: null, 1296 optionality: false, 1297 casing: null, 1298 def: "", 1299 placeholder: "" 1300 }, 1301 locator: [], 1302 mloc: {}, 1303 cd: cacheDependency 1304 }); 1305 } 1306 if (ndxIntlzr !== undefined && getMaskSet().tests[pos]) { 1307 return $.extend(true, [], matches); 1308 } 1309 getMaskSet().tests[pos] = $.extend(true, [], matches); 1310 return getMaskSet().tests[pos]; 1311 } 1312 function getBufferTemplate() { 1313 if (getMaskSet()._buffer === undefined) { 1314 getMaskSet()._buffer = getMaskTemplate(false, 1); 1315 if (getMaskSet().buffer === undefined) getMaskSet().buffer = getMaskSet()._buffer.slice(); 1316 } 1317 return getMaskSet()._buffer; 1318 } 1319 function getBuffer(noCache) { 1320 if (getMaskSet().buffer === undefined || noCache === true) { 1321 getMaskSet().buffer = getMaskTemplate(true, getLastValidPosition(), true); 1322 if (getMaskSet()._buffer === undefined) getMaskSet()._buffer = getMaskSet().buffer.slice(); 1323 } 1324 return getMaskSet().buffer; 1325 } 1326 function refreshFromBuffer(start, end, buffer) { 1327 var i, p; 1328 if (start === true) { 1329 resetMaskSet(); 1330 start = 0; 1331 end = buffer.length; 1332 } else { 1333 for (i = start; i < end; i++) { 1334 delete getMaskSet().validPositions[i]; 1335 } 1336 } 1337 p = start; 1338 for (i = start; i < end; i++) { 1339 resetMaskSet(true); 1340 if (buffer[i] !== opts.skipOptionalPartCharacter) { 1341 var valResult = isValid(p, buffer[i], true, true); 1342 if (valResult !== false) { 1343 resetMaskSet(true); 1344 p = valResult.caret !== undefined ? valResult.caret : valResult.pos + 1; 1345 } 1346 } 1347 } 1348 } 1349 function casing(elem, test, pos) { 1350 switch (opts.casing || test.casing) { 1351 case "upper": 1352 elem = elem.toUpperCase(); 1353 break; 1354 1355 case "lower": 1356 elem = elem.toLowerCase(); 1357 break; 1358 1359 case "title": 1360 var posBefore = getMaskSet().validPositions[pos - 1]; 1361 if (pos === 0 || posBefore && posBefore.input === String.fromCharCode(Inputmask.keyCode.SPACE)) { 1362 elem = elem.toUpperCase(); 1363 } else { 1364 elem = elem.toLowerCase(); 1365 } 1366 break; 1367 1368 default: 1369 if ($.isFunction(opts.casing)) { 1370 var args = Array.prototype.slice.call(arguments); 1371 args.push(getMaskSet().validPositions); 1372 elem = opts.casing.apply(this, args); 1373 } 1374 } 1375 return elem; 1376 } 1377 function checkAlternationMatch(altArr1, altArr2, na) { 1378 var altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1), isMatch = false, naArr = na !== undefined ? na.split(",") : [], naNdx; 1379 for (var i = 0; i < naArr.length; i++) { 1380 if ((naNdx = altArr1.indexOf(naArr[i])) !== -1) { 1381 altArr1.splice(naNdx, 1); 1382 } 1383 } 1384 for (var alndx = 0; alndx < altArr1.length; alndx++) { 1385 if ($.inArray(altArr1[alndx], altArrC) !== -1) { 1386 isMatch = true; 1387 break; 1388 } 1389 } 1390 return isMatch; 1391 } 1392 function alternate(pos, c, strict, fromSetValid, rAltPos) {
1393 var validPsClone = $.extend(true, {}, getMaskSet().validPositions), lastAlt, alternation, isValidRslt = false, altPos, prevAltPos, i, validPos, decisionPos, lAltPos = rAltPos !== undefined ? rAltPos : getLastValidPosition(); 1394 if (lAltPos === -1 && rAltPos === undefined) { 1395 lastAlt = 0; 1396 prevAltPos = getTest(lastAlt); 1397 alternation = prevAltPos.alternation; 1398 } else { 1399 for (;lAltPos >= 0; lAltPos--) { 1400 altPos = getMaskSet().validPositions[lAltPos]; 1401 if (altPos && altPos.alternation !== undefined) { 1402 if (prevAltPos && prevAltPos.locator[altPos.alternation] !== altPos.locator[altPos.alternation]) { 1403 break; 1404 } 1405 lastAlt = lAltPos; 1406 alternation = getMaskSet().validPositions[lastAlt].alternation; 1407 prevAltPos = altPos; 1408 } 1409 } 1410 } 1411 if (alternation !== undefined) { 1412 decisionPos = parseInt(lastAlt); 1413 getMaskSet().excludes[decisionPos] = getMaskSet().excludes[decisionPos] || []; 1414 if (pos !== true) { 1415 getMaskSet().excludes[decisionPos].push(getDecisionTaker(prevAltPos)); 1416 } 1417 var validInputsClone = [], staticInputsBeforePos = 0; 1418 for (i = decisionPos; i < getLastValidPosition(undefined, true) + 1; i++) { 1419 validPos = getMaskSet().validPositions[i]; 1420 if (validPos && validPos.generatedInput !== true) { 1421 validInputsClone.push(validPos.input); 1422 } else if (i < pos) staticInputsBeforePos++; 1423 delete getMaskSet().validPositions[i]; 1424 } 1425 while (getMaskSet().excludes[decisionPos] && getMaskSet().excludes[decisionPos].length < 10) { 1426 var posOffset = staticInputsBeforePos * -1, validInputs = validInputsClone.slice(); 1427 getMaskSet().tests[decisionPos] = undefined; 1428 resetMaskSet(true); 1429 isValidRslt = true; 1430 while (validInputs.length > 0) { 1431 var input = validInputs.shift(); 1432 if (!(isValidRslt = isValid(getLastValidPosition(undefined, true) + 1, input, false, fromSetValid, true))) { 1433 break; 1434 } 1435 } 1436 if (isValidRslt && c !== undefined) { 1437 var targetLvp = getLastValidPosition(pos) + 1; 1438 for (i = decisionPos; i < getLastValidPosition() + 1; i++) { 1439 validPos = getMaskSet().validPositions[i]; 1440 if ((validPos === undefined || validPos.match.fn == null) && i < pos + posOffset) { 1441 posOffset++; 1442 } 1443 } 1444 pos = pos + posOffset; 1445 isValidRslt = isValid(pos > targetLvp ? targetLvp : pos, c, strict, fromSetValid, true); 1446 } 1447 if (!isValidRslt) { 1448 resetMaskSet(); 1449 prevAltPos = getTest(decisionPos); 1450 getMaskSet().validPositions = $.extend(true, {}, validPsClone); 1451 if (getMaskSet().excludes[decisionPos]) { 1452 var decisionTaker = getDecisionTaker(prevAltPos); 1453 if (getMaskSet().excludes[decisionPos].indexOf(decisionTaker) !== -1) { 1454 isValidRslt = alternate(pos, c, strict, fromSetValid, decisionPos - 1); 1455 break; 1456 } 1457 getMaskSet().excludes[decisionPos].push(decisionTaker); 1458 for (i = decisionPos; i < getLastValidPosition(undefined, true) + 1; i++) { 1459 delete getMaskSet().validPositions[i]; 1460 } 1461 } else { 1462 isValidRslt = alternate(pos, c, strict, fromSetValid, decisionPos - 1); 1463 break; 1464 } 1465 } else break; 1466 } 1467 } 1468 getMaskSet().excludes[decisionPos] = undefined; 1469 return isValidRslt; 1470 } 1471 function isValid(pos, c, strict, fromSetValid, fromAlternate, validateOnly) { 1472 function isSelection(posObj) { 1473 return isRTL ? posObj.begin - posObj.end > 1 || posObj.begin - posObj.end === 1 : posObj.end - posObj.begin > 1 || posObj.end - posObj.begin === 1; 1474 }
1475 strict = strict === true; 1476 var maskPos = pos; 1477 if (pos.begin !== undefined) { 1478 maskPos = isRTL ? pos.end : pos.begin; 1479 } 1480 function _isValid(position, c, strict) { 1481 var rslt = false; 1482 $.each(getTests(position), function(ndx, tst) { 1483 var test = tst.match; 1484 getBuffer(true); 1485 rslt = test.fn != null ? test.fn.test(c, getMaskSet(), position, strict, opts, isSelection(pos)) : (c === test.def || c === opts.skipOptionalPartCharacter) && test.def !== "" ? { 1486 c: getPlaceholder(position, test, true) || test.def, 1487 pos: position 1488 } : false; 1489 if (rslt !== false) { 1490 var elem = rslt.c !== undefined ? rslt.c : c, validatedPos = position; 1491 elem = elem === opts.skipOptionalPartCharacter && test.fn === null ? getPlaceholder(position, test, true) || test.def : elem; 1492 if (rslt.remove !== undefined) { 1493 if (!$.isArray(rslt.remove)) rslt.remove = [ rslt.remove ]; 1494 $.each(rslt.remove.sort(function(a, b) { 1495 return b - a; 1496 }), function(ndx, lmnt) { 1497 revalidateMask({ 1498 begin: lmnt, 1499 end: lmnt + 1 1500 }); 1501 }); 1502 } 1503 if (rslt.insert !== undefined) { 1504 if (!$.isArray(rslt.insert)) rslt.insert = [ rslt.insert ]; 1505 $.each(rslt.insert.sort(function(a, b) { 1506 return a - b; 1507 }), function(ndx, lmnt) { 1508 isValid(lmnt.pos, lmnt.c, true, fromSetValid); 1509 }); 1510 } 1511 if (rslt !== true && rslt.pos !== undefined && rslt.pos !== position) { 1512 validatedPos = rslt.pos; 1513 } 1514 if (rslt !== true && rslt.pos === undefined && rslt.c === undefined) { 1515 return false; 1516 } 1517 if (!revalidateMask(pos, $.extend({}, tst, { 1518 input: casing(elem, test, validatedPos) 1519 }), fromSetValid, validatedPos)) { 1520 rslt = false; 1521 } 1522 return false; 1523 } 1524 }); 1525 return rslt; 1526 } 1527 var result = true, positionsClone = $.extend(true, {}, getMaskSet().validPositions); 1528 if ($.isFunction(opts.preValidation) && !strict && fromSetValid !== true && validateOnly !== true) { 1529 result = opts.preValidation(getBuffer(), maskPos, c, isSelection(pos), opts, getMaskSet()); 1530 } 1531 if (result === true) { 1532 trackbackPositions(undefined, maskPos, true); 1533 if (maxLength === undefined || maskPos < maxLength) { 1534 result = _isValid(maskPos, c, strict); 1535 if ((!strict || fromSetValid === true) && result === false && validateOnly !== true) { 1536 var currentPosValid = getMaskSet().validPositions[maskPos]; 1537 if (currentPosValid && currentPosValid.match.fn === null && (currentPosValid.match.def === c || c === opts.skipOptionalPartCharacter)) { 1538 result = { 1539 caret: seekNext(maskPos) 1540 }; 1541 } else if ((opts.insertMode || getMaskSet().validPositions[seekNext(maskPos)] === undefined) && !isMask(maskPos, true)) { 1542 for (var nPos = maskPos + 1, snPos = seekNext(maskPos); nPos <= snPos; nPos++) { 1543 result = _isValid(nPos, c, strict); 1544 if (result !== false) { 1545 result = trackbackPositions(maskPos, result.pos !== undefined ? result.pos : nPos) || result; 1546 maskPos = nPos; 1547 break; 1548 } 1549 } 1550 } 1551 } 1552 } 1553 if (result === false && opts.keepStatic !== false && (opts.regex == null || isComplete(getBuffer())) && !strict && fromAlternate !== true) { 1554 result = alternate(maskPos, c, strict, fromSetValid); 1555 } 1556 if (result === true) { 1557 result = { 1558 pos: maskPos 1559 }; 1560 } 1561 } 1562 if ($.isFunction(opts.postValidation) && result !== false && !strict && fromSetValid !== true && validateOnly !== true) { 1563 var postResult = opts.postValidation(getBuffer(true), pos.begin !== undefined ? isRTL ? pos.end : pos.begin : pos, result, opts); 1564 if (postResult !== undefined) { 1565 if (postResult.refreshFromBuffer && postResult.buffer) { 1566 var refresh = postResult.refreshFromBuffer; 1567 refreshFromBuffer(refresh === true ? refresh : refresh.start, refresh.end, postResult.buffer); 1568 } 1569 result = postResult === true ? result : postResult; 1570 } 1571 } 1572 if (result && result.pos === undefined) { 1573 result.pos = maskPos; 1574 } 1575 if (result === false || validateOnly === true) { 1576 resetMaskSet(true); 1577 getMaskSet().validPositions = $.extend(true, {}, positionsClone); 1578 } 1579 return result; 1580 } 1581 function trackbackPositions(originalPos, newPos, fillOnly) { 1582 var result; 1583 if (originalPos === undefined) { 1584 for (originalPos = newPos - 1; originalPos > 0; originalPos--) { 1585 if (getMaskSet().validPositions[originalPos]) break; 1586 } 1587 } 1588 for (var ps = originalPos; ps < newPos; ps++) { 1589 if (getMaskSet().validPositions[ps] === undefined && !isMask(ps, true)) { 1590 var vp = ps == 0 ? getTest(ps) : getMaskSet().validPositions[ps - 1]; 1591 if (vp) { 1592 var tests = getTests(ps).slice(); 1593 if (tests[tests.length - 1].match.def === "") tests.pop(); 1594 var bestMatch = determineTestTemplate(ps, tests); 1595 bestMatch = $.extend({}, bestMatch, { 1596 input: getPlaceholder(ps, bestMatch.match, true) || bestMatch.match.def 1597 }); 1598 bestMatch.generatedInput = true; 1599 revalidateMask(ps, bestMatch, true); 1600 if (fillOnly !== true) { 1601 var cvpInput = getMaskSet().validPositions[newPos].input; 1602 getMaskSet().validPositions[newPos] = undefined; 1603 result = isValid(newPos, cvpInput, true, true); 1604 } 1605 } 1606 } 1607 } 1608 return result; 1609 } 1610 function revalidateMask(pos, validTest, fromSetValid, validatedPos) { 1611 function IsEnclosedStatic(pos, valids, selection) { 1612 var posMatch = valids[pos]; 1613 if (posMatch !== undefined && (posMatch.match.fn === null && posMatch.match.optionality !== true || posMatch.input === opts.radixPoint)) { 1614 var prevMatch = selection.begin <= pos - 1 ? valids[pos - 1] && valids[pos - 1].match.fn === null && valids[pos - 1] : valids[pos - 1], nextMatch = selection.end > pos + 1 ? valids[pos + 1] && valids[pos + 1].match.fn === null && valids[pos + 1] : valids[pos + 1]; 1615 return prevMatch && nextMatch; 1616 } 1617 return false;
1618 } 1619 var begin = pos.begin !== undefined ? pos.begin : pos, end = pos.end !== undefined ? pos.end : pos; 1620 if (pos.begin > pos.end) { 1621 begin = pos.end; 1622 end = pos.begin; 1623 } 1624 validatedPos = validatedPos !== undefined ? validatedPos : begin; 1625 if (begin !== end || opts.insertMode && getMaskSet().validPositions[validatedPos] !== undefined && fromSetValid === undefined) { 1626 var positionsClone = $.extend(true, {}, getMaskSet().validPositions), lvp = getLastValidPosition(undefined, true), i; 1627 getMaskSet().p = begin; 1628 for (i = lvp; i >= begin; i--) { 1629 if (getMaskSet().validPositions[i] && getMaskSet().validPositions[i].match.nativeDef === "+") { 1630 opts.isNegative = false; 1631 } 1632 delete getMaskSet().validPositions[i]; 1633 } 1634 var valid = true, j = validatedPos, vps = getMaskSet().validPositions, needsValidation = false, posMatch = j, i = j; 1635 if (validTest) { 1636 getMaskSet().validPositions[validatedPos] = $.extend(true, {}, validTest); 1637 posMatch++; 1638 j++; 1639 if (begin < end) i++; 1640 } 1641 for (;i <= lvp; i++) { 1642 var t = positionsClone[i]; 1643 if (t !== undefined && (i >= end || i >= begin && t.generatedInput !== true && IsEnclosedStatic(i, positionsClone, { 1644 begin: begin, 1645 end: end 1646 }))) { 1647 while (getTest(posMatch).match.def !== "") { 1648 if (needsValidation === false && positionsClone[posMatch] && positionsClone[posMatch].match.nativeDef === t.match.nativeDef) { 1649 getMaskSet().validPositions[posMatch] = $.extend(true, {}, positionsClone[posMatch]); 1650 getMaskSet().validPositions[posMatch].input = t.input; 1651 trackbackPositions(undefined, posMatch, true); 1652 j = posMatch + 1; 1653 valid = true; 1654 } else if (opts.shiftPositions && positionCanMatchDefinition(posMatch, t.match.def)) { 1655 var result = isValid(posMatch, t.input, true, true); 1656 valid = result !== false; 1657 j = result.caret || result.insert ? getLastValidPosition() : posMatch + 1; 1658 needsValidation = true; 1659 } else { 1660 valid = t.generatedInput === true || t.input === opts.radixPoint && opts.numericInput === true; 1661 } 1662 if (valid) break; 1663 if (!valid && posMatch > end && isMask(posMatch, true) && (t.match.fn !== null || posMatch > getMaskSet().maskLength)) { 1664 break; 1665 } 1666 posMatch++; 1667 } 1668 if (getTest(posMatch).match.def == "") valid = false; 1669 posMatch = j; 1670 } 1671 if (!valid) break; 1672 } 1673 if (!valid) { 1674 getMaskSet().validPositions = $.extend(true, {}, positionsClone); 1675 resetMaskSet(true); 1676 return false; 1677 } 1678 } else if (validTest) { 1679 getMaskSet().validPositions[validatedPos] = $.extend(true, {}, validTest); 1680 } 1681 resetMaskSet(true); 1682 return true; 1683 } 1684 function isMask(pos, strict) { 1685 var test = getTestTemplate(pos).match; 1686 if (test.def === "") test = getTest(pos).match; 1687 if (test.fn != null) { 1688 return test.fn; 1689 } 1690 if (strict !== true && pos > -1) { 1691 var tests = getTests(pos); 1692 return tests.length > 1 + (tests[tests.length - 1].match.def === "" ? 1 : 0); 1693 } 1694 return false;
1695 } 1696 function seekNext(pos, newBlock) { 1697 var position = pos + 1; 1698 while (getTest(position).match.def !== "" && (newBlock === true && (getTest(position).match.newBlockMarker !== true || !isMask(position)) || newBlock !== true && !isMask(position))) { 1699 position++; 1700 } 1701 return position; 1702 } 1703 function seekPrevious(pos, newBlock) { 1704 var position = pos, tests; 1705 if (position <= 0) return 0; 1706 while (--position > 0 && (newBlock === true && getTest(position).match.newBlockMarker !== true || newBlock !== true && !isMask(position) && (tests = getTests(position), 1707 tests.length < 2 || tests.length === 2 && tests[1].match.def === ""))) {} 1708 return position; 1709 } 1710 function getBufferElement(position) { 1711 return getMaskSet().validPositions[position] === undefined ? getPlaceholder(position) : getMaskSet().val
1711idPositions[position].input; 1712 } 1713 function writeBuffer(input, buffer, caretPos, event, triggerEvents) { 1714 if (event && $.isFunction(opts.onBeforeWrite)) { 1715 var result = opts.onBeforeWrite.call(inputmask, event, buffer, caretPos, opts); 1716 if (result) { 1717 if (result.refreshFromBuffer) { 1718 var refresh = result.refreshFromBuffer; 1719 refreshFromBuffer(refresh === true ? refresh : refresh.start, refresh.end, result.buffer || buffer); 1720 buffer = getBuffer(true); 1721 } 1722 if (caretPos !== undefined) caretPos = result.caret !== undefined ? result.caret : caretPos; 1723 } 1724 } 1725 if (input !== undefined) { 1726 input.inputmask._valueSet(buffer.join("")); 1727 if (caretPos !== undefined && (event === undefined || event.type !== "blur")) { 1728 caret(input, caretPos); 1729 } else renderColorMask(input, caretPos, buffer.length === 0); 1730 if (triggerEvents === true) { 1731 var $input = $(input), nptVal = input.inputmask._valueGet(); 1732 skipInputEvent = true; 1733 $input.trigger("input"); 1734 setTimeout(function() { 1735 if (nptVal === getBufferTemplate().join("")) { 1736 $input.trigger("cleared"); 1737 } else if (isComplete(buffer) === true) { 1738 $input.trigger("complete"); 1739 } 1740 }, 0); 1741 } 1742 } 1743 } 1744 function getPlaceholder(pos, test, returnPL) { 1745 test = test || getTest(pos).match; 1746 if (test.placeholder !== undefined || returnPL === true) { 1747 return $.isFunction(test.placeholder) ? test.placeholder(opts) : test.placeholder; 1748 } else if (test.fn === null) { 1749 if (pos > -1 && getMaskSet().validPositions[pos] === undefined) { 1750 var tests = getTests(pos), staticAlternations = [], prevTest; 1751 if (tests.length > 1 + (tests[tests.length - 1].match.def === "" ? 1 : 0)) { 1752 for (var i = 0; i < tests.length; i++) { 1753 if (tests[i].match.optionality !== true && tests[i].match.optionalQuantifier !== true && (tests[i].match.fn === null || prevTest === undefined || tests[i].match.fn.test(prevTest.match.def, getMaskSet(), pos, true, opts) !== false)) { 1754 staticAlternations.push(tests[i]); 1755 if (tests[i].match.fn === null) prevTest = tests[i]; 1756 if (staticAlternations.length > 1) { 1757 if (/[0-9a-bA-Z]/.test(staticAlternations[0].match.def)) { 1758 return opts.placeholder.charAt(pos % opts.placeholder.length); 1759 } 1760 } 1761 } 1762 } 1763 } 1764 } 1765 return test.def; 1766 } 1767 return opts.placeholder.charAt(pos % opts.placeholder.length); 1768 } 1769 function HandleNativePlaceholder(npt, value) { 1770 if (ie && npt.inputmask._valueGet() !== value) { 1771 var buffer = getBuffer().slice(), nptValue = npt.inputmask._valueGet(); 1772 if (nptValue !== value) { 1773 if (getLastValidPosition() === -1 && nptValue === getBufferTemplate().join("")) { 1774 buffer = []; 1775 } else { 1776 clearOptionalTail(buffer); 1777 } 1778 writeBuffer(npt, buffer); 1779 } 1780 } else if (npt.placeholder !== value) { 1781 npt.placeholder = value; 1782 if (npt.placeholder === "") npt.removeAttribute("placeholder"); 1783 } 1784 } 1785 var EventRuler = { 1786 on: function on(input, eventName, eventHandler) { 1787 var ev = function ev(e) { 1788 var that = this; 1789 if (that.inputmask === undefined && this.nodeName !== "FORM") { 1790 var imOpts = $.data(that, "_inputmask_opts"); 1791 if (imOpts) new Inputmask(imOpts).mask(that); else EventRuler.off(that); 1792 } else if (e.type !== "setvalue" && this.nodeName !== "FORM" && (that.disabled || that.readOnly && !(e.type === "keydown" && e.ctrlKey && e.keyCode === 67 || opts.tabThrough === false && e.keyCode === Inputmask.keyCode.TAB))) { 1793 e.preventDefault(); 1794 } else { 1795 switch (e.type) { 1796 case "input": 1797 if (skipInputEvent === true) { 1798 skipInputEvent = false;
1799 return e.preventDefault(); 1800 } 1801 if (mobile) { 1802 var args = arguments; 1803 setTimeout(function() { 1804 eventHandler.apply(that, args); 1805 caret(that, that.inputmask.caretPos, undefined, true); 1806 }, 0); 1807 return false; 1808 } 1809 break; 1810 1811 case "keydown": 1812 skipKeyPressEvent = false; 1813 skipInputEvent = false; 1814 break; 1815 1816 case "keypress": 1817 if (skipKeyPressEvent === true) { 1818 return e.preventDefault(); 1819 } 1820 skipKeyPressEvent = true; 1821 break; 1822 1823 case "click": 1824 if (iemobile || iphone) { 1825 var args = arguments; 1826 setTimeout(function() { 1827 eventHandler.apply(that, args); 1828 }, 0); 1829 return false; 1830 } 1831 break; 1832 } 1833 var returnVal = eventHandler.apply(that, arguments); 1834 if (returnVal === false) { 1835 e.preventDefault(); 1836 e.stopPropagation(); 1837 } 1838 return returnVal; 1839 } 1840 }; 1841 input.inputmask.events[eventName] = input.inputmask.events[eventName] || []; 1842 input.inputmask.events[eventName].push(ev); 1843 if ($.inArray(eventName, [ "submit", "reset" ]) !== -1) { 1844 if (input.form !== null) $(input.form).on(eventName, ev); 1845 } else { 1846 $(input).on(eventName, ev); 1847 } 1848 }, 1849 off: function off(input, event) { 1850 if (input.inputmask && input.inputmask.events) { 1851 var events; 1852 if (event) { 1853 events = []; 1854 events[event] = input.inputmask.events[event]; 1855 } else { 1856 events = input.inputmask.events; 1857 } 1858 $.each(events, function(eventName, evArr) { 1859 while (evArr.length > 0) { 1860 var ev = evArr.pop(); 1861 if ($.inArray(eventName, [ "submit", "reset" ]) !== -1) { 1862 if (input.form !== null) $(input.form).off(eventName, ev); 1863 } else { 1864 $(input).off(eventName, ev); 1865 } 1866 } 1867 delete input.inputmask.events[eventName]; 1868 }); 1869 } 1870 } 1871 }; 1872 var EventHandlers = { 1873 keydownEvent: function keydownEvent(e) { 1874 var input = this, $input = $(input), k = e.keyCode, pos = caret(input); 1875 if (k === Inputmask.keyCode.BACKSPACE || k === Inputmask.keyCode.DELETE || iphone && k === Inputmask.keyCode.BACKSPACE_SAFARI || e.ctrlKey && k === Inputmask.keyCode.X && !isInputEventSupported("cut")) { 1876 e.preventDefault(); 1877 handleRemove(input, k, pos); 1878 writeBuffer(input, getBuffer(true), getMaskSet().p, e, input.inputmask._valueGet() !== getBuffer().join("")); 1879 } else if (k === Inputmask.keyCode.END || k === Inputmask.keyCode.PAGE_DOWN) { 1880 e.preventDefault(); 1881 var caretPos = seekNext(getLastValidPosition()); 1882 caret(input, e.shiftKey ? pos.begin : caretPos, caretPos, true); 1883 } else if (k === Inputmask.keyCode.HOME && !e.shiftKey || k === Inputmask.keyCode.PAGE_UP) { 1884 e.preventDefault(); 1885 caret(input, 0, e.shiftKey ? pos.begin : 0, true); 1886 } else if ((opts.undoOnEscape && k === Inputmask.keyCode.ESCAPE || k === 90 && e.ctrlKey) && e.altKey !== true) { 1887 checkVal(input, true, false, undoValue.split("")); 1888 $input.trigger("click"); 1889 } else if (k === Inputmask.keyCode.INSERT && !(e.shiftKey || e.ctrlKey)) { 1890 opts.insertMode = !opts.insertMode; 1891 input.setAttribute("im-insert", opts.insertMode); 1892 } else if (opts.tabThrough === true && k === Inputmask.keyCode.TAB) { 1893 if (e.shiftKey === true) { 1894 if (getTest(pos.begin).match.fn === null) { 1895 pos.begin = seekNext(pos.begin); 1896 } 1897 pos.end = seekPrevious(pos.begin, true); 1898 pos.begin = seekPrevious(pos.end, true); 1899 } else { 1900 pos.begin = seekNext(pos.begin, true); 1901 pos.end = seekNext(pos.begin, true); 1902 if (pos.end < getMaskSet().maskLength) pos.end--; 1903 } 1904 if (pos.begin < getMaskSet().maskLength) { 1905 e.preventDefault(); 1906 caret(input, pos.begin, pos.end); 1907 } 1908 } 1909 opts.onKeyDown.call(this, e, getBuffer(), caret(input).begin, opts); 1910 ignorable = $.inArray(k, opts.ignorables) !== -1; 1911 }, 1912 keypressEvent: function keypressEvent(e, checkval, writeOut, strict, ndx) { 1913 var input = this, $input = $(input), k = e.which || e.charCode || e.keyCode; 1914 if (checkval !== true && !(e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable)) { 1915 if (k === Inputmask.keyCode.ENTER && undoValue !== getBuffer().join("")) { 1916 undoValue = getBuffer().join(""); 1917 setTimeout(function() { 1918 $input.trigger("change"); 1919 }, 0); 1920 } 1921 return true; 1922 } else { 1923 if (k) { 1924 if (k === 46 && e.shiftKey === false && opts.radixPoint !== "") k = opts.radixPoint.charCodeAt(0); 1925 var pos = checkval ? { 1926 begin: ndx, 1927 end: ndx 1928 } : caret(input), forwardPosition, c = String.fromCharCode(k), offset = 0; 1929 if (opts._radixDance && opts.numericInput) { 1930 var caretPos = getBuffer().indexOf(opts.radixPoint.charAt(0)) + 1; 1931 if (pos.begin <= caretPos) { 1932 if (k === opts.radixPoint.charCodeAt(0)) offset = 1; 1933 pos.begin -= 1; 1934 pos.end -= 1; 1935 } 1936 } 1937 getMaskSet().writeOutBuffer = true; 1938 var valResult = isValid(pos, c, strict); 1939 if (valResult !== false) { 1940 resetMaskSet(true); 1941 forwardPosition = valResult.caret !== undefined ? valResult.caret : seekNext(valResult.pos.begin ? valResult.pos.begin : valResult.pos); 1942 getMaskSet().p = forwardPosition; 1943 } 1944 forwardPosition = (opts.numericInput && valResult.caret === undefined ? seekPrevious(forwardPosition) : forwardPosition) + offset; 1945 if (writeOut !== false) { 1946 setTimeout(function() { 1947 opts.onKeyValidation.call(input, k, valResult, opts); 1948 }, 0); 1949 if (getMaskSet().writeOutBuffer && valResult !== false) { 1950 var buffer = getBuffer(); 1951 writeBuffer(input, buffer, forwardPosition, e, checkval !== true); 1952 } 1953 } 1954 e.preventDefault(); 1955 if (checkval) { 1956 if (valResult !== false) valResult.forwardPosition = forwardPosition; 1957 return valResult; 1958 } 1959 } 1960 } 1961 }, 1962 pasteEvent: function pasteEvent(e) { 1963 var input = this, ev = e.originalEvent || e, $input = $(input), inputValue = input.inputmask._valueGet(true), caretPos = caret(input), tempValue; 1964 if (isRTL) { 1965 tempValue = caretPos.end; 1966 caretPos.end = caretPos.begin; 1967 caretPos.begin = tempValue; 1968 } 1969 var valueBeforeCaret = inputValue.substr(0, caretPos.begin), valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length); 1970 if (valueBeforeCaret === (isRTL ? getBufferTemplate().reverse() : getBufferTemplate()).slice(0, caretPos.begin).join("")) valueBeforeCaret = ""; 1971 if (valueAfterCaret === (isRTL ? getBufferTemplate().reverse() : getBufferTemplate()).slice(caretPos.end).join("")) valueAfterCaret = ""; 1972 if (window.clipboardData && window.clipboardData.getData) { 1973 inputValue = valueBeforeCaret + window.clipboardData.getData("Text") + valueAfterCaret; 1974 } else if (ev.clipboardData && ev.clipboardData.getData) { 1975 inputValue = valueBeforeCaret + ev.clipboardData.getData("text/plain") + valueAfterCaret; 1976 } else return true; 1977 var pasteValue = inputValue; 1978 if ($.isFunction(opts.onBeforePaste)) { 1979 pasteValue = opts.onBeforePaste.call(inputmask, inputValue, opts); 1980 if (pasteValue === false) { 1981 return e.preventDefault(); 1982 } 1983 if (!pasteValue) { 1984 pasteValue = inputValue; 1985 } 1986 } 1987 checkVal(input, false, false, pasteValue.toString().split("")); 1988 writeBuffer(input, getBuffer(), seekNext(getLastValidPosition()), e, undoValue !== getBuffer().join("")); 1989 return e.preventDefault(); 1990 }, 1991 inputFallBackEvent: function inputFallBackEvent(e) { 1992 function radixPointHandler(input, inputValue, caretPos) { 1993 if (inputValue.charAt(caretPos.begin - 1) === "." && opts.radixPoint !== "") { 1994 inputValue = inputValue.split(""); 1995 inputValue[caretPos.begin - 1] = opts.radixPoint.charAt(0); 1996 inputValue = inputValue.join(""); 1997 } 1998 return inputValue; 1999 } 2000 function ieMobileHandler(input, inputValue, caretPos) { 2001 if (iemobile) { 2002 var inputChar = inputValue.replace(getBuffer().join(""), ""); 2003 if (inputChar.length === 1) { 2004 var iv = inputValue.split(""); 2005 iv.splice(caretPos.begin, 0, inputChar); 2006 inputValue = iv.join(""); 2007 } 2008 } 2009 return inputValue; 2010 } 2011 var input = this, inputValue = input.inputmask._valueGet(); 2012 if (getBuffer().join("") !== inputValue) { 2013 var caretPos = caret(input); 2014 inputValue = radixPointHandler(input, inputValue, caretPos); 2015 inputValue = ieMobileHandler(input, inputValue, caretPos); 2016 if (getBuffer().join("") !== inputValue) { 2017 var buffer = getBuffer().join(""), offset = !opts.numericInput && inputValue.length > buffer.length ? -1 : 0, frontPart = inputValue.substr(0, caretPos.begin), backPart = inputValue.substr(caretPos.begin), frontBufferPart = buffer.substr(0, caretPos.begin + offset), backBufferPart = buffer.substr(caretPos.begin + offset); 2018 var selection = caretPos, entries = "", isEntry = false;
2019 if (frontPart !== frontBufferPart) { 2020 var fpl = (isEntry = frontPart.length >= frontBufferPart.length) ? frontPart.length : frontBufferPart.length, i; 2021 for (i = 0; frontPart.charAt(i) === frontBufferPart.charAt(i) && i < fpl; i++) {} 2022 if (isEntry) { 2023 selection.begin = i - offset; 2024 entries += frontPart.slice(i, selection.end); 2025 } 2026 } 2027 if (backPart !== backBufferPart) { 2028 if (backPart.length > backBufferPart.length) { 2029 entries += backPart.slice(0, 1); 2030 } else { 2031 if (backPart.length < backBufferPart.length) { 2032 selection.end += backBufferPart.length - backPart.length; 2033 if (!isEntry && opts.radixPoint !== "" && backPart === "" && frontPart.charAt(selection.begin + offset - 1) === opts.radixPoint) { 2034 selection.begin--; 2035 entries = opts.radixPoint; 2036 } 2037 } 2038 } 2039 } 2040 writeBuffer(input, getBuffer(), { 2041 begin: selection.begin + offset, 2042 end: selection.end + offset 2043 }); 2044 if (entries.length > 0) { 2045 $.each(entries.split(""), function(ndx, entry) { 2046 var keypress = new $.Event("keypress"); 2047 keypress.which = entry.charCodeAt(0); 2048 ignorable = false; 2049 EventHandlers.keypressEvent.call(input, keypress); 2050 }); 2051 } else { 2052 if (selection.begin === selection.end - 1) { 2053 selection.begin = seekPrevious(selection.begin + 1); 2054 if (selection.begin === selection.end - 1) { 2055 caret(input, selection.begin); 2056 } else { 2057 caret(input, selection.begin, selection.end); 2058 } 2059 } 2060 var keydown = new $.Event("keydown"); 2061 keydown.keyCode = opts.numericInput ? Inputmask.keyCode.BACKSPACE : Inputmask.keyCode.DELETE; 2062 EventHandlers.keydownEvent.call(input, keydown); 2063 } 2064 e.preventDefault(); 2065 } 2066 } 2067 }, 2068 beforeInputEvent: function beforeInputEvent(e) { 2069 if (e.cancelable) { 2070 var input = this; 2071 switch (e.inputType) { 2072 case "insertText": 2073 $.each(e.data.split(""), function(ndx, entry) { 2074 var keypress = new $.Event("keypress"); 2075 keypress.which = entry.charCodeAt(0); 2076 ignorable = false; 2077 EventHandlers.keypressEvent.call(input, keypress); 2078 }); 2079 return e.preventDefault(); 2080 2081 case "deleteContentBackward": 2082 var keydown = new $.Event("keydown"); 2083 keydown.keyCode = Inputmask.keyCode.BACKSPACE; 2084 EventHandlers.keydownEvent.call(input, keydown); 2085 return e.preventDefault(); 2086 2087 case "deleteContentForward":
2088 var keydown = new $.Event("keydown"); 2089 keydown.keyCode = Inputmask.keyCode.DELETE; 2090 EventHandlers.keydownEvent.call(input, keydown); 2091 return e.preventDefault(); 2092 } 2093 } 2094 }, 2095 setValueEvent: function setValueEvent(e) { 2096 this.inputmask.refreshValue = false; 2097 var input = this, value = e && e.detail ? e.detail[0] : arguments[1], value = value || input.inputmask._valueGet(true); 2098 if ($.isFunction(opts.onBeforeMask)) value = opts.onBeforeMask.call(inputmask, value, opts) || value; 2099 value = value.split(""); 2100 checkVal(input, true, false, value); 2101 undoValue = getBuffer().join(""); 2102 if ((opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() === getBufferTemplate().join("")) { 2103 input.inputmask._valueSet(""); 2104 } 2105 }, 2106 focusEvent: function focusEvent(e) { 2107 var input = this, nptValue = input.inputmask._valueGet(); 2108 if (opts.showMaskOnFocus && (!opts.showMaskOnHover || opts.showMaskOnHover && nptValue === "")) { 2109 if (input.inputmask._valueGet() !== getBuffer().join("")) { 2110 writeBuffer(input, getBuffer(), seekNext(getLastValidPosition())); 2111 } else if (mouseEnter === false) { 2112 caret(input, seekNext(getLastValidPosition())); 2113 } 2114 } 2115 if (opts.positionCaretOnTab === true && mouseEnter === false) { 2116 EventHandlers.clickEvent.apply(input, [ e, true ]); 2117 } 2118 undoValue = getBuffer().join(""); 2119 }, 2120 mouseleaveEvent: function mouseleaveEvent(e) { 2121 var input = this; 2122 mouseEnter = false; 2123 if (opts.clearMaskOnLostFocus && document.activeElement !== input) { 2124 HandleNativePlaceholder(input, originalPlaceholder); 2125 } 2126 }, 2127 clickEvent: function clickEvent(e, tabbed) { 2128 function doRadixFocus(clickPos) { 2129 if (opts.radixPoint !== "") { 2130 var vps = getMaskSet().validPositions; 2131 if (vps[clickPos] === undefined || vps[clickPos].input === getPlaceholder(clickPos)) { 2132 if (clickPos < seekNext(-1)) return true; 2133 var radixPos = $.inArray(opts.radixPoint, getBuffer()); 2134 if (radixPos !== -1) { 2135 for (var vp in vps) { 2136 if (radixPos < vp && vps[vp].input !== getPlaceholder(vp)) { 2137 return false; 2138 } 2139 } 2140 return true; 2141 } 2142 } 2143 } 2144 return false; 2145 } 2146 var input = this; 2147 setTimeout(function() { 2148 if (document.activeElement === input) { 2149 var selectedCaret = caret(input); 2150 if (tabbed) { 2151 if (isRTL) { 2152 selectedCaret.end = selectedCaret.begin; 2153 } else { 2154 selectedCaret.begin = selectedCaret.end; 2155 } 2156 } 2157 if (selectedCaret.begin === selectedCaret.end) { 2158 switch (opts.positionCaretOnClick) { 2159 case "none": 2160 break; 2161 2162 case "select": 2163 caret(input, 0, getBuffer().length); 2164 break; 2165 2166 case "ignore": 2167 caret(input, seekNext(getLastValidPosition())); 2168 break; 2169 2170 case "radixFocus": 2171 if (doRadixFocus(selectedCaret.begin)) { 2172 var radixPos = getBuffer().join("").indexOf(opts.radixPoint); 2173 caret(input, opts.numericInput ? seekNext(radixPos) : radixPos); 2174 break; 2175 } 2176 2177 default: 2178 var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition, true), lastPosition = seekNext(lvclickPosition); 2179 if (clickPosition < lastPosition) { 2180 caret(input, !isMask(clickPosition, true) && !isMask(clickPosition - 1, true) ? seekNext(clickPosition) : clickPosition); 2181 } else { 2182 var lvp = getMaskSet().validPositions[lvclickPosition], tt = getTestTemplate(lastPosition, lvp ? lvp.match.locator : undefined, lvp), placeholder = getPlaceholder(lastPosition, tt.match); 2183 if (placeholder !== "" && getBuffer()[lastPosition] !== placeholder && tt.match.optionalQuantifier !== true && tt.match.newBlockMarker !== true || !isMask(lastPosition, opts.keepStatic) && tt.match.def === placeholder) { 2184 var newPos = seekNext(lastPosition); 2185 if (clickPosition >= newPos || clickPosition === lastPosition) { 2186 lastPosition = newPos; 2187 } 2188 } 2189 caret(input, lastPosition); 2190 } 2191 break; 2192 } 2193 } 2194 } 2195 }, 0); 2196 }, 2197 cutEvent: function cutEvent(e) { 2198 var input = this, $input = $(input), pos = caret(input), ev = e.originalEvent || e; 2199 var clipboardData = window.clipboardData || ev.clipboardData, clipData = isRTL ? getBuffer().slice(pos.end, pos.begin) : getBuffer().slice(pos.begin, pos.end); 2200 clipboardData.setData("text", isRTL ? clipData.reverse().join("") : clip
2200Data.join("")); 2201 if (document.execCommand) document.execCommand("copy"); 2202 handleRemove(input, Inputmask.keyCode.DELETE, pos); 2203 writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")); 2204 }, 2205 blurEvent: function blurEvent(e) { 2206 var $input = $(this), input = this; 2207 if (input.inputmask) { 2208 HandleNativePlaceholder(input, originalPlaceholder); 2209 var nptValue = input.inputmask._valueGet(), buffer = getBuffer().slice(); 2210 if (nptValue !== "" || colorMask !== undefined) { 2211 if (opts.clearMaskOnLostFocus) { 2212 if (getLastValidPosition() === -1 && nptValue === getBufferTemplate().join("")) { 2213 buffer = []; 2214 } else { 2215 clearOptionalTail(buffer); 2216 } 2217 } 2218 if (isComplete(buffer) === false) { 2219 setTimeout(function() { 2220 $input.trigger("incomplete"); 2221 }, 0); 2222 if (opts.clearIncomplete) { 2223 resetMaskSet(); 2224 if (opts.clearMaskOnLostFocus) { 2225 buffer = []; 2226 } else { 2227 buffer = getBufferTemplate().slice(); 2228 } 2229 } 2230 } 2231 writeBuffer(input, buffer, undefined, e); 2232 } 2233 if (undoValue !== getBuffer().join("")) { 2234 undoValue = buffer.join(""); 2235 $input.trigger("change"); 2236 } 2237 } 2238 }, 2239 mouseenterEvent: function mouseenterEvent(e) { 2240 var input = this; 2241 mouseEnter = true; 2242 if (document.activeElement !== input && opts.showMaskOnHover) { 2243 HandleNativePlaceholder(input, (isRTL ? getBuffer().slice().reverse() : getBuffer()).join("")); 2244 } 2245 }, 2246 submitEvent: function submitEvent(e) { 2247 if (undoValue !== getBuffer().join("")) { 2248 $el.trigger("change"); 2249 } 2250 if (opts.clearMaskOnLostFocus && getLastValidPosition() === -1 && el.inputmask._valueGet && el.inputmask._valueGet() === getBufferTemplate().join("")) { 2251 el.inputmask._valueSet(""); 2252 } 2253 if (opts.clearIncomplete && isComplete(getBuffer()) === false) { 2254 el.inputmask._valueSet(""); 2255 } 2256 if (opts.removeMaskOnSubmit) { 2257 el.inputmask._valueSet(el.inputmask.unmaskedvalue(), true); 2258 setTimeout(function() { 2259 writeBuffer(el, getBuffer()); 2260 }, 0); 2261 } 2262 }, 2263 resetEvent: function resetEvent(e) { 2264 el.inputmask.refreshValue = true; 2265 setTimeout(function() { 2266 $el.trigger("setvalue"); 2267 }, 0); 2268 } 2269 }; 2270 function checkVal(input, writeOut, strict, nptvl, initiatingEvent) { 2271 var inputmask = this || input.inputmask, inputValue = nptvl.slice(), charCodes = "", initialNdx = -1, result = undefined; 2272 function isTemplateMatch(ndx, charCodes) { 2273 var charCodeNdx = getMaskTemplate(true, 0, false).slice(ndx, seekNext(ndx)).join("").replace(/'/g, "").indexOf(charCodes); 2274 return charCodeNdx !== -1 && !isMask(ndx) && (getTest(ndx).match.nativeDef === charCodes.charAt(0) || getTest(ndx).match.fn === null && getTest(ndx).match.nativeDef === "'" + charCodes.charAt(0) || getTest(ndx).match.nativeDef === " " && (getTest(ndx + 1).match.nativeDef === charCodes.charAt(0) || getTest(ndx + 1).match.fn === null && getTest(ndx + 1).match.nativeDef === "'" + charCodes.charAt(0))); 2275 } 2276 resetMaskSet(); 2277 if (!strict && opts.autoUnmask !== true) { 2278 var staticInput = getBufferTemplate().slice(0, seekNext(-1)).join(""), matches = inputValue.join("").match(new RegExp("^" + Inputmask.escapeRegex(staticInput), "g")); 2279 if (matches && matches.length > 0) { 2280 inputValue.splice(0, matches.length * staticInput.length); 2281 initialNdx = seekNext(initialNdx); 2282 } 2283 } else { 2284 initialNdx = seekNext(initialNdx); 2285 } 2286 if (initialNdx === -1) { 2287 getMaskSet().p = seekNext(initialNdx); 2288 initialNdx = 0; 2289 } else getMaskSet().p = initialNdx; 2290 inputmask.caretPos = { 2291 begin: initialNdx 2292 };
2293 $.each(inputValue, function(ndx, charCode) { 2294 if (charCode !== undefined) { 2295 if (getMaskSet().validPositions[ndx] === undefined && inputValue[ndx] === getPlaceholder(ndx) && isMask(ndx, true) && isValid(ndx, inputValue[ndx], true, undefined, undefined, true) === false) { 2296 getMaskSet().p++; 2297 } else { 2298 var keypress = new $.Event("_checkval"); 2299 keypress.which = charCode.charCodeAt(0); 2300 charCodes += charCode; 2301 var lvp = getLastValidPosition(undefined, true); 2302 if (!isTemplateMatch(initialNdx, charCodes)) { 2303 result = EventHandlers.keypressEvent.call(input, keypress, true, false, strict, inputmask.caretPos.begin); 2304 if (result) { 2305 initialNdx = inputmask.caretPos.begin + 1; 2306 charCodes = ""; 2307 } 2308 } else { 2309 result = EventHandlers.keypressEvent.call(input, keypress, true, false, strict, lvp + 1); 2310 } 2311 if (result) { 2312 writeBuffer(undefined, getBuffer(), result.forwardPosition, keypress, false); 2313 inputmask.caretPos = { 2314 begin: result.forwardPosition, 2315 end: result.forwardPosition 2316 }; 2317 } 2318 } 2319 } 2320 }); 2321 if (writeOut) writeBuffer(input, getBuffer(), result ? result.forwardPosition : undefined, initiatingEvent || new $.Event("checkval"), initiatingEvent && initiatingEvent.type === "input"); 2322 } 2323 function unmaskedvalue(input) { 2324 if (input) { 2325 if (input.inputmask === undefined) { 2326 return input.value; 2327 } 2328 if (input.inputmask && input.inputmask.refreshValue) { 2329 EventHandlers.setValueEvent.call(input); 2330 } 2331 } 2332 var umValue = [], vps = getMaskSet().validPositions; 2333 for (var pndx in vps) { 2334 if (vps[pndx].match && vps[pndx].match.fn != null) { 2335 umValue.push(vps[pndx].input); 2336 } 2337 } 2338 var unmaskedValue = umValue.length === 0 ? "" : (isRTL ? umValue.reverse() : umValue).join(""); 2339 if ($.isFunction(opts.onUnMask)) { 2340 var bufferValue = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join(""); 2341 unmaskedValue = opts.onUnMask.call(inputmask, bufferValue, unmaskedValue, opts); 2342 } 2343 return unmaskedValue; 2344 } 2345 function caret(input, begin, end, notranslate) { 2346 function translatePosition(pos) { 2347 if (isRTL && typeof pos === "number" && (!opts.greedy || opts.placeholder !== "") && el) { 2348 pos = el.inputmask._valueGet().length - pos; 2349 } 2350 return pos; 2351 } 2352 var range; 2353 if (begin !== undefined) { 2354 if ($.isArray(begin)) { 2355 end = isRTL ? begin[0] : begin[1]; 2356 begin = isRTL ? begin[1] : begin[0]; 2357 } 2358 if (begin.begin !== undefined) { 2359 end = isRTL ? begin.begin : begin.end; 2360 begin = isRTL ? begin.end : begin.begin; 2361 } 2362 if (typeof begin === "number") { 2363 begin = notranslate ? begin : translatePosition(begin); 2364 end = notranslate ? end : translatePosition(end); 2365 end = typeof end == "number" ? end : begin; 2366 var scrollCalc = parseInt(((input.ownerDocument.defaultView || window).getComputedStyle ? (input.ownerDocument.defaultView || window).getComputedStyle(input, null) : input.currentStyle).fontSize) * end; 2367 input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0; 2368 input.inputmask.caretPos = { 2369 begin: begin, 2370 end: end 2371 }; 2372 if (input === document.activeElement) { 2373 if ("selectionStart" in input) { 2374 input.selectionStart = begin; 2375 input.selectionEnd = end; 2376 } else if (window.getSelection) { 2377 range = document.createRange(); 2378 if (input.firstChild === undefined || input.firstChild === null) { 2379 var textNode = document.createTextNode(""); 2380 input.appendChild(textNode); 2381 } 2382 range.setStart(input.firstChild, begin < input.inputmask._valueGet().length ? begin : input.inputmask._valueGet().length); 2383 range.setEnd(input.firstChild, end < input.inputmask._valueGet().length ? end : input.inputmask._valueGet().length); 2384 range.collapse(true); 2385 var sel = window.getSelection(); 2386 sel.removeAllRanges(); 2387 sel.addRange(range); 2388 } else if (input.createTextRange) { 2389 range = input.createTextRange(); 2390 range.collapse(true); 2391 range.moveEnd("character", end); 2392 range.moveStart("character", begin); 2393 range.select(); 2394 } 2395 renderColorMask(input, { 2396 begin: begin, 2397 end: end 2398 }); 2399 } 2400 } 2401 } else { 2402 if ("selectionStart" in input) { 2403 begin = input.selectionStart; 2404 end = input.selectionEnd; 2405 } else if (window.getSelection) { 2406 range = window.getSelection().getRangeAt(0); 2407 if (range.commonAncestorContainer.parentNode === input || range.commonAncestorContainer === input) { 2408 begin = range.startOffset; 2409 end = range.endOffset; 2410 } 2411 } else if (document.selection && document.selection.createRange) { 2412 range = document.selection.createRange(); 2413 begin = 0 - range.duplicate().moveStart("character", -input.inputmask._valueGet().length); 2414 end = begin + range.text.length; 2415 } 2416 return { 2417 begin: notranslate ? begin : translatePosition(begin), 2418 end: notranslate ? end : translatePosition(en
2418d) 2419 }; 2420 } 2421 } 2422 function determineLastRequiredPosition(returnDefinition) { 2423 var buffer = getMaskTemplate(true, getLastValidPosition(), true, true), bl = buffer.length, pos, lvp = getLastValidPosition(), positions = {}, lvTest = getMaskSet().validPositions[lvp], ndxIntlzr = lvTest !== undefined ? lvTest.locator.slice() : undefined, testPos; 2424 for (pos = lvp + 1; pos < buffer.length; pos++) { 2425 testPos = getTestTemplate(pos, ndxIntlzr, pos - 1); 2426 ndxIntlzr = testPos.locator.slice(); 2427 positions[pos] = $.extend(true, {}, testPos); 2428 } 2429 var lvTestAlt = lvTest && lvTest.alternation !== undefined ? lvTest.locator[lvTest.alternation] : undefined; 2430 for (pos = bl - 1; pos > lvp; pos--) { 2431 testPos = positions[pos]; 2432 if ((testPos.match.optionality || testPos.match.optionalQuantifier && testPos.match.newBlockMarker || lvTestAlt && (lvTestAlt !== positions[pos].locator[lvTest.alternation] && testPos.match.fn != null || testPos.match.fn === null && testPos.locator[lvTest.alternation] && checkAlternationMatch(testPos.locator[lvTest.alternation].toString().split(","), lvTestAlt.toString().split(",")) && getTests(pos)[0].def !== "")) && buffer[pos] === getPlaceholder(pos, testPos.match)) { 2433 bl--; 2434 } else break; 2435 } 2436 return returnDefinition ? { 2437 l: bl, 2438 def: positions[bl] ? positions[bl].match : undefined 2439 } : bl; 2440 } 2441 function clearOptionalTail(buffer) { 2442 buffer.length = 0; 2443 var template = getMaskTemplate(true, 0, true, undefined, true), lmnt, validPos; 2444 while (lmnt = template.shift(), lmnt !== undefined) { 2445 buffer.push(lmnt); 2446 } 2447 return buffer; 2448 } 2449 function isComplete(buffer) { 2450 if ($.isFunction(opts.isComplete)) return opts.isComplete(buffer, opts); 2451 if (opts.repeat === "*") return undefined; 2452 var complete = false, lrp = determineLastRequiredPosition(true), aml = seekPrevious(lrp.l); 2453 if (lrp.def === undefined || lrp.def.newBlockMarker || lrp.def.optionality || lrp.def.optionalQuantifier) { 2454 complete = true; 2455 for (var i = 0; i <= aml; i++) { 2456 var test = getTestTemplate(i).match; 2457 if (test.fn !== null && getMaskSet().validPositions[i] === undefined && test.optionality !== true && test.optionalQuantifier !== true || test.fn === null && buffer[i] !== getPlaceholder(i, test)) { 2458 complete = false; 2459 break; 2460 } 2461 } 2462 } 2463 return complete; 2464 } 2465 function handleRemove(input, k, pos, strict, fromIsValid) { 2466 if (opts.numericInput || isRTL) { 2467 if (k === Inputmask.keyCode.BACKSPACE) { 2468 k = Inputmask.keyCode.DELETE; 2469 } else if (k === Inputmask.keyCode.DELETE) { 2470 k = Inputmask.keyCode.BACKSPACE; 2471 } 2472 if (isRTL) { 2473 var pend = pos.end; 2474 pos.end = pos.begin; 2475 pos.begin = pend; 2476 } 2477 } 2478 if (k === Inputmask.keyCode.BACKSPACE && pos.end - pos.begin < 1) { 2479 pos.begin = seekPrevious(pos.begin); 2480 if (getMaskSet().validPositions[pos.begin] !== undefined && getMaskSet().validPositions[pos.begin].input === opts.groupSeparator) { 2481 pos.begin--; 2482 } 2483 } else if (k === Inputmask.keyCode.DELETE && pos.begin === pos.end) { 2484 pos.end = isMask(pos.end, true) && getMaskSet().validPositions[pos.end] && getMaskSet().validPositions[pos.end].input !== opts.radixPoint ? pos.end + 1 : seekNext(pos.end) + 1; 2485 if (getMaskSet().validPositions[pos.begin] !== undefined && getMaskSet().validPositions[pos.begin].input === opts.groupSeparator) { 2486 pos.end++; 2487 } 2488 } 2489 revalidateMask(pos); 2490 if (strict !== true && opts.keepStatic !== false || opts.regex !== null) { 2491 var result = alternate(true); 2492 if (result) { 2493 var newPos = result.caret !== undefined ? result.caret : result.pos ? seekNext(result.pos.begin ? result.pos.begin : result.pos) : getLastValidPosition(-1, true); 2494 if (k !== Inputmask.keyCode.DELETE || pos.begin > newPos) { 2495 pos.begin == newPos; 2496 } 2497 } 2498 } 2499 var lvp = getLastValidPosition(pos.begin, true); 2500 if (lvp < pos.begin || pos.begin === -1) { 2501 getMaskSet().p = seekNext(lvp); 2502 } else if (strict !== true) { 2503 getMaskSet().p = pos.begin; 2504 if (fromIsValid !== true) { 2505 while (getMaskSet().p < lvp && getMaskSet().validPositions[getMaskSet().p] === undefined) { 2506 getMaskSet().p++; 2507 } 2508 } 2509 } 2510 } 2511 function initializeColorMask(input) { 2512 var computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null); 2513 function findCaretPos(clientx) { 2514 var e = document.createElement("span"), caretPos; 2515 for (var style in computedStyle) { 2516 if (isNaN(style) && style.indexOf("font") !== -1) { 2517 e.style[style] = computedStyle[style]; 2518 } 2519 } 2520 e.style.textTransform = computedStyle.textTransform; 2521 e.style.letterSpacing = computedStyle.letterSpacing; 2522 e.style.position = "absolute"; 2523 e.style.height = "auto"; 2524 e.style.width = "auto"; 2525 e.style.visibility = "hidden"; 2526 e.style.whiteSpace = "nowrap"; 2527 document.body.appendChild(e); 2528 var inputText = input.inputmask._valueGet(), previousWidth = 0, itl; 2529 for (caretPos = 0, itl = inputText.length; caretPos <= itl;
2529 caretPos++) { 2530 e.innerHTML += inputText.charAt(caretPos) || "_"; 2531 if (e.offsetWidth >= clientx) { 2532 var offset1 = clientx - previousWidth; 2533 var offset2 = e.offsetWidth - clientx; 2534 e.innerHTML = inputText.charAt(caretPos); 2535 offset1 -= e.offsetWidth / 3; 2536 caretPos = offset1 < offset2 ? caretPos - 1 : caretPos; 2537 break; 2538 } 2539 previousWidth = e.offsetWidth; 2540 } 2541 document.body.removeChild(e); 2542 return caretPos; 2543 } 2544 var template = document.createElement("div"); 2545 template.style.width = computedStyle.width; 2546 template.style.textAlign = computedStyle.textAlign; 2547 colorMask = document.createElement("div"); 2548 input.inputmask.colorMask = colorMask; 2549 colorMask.className = "im-colormask"; 2550 input.parentNode.insertBefore(colorMask, input); 2551 input.parentNode.removeChild(input); 2552 colorMask.appendChild(input); 2553 colorMask.appendChild(template); 2554 input.style.left = template.offsetLeft + "px"; 2555 $(colorMask).on("mouseleave", function(e) { 2556 return EventHandlers.mouseleaveEvent.call(input, [ e ]); 2557 }); 2558 $(colorMask).on("mouseenter", function(e) { 2559 return EventHandlers.mouseenterEvent.call(input, [ e ]); 2560 }); 2561 $(colorMask).on("click", function(e) { 2562 caret(input, findCaretPos(e.clientX)); 2563 return EventHandlers.clickEvent.call(input, [ e ]); 2564 }); 2565 } 2566 Inputmask.prototype.positionColorMask = function(input, template) { 2567 input.style.left = template.offsetLeft + "px"; 2568 }; 2569 function renderColorMask(input, caretPos, clear) { 2570 var maskTemplate = [], isStatic = false, test, testPos, ndxIntlzr, pos = 0; 2571 function setEntry(entry) { 2572 if (entry === undefined) entry = ""; 2573 if (!isStatic && (test.fn === null || testPos.input === undefined)) { 2574 isStatic = true; 2575 maskTemplate.push("<span class='im-static'>" + entry); 2576 } else if (isStatic && (test.fn !== null && testPos.input !== undefined || test.def === "")) { 2577 isStatic = false; 2578 var mtl = maskTemplate.length; 2579 maskTemplate[mtl - 1] = maskTemplate[mtl - 1] + "</span>"; 2580 maskTemplate.push(entry); 2581 } else maskTemplate.push(entry); 2582 } 2583 function setCaret() { 2584 if (document.activeElement === input) { 2585 maskTemplate.splice(caretPos.begin, 0, caretPos.begin === caretPos.end || caretPos.end > getMaskSet().maskLength ? '<mark class="im-caret" style="border-right-width: 1px;border-right-style: solid;">' : '<mark class="im-caret-select">'); 2586 maskTemplate.splice(caretPos.end + 1, 0, "</mark>"); 2587 } 2588 } 2589 if (colorMask !== undefined) { 2590 var buffer = getBuffer(); 2591 if (caretPos === undefined) { 2592 caretPos = caret(input); 2593 } else if (caretPos.begin === undefined) { 2594 caretPos = { 2595 begin: caretPos, 2596 end: caretPos 2597 }; 2598 } 2599 if (clear !== true) { 2600 var lvp = getLastValidPosition(); 2601 do { 2602 if (getMaskSet().validPositions[pos]) { 2603 testPos = getMaskSet().validPositions[pos]; 2604 test = testPos.match; 2605 ndxIntlzr = testPos.locator.slice(); 2606 setEntry(buffer[pos]); 2607 } else { 2608 testPos = getTestTemplate(pos, ndxIntlzr, pos - 1); 2609 test = testPos.match; 2610 ndxIntlzr = testPos.locator.slice(); 2611 if (opts.jitMasking === false || pos < lvp || typeof opts.jitMasking === "number" && isFinite(opts.jitMasking) && opts.jitMasking > pos) { 2612 setEntry(getPlaceholder(pos, test)); 2613 } else isStatic = false;
2614 } 2615 pos++; 2616 } while ((maxLength === undefined || pos < maxLength) && (test.fn !== null || test.def !== "") || lvp > pos || isStatic); 2617 if (isStatic) setEntry(); 2618 setCaret(); 2619 } 2620 var template = colorMask.getElementsByTagName("div")[0]; 2621 template.innerHTML = maskTemplate.join(""); 2622 input.inputmask.positionColorMask(input, template); 2623 } 2624 } 2625 function mask(elem) { 2626 function isElementTypeSupported(input, opts) { 2627 function patchValueProperty(npt) { 2628 var valueGet; 2629 var valueSet; 2630 function patchValhook(type) { 2631 if ($.valHooks && ($.valHooks[type] === undefined || $.valHooks[type].inputmaskpatch !== true)) { 2632 var valhookGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function(elem) { 2633 return elem.value; 2634 }; 2635 var valhookSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function(elem, value) { 2636 elem.value = value; 2637 return elem; 2638 }; 2639 $.valHooks[type] = { 2640 get: function get(elem) { 2641 if (elem.inputmask) { 2642 if (elem.inputmask.opts.autoUnmask) { 2643 return elem.inputmask.unmaskedvalue(); 2644 } else { 2645 var result = valhookGet(elem); 2646 return getLastValidPosition(undefined, undefined, elem.inputmask.maskset.validPositions) !== -1 || opts.nullable !== true ? result : ""; 2647 } 2648 } else return valhookGet(elem); 2649 }, 2650 set: function set(elem, value) { 2651 var $elem = $(elem), result; 2652 result = valhookSet(elem, value); 2653 if (elem.inputmask) { 2654 $elem.trigger("setvalue", [ value ]); 2655 } 2656 return result; 2657 }, 2658 inputmaskpatch: true 2659 }; 2660 } 2661 } 2662 function getter() { 2663 if (this.inputmask) { 2664 return this.inputmask.opts.autoUnmask ? this.inputmask.unmaskedvalue() : getLastValidPosition() !== -1 || opts.nullable !== true ? document.activeElement === this && opts.clearMaskOnLostFocus ? (isRTL ? clearOptionalTail(getBuffer().slice()).reverse() : clearOptionalTail(getBuffer().slice())).join("") : valueGet.call(this) : ""; 2665 } else return valueGet.call(this); 2666 } 2667 function setter(value) { 2668 valueSet.call(this, value); 2669 if (this.inputmask) { 2670 $(this).trigger("setvalue", [ value ]); 2671 } 2672 } 2673 function installNativeValueSetFallback(npt) { 2674 EventRuler.on(npt, "mouseenter", function(event) { 2675 var $input = $(this), input = this, value = input.inputmask._valueGet(); 2676 if (value !== getBuffer().join("")) { 2677 $input.trigger("setvalue"); 2678 } 2679 }); 2680 } 2681 if (!npt.inputmask.__valueGet) { 2682 if (opts.noValuePatching !== true) { 2683 if (Object.getOwnPropertyDescriptor) { 2684 if (typeof Object.getPrototypeOf
2684!== "function") { 2685 Object.getPrototypeOf = _typeof("test".__proto__) === "object" ? function(object) { 2686 return object.__proto__; 2687 } : function(object) { 2688 return object.constructor.prototype; 2689 }; 2690 } 2691 var valueProperty = Object.getPrototypeOf ? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(npt), "value") : undefined; 2692 if (valueProperty && valueProperty.get && valueProperty.set) { 2693 valueGet = valueProperty.get; 2694 valueSet = valueProperty.set; 2695 Object.defineProperty(npt, "value", { 2696 get: getter, 2697 set: setter, 2698 configurable: true 2699 }); 2700 } else if (npt.tagName !== "INPUT") { 2701 valueGet = function valueGet() { 2702 return this.textContent; 2703 }; 2704 valueSet = function valueSet(value) { 2705 this.textContent = value; 2706 }; 2707 Object.defineProperty(npt, "value", { 2708 get: getter, 2709 set: setter, 2710 configurable: true 2711 }); 2712 } 2713 } else if (document.__lookupGetter__ && npt.__lookupGetter__("value")) { 2714 valueGet = npt.__lookupGetter__("value"); 2715 valueSet = npt.__lookupSetter__("value"); 2716 npt.__defineGetter__("value", getter); 2717 npt.__defineSetter__("value", setter); 2718 } 2719 npt.inputmask.__valueGet = valueGet; 2720 npt.inputmask.__valueSet = valueSet; 2721 } 2722 npt.inputmask._valueGet = function(overruleRTL) { 2723 return isRTL && overruleRTL !== true ? valueGet.call(this.el).split("").reverse().join("") : valueGet.call(this.el); 2724 }; 2725 npt.inputmask._valueSet = function(value, overruleRTL) { 2726 valueSet.call(this.el, value === null || value === undefined ? "" : overruleRTL !== true && isRTL ? value.split("").reverse().join("") : value); 2727 }; 2728 if (valueGet === undefined) { 2729 valueGet = function valueGet() { 2730 return this.value; 2731 }; 2732 valueSet = function valueSet(value) { 2733 this.value = value; 2734 }; 2735 patchValhook(npt.type); 2736 installNativeValueSetFallback(npt); 2737 } 2738 } 2739 } 2740 var elementType = input.getAttribute("type"); 2741 var isSupported = input.tagName === "INPUT" && $.inArray(elementType, opts.supportsInputType) !== -1 || input.isContentEditable || input.tagName === "TEXTAREA"; 2742 if (!isSupported) { 2743 if (input.tagName === "INPUT") { 2744 var el = document.createElement("input"); 2745 el.setAttribute("type", elementType); 2746 isSupported = el.type === "text"; 2747 el = null; 2748 } else isSupported = "partial"; 2749 } 2750 if (isSupported !== false) { 2751 patchValueProperty(input); 2752 } else input.inputmask = undefined; 2753 return isSupported; 2754 } 2755 EventRuler.off(elem); 2756 var isSupported = isElementTypeSupported(elem, opts); 2757 if (isSupported !== false) { 2758 el = elem; 2759 $el = $(el); 2760 originalPlaceholder = el.placeholder; 2761 maxLength = el !== undefined ? el.maxLength : undefined; 2762 if (maxLength === -1) maxLength = undefined; 2763 if (opts.colorMask === true) { 2764 initializeColorMask(el); 2765 } 2766 if (mobile) { 2767 if ("inputmode" in el) { 2768 el.inputmode = opts.inputmode; 2769 el.setAttribute("inputmode", opts.inputmode); 2770 } 2771 if (opts.disablePredictiveText === true) { 2772 if ("autocorrect" in el) { 2773 el.autocorrect = false;
2774 } else { 2775 if (opts.colorMask !== true) { 2776 initializeColorMask(el); 2777 } 2778 el.type = "password"; 2779 } 2780 } 2781 } 2782 if (isSupported === true) { 2783 el.setAttribute("im-insert", opts.insertMode); 2784 EventRuler.on(el, "submit", EventHandlers.submitEvent); 2785 EventRuler.on(el, "reset", EventHandlers.resetEvent); 2786 EventRuler.on(el, "blur", EventHandlers.blurEvent); 2787 EventRuler.on(el, "focus", EventHandlers.focusEvent); 2788 if (opts.colorMask !== true) { 2789 EventRuler.on(el, "click", EventHandlers.clickEvent); 2790 EventRuler.on(el, "mouseleave", EventHandlers.mouseleaveEvent); 2791 EventRuler.on(el, "mouseenter", EventHandlers.mouseenterEvent); 2792 } 2793 EventRuler.on(el, "paste", EventHandlers.pasteEvent); 2794 EventRuler.on(el, "cut", EventHandlers.cutEvent); 2795 EventRuler.on(el, "complete", opts.oncomplete); 2796 EventRuler.on(el, "incomplete", opts.onincomplete); 2797 EventRuler.on(el, "cleared", opts.oncleared); 2798 if (!mobile && opts.inputEventOnly !== true) { 2799 EventRuler.on(el, "keydown", EventHandlers.keydownEvent); 2800 EventRuler.on(el, "keypress", EventHandlers.keypressEvent); 2801 } else { 2802 el.removeAttribute("maxLength"); 2803 } 2804 EventRuler.on(el, "input", EventHandlers.inputFallBackEvent); 2805 EventRuler.on(el, "beforeinput", EventHandlers.beforeInputEvent); 2806 } 2807 EventRuler.on(el, "setvalue", EventHandlers.setValueEvent); 2808 undoValue = getBufferTemplate().join(""); 2809 if (el.inputmask._valueGet(true) !== "" || opts.clearMaskOnLostFocus === false || document.activeElement === el) { 2810 var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(inputmask, el.inputmask._valueGet(true), opts) || el.inputmask._valueGet(true) : el.inputmask._valueGet(true); 2811 if (initialValue !== "") checkVal(el, true, false, initialValue.split("")); 2812 var buffer = getBuffer().slice(); 2813 undoValue = buffer.join(""); 2814 if (isComplete(buffer) === false) { 2815 if (opts.clearIncomplete) { 2816 resetMaskSet(); 2817 } 2818 } 2819 if (opts.clearMaskOnLostFocus && document.activeElement !== el) { 2820 if (getLastValidPosition() === -1) { 2821 buffer = []; 2822 } else { 2823 clearOptionalTail(buffer); 2824 } 2825 } 2826 if (opts.clearMaskOnLostFocus === false || opts.showMaskOnFocus && document.activeElement === el || el.inputmask._valueGet(true) !== "") writeBuffer(el, buffer); 2827 if (document.activeElement === el) { 2828 caret(el, seekNext(getLastValidPosition())); 2829 } 2830 } 2831 } 2832 } 2833 var valueBuffer; 2834 if (actionObj !== undefined) { 2835 switch (actionObj.action) { 2836 case "isComplete": 2837 el = actionObj.el; 2838 return isComplete(getBuffer()); 2839 2840 case "unmaskedvalue": 2841 if (el === undefined || actionObj.value !== undefined) { 2842 valueBuffer = actionObj.value; 2843 valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(inputmask, valueBuffer, opts) || valueBuffer : valueBuffer).split(""); 2844 checkVal.call(this, undefined, false, false, valueBuffer); 2845 if ($.isFunction(opts.onBeforeWrite)) opts.onBeforeWrite.call(inputmask, undefined, getBuffer(), 0, opts); 2846 } 2847 return unmaskedvalue(el); 2848 2849 case "mask": 2850 mask(el); 2851 break; 2852 2853 case "format": 2854 valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(inputmask, actionObj.value, opts) || actionObj.value : actionObj.value).split(""); 2855 checkVal.call(this, undefined, true, false, valueBuffer); 2856 if (actionObj.metadata) { 2857 return { 2858 value: isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join(""), 2859 metadata: maskScope.call(this, { 2860 action: "getmetadata" 2861 }, maskset, opts) 2862 }; 2863 } 2864 return isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join(""); 2865 2866 case "isValid": 2867 if (actionObj.value) { 2868 valueBuffer = actionObj.value.split(""); 2869 checkVal.call(this, undefined, true, true, valueBuffer); 2870 } else { 2871 actionObj.value = getBuffer().join(""); 2872 } 2873 var buffer = getBuffer(); 2874 var rl = determineLastRequiredPosition(), lmib = buffer.length - 1; 2875 for (;lmib > rl; lmib--) { 2876 if (isMask(lmib)) break; 2877 } 2878 buffer.splice(rl, lmib + 1 - rl); 2879 return isComplete(buffer) && actionObj.value === getBuffer().join(""); 2880 2881 case "getemptymask": 2882 return getBufferTemplate().join(""); 2883 2884 case "remove": 2885 if (el && el.inputmask) { 2886 $.data(el, "_inputmask_opts", null); 2887 $el = $(el); 2888 el.inputmask._valueSet(opts.autoUnmask ? unmaskedvalue(el) : el.inputmask._valueGet(true)); 2889 EventRuler.off(el); 2890 if (el.inputmask.colorMask) { 2891 colorMask = el.inputmask.colorMask; 2892 colorMask.removeChild(el); 2893 colorMask.parentNode.insertBefore(el, colorMask); 2894 colorMask.parentNode.removeChild(colorMask); 2895 } 2896 var valueProperty; 2897 if (Object.getOwnPropertyDescriptor && Ob
2897ject.getPrototypeOf) { 2898 valueProperty = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(el), "value"); 2899 if (valueProperty) { 2900 if (el.inputmask.__valueGet) { 2901 Object.defineProperty(el, "value", { 2902 get: el.inputmask.__valueGet, 2903 set: el.inputmask.__valueSet, 2904 configurable: true 2905 }); 2906 } 2907 } 2908 } else if (document.__lookupGetter__ && el.__lookupGetter__("value")) { 2909 if (el.inputmask.__valueGet) { 2910 el.__defineGetter__("value", el.inputmask.__valueGet); 2911 el.__defineSetter__("value", el.inputmask.__valueSet); 2912 } 2913 } 2914 el.inputmask = undefined; 2915 } 2916 return el; 2917 break; 2918 2919 case "getmetadata": 2920 if ($.isArray(maskset.metadata)) { 2921 var maskTarget = getMaskTemplate(true, 0, false).join(""); 2922 $.each(maskset.metadata, function(ndx, mtdt) { 2923 if (mtdt.mask === maskTarget) { 2924 maskTarget = mtdt; 2925 return false; 2926 } 2927 }); 2928 return maskTarget; 2929 } 2930 return maskset.metadata; 2931 } 2932 } 2933 } 2934 return Inputmask; 2935 }); 2936}, function(module, exports, __webpack_require__) { 2937 "use strict"; 2938 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__; 2939 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) { 2940 return typeof obj; 2941 } : function(obj) { 2942 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 2943 }; 2944 (function(factory) { 2945 if (true) { 2946 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(4) ], __WEBPACK_AMD_DEFINE_FACTORY__ = factory, 2947 __WEBPACK_AMD_DEFINE_RESULT__ = typeof __WEBPACK_AMD_DEFINE_FACTORY__ === "function" ? __WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__) : __WEBPACK_AMD_DEFINE_FACTORY__, 2948 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 2949 } else {} 2950 })(function($) { 2951 return $; 2952 }); 2953}, function(module, exports) { 2954 module.exports = jQuery; 2955}, function(module, exports, __webpack_require__) { 2956 "use strict"; 2957 var __WEBPACK_AMD_DEFINE_RESULT__; 2958 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) { 2959 return typeof obj; 2960 } : function(obj) { 2961 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 2962 }; 2963 if (true) !(__WEBPACK_AMD_DEFINE_RESULT__ = function() { 2964 return window || new (eval("require('jsdom')")("").window)(); 2965 }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); else {} 2966}, function(module, exports, __webpack_require__) { 2967 "use strict"; 2968 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__; 2969 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) { 2970 return typeof obj; 2971 } : function(obj) { 2972 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 2973 }; 2974 (function(factory) { 2975 if (true) { 2976 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(2) ], __WEBPACK_AMD_DEFINE_FACTORY__ = factory, 2977 __WEBPACK_AMD_DEFINE_RESULT__ = typeof __WEBPACK_AMD_DEFINE_FACTORY__ === "function" ? __WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__) : __WEBPACK_AMD_DEFINE_FACTORY__, 2978 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 2979 } else {} 2980 })(function(Inputmask) { 2981 var $ = Inputmask.dependencyLib; 2982 var formatCode = { 2983 d: [ "[1-9]|[12][0-9]|3[01]", Date.prototype.setDate, "day", Date.prototype.getDate ], 2984 dd: [ "0[1-9]|[12][0-9]|3[01]", Date.prototype.setDate, "day", function() { 2985 return pad(Date.prototype.getDate.call(this), 2); 2986 } ], 2987 ddd: [ "" ], 2988 dddd: [ "" ], 2989 m: [ "[1-9]|1[012]", Date.prototype.setMonth, "month", function() { 2990 return Date.prototype.getMonth.call(this) + 1; 2991 } ], 2992 mm: [ "0[1-9]|1[012]", Date.prototype.setMonth, "month", function() { 2993 return pad(Date.prototype.getMonth.call(this) + 1, 2); 2994 } ], 2995 mmm: [ "" ], 2996 mmmm: [ "" ], 2997 yy: [ "[0-9]{2}", Date.prototype.setFullYear, "year", function() { 2998 return pad(Date.prototype.getFullYear.call(this), 2); 2999 } ], 3000 yyyy: [ "[0-9]{4}", Date.prototype.setFullYear, "year", function() { 3001 return pad(Date.prototype.getFullYear.call(this), 4); 3002 } ], 3003 h: [ "[1-9]|1[0-2]", Date.prototype.setHours, "hours", Date.prototype.getHours ], 3004 hh: [ "0[1-9]|1[0-2]", Date.prototype.setHours, "hours", function() { 3005 return pad(Date.prototype.getHours.call(this), 2); 3006 } ], 3007 hhh: [ "[0-9]+", Date.prototype.setHours, "hours", Date.prototype.getHours ], 3008 H: [ "1?[0-9]|2[0-3]", Date.prototype.setHours, "hours", Date.prototype.getHours ], 3009 HH: [ "[01][0-9]|2[0-3]", Date.prototype.setHours, "hours", function() { 3010 return pad(Date.prototype.getHours.call(this), 2); 3011 } ], 3012 HHH: [ "[0-9]+", Date.prototype.setHours, "hours", Date.prototype.getHours ], 3013 M: [ "[1-5]?[0-9]", Date.prototype.setMinutes, "minutes", Date.prototype.getMinutes ], 3014 MM: [ "[0-5][0-9]", Date.prototype.setMinutes, "minutes", function() { 3015 return pad(Date.prototype.getMinutes.call(this), 2); 3016 } ], 3017 s: [ "[1-5]?[0-9]", Date.prototype.setSeconds, "seconds", Date.prototype.getSeconds ], 3018 ss: [ "[0-5][0-9]", Date.prototype.setSeconds, "seconds", function() { 3019 return pad(Date.prototype.getSeconds.call(this), 2); 3020 } ], 3021 l: [ "[0-9]{3}", Date.prototype.setMilliseconds, "milliseconds", function() { 3022 return pad(Date.prototype.getMilliseconds.call(this), 3); 3023 } ], 3024 L: [ "[0-9]{2}", Date.prototype.setMilliseconds, "milliseconds", function() { 3025 return pad(Date.prototype.getMilliseconds.call(this), 2); 3026 } ], 3027 t: [ "[ap]" ], 3028 tt: [ "[ap]m" ], 3029 T: [ "[AP]" ], 3030 TT: [ "[AP]M" ], 3031 Z: [ "" ], 3032 o: [ "" ], 3033 S: [ "" ] 3034 }, formatAlias = { 3035 isoDate: "yyyy-mm-dd", 3036 isoTime: "HH:MM:ss", 3037 isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", 3038 isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" 3039 }; 3040 function getTokenizer(opts) { 3041 if (!opts.tokenizer) { 3042 var tokens = []; 3043 for (var ndx in formatCode) { 3044 if (tokens.indexOf(ndx[0]) === -1) tokens.push(ndx[0]); 3045 } 3046 opts.tokenizer = "(" + tokens.join("+|") + ")+?|."; 3047 opts.tokenizer = new RegExp(opts.tokenizer, "g"); 3048 } 3049 return opts.tokenizer; 3050 } 3051 function isValidDate(dateParts, currentResult) { 3052 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;
3053 } 3054 function isDateInRange(dateParts, opts) { 3055 var result = true; 3056 if (opts.min) { 3057 if (dateParts["rawyear"]) { 3058 var rawYear = dateParts["rawyear"].replace(/[^0-9]/g, ""), minYear = opts.min.year.substr(0, rawYear.length); 3059 result = minYear <= rawYear; 3060 } 3061 if (dateParts["year"] === dateParts["rawyear"]) { 3062 if (opts.min.date.getTime() === opts.min.date.getTime()) { 3063 result = opts.min.date.getTime() <= dateParts.date.getTime(); 3064 } 3065 } 3066 } 3067 if (result && opts.max && opts.max.date.getTime() === opts.max.date.getTime()) { 3068 result = opts.max.date.getTime() >= dateParts.date.getTime(); 3069 } 3070 return result; 3071 } 3072 function parse(format, dateObjValue, opts, raw) { 3073 var mask = "", match; 3074 while (match = getTokenizer(opts).exec(format)) { 3075 if (dateObjValue === undefined) { 3076 if (formatCode[match[0]]) { 3077 mask += "(" + formatCode[match[0]][0] + ")"; 3078 } else { 3079 switch (match[0]) { 3080 case "[": 3081 mask += "("; 3082 break; 3083 3084 case "]": 3085 mask += ")?"; 3086 break; 3087 3088 default: 3089 mask += Inputmask.escapeRegex(match[0]); 3090 } 3091 } 3092 } else { 3093 if (formatCode[match[0]]) { 3094 if (raw !== true && formatCode[match[0]][3]) { 3095 var getFn = formatCode[match[0]][3]; 3096 mask += getFn.call(dateObjValue.date); 3097 } else if (formatCode[match[0]][2]) mask += dateObjValue["raw" + formatCode[match[0]][2]]; else mask += match[0]; 3098 } else mask += match[0]; 3099 } 3100 } 3101 return mask; 3102 } 3103 function pad(val, len) { 3104 val = String(val); 3105 len = len || 2; 3106 while (val.length < len) { 3107 val = "0" + val; 3108 } 3109 return val; 3110 } 3111 function analyseMask(maskString, format, opts) { 3112 var dateObj = { 3113 date: new Date(1, 0, 1) 3114 }, targetProp, mask = maskString, match, dateOperation, targetValidator; 3115 function extendProperty(value) { 3116 var correctedValue = value.replace(/[^0-9]/g, "0"); 3117 if (correctedValue != value) { 3118 var enteredPart = value.replace(/[^0-9]/g, ""), min = (opts.min && opts.min[targetProp] || value).toString(), max = (opts.max && opts.max[targetProp] || value).toString(); 3119 correctedValue = enteredPart + (enteredPart < min.slice(0, enteredPart.length) ? min.slice(enteredPart.length) : enteredPart > max.slice(0, enteredPart.length) ? max.slice(enteredPart.length) : correctedValue.toString().slice(enteredPart.length)); 3120 } 3121 return correctedValue; 3122 } 3123 function setValue(dateObj, value, opts) { 3124 dateObj[targetProp] = extendProperty(value); 3125 dateObj["raw" + targetProp] = value; 3126 if (dateOperation !== undefined) dateOperation.call(dateObj.date, targetProp == "month" ? parseInt(dateObj[targetProp]) - 1 : dateObj[targetProp]); 3127 } 3128 if (typeof mask === "string") { 3129 while (match = getTokenizer(opts).exec(format)) { 3130 var value = mask.slice(0, match[0].length); 3131 if (formatCode.hasOwnProperty(match[0])) { 3132 targetValidator = formatCode[match[0]][0]; 3133 targetProp = formatCode[match[0]][2]; 3134 dateOperation = formatCode[match[0]][1]; 3135 setValue(dateObj, value, opts); 3136 } 3137 mask = mask.slice(value.length); 3138 } 3139 return dateObj; 3140 } else if (mask && (typeof mask === "undefined" ? "undefined" : _typeof(mask)) === "object" && mask.hasOwnProperty("date")) { 3141 return mask; 3142 } 3143 return undefined; 3144 } 3145 Inputmask.extendAliases({ 3146 datetime: { 3147 mask: function mask(opts) { 3148 formatCode.S = opts.i18n.ordinalSuffix.join("|"); 3149 opts.inputFormat = formatAlias[opts.inputFormat] || opts.inputFormat; 3150 opts.displayFormat = formatAlias[opts.displayFormat] || opts.displayFormat || opts.inputFormat; 3151 opts.outputFormat = formatAlias[opts.outputFormat] || opts.outputFormat || opts.inputFormat; 3152 opts.placeholder = opts.placeholder !== "" ? opts.placeholder : opts.inputFormat.replace(/[\[\]]/, ""); 3153 opts.regex = parse(opts.inputFormat, undefined, opts); 3154 return null; 3155 }, 3156 placeholder: "", 3157 inputFormat: "isoDateTime", 3158 displayFormat: undefined, 3159 outputFormat: undefined, 3160 min: null, 3161 max: null, 3162 i18n: { 3163 dayNames: [ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ], 3164 monthNames: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "
3164November", "December" ], 3165 ordinalSuffix: [ "st", "nd", "rd", "th" ] 3166 }, 3167 postValidation: function postValidation(buffer, pos, currentResult, opts) { 3168 opts.min = analyseMask(opts.min, opts.inputFormat, opts); 3169 opts.max = analyseMask(opts.max, opts.inputFormat, opts); 3170 var result = currentResult, dateParts = analyseMask(buffer.join(""), opts.inputFormat, opts); 3171 if (result && dateParts.date.getTime() === dateParts.date.getTime()) { 3172 result = isValidDate(dateParts, result); 3173 result = result && isDateInRange(dateParts, opts); 3174 } 3175 if (pos && result && currentResult.pos !== pos) { 3176 return { 3177 buffer: parse(opts.inputFormat, dateParts, opts), 3178 refreshFromBuffer: { 3179 start: pos, 3180 end: currentResult.pos 3181 } 3182 }; 3183 } 3184 return result; 3185 }, 3186 onKeyDown: function onKeyDown(e, buffer, caretPos, opts) { 3187 var input = this; 3188 if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) { 3189 var today = new Date(), match, date = ""; 3190 while (match = getTokenizer(opts).exec(opts.inputFormat)) { 3191 if (match[0].charAt(0) === "d") { 3192 date += pad(today.getDate(), match[0].length); 3193 } else if (match[0].charAt(0) === "m") { 3194 date += pad(today.getMonth() + 1, match[0].length); 3195 } else if (match[0] === "yyyy") { 3196 date += today.getFullYear().toString(); 3197 } else if (match[0].charAt(0) === "y") { 3198 date += pad(today.getYear(), match[0].length); 3199 } 3200 } 3201 input.inputmask._valueSet(date); 3202 $(input).trigger("setvalue"); 3203 } 3204 }, 3205 onUnMask: function onUnMask(maskedValue, unmaskedValue, opts) { 3206 return parse(opts.outputFormat, analyseMask(maskedValue, opts.inputFormat, opts), opts, true); 3207 }, 3208 casing: function casing(elem, test, pos, validPositions) { 3209 if (test.nativeDef.indexOf("[ap]") == 0) return elem.toLowerCase(); 3210 if (test.nativeDef.indexOf("[AP]") == 0) return elem.toUpperCase(); 3211 return elem; 3212 }, 3213 insertMode: false, 3214 shiftPositions: false 3215 } 3216 }); 3217 return Inputmask; 3218 }); 3219}, function(module, exports, __webpack_require__) { 3220 "use strict"; 3221 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__; 3222 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) { 3223 return typeof obj; 3224 } : function(obj) { 3225 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 3226 }; 3227 (function(factory) { 3228 if (true) { 3229 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(2) ], __WEBPACK_AMD_DEFINE_FACTORY__ = factory, 3230 __WEBPACK_AMD_DEFINE_RESULT__ = typeof __WEBPACK_AMD_DEFINE_FACTORY__ === "function" ? __WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__) : __WEBPACK_AMD_DEFINE_FACTORY__, 3231 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 3232 } else {} 3233 })(function(Inputmask) { 3234 var $ = Inputmask.dependencyLib; 3235 function autoEscape(txt, opts) { 3236 var escapedTxt = ""; 3237 for (var i = 0; i < txt.length; i++) { 3238 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)) { 3239 escapedTxt += "\\" + txt.charAt(i); 3240 } else escapedTxt += txt.charAt(i); 3241 } 3242 return escapedTxt; 3243 } 3244 function alignDigits(buffer, digits, opts) { 3245 if (digits > 0) { 3246 var radixPosition = $.inArray(opts.radixPoint, buffer); 3247 if (radixPosition === -1) { 3248 buffer.push(opts.radixPoint); 3249 radixPosition = buffer.length - 1; 3250 } 3251 for (var i = 1; i <= digits; i++) { 3252 buffer[radixPosition + i] = buffer[radixPosition + i] || "0"; 3253 } 3254 } 3255 return buffer; 3256 } 3257 Inputmask.extendAliases({ 3258 numeric: { 3259 mask: function mask(opts) { 3260 if (opts.repeat !== 0 && isNaN(opts.integerDigits)) { 3261 opts.integerDigits = opts.repeat; 3262 } 3263 opts.repeat = 0; 3264 if (opts.groupSeparator === opts.radixPoint && opts.digits && opts.digits !== "0") { 3265 if (opts.radixPoint === ".") { 3266 opts.groupSeparator = ","; 3267 } else if (opts.radixPoint === ",") { 3268 opts.groupSeparator = "."; 3269 } else opts.groupSeparator = ""; 3270 } 3271 if (opts.groupSeparator === " ") { 3272 opts.skipOptionalPartCharacter = undefined; 3273 } 3274 opts.autoGroup = opts.autoGroup && opts.groupSeparator !== ""; 3275 if (opts.autoGroup) { 3276 if (typeof opts.groupSize == "string" && isFinite(opts.groupSize)) opts.groupSize = parseInt(opts.groupSize); 3277 if (isFinite(opts.integerDigits)) { 3278 var seps = Math.floor(opts.integerDigits / opts.groupSize); 3279 var mod = opts.integerDigits % opts.groupSize; 3280 opts.integerDigits = parseInt(opts.integerDigits) + (mod === 0 ? seps - 1 : seps); 3281 if (opts.integerDigits < 1) { 3282 opts.integerDigits = "*"; 3283 } 3284 } 3285 } 3286 if (opts.placeholder.length > 1) { 3287 opts.placeholder = opts.placeholder.charAt(0); 3288 } 3289 if (opts.positionCaretOnClick === "radixFocus" && opts.placeholder === "" && opts.integerOptional === false) { 3290 opts.positionCaretOnClick = "lvp"; 3291 } 3292 opts.definitions[";"] = opts.definitions["~"]; 3293 opts.definitions[";"].definitionSymbol = "~"; 3294 if (opts.numericInput === true) { 3295 opts.positionCaretOnClick = opts.positionCaretOnClick === "radixFocus" ? "lvp" : opts.positionCaretOnClick; 3296 opts.digitsOptional = false;
3297 if (isNaN(opts.digits)) opts.digits = 2; 3298 opts.decimalProtect = false; 3299 } 3300 var mask = "[+]"; 3301 mask += autoEscape(opts.prefix, opts); 3302 if (opts.integerOptional === true) { 3303 mask += "~{1," + opts.integerDigits + "}"; 3304 } else mask += "~{" + opts.integerDigits + "}"; 3305 if (opts.digits !== undefined) { 3306 var radixDef = opts.decimalProtect ? ":" : opts.radixPoint; 3307 var dq = opts.digits.toString().split(","); 3308 if (isFinite(dq[0]) && dq[1] && isFinite(dq[1])) { 3309 mask += radixDef + ";{" + opts.digits + "}"; 3310 } else if (isNaN(opts.digits) || parseInt(opts.digits) > 0) { 3311 if (opts.digitsOptional) { 3312 mask += "[" + radixDef + ";{1," + opts.digits + "}]"; 3313 } else mask += radixDef + ";{" + opts.digits + "}"; 3314 } 3315 } 3316 mask += autoEscape(opts.suffix, opts); 3317 mask += "[-]"; 3318 opts.greedy = false; 3319 return mask; 3320 }, 3321 placeholder: "", 3322 greedy: false, 3323 digits: "*", 3324 digitsOptional: true, 3325 enforceDigitsOnBlur: false, 3326 radixPoint: ".", 3327 positionCaretOnClick: "radixFocus", 3328 groupSize: 3, 3329 groupSeparator: "", 3330 autoGroup: false, 3331 allowMinus: true, 3332 negationSymbol: { 3333 front: "-", 3334 back: "" 3335 }, 3336 integerDigits: "+", 3337 integerOptional: true, 3338 prefix: "", 3339 suffix: "", 3340 rightAlign: true, 3341 decimalProtect: true, 3342 min: null, 3343 max: null, 3344 step: 1, 3345 insertMode: true, 3346 autoUnmask: false, 3347 unmaskAsNumber: false, 3348 inputmode: "numeric", 3349 preValidation: function preValidation(buffer, pos, c, isSelection, opts, maskset) { 3350 if (c === "-" || c === opts.negationSymbol.front) { 3351 if (opts.allowMinus !== true) return false; 3352 opts.isNegative = opts.isNegative === undefined ? true : !opts.isNegative; 3353 if (buffer.join("") === "") return true; 3354 return { 3355 caret: maskset.validPositions[pos] ? pos : undefined, 3356 dopost: true 3357 }; 3358 } 3359 if (isSelection === false && c === opts.radixPoint && opts.digits !== undefined && (isNaN(opts.digits) || parseInt(opts.digits) > 0)) { 3360 var radixPos = $.inArray(opts.radixPoint, buffer); 3361 if (radixPos !== -1 && maskset.validPositions[radixPos] !== undefined) { 3362 if (opts.numericInput === true) { 3363 return pos === radixPos; 3364 } 3365 return { 3366 caret: radixPos + 1 3367 }; 3368 } 3369 } 3370 return true; 3371 }, 3372 postValidation: function postValidation(buffer, pos, currentResult, opts) { 3373 function buildPostMask(buffer, opts) { 3374 var postMask = ""; 3375 postMask += "(" + opts.groupSeparator + "*{" + opts.groupSize + "}){*}"; 3376 if (opts.radixPoint !== "") { 3377 var radixSplit = buffer.join("").split(opts.radixPoint); 3378 if (radixSplit[1]) { 3379 postMask += opts.radixPoint + "*{" + radixSplit[1].match(/^\d*\??\d*/)[0].length + "}"; 3380 } 3381 } 3382 return postMask; 3383 } 3384 var suffix = opts.suffix.split(""), prefix = opts.prefix.split(""); 3385 if (currentResult.pos === undefined && currentResult.caret !== undefined && currentResult.dopost !== true) return currentResult; 3386 var caretPos = currentResult.caret !== undefined ? currentResult.caret : currentResult.pos; 3387 var maskedValue = buffer.slice(); 3388 if (opts.numericInput) { 3389 caretPos = maskedValue.length - caretPos - 1; 3390 maskedValue = maskedValue.reverse(); 3391 } 3392 var charAtPos = maskedValue[caretPos]; 3393 if (charAtPos === opts.groupSeparator) { 3394 caretPos += 1; 3395 charAtPos = maskedValue[caretPos]; 3396 } 3397 if (caretPos === maskedValue.length - opts.suffix.length - 1 && charAtPos === opts.radixPoint) return currentResult; 3398 if (charAtPos !== undefined) { 3399 if (charAtPos !== opts.radixPoint && charAtPos !== opts.negationSymbol.front && charAtPos !== opts.negationSymbol.back) { 3400 maskedValue[caretPos] = "?"; 3401 if (opts.prefix.length > 0 && caretPos >= (opts.isNegative === false ? 1 : 0) && caretPos < opts.prefix.length - 1 + (opts.isNegative === false ? 1 : 0)) { 3402 prefix[caretPos - (opts.isNegative === false ? 1 : 0)] = "?"; 3403 } else if (opts.suffix.length > 0 && caretPos >= maskedValue.length - opts.suffix.length - (opts.isNegative === false ? 1 : 0)) { 3404 suffix[caretPos - (maskedValue.length - opts.suffix.length - (opts.isNegative === false ? 1 : 0))] = "?"; 3405 } 3406 } 3407 } 3408 prefix = prefix.join(""); 3409 suffix = suffix.join(""); 3410 var processValue = maskedValue.join("").replace(prefix, ""); 3411 processValue = processValue.replace(suffix, ""); 3412 processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""); 3413 processValue = processValue.replace(new RegExp("[-" + Inputmask.escapeRegex(opts.negationSymbol.front) + "]", "g"), ""); 3414 processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), ""); 3415 if (isNaN(opts.placeholder)) { 3416 processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.placeholder), "g"), ""); 3417 } 3418 if (processValue.length > 1 && processValue.indexOf(opts.radixPoint) !== 1) { 3419 if (charAtPos === "0") { 3420 processValue = processValue.replace(/^\?/g, ""); 3421 } 3422 processValue = processValue.replace(/^0/g, ""); 3423 } 3424 if (processValue.charAt(0) === opts.radixPoint && opts.radixPoint !== "" && opts.numericInput !== true) { 3425 processValue = "0" + processValue; 3426 } 3427 if (processValue !== "") { 3428 processValue = processValue.split(""); 3429 if ((!opts.digitsOptional || opts.enforceDigitsOnBlur && currentResult.event === "blur") && isFinite(opts.digits)) { 3430 var radixPosition = $.inArray(opts.radixPoint, processValue); 3431 var rpb = $.inArray(opts.radixPoint, maskedValue); 3432 if (radixPosition === -1) { 3433 processValue.push(opts.radixPoint); 3434 radixPosition = processValue.length - 1; 3435 } 3436 for (var i = 1; i <= opts.digits; i++) { 3437 if ((!opts.digitsOptional || opts.enforceDigitsOnBlur && currentResult.event === "blur") && (processValue[radixPosition + i] === undefined || processValue[radixPosition + i] === opts.placeholder.charAt(0))) { 3438 processValue[radixPosition + i] = currentResult.placeholder || opts.placeholder.charAt(0); 3439 } else if (rpb !== -1 && maskedValue[rpb + i] !== undefined) { 3440 processValue[radixPosition + i] = processValue[radixPosition + i] || maskedValue[rpb + i]; 3441 } 3442 } 3443 } 3444 if (opts.autoGroup === true && opts.groupSeparator !== "" && (charAtPos !== opts.radixPoint || currentResult.pos !== undefined || currentResult.dopost)) { 3445 var addRadix = processValue[processValue.length - 1] === opts.radixPoint && currentResult.c === opts.radixPoint; 3446 processValue = Inputmask(buildPostMask(processValue, opts), { 3447 numericInput: true, 3448 jitMasking: true, 3449 definitions: { 3450 "*": { 3451 validator: "[0-9?]", 3452 cardinality: 1 3453 } 3454 } 3455 }).format(processValue.join("")); 3456 if (addRadix) processValue += opts.radixPoint; 3457 if (processValue.charAt(0) === opts.groupSeparator) { 3458 processValue.substr(1); 3459 } 3460 } else processValue = processValue.join(""); 3461 } 3462 if (opts.isNegative && currentResult.event === "blur") { 3463 opts.isNegative = processValue !== "0"; 3464 } 3465 processValue = prefix + processValue; 3466 processValue += suffix; 3467 if (opts.isNegative) { 3468 processValue = opts.negationSymbol.front + processValue; 3469 processValue += opts.negationSymbol.back; 3470 } 3471 processValue = processValue.split(""); 3472 if (charAtPos !== undefined) { 3473 if (charAtPos !== opts.radixPoint && charAtPos !== opts.negationSymbol.front && charAtPos !== opts.negationSymbol.back) { 3474 caretPos = $.inArray("?", processValue); 3475 if (caretPos > -1) { 3476 processValue[caretPos] = charAtPos; 3477 } else caretPos = currentResult.caret || 0; 3478 } else if (charAtPos === opts.radixPoint || charAtPos === opts.negationSymbol.front || charAtPos === opts.negationSymbol.back) { 3479 var newCaretPos = $.inArray(charAtPos, processValue); 3480 if (newCaretPos !== -1) caretPos = newCaretPos; 3481 } 3482 } 3483 if (opts.numericInput) { 3484 caretPos = processValue.length - caretPos - 1; 3485 processValue = processValue.reverse(); 3486 } 3487 var rslt = { 3488 caret: (charAtPos === undefined || currentResult.pos !== undefined) && caretPos !== undefined ? caretPos + (opts.numericInput ? -1 : 1) : caretPos, 3489 buffer: processValue, 3490 refreshFromBuffer: currentResult.dopost || buffer.join("") !== processValue.join("") 3491 }; 3492 return rslt.refreshFromBuffer ? rslt : currentResult; 3493 }, 3494 onBeforeWrite: function onBeforeWrite(e, buffer, caretPos, opts) { 3495 function parseMinMaxOptions(opts) { 3496 if (opts.parseMinMaxOptions === undefined) { 3497 if (opts.min !== null) { 3498 opts.min = opts.min.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""); 3499 if (opts.radixPoint === ",") opts.min = opts.min.replace(opts.radixPoint, "."); 3500 opts.min = isFinite(opts.min) ? parseFloat(opts.min) : NaN; 3501 if (isNaN(opts.min)) opts.min = Number.MIN_VALUE; 3502 } 3503 if (opts.max !== null) { 3504 opts.max = opts.max.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""); 3505 if (opts.radixPoint === ",") opts.max = opts.max.replace(opts.radixPoint, "."); 3506 opts.max = isFinite(opts.max) ? parseFloat(opts.max) : NaN; 3507 if (isNaN(opts.max)) opts.max = Number.MAX_VALUE; 3508 } 3509 opts.parseMinMaxOptions = "done"; 3510 } 3511 } 3512 if (e) { 3513 switch (e.type) { 3514 case "keydown": 3515 return opts.postValidation(buffer, caretPos, { 3516 caret: caretPos, 3517 dopost: true 3518 }, opts); 3519 3520 case "blur": 3521 case "checkval": 3522 var unmasked; 3523 parseMinMaxOptions(opts); 3524 if (opts.min !== null || opts.max !== null) { 3525 unmasked = opts.onUnMask(buffer.join(""), undefined, $.extend({}, opts, { 3526 unmaskAsNumber: true 3527 })); 3528 if (opts.min !== null && unmasked < opts.min) { 3529 opts.isNegative = opts.min < 0; 3530 return opts.postValidation(opts.min.toString().replace(".", opts.radixPoint).split(""), caretPos, { 3531 caret: caretPos, 3532 dopost: true, 3533 placeholder: "0" 3534 }, opts); 3535 } else if (opts.max !== null && unmasked > opts.max) { 3536 opts.isNegative = opts.max < 0; 3537 return opts.postValidation(opts.max.toString().replace(".", opts.radixPoint).split(""), caretPos, { 3538 caret: caretPos, 3539 dopost: true, 3540 placeholder: "0" 3541 }, opts); 3542 } 3543 } 3544 return opts.postValidation(buffer, caretPos, { 3545 caret: caretPos, 3546 placeholder: "0", 3547 event: "blur" 3548 }, opts); 3549 3550 case "_checkval": 3551 return { 3552 caret: caretPos 3553 }; 3554 3555 default: 3556 break; 3557 } 3558 } 3559 }, 3560 regex: { 3561 integerPart: function integerPart(opts, emptyCheck) { 3562 return emptyCheck ? new RegExp("[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "+]?") : new RegExp("[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "+]?\\d+"); 3563 }, 3564 integerNPart: function integerNPart(opts) { 3565 return new RegExp("[\\d" + Inputmask.escapeRegex(opts.groupSeparator) + Inputmask.escapeR
3565egex(opts.placeholder.charAt(0)) + "]+"); 3566 } 3567 }, 3568 definitions: { 3569 "~": { 3570 validator: function validator(chrs, maskset, pos, strict, opts, isSelection) { 3571 var isValid, l; 3572 if (chrs === "k" || chrs === "m") { 3573 isValid = { 3574 insert: [], 3575 c: 0 3576 }; 3577 for (var i = 0, l = chrs === "k" ? 2 : 5; i < l; i++) { 3578 isValid.insert.push({ 3579 pos: pos + i, 3580 c: 0 3581 }); 3582 } 3583 isValid.pos = pos + l; 3584 return isValid; 3585 } 3586 isValid = strict ? new RegExp("[0-9" + Inputmask.escapeRegex(opts.groupSeparator) + "]").test(chrs) : new RegExp("[0-9]").test(chrs); 3587 if (isValid === true) { 3588 if (opts.numericInput !== true && maskset.validPositions[pos] !== undefined && maskset.validPositions[pos].match.def === "~" && !isSelection) { 3589 var processValue = maskset.buffer.join(""); 3590 processValue = processValue.replace(new RegExp("[-" + Inputmask.escapeRegex(opts.negationSymbol.front) + "]", "g"), ""); 3591 processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), ""); 3592 var pvRadixSplit = processValue.split(opts.radixPoint); 3593 if (pvRadixSplit.length > 1) { 3594 pvRadixSplit[1] = pvRadixSplit[1].replace(/0/g, opts.placeholder.charAt(0)); 3595 } 3596 if (pvRadixSplit[0] === "0") { 3597 pvRadixSplit[0] = pvRadixSplit[0].replace(/0/g, opts.placeholder.charAt(0)); 3598 } 3599 processValue = pvRadixSplit[0] + opts.radixPoint + pvRadixSplit[1] || ""; 3600 var bufferTemplate = maskset._buffer.join(""); 3601 if (processValue === opts.radixPoint) { 3602 processValue = bufferTemplate; 3603 } 3604 while (processValue.match(Inputmask.escapeRegex(bufferTemplate) + "$") === null) { 3605 bufferTemplate = bufferTemplate.slice(1); 3606 } 3607 processValue = processValue.replace(bufferTemplate, ""); 3608 processValue = processValue.split(""); 3609 if (processValue[pos] === undefined) { 3610 isValid = { 3611 pos: pos, 3612 remove: pos 3613 }; 3614 } else { 3615 isValid = { 3616 pos: pos 3617 }; 3618 } 3619 } 3620 } else if (!strict && chrs === opts.radixPoint && maskset.validPositions[pos - 1] === undefined) { 3621 isValid = { 3622 insert: { 3623 pos: pos, 3624 c: 0 3625 }, 3626 pos: pos + 1 3627 }; 3628 } 3629 return isValid; 3630 }, 3631 cardinality: 1 3632 }, 3633 "+": { 3634 validator: function validator(chrs, maskset, pos, strict, opts) { 3635 return opts.allowMinus && (chrs === "-" || chrs === opts.negationSymbol.front); 3636 }, 3637 cardinality: 1, 3638 placeholder: "" 3639 }, 3640 "-": { 3641 validator: function validator(chrs, maskset, pos, strict, opts) { 3642 return opts.allowMinus && chrs === opts.negationSymbol.back; 3643 }, 3644 cardinality: 1, 3645 placeholder: "" 3646 }, 3647 ":": { 3648 validator: function validator(chrs, maskset, pos, strict, opts) { 3649 var radix = "[" + Inputmask.escapeRegex(opts.radixPoint) + "]"; 3650 var isValid = new RegExp(radix).test(chrs); 3651 if (isValid && maskset.validPositions[pos] && maskset.validPositions[pos].match.placeholder === opts.radixPoint) { 3652 isValid = { 3653 caret: pos + 1 3654 }; 3655 } 3656 return isValid; 3657 }, 3658 cardinality: 1, 3659 placeholder: function placeholder(opts) { 3660 return opts.radixPoint; 3661 } 3662 } 3663 }, 3664 onUnMask: function onUnMask(maskedValue, unmaskedValue, opts) { 3665 if (unmaskedValue === "" && opts.nullable === true) { 3666 return unmaskedValue; 3667 } 3668 var processValue = maskedValue.replace(opts.prefix, ""); 3669 processValue = processValue.replace(opts.suffix, ""); 3670 processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""); 3671 if (opts.placeholder.charAt(0) !== "") { 3672 processValue = processValue.replace(new RegExp(opts.placeholder.charAt(0), "g"), "0"); 3673 } 3674 if (opts.unmaskAsNumber) { 3675 if (opts.radixPoint !== "" && processValue.indexOf(opts.radixPoint) !== -1) processValue = processValue.replace(Inputmask.escapeRegex.call(this, opts.radixPoint), "."); 3676 processValue = processValue.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), "-"); 3677 processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), ""); 3678 return Number(processValue); 3679 } 3680 return processValue; 3681 }, 3682 isComplete: function isComplete(buffer, opts) { 3683 var maskedValue = (opts.numericInput ? buffer.slice().reverse() : buffer).join(""); 3684 maskedValue = maskedValue.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), "-"); 3685 maskedValue = maskedValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), ""); 3686 maskedValue = maskedValue.replace(opts.prefix, ""); 3687 maskedValue = maskedValue.replace(opts.suffix, ""); 3688 maskedValue = maskedValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator) + "([0-9]{3})", "g"), "$1"); 3689 if (opts.radixPoint === ",") maskedValue = maskedValue.replace(Inputmask.escapeRegex(opts.radixPoint), "."); 3690 return isFinite(maskedValue); 3691 }, 3692 onBeforeMask: function onBeforeMask(initialValue, opts) { 3693 opts.isNegative = undefined; 3694 if (typeof initialValue == "number" && opts.radixPoint !== "") { 3695 initialValue = initialValue.toString().replace(".", opts.radixPoint); 3696 } 3697 initialValue = initialValue.toString().charAt(initialValue.length - 1) === opts.radixPoint ? initialValue.toString().substr(0, initialValue.length - 1) : initialValue.toString(); 3698 if (opts.radixPoint !== "" && isFinite(initialValue)) { 3699 var vs = initialValue.split("."), groupSize = opts.groupSeparator !== "" ? parseInt(opts.groupSize) : 0; 3700 if (vs.length === 2 && (vs[0].length > groupSize || vs[1].length > groupSize || vs[0].length <= groupSize && vs[1].length < groupSize)) { 3701 initialValue = initialValue.replace(".", opts.radixPoint); 3702 } 3703 } 3704 var kommaMatches = initialValue.match(/,/g); 3705 var dotMatches = initialValue.match(/\./g); 3706 if (dotMatches && kommaMatches) { 3707 if (dotMatches.length > kommaMatches.length) { 3708 initialValue = initialValue.replace(/\./g, ""); 3709 initialValue = initialValue.replace(",", opts.radixPoint); 3710 } else if (kommaMatches.length > dotMatches.length) { 3711 initialValue = initialValue.replace(/,/g, ""); 3712 initialValue = initialValue.replace(".", opts.radixPoint); 3713 } else { 3714 initialValue = initialValue.indexOf(".") < initialValue.indexOf(",") ? initialValue.replace(/\./g, "") : initialValue.replace(/,/g, ""); 3715 } 3716 } else { 3717 initialValue = initialValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""); 3718 } 3719 var digits = 0; 3720 if (opts.radixPoint !== "" && initialValue.indexOf(opts.radixPoint) !== -1) { 3721 var valueParts = initialValue.split(opts.radixPoint), digits = valueParts[1].match(new RegExp("\\d*"))[0].length, digitsFactor = Math.pow(10, digits || 1); 3722 if (isFinite(opts.digits)) { 3723 digits = parseInt(opts.digits); 3724 digitsFactor = Math.pow(10, digits); 3725 } 3726 initialValue = initialValue.replace(Inputmask.escapeRegex(opts.radixPoint), "."); 3727 if (isFinite(initialValue)) initialValue = Math.round(parseFloat(initialValue) * digitsFactor) / digitsFactor; 3728 initialValue = initialValue.toString().replace(".", opts.radixPoint); 3729 } 3730 if (opts.digits === 0) { 3731 if (initialValue.indexOf(".") !== -1) { 3732 initialValue = initialValue.substring(0, initialValue.indexOf(".")); 3733 } else if (initialValue.indexOf(",") !== -1) { 3734 initialValue = initialValue.substring(0, initialValue.indexOf(",")); 3735 } 3736 } 3737 return alignDigits(initialValue.toString().split(""), digits, opts).join(""); 3738 }, 3739 onKeyDown: function onKeyDown(e, buffer, caretPos, opts) { 3740 var $input = $(this); 3741 if (e.ctrlKey) { 3742 switch (e.keyCode) { 3743 case Inputmask.keyCode.UP: 3744 $input.val(parseFloat(this.inputmask.unmaskedvalue()) + parseInt(opts.step)); 3745 $input.trigger("setvalue"); 3746 break; 3747 3748 case Inputmask.keyCode.DOWN: 3749 $input.val(parseFloat(this.inputmask.unmaskedvalue()) - parseInt(opts.step)); 3750 $input.trigger("setvalue"); 3751 break; 3752 } 3753 } 3754 } 3755 }, 3756 currency: { 3757 prefix: "$ ", 3758 groupSeparator: ",", 3759 alias: "numeric", 3760 placeholder: "0", 3761 autoGroup: true, 3762 digits: 2, 3763 digitsOptional: false, 3764 clearMaskOnLostFocus: false 3765 },
3766 decimal: { 3767 alias: "numeric" 3768 }, 3769 integer: { 3770 alias: "numeric", 3771 digits: 0, 3772 radixPoint: "" 3773 }, 3774 percentage: { 3775 alias: "numeric", 3776 digits: 2, 3777 digitsOptional: true, 3778 radixPoint: ".", 3779 placeholder: "0", 3780 autoGroup: false, 3781 min: 0, 3782 max: 100, 3783 suffix: " %", 3784 allowMinus: false 3785 } 3786 }); 3787 return Inputmask; 3788 }); 3789}, function(module, exports, __webpack_require__) { 3790 "use strict"; 3791 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__; 3792 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) { 3793 return typeof obj; 3794 } : function(obj) { 3795 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 3796 }; 3797 (function(factory) { 3798 if (true) { 3799 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(4), __webpack_require__(2) ], 3800 __WEBPACK_AMD_DEFINE_FACTORY__ = factory, __WEBPACK_AMD_DEFINE_RESULT__ = typeof __WEBPACK_AMD_DEFINE_FACTORY__ === "function" ? __WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__) : __WEBPACK_AMD_DEFINE_FACTORY__, 3801 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 3802 } else {} 3803 })(function($, Inputmask) { 3804 if ($.fn.inputmask === undefined) { 3805 $.fn.inputmask = function(fn, options) { 3806 var nptmask, input = this[0]; 3807 if (options === undefined) options = {}; 3808 if (typeof fn === "string") { 3809 switch (fn) { 3810 case "unmaskedvalue": 3811 return input && input.inputmask ? input.inputmask.unmaskedvalue() : $(input).val(); 3812 3813 case "remove": 3814 return this.each(function() { 3815 if (this.inputmask) this.inputmask.remove(); 3816 }); 3817 3818 case "getemptymask": 3819 return input && input.inputmask ? input.inputmask.getemptymask() : ""; 3820 3821 case "hasMaskedValue": 3822 return input && input.inputmask ? input.inputmask.hasMaskedValue() : false; 3823 3824 case "isComplete": 3825 return input && input.inputmask ? input.inputmask.isComplete() : true; 3826 3827 case "getmetadata": 3828 return input && input.inputmask ? input.inputmask.getmetadata() : undefined; 3829 3830 case "setvalue": 3831 Inputmask.setValue(input, options); 3832 break; 3833 3834 case "option": 3835 if (typeof options === "string") { 3836 if (input && input.inputmask !== undefined) { 3837 return input.inputmask.option(options); 3838 } 3839 } else { 3840 return this.each(function() { 3841 if (this.inputmask !== undefined) { 3842 return this.inputmask.option(options); 3843 } 3844 }); 3845 } 3846 break; 3847 3848 default: 3849 options.alias = fn; 3850 nptmask = new Inputmask(options); 3851 return this.each(function() { 3852 nptmask.mask(this); 3853 }); 3854 } 3855 } else if (Array.isArray(fn)) { 3856 options.alias = fn; 3857 nptmask = new Inputmask(options); 3858 return this.each(function() { 3859 nptmask.mask(this); 3860 }); 3861 } else if ((typeof fn === "undefined" ? "undefined" : _typeof(fn)) == "object") { 3862 nptmask = new Inputmask(fn);
3863 if (fn.mask === undefined && fn.alias === undefined) { 3864 return this.each(function() { 3865 if (this.inputmask !== undefined) { 3866 return this.inputmask.option(fn); 3867 } else nptmask.mask(this); 3868 }); 3869 } else { 3870 return this.each(function() { 3871 nptmask.mask(this); 3872 }); 3873 } 3874 } else if (fn === undefined) { 3875 return this.each(function() { 3876 nptmask = new Inputmask(options); 3877 nptmask.mask(this); 3878 }); 3879 } 3880 }; 3881 } 3882 return $.fn.inputmask; 3883 }); 3884} ]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.