jquery.inputmask.bundle.js 217 KB

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