jquery.inputmask.bundle.js
2403 lines
| 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.0-beta.58 |
| 7 | */ |
| 8 | |
| 9 | !function(modules) { |
| 10 | var installedModules = {}; |
| 11 | function __webpack_require__(moduleId) { |
| 12 | if (installedModules[moduleId]) return installedModules[moduleId].exports; |
| 13 | var module = installedModules[moduleId] = { |
| 14 | i: moduleId, |
| 15 | l: !1, |
| 16 | exports: {} |
| 17 | }; |
| 18 | return modules[moduleId].call(module.exports, module, module.exports, __webpack_require__), |
| 19 | module.l = !0, module.exports; |
| 20 | } |
| 21 | __webpack_require__.m = modules, __webpack_require__.c = installedModules, __webpack_require__.d = function(exports, name, getter) { |
| 22 | __webpack_require__.o(exports, name) || Object.defineProperty(exports, name, { |
| 23 | configurable: !1, |
| 24 | enumerable: !0, |
| 25 | get: getter |
| 26 | }); |
| 27 | }, __webpack_require__.n = function(module) { |
| 28 | var getter = module && module.__esModule ? function() { |
| 29 | return module.default; |
| 30 | } : function() { |
| 31 | return module; |
| 32 | }; |
| 33 | return __webpack_require__.d(getter, "a", getter), getter; |
| 34 | }, __webpack_require__.o = function(object, property) { |
| 35 | return Object.prototype.hasOwnProperty.call(object, property); |
| 36 | }, __webpack_require__.p = "", __webpack_require__(__webpack_require__.s = 3); |
| 37 | }([ function(module, exports, __webpack_require__) { |
| 38 | "use strict"; |
| 39 | var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__, factory; |
| 40 | "function" == typeof Symbol && Symbol.iterator; |
| 41 | factory = function($) { |
| 42 | return $; |
| 43 | }, __WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(2) ], void 0 === (__WEBPACK_AMD_DEFINE_RESULT__ = "function" == typeof (__WEBPACK_AMD_DEFINE_FACTORY__ = factory) ? __WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__) : __WEBPACK_AMD_DEFINE_FACTORY__) || (module.exports = __WEBPACK_AMD_DEFINE_RESULT__); |
| 44 | }, function(module, exports, __webpack_require__) { |
| 45 | "use strict"; |
| 46 | var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__, factory, _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) { |
| 47 | return typeof obj; |
| 48 | } : function(obj) { |
| 49 | return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; |
| 50 | }; |
| 51 | factory = function($, window, document, undefined) { |
| 52 | var ua = navigator.userAgent, mobile = isInputEventSupported("touchstart"), iemobile = /iemobile/i.test(ua), iphone = /iphone/i.test(ua) && !iemobile; |
| 53 | function Inputmask(alias, options, internal) { |
| 54 | if (!(this instanceof Inputmask)) return new Inputmask(alias, options, internal); |
| 55 | this.el = undefined, this.events = {}, this.maskset = undefined, this.refreshValue = !1, |
| 56 | !0 !== internal && ($.isPlainObject(alias) ? options = alias : (options = options || {}, |
| 57 | alias && (options.alias = alias)), this.opts = $.extend(!0, {}, this.defaults, options), |
| 58 | this.noMasksCache = options && options.definitions !== undefined, this.userOptions = options || {}, |
| 59 | this.isRTL = this.opts.numericInput, resolveAlias(this.opts.alias, options, this.opts)); |
| 60 | } |
| 61 | function resolveAlias(aliasStr, options, opts) { |
| 62 | var aliasDefinition = Inputmask.prototype.aliases[aliasStr]; |
| 63 | return aliasDefinition ? (aliasDefinition.alias && resolveAlias(aliasDefinition.alias, undefined, opts), |
| 64 | $.extend(!0, opts, aliasDefinition), $.extend(!0, opts, options), !0) : (null === opts.mask && (opts.mask = aliasStr), |
| 65 | !1); |
| 66 | } |
| 67 | function generateMaskSet(opts, nocache) { |
| 68 | function generateMask(mask, metadata, opts) { |
| 69 | var regexMask = !1; |
| 70 | if (null !== mask && "" !== mask || ((regexMask = null !== opts.regex) ? mask = (mask = opts.regex).replace(/^(\^)(.*)(\$)$/, "$2") : (regexMask = !0, |
| 71 | mask = ".*")), 1 === mask.length && !1 === opts.greedy && 0 !== opts.repeat && (opts.placeholder = ""), |
| 72 | opts.repeat > 0 || "*" === opts.repeat || "+" === opts.repeat) { |
| 73 | var repeatStart = "*" === opts.repeat ? 0 : "+" === opts.repeat ? 1 : opts.repeat; |
| 74 | mask = opts.groupmarker[0] + mask + opts.groupmarker[1] + opts.quantifiermarker[0] + repeatStart + "," + opts.repeat + opts.quantifiermarker[1]; |
| 75 | } |
| 76 | var masksetDefinition, maskdefKey = regexMask ? "regex_" + opts.regex : opts.numericInput ? mask.split("").reverse().join("") : mask; |
| 77 | return Inputmask.prototype.masksCache[maskdefKey] === undefined || !0 === nocache ? (masksetDefinition = { |
| 78 | mask: mask, |
| 79 | maskToken: Inputmask.prototype.analyseMask(mask, regexMask, opts), |
| 80 | validPositions: {}, |
| 81 | _buffer: undefined, |
| 82 | buffer: undefined, |
| 83 | tests: {}, |
| 84 | excludes: {}, |
| 85 | metadata: metadata, |
| 86 | maskLength: undefined |
| 87 | }, !0 !== nocache && (Inputmask.prototype.masksCache[maskdefKey] = masksetDefinition, |
| 88 | masksetDefinition = $.extend(!0, {}, Inputmask.prototype.masksCache[maskdefKey]))) : masksetDefinition = $.extend(!0, {}, Inputmask.prototype.masksCache[maskdefKey]), |
| 89 | masksetDefinition; |
| 90 | } |
| 91 | if ($.isFunction(opts.mask) && (opts.mask = opts.mask(opts)), $.isArray(opts.mask)) { |
| 92 | if (opts.mask.length > 1) { |
| 93 | if (null === opts.keepStatic) { |
| 94 | opts.keepStatic = "auto"; |
| 95 | for (var i = 0; i < opts.mask.length; i++) if (opts.mask[i].charAt(0) !== opts.mask[0].charAt(0)) { |
| 96 | opts.keepStatic = !0; |
| 97 | break; |
| 98 | } |
| 99 | } |
| 100 | var altMask = opts.groupmarker[0]; |
| 101 | return $.each(opts.isRTL ? opts.mask.reverse() : opts.mask, function(ndx, msk) { |
| 102 | altMask.length > 1 && (altMask += opts.groupmarker[1] + opts.alternatormarker + opts.groupmarker[0]), |
| 103 | msk.mask === undefined || $.isFunction(msk.mask) ? altMask += msk : altMask += msk.mask; |
| 104 | }), generateMask(altMask += opts.groupmarker[1], opts.mask, opts); |
| 105 | } |
| 106 | opts.mask = opts.mask.pop(); |
| 107 | } |
| 108 | return opts.mask && opts.mask.mask !== undefined && !$.isFunction(opts.mask.mask) ? generateMask(opts.mask.mask, opts.mask, opts) : generateMask(opts.mask, opts.mask, opts); |
| 109 | } |
| 110 | function isInputEventSupported(eventName) { |
| 111 | var el = document.createElement("input"), evName = "on" + eventName, isSupported = evName in el; |
| 112 | return isSupported || (el.setAttribute(evName, "return;"), isSupported = "function" == typeof el[evName]), |
| 113 | el = null, isSupported; |
| 114 | } |
| 115 | function maskScope(actionObj, maskset, opts) { |
| 116 | maskset = maskset || this.maskset, opts = opts || this.opts; |
| 117 | var undoValue, $el, maxLength, colorMask, inputmask = this, el = this.el, isRTL = this.isRTL, skipKeyPressEvent = !1, skipInputEvent = !1, ignorable = !1, mouseEnter = !1; |
| 118 | function getMaskTemplate(baseOnInput, minimalPos, includeMode, noJit, clearOptionalTail) { |
| 119 | var greedy = opts.greedy; |
| 120 | clearOptionalTail && (opts.greedy = !1), minimalPos = minimalPos || 0; |
| 121 | var ndxIntlzr, test, testPos, maskTemplate = [], pos = 0, lvp = getLastValidPosition(); |
| 122 | do { |
| 123 | if (!0 === baseOnInput && getMaskSet().validPositions[pos]) test = (testPos = clearOptionalTail && !0 === getMaskSet().validPositions[pos].match.optionality && getMaskSet().validPositions[pos + 1] === undefined && (!0 === getMaskSet().validPositions[pos].generatedInput || getMaskSet().validPositions[pos].input == opts.skipOptionalPartCharacter && pos > 0) ? determineTestTemplate(pos, getTests(pos, ndxIntlzr, pos - 1)) : getMaskSet().validPositions[pos]).match, |
| 124 | ndxIntlzr = testPos.locator.slice(), maskTemplate.push(!0 === includeMode ? testPos.input : !1 === includeMode ? test.nativeDef : getPlaceholder(pos, test)); else { |
| 125 | test = (testPos = getTestTemplate(pos, ndxIntlzr, pos - 1)).match, ndxIntlzr = testPos.locator.slice(); |
| 126 | var jitMasking = !0 !== noJit && (!1 !== opts.jitMasking ? opts.jitMasking : test.jit); |
| 127 | (!1 === jitMasking || jitMasking === undefined || pos < lvp || "number" == typeof jitMasking && isFinite(jitMasking) && jitMasking > pos) && maskTemplate.push(!1 === includeMode ? test.nativeDef : getPlaceholder(pos, test)); |
| 128 | } |
| 129 | "auto" === opts.keepStatic && test.newBlockMarker && null !== test.fn && (opts.keepStatic = pos - 1), |
| 130 | pos++; |
| 131 | } while ((maxLength === undefined || pos < maxLength) && (null !== test.fn || "" !== test.def) || minimalPos > pos); |
| 132 | return "" === maskTemplate[maskTemplate.length - 1] && maskTemplate.pop(), !1 === includeMode && getMaskSet().maskLength !== undefined || (getMaskSet().maskLength = pos - 1), |
| 133 | opts.greedy = greedy, maskTemplate; |
| 134 | } |
| 135 | function getMaskSet() { |
| 136 | return maskset; |
| 137 | } |
| 138 | function resetMaskSet(soft) { |
| 139 | var maskset = getMaskSet(); |
| 140 | maskset.buffer = undefined, !0 !== soft && (maskset.validPositions = {}, maskset.p = 0); |
| 141 | } |
| 142 | function getLastValidPosition(closestTo, strict, validPositions) { |
| 143 | var before = -1, after = -1, valids = validPositions || getMaskSet().validPositions; |
| 144 | for (var posNdx in closestTo === undefined && (closestTo = -1), valids) { |
| 145 | var psNdx = parseInt(posNdx); |
| 146 | valids[psNdx] && (strict || !0 !== valids[psNdx].generatedInput) && (psNdx <= closestTo && (before = psNdx), |
| 147 | psNdx >= closestTo && (after = psNdx)); |
| 148 | } |
| 149 | return -1 === before || before == closestTo ? after : -1 == after ? before : closestTo - before < after - closestTo ? before : after; |
| 150 | } |
| 151 | function getDecisionTaker(tst) { |
| 152 | var decisionTaker = tst.locator[tst.alternation]; |
| 153 | return "string" == typeof decisionTaker && decisionTaker.length > 0 && (decisionTaker = decisionTaker.split(",")[0]), |
| 154 | decisionTaker !== undefined ? decisionTaker.toString() : ""; |
| 155 | } |
| 156 | function getLocator(tst, align) { |
| 157 | var locator = (tst.alternation != undefined ? tst.mloc[getDecisionTaker(tst)] : tst.locator).join(""); |
| 158 | if ("" !== locator) for (;locator.length < align; ) locator += "0"; |
| 159 | return locator; |
| 160 | } |
| 161 | function determineTestTemplate(pos, tests) { |
| 162 | for (var tstLocator, closest, bestMatch, targetLocator = getLocator(getTest(pos = pos > 0 ? pos - 1 : 0)), ndx = 0; ndx < tests.length; ndx++) { |
| 163 | var tst = tests[ndx]; |
| 164 | tstLocator = getLocator(tst, targetLocator.length); |
| 165 | var distance = Math.abs(tstLocator - targetLocator); |
| 166 | (closest === undefined || "" !== tstLocator && distance < closest || bestMatch && bestMatch.match.optionality && "master" === bestMatch.match.newBlockMarker && (!tst.match.optionality || !tst.match.newBlockMarker) || bestMatch && bestMatch.match.optionalQuantifier && !tst.match.optionalQuantifier) && (closest = distance, |
| 167 | bestMatch = tst); |
| 168 | } |
| 169 | return bestMatch; |
| 170 | } |
| 171 | function getTestTemplate(pos, ndxIntlzr, tstPs) { |
| 172 | return getMaskSet().validPositions[pos] || determineTestTemplate(pos, getTests(pos, ndxIntlzr ? ndxIntlzr.slice() : ndxIntlzr, tstPs)); |
| 173 | } |
| 174 | function getTest(pos, tests) { |
| 175 | return getMaskSet().validPositions[pos] ? getMaskSet().validPositions[pos] : (tests || getTests(pos))[0]; |
| 176 | } |
| 177 | function positionCanMatchDefinition(pos, def) { |
| 178 | for (var valid = !1, tests = getTests(pos), tndx = 0; tndx < tests.length; tndx++) if (tests[tndx].match && tests[tndx].match.def === def) { |
| 179 | valid = !0; |
| 180 | break; |
| 181 | } |
| 182 | return valid; |
| 183 | } |
| 184 | function getTests(pos, ndxIntlzr, tstPs) { |
| 185 | var latestMatch, maskTokens = getMaskSet().maskToken, testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr ? ndxIntlzr.slice() : [ 0 ], matches = [], insertStop = !1, cacheDependency = ndxIntlzr ? ndxIntlzr.join("") : ""; |
| 186 | function resolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) { |
| 187 | function handleMatch(match, loopNdx, quantifierRecurse) { |
| 188 | function isFirstMatch(latestMatch, tokenGroup) { |
| 189 | var firstMatch = 0 === $.inArray(latestMatch, tokenGroup.matches); |
| 190 | return firstMatch || $.each(tokenGroup.matches, function(ndx, match) { |
| 191 | if (!0 === match.isQuantifier ? firstMatch = isFirstMatch(latestMatch, tokenGroup.matches[ndx - 1]) : !0 === match.isOptional ? firstMatch = isFirstMatch(latestMatch, match) : !0 === match.isAlternate && (firstMatch = isFirstMatch(latestMatch, match)), |
| 192 | firstMatch) return !1; |
| 193 | }), firstMatch; |
| 194 | } |
| 195 | function resolveNdxInitializer(pos, alternateNdx, targetAlternation) { |
| 196 | var bestMatch, indexPos; |
| 197 | if ((getMaskSet().tests[pos] || getMaskSet().validPositions[pos]) && $.each(getMaskSet().tests[pos] || [ getMaskSet().validPositions[pos] ], function(ndx, lmnt) { |
| 198 | if (lmnt.mloc[alternateNdx]) return bestMatch = lmnt, !1; |
| 199 | var alternation = targetAlternation !== undefined ? targetAlternation : lmnt.alternation, ndxPos = lmnt.locator[alternation] !== undefined ? lmnt.locator[alternation].toString().indexOf(alternateNdx) : -1; |
| 200 | (indexPos === undefined || ndxPos < indexPos) && -1 !== ndxPos && (bestMatch = lmnt, |
| 201 | indexPos = ndxPos); |
| 202 | }), bestMatch) { |
| 203 | var bestMatchAltIndex = bestMatch.locator[bestMatch.alternation]; |
| 204 | return (bestMatch.mloc[alternateNdx] || bestMatch.mloc[bestMatchAltIndex] || bestMatch.locator).slice((targetAlternation !== undefined ? targetAlternation : bestMatch.alternation) + 1); |
| 205 | } |
| 206 | return targetAlternation !== undefined ? resolveNdxInitializer(pos, alternateNdx) : undefined; |
| 207 | } |
| 208 | function isSubsetOf(source, target) { |
| 209 | function expand(pattern) { |
| 210 | for (var start, end, expanded = [], i = 0, l = pattern.length; i < l; i++) if ("-" === pattern.charAt(i)) for (end = pattern.charCodeAt(i + 1); ++start < end; ) expanded.push(String.fromCharCode(start)); else start = pattern.charCodeAt(i), |
| 211 | expanded.push(pattern.charAt(i)); |
| 212 | return expanded.join(""); |
| 213 | } |
| 214 | return opts.regex && null !== source.match.fn && null !== target.match.fn ? -1 !== expand(target.match.def.replace(/[\[\]]/g, "")).indexOf(expand(source.match.def.replace(/[\[\]]/g, ""))) : source.match.def === target.match.nativeDef; |
| 215 | } |
| 216 | function setMergeLocators(targetMatch, altMatch) { |
| 217 | if (altMatch === undefined || targetMatch.alternation === altMatch.alternation && -1 === targetMatch.locator[targetMatch.alternation].toString().indexOf(altMatch.locator[altMatch.alternation])) { |
| 218 | targetMatch.mloc = targetMatch.mloc || {}; |
| 219 | var locNdx = targetMatch.locator[targetMatch.alternation]; |
| 220 | if (locNdx !== undefined) { |
| 221 | if ("string" == typeof locNdx && (locNdx = locNdx.split(",")[0]), targetMatch.mloc[locNdx] === undefined && (targetMatch.mloc[locNdx] = targetMatch.locator.slice()), |
| 222 | altMatch !== undefined) { |
| 223 | for (var ndx in altMatch.mloc) "string" == typeof ndx && (ndx = ndx.split(",")[0]), |
| 224 | targetMatch.mloc[ndx] === undefined && (targetMatch.mloc[ndx] = altMatch.mloc[ndx]); |
| 225 | targetMatch.locator[targetMatch.alternation] = Object.keys(targetMatch.mloc).join(","); |
| 226 | } |
| 227 | return !0; |
| 228 | } |
| 229 | targetMatch.alternation = undefined; |
| 230 | } |
| 231 | return !1; |
| 232 | } |
| 233 | if (testPos > 5e3) 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; |
| 234 | if (testPos === pos && match.matches === undefined) return matches.push({ |
| 235 | match: match, |
| 236 | locator: loopNdx.reverse(), |
| 237 | cd: cacheDependency, |
| 238 | mloc: {} |
| 239 | }), !0; |
| 240 | if (match.matches !== undefined) { |
| 241 | if (match.isGroup && quantifierRecurse !== match) { |
| 242 | if (match = handleMatch(maskToken.matches[$.inArray(match, maskToken.matches) + 1], loopNdx, quantifierRecurse)) return !0; |
| 243 | } else if (match.isOptional) { |
| 244 | var optionalToken = match; |
| 245 | if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) { |
| 246 | if ($.each(matches, function(ndx, mtch) { |
| 247 | mtch.match.optionality = !0; |
| 248 | }), latestMatch = matches[matches.length - 1].match, quantifierRecurse !== undefined || !isFirstMatch(latestMatch, optionalToken)) return !0; |
| 249 | insertStop = !0, testPos = pos; |
| 250 | } |
| 251 | } else if (match.isAlternator) { |
| 252 | var maltMatches, alternateToken = match, malternateMatches = [], currentMatches = matches.slice(), loopNdxCnt = loopNdx.length, altIndex = ndxInitializer.length > 0 ? ndxInitializer.shift() : -1; |
| 253 | if (-1 === altIndex || "string" == typeof altIndex) { |
| 254 | var amndx, currentPos = testPos, ndxInitializerClone = ndxInitializer.slice(), altIndexArr = []; |
| 255 | if ("string" == typeof altIndex) altIndexArr = altIndex.split(","); else for (amndx = 0; amndx < alternateToken.matches.length; amndx++) altIndexArr.push(amndx.toString()); |
| 256 | if (getMaskSet().excludes[pos]) { |
| 257 | for (var altIndexArrClone = altIndexArr.slice(), i = 0, el = getMaskSet().excludes[pos].length; i < el; i++) altIndexArr.splice(altIndexArr.indexOf(getMaskSet().excludes[pos][i].toString()), 1); |
| 258 | 0 === altIndexArr.length && (getMaskSet().excludes[pos] = undefined, altIndexArr = altIndexArrClone); |
| 259 | } |
| 260 | (!0 === opts.keepStatic || isFinite(parseInt(opts.keepStatic)) && currentPos >= opts.keepStatic) && (altIndexArr = altIndexArr.slice(0, 1)); |
| 261 | for (var unMatchedAlternation = !1, ndx = 0; ndx < altIndexArr.length; ndx++) { |
| 262 | amndx = parseInt(altIndexArr[ndx]), matches = [], ndxInitializer = "string" == typeof altIndex && resolveNdxInitializer(testPos, amndx, loopNdxCnt) || ndxInitializerClone.slice(), |
| 263 | alternateToken.matches[amndx] && handleMatch(alternateToken.matches[amndx], [ amndx ].concat(loopNdx), quantifierRecurse) ? match = !0 : 0 === ndx && (unMatchedAlternation = !0), |
| 264 | maltMatches = matches.slice(), testPos = currentPos, matches = []; |
| 265 | for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) { |
| 266 | var altMatch = maltMatches[ndx1], dropMatch = !1; |
| 267 | altMatch.match.jit = altMatch.match.jit || unMatchedAlternation, altMatch.alternation = altMatch.alternation || loopNdxCnt, |
| 268 | setMergeLocators(altMatch); |
| 269 | for (var ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) { |
| 270 | var altMatch2 = malternateMatches[ndx2]; |
| 271 | if ("string" != typeof altIndex || altMatch.alternation !== undefined && -1 !== $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr)) { |
| 272 | if (altMatch.match.nativeDef === altMatch2.match.nativeDef) { |
| 273 | dropMatch = !0, setMergeLocators(altMatch2, altMatch); |
| 274 | break; |
| 275 | } |
| 276 | if (isSubsetOf(altMatch, altMatch2)) { |
| 277 | setMergeLocators(altMatch, altMatch2) && (dropMatch = !0, malternateMatches.splice(malternateMatches.indexOf(altMatch2), 0, altMatch)); |
| 278 | break; |
| 279 | } |
| 280 | if (isSubsetOf(altMatch2, altMatch)) { |
| 281 | setMergeLocators(altMatch2, altMatch); |
| 282 | break; |
| 283 | } |
| 284 | if (target = altMatch2, null === (source = altMatch).match.fn && null !== target.match.fn && target.match.fn.test(source.match.def, getMaskSet(), pos, !1, opts, !1)) { |
| 285 | setMergeLocators(altMatch, altMatch2) && (dropMatch = !0, malternateMatches.splice(malternateMatches.indexOf(altMatch2), 0, altMatch)); |
| 286 | break; |
| 287 | } |
| 288 | } |
| 289 | } |
| 290 | dropMatch || malternateMatches.push(altMatch); |
| 291 | } |
| 292 | } |
| 293 | matches = currentMatches.concat(malternateMatches), testPos = pos, insertStop = matches.length > 0, |
| 294 | match = malternateMatches.length > 0, ndxInitializer = ndxInitializerClone.slice(); |
| 295 | } else match = handleMatch(alternateToken.matches[altIndex] || maskToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse); |
| 296 | if (match) return !0; |
| 297 | } else if (match.isQuantifier && quantifierRecurse !== maskToken.matches[$.inArray(match, maskToken.matches) - 1]) for (var qt = match, qndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max) && testPos <= pos; qndx++) { |
| 298 | var tokenGroup = maskToken.matches[$.inArray(qt, maskToken.matches) - 1]; |
| 299 | if (match = handleMatch(tokenGroup, [ qndx ].concat(loopNdx), tokenGroup)) { |
| 300 | if ((latestMatch = matches[matches.length - 1].match).optionalQuantifier = qndx > qt.quantifier.min - 1, |
| 301 | latestMatch.jit = qndx + tokenGroup.matches.indexOf(latestMatch) >= qt.quantifier.jit, |
| 302 | isFirstMatch(latestMatch, tokenGroup) && qndx > qt.quantifier.min - 1) { |
| 303 | insertStop = !0, testPos = pos; |
| 304 | break; |
| 305 | } |
| 306 | if (qt.quantifier.jit !== undefined && isNaN(qt.quantifier.max) && latestMatch.optionalQuantifier && getMaskSet().validPositions[pos - 1] === undefined) { |
| 307 | matches.pop(), insertStop = !0, testPos = pos, cacheDependency = undefined; |
| 308 | break; |
| 309 | } |
| 310 | return !0; |
| 311 | } |
| 312 | } else if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) return !0; |
| 313 | } else testPos++; |
| 314 | var source, target; |
| 315 | } |
| 316 | for (var tndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; tndx < maskToken.matches.length; tndx++) if (!0 !== maskToken.matches[tndx].isQuantifier) { |
| 317 | var match = handleMatch(maskToken.matches[tndx], [ tndx ].concat(loopNdx), quantifierRecurse); |
| 318 | if (match && testPos === pos) return match; |
| 319 | if (testPos > pos) break; |
| 320 | } |
| 321 | } |
| 322 | if (pos > -1) { |
| 323 | if (ndxIntlzr === undefined) { |
| 324 | for (var test, previousPos = pos - 1; (test = getMaskSet().validPositions[previousPos] || getMaskSet().tests[previousPos]) === undefined && previousPos > -1; ) previousPos--; |
| 325 | test !== undefined && previousPos > -1 && (ndxInitializer = function(pos, tests) { |
| 326 | var locator = []; |
| 327 | return $.isArray(tests) || (tests = [ tests ]), tests.length > 0 && (tests[0].alternation === undefined ? 0 === (locator = determineTestTemplate(pos, tests.slice()).locator.slice()).length && (locator = tests[0].locator.slice()) : $.each(tests, function(ndx, tst) { |
| 328 | if ("" !== tst.def) if (0 === locator.length) locator = tst.locator.slice(); else for (var i = 0; i < locator.length; i++) tst.locator[i] && -1 === locator[i].toString().indexOf(tst.locator[i]) && (locator[i] += "," + tst.locator[i]); |
| 329 | })), locator; |
| 330 | }(previousPos, test), cacheDependency = ndxInitializer.join(""), testPos = previousPos); |
| 331 | } |
| 332 | if (getMaskSet().tests[pos] && getMaskSet().tests[pos][0].cd === cacheDependency) return getMaskSet().tests[pos]; |
| 333 | for (var mtndx = ndxInitializer.shift(); mtndx < maskTokens.length; mtndx++) { |
| 334 | if (resolveTestFromToken(maskTokens[mtndx], ndxInitializer, [ mtndx ]) && testPos === pos || testPos > pos) break; |
| 335 | } |
| 336 | } |
| 337 | return (0 === matches.length || insertStop) && matches.push({ |
| 338 | match: { |
| 339 | fn: null, |
| 340 | optionality: !1, |
| 341 | casing: null, |
| 342 | def: "", |
| 343 | placeholder: "" |
| 344 | }, |
| 345 | locator: [], |
| 346 | mloc: {}, |
| 347 | cd: cacheDependency |
| 348 | }), ndxIntlzr !== undefined && getMaskSet().tests[pos] ? $.extend(!0, [], matches) : (getMaskSet().tests[pos] = $.extend(!0, [], matches), |
| 349 | getMaskSet().tests[pos]); |
| 350 | } |
| 351 | function getBufferTemplate() { |
| 352 | return getMaskSet()._buffer === undefined && (getMaskSet()._buffer = getMaskTemplate(!1, 1), |
| 353 | getMaskSet().buffer === undefined && (getMaskSet().buffer = getMaskSet()._buffer.slice())), |
| 354 | getMaskSet()._buffer; |
| 355 | } |
| 356 | function getBuffer(noCache) { |
| 357 | return getMaskSet().buffer !== undefined && !0 !== noCache || (getMaskSet().buffer = getMaskTemplate(!0, getLastValidPosition(), !0)), |
| 358 | getMaskSet().buffer; |
| 359 | } |
| 360 | function refreshFromBuffer(start, end, buffer) { |
| 361 | var i, p; |
| 362 | if (!0 === start) resetMaskSet(), start = 0, end = buffer.length; else for (i = start; i < end; i++) delete getMaskSet().validPositions[i]; |
| 363 | for (p = start, i = start; i < end; i++) if (resetMaskSet(!0), buffer[i] !== opts.skipOptionalPartCharacter) { |
| 364 | var valResult = isValid(p, buffer[i], !0, !0); |
| 365 | !1 !== valResult && (resetMaskSet(!0), p = valResult.caret !== undefined ? valResult.caret : valResult.pos + 1); |
| 366 | } |
| 367 | } |
| 368 | function checkAlternationMatch(altArr1, altArr2, na) { |
| 369 | for (var naNdx, altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1), isMatch = !1, naArr = na !== undefined ? na.split(",") : [], i = 0; i < naArr.length; i++) -1 !== (naNdx = altArr1.indexOf(naArr[i])) && altArr1.splice(naNdx, 1); |
| 370 | for (var alndx = 0; alndx < altArr1.length; alndx++) if (-1 !== $.inArray(altArr1[alndx], altArrC)) { |
| 371 | isMatch = !0; |
| 372 | break; |
| 373 | } |
| 374 | return isMatch; |
| 375 | } |
| 376 | function alternate(pos, c, strict, fromSetValid, rAltPos) { |
| 377 | var lastAlt, alternation, altPos, prevAltPos, i, validPos, decisionPos, validPsClone = $.extend(!0, {}, getMaskSet().validPositions), isValidRslt = !1, lAltPos = rAltPos !== undefined ? rAltPos : getLastValidPosition(); |
| 378 | if (-1 === lAltPos && rAltPos === undefined) alternation = (prevAltPos = getTest(lastAlt = 0)).alternation; else for (;lAltPos >= 0; lAltPos--) if ((altPos = getMaskSet().validPositions[lAltPos]) && altPos.alternation !== undefined) { |
| 379 | if (prevAltPos && prevAltPos.locator[altPos.alternation] !== altPos.locator[altPos.alternation]) break; |
| 380 | lastAlt = lAltPos, alternation = getMaskSet().validPositions[lastAlt].alternation, |
| 381 | prevAltPos = altPos; |
| 382 | } |
| 383 | if (alternation !== undefined) { |
| 384 | decisionPos = parseInt(lastAlt), getMaskSet().excludes[decisionPos] = getMaskSet().excludes[decisionPos] || [], |
| 385 | !0 !== pos && getMaskSet().excludes[decisionPos].push(getDecisionTaker(prevAltPos)); |
| 386 | var validInputsClone = [], staticInputsBeforePos = 0; |
| 387 | for (i = decisionPos; i < getLastValidPosition(undefined, !0) + 1; i++) (validPos = getMaskSet().validPositions[i]) && !0 !== validPos.generatedInput ? validInputsClone.push(validPos.input) : i < pos && staticInputsBeforePos++, |
| 388 | delete getMaskSet().validPositions[i]; |
| 389 | for (;getMaskSet().excludes[decisionPos] && getMaskSet().excludes[decisionPos].length < 10; ) { |
| 390 | var posOffset = -1 * staticInputsBeforePos, validInputs = validInputsClone.slice(); |
| 391 | for (getMaskSet().tests[decisionPos] = undefined, resetMaskSet(!0), isValidRslt = !0; validInputs.length > 0; ) { |
| 392 | var input = validInputs.shift(); |
| 393 | if (!(isValidRslt = isValid(getLastValidPosition(undefined, !0) + 1, input, !1, fromSetValid, !0))) break; |
| 394 | } |
| 395 | if (isValidRslt && c !== undefined) { |
| 396 | var targetLvp = getLastValidPosition(pos) + 1; |
| 397 | for (i = decisionPos; i < getLastValidPosition() + 1; i++) ((validPos = getMaskSet().validPositions[i]) === undefined || null == validPos.match.fn) && i < pos + posOffset && posOffset++; |
| 398 | isValidRslt = isValid((pos += posOffset) > targetLvp ? targetLvp : pos, c, strict, fromSetValid, !0); |
| 399 | } |
| 400 | if (isValidRslt) break; |
| 401 | if (resetMaskSet(), prevAltPos = getTest(decisionPos), getMaskSet().validPositions = $.extend(!0, {}, validPsClone), |
| 402 | !getMaskSet().excludes[decisionPos]) { |
| 403 | isValidRslt = alternate(pos, c, strict, fromSetValid, decisionPos - 1); |
| 404 | break; |
| 405 | } |
| 406 | var decisionTaker = getDecisionTaker(prevAltPos); |
| 407 | if (-1 !== getMaskSet().excludes[decisionPos].indexOf(decisionTaker)) { |
| 408 | isValidRslt = alternate(pos, c, strict, fromSetValid, decisionPos - 1); |
| 409 | break; |
| 410 | } |
| 411 | for (getMaskSet().excludes[decisionPos].push(decisionTaker), i = decisionPos; i < getLastValidPosition(undefined, !0) + 1; i++) delete getMaskSet().validPositions[i]; |
| 412 | } |
| 413 | } |
| 414 | return getMaskSet().excludes[decisionPos] = undefined, isValidRslt; |
| 415 | } |
| 416 | function isValid(pos, c, strict, fromSetValid, fromAlternate, validateOnly) { |
| 417 | function isSelection(posObj) { |
| 418 | return isRTL ? posObj.begin - posObj.end > 1 || posObj.begin - posObj.end == 1 : posObj.end - posObj.begin > 1 || posObj.end - posObj.begin == 1; |
| 419 | } |
| 420 | strict = !0 === strict; |
| 421 | var maskPos = pos; |
| 422 | function _isValid(position, c, strict) { |
| 423 | var rslt = !1; |
| 424 | return $.each(getTests(position), function(ndx, tst) { |
| 425 | var test = tst.match; |
| 426 | if (getBuffer(!0), !1 !== (rslt = null != test.fn ? test.fn.test(c, getMaskSet(), position, strict, opts, isSelection(pos)) : (c === test.def || c === opts.skipOptionalPartCharacter) && "" !== test.def && { |
| 427 | c: getPlaceholder(position, test, !0) || test.def, |
| 428 | pos: position |
| 429 | })) { |
| 430 | var elem = rslt.c !== undefined ? rslt.c : c, validatedPos = position; |
| 431 | return elem = elem === opts.skipOptionalPartCharacter && null === test.fn ? getPlaceholder(position, test, !0) || test.def : elem, |
| 432 | rslt.remove !== undefined && ($.isArray(rslt.remove) || (rslt.remove = [ rslt.remove ]), |
| 433 | $.each(rslt.remove.sort(function(a, b) { |
| 434 | return b - a; |
| 435 | }), function(ndx, lmnt) { |
| 436 | revalidateMask({ |
| 437 | begin: lmnt, |
| 438 | end: lmnt + 1 |
| 439 | }); |
| 440 | })), rslt.insert !== undefined && ($.isArray(rslt.insert) || (rslt.insert = [ rslt.insert ]), |
| 441 | $.each(rslt.insert.sort(function(a, b) { |
| 442 | return a - b; |
| 443 | }), function(ndx, lmnt) { |
| 444 | isValid(lmnt.pos, lmnt.c, !0, fromSetValid); |
| 445 | })), !0 !== rslt && rslt.pos !== undefined && rslt.pos !== position && (validatedPos = rslt.pos), |
| 446 | !0 !== rslt && rslt.pos === undefined && rslt.c === undefined ? !1 : (revalidateMask(pos, $.extend({}, tst, { |
| 447 | input: function(elem, test, pos) { |
| 448 | switch (opts.casing || test.casing) { |
| 449 | case "upper": |
| 450 | elem = elem.toUpperCase(); |
| 451 | break; |
| 452 | |
| 453 | case "lower": |
| 454 | elem = elem.toLowerCase(); |
| 455 | break; |
| 456 | |
| 457 | case "title": |
| 458 | var posBefore = getMaskSet().validPositions[pos - 1]; |
| 459 | elem = 0 === pos || posBefore && posBefore.input === String.fromCharCode(Inputmask.keyCode.SPACE) ? elem.toUpperCase() : elem.toLowerCase(); |
| 460 | break; |
| 461 | |
| 462 | default: |
| 463 | if ($.isFunction(opts.casing)) { |
| 464 | var args = Array.prototype.slice.call(arguments); |
| 465 | args.push(getMaskSet().validPositions), elem = opts.casing.apply(this, args); |
| 466 | } |
| 467 | } |
| 468 | return elem; |
| 469 | }(elem, test, validatedPos) |
| 470 | }), fromSetValid, validatedPos) || (rslt = !1), !1); |
| 471 | } |
| 472 | }), rslt; |
| 473 | } |
| 474 | pos.begin !== undefined && (maskPos = isRTL ? pos.end : pos.begin); |
| 475 | var result = !0, positionsClone = $.extend(!0, {}, getMaskSet().validPositions); |
| 476 | if ($.isFunction(opts.preValidation) && !strict && !0 !== fromSetValid && !0 !== validateOnly && (result = opts.preValidation(getBuffer(), maskPos, c, isSelection(pos), opts, getMaskSet())), |
| 477 | !0 === result) { |
| 478 | if (trackbackPositions(undefined, maskPos, !0), (maxLength === undefined || maskPos < maxLength) && (result = _isValid(maskPos, c, strict), |
| 479 | (!strict || !0 === fromSetValid) && !1 === result && !0 !== validateOnly)) { |
| 480 | var currentPosValid = getMaskSet().validPositions[maskPos]; |
| 481 | if (!currentPosValid || null !== currentPosValid.match.fn || currentPosValid.match.def !== c && c !== opts.skipOptionalPartCharacter) { |
| 482 | if ((opts.insertMode || getMaskSet().validPositions[seekNext(maskPos)] === undefined) && !isMask(maskPos, !0)) for (var nPos = maskPos + 1, snPos = seekNext(maskPos); nPos <= snPos; nPos++) if (!1 !== (result = _isValid(nPos, c, strict))) { |
| 483 | result = trackbackPositions(maskPos, result.pos !== undefined ? result.pos : nPos) || result, |
| 484 | maskPos = nPos; |
| 485 | break; |
| 486 | } |
| 487 | } else result = { |
| 488 | caret: seekNext(maskPos) |
| 489 | }; |
| 490 | } |
| 491 | !1 !== result || !1 === opts.keepStatic || null != opts.regex && !isComplete(getBuffer()) || strict || !0 === fromAlternate || (result = alternate(maskPos, c, strict, fromSetValid)), |
| 492 | !0 === result && (result = { |
| 493 | pos: maskPos |
| 494 | }); |
| 495 | } |
| 496 | if ($.isFunction(opts.postValidation) && !1 !== result && !strict && !0 !== fromSetValid && !0 !== validateOnly) { |
| 497 | var postResult = opts.postValidation(getBuffer(!0), result, opts); |
| 498 | if (postResult !== undefined) { |
| 499 | if (postResult.refreshFromBuffer && postResult.buffer) { |
| 500 | var refresh = postResult.refreshFromBuffer; |
| 501 | refreshFromBuffer(!0 === refresh ? refresh : refresh.start, refresh.end, postResult.buffer); |
| 502 | } |
| 503 | result = !0 === postResult ? result : postResult; |
| 504 | } |
| 505 | } |
| 506 | return result && result.pos === undefined && (result.pos = maskPos), !1 !== result && !0 !== validateOnly || (resetMaskSet(!0), |
| 507 | getMaskSet().validPositions = $.extend(!0, {}, positionsClone)), result; |
| 508 | } |
| 509 | function trackbackPositions(originalPos, newPos, fillOnly) { |
| 510 | var result; |
| 511 | if (originalPos === undefined) for (originalPos = newPos - 1; originalPos > 0 && !getMaskSet().validPositions[originalPos]; originalPos--) ; |
| 512 | for (var ps = originalPos; ps < newPos; ps++) if (getMaskSet().validPositions[ps] === undefined && !isMask(ps, !0)) { |
| 513 | var vp = 0 == ps ? getTest(ps) : getMaskSet().validPositions[ps - 1]; |
| 514 | if (vp) { |
| 515 | var tstLocator, targetLocator = getLocator(vp), tests = getTests(ps).slice(), closest = undefined, bestMatch = getTest(ps); |
| 516 | if ("" === tests[tests.length - 1].match.def && tests.pop(), $.each(tests, function(ndx, tst) { |
| 517 | tstLocator = getLocator(tst, targetLocator.length); |
| 518 | var distance = Math.abs(tstLocator - targetLocator); |
| 519 | (closest === undefined || distance < closest) && null === tst.match.fn && !0 !== tst.match.optionality && !0 !== tst.match.optionalQuantifier && (closest = distance, |
| 520 | bestMatch = tst); |
| 521 | }), (bestMatch = $.extend({}, bestMatch, { |
| 522 | input: getPlaceholder(ps, bestMatch.match, !0) || bestMatch.match.def |
| 523 | })).generatedInput = !0, revalidateMask(ps, bestMatch, !0), !0 !== fillOnly) { |
| 524 | var cvpInput = getMaskSet().validPositions[newPos].input; |
| 525 | getMaskSet().validPositions[newPos] = undefined, result = isValid(newPos, cvpInput, !0, !0); |
| 526 | } |
| 527 | } |
| 528 | } |
| 529 | return result; |
| 530 | } |
| 531 | function revalidateMask(pos, validTest, fromSetValid, validatedPos) { |
| 532 | function IsEnclosedStatic(pos, valids, selection) { |
| 533 | var posMatch = valids[pos]; |
| 534 | if (posMatch !== undefined && (null === posMatch.match.fn && !0 !== posMatch.match.optionality || posMatch.input === opts.radixPoint)) { |
| 535 | var prevMatch = selection.begin <= pos - 1 ? valids[pos - 1] && null === valids[pos - 1].match.fn && valids[pos - 1] : valids[pos - 1], nextMatch = selection.end > pos + 1 ? valids[pos + 1] && null === valids[pos + 1].match.fn && valids[pos + 1] : valids[pos + 1]; |
| 536 | return prevMatch && nextMatch; |
| 537 | } |
| 538 | return !1; |
| 539 | } |
| 540 | var begin = pos.begin !== undefined ? pos.begin : pos, end = pos.end !== undefined ? pos.end : pos; |
| 541 | if (pos.begin > pos.end && (begin = pos.end, end = pos.begin), validatedPos = validatedPos !== undefined ? validatedPos : begin, |
| 542 | begin !== end || opts.insertMode && getMaskSet().validPositions[validatedPos] !== undefined && fromSetValid === undefined) { |
| 543 | var positionsClone = $.extend(!0, {}, getMaskSet().validPositions), lvp = getLastValidPosition(undefined, !0); |
| 544 | for (getMaskSet().p = begin, i = lvp; i >= begin; i--) getMaskSet().validPositions[i] && "+" === getMaskSet().validPositions[i].match.nativeDef && (opts.isNegative = !1), |
| 545 | delete getMaskSet().validPositions[i]; |
| 546 | var valid = !0, j = validatedPos, needsValidation = (getMaskSet().validPositions, |
| 547 | !1), posMatch = j, i = j; |
| 548 | for (validTest && (getMaskSet().validPositions[validatedPos] = $.extend(!0, {}, validTest), |
| 549 | posMatch++, j++, begin < end && i++); i <= lvp; i++) { |
| 550 | var t = positionsClone[i]; |
| 551 | if (t !== undefined && (i >= end || i >= begin && !0 !== t.generatedInput && IsEnclosedStatic(i, positionsClone, { |
| 552 | begin: begin, |
| 553 | end: end |
| 554 | }))) { |
| 555 | for (;"" !== getTest(posMatch).match.def; ) { |
| 556 | if (!1 === needsValidation && positionsClone[posMatch] && positionsClone[posMatch].match.nativeDef === t.match.nativeDef) getMaskSet().validPositions[posMatch] = $.extend(!0, {}, positionsClone[posMatch]), |
| 557 | getMaskSet().validPositions[posMatch].input = t.input, trackbackPositions(undefined, posMatch, !0), |
| 558 | j = posMatch + 1, valid = !0; else if (positionCanMatchDefinition(posMatch, t.match.def)) { |
| 559 | var result = isValid(posMatch, t.input, !0, !0); |
| 560 | valid = !1 !== result, j = result.caret || result.insert ? getLastValidPosition() : posMatch + 1, |
| 561 | needsValidation = !0; |
| 562 | } else if (!(valid = !0 === t.generatedInput || t.input === opts.radixPoint && !0 === opts.numericInput) && "" === getTest(posMatch).match.def) break; |
| 563 | if (valid) break; |
| 564 | posMatch++; |
| 565 | } |
| 566 | "" == getTest(posMatch).match.def && (valid = !1), posMatch = j; |
| 567 | } |
| 568 | if (!valid) break; |
| 569 | } |
| 570 | if (!valid) return getMaskSet().validPositions = $.extend(!0, {}, positionsClone), |
| 571 | resetMaskSet(!0), !1; |
| 572 | } else validTest && (getMaskSet().validPositions[validatedPos] = $.extend(!0, {}, validTest)); |
| 573 | return resetMaskSet(!0), !0; |
| 574 | } |
| 575 | function isMask(pos, strict) { |
| 576 | var test = getTestTemplate(pos).match; |
| 577 | if ("" === test.def && (test = getTest(pos).match), null != test.fn) return test.fn; |
| 578 | if (!0 !== strict && pos > -1) { |
| 579 | var tests = getTests(pos); |
| 580 | return tests.length > 1 + ("" === tests[tests.length - 1].match.def ? 1 : 0); |
| 581 | } |
| 582 | return !1; |
| 583 | } |
| 584 | function seekNext(pos, newBlock) { |
| 585 | for (var position = pos + 1; "" !== getTest(position).match.def && (!0 === newBlock && (!0 !== getTest(position).match.newBlockMarker || !isMask(position)) || !0 !== newBlock && !isMask(position)); ) position++; |
| 586 | return position; |
| 587 | } |
| 588 | function seekPrevious(pos, newBlock) { |
| 589 | var tests, position = pos; |
| 590 | if (position <= 0) return 0; |
| 591 | for (;--position > 0 && (!0 === newBlock && !0 !== getTest(position).match.newBlockMarker || !0 !== newBlock && !isMask(position) && ((tests = getTests(position)).length < 2 || 2 === tests.length && "" === tests[1].match.def)); ) ; |
| 592 | return position; |
| 593 | } |
| 594 | function writeBuffer(input, buffer, caretPos, event, triggerEvents) { |
| 595 | if (event && $.isFunction(opts.onBeforeWrite)) { |
| 596 | var result = opts.onBeforeWrite.call(inputmask, event, buffer, caretPos, opts); |
| 597 | if (result) { |
| 598 | if (result.refreshFromBuffer) { |
| 599 | var refresh = result.refreshFromBuffer; |
| 600 | refreshFromBuffer(!0 === refresh ? refresh : refresh.start, refresh.end, result.buffer || buffer), |
| 601 | buffer = getBuffer(!0); |
| 602 | } |
| 603 | caretPos !== undefined && (caretPos = result.caret !== undefined ? result.caret : caretPos); |
| 604 | } |
| 605 | } |
| 606 | if (input !== undefined && (input.inputmask._valueSet(buffer.join("")), caretPos === undefined || event !== undefined && "blur" === event.type ? renderColorMask(input, caretPos, 0 === buffer.length) : caret(input, caretPos), |
| 607 | !0 === triggerEvents)) { |
| 608 | var $input = $(input), nptVal = input.inputmask._valueGet(); |
| 609 | skipInputEvent = !0, $input.trigger("input"), setTimeout(function() { |
| 610 | nptVal === getBufferTemplate().join("") ? $input.trigger("cleared") : !0 === isComplete(buffer) && $input.trigger("complete"); |
| 611 | }, 0); |
| 612 | } |
| 613 | } |
| 614 | function getPlaceholder(pos, test, returnPL) { |
| 615 | if ((test = test || getTest(pos).match).placeholder !== undefined || !0 === returnPL) return $.isFunction(test.placeholder) ? test.placeholder(opts) : test.placeholder; |
| 616 | if (null === test.fn) { |
| 617 | if (pos > -1 && getMaskSet().validPositions[pos] === undefined) { |
| 618 | var prevTest, tests = getTests(pos), staticAlternations = []; |
| 619 | if (tests.length > 1 + ("" === tests[tests.length - 1].match.def ? 1 : 0)) for (var i = 0; i < tests.length; i++) if (!0 !== tests[i].match.optionality && !0 !== tests[i].match.optionalQuantifier && (null === tests[i].match.fn || prevTest === undefined || !1 !== tests[i].match.fn.test(prevTest.match.def, getMaskSet(), pos, !0, opts)) && (staticAlternations.push(tests[i]), |
| 620 | null === tests[i].match.fn && (prevTest = tests[i]), staticAlternations.length > 1 && /[0-9a-bA-Z]/.test(staticAlternations[0].match.def))) return opts.placeholder.charAt(pos % opts.placeholder.length); |
| 621 | } |
| 622 | return test.def; |
| 623 | } |
| 624 | return opts.placeholder.charAt(pos % opts.placeholder.length); |
| 625 | } |
| 626 | var valueBuffer, EventRuler = { |
| 627 | on: function(input, eventName, eventHandler) { |
| 628 | var ev = function(e) { |
| 629 | var that = this; |
| 630 | if (that.inputmask === undefined && "FORM" !== this.nodeName) { |
| 631 | var imOpts = $.data(that, "_inputmask_opts"); |
| 632 | imOpts ? new Inputmask(imOpts).mask(that) : EventRuler.off(that); |
| 633 | } else { |
| 634 | if ("setvalue" === e.type || "FORM" === this.nodeName || !(that.disabled || that.readOnly && !("keydown" === e.type && e.ctrlKey && 67 === e.keyCode || !1 === opts.tabThrough && e.keyCode === Inputmask.keyCode.TAB))) { |
| 635 | switch (e.type) { |
| 636 | case "input": |
| 637 | if (!0 === skipInputEvent) return skipInputEvent = !1, e.preventDefault(); |
| 638 | if (mobile) { |
| 639 | var args = arguments; |
| 640 | return setTimeout(function() { |
| 641 | eventHandler.apply(that, args), caret(that, that.inputmask.caretPos, undefined, !0); |
| 642 | }, 0), !1; |
| 643 | } |
| 644 | break; |
| 645 | |
| 646 | case "keydown": |
| 647 | skipKeyPressEvent = !1, skipInputEvent = !1; |
| 648 | break; |
| 649 | |
| 650 | case "keypress": |
| 651 | if (!0 === skipKeyPressEvent) return e.preventDefault(); |
| 652 | skipKeyPressEvent = !0; |
| 653 | break; |
| 654 | |
| 655 | case "click": |
| 656 | if (iemobile || iphone) { |
| 657 | args = arguments; |
| 658 | return setTimeout(function() { |
| 659 | eventHandler.apply(that, args); |
| 660 | }, 0), !1; |
| 661 | } |
| 662 | } |
| 663 | var returnVal = eventHandler.apply(that, arguments); |
| 664 | return !1 === returnVal && (e.preventDefault(), e.stopPropagation()), returnVal; |
| 665 | } |
| 666 | e.preventDefault(); |
| 667 | } |
| 668 | }; |
| 669 | input.inputmask.events[eventName] = input.inputmask.events[eventName] || [], input.inputmask.events[eventName].push(ev), |
| 670 | -1 !== $.inArray(eventName, [ "submit", "reset" ]) ? null !== input.form && $(input.form).on(eventName, ev) : $(input).on(eventName, ev); |
| 671 | }, |
| 672 | off: function(input, event) { |
| 673 | var events; |
| 674 | input.inputmask && input.inputmask.events && (event ? (events = [])[event] = input.inputmask.events[event] : events = input.inputmask.events, |
| 675 | $.each(events, function(eventName, evArr) { |
| 676 | for (;evArr.length > 0; ) { |
| 677 | var ev = evArr.pop(); |
| 678 | -1 !== $.inArray(eventName, [ "submit", "reset" ]) ? null !== input.form && $(input.form).off(eventName, ev) : $(input).off(eventName, ev); |
| 679 | } |
| 680 | delete input.inputmask.events[eventName]; |
| 681 | })); |
| 682 | } |
| 683 | }, EventHandlers = { |
| 684 | keydownEvent: function(e) { |
| 685 | var input = this, $input = $(input), k = e.keyCode, pos = caret(input); |
| 686 | if (k === Inputmask.keyCode.BACKSPACE || k === Inputmask.keyCode.DELETE || iphone && k === Inputmask.keyCode.BACKSPACE_SAFARI || e.ctrlKey && k === Inputmask.keyCode.X && !isInputEventSupported("cut")) e.preventDefault(), |
| 687 | handleRemove(input, k, pos), writeBuffer(input, getBuffer(!0), getMaskSet().p, e, input.inputmask._valueGet() !== getBuffer().join("")); else if (k === Inputmask.keyCode.END || k === Inputmask.keyCode.PAGE_DOWN) { |
| 688 | e.preventDefault(); |
| 689 | var caretPos = seekNext(getLastValidPosition()); |
| 690 | opts.insertMode || caretPos !== getMaskSet().maskLength || e.shiftKey || caretPos--, |
| 691 | caret(input, e.shiftKey ? pos.begin : caretPos, caretPos, !0); |
| 692 | } else k === Inputmask.keyCode.HOME && !e.shiftKey || k === Inputmask.keyCode.PAGE_UP ? (e.preventDefault(), |
| 693 | caret(input, 0, e.shiftKey ? pos.begin : 0, !0)) : (opts.undoOnEscape && k === Inputmask.keyCode.ESCAPE || 90 === k && e.ctrlKey) && !0 !== e.altKey ? (checkVal(input, !0, !1, undoValue.split("")), |
| 694 | $input.trigger("click")) : k !== Inputmask.keyCode.INSERT || e.shiftKey || e.ctrlKey ? !0 === opts.tabThrough && k === Inputmask.keyCode.TAB ? (!0 === e.shiftKey ? (null === getTest(pos.begin).match.fn && (pos.begin = seekNext(pos.begin)), |
| 695 | pos.end = seekPrevious(pos.begin, !0), pos.begin = seekPrevious(pos.end, !0)) : (pos.begin = seekNext(pos.begin, !0), |
| 696 | pos.end = seekNext(pos.begin, !0), pos.end < getMaskSet().maskLength && pos.end--), |
| 697 | pos.begin < getMaskSet().maskLength && (e.preventDefault(), caret(input, pos.begin, pos.end))) : e.shiftKey || !1 === opts.insertMode && (k === Inputmask.keyCode.RIGHT ? setTimeout(function() { |
| 698 | var caretPos = caret(input); |
| 699 | caret(input, caretPos.begin); |
| 700 | }, 0) : k === Inputmask.keyCode.LEFT && setTimeout(function() { |
| 701 | var caretPos = caret(input); |
| 702 | caret(input, isRTL ? caretPos.begin + 1 : caretPos.begin - 1); |
| 703 | }, 0)) : (opts.insertMode = !opts.insertMode, caret(input, opts.insertMode || pos.begin !== getMaskSet().maskLength ? pos.begin : pos.begin - 1)); |
| 704 | opts.onKeyDown.call(this, e, getBuffer(), caret(input).begin, opts), ignorable = -1 !== $.inArray(k, opts.ignorables); |
| 705 | }, |
| 706 | keypressEvent: function(e, checkval, writeOut, strict, ndx) { |
| 707 | var input = this, $input = $(input), k = e.which || e.charCode || e.keyCode; |
| 708 | if (!(!0 === checkval || e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable)) return k === Inputmask.keyCode.ENTER && undoValue !== getBuffer().join("") && (undoValue = getBuffer().join(""), |
| 709 | setTimeout(function() { |
| 710 | $input.trigger("change"); |
| 711 | }, 0)), !0; |
| 712 | if (k) { |
| 713 | 46 === k && !1 === e.shiftKey && "" !== opts.radixPoint && (k = opts.radixPoint.charCodeAt(0)); |
| 714 | var forwardPosition, pos = checkval ? { |
| 715 | begin: ndx, |
| 716 | end: ndx |
| 717 | } : caret(input), c = String.fromCharCode(k), offset = 0; |
| 718 | if (opts._radixDance && opts.numericInput) { |
| 719 | var caretPos = getBuffer().indexOf(opts.radixPoint.charAt(0)) + 1; |
| 720 | pos.begin <= caretPos && (k === opts.radixPoint.charCodeAt(0) && (offset = 1), pos.begin -= 1, |
| 721 | pos.end -= 1); |
| 722 | } |
| 723 | getMaskSet().writeOutBuffer = !0; |
| 724 | var valResult = isValid(pos, c, strict); |
| 725 | if (!1 !== valResult && (resetMaskSet(!0), forwardPosition = valResult.caret !== undefined ? valResult.caret : seekNext(valResult.pos.begin ? valResult.pos.begin : valResult.pos), |
| 726 | getMaskSet().p = forwardPosition), forwardPosition = (opts.numericInput && valResult.caret === undefined ? seekPrevious(forwardPosition) : forwardPosition) + offset, |
| 727 | !1 !== writeOut && (setTimeout(function() { |
| 728 | opts.onKeyValidation.call(input, k, valResult, opts); |
| 729 | }, 0), getMaskSet().writeOutBuffer && !1 !== valResult)) { |
| 730 | var buffer = getBuffer(); |
| 731 | writeBuffer(input, buffer, forwardPosition, e, !0 !== checkval); |
| 732 | } |
| 733 | if (e.preventDefault(), checkval) return !1 !== valResult && (valResult.forwardPosition = forwardPosition), |
| 734 | valResult; |
| 735 | } |
| 736 | }, |
| 737 | pasteEvent: function(e) { |
| 738 | var tempValue, ev = e.originalEvent || e, inputValue = ($(this), this.inputmask._valueGet(!0)), caretPos = caret(this); |
| 739 | isRTL && (tempValue = caretPos.end, caretPos.end = caretPos.begin, caretPos.begin = tempValue); |
| 740 | var valueBeforeCaret = inputValue.substr(0, caretPos.begin), valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length); |
| 741 | if (valueBeforeCaret === (isRTL ? getBufferTemplate().reverse() : getBufferTemplate()).slice(0, caretPos.begin).join("") && (valueBeforeCaret = ""), |
| 742 | valueAfterCaret === (isRTL ? getBufferTemplate().reverse() : getBufferTemplate()).slice(caretPos.end).join("") && (valueAfterCaret = ""), |
| 743 | window.clipboardData && window.clipboardData.getData) inputValue = valueBeforeCaret + window.clipboardData.getData("Text") + valueAfterCaret; else { |
| 744 | if (!ev.clipboardData || !ev.clipboardData.getData) return !0; |
| 745 | inputValue = valueBeforeCaret + ev.clipboardData.getData("text/plain") + valueAfterCaret; |
| 746 | } |
| 747 | var pasteValue = inputValue; |
| 748 | if ($.isFunction(opts.onBeforePaste)) { |
| 749 | if (!1 === (pasteValue = opts.onBeforePaste.call(inputmask, inputValue, opts))) return e.preventDefault(); |
| 750 | pasteValue || (pasteValue = inputValue); |
| 751 | } |
| 752 | return checkVal(this, !1, !1, pasteValue.toString().split("")), writeBuffer(this, getBuffer(), seekNext(getLastValidPosition()), e, undoValue !== getBuffer().join("")), |
| 753 | e.preventDefault(); |
| 754 | }, |
| 755 | inputFallBackEvent: function(e) { |
| 756 | var input = this, inputValue = input.inputmask._valueGet(); |
| 757 | if (getBuffer().join("") !== inputValue) { |
| 758 | var caretPos = caret(input); |
| 759 | if (inputValue = function(input, inputValue, caretPos) { |
| 760 | if (iemobile) { |
| 761 | var inputChar = inputValue.replace(getBuffer().join(""), ""); |
| 762 | if (1 === inputChar.length) { |
| 763 | var iv = inputValue.split(""); |
| 764 | iv.splice(caretPos.begin, 0, inputChar), inputValue = iv.join(""); |
| 765 | } |
| 766 | } |
| 767 | return inputValue; |
| 768 | }(0, inputValue = function(input, inputValue, caretPos) { |
| 769 | return "." === inputValue.charAt(caretPos.begin - 1) && "" !== opts.radixPoint && ((inputValue = inputValue.split(""))[caretPos.begin - 1] = opts.radixPoint.charAt(0), |
| 770 | inputValue = inputValue.join("")), inputValue; |
| 771 | }(0, inputValue, caretPos), caretPos), getBuffer().join("") !== inputValue) { |
| 772 | 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), selection = caretPos, entries = "", isEntry = !1; |
| 773 | if (frontPart !== frontBufferPart) { |
| 774 | for (var fpl = (isEntry = frontPart.length >= frontBufferPart.length) ? frontPart.length : frontBufferPart.length, i = 0; frontPart.charAt(i) === frontBufferPart.charAt(i) && i < fpl; i++) ; |
| 775 | isEntry && (0 === offset && (selection.begin = i), entries += frontPart.slice(i, selection.end)); |
| 776 | } |
| 777 | if (backPart !== backBufferPart && (backPart.length > backBufferPart.length ? entries += backPart.slice(0, 1) : backPart.length < backBufferPart.length && (selection.end += backBufferPart.length - backPart.length, |
| 778 | isEntry || "" === opts.radixPoint || "" !== backPart || frontPart.charAt(selection.begin + offset - 1) !== opts.radixPoint || (selection.begin--, |
| 779 | entries = opts.radixPoint))), writeBuffer(input, getBuffer(), { |
| 780 | begin: selection.begin + offset, |
| 781 | end: selection.end + offset |
| 782 | }), entries.length > 0) $.each(entries.split(""), function(ndx, entry) { |
| 783 | var keypress = new $.Event("keypress"); |
| 784 | keypress.which = entry.charCodeAt(0), ignorable = !1, EventHandlers.keypressEvent.call(input, keypress); |
| 785 | }); else { |
| 786 | selection.begin === selection.end - 1 && (selection.begin = seekPrevious(selection.begin + 1), |
| 787 | selection.begin === selection.end - 1 ? caret(input, selection.begin) : caret(input, selection.begin, selection.end)); |
| 788 | var keydown = new $.Event("keydown"); |
| 789 | keydown.keyCode = opts.numericInput ? Inputmask.keyCode.BACKSPACE : Inputmask.keyCode.DELETE, |
| 790 | EventHandlers.keydownEvent.call(input, keydown), !1 === opts.insertMode && caret(input, caret(input).begin - 1); |
| 791 | } |
| 792 | e.preventDefault(); |
| 793 | } |
| 794 | } |
| 795 | }, |
| 796 | beforeInputEvent: function(e) { |
| 797 | if (e.cancelable) { |
| 798 | var input = this; |
| 799 | switch (e.inputType) { |
| 800 | case "insertText": |
| 801 | return $.each(e.data.split(""), function(ndx, entry) { |
| 802 | var keypress = new $.Event("keypress"); |
| 803 | keypress.which = entry.charCodeAt(0), ignorable = !1, EventHandlers.keypressEvent.call(input, keypress); |
| 804 | }), e.preventDefault(); |
| 805 | |
| 806 | case "deleteContentBackward": |
| 807 | return (keydown = new $.Event("keydown")).keyCode = Inputmask.keyCode.BACKSPACE, |
| 808 | EventHandlers.keydownEvent.call(input, keydown), e.preventDefault(); |
| 809 | |
| 810 | case "deleteContentForward": |
| 811 | var keydown; |
| 812 | return (keydown = new $.Event("keydown")).keyCode = Inputmask.keyCode.DELETE, EventHandlers.keydownEvent.call(input, keydown), |
| 813 | e.preventDefault(); |
| 814 | } |
| 815 | } |
| 816 | }, |
| 817 | setValueEvent: function(e) { |
| 818 | this.inputmask.refreshValue = !1; |
| 819 | var value = (value = e && e.detail ? e.detail[0] : arguments[1]) || this.inputmask._valueGet(!0); |
| 820 | $.isFunction(opts.onBeforeMask) && (value = opts.onBeforeMask.call(inputmask, value, opts) || value), |
| 821 | checkVal(this, !0, !1, value = value.split("")), undoValue = getBuffer().join(""), |
| 822 | (opts.clearMaskOnLostFocus || opts.clearIncomplete) && this.inputmask._valueGet() === getBufferTemplate().join("") && this.inputmask._valueSet(""); |
| 823 | }, |
| 824 | focusEvent: function(e) { |
| 825 | var nptValue = this.inputmask._valueGet(); |
| 826 | opts.showMaskOnFocus && (!opts.showMaskOnHover || opts.showMaskOnHover && "" === nptValue) && (this.inputmask._valueGet() !== getBuffer().join("") ? writeBuffer(this, getBuffer(), seekNext(getLastValidPosition())) : !1 === mouseEnter && caret(this, seekNext(getLastValidPosition()))), |
| 827 | !0 === opts.positionCaretOnTab && !1 === mouseEnter && EventHandlers.clickEvent.apply(this, [ e, !0 ]), |
| 828 | undoValue = getBuffer().join(""); |
| 829 | }, |
| 830 | mouseleaveEvent: function(e) { |
| 831 | if (mouseEnter = !1, opts.clearMaskOnLostFocus && document.activeElement !== this) { |
| 832 | var buffer = getBuffer().slice(), nptValue = this.inputmask._valueGet(); |
| 833 | nptValue !== this.getAttribute("placeholder") && "" !== nptValue && (-1 === getLastValidPosition() && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer), |
| 834 | writeBuffer(this, buffer)); |
| 835 | } |
| 836 | }, |
| 837 | clickEvent: function(e, tabbed) { |
| 838 | var input = this; |
| 839 | setTimeout(function() { |
| 840 | if (document.activeElement === input) { |
| 841 | var selectedCaret = caret(input); |
| 842 | if (tabbed && (isRTL ? selectedCaret.end = selectedCaret.begin : selectedCaret.begin = selectedCaret.end), |
| 843 | selectedCaret.begin === selectedCaret.end) switch (opts.positionCaretOnClick) { |
| 844 | case "none": |
| 845 | break; |
| 846 | |
| 847 | case "select": |
| 848 | caret(input, 0, getBuffer().length); |
| 849 | break; |
| 850 | |
| 851 | case "ignore": |
| 852 | caret(input, seekNext(getLastValidPosition())); |
| 853 | break; |
| 854 | |
| 855 | case "radixFocus": |
| 856 | if (function(clickPos) { |
| 857 | if ("" !== opts.radixPoint) { |
| 858 | var vps = getMaskSet().validPositions; |
| 859 | if (vps[clickPos] === undefined || vps[clickPos].input === getPlaceholder(clickPos)) { |
| 860 | if (clickPos < seekNext(-1)) return !0; |
| 861 | var radixPos = $.inArray(opts.radixPoint, getBuffer()); |
| 862 | if (-1 !== radixPos) { |
| 863 | for (var vp in vps) if (radixPos < vp && vps[vp].input !== getPlaceholder(vp)) return !1; |
| 864 | return !0; |
| 865 | } |
| 866 | } |
| 867 | } |
| 868 | return !1; |
| 869 | }(selectedCaret.begin)) { |
| 870 | var radixPos = getBuffer().join("").indexOf(opts.radixPoint); |
| 871 | caret(input, opts.numericInput ? seekNext(radixPos) : radixPos); |
| 872 | break; |
| 873 | } |
| 874 | |
| 875 | default: |
| 876 | var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition, !0), lastPosition = seekNext(lvclickPosition); |
| 877 | if (clickPosition < lastPosition) caret(input, isMask(clickPosition, !0) || isMask(clickPosition - 1, !0) ? clickPosition : seekNext(clickPosition)); else { |
| 878 | var lvp = getMaskSet().validPositions[lvclickPosition], tt = getTestTemplate(lastPosition, lvp ? lvp.match.locator : undefined, lvp), placeholder = getPlaceholder(lastPosition, tt.match); |
| 879 | if ("" !== placeholder && getBuffer()[lastPosition] !== placeholder && !0 !== tt.match.optionalQuantifier && !0 !== tt.match.newBlockMarker || !isMask(lastPosition, opts.keepStatic) && tt.match.def === placeholder) { |
| 880 | var newPos = seekNext(lastPosition); |
| 881 | (clickPosition >= newPos || clickPosition === lastPosition) && (lastPosition = newPos); |
| 882 | } |
| 883 | caret(input, lastPosition); |
| 884 | } |
| 885 | } |
| 886 | } |
| 887 | }, 0); |
| 888 | }, |
| 889 | dblclickEvent: function(e) { |
| 890 | var input = this; |
| 891 | setTimeout(function() { |
| 892 | caret(input, 0, seekNext(getLastValidPosition())); |
| 893 | }, 0); |
| 894 | }, |
| 895 | cutEvent: function(e) { |
| 896 | $(this); |
| 897 | var pos = caret(this), ev = e.originalEvent || e, clipboardData = window.clipboardData || ev.clipboardData, clipData = isRTL ? getBuffer().slice(pos.end, pos.begin) : getBuffer().slice(pos.begin, pos.end); |
| 898 | clipboardData.setData("text", isRTL ? clipData.reverse().join("") : clipData.join("")), |
| 899 | document.execCommand && document.execCommand("copy"), handleRemove(this, Inputmask.keyCode.DELETE, pos), |
| 900 | writeBuffer(this, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")); |
| 901 | }, |
| 902 | blurEvent: function(e) { |
| 903 | var $input = $(this); |
| 904 | if (this.inputmask) { |
| 905 | var nptValue = this.inputmask._valueGet(), buffer = getBuffer().slice(); |
| 906 | "" === nptValue && colorMask === undefined || (opts.clearMaskOnLostFocus && (-1 === getLastValidPosition() && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)), |
| 907 | !1 === isComplete(buffer) && (setTimeout(function() { |
| 908 | $input.trigger("incomplete"); |
| 909 | }, 0), opts.clearIncomplete && (resetMaskSet(), buffer = opts.clearMaskOnLostFocus ? [] : getBufferTemplate().slice())), |
| 910 | writeBuffer(this, buffer, undefined, e)), undoValue !== getBuffer().join("") && (undoValue = buffer.join(""), |
| 911 | $input.trigger("change")); |
| 912 | } |
| 913 | }, |
| 914 | mouseenterEvent: function(e) { |
| 915 | mouseEnter = !0, document.activeElement !== this && opts.showMaskOnHover && this.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(this, getBuffer()); |
| 916 | }, |
| 917 | submitEvent: function(e) { |
| 918 | undoValue !== getBuffer().join("") && $el.trigger("change"), opts.clearMaskOnLostFocus && -1 === getLastValidPosition() && el.inputmask._valueGet && el.inputmask._valueGet() === getBufferTemplate().join("") && el.inputmask._valueSet(""), |
| 919 | opts.clearIncomplete && !1 === isComplete(getBuffer()) && el.inputmask._valueSet(""), |
| 920 | opts.removeMaskOnSubmit && (el.inputmask._valueSet(el.inputmask.unmaskedvalue(), !0), |
| 921 | setTimeout(function() { |
| 922 | writeBuffer(el, getBuffer()); |
| 923 | }, 0)); |
| 924 | }, |
| 925 | resetEvent: function(e) { |
| 926 | el.inputmask.refreshValue = !0, setTimeout(function() { |
| 927 | $el.trigger("setvalue"); |
| 928 | }, 0); |
| 929 | } |
| 930 | }; |
| 931 | function checkVal(input, writeOut, strict, nptvl, initiatingEvent) { |
| 932 | var inputmask = this || input.inputmask, inputValue = nptvl.slice(), charCodes = "", initialNdx = -1, result = undefined; |
| 933 | if (resetMaskSet(), strict || !0 === opts.autoUnmask) initialNdx = seekNext(initialNdx); else { |
| 934 | var staticInput = getBufferTemplate().slice(0, seekNext(-1)).join(""), matches = inputValue.join("").match(new RegExp("^" + Inputmask.escapeRegex(staticInput), "g")); |
| 935 | matches && matches.length > 0 && (inputValue.splice(0, matches.length * staticInput.length), |
| 936 | initialNdx = seekNext(initialNdx)); |
| 937 | } |
| 938 | -1 === initialNdx ? (getMaskSet().p = seekNext(initialNdx), initialNdx = 0) : getMaskSet().p = initialNdx, |
| 939 | inputmask.caretPos = { |
| 940 | begin: initialNdx |
| 941 | }, $.each(inputValue, function(ndx, charCode) { |
| 942 | if (charCode !== undefined) if (getMaskSet().validPositions[ndx] === undefined && inputValue[ndx] === getPlaceholder(ndx) && isMask(ndx, !0) && !1 === isValid(ndx, inputValue[ndx], !0, undefined, undefined, !0)) getMaskSet().p++; else { |
| 943 | var keypress = new $.Event("_checkval"); |
| 944 | keypress.which = charCode.charCodeAt(0), charCodes += charCode; |
| 945 | var lvp = getLastValidPosition(undefined, !0); |
| 946 | !function(ndx, charCodes) { |
| 947 | return -1 !== getMaskTemplate(!0, 0, !1).slice(ndx, seekNext(ndx)).join("").replace(/'/g, "").indexOf(charCodes) && !isMask(ndx) && (getTest(ndx).match.nativeDef === charCodes.charAt(0) || null === getTest(ndx).match.fn && getTest(ndx).match.nativeDef === "'" + charCodes.charAt(0) || " " === getTest(ndx).match.nativeDef && (getTest(ndx + 1).match.nativeDef === charCodes.charAt(0) || null === getTest(ndx + 1).match.fn && getTest(ndx + 1).match.nativeDef === "'" + charCodes.charAt(0))); |
| 948 | }(initialNdx, charCodes) ? (result = EventHandlers.keypressEvent.call(input, keypress, !0, !1, strict, inputmask.caretPos.begin)) && (initialNdx = inputmask.caretPos.begin + 1, |
| 949 | charCodes = "") : result = EventHandlers.keypressEvent.call(input, keypress, !0, !1, strict, lvp + 1), |
| 950 | result && (writeBuffer(undefined, getBuffer(), result.forwardPosition, keypress, !1), |
| 951 | inputmask.caretPos = { |
| 952 | begin: result.forwardPosition, |
| 953 | end: result.forwardPosition |
| 954 | }); |
| 955 | } |
| 956 | }), writeOut && writeBuffer(input, getBuffer(), result ? result.forwardPosition : undefined, initiatingEvent || new $.Event("checkval"), initiatingEvent && "input" === initiatingEvent.type); |
| 957 | } |
| 958 | function unmaskedvalue(input) { |
| 959 | if (input) { |
| 960 | if (input.inputmask === undefined) return input.value; |
| 961 | input.inputmask && input.inputmask.refreshValue && EventHandlers.setValueEvent.call(input); |
| 962 | } |
| 963 | var umValue = [], vps = getMaskSet().validPositions; |
| 964 | for (var pndx in vps) vps[pndx].match && null != vps[pndx].match.fn && umValue.push(vps[pndx].input); |
| 965 | var unmaskedValue = 0 === umValue.length ? "" : (isRTL ? umValue.reverse() : umValue).join(""); |
| 966 | if ($.isFunction(opts.onUnMask)) { |
| 967 | var bufferValue = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join(""); |
| 968 | unmaskedValue = opts.onUnMask.call(inputmask, bufferValue, unmaskedValue, opts); |
| 969 | } |
| 970 | return unmaskedValue; |
| 971 | } |
| 972 | function translatePosition(pos) { |
| 973 | return !isRTL || "number" != typeof pos || opts.greedy && "" === opts.placeholder || !el || (pos = el.inputmask._valueGet().length - pos), |
| 974 | pos; |
| 975 | } |
| 976 | function caret(input, begin, end, notranslate) { |
| 977 | var range; |
| 978 | if (begin === undefined) return input.setSelectionRange ? (begin = input.selectionStart, |
| 979 | end = input.selectionEnd) : window.getSelection ? (range = window.getSelection().getRangeAt(0)).commonAncestorContainer.parentNode !== input && range.commonAncestorContainer !== input || (begin = range.startOffset, |
| 980 | end = range.endOffset) : document.selection && document.selection.createRange && (end = (begin = 0 - (range = document.selection.createRange()).duplicate().moveStart("character", -input.inputmask._valueGet().length)) + range.text.length), |
| 981 | { |
| 982 | begin: notranslate ? begin : translatePosition(begin), |
| 983 | end: notranslate ? end : translatePosition(end) |
| 984 | }; |
| 985 | if ($.isArray(begin) && (end = isRTL ? begin[0] : begin[1], begin = isRTL ? begin[1] : begin[0]), |
| 986 | begin.begin !== undefined && (end = isRTL ? begin.begin : begin.end, begin = isRTL ? begin.end : begin.begin), |
| 987 | "number" == typeof begin) { |
| 988 | begin = notranslate ? begin : translatePosition(begin), end = "number" == typeof (end = notranslate ? end : translatePosition(end)) ? end : begin; |
| 989 | var scrollCalc = parseInt(((input.ownerDocument.defaultView || window).getComputedStyle ? (input.ownerDocument.defaultView || window).getComputedStyle(input, null) : input.currentStyle).fontSize) * end; |
| 990 | if (input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0, iphone || !1 !== opts.insertMode || begin !== end || end++, |
| 991 | input.inputmask.caretPos = { |
| 992 | begin: begin, |
| 993 | end: end |
| 994 | }, input.setSelectionRange) input.selectionStart = begin, input.selectionEnd = end; else if (window.getSelection) { |
| 995 | if (range = document.createRange(), input.firstChild === undefined || null === input.firstChild) { |
| 996 | var textNode = document.createTextNode(""); |
| 997 | input.appendChild(textNode); |
| 998 | } |
| 999 | range.setStart(input.firstChild, begin < input.inputmask._valueGet().length ? begin : input.inputmask._valueGet().length), |
| 1000 | range.setEnd(input.firstChild, end < input.inputmask._valueGet().length ? end : input.inputmask._valueGet().length), |
| 1001 | range.collapse(!0); |
| 1002 | var sel = window.getSelection(); |
| 1003 | sel.removeAllRanges(), sel.addRange(range); |
| 1004 | } else input.createTextRange && ((range = input.createTextRange()).collapse(!0), |
| 1005 | range.moveEnd("character", end), range.moveStart("character", begin), range.select()); |
| 1006 | renderColorMask(input, { |
| 1007 | begin: begin, |
| 1008 | end: end |
| 1009 | }); |
| 1010 | } |
| 1011 | } |
| 1012 | function determineLastRequiredPosition(returnDefinition) { |
| 1013 | var pos, testPos, buffer = getMaskTemplate(!0, getLastValidPosition(), !0, !0), bl = buffer.length, lvp = getLastValidPosition(), positions = {}, lvTest = getMaskSet().validPositions[lvp], ndxIntlzr = lvTest !== undefined ? lvTest.locator.slice() : undefined; |
| 1014 | for (pos = lvp + 1; pos < buffer.length; pos++) ndxIntlzr = (testPos = getTestTemplate(pos, ndxIntlzr, pos - 1)).locator.slice(), |
| 1015 | positions[pos] = $.extend(!0, {}, testPos); |
| 1016 | var lvTestAlt = lvTest && lvTest.alternation !== undefined ? lvTest.locator[lvTest.alternation] : undefined; |
| 1017 | for (pos = bl - 1; pos > lvp && (((testPos = positions[pos]).match.optionality || testPos.match.optionalQuantifier && testPos.match.newBlockMarker || lvTestAlt && (lvTestAlt !== positions[pos].locator[lvTest.alternation] && null != testPos.match.fn || null === testPos.match.fn && testPos.locator[lvTest.alternation] && checkAlternationMatch(testPos.locator[lvTest.alternation].toString().split(","), lvTestAlt.toString().split(",")) && "" !== getTests(pos)[0].def)) && buffer[pos] === getPlaceholder(pos, testPos.match)); pos--) bl--; |
| 1018 | return returnDefinition ? { |
| 1019 | l: bl, |
| 1020 | def: positions[bl] ? positions[bl].match : undefined |
| 1021 | } : bl; |
| 1022 | } |
| 1023 | function clearOptionalTail(buffer) { |
| 1024 | buffer.length = 0; |
| 1025 | for (var lmnt, template = getMaskTemplate(!0, 0, !0, undefined, !0); (lmnt = template.shift()) !== undefined; ) buffer.push(lmnt); |
| 1026 | return buffer; |
| 1027 | } |
| 1028 | function isComplete(buffer) { |
| 1029 | if ($.isFunction(opts.isComplete)) return opts.isComplete(buffer, opts); |
| 1030 | if ("*" === opts.repeat) return undefined; |
| 1031 | var complete = !1, lrp = determineLastRequiredPosition(!0), aml = seekPrevious(lrp.l); |
| 1032 | if (lrp.def === undefined || lrp.def.newBlockMarker || lrp.def.optionality || lrp.def.optionalQuantifier) { |
| 1033 | complete = !0; |
| 1034 | for (var i = 0; i <= aml; i++) { |
| 1035 | var test = getTestTemplate(i).match; |
| 1036 | if (null !== test.fn && getMaskSet().validPositions[i] === undefined && !0 !== test.optionality && !0 !== test.optionalQuantifier || null === test.fn && buffer[i] !== getPlaceholder(i, test)) { |
| 1037 | complete = !1; |
| 1038 | break; |
| 1039 | } |
| 1040 | } |
| 1041 | } |
| 1042 | return complete; |
| 1043 | } |
| 1044 | function handleRemove(input, k, pos, strict, fromIsValid) { |
| 1045 | if ((opts.numericInput || isRTL) && (k === Inputmask.keyCode.BACKSPACE ? k = Inputmask.keyCode.DELETE : k === Inputmask.keyCode.DELETE && (k = Inputmask.keyCode.BACKSPACE), |
| 1046 | isRTL)) { |
| 1047 | var pend = pos.end; |
| 1048 | pos.end = pos.begin, pos.begin = pend; |
| 1049 | } |
| 1050 | if (k === Inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || !1 === opts.insertMode) ? (pos.begin = seekPrevious(pos.begin), |
| 1051 | getMaskSet().validPositions[pos.begin] !== undefined && getMaskSet().validPositions[pos.begin].input === opts.groupSeparator && pos.begin--, |
| 1052 | !1 === opts.insertMode && pos.end !== getMaskSet().maskLength && pos.end--) : k === Inputmask.keyCode.DELETE && pos.begin === pos.end && (pos.end = isMask(pos.end, !0) && getMaskSet().validPositions[pos.end] && getMaskSet().validPositions[pos.end].input !== opts.radixPoint ? pos.end + 1 : seekNext(pos.end) + 1, |
| 1053 | getMaskSet().validPositions[pos.begin] !== undefined && getMaskSet().validPositions[pos.begin].input === opts.groupSeparator && pos.end++), |
| 1054 | revalidateMask(pos), !0 !== strict && !1 !== opts.keepStatic || null !== opts.regex) { |
| 1055 | var result = alternate(!0); |
| 1056 | if (result) { |
| 1057 | var newPos = result.caret !== undefined ? result.caret : result.pos ? seekNext(result.pos.begin ? result.pos.begin : result.pos) : getLastValidPosition(-1, !0); |
| 1058 | (k !== Inputmask.keyCode.DELETE || pos.begin > newPos) && pos.begin; |
| 1059 | } |
| 1060 | } |
| 1061 | var lvp = getLastValidPosition(pos.begin, !0); |
| 1062 | if (lvp < pos.begin || -1 === pos.begin) getMaskSet().p = seekNext(lvp); else if (!0 !== strict && (getMaskSet().p = pos.begin, |
| 1063 | !0 !== fromIsValid)) for (;getMaskSet().p < lvp && getMaskSet().validPositions[getMaskSet().p] === undefined; ) getMaskSet().p++; |
| 1064 | } |
| 1065 | function initializeColorMask(input) { |
| 1066 | var computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null); |
| 1067 | var template = document.createElement("div"); |
| 1068 | template.style.width = computedStyle.width, template.style.textAlign = computedStyle.textAlign, |
| 1069 | colorMask = document.createElement("div"), input.inputmask.colorMask = colorMask, |
| 1070 | colorMask.className = "im-colormask", input.parentNode.insertBefore(colorMask, input), |
| 1071 | input.parentNode.removeChild(input), colorMask.appendChild(input), colorMask.appendChild(template), |
| 1072 | input.style.left = template.offsetLeft + "px", $(colorMask).on("mouseleave", function(e) { |
| 1073 | return EventHandlers.mouseleaveEvent.call(input, [ e ]); |
| 1074 | }), $(colorMask).on("mouseenter", function(e) { |
| 1075 | return EventHandlers.mouseenterEvent.call(input, [ e ]); |
| 1076 | }), $(colorMask).on("click", function(e) { |
| 1077 | return caret(input, function(clientx) { |
| 1078 | var caretPos, e = document.createElement("span"); |
| 1079 | for (var style in computedStyle) isNaN(style) && -1 !== style.indexOf("font") && (e.style[style] = computedStyle[style]); |
| 1080 | e.style.textTransform = computedStyle.textTransform, e.style.letterSpacing = computedStyle.letterSpacing, |
| 1081 | e.style.position = "absolute", e.style.height = "auto", e.style.width = "auto", |
| 1082 | e.style.visibility = "hidden", e.style.whiteSpace = "nowrap", document.body.appendChild(e); |
| 1083 | var itl, inputText = input.inputmask._valueGet(), previousWidth = 0; |
| 1084 | for (caretPos = 0, itl = inputText.length; caretPos <= itl; caretPos++) { |
| 1085 | if (e.innerHTML += inputText.charAt(caretPos) || "_", e.offsetWidth >= clientx) { |
| 1086 | var offset1 = clientx - previousWidth, offset2 = e.offsetWidth - clientx; |
| 1087 | e.innerHTML = inputText.charAt(caretPos), caretPos = (offset1 -= e.offsetWidth / 3) < offset2 ? caretPos - 1 : caretPos; |
| 1088 | break; |
| 1089 | } |
| 1090 | previousWidth = e.offsetWidth; |
| 1091 | } |
| 1092 | return document.body.removeChild(e), caretPos; |
| 1093 | }(e.clientX)), EventHandlers.clickEvent.call(input, [ e ]); |
| 1094 | }), $(input).on("keydown", function(e) { |
| 1095 | e.shiftKey || !1 === opts.insertMode || setTimeout(function() { |
| 1096 | renderColorMask(input); |
| 1097 | }, 0); |
| 1098 | }); |
| 1099 | } |
| 1100 | function renderColorMask(input, caretPos, clear) { |
| 1101 | var test, testPos, ndxIntlzr, maskTemplate = [], isStatic = !1, pos = 0; |
| 1102 | function setEntry(entry) { |
| 1103 | if (entry === undefined && (entry = ""), isStatic || null !== test.fn && testPos.input !== undefined) if (isStatic && (null !== test.fn && testPos.input !== undefined || "" === test.def)) { |
| 1104 | isStatic = !1; |
| 1105 | var mtl = maskTemplate.length; |
| 1106 | maskTemplate[mtl - 1] = maskTemplate[mtl - 1] + "</span>", maskTemplate.push(entry); |
| 1107 | } else maskTemplate.push(entry); else isStatic = !0, maskTemplate.push("<span class='im-static'>" + entry); |
| 1108 | } |
| 1109 | if (colorMask !== undefined) { |
| 1110 | var buffer = getBuffer(); |
| 1111 | if (caretPos === undefined ? caretPos = caret(input) : caretPos.begin === undefined && (caretPos = { |
| 1112 | begin: caretPos, |
| 1113 | end: caretPos |
| 1114 | }), !0 !== clear) { |
| 1115 | var lvp = getLastValidPosition(); |
| 1116 | do { |
| 1117 | getMaskSet().validPositions[pos] ? (testPos = getMaskSet().validPositions[pos], |
| 1118 | test = testPos.match, ndxIntlzr = testPos.locator.slice(), setEntry(buffer[pos])) : (testPos = getTestTemplate(pos, ndxIntlzr, pos - 1), |
| 1119 | test = testPos.match, ndxIntlzr = testPos.locator.slice(), !1 === opts.jitMasking || pos < lvp || "number" == typeof opts.jitMasking && isFinite(opts.jitMasking) && opts.jitMasking > pos ? setEntry(getPlaceholder(pos, test)) : isStatic = !1), |
| 1120 | pos++; |
| 1121 | } while ((maxLength === undefined || pos < maxLength) && (null !== test.fn || "" !== test.def) || lvp > pos || isStatic); |
| 1122 | isStatic && setEntry(), document.activeElement === input && (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">'), |
| 1123 | maskTemplate.splice(caretPos.end + 1, 0, "</mark>")); |
| 1124 | } |
| 1125 | var template = colorMask.getElementsByTagName("div")[0]; |
| 1126 | template.innerHTML = maskTemplate.join(""), input.inputmask.positionColorMask(input, template); |
| 1127 | } |
| 1128 | } |
| 1129 | if (Inputmask.prototype.positionColorMask = function(input, template) { |
| 1130 | input.style.left = template.offsetLeft + "px"; |
| 1131 | }, actionObj !== undefined) switch (actionObj.action) { |
| 1132 | case "isComplete": |
| 1133 | return el = actionObj.el, isComplete(getBuffer()); |
| 1134 | |
| 1135 | case "unmaskedvalue": |
| 1136 | return el !== undefined && actionObj.value === undefined || (valueBuffer = actionObj.value, |
| 1137 | valueBuffer = ($.isFunction(opts.onBeforeMask) && opts.onBeforeMask.call(inputmask, valueBuffer, opts) || valueBuffer).split(""), |
| 1138 | checkVal.call(this, undefined, !1, !1, valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite.call(inputmask, undefined, getBuffer(), 0, opts)), |
| 1139 | unmaskedvalue(el); |
| 1140 | |
| 1141 | case "mask": |
| 1142 | !function(elem) { |
| 1143 | EventRuler.off(elem); |
| 1144 | var isSupported = function(input, opts) { |
| 1145 | var elementType = input.getAttribute("type"), isSupported = "INPUT" === input.tagName && -1 !== $.inArray(elementType, opts.supportsInputType) || input.isContentEditable || "TEXTAREA" === input.tagName; |
| 1146 | if (!isSupported) if ("INPUT" === input.tagName) { |
| 1147 | var el = document.createElement("input"); |
| 1148 | el.setAttribute("type", elementType), isSupported = "text" === el.type, el = null; |
| 1149 | } else isSupported = "partial"; |
| 1150 | return !1 !== isSupported ? function(npt) { |
| 1151 | var valueGet, valueSet; |
| 1152 | function getter() { |
| 1153 | return this.inputmask ? this.inputmask.opts.autoUnmask ? this.inputmask.unmaskedvalue() : -1 !== getLastValidPosition() || !0 !== opts.nullable ? document.activeElement === this && opts.clearMaskOnLostFocus ? (isRTL ? clearOptionalTail(getBuffer().slice()).reverse() : clearOptionalTail(getBuffer().slice())).join("") : valueGet.call(this) : "" : valueGet.call(this); |
| 1154 | } |
| 1155 | function setter(value) { |
| 1156 | valueSet.call(this, value), this.inputmask && $(this).trigger("setvalue", [ value ]); |
| 1157 | } |
| 1158 | if (!npt.inputmask.__valueGet) { |
| 1159 | if (!0 !== opts.noValuePatching) { |
| 1160 | if (Object.getOwnPropertyDescriptor) { |
| 1161 | "function" != typeof Object.getPrototypeOf && (Object.getPrototypeOf = "object" === _typeof("test".__proto__) ? function(object) { |
| 1162 | return object.__proto__; |
| 1163 | } : function(object) { |
| 1164 | return object.constructor.prototype; |
| 1165 | }); |
| 1166 | var valueProperty = Object.getPrototypeOf ? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(npt), "value") : undefined; |
| 1167 | valueProperty && valueProperty.get && valueProperty.set ? (valueGet = valueProperty.get, |
| 1168 | valueSet = valueProperty.set, Object.defineProperty(npt, "value", { |
| 1169 | get: getter, |
| 1170 | set: setter, |
| 1171 | configurable: !0 |
| 1172 | })) : "INPUT" !== npt.tagName && (valueGet = function() { |
| 1173 | return this.textContent; |
| 1174 | }, valueSet = function(value) { |
| 1175 | this.textContent = value; |
| 1176 | }, Object.defineProperty(npt, "value", { |
| 1177 | get: getter, |
| 1178 | set: setter, |
| 1179 | configurable: !0 |
| 1180 | })); |
| 1181 | } else document.__lookupGetter__ && npt.__lookupGetter__("value") && (valueGet = npt.__lookupGetter__("value"), |
| 1182 | valueSet = npt.__lookupSetter__("value"), npt.__defineGetter__("value", getter), |
| 1183 | npt.__defineSetter__("value", setter)); |
| 1184 | npt.inputmask.__valueGet = valueGet, npt.inputmask.__valueSet = valueSet; |
| 1185 | } |
| 1186 | npt.inputmask._valueGet = function(overruleRTL) { |
| 1187 | return isRTL && !0 !== overruleRTL ? valueGet.call(this.el).split("").reverse().join("") : valueGet.call(this.el); |
| 1188 | }, npt.inputmask._valueSet = function(value, overruleRTL) { |
| 1189 | valueSet.call(this.el, null === value || value === undefined ? "" : !0 !== overruleRTL && isRTL ? value.split("").reverse().join("") : value); |
| 1190 | }, valueGet === undefined && (valueGet = function() { |
| 1191 | return this.value; |
| 1192 | }, valueSet = function(value) { |
| 1193 | this.value = value; |
| 1194 | }, function(type) { |
| 1195 | if ($.valHooks && ($.valHooks[type] === undefined || !0 !== $.valHooks[type].inputmaskpatch)) { |
| 1196 | var valhookGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function(elem) { |
| 1197 | return elem.value; |
| 1198 | }, valhookSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function(elem, value) { |
| 1199 | return elem.value = value, elem; |
| 1200 | }; |
| 1201 | $.valHooks[type] = { |
| 1202 | get: function(elem) { |
| 1203 | if (elem.inputmask) { |
| 1204 | if (elem.inputmask.opts.autoUnmask) return elem.inputmask.unmaskedvalue(); |
| 1205 | var result = valhookGet(elem); |
| 1206 | return -1 !== getLastValidPosition(undefined, undefined, elem.inputmask.maskset.validPositions) || !0 !== opts.nullable ? result : ""; |
| 1207 | } |
| 1208 | return valhookGet(elem); |
| 1209 | }, |
| 1210 | set: function(elem, value) { |
| 1211 | var result, $elem = $(elem); |
| 1212 | return result = valhookSet(elem, value), elem.inputmask && $elem.trigger("setvalue", [ value ]), |
| 1213 | result; |
| 1214 | }, |
| 1215 | inputmaskpatch: !0 |
| 1216 | }; |
| 1217 | } |
| 1218 | }(npt.type), function(npt) { |
| 1219 | EventRuler.on(npt, "mouseenter", function(event) { |
| 1220 | var $input = $(this); |
| 1221 | this.inputmask._valueGet() !== getBuffer().join("") && $input.trigger("setvalue"); |
| 1222 | }); |
| 1223 | }(npt)); |
| 1224 | } |
| 1225 | }(input) : input.inputmask = undefined, isSupported; |
| 1226 | }(elem, opts); |
| 1227 | if (!1 !== isSupported && ($el = $(el = elem), -1 === (maxLength = el !== undefined ? el.maxLength : undefined) && (maxLength = undefined), |
| 1228 | !0 === opts.colorMask && initializeColorMask(el), mobile && ("inputmode" in el && (el.inputmode = opts.inputmode, |
| 1229 | el.setAttribute("inputmode", opts.inputmode)), !0 === opts.disablePredictiveText && ("autocorrect" in el ? el.autocorrect = !1 : (!0 !== opts.colorMask && initializeColorMask(el), |
| 1230 | el.type = "password"))), !0 === isSupported && (EventRuler.on(el, "submit", EventHandlers.submitEvent), |
| 1231 | EventRuler.on(el, "reset", EventHandlers.resetEvent), EventRuler.on(el, "blur", EventHandlers.blurEvent), |
| 1232 | EventRuler.on(el, "focus", EventHandlers.focusEvent), !0 !== opts.colorMask && (EventRuler.on(el, "click", EventHandlers.clickEvent), |
| 1233 | EventRuler.on(el, "mouseleave", EventHandlers.mouseleaveEvent), EventRuler.on(el, "mouseenter", EventHandlers.mouseenterEvent)), |
| 1234 | EventRuler.on(el, "dblclick", EventHandlers.dblclickEvent), EventRuler.on(el, "paste", EventHandlers.pasteEvent), |
| 1235 | EventRuler.on(el, "dragdrop", EventHandlers.pasteEvent), EventRuler.on(el, "drop", EventHandlers.pasteEvent), |
| 1236 | EventRuler.on(el, "cut", EventHandlers.cutEvent), EventRuler.on(el, "complete", opts.oncomplete), |
| 1237 | EventRuler.on(el, "incomplete", opts.onincomplete), EventRuler.on(el, "cleared", opts.oncleared), |
| 1238 | mobile || !0 === opts.inputEventOnly ? el.removeAttribute("maxLength") : (EventRuler.on(el, "keydown", EventHandlers.keydownEvent), |
| 1239 | EventRuler.on(el, "keypress", EventHandlers.keypressEvent)), EventRuler.on(el, "compositionstart", $.noop), |
| 1240 | EventRuler.on(el, "compositionupdate", $.noop), EventRuler.on(el, "compositionend", $.noop), |
| 1241 | EventRuler.on(el, "keyup", $.noop), EventRuler.on(el, "input", EventHandlers.inputFallBackEvent), |
| 1242 | EventRuler.on(el, "beforeinput", EventHandlers.beforeInputEvent)), EventRuler.on(el, "setvalue", EventHandlers.setValueEvent), |
| 1243 | undoValue = getBufferTemplate().join(""), "" !== el.inputmask._valueGet(!0) || !1 === opts.clearMaskOnLostFocus || document.activeElement === el)) { |
| 1244 | var initialValue = $.isFunction(opts.onBeforeMask) && opts.onBeforeMask.call(inputmask, el.inputmask._valueGet(!0), opts) || el.inputmask._valueGet(!0); |
| 1245 | "" !== initialValue && checkVal(el, !0, !1, initialValue.split("")); |
| 1246 | var buffer = getBuffer().slice(); |
| 1247 | undoValue = buffer.join(""), !1 === isComplete(buffer) && opts.clearIncomplete && resetMaskSet(), |
| 1248 | opts.clearMaskOnLostFocus && document.activeElement !== el && (-1 === getLastValidPosition() ? buffer = [] : clearOptionalTail(buffer)), |
| 1249 | (!1 === opts.clearMaskOnLostFocus || opts.showMaskOnFocus && document.activeElement === el || "" !== el.inputmask._valueGet(!0)) && writeBuffer(el, buffer), |
| 1250 | document.activeElement === el && caret(el, seekNext(getLastValidPosition())); |
| 1251 | } |
| 1252 | }(el); |
| 1253 | break; |
| 1254 | |
| 1255 | case "format": |
| 1256 | return valueBuffer = ($.isFunction(opts.onBeforeMask) && opts.onBeforeMask.call(inputmask, actionObj.value, opts) || actionObj.value).split(""), |
| 1257 | checkVal.call(this, undefined, !0, !1, valueBuffer), actionObj.metadata ? { |
| 1258 | value: isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join(""), |
| 1259 | metadata: maskScope.call(this, { |
| 1260 | action: "getmetadata" |
| 1261 | }, maskset, opts) |
| 1262 | } : isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join(""); |
| 1263 | |
| 1264 | case "isValid": |
| 1265 | actionObj.value ? (valueBuffer = actionObj.value.split(""), checkVal.call(this, undefined, !0, !0, valueBuffer)) : actionObj.value = getBuffer().join(""); |
| 1266 | for (var buffer = getBuffer(), rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ; |
| 1267 | return buffer.splice(rl, lmib + 1 - rl), isComplete(buffer) && actionObj.value === getBuffer().join(""); |
| 1268 | |
| 1269 | case "getemptymask": |
| 1270 | return getBufferTemplate().join(""); |
| 1271 | |
| 1272 | case "remove": |
| 1273 | if (el && el.inputmask) $.data(el, "_inputmask_opts", null), $el = $(el), el.inputmask._valueSet(opts.autoUnmask ? unmaskedvalue(el) : el.inputmask._valueGet(!0)), |
| 1274 | EventRuler.off(el), el.inputmask.colorMask && ((colorMask = el.inputmask.colorMask).removeChild(el), |
| 1275 | colorMask.parentNode.insertBefore(el, colorMask), colorMask.parentNode.removeChild(colorMask)), |
| 1276 | Object.getOwnPropertyDescriptor && Object.getPrototypeOf ? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(el), "value") && el.inputmask.__valueGet && Object.defineProperty(el, "value", { |
| 1277 | get: el.inputmask.__valueGet, |
| 1278 | set: el.inputmask.__valueSet, |
| 1279 | configurable: !0 |
| 1280 | }) : document.__lookupGetter__ && el.__lookupGetter__("value") && el.inputmask.__valueGet && (el.__defineGetter__("value", el.inputmask.__valueGet), |
| 1281 | el.__defineSetter__("value", el.inputmask.__valueSet)), el.inputmask = undefined; |
| 1282 | return el; |
| 1283 | |
| 1284 | case "getmetadata": |
| 1285 | if ($.isArray(maskset.metadata)) { |
| 1286 | var maskTarget = getMaskTemplate(!0, 0, !1).join(""); |
| 1287 | return $.each(maskset.metadata, function(ndx, mtdt) { |
| 1288 | if (mtdt.mask === maskTarget) return maskTarget = mtdt, !1; |
| 1289 | }), maskTarget; |
| 1290 | } |
| 1291 | return maskset.metadata; |
| 1292 | } |
| 1293 | } |
| 1294 | return Inputmask.prototype = { |
| 1295 | dataAttribute: "data-inputmask", |
| 1296 | defaults: { |
| 1297 | placeholder: "_", |
| 1298 | optionalmarker: [ "[", "]" ], |
| 1299 | quantifiermarker: [ "{", "}" ], |
| 1300 | groupmarker: [ "(", ")" ], |
| 1301 | alternatormarker: "|", |
| 1302 | escapeChar: "\\", |
| 1303 | mask: null, |
| 1304 | regex: null, |
| 1305 | oncomplete: $.noop, |
| 1306 | onincomplete: $.noop, |
| 1307 | oncleared: $.noop, |
| 1308 | repeat: 0, |
| 1309 | greedy: !1, |
| 1310 | autoUnmask: !1, |
| 1311 | removeMaskOnSubmit: !1, |
| 1312 | clearMaskOnLostFocus: !0, |
| 1313 | insertMode: !0, |
| 1314 | clearIncomplete: !1, |
| 1315 | alias: null, |
| 1316 | onKeyDown: $.noop, |
| 1317 | onBeforeMask: null, |
| 1318 | onBeforePaste: function(pastedValue, opts) { |
| 1319 | return $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(this, pastedValue, opts) : pastedValue; |
| 1320 | }, |
| 1321 | onBeforeWrite: null, |
| 1322 | onUnMask: null, |
| 1323 | showMaskOnFocus: !0, |
| 1324 | showMaskOnHover: !0, |
| 1325 | onKeyValidation: $.noop, |
| 1326 | skipOptionalPartCharacter: " ", |
| 1327 | numericInput: !1, |
| 1328 | rightAlign: !1, |
| 1329 | undoOnEscape: !0, |
| 1330 | radixPoint: "", |
| 1331 | _radixDance: !1, |
| 1332 | groupSeparator: "", |
| 1333 | keepStatic: null, |
| 1334 | positionCaretOnTab: !0, |
| 1335 | tabThrough: !1, |
| 1336 | supportsInputType: [ "text", "tel", "password", "search" ], |
| 1337 | 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 ], |
| 1338 | isComplete: null, |
| 1339 | preValidation: null, |
| 1340 | postValidation: null, |
| 1341 | staticDefinitionSymbol: undefined, |
| 1342 | jitMasking: !1, |
| 1343 | nullable: !0, |
| 1344 | inputEventOnly: !1, |
| 1345 | noValuePatching: !1, |
| 1346 | positionCaretOnClick: "lvp", |
| 1347 | casing: null, |
| 1348 | inputmode: "verbatim", |
| 1349 | colorMask: !1, |
| 1350 | disablePredictiveText: !1, |
| 1351 | importDataAttributes: !0 |
| 1352 | }, |
| 1353 | definitions: { |
| 1354 | 9: { |
| 1355 | validator: "[0-91-9]", |
| 1356 | definitionSymbol: "*" |
| 1357 | }, |
| 1358 | a: { |
| 1359 | validator: "[A-Za-zА-яЁёÀ-ÿµ]", |
| 1360 | definitionSymbol: "*" |
| 1361 | }, |
| 1362 | "*": { |
| 1363 | validator: "[0-91-9A-Za-zА-яЁёÀ-ÿµ]" |
| 1364 | } |
| 1365 | }, |
| 1366 | aliases: {}, |
| 1367 | masksCache: {}, |
| 1368 | mask: function(elems) { |
| 1369 | var that = this; |
| 1370 | return "string" == typeof elems && (elems = document.getElementById(elems) || document.querySelectorAll(elems)), |
| 1371 | elems = elems.nodeName ? [ elems ] : elems, $.each(elems, function(ndx, el) { |
| 1372 | var scopedOpts = $.extend(!0, {}, that.opts); |
| 1373 | if (function(npt, opts, userOptions, dataAttribute) { |
| 1374 | if (!0 === opts.importDataAttributes) { |
| 1375 | var option, dataoptions, optionData, p, importOption = function(option, optionData) { |
| 1376 | null !== (optionData = optionData !== undefined ? optionData : npt.getAttribute(dataAttribute + "-" + option)) && ("string" == typeof optionData && (0 === option.indexOf("on") ? optionData = window[optionData] : "false" === optionData ? optionData = !1 : "true" === optionData && (optionData = !0)), |
| 1377 | userOptions[option] = optionData); |
| 1378 | }, attrOptions = npt.getAttribute(dataAttribute); |
| 1379 | if (attrOptions && "" !== attrOptions && (attrOptions = attrOptions.replace(/'/g, '"'), |
| 1380 | dataoptions = JSON.parse("{" + attrOptions + "}")), dataoptions) for (p in optionData = undefined, |
| 1381 | dataoptions) if ("alias" === p.toLowerCase()) { |
| 1382 | optionData = dataoptions[p]; |
| 1383 | break; |
| 1384 | } |
| 1385 | for (option in importOption("alias", optionData), userOptions.alias && resolveAlias(userOptions.alias, userOptions, opts), |
| 1386 | opts) { |
| 1387 | if (dataoptions) for (p in optionData = undefined, dataoptions) if (p.toLowerCase() === option.toLowerCase()) { |
| 1388 | optionData = dataoptions[p]; |
| 1389 | break; |
| 1390 | } |
| 1391 | importOption(option, optionData); |
| 1392 | } |
| 1393 | } |
| 1394 | return $.extend(!0, opts, userOptions), ("rtl" === npt.dir || opts.rightAlign) && (npt.style.textAlign = "right"), |
| 1395 | ("rtl" === npt.dir || opts.numericInput) && (npt.dir = "ltr", npt.removeAttribute("dir"), |
| 1396 | opts.isRTL = !0), Object.keys(userOptions).length; |
| 1397 | }(el, scopedOpts, $.extend(!0, {}, that.userOptions), that.dataAttribute)) { |
| 1398 | var maskset = generateMaskSet(scopedOpts, that.noMasksCache); |
| 1399 | maskset !== undefined && (el.inputmask !== undefined && (el.inputmask.opts.autoUnmask = !0, |
| 1400 | el.inputmask.remove()), el.inputmask = new Inputmask(undefined, undefined, !0), |
| 1401 | el.inputmask.opts = scopedOpts, el.inputmask.noMasksCache = that.noMasksCache, el.inputmask.userOptions = $.extend(!0, {}, that.userOptions), |
| 1402 | el.inputmask.isRTL = scopedOpts.isRTL || scopedOpts.numericInput, el.inputmask.el = el, |
| 1403 | el.inputmask.maskset = maskset, $.data(el, "_inputmask_opts", scopedOpts), maskScope.call(el.inputmask, { |
| 1404 | action: "mask" |
| 1405 | })); |
| 1406 | } |
| 1407 | }), elems && elems[0] && elems[0].inputmask || this; |
| 1408 | }, |
| 1409 | option: function(options, noremask) { |
| 1410 | return "string" == typeof options ? this.opts[options] : "object" === (void 0 === options ? "undefined" : _typeof(options)) ? ($.extend(this.userOptions, options), |
| 1411 | this.el && !0 !== noremask && this.mask(this.el), this) : void 0; |
| 1412 | }, |
| 1413 | unmaskedvalue: function(value) { |
| 1414 | return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache), |
| 1415 | maskScope.call(this, { |
| 1416 | action: "unmaskedvalue", |
| 1417 | value: value |
| 1418 | }); |
| 1419 | }, |
| 1420 | remove: function() { |
| 1421 | return maskScope.call(this, { |
| 1422 | action: "remove" |
| 1423 | }); |
| 1424 | }, |
| 1425 | getemptymask: function() { |
| 1426 | return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache), |
| 1427 | maskScope.call(this, { |
| 1428 | action: "getemptymask" |
| 1429 | }); |
| 1430 | }, |
| 1431 | hasMaskedValue: function() { |
| 1432 | return !this.opts.autoUnmask; |
| 1433 | }, |
| 1434 | isComplete: function() { |
| 1435 | return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache), |
| 1436 | maskScope.call(this, { |
| 1437 | action: "isComplete" |
| 1438 | }); |
| 1439 | }, |
| 1440 | getmetadata: function() { |
| 1441 | return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache), |
| 1442 | maskScope.call(this, { |
| 1443 | action: "getmetadata" |
| 1444 | }); |
| 1445 | }, |
| 1446 | isValid: function(value) { |
| 1447 | return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache), |
| 1448 | maskScope.call(this, { |
| 1449 | action: "isValid", |
| 1450 | value: value |
| 1451 | }); |
| 1452 | }, |
| 1453 | format: function(value, metadata) { |
| 1454 | return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache), |
| 1455 | maskScope.call(this, { |
| 1456 | action: "format", |
| 1457 | value: value, |
| 1458 | metadata: metadata |
| 1459 | }); |
| 1460 | }, |
| 1461 | setValue: function(value) { |
| 1462 | this.el && $(this.el).trigger("setvalue", [ value ]); |
| 1463 | }, |
| 1464 | analyseMask: function(mask, regexMask, opts) { |
| 1465 | var match, m, openingToken, currentOpeningToken, alternator, lastMatch, 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 = !1, currentToken = new MaskToken(), openenings = [], maskTokens = []; |
| 1466 | function MaskToken(isGroup, isOptional, isQuantifier, isAlternator) { |
| 1467 | this.matches = [], this.openGroup = isGroup || !1, this.alternatorGroup = !1, this.isGroup = isGroup || !1, |
| 1468 | this.isOptional = isOptional || !1, this.isQuantifier = isQuantifier || !1, this.isAlternator = isAlternator || !1, |
| 1469 | this.quantifier = { |
| 1470 | min: 1, |
| 1471 | max: 1 |
| 1472 | }; |
| 1473 | } |
| 1474 | function insertTestDefinition(mtoken, element, position) { |
| 1475 | position = position !== undefined ? position : mtoken.matches.length; |
| 1476 | var prevMatch = mtoken.matches[position - 1]; |
| 1477 | if (regexMask) 0 === element.indexOf("[") || escaped && /\\d|\\s|\\w]/i.test(element) || "." === element ? mtoken.matches.splice(position++, 0, { |
| 1478 | fn: new RegExp(element, opts.casing ? "i" : ""), |
| 1479 | optionality: !1, |
| 1480 | newBlockMarker: prevMatch === undefined ? "master" : prevMatch.def !== element, |
| 1481 | casing: null, |
| 1482 | def: element, |
| 1483 | placeholder: undefined, |
| 1484 | nativeDef: element |
| 1485 | }) : (escaped && (element = element[element.length - 1]), $.each(element.split(""), function(ndx, lmnt) { |
| 1486 | prevMatch = mtoken.matches[position - 1], mtoken.matches.splice(position++, 0, { |
| 1487 | fn: null, |
| 1488 | optionality: !1, |
| 1489 | newBlockMarker: prevMatch === undefined ? "master" : prevMatch.def !== lmnt && null !== prevMatch.fn, |
| 1490 | casing: null, |
| 1491 | def: opts.staticDefinitionSymbol || lmnt, |
| 1492 | placeholder: opts.staticDefinitionSymbol !== undefined ? lmnt : undefined, |
| 1493 | nativeDef: (escaped ? "'" : "") + lmnt |
| 1494 | }); |
| 1495 | })), escaped = !1; else { |
| 1496 | var maskdef = (opts.definitions ? opts.definitions[element] : undefined) || Inputmask.prototype.definitions[element]; |
| 1497 | maskdef && !escaped ? mtoken.matches.splice(position++, 0, { |
| 1498 | fn: maskdef.validator ? "string" == typeof maskdef.validator ? new RegExp(maskdef.validator, opts.casing ? "i" : "") : new function() { |
| 1499 | this.test = maskdef.validator; |
| 1500 | }() : new RegExp("."), |
| 1501 | optionality: !1, |
| 1502 | newBlockMarker: prevMatch === undefined ? "master" : prevMatch.def !== (maskdef.definitionSymbol || element), |
| 1503 | casing: maskdef.casing, |
| 1504 | def: maskdef.definitionSymbol || element, |
| 1505 | placeholder: maskdef.placeholder, |
| 1506 | nativeDef: element |
| 1507 | }) : (mtoken.matches.splice(position++, 0, { |
| 1508 | fn: null, |
| 1509 | optionality: !1, |
| 1510 | newBlockMarker: prevMatch === undefined ? "master" : prevMatch.def !== element && null !== prevMatch.fn, |
| 1511 | casing: null, |
| 1512 | def: opts.staticDefinitionSymbol || element, |
| 1513 | placeholder: opts.staticDefinitionSymbol !== undefined ? element : undefined, |
| 1514 | nativeDef: (escaped ? "'" : "") + element |
| 1515 | }), escaped = !1); |
| 1516 | } |
| 1517 | } |
| 1518 | function defaultCase() { |
| 1519 | if (openenings.length > 0) { |
| 1520 | if (insertTestDefinition(currentOpeningToken = openenings[openenings.length - 1], m), |
| 1521 | currentOpeningToken.isAlternator) { |
| 1522 | alternator = openenings.pop(); |
| 1523 | for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup && (alternator.matches[mndx].isGroup = !1); |
| 1524 | openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1]).matches.push(alternator) : currentToken.matches.push(alternator); |
| 1525 | } |
| 1526 | } else insertTestDefinition(currentToken, m); |
| 1527 | } |
| 1528 | function groupify(matches) { |
| 1529 | var groupToken = new MaskToken(!0); |
| 1530 | return groupToken.openGroup = !1, groupToken.matches = matches, groupToken; |
| 1531 | } |
| 1532 | for (regexMask && (opts.optionalmarker[0] = undefined, opts.optionalmarker[1] = undefined); match = regexMask ? regexTokenizer.exec(mask) : tokenizer.exec(mask); ) { |
| 1533 | if (m = match[0], regexMask) switch (m.charAt(0)) { |
| 1534 | case "?": |
| 1535 | m = "{0,1}"; |
| 1536 | break; |
| 1537 | |
| 1538 | case "+": |
| 1539 | case "*": |
| 1540 | m = "{" + m + "}"; |
| 1541 | } |
| 1542 | if (escaped) defaultCase(); else switch (m.charAt(0)) { |
| 1543 | case "(?=": |
| 1544 | case "(?!": |
| 1545 | case "(?<=": |
| 1546 | case "(?<!": |
| 1547 | break; |
| 1548 | |
| 1549 | case opts.escapeChar: |
| 1550 | escaped = !0, regexMask && defaultCase(); |
| 1551 | break; |
| 1552 | |
| 1553 | case opts.optionalmarker[1]: |
| 1554 | case opts.groupmarker[1]: |
| 1555 | if ((openingToken = openenings.pop()).openGroup = !1, openingToken !== undefined) if (openenings.length > 0) { |
| 1556 | if ((currentOpeningToken = openenings[openenings.length - 1]).matches.push(openingToken), |
| 1557 | currentOpeningToken.isAlternator) { |
| 1558 | alternator = openenings.pop(); |
| 1559 | for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1, |
| 1560 | alternator.matches[mndx].alternatorGroup = !1; |
| 1561 | openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1]).matches.push(alternator) : currentToken.matches.push(alternator); |
| 1562 | } |
| 1563 | } else currentToken.matches.push(openingToken); else defaultCase(); |
| 1564 | break; |
| 1565 | |
| 1566 | case opts.optionalmarker[0]: |
| 1567 | openenings.push(new MaskToken(!1, !0)); |
| 1568 | break; |
| 1569 | |
| 1570 | case opts.groupmarker[0]: |
| 1571 | openenings.push(new MaskToken(!0)); |
| 1572 | break; |
| 1573 | |
| 1574 | case opts.quantifiermarker[0]: |
| 1575 | var quantifier = new MaskToken(!1, !1, !0), mqj = (m = m.replace(/[{}]/g, "")).split("|"), mq = mqj[0].split(","), mq0 = isNaN(mq[0]) ? mq[0] : parseInt(mq[0]), mq1 = 1 === mq.length ? mq0 : isNaN(mq[1]) ? mq[1] : parseInt(mq[1]); |
| 1576 | "*" !== mq0 && "+" !== mq0 || (mq0 = "*" === mq1 ? 0 : 1), quantifier.quantifier = { |
| 1577 | min: mq0, |
| 1578 | max: mq1, |
| 1579 | jit: mqj[1] |
| 1580 | }; |
| 1581 | var matches = openenings.length > 0 ? openenings[openenings.length - 1].matches : currentToken.matches; |
| 1582 | if ((match = matches.pop()).isAlternator) { |
| 1583 | matches.push(match), matches = match.matches; |
| 1584 | var groupToken = new MaskToken(!0), tmpMatch = matches.pop(); |
| 1585 | matches.push(groupToken), matches = groupToken.matches, match = tmpMatch; |
| 1586 | } |
| 1587 | match.isGroup || (match = groupify([ match ])), matches.push(match), matches.push(quantifier); |
| 1588 | break; |
| 1589 | |
| 1590 | case opts.alternatormarker: |
| 1591 | var groupQuantifier = function(matches) { |
| 1592 | var lastMatch = matches.pop(); |
| 1593 | return lastMatch.isQuantifier && (lastMatch = groupify([ matches.pop(), lastMatch ])), |
| 1594 | lastMatch; |
| 1595 | }; |
| 1596 | if (openenings.length > 0) { |
| 1597 | var subToken = (currentOpeningToken = openenings[openenings.length - 1]).matches[currentOpeningToken.matches.length - 1]; |
| 1598 | lastMatch = currentOpeningToken.openGroup && (subToken.matches === undefined || !1 === subToken.isGroup && !1 === subToken.isAlternator) ? openenings.pop() : groupQuantifier(currentOpeningToken.matches); |
| 1599 | } else lastMatch = groupQuantifier(currentToken.matches); |
| 1600 | if (lastMatch.isAlternator) openenings.push(lastMatch); else if (lastMatch.alternatorGroup ? (alternator = openenings.pop(), |
| 1601 | lastMatch.alternatorGroup = !1) : alternator = new MaskToken(!1, !1, !1, !0), alternator.matches.push(lastMatch), |
| 1602 | openenings.push(alternator), lastMatch.openGroup) { |
| 1603 | lastMatch.openGroup = !1; |
| 1604 | var alternatorGroup = new MaskToken(!0); |
| 1605 | alternatorGroup.alternatorGroup = !0, openenings.push(alternatorGroup); |
| 1606 | } |
| 1607 | break; |
| 1608 | |
| 1609 | default: |
| 1610 | defaultCase(); |
| 1611 | } |
| 1612 | } |
| 1613 | for (;openenings.length > 0; ) openingToken = openenings.pop(), currentToken.matches.push(openingToken); |
| 1614 | return currentToken.matches.length > 0 && (!function verifyGroupMarker(maskToken) { |
| 1615 | maskToken && maskToken.matches && $.each(maskToken.matches, function(ndx, token) { |
| 1616 | var nextToken = maskToken.matches[ndx + 1]; |
| 1617 | (nextToken === undefined || nextToken.matches === undefined || !1 === nextToken.isQuantifier) && token && token.isGroup && (token.isGroup = !1, |
| 1618 | regexMask || (insertTestDefinition(token, opts.groupmarker[0], 0), !0 !== token.openGroup && insertTestDefinition(token, opts.groupmarker[1]))), |
| 1619 | verifyGroupMarker(token); |
| 1620 | }); |
| 1621 | }(currentToken), maskTokens.push(currentToken)), (opts.numericInput || opts.isRTL) && function reverseTokens(maskToken) { |
| 1622 | for (var match in maskToken.matches = maskToken.matches.reverse(), maskToken.matches) if (maskToken.matches.hasOwnProperty(match)) { |
| 1623 | var intMatch = parseInt(match); |
| 1624 | if (maskToken.matches[match].isQuantifier && maskToken.matches[intMatch + 1] && maskToken.matches[intMatch + 1].isGroup) { |
| 1625 | var qt = maskToken.matches[match]; |
| 1626 | maskToken.matches.splice(match, 1), maskToken.matches.splice(intMatch + 1, 0, qt); |
| 1627 | } |
| 1628 | maskToken.matches[match].matches !== undefined ? maskToken.matches[match] = reverseTokens(maskToken.matches[match]) : maskToken.matches[match] = ((st = maskToken.matches[match]) === opts.optionalmarker[0] ? st = opts.optionalmarker[1] : st === opts.optionalmarker[1] ? st = opts.optionalmarker[0] : st === opts.groupmarker[0] ? st = opts.groupmarker[1] : st === opts.groupmarker[1] && (st = opts.groupmarker[0]), |
| 1629 | st); |
| 1630 | } |
| 1631 | var st; |
| 1632 | return maskToken; |
| 1633 | }(maskTokens[0]), maskTokens; |
| 1634 | } |
| 1635 | }, Inputmask.extendDefaults = function(options) { |
| 1636 | $.extend(!0, Inputmask.prototype.defaults, options); |
| 1637 | }, Inputmask.extendDefinitions = function(definition) { |
| 1638 | $.extend(!0, Inputmask.prototype.definitions, definition); |
| 1639 | }, Inputmask.extendAliases = function(alias) { |
| 1640 | $.extend(!0, Inputmask.prototype.aliases, alias); |
| 1641 | }, Inputmask.format = function(value, options, metadata) { |
| 1642 | return Inputmask(options).format(value, metadata); |
| 1643 | }, Inputmask.unmask = function(value, options) { |
| 1644 | return Inputmask(options).unmaskedvalue(value); |
| 1645 | }, Inputmask.isValid = function(value, options) { |
| 1646 | return Inputmask(options).isValid(value); |
| 1647 | }, Inputmask.remove = function(elems) { |
| 1648 | "string" == typeof elems && (elems = document.getElementById(elems) || document.querySelectorAll(elems)), |
| 1649 | elems = elems.nodeName ? [ elems ] : elems, $.each(elems, function(ndx, el) { |
| 1650 | el.inputmask && el.inputmask.remove(); |
| 1651 | }); |
| 1652 | }, Inputmask.setValue = function(elems, value) { |
| 1653 | "string" == typeof elems && (elems = document.getElementById(elems) || document.querySelectorAll(elems)), |
| 1654 | elems = elems.nodeName ? [ elems ] : elems, $.each(elems, function(ndx, el) { |
| 1655 | el.inputmask ? el.inputmask.setValue(value) : $(el).trigger("setvalue", [ value ]); |
| 1656 | }); |
| 1657 | }, Inputmask.escapeRegex = function(str) { |
| 1658 | return str.replace(new RegExp("(\\" + [ "/", ".", "*", "+", "?", "|", "(", ")", "[", "]", "{", "}", "\\", "$", "^" ].join("|\\") + ")", "gim"), "\\$1"); |
| 1659 | }, Inputmask.keyCode = { |
| 1660 | BACKSPACE: 8, |
| 1661 | BACKSPACE_SAFARI: 127, |
| 1662 | DELETE: 46, |
| 1663 | DOWN: 40, |
| 1664 | END: 35, |
| 1665 | ENTER: 13, |
| 1666 | ESCAPE: 27, |
| 1667 | HOME: 36, |
| 1668 | INSERT: 45, |
| 1669 | LEFT: 37, |
| 1670 | PAGE_DOWN: 34, |
| 1671 | PAGE_UP: 33, |
| 1672 | RIGHT: 39, |
| 1673 | SPACE: 32, |
| 1674 | TAB: 9, |
| 1675 | UP: 38, |
| 1676 | X: 88, |
| 1677 | CONTROL: 17 |
| 1678 | }, Inputmask; |
| 1679 | }, __WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(0), __webpack_require__(5), __webpack_require__(6) ], |
| 1680 | void 0 === (__WEBPACK_AMD_DEFINE_RESULT__ = "function" == typeof (__WEBPACK_AMD_DEFINE_FACTORY__ = factory) ? __WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__) : __WEBPACK_AMD_DEFINE_FACTORY__) || (module.exports = __WEBPACK_AMD_DEFINE_RESULT__); |
| 1681 | }, function(module, exports) { |
| 1682 | module.exports = jQuery; |
| 1683 | }, function(module, exports, __webpack_require__) { |
| 1684 | "use strict"; |
| 1685 | __webpack_require__(4), __webpack_require__(7), __webpack_require__(8), __webpack_require__(9); |
| 1686 | var _inputmask2 = _interopRequireDefault(__webpack_require__(1)), _inputmask4 = _interopRequireDefault(__webpack_require__(0)), _jquery2 = _interopRequireDefault(__webpack_require__(2)); |
| 1687 | function _interopRequireDefault(obj) { |
| 1688 | return obj && obj.__esModule ? obj : { |
| 1689 | default: obj |
| 1690 | }; |
| 1691 | } |
| 1692 | _inputmask4.default === _jquery2.default && __webpack_require__(10), window.Inputmask = _inputmask2.default; |
| 1693 | }, function(module, exports, __webpack_require__) { |
| 1694 | "use strict"; |
| 1695 | var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__, factory; |
| 1696 | "function" == typeof Symbol && Symbol.iterator; |
| 1697 | factory = function($, Inputmask) { |
| 1698 | var formatCode = { |
| 1699 | d: [ "[1-9]|[12][0-9]|3[01]", Date.prototype.setDate, "day", Date.prototype.getDate ], |
| 1700 | dd: [ "0[1-9]|[12][0-9]|3[01]", Date.prototype.setDate, "day", function() { |
| 1701 | return pad(Date.prototype.getDate.call(this), 2); |
| 1702 | } ], |
| 1703 | ddd: [ "" ], |
| 1704 | dddd: [ "" ], |
| 1705 | m: [ "[1-9]|1[012]", Date.prototype.setMonth, "month", function() { |
| 1706 | return Date.prototype.getMonth.call(this) + 1; |
| 1707 | } ], |
| 1708 | mm: [ "0[1-9]|1[012]", Date.prototype.setMonth, "month", function() { |
| 1709 | return pad(Date.prototype.getMonth.call(this) + 1, 2); |
| 1710 | } ], |
| 1711 | mmm: [ "" ], |
| 1712 | mmmm: [ "" ], |
| 1713 | yy: [ "[0-9]{2}", Date.prototype.setFullYear, "year", function() { |
| 1714 | return pad(Date.prototype.getFullYear.call(this), 2); |
| 1715 | } ], |
| 1716 | yyyy: [ "[0-9]{4}", Date.prototype.setFullYear, "year", function() { |
| 1717 | return pad(Date.prototype.getFullYear.call(this), 4); |
| 1718 | } ], |
| 1719 | h: [ "[1-9]|1[0-2]", Date.prototype.setHours, "hours", Date.prototype.getHours ], |
| 1720 | hh: [ "0[1-9]|1[0-2]", Date.prototype.setHours, "hours", function() { |
| 1721 | return pad(Date.prototype.getHours.call(this), 2); |
| 1722 | } ], |
| 1723 | hhh: [ "[0-9]+", Date.prototype.setHours, "hours", Date.prototype.getHours ], |
| 1724 | H: [ "1?[0-9]|2[0-3]", Date.prototype.setHours, "hours", Date.prototype.getHours ], |
| 1725 | HH: [ "[01][0-9]|2[0-3]", Date.prototype.setHours, "hours", function() { |
| 1726 | return pad(Date.prototype.getHours.call(this), 2); |
| 1727 | } ], |
| 1728 | HHH: [ "[0-9]+", Date.prototype.setHours, "hours", Date.prototype.getHours ], |
| 1729 | M: [ "[1-5]?[0-9]", Date.prototype.setMinutes, "minutes", Date.prototype.getMinutes ], |
| 1730 | MM: [ "[0-5][0-9]", Date.prototype.setMinutes, "minutes", function() { |
| 1731 | return pad(Date.prototype.getMinutes.call(this), 2); |
| 1732 | } ], |
| 1733 | s: [ "[1-5]?[0-9]", Date.prototype.setSeconds, "seconds", Date.prototype.getSeconds ], |
| 1734 | ss: [ "[0-5][0-9]", Date.prototype.setSeconds, "seconds", function() { |
| 1735 | return pad(Date.prototype.getSeconds.call(this), 2); |
| 1736 | } ], |
| 1737 | l: [ "[0-9]{3}", Date.prototype.setMilliseconds, "milliseconds", function() { |
| 1738 | return pad(Date.prototype.getMilliseconds.call(this), 3); |
| 1739 | } ], |
| 1740 | L: [ "[0-9]{2}", Date.prototype.setMilliseconds, "milliseconds", function() { |
| 1741 | return pad(Date.prototype.getMilliseconds.call(this), 2); |
| 1742 | } ], |
| 1743 | t: [ "[ap]" ], |
| 1744 | tt: [ "[ap]m" ], |
| 1745 | T: [ "[AP]" ], |
| 1746 | TT: [ "[AP]M" ], |
| 1747 | Z: [ "" ], |
| 1748 | o: [ "" ], |
| 1749 | S: [ "" ] |
| 1750 | }, formatAlias = { |
| 1751 | isoDate: "yyyy-mm-dd", |
| 1752 | isoTime: "HH:MM:ss", |
| 1753 | isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", |
| 1754 | isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" |
| 1755 | }; |
| 1756 | function getTokenizer(opts) { |
| 1757 | if (!opts.tokenizer) { |
| 1758 | var tokens = []; |
| 1759 | for (var ndx in formatCode) -1 === tokens.indexOf(ndx[0]) && tokens.push(ndx[0]); |
| 1760 | opts.tokenizer = "(" + tokens.join("+|") + ")+?|.", opts.tokenizer = new RegExp(opts.tokenizer, "g"); |
| 1761 | } |
| 1762 | return opts.tokenizer; |
| 1763 | } |
| 1764 | function parse(format, dateObjValue, opts) { |
| 1765 | for (var match, mask = ""; match = getTokenizer(opts).exec(format); ) { |
| 1766 | if (void 0 === dateObjValue) if (formatCode[match[0]]) mask += "(" + formatCode[match[0]][0] + ")"; else switch (match[0]) { |
| 1767 | case "[": |
| 1768 | mask += "("; |
| 1769 | break; |
| 1770 | |
| 1771 | case "]": |
| 1772 | mask += ")?"; |
| 1773 | break; |
| 1774 | |
| 1775 | default: |
| 1776 | mask += Inputmask.escapeRegex(match[0]); |
| 1777 | } else if (formatCode[match[0]]) mask += formatCode[match[0]][3].call(dateObjValue.date); else mask += match[0]; |
| 1778 | } |
| 1779 | return mask; |
| 1780 | } |
| 1781 | function pad(val, len) { |
| 1782 | for (val = String(val), len = len || 2; val.length < len; ) val = "0" + val; |
| 1783 | return val; |
| 1784 | } |
| 1785 | function analyseMask(maskString, format, opts) { |
| 1786 | var targetProp, match, dateOperation, dateObj = { |
| 1787 | date: new Date(1, 0, 1) |
| 1788 | }, mask = maskString; |
| 1789 | function extendYear(year) { |
| 1790 | var correctedyear = 4 === year.length ? year : new Date().getFullYear().toString().substr(0, 4 - year.length) + year; |
| 1791 | return opts.min && opts.min.year && opts.max && opts.max.year ? (correctedyear = correctedyear.replace(/[^0-9]/g, ""), |
| 1792 | correctedyear += opts.min.year == opts.max.year ? opts.min.year.substr(correctedyear.length) : ("" !== correctedyear && 0 == opts.max.year.indexOf(correctedyear) ? parseInt(opts.max.year) - 1 : parseInt(opts.min.year) + 1).toString().substr(correctedyear.length)) : correctedyear = correctedyear.replace(/[^0-9]/g, "0"), |
| 1793 | correctedyear; |
| 1794 | } |
| 1795 | function setValue(dateObj, value, opts) { |
| 1796 | "year" === targetProp ? (dateObj[targetProp] = extendYear(value), dateObj["raw" + targetProp] = value) : dateObj[targetProp] = opts.min && value.match(/[^0-9]/) ? opts.min[targetProp] : value, |
| 1797 | void 0 !== dateOperation && dateOperation.call(dateObj.date, "month" == targetProp ? parseInt(dateObj[targetProp]) - 1 : dateObj[targetProp]); |
| 1798 | } |
| 1799 | if ("string" == typeof mask) { |
| 1800 | for (;match = getTokenizer(opts).exec(format); ) { |
| 1801 | var value = mask.slice(0, match[0].length); |
| 1802 | formatCode.hasOwnProperty(match[0]) && (targetProp = formatCode[match[0]][2], dateOperation = formatCode[match[0]][1], |
| 1803 | setValue(dateObj, value, opts)), mask = mask.slice(value.length); |
| 1804 | } |
| 1805 | return dateObj; |
| 1806 | } |
| 1807 | } |
| 1808 | return Inputmask.extendAliases({ |
| 1809 | datetime: { |
| 1810 | mask: function(opts) { |
| 1811 | return formatCode.S = opts.i18n.ordinalSuffix.join("|"), opts.inputFormat = formatAlias[opts.inputFormat] || opts.inputFormat, |
| 1812 | opts.displayFormat = formatAlias[opts.displayFormat] || opts.displayFormat || opts.inputFormat, |
| 1813 | opts.outputFormat = formatAlias[opts.outputFormat] || opts.outputFormat || opts.inputFormat, |
| 1814 | opts.placeholder = "" !== opts.placeholder ? opts.placeholder : opts.inputFormat.replace(/[\[\]]/, ""), |
| 1815 | opts.min = analyseMask(opts.min, opts.inputFormat, opts), opts.max = analyseMask(opts.max, opts.inputFormat, opts), |
| 1816 | opts.regex = parse(opts.inputFormat, void 0, opts), null; |
| 1817 | }, |
| 1818 | placeholder: "", |
| 1819 | inputFormat: "isoDateTime", |
| 1820 | displayFormat: void 0, |
| 1821 | outputFormat: void 0, |
| 1822 | min: null, |
| 1823 | max: null, |
| 1824 | i18n: { |
| 1825 | dayNames: [ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ], |
| 1826 | monthNames: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], |
| 1827 | ordinalSuffix: [ "st", "nd", "rd", "th" ] |
| 1828 | }, |
| 1829 | postValidation: function(buffer, currentResult, opts) { |
| 1830 | var result = currentResult, dateParts = analyseMask(buffer.join(""), opts.inputFormat, opts); |
| 1831 | return result && dateParts.date.getTime() == dateParts.date.getTime() && (result = (result = function(dateParts, currentResult) { |
| 1832 | return (!isFinite(dateParts.day) || "29" == dateParts.day && !isFinite(dateParts.rawyear) || new Date(dateParts.date.getFullYear(), isFinite(dateParts.month) ? dateParts.month : dateParts.date.getMonth() + 1, 0).getDate() >= dateParts.day) && currentResult; |
| 1833 | }(dateParts, result)) && function(dateParts, opts) { |
| 1834 | var result = !0; |
| 1835 | return opts.min && opts.min.date.getTime() == opts.min.date.getTime() && (result = opts.min.date.getTime() <= dateParts.date.getTime()), |
| 1836 | result && opts.max && opts.max.date.getTime() == opts.max.date.getTime() && (result = opts.max.date.getTime() >= dateParts.date.getTime()), |
| 1837 | result; |
| 1838 | }(dateParts, opts)), result; |
| 1839 | }, |
| 1840 | onKeyDown: function(e, buffer, caretPos, opts) { |
| 1841 | if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) { |
| 1842 | for (var match, today = new Date(), date = ""; match = getTokenizer(opts).exec(opts.inputFormat); ) "d" === match[0].charAt(0) ? date += pad(today.getDate(), match[0].length) : "m" === match[0].charAt(0) ? date += pad(today.getMonth() + 1, match[0].length) : "yyyy" === match[0] ? date += today.getFullYear().toString() : "y" === match[0].charAt(0) && (date += pad(today.getYear(), match[0].length)); |
| 1843 | this.inputmask._valueSet(date), $(this).trigger("setvalue"); |
| 1844 | } |
| 1845 | }, |
| 1846 | onUnMask: function(maskedValue, unmaskedValue, opts) { |
| 1847 | return parse(opts.outputFormat, analyseMask(maskedValue, opts.inputFormat, opts), opts); |
| 1848 | }, |
| 1849 | casing: function(elem, test, pos, validPositions) { |
| 1850 | return 0 == test.nativeDef.indexOf("[ap]") ? elem.toLowerCase() : 0 == test.nativeDef.indexOf("[AP]") ? elem.toUpperCase() : elem; |
| 1851 | }, |
| 1852 | insertMode: !1 |
| 1853 | } |
| 1854 | }), Inputmask; |
| 1855 | }, __WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(0), __webpack_require__(1) ], |
| 1856 | void 0 === (__WEBPACK_AMD_DEFINE_RESULT__ = "function" == typeof (__WEBPACK_AMD_DEFINE_FACTORY__ = factory) ? __WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__) : __WEBPACK_AMD_DEFINE_FACTORY__) || (module.exports = __WEBPACK_AMD_DEFINE_RESULT__); |
| 1857 | }, function(module, exports, __webpack_require__) { |
| 1858 | "use strict"; |
| 1859 | var __WEBPACK_AMD_DEFINE_RESULT__; |
| 1860 | "function" == typeof Symbol && Symbol.iterator; |
| 1861 | void 0 === (__WEBPACK_AMD_DEFINE_RESULT__ = function() { |
| 1862 | return window; |
| 1863 | }.call(exports, __webpack_require__, exports, module)) || (module.exports = __WEBPACK_AMD_DEFINE_RESULT__); |
| 1864 | }, function(module, exports, __webpack_require__) { |
| 1865 | "use strict"; |
| 1866 | var __WEBPACK_AMD_DEFINE_RESULT__; |
| 1867 | "function" == typeof Symbol && Symbol.iterator; |
| 1868 | void 0 === (__WEBPACK_AMD_DEFINE_RESULT__ = function() { |
| 1869 | return document; |
| 1870 | }.call(exports, __webpack_require__, exports, module)) || (module.exports = __WEBPACK_AMD_DEFINE_RESULT__); |
| 1871 | }, function(module, exports, __webpack_require__) { |
| 1872 | "use strict"; |
| 1873 | var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__, factory; |
| 1874 | "function" == typeof Symbol && Symbol.iterator; |
| 1875 | factory = function($, Inputmask) { |
| 1876 | return Inputmask.extendDefinitions({ |
| 1877 | A: { |
| 1878 | validator: "[A-Za-zА-яЁёÀ-ÿµ]", |
| 1879 | casing: "upper" |
| 1880 | }, |
| 1881 | "&": { |
| 1882 | validator: "[0-9A-Za-zА-яЁёÀ-ÿµ]", |
| 1883 | casing: "upper" |
| 1884 | }, |
| 1885 | "#": { |
| 1886 | validator: "[0-9A-Fa-f]", |
| 1887 | casing: "upper" |
| 1888 | } |
| 1889 | }), Inputmask.extendAliases({ |
| 1890 | cssunit: { |
| 1891 | regex: "[+-]?[0-9]+\\.?([0-9]+)?(px|em|rem|ex|%|in|cm|mm|pt|pc)" |
| 1892 | }, |
| 1893 | url: { |
| 1894 | regex: "(https?|ftp)//.*", |
| 1895 | autoUnmask: !1 |
| 1896 | }, |
| 1897 | ip: { |
| 1898 | mask: "i[i[i]].i[i[i]].i[i[i]].i[i[i]]", |
| 1899 | definitions: { |
| 1900 | i: { |
| 1901 | validator: function(chrs, maskset, pos, strict, opts) { |
| 1902 | return pos - 1 > -1 && "." !== maskset.buffer[pos - 1] ? (chrs = maskset.buffer[pos - 1] + chrs, |
| 1903 | chrs = pos - 2 > -1 && "." !== maskset.buffer[pos - 2] ? maskset.buffer[pos - 2] + chrs : "0" + chrs) : chrs = "00" + chrs, |
| 1904 | new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]").test(chrs); |
| 1905 | } |
| 1906 | } |
| 1907 | }, |
| 1908 | onUnMask: function(maskedValue, unmaskedValue, opts) { |
| 1909 | return maskedValue; |
| 1910 | }, |
| 1911 | inputmode: "numeric" |
| 1912 | }, |
| 1913 | email: { |
| 1914 | mask: "*{1,64}[.*{1,64}][.*{1,64}][.*{1,63}]@-{1,63}.-{1,63}[.-{1,63}][.-{1,63}]", |
| 1915 | greedy: !1, |
| 1916 | casing: "lower", |
| 1917 | onBeforePaste: function(pastedValue, opts) { |
| 1918 | return (pastedValue = pastedValue.toLowerCase()).replace("mailto:", ""); |
| 1919 | }, |
| 1920 | definitions: { |
| 1921 | "*": { |
| 1922 | validator: "[0-91-9A-Za-zА-яЁёÀ-ÿµ!#$%&'*+/=?^_`{|}~-]" |
| 1923 | }, |
| 1924 | "-": { |
| 1925 | validator: "[0-9A-Za-z-]" |
| 1926 | } |
| 1927 | }, |
| 1928 | onUnMask: function(maskedValue, unmaskedValue, opts) { |
| 1929 | return maskedValue; |
| 1930 | }, |
| 1931 | inputmode: "email" |
| 1932 | }, |
| 1933 | mac: { |
| 1934 | mask: "##:##:##:##:##:##" |
| 1935 | }, |
| 1936 | vin: { |
| 1937 | mask: "V{13}9{4}", |
| 1938 | definitions: { |
| 1939 | V: { |
| 1940 | validator: "[A-HJ-NPR-Za-hj-npr-z\\d]", |
| 1941 | casing: "upper" |
| 1942 | } |
| 1943 | }, |
| 1944 | clearIncomplete: !0, |
| 1945 | autoUnmask: !0 |
| 1946 | } |
| 1947 | }), Inputmask; |
| 1948 | }, __WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(0), __webpack_require__(1) ], |
| 1949 | void 0 === (__WEBPACK_AMD_DEFINE_RESULT__ = "function" == typeof (__WEBPACK_AMD_DEFINE_FACTORY__ = factory) ? __WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__) : __WEBPACK_AMD_DEFINE_FACTORY__) || (module.exports = __WEBPACK_AMD_DEFINE_RESULT__); |
| 1950 | }, function(module, exports, __webpack_require__) { |
| 1951 | "use strict"; |
| 1952 | var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__, factory; |
| 1953 | "function" == typeof Symbol && Symbol.iterator; |
| 1954 | factory = function($, Inputmask, undefined) { |
| 1955 | function autoEscape(txt, opts) { |
| 1956 | for (var escapedTxt = "", i = 0; i < txt.length; i++) Inputmask.prototype.definitions[txt.charAt(i)] || opts.definitions[txt.charAt(i)] || opts.optionalmarker.start === txt.charAt(i) || opts.optionalmarker.end === txt.charAt(i) || opts.quantifiermarker.start === txt.charAt(i) || opts.quantifiermarker.end === txt.charAt(i) || opts.groupmarker.start === txt.charAt(i) || opts.groupmarker.end === txt.charAt(i) || opts.alternatormarker === txt.charAt(i) ? escapedTxt += "\\" + txt.charAt(i) : escapedTxt += txt.charAt(i); |
| 1957 | return escapedTxt; |
| 1958 | } |
| 1959 | return Inputmask.extendAliases({ |
| 1960 | numeric: { |
| 1961 | mask: function(opts) { |
| 1962 | if (0 !== opts.repeat && isNaN(opts.integerDigits) && (opts.integerDigits = opts.repeat), |
| 1963 | opts.repeat = 0, opts.groupSeparator === opts.radixPoint && opts.digits && "0" !== opts.digits && ("." === opts.radixPoint ? opts.groupSeparator = "," : "," === opts.radixPoint ? opts.groupSeparator = "." : opts.groupSeparator = ""), |
| 1964 | " " === opts.groupSeparator && (opts.skipOptionalPartCharacter = undefined), opts.autoGroup = opts.autoGroup && "" !== opts.groupSeparator, |
| 1965 | opts.autoGroup && ("string" == typeof opts.groupSize && isFinite(opts.groupSize) && (opts.groupSize = parseInt(opts.groupSize)), |
| 1966 | isFinite(opts.integerDigits))) { |
| 1967 | var seps = Math.floor(opts.integerDigits / opts.groupSize), mod = opts.integerDigits % opts.groupSize; |
| 1968 | opts.integerDigits = parseInt(opts.integerDigits) + (0 === mod ? seps - 1 : seps), |
| 1969 | opts.integerDigits < 1 && (opts.integerDigits = "*"); |
| 1970 | } |
| 1971 | opts.placeholder.length > 1 && (opts.placeholder = opts.placeholder.charAt(0)), |
| 1972 | "radixFocus" === opts.positionCaretOnClick && "" === opts.placeholder && !1 === opts.integerOptional && (opts.positionCaretOnClick = "lvp"), |
| 1973 | opts.definitions[";"] = opts.definitions["~"], opts.definitions[";"].definitionSymbol = "~", |
| 1974 | !0 === opts.numericInput && (opts.positionCaretOnClick = "radixFocus" === opts.positionCaretOnClick ? "lvp" : opts.positionCaretOnClick, |
| 1975 | opts.digitsOptional = !1, isNaN(opts.digits) && (opts.digits = 2), opts.decimalProtect = !1); |
| 1976 | var mask = "[+]"; |
| 1977 | if (mask += autoEscape(opts.prefix, opts), !0 === opts.integerOptional ? mask += "~{1," + opts.integerDigits + "}" : mask += "~{" + opts.integerDigits + "}", |
| 1978 | opts.digits !== undefined) { |
| 1979 | var radixDef = opts.decimalProtect ? ":" : opts.radixPoint, dq = opts.digits.toString().split(","); |
| 1980 | isFinite(dq[0]) && dq[1] && isFinite(dq[1]) ? mask += radixDef + ";{" + opts.digits + "}" : (isNaN(opts.digits) || parseInt(opts.digits) > 0) && (opts.digitsOptional ? mask += "[" + radixDef + ";{1," + opts.digits + "}]" : mask += radixDef + ";{" + opts.digits + "}"); |
| 1981 | } |
| 1982 | return mask += autoEscape(opts.suffix, opts), mask += "[-]", opts.greedy = !1, mask; |
| 1983 | }, |
| 1984 | placeholder: "", |
| 1985 | greedy: !1, |
| 1986 | digits: "*", |
| 1987 | digitsOptional: !0, |
| 1988 | enforceDigitsOnBlur: !1, |
| 1989 | radixPoint: ".", |
| 1990 | positionCaretOnClick: "radixFocus", |
| 1991 | groupSize: 3, |
| 1992 | groupSeparator: "", |
| 1993 | autoGroup: !1, |
| 1994 | allowMinus: !0, |
| 1995 | negationSymbol: { |
| 1996 | front: "-", |
| 1997 | back: "" |
| 1998 | }, |
| 1999 | integerDigits: "+", |
| 2000 | integerOptional: !0, |
| 2001 | prefix: "", |
| 2002 | suffix: "", |
| 2003 | rightAlign: !0, |
| 2004 | decimalProtect: !0, |
| 2005 | min: null, |
| 2006 | max: null, |
| 2007 | step: 1, |
| 2008 | insertMode: !0, |
| 2009 | autoUnmask: !1, |
| 2010 | unmaskAsNumber: !1, |
| 2011 | inputmode: "numeric", |
| 2012 | preValidation: function(buffer, pos, c, isSelection, opts, maskset) { |
| 2013 | if ("-" === c || c === opts.negationSymbol.front) return !0 === opts.allowMinus && (opts.isNegative = opts.isNegative === undefined || !opts.isNegative, |
| 2014 | "" === buffer.join("") || { |
| 2015 | caret: pos, |
| 2016 | dopost: !0 |
| 2017 | }); |
| 2018 | if (!1 === isSelection && c === opts.radixPoint && opts.digits !== undefined && (isNaN(opts.digits) || parseInt(opts.digits) > 0)) { |
| 2019 | var radixPos = $.inArray(opts.radixPoint, buffer); |
| 2020 | if (-1 !== radixPos && maskset.validPositions[radixPos] !== undefined) return !0 === opts.numericInput ? pos === radixPos : { |
| 2021 | caret: radixPos + 1 |
| 2022 | }; |
| 2023 | } |
| 2024 | return !0; |
| 2025 | }, |
| 2026 | postValidation: function(buffer, currentResult, opts) { |
| 2027 | var suffix = opts.suffix.split(""), prefix = opts.prefix.split(""); |
| 2028 | if (currentResult.pos === undefined && currentResult.caret !== undefined && !0 !== currentResult.dopost) return currentResult; |
| 2029 | var caretPos = currentResult.caret !== undefined ? currentResult.caret : currentResult.pos, maskedValue = buffer.slice(); |
| 2030 | opts.numericInput && (caretPos = maskedValue.length - caretPos - 1, maskedValue = maskedValue.reverse()); |
| 2031 | var charAtPos = maskedValue[caretPos]; |
| 2032 | if (charAtPos === opts.groupSeparator && (charAtPos = maskedValue[caretPos += 1]), |
| 2033 | caretPos === maskedValue.length - opts.suffix.length - 1 && charAtPos === opts.radixPoint) return currentResult; |
| 2034 | charAtPos !== undefined && charAtPos !== opts.radixPoint && charAtPos !== opts.negationSymbol.front && charAtPos !== opts.negationSymbol.back && (maskedValue[caretPos] = "?", |
| 2035 | opts.prefix.length > 0 && caretPos >= (!1 === opts.isNegative ? 1 : 0) && caretPos < opts.prefix.length - 1 + (!1 === opts.isNegative ? 1 : 0) ? prefix[caretPos - (!1 === opts.isNegative ? 1 : 0)] = "?" : opts.suffix.length > 0 && caretPos >= maskedValue.length - opts.suffix.length - (!1 === opts.isNegative ? 1 : 0) && (suffix[caretPos - (maskedValue.length - opts.suffix.length - (!1 === opts.isNegative ? 1 : 0))] = "?")), |
| 2036 | prefix = prefix.join(""), suffix = suffix.join(""); |
| 2037 | var processValue = maskedValue.join("").replace(prefix, ""); |
| 2038 | if (processValue = (processValue = (processValue = (processValue = processValue.replace(suffix, "")).replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "")).replace(new RegExp("[-" + Inputmask.escapeRegex(opts.negationSymbol.front) + "]", "g"), "")).replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), ""), |
| 2039 | isNaN(opts.placeholder) && (processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.placeholder), "g"), "")), |
| 2040 | processValue.length > 1 && 1 !== processValue.indexOf(opts.radixPoint) && ("0" === charAtPos && (processValue = processValue.replace(/^\?/g, "")), |
| 2041 | processValue = processValue.replace(/^0/g, "")), processValue.charAt(0) === opts.radixPoint && "" !== opts.radixPoint && !0 !== opts.numericInput && (processValue = "0" + processValue), |
| 2042 | "" !== processValue) { |
| 2043 | if (processValue = processValue.split(""), (!opts.digitsOptional || opts.enforceDigitsOnBlur && "blur" === currentResult.event) && isFinite(opts.digits)) { |
| 2044 | var radixPosition = $.inArray(opts.radixPoint, processValue), rpb = $.inArray(opts.radixPoint, maskedValue); |
| 2045 | -1 === radixPosition && (processValue.push(opts.radixPoint), radixPosition = processValue.length - 1); |
| 2046 | for (var i = 1; i <= opts.digits; i++) opts.digitsOptional && (!opts.enforceDigitsOnBlur || "blur" !== currentResult.event) || processValue[radixPosition + i] !== undefined && processValue[radixPosition + i] !== opts.placeholder.charAt(0) ? -1 !== rpb && maskedValue[rpb + i] !== undefined && (processValue[radixPosition + i] = processValue[radixPosition + i] || maskedValue[rpb + i]) : processValue[radixPosition + i] = currentResult.placeholder || opts.placeholder.charAt(0); |
| 2047 | } |
| 2048 | if (!0 !== opts.autoGroup || "" === opts.groupSeparator || charAtPos === opts.radixPoint && currentResult.pos === undefined && !currentResult.dopost) processValue = processValue.join(""); else { |
| 2049 | var addRadix = processValue[processValue.length - 1] === opts.radixPoint && currentResult.c === opts.radixPoint; |
| 2050 | processValue = Inputmask(function(buffer, opts) { |
| 2051 | var postMask = ""; |
| 2052 | if (postMask += "(" + opts.groupSeparator + "*{" + opts.groupSize + "}){*}", "" !== opts.radixPoint) { |
| 2053 | var radixSplit = buffer.join("").split(opts.radixPoint); |
| 2054 | radixSplit[1] && (postMask += opts.radixPoint + "*{" + radixSplit[1].match(/^\d*\??\d*/)[0].length + "}"); |
| 2055 | } |
| 2056 | return postMask; |
| 2057 | }(processValue, opts), { |
| 2058 | numericInput: !0, |
| 2059 | jitMasking: !0, |
| 2060 | definitions: { |
| 2061 | "*": { |
| 2062 | validator: "[0-9?]", |
| 2063 | cardinality: 1 |
| 2064 | } |
| 2065 | } |
| 2066 | }).format(processValue.join("")), addRadix && (processValue += opts.radixPoint), |
| 2067 | processValue.charAt(0) === opts.groupSeparator && processValue.substr(1); |
| 2068 | } |
| 2069 | } |
| 2070 | if (opts.isNegative && "blur" === currentResult.event && (opts.isNegative = "0" !== processValue), |
| 2071 | processValue = prefix + processValue, processValue += suffix, opts.isNegative && (processValue = opts.negationSymbol.front + processValue, |
| 2072 | processValue += opts.negationSymbol.back), processValue = processValue.split(""), |
| 2073 | charAtPos !== undefined) if (charAtPos !== opts.radixPoint && charAtPos !== opts.negationSymbol.front && charAtPos !== opts.negationSymbol.back) (caretPos = $.inArray("?", processValue)) > -1 ? processValue[caretPos] = charAtPos : caretPos = currentResult.caret || 0; else if (charAtPos === opts.radixPoint || charAtPos === opts.negationSymbol.front || charAtPos === opts.negationSymbol.back) { |
| 2074 | var newCaretPos = $.inArray(charAtPos, processValue); |
| 2075 | -1 !== newCaretPos && (caretPos = newCaretPos); |
| 2076 | } |
| 2077 | opts.numericInput && (caretPos = processValue.length - caretPos - 1, processValue = processValue.reverse()); |
| 2078 | var rslt = { |
| 2079 | caret: charAtPos === undefined || currentResult.pos !== undefined ? caretPos + (opts.numericInput ? -1 : 1) : caretPos, |
| 2080 | buffer: processValue, |
| 2081 | refreshFromBuffer: currentResult.dopost || buffer.join("") !== processValue.join("") |
| 2082 | }; |
| 2083 | return rslt.refreshFromBuffer ? rslt : currentResult; |
| 2084 | }, |
| 2085 | onBeforeWrite: function(e, buffer, caretPos, opts) { |
| 2086 | if (e) switch (e.type) { |
| 2087 | case "keydown": |
| 2088 | return opts.postValidation(buffer, { |
| 2089 | caret: caretPos, |
| 2090 | dopost: !0 |
| 2091 | }, opts); |
| 2092 | |
| 2093 | case "blur": |
| 2094 | case "checkval": |
| 2095 | var unmasked; |
| 2096 | if (function(opts) { |
| 2097 | opts.parseMinMaxOptions === undefined && (null !== opts.min && (opts.min = opts.min.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""), |
| 2098 | "," === opts.radixPoint && (opts.min = opts.min.replace(opts.radixPoint, ".")), |
| 2099 | opts.min = isFinite(opts.min) ? parseFloat(opts.min) : NaN, isNaN(opts.min) && (opts.min = Number.MIN_VALUE)), |
| 2100 | null !== opts.max && (opts.max = opts.max.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""), |
| 2101 | "," === opts.radixPoint && (opts.max = opts.max.replace(opts.radixPoint, ".")), |
| 2102 | opts.max = isFinite(opts.max) ? parseFloat(opts.max) : NaN, isNaN(opts.max) && (opts.max = Number.MAX_VALUE)), |
| 2103 | opts.parseMinMaxOptions = "done"); |
| 2104 | }(opts), null !== opts.min || null !== opts.max) { |
| 2105 | if (unmasked = opts.onUnMask(buffer.join(""), undefined, $.extend({}, opts, { |
| 2106 | unmaskAsNumber: !0 |
| 2107 | })), null !== opts.min && unmasked < opts.min) return opts.isNegative = opts.min < 0, |
| 2108 | opts.postValidation(opts.min.toString().replace(".", opts.radixPoint).split(""), { |
| 2109 | caret: caretPos, |
| 2110 | dopost: !0, |
| 2111 | placeholder: "0" |
| 2112 | }, opts); |
| 2113 | if (null !== opts.max && unmasked > opts.max) return opts.isNegative = opts.max < 0, |
| 2114 | opts.postValidation(opts.max.toString().replace(".", opts.radixPoint).split(""), { |
| 2115 | caret: caretPos, |
| 2116 | dopost: !0, |
| 2117 | placeholder: "0" |
| 2118 | }, opts); |
| 2119 | } |
| 2120 | return opts.postValidation(buffer, { |
| 2121 | caret: caretPos, |
| 2122 | placeholder: "0", |
| 2123 | event: "blur" |
| 2124 | }, opts); |
| 2125 | |
| 2126 | case "_checkval": |
| 2127 | return { |
| 2128 | caret: caretPos |
| 2129 | }; |
| 2130 | } |
| 2131 | }, |
| 2132 | regex: { |
| 2133 | integerPart: function(opts, emptyCheck) { |
| 2134 | return emptyCheck ? new RegExp("[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "+]?") : new RegExp("[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "+]?\\d+"); |
| 2135 | }, |
| 2136 | integerNPart: function(opts) { |
| 2137 | return new RegExp("[\\d" + Inputmask.escapeRegex(opts.groupSeparator) + Inputmask.escapeRegex(opts.placeholder.charAt(0)) + "]+"); |
| 2138 | } |
| 2139 | }, |
| 2140 | definitions: { |
| 2141 | "~": { |
| 2142 | validator: function(chrs, maskset, pos, strict, opts, isSelection) { |
| 2143 | var isValid; |
| 2144 | if ("k" === chrs || "m" === chrs) { |
| 2145 | isValid = { |
| 2146 | insert: [], |
| 2147 | c: 0 |
| 2148 | }; |
| 2149 | for (var i = 0, l = "k" === chrs ? 2 : 5; i < l; i++) isValid.insert.push({ |
| 2150 | pos: pos + i, |
| 2151 | c: 0 |
| 2152 | }); |
| 2153 | return isValid.pos = pos + l, isValid; |
| 2154 | } |
| 2155 | if (!0 === (isValid = strict ? new RegExp("[0-9" + Inputmask.escapeRegex(opts.groupSeparator) + "]").test(chrs) : new RegExp("[0-9]").test(chrs))) { |
| 2156 | if (!0 !== opts.numericInput && maskset.validPositions[pos] !== undefined && "~" === maskset.validPositions[pos].match.def && !isSelection) { |
| 2157 | var processValue = maskset.buffer.join(""), pvRadixSplit = (processValue = (processValue = processValue.replace(new RegExp("[-" + Inputmask.escapeRegex(opts.negationSymbol.front) + "]", "g"), "")).replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), "")).split(opts.radixPoint); |
| 2158 | pvRadixSplit.length > 1 && (pvRadixSplit[1] = pvRadixSplit[1].replace(/0/g, opts.placeholder.charAt(0))), |
| 2159 | "0" === pvRadixSplit[0] && (pvRadixSplit[0] = pvRadixSplit[0].replace(/0/g, opts.placeholder.charAt(0))), |
| 2160 | processValue = pvRadixSplit[0] + opts.radixPoint + pvRadixSplit[1] || ""; |
| 2161 | var bufferTemplate = maskset._buffer.join(""); |
| 2162 | for (processValue === opts.radixPoint && (processValue = bufferTemplate); null === processValue.match(Inputmask.escapeRegex(bufferTemplate) + "$"); ) bufferTemplate = bufferTemplate.slice(1); |
| 2163 | isValid = (processValue = (processValue = processValue.replace(bufferTemplate, "")).split(""))[pos] === undefined ? { |
| 2164 | pos: pos, |
| 2165 | remove: pos |
| 2166 | } : { |
| 2167 | pos: pos |
| 2168 | }; |
| 2169 | } |
| 2170 | } else strict || chrs !== opts.radixPoint || maskset.validPositions[pos - 1] !== undefined || (isValid = { |
| 2171 | insert: { |
| 2172 | pos: pos, |
| 2173 | c: 0 |
| 2174 | }, |
| 2175 | pos: pos + 1 |
| 2176 | }); |
| 2177 | return isValid; |
| 2178 | }, |
| 2179 | cardinality: 1 |
| 2180 | }, |
| 2181 | "+": { |
| 2182 | validator: function(chrs, maskset, pos, strict, opts) { |
| 2183 | return opts.allowMinus && ("-" === chrs || chrs === opts.negationSymbol.front); |
| 2184 | }, |
| 2185 | cardinality: 1, |
| 2186 | placeholder: "" |
| 2187 | }, |
| 2188 | "-": { |
| 2189 | validator: function(chrs, maskset, pos, strict, opts) { |
| 2190 | return opts.allowMinus && chrs === opts.negationSymbol.back; |
| 2191 | }, |
| 2192 | cardinality: 1, |
| 2193 | placeholder: "" |
| 2194 | }, |
| 2195 | ":": { |
| 2196 | validator: function(chrs, maskset, pos, strict, opts) { |
| 2197 | var radix = "[" + Inputmask.escapeRegex(opts.radixPoint) + "]", isValid = new RegExp(radix).test(chrs); |
| 2198 | return isValid && maskset.validPositions[pos] && maskset.validPositions[pos].match.placeholder === opts.radixPoint && (isValid = { |
| 2199 | caret: pos + 1 |
| 2200 | }), isValid; |
| 2201 | }, |
| 2202 | cardinality: 1, |
| 2203 | placeholder: function(opts) { |
| 2204 | return opts.radixPoint; |
| 2205 | } |
| 2206 | } |
| 2207 | }, |
| 2208 | onUnMask: function(maskedValue, unmaskedValue, opts) { |
| 2209 | if ("" === unmaskedValue && !0 === opts.nullable) return unmaskedValue; |
| 2210 | var processValue = maskedValue.replace(opts.prefix, ""); |
| 2211 | return processValue = (processValue = processValue.replace(opts.suffix, "")).replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""), |
| 2212 | "" !== opts.placeholder.charAt(0) && (processValue = processValue.replace(new RegExp(opts.placeholder.charAt(0), "g"), "0")), |
| 2213 | opts.unmaskAsNumber ? ("" !== opts.radixPoint && -1 !== processValue.indexOf(opts.radixPoint) && (processValue = processValue.replace(Inputmask.escapeRegex.call(this, opts.radixPoint), ".")), |
| 2214 | processValue = (processValue = processValue.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), "-")).replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), ""), |
| 2215 | Number(processValue)) : processValue; |
| 2216 | }, |
| 2217 | isComplete: function(buffer, opts) { |
| 2218 | var maskedValue = (opts.numericInput ? buffer.slice().reverse() : buffer).join(""); |
| 2219 | return maskedValue = (maskedValue = (maskedValue = (maskedValue = (maskedValue = maskedValue.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), "-")).replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), "")).replace(opts.prefix, "")).replace(opts.suffix, "")).replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator) + "([0-9]{3})", "g"), "$1"), |
| 2220 | "," === opts.radixPoint && (maskedValue = maskedValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".")), |
| 2221 | isFinite(maskedValue); |
| 2222 | }, |
| 2223 | onBeforeMask: function(initialValue, opts) { |
| 2224 | if (opts.isNegative = undefined, "number" == typeof initialValue && "" !== opts.radixPoint && (initialValue = initialValue.toString().replace(".", opts.radixPoint)), |
| 2225 | initialValue = initialValue.toString().charAt(initialValue.length - 1) === opts.radixPoint ? initialValue.toString().substr(0, initialValue.length - 1) : initialValue.toString(), |
| 2226 | "" !== opts.radixPoint && isFinite(initialValue)) { |
| 2227 | var vs = initialValue.split("."), groupSize = "" !== opts.groupSeparator ? parseInt(opts.groupSize) : 0; |
| 2228 | 2 === vs.length && (vs[0].length > groupSize || vs[1].length > groupSize || vs[0].length <= groupSize && vs[1].length < groupSize) && (initialValue = initialValue.replace(".", opts.radixPoint)); |
| 2229 | } |
| 2230 | var kommaMatches = initialValue.match(/,/g), dotMatches = initialValue.match(/\./g); |
| 2231 | if (initialValue = dotMatches && kommaMatches ? dotMatches.length > kommaMatches.length ? (initialValue = initialValue.replace(/\./g, "")).replace(",", opts.radixPoint) : kommaMatches.length > dotMatches.length ? (initialValue = initialValue.replace(/,/g, "")).replace(".", opts.radixPoint) : initialValue.indexOf(".") < initialValue.indexOf(",") ? initialValue.replace(/\./g, "") : initialValue.replace(/,/g, "") : initialValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""), |
| 2232 | 0 === opts.digits && (-1 !== initialValue.indexOf(".") ? initialValue = initialValue.substring(0, initialValue.indexOf(".")) : -1 !== initialValue.indexOf(",") && (initialValue = initialValue.substring(0, initialValue.indexOf(",")))), |
| 2233 | "" !== opts.radixPoint && isFinite(opts.digits) && -1 !== initialValue.indexOf(opts.radixPoint)) { |
| 2234 | var decPart = initialValue.split(opts.radixPoint)[1].match(new RegExp("\\d*"))[0]; |
| 2235 | if (parseInt(opts.digits) < decPart.toString().length) { |
| 2236 | var digitsFactor = Math.pow(10, parseInt(opts.digits)); |
| 2237 | initialValue = initialValue.replace(Inputmask.escapeRegex(opts.radixPoint), "."), |
| 2238 | initialValue = (initialValue = Math.round(parseFloat(initialValue) * digitsFactor) / digitsFactor).toString().replace(".", opts.radixPoint); |
| 2239 | } |
| 2240 | } |
| 2241 | return function(buffer, opts) { |
| 2242 | var radixPosition = $.inArray(opts.radixPoint, buffer); |
| 2243 | -1 === radixPosition && (buffer.push(opts.radixPoint), radixPosition = buffer.length - 1); |
| 2244 | for (var i = 1; i <= opts.digits; i++) buffer[radixPosition + i] = buffer[radixPosition + i] || "0"; |
| 2245 | return buffer; |
| 2246 | }(initialValue.toString().split(""), opts).join(""); |
| 2247 | }, |
| 2248 | onKeyDown: function(e, buffer, caretPos, opts) { |
| 2249 | var $input = $(this); |
| 2250 | if (e.ctrlKey) switch (e.keyCode) { |
| 2251 | case Inputmask.keyCode.UP: |
| 2252 | $input.val(parseFloat(this.inputmask.unmaskedvalue()) + parseInt(opts.step)), $input.trigger("setvalue"); |
| 2253 | break; |
| 2254 | |
| 2255 | case Inputmask.keyCode.DOWN: |
| 2256 | $input.val(parseFloat(this.inputmask.unmaskedvalue()) - parseInt(opts.step)), $input.trigger("setvalue"); |
| 2257 | } |
| 2258 | } |
| 2259 | }, |
| 2260 | currency: { |
| 2261 | prefix: "$ ", |
| 2262 | groupSeparator: ",", |
| 2263 | alias: "numeric", |
| 2264 | placeholder: "0", |
| 2265 | autoGroup: !0, |
| 2266 | digits: 2, |
| 2267 | digitsOptional: !1, |
| 2268 | clearMaskOnLostFocus: !1 |
| 2269 | }, |
| 2270 | decimal: { |
| 2271 | alias: "numeric" |
| 2272 | }, |
| 2273 | integer: { |
| 2274 | alias: "numeric", |
| 2275 | digits: 0, |
| 2276 | radixPoint: "" |
| 2277 | }, |
| 2278 | percentage: { |
| 2279 | alias: "numeric", |
| 2280 | digits: 2, |
| 2281 | digitsOptional: !0, |
| 2282 | radixPoint: ".", |
| 2283 | placeholder: "0", |
| 2284 | autoGroup: !1, |
| 2285 | min: 0, |
| 2286 | max: 100, |
| 2287 | suffix: " %", |
| 2288 | allowMinus: !1 |
| 2289 | } |
| 2290 | }), Inputmask; |
| 2291 | }, __WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(0), __webpack_require__(1) ], |
| 2292 | void 0 === (__WEBPACK_AMD_DEFINE_RESULT__ = "function" == typeof (__WEBPACK_AMD_DEFINE_FACTORY__ = factory) ? __WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__) : __WEBPACK_AMD_DEFINE_FACTORY__) || (module.exports = __WEBPACK_AMD_DEFINE_RESULT__); |
| 2293 | }, function(module, exports, __webpack_require__) { |
| 2294 | "use strict"; |
| 2295 | var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__, factory; |
| 2296 | "function" == typeof Symbol && Symbol.iterator; |
| 2297 | factory = function($, Inputmask) { |
| 2298 | function maskSort(a, b) { |
| 2299 | var maska = (a.mask || a).replace(/#/g, "0").replace(/\)/, "0").replace(/[+()#-]/g, ""), maskb = (b.mask || b).replace(/#/g, "0").replace(/\)/, "0").replace(/[+()#-]/g, ""); |
| 2300 | return maska.localeCompare(maskb); |
| 2301 | } |
| 2302 | var analyseMaskBase = Inputmask.prototype.analyseMask; |
| 2303 | return Inputmask.prototype.analyseMask = function(mask, regexMask, opts) { |
| 2304 | var maskGroups = {}; |
| 2305 | return opts.phoneCodes && (opts.phoneCodes && opts.phoneCodes.length > 1e3 && (function reduceVariations(masks, previousVariation, previousmaskGroup) { |
| 2306 | previousVariation = previousVariation || "", previousmaskGroup = previousmaskGroup || maskGroups, |
| 2307 | "" !== previousVariation && (previousmaskGroup[previousVariation] = {}); |
| 2308 | for (var variation = "", maskGroup = previousmaskGroup[previousVariation] || previousmaskGroup, i = masks.length - 1; i >= 0; i--) maskGroup[variation = (mask = masks[i].mask || masks[i]).substr(0, 1)] = maskGroup[variation] || [], |
| 2309 | maskGroup[variation].unshift(mask.substr(1)), masks.splice(i, 1); |
| 2310 | for (var ndx in maskGroup) maskGroup[ndx].length > 500 && reduceVariations(maskGroup[ndx].slice(), ndx, maskGroup); |
| 2311 | }((mask = mask.substr(1, mask.length - 2)).split(opts.groupmarker[1] + opts.alternatormarker + opts.groupmarker[0])), |
| 2312 | mask = function rebuild(maskGroup) { |
| 2313 | var mask = "", submasks = []; |
| 2314 | for (var ndx in maskGroup) $.isArray(maskGroup[ndx]) ? 1 === maskGroup[ndx].length ? submasks.push(ndx + maskGroup[ndx]) : submasks.push(ndx + opts.groupmarker[0] + maskGroup[ndx].join(opts.groupmarker[1] + opts.alternatormarker + opts.groupmarker[0]) + opts.groupmarker[1]) : submasks.push(ndx + rebuild(maskGroup[ndx])); |
| 2315 | return 1 === submasks.length ? mask += submasks[0] : mask += opts.groupmarker[0] + submasks.join(opts.groupmarker[1] + opts.alternatormarker + opts.groupmarker[0]) + opts.groupmarker[1], |
| 2316 | mask; |
| 2317 | }(maskGroups)), mask = mask.replace(/9/g, "\\9")), analyseMaskBase.call(this, mask, regexMask, opts); |
| 2318 | }, Inputmask.extendAliases({ |
| 2319 | abstractphone: { |
| 2320 | groupmarker: [ "<", ">" ], |
| 2321 | countrycode: "", |
| 2322 | phoneCodes: [], |
| 2323 | keepStatic: "auto", |
| 2324 | mask: function(opts) { |
| 2325 | return opts.definitions = { |
| 2326 | "#": Inputmask.prototype.definitions[9] |
| 2327 | }, opts.phoneCodes.sort(maskSort); |
| 2328 | }, |
| 2329 | onBeforeMask: function(value, opts) { |
| 2330 | var processedValue = value.replace(/^0{1,2}/, "").replace(/[\s]/g, ""); |
| 2331 | return (processedValue.indexOf(opts.countrycode) > 1 || -1 === processedValue.indexOf(opts.countrycode)) && (processedValue = "+" + opts.countrycode + processedValue), |
| 2332 | processedValue; |
| 2333 | }, |
| 2334 | onUnMask: function(maskedValue, unmaskedValue, opts) { |
| 2335 | return maskedValue.replace(/[()#-]/g, ""); |
| 2336 | }, |
| 2337 | inputmode: "tel" |
| 2338 | } |
| 2339 | }), Inputmask; |
| 2340 | }, __WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(0), __webpack_require__(1) ], |
| 2341 | void 0 === (__WEBPACK_AMD_DEFINE_RESULT__ = "function" == typeof (__WEBPACK_AMD_DEFINE_FACTORY__ = factory) ? __WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__) : __WEBPACK_AMD_DEFINE_FACTORY__) || (module.exports = __WEBPACK_AMD_DEFINE_RESULT__); |
| 2342 | }, function(module, exports, __webpack_require__) { |
| 2343 | "use strict"; |
| 2344 | var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__, factory, _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) { |
| 2345 | return typeof obj; |
| 2346 | } : function(obj) { |
| 2347 | return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; |
| 2348 | }; |
| 2349 | factory = function($, Inputmask) { |
| 2350 | return void 0 === $.fn.inputmask && ($.fn.inputmask = function(fn, options) { |
| 2351 | var nptmask, input = this[0]; |
| 2352 | if (void 0 === options && (options = {}), "string" == typeof fn) switch (fn) { |
| 2353 | case "unmaskedvalue": |
| 2354 | return input && input.inputmask ? input.inputmask.unmaskedvalue() : $(input).val(); |
| 2355 | |
| 2356 | case "remove": |
| 2357 | return this.each(function() { |
| 2358 | this.inputmask && this.inputmask.remove(); |
| 2359 | }); |
| 2360 | |
| 2361 | case "getemptymask": |
| 2362 | return input && input.inputmask ? input.inputmask.getemptymask() : ""; |
| 2363 | |
| 2364 | case "hasMaskedValue": |
| 2365 | return !(!input || !input.inputmask) && input.inputmask.hasMaskedValue(); |
| 2366 | |
| 2367 | case "isComplete": |
| 2368 | return !input || !input.inputmask || input.inputmask.isComplete(); |
| 2369 | |
| 2370 | case "getmetadata": |
| 2371 | return input && input.inputmask ? input.inputmask.getmetadata() : void 0; |
| 2372 | |
| 2373 | case "setvalue": |
| 2374 | Inputmask.setValue(input, options); |
| 2375 | break; |
| 2376 | |
| 2377 | case "option": |
| 2378 | if ("string" != typeof options) return this.each(function() { |
| 2379 | if (void 0 !== this.inputmask) return this.inputmask.option(options); |
| 2380 | }); |
| 2381 | if (input && void 0 !== input.inputmask) return input.inputmask.option(options); |
| 2382 | break; |
| 2383 | |
| 2384 | default: |
| 2385 | return options.alias = fn, nptmask = new Inputmask(options), this.each(function() { |
| 2386 | nptmask.mask(this); |
| 2387 | }); |
| 2388 | } else { |
| 2389 | if ("object" == (void 0 === fn ? "undefined" : _typeof(fn))) return nptmask = new Inputmask(fn), |
| 2390 | void 0 === fn.mask && void 0 === fn.alias ? this.each(function() { |
| 2391 | if (void 0 !== this.inputmask) return this.inputmask.option(fn); |
| 2392 | nptmask.mask(this); |
| 2393 | }) : this.each(function() { |
| 2394 | nptmask.mask(this); |
| 2395 | }); |
| 2396 | if (void 0 === fn) return this.each(function() { |
| 2397 | (nptmask = new Inputmask(options)).mask(this); |
| 2398 | }); |
| 2399 | } |
| 2400 | }), $.fn.inputmask; |
| 2401 | }, __WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(2), __webpack_require__(1) ], |
| 2402 | void 0 === (__WEBPACK_AMD_DEFINE_RESULT__ = "function" == typeof (__WEBPACK_AMD_DEFINE_FACTORY__ = factory) ? __WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__) : __WEBPACK_AMD_DEFINE_FACTORY__) || (module.exports = __WEBPACK_AMD_DEFINE_RESULT__); |
| 2403 | } ]); |