jquery.inputmask.bundle.js 216 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867
  1. /*!
  2. * jquery.inputmask.bundle.js
  3. * https://github.com/RobinHerbots/Inputmask
  4. * Copyright (c) 2010 - 2018 Robin Herbots
  5. * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
  6. * Version: 4.0.3-beta.0
  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__(6);
  76. __webpack_require__(7);
  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__(8);
  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\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  110. casing: "upper"
  111. },
  112. "&": {
  113. validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  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-9\uff11-\uff19A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5!#$%&'*+/=?^_`{|}~-]"
  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) ],
  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, undefined) {
  202. var document = window.document, 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-9\uff11-\uff19]",
  287. definitionSymbol: "*"
  288. },
  289. a: {
  290. validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  291. definitionSymbol: "*"
  292. },
  293. "*": {
  294. validator: "[0-9\uff11-\uff19A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]"
  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. if (input.placeholder === "") input.removeAttribute("placeholder");
  2088. }
  2089. },
  2090. clickEvent: function clickEvent(e, tabbed) {
  2091. function doRadixFocus(clickPos) {
  2092. if (opts.radixPoint !== "") {
  2093. var vps = getMaskSet().validPositions;
  2094. if (vps[clickPos] === undefined || vps[clickPos].input === getPlaceholder(clickPos)) {
  2095. if (clickPos < seekNext(-1)) return true;
  2096. var radixPos = $.inArray(opts.radixPoint, getBuffer());
  2097. if (radixPos !== -1) {
  2098. for (var vp in vps) {
  2099. if (radixPos < vp && vps[vp].input !== getPlaceholder(vp)) {
  2100. return false;
  2101. }
  2102. }
  2103. return true;
  2104. }
  2105. }
  2106. }
  2107. return false;
  2108. }
  2109. var input = this;
  2110. setTimeout(function() {
  2111. if (document.activeElement === input) {
  2112. var selectedCaret = caret(input);
  2113. if (tabbed) {
  2114. if (isRTL) {
  2115. selectedCaret.end = selectedCaret.begin;
  2116. } else {
  2117. selectedCaret.begin = selectedCaret.end;
  2118. }
  2119. }
  2120. if (selectedCaret.begin === selectedCaret.end) {
  2121. switch (opts.positionCaretOnClick) {
  2122. case "none":
  2123. break;
  2124. case "select":
  2125. caret(input, 0, getBuffer().length);
  2126. break;
  2127. case "ignore":
  2128. caret(input, seekNext(getLastValidPosition()));
  2129. break;
  2130. case "radixFocus":
  2131. if (doRadixFocus(selectedCaret.begin)) {
  2132. var radixPos = getBuffer().join("").indexOf(opts.radixPoint);
  2133. caret(input, opts.numericInput ? seekNext(radixPos) : radixPos);
  2134. break;
  2135. }
  2136. default:
  2137. var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition, true), lastPosition = seekNext(lvclickPosition);
  2138. if (clickPosition < lastPosition) {
  2139. caret(input, !isMask(clickPosition, true) && !isMask(clickPosition - 1, true) ? seekNext(clickPosition) : clickPosition);
  2140. } else {
  2141. var lvp = getMaskSet().validPositions[lvclickPosition], tt = getTestTemplate(lastPosition, lvp ? lvp.match.locator : undefined, lvp), placeholder = getPlaceholder(lastPosition, tt.match);
  2142. if (placeholder !== "" && getBuffer()[lastPosition] !== placeholder && tt.match.optionalQuantifier !== true && tt.match.newBlockMarker !== true || !isMask(lastPosition, opts.keepStatic) && tt.match.def === placeholder) {
  2143. var newPos = seekNext(lastPosition);
  2144. if (clickPosition >= newPos || clickPosition === lastPosition) {
  2145. lastPosition = newPos;
  2146. }
  2147. }
  2148. caret(input, lastPosition);
  2149. }
  2150. break;
  2151. }
  2152. }
  2153. }
  2154. }, 0);
  2155. },
  2156. cutEvent: function cutEvent(e) {
  2157. var input = this, $input = $(input), pos = caret(input), ev = e.originalEvent || e;
  2158. var clipboardData = window.clipboardData || ev.clipboardData, clipData = isRTL ? getBuffer().slice(pos.end, pos.begin) : getBuffer().slice(pos.begin, pos.end);
  2159. clipboardData.setData("text", isRTL ? clipData.reverse().join("") : clipData.join(""));
  2160. if (document.execCommand) document.execCommand("copy");
  2161. handleRemove(input, Inputmask.keyCode.DELETE, pos);
  2162. writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join(""));
  2163. },
  2164. blurEvent: function blurEvent(e) {
  2165. var $input = $(this), input = this;
  2166. if (input.inputmask) {
  2167. input.placeholder = originalPlaceholder;
  2168. if (input.placeholder === "") input.removeAttribute("placeholder");
  2169. var nptValue = input.inputmask._valueGet(), buffer = getBuffer().slice();
  2170. if (nptValue !== "" || colorMask !== undefined) {
  2171. if (opts.clearMaskOnLostFocus) {
  2172. if (getLastValidPosition() === -1 && nptValue === getBufferTemplate().join("")) {
  2173. buffer = [];
  2174. } else {
  2175. clearOptionalTail(buffer);
  2176. }
  2177. }
  2178. if (isComplete(buffer) === false) {
  2179. setTimeout(function() {
  2180. $input.trigger("incomplete");
  2181. }, 0);
  2182. if (opts.clearIncomplete) {
  2183. resetMaskSet();
  2184. if (opts.clearMaskOnLostFocus) {
  2185. buffer = [];
  2186. } else {
  2187. buffer = getBufferTemplate().slice();
  2188. }
  2189. }
  2190. }
  2191. writeBuffer(input, buffer, undefined, e);
  2192. }
  2193. if (undoValue !== getBuffer().join("")) {
  2194. undoValue = buffer.join("");
  2195. $input.trigger("change");
  2196. }
  2197. }
  2198. },
  2199. mouseenterEvent: function mouseenterEvent(e) {
  2200. var input = this;
  2201. mouseEnter = true;
  2202. if (document.activeElement !== input && opts.showMaskOnHover) {
  2203. input.placeholder = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join("");
  2204. }
  2205. },
  2206. submitEvent: function submitEvent(e) {
  2207. if (undoValue !== getBuffer().join("")) {
  2208. $el.trigger("change");
  2209. }
  2210. if (opts.clearMaskOnLostFocus && getLastValidPosition() === -1 && el.inputmask._valueGet && el.inputmask._valueGet() === getBufferTemplate().join("")) {
  2211. el.inputmask._valueSet("");
  2212. }
  2213. if (opts.clearIncomplete && isComplete(getBuffer()) === false) {
  2214. el.inputmask._valueSet("");
  2215. }
  2216. if (opts.removeMaskOnSubmit) {
  2217. el.inputmask._valueSet(el.inputmask.unmaskedvalue(), true);
  2218. setTimeout(function() {
  2219. writeBuffer(el, getBuffer());
  2220. }, 0);
  2221. }
  2222. },
  2223. resetEvent: function resetEvent(e) {
  2224. el.inputmask.refreshValue = true;
  2225. setTimeout(function() {
  2226. $el.trigger("setvalue");
  2227. }, 0);
  2228. }
  2229. };
  2230. function checkVal(input, writeOut, strict, nptvl, initiatingEvent) {
  2231. var inputmask = this || input.inputmask, inputValue = nptvl.slice(), charCodes = "", initialNdx = -1, result = undefined;
  2232. function isTemplateMatch(ndx, charCodes) {
  2233. var charCodeNdx = getMaskTemplate(true, 0, false).slice(ndx, seekNext(ndx)).join("").replace(/'/g, "").indexOf(charCodes);
  2234. 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)));
  2235. }
  2236. resetMaskSet();
  2237. if (!strict && opts.autoUnmask !== true) {
  2238. var staticInput = getBufferTemplate().slice(0, seekNext(-1)).join(""), matches = inputValue.join("").match(new RegExp("^" + Inputmask.escapeRegex(staticInput), "g"));
  2239. if (matches && matches.length > 0) {
  2240. inputValue.splice(0, matches.length * staticInput.length);
  2241. initialNdx = seekNext(initialNdx);
  2242. }
  2243. } else {
  2244. initialNdx = seekNext(initialNdx);
  2245. }
  2246. if (initialNdx === -1) {
  2247. getMaskSet().p = seekNext(initialNdx);
  2248. initialNdx = 0;
  2249. } else getMaskSet().p = initialNdx;
  2250. inputmask.caretPos = {
  2251. begin: initialNdx
  2252. };
  2253. $.each(inputValue, function(ndx, charCode) {
  2254. if (charCode !== undefined) {
  2255. if (getMaskSet().validPositions[ndx] === undefined && inputValue[ndx] === getPlaceholder(ndx) && isMask(ndx, true) && isValid(ndx, inputValue[ndx], true, undefined, undefined, true) === false) {
  2256. getMaskSet().p++;
  2257. } else {
  2258. var keypress = new $.Event("_checkval");
  2259. keypress.which = charCode.charCodeAt(0);
  2260. charCodes += charCode;
  2261. var lvp = getLastValidPosition(undefined, true);
  2262. if (!isTemplateMatch(initialNdx, charCodes)) {
  2263. result = EventHandlers.keypressEvent.call(input, keypress, true, false, strict, inputmask.caretPos.begin);
  2264. if (result) {
  2265. initialNdx = inputmask.caretPos.begin + 1;
  2266. charCodes = "";
  2267. }
  2268. } else {
  2269. result = EventHandlers.keypressEvent.call(input, keypress, true, false, strict, lvp + 1);
  2270. }
  2271. if (result) {
  2272. writeBuffer(undefined, getBuffer(), result.forwardPosition, keypress, false);
  2273. inputmask.caretPos = {
  2274. begin: result.forwardPosition,
  2275. end: result.forwardPosition
  2276. };
  2277. }
  2278. }
  2279. }
  2280. });
  2281. if (writeOut) writeBuffer(input, getBuffer(), result ? result.forwardPosition : undefined, initiatingEvent || new $.Event("checkval"), initiatingEvent && initiatingEvent.type === "input");
  2282. }
  2283. function unmaskedvalue(input) {
  2284. if (input) {
  2285. if (input.inputmask === undefined) {
  2286. return input.value;
  2287. }
  2288. if (input.inputmask && input.inputmask.refreshValue) {
  2289. EventHandlers.setValueEvent.call(input);
  2290. }
  2291. }
  2292. var umValue = [], vps = getMaskSet().validPositions;
  2293. for (var pndx in vps) {
  2294. if (vps[pndx].match && vps[pndx].match.fn != null) {
  2295. umValue.push(vps[pndx].input);
  2296. }
  2297. }
  2298. var unmaskedValue = umValue.length === 0 ? "" : (isRTL ? umValue.reverse() : umValue).join("");
  2299. if ($.isFunction(opts.onUnMask)) {
  2300. var bufferValue = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join("");
  2301. unmaskedValue = opts.onUnMask.call(inputmask, bufferValue, unmaskedValue, opts);
  2302. }
  2303. return unmaskedValue;
  2304. }
  2305. function caret(input, begin, end, notranslate) {
  2306. function translatePosition(pos) {
  2307. if (isRTL && typeof pos === "number" && (!opts.greedy || opts.placeholder !== "") && el) {
  2308. pos = el.inputmask._valueGet().length - pos;
  2309. }
  2310. return pos;
  2311. }
  2312. var range;
  2313. if (begin !== undefined) {
  2314. if ($.isArray(begin)) {
  2315. end = isRTL ? begin[0] : begin[1];
  2316. begin = isRTL ? begin[1] : begin[0];
  2317. }
  2318. if (begin.begin !== undefined) {
  2319. end = isRTL ? begin.begin : begin.end;
  2320. begin = isRTL ? begin.end : begin.begin;
  2321. }
  2322. if (typeof begin === "number") {
  2323. begin = notranslate ? begin : translatePosition(begin);
  2324. end = notranslate ? end : translatePosition(end);
  2325. end = typeof end == "number" ? end : begin;
  2326. var scrollCalc = parseInt(((input.ownerDocument.defaultView || window).getComputedStyle ? (input.ownerDocument.defaultView || window).getComputedStyle(input, null) : input.currentStyle).fontSize) * end;
  2327. input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0;
  2328. input.inputmask.caretPos = {
  2329. begin: begin,
  2330. end: end
  2331. };
  2332. if (input === document.activeElement) {
  2333. if ("selectionStart" in input) {
  2334. input.selectionStart = begin;
  2335. input.selectionEnd = end;
  2336. } else if (window.getSelection) {
  2337. range = document.createRange();
  2338. if (input.firstChild === undefined || input.firstChild === null) {
  2339. var textNode = document.createTextNode("");
  2340. input.appendChild(textNode);
  2341. }
  2342. range.setStart(input.firstChild, begin < input.inputmask._valueGet().length ? begin : input.inputmask._valueGet().length);
  2343. range.setEnd(input.firstChild, end < input.inputmask._valueGet().length ? end : input.inputmask._valueGet().length);
  2344. range.collapse(true);
  2345. var sel = window.getSelection();
  2346. sel.removeAllRanges();
  2347. sel.addRange(range);
  2348. } else if (input.createTextRange) {
  2349. range = input.createTextRange();
  2350. range.collapse(true);
  2351. range.moveEnd("character", end);
  2352. range.moveStart("character", begin);
  2353. range.select();
  2354. }
  2355. renderColorMask(input, {
  2356. begin: begin,
  2357. end: end
  2358. });
  2359. }
  2360. }
  2361. } else {
  2362. if ("selectionStart" in input) {
  2363. begin = input.selectionStart;
  2364. end = input.selectionEnd;
  2365. } else if (window.getSelection) {
  2366. range = window.getSelection().getRangeAt(0);
  2367. if (range.commonAncestorContainer.parentNode === input || range.commonAncestorContainer === input) {
  2368. begin = range.startOffset;
  2369. end = range.endOffset;
  2370. }
  2371. } else if (document.selection && document.selection.createRange) {
  2372. range = document.selection.createRange();
  2373. begin = 0 - range.duplicate().moveStart("character", -input.inputmask._valueGet().length);
  2374. end = begin + range.text.length;
  2375. }
  2376. return {
  2377. begin: notranslate ? begin : translatePosition(begin),
  2378. end: notranslate ? end : translatePosition(end)
  2379. };
  2380. }
  2381. }
  2382. function determineLastRequiredPosition(returnDefinition) {
  2383. 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;
  2384. for (pos = lvp + 1; pos < buffer.length; pos++) {
  2385. testPos = getTestTemplate(pos, ndxIntlzr, pos - 1);
  2386. ndxIntlzr = testPos.locator.slice();
  2387. positions[pos] = $.extend(true, {}, testPos);
  2388. }
  2389. var lvTestAlt = lvTest && lvTest.alternation !== undefined ? lvTest.locator[lvTest.alternation] : undefined;
  2390. for (pos = bl - 1; pos > lvp; pos--) {
  2391. testPos = positions[pos];
  2392. 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)) {
  2393. bl--;
  2394. } else break;
  2395. }
  2396. return returnDefinition ? {
  2397. l: bl,
  2398. def: positions[bl] ? positions[bl].match : undefined
  2399. } : bl;
  2400. }
  2401. function clearOptionalTail(buffer) {
  2402. buffer.length = 0;
  2403. var template = getMaskTemplate(true, 0, true, undefined, true), lmnt, validPos;
  2404. while (lmnt = template.shift(), lmnt !== undefined) {
  2405. buffer.push(lmnt);
  2406. }
  2407. return buffer;
  2408. }
  2409. function isComplete(buffer) {
  2410. if ($.isFunction(opts.isComplete)) return opts.isComplete(buffer, opts);
  2411. if (opts.repeat === "*") return undefined;
  2412. var complete = false, lrp = determineLastRequiredPosition(true), aml = seekPrevious(lrp.l);
  2413. if (lrp.def === undefined || lrp.def.newBlockMarker || lrp.def.optionality || lrp.def.optionalQuantifier) {
  2414. complete = true;
  2415. for (var i = 0; i <= aml; i++) {
  2416. var test = getTestTemplate(i).match;
  2417. if (test.fn !== null && getMaskSet().validPositions[i] === undefined && test.optionality !== true && test.optionalQuantifier !== true || test.fn === null && buffer[i] !== getPlaceholder(i, test)) {
  2418. complete = false;
  2419. break;
  2420. }
  2421. }
  2422. }
  2423. return complete;
  2424. }
  2425. function handleRemove(input, k, pos, strict, fromIsValid) {
  2426. if (opts.numericInput || isRTL) {
  2427. if (k === Inputmask.keyCode.BACKSPACE) {
  2428. k = Inputmask.keyCode.DELETE;
  2429. } else if (k === Inputmask.keyCode.DELETE) {
  2430. k = Inputmask.keyCode.BACKSPACE;
  2431. }
  2432. if (isRTL) {
  2433. var pend = pos.end;
  2434. pos.end = pos.begin;
  2435. pos.begin = pend;
  2436. }
  2437. }
  2438. if (k === Inputmask.keyCode.BACKSPACE && pos.end - pos.begin < 1) {
  2439. pos.begin = seekPrevious(pos.begin);
  2440. if (getMaskSet().validPositions[pos.begin] !== undefined && getMaskSet().validPositions[pos.begin].input === opts.groupSeparator) {
  2441. pos.begin--;
  2442. }
  2443. } else if (k === Inputmask.keyCode.DELETE && pos.begin === pos.end) {
  2444. pos.end = isMask(pos.end, true) && getMaskSet().validPositions[pos.end] && getMaskSet().validPositions[pos.end].input !== opts.radixPoint ? pos.end + 1 : seekNext(pos.end) + 1;
  2445. if (getMaskSet().validPositions[pos.begin] !== undefined && getMaskSet().validPositions[pos.begin].input === opts.groupSeparator) {
  2446. pos.end++;
  2447. }
  2448. }
  2449. revalidateMask(pos);
  2450. if (strict !== true && opts.keepStatic !== false || opts.regex !== null) {
  2451. var result = alternate(true);
  2452. if (result) {
  2453. var newPos = result.caret !== undefined ? result.caret : result.pos ? seekNext(result.pos.begin ? result.pos.begin : result.pos) : getLastValidPosition(-1, true);
  2454. if (k !== Inputmask.keyCode.DELETE || pos.begin > newPos) {
  2455. pos.begin == newPos;
  2456. }
  2457. }
  2458. }
  2459. var lvp = getLastValidPosition(pos.begin, true);
  2460. if (lvp < pos.begin || pos.begin === -1) {
  2461. getMaskSet().p = seekNext(lvp);
  2462. } else if (strict !== true) {
  2463. getMaskSet().p = pos.begin;
  2464. if (fromIsValid !== true) {
  2465. while (getMaskSet().p < lvp && getMaskSet().validPositions[getMaskSet().p] === undefined) {
  2466. getMaskSet().p++;
  2467. }
  2468. }
  2469. }
  2470. }
  2471. function initializeColorMask(input) {
  2472. var computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null);
  2473. function findCaretPos(clientx) {
  2474. var e = document.createElement("span"), caretPos;
  2475. for (var style in computedStyle) {
  2476. if (isNaN(style) && style.indexOf("font") !== -1) {
  2477. e.style[style] = computedStyle[style];
  2478. }
  2479. }
  2480. e.style.textTransform = computedStyle.textTransform;
  2481. e.style.letterSpacing = computedStyle.letterSpacing;
  2482. e.style.position = "absolute";
  2483. e.style.height = "auto";
  2484. e.style.width = "auto";
  2485. e.style.visibility = "hidden";
  2486. e.style.whiteSpace = "nowrap";
  2487. document.body.appendChild(e);
  2488. var inputText = input.inputmask._valueGet(), previousWidth = 0, itl;
  2489. for (caretPos = 0, itl = inputText.length; caretPos <= itl; caretPos++) {
  2490. e.innerHTML += inputText.charAt(caretPos) || "_";
  2491. if (e.offsetWidth >= clientx) {
  2492. var offset1 = clientx - previousWidth;
  2493. var offset2 = e.offsetWidth - clientx;
  2494. e.innerHTML = inputText.charAt(caretPos);
  2495. offset1 -= e.offsetWidth / 3;
  2496. caretPos = offset1 < offset2 ? caretPos - 1 : caretPos;
  2497. break;
  2498. }
  2499. previousWidth = e.offsetWidth;
  2500. }
  2501. document.body.removeChild(e);
  2502. return caretPos;
  2503. }
  2504. var template = document.createElement("div");
  2505. template.style.width = computedStyle.width;
  2506. template.style.textAlign = computedStyle.textAlign;
  2507. colorMask = document.createElement("div");
  2508. input.inputmask.colorMask = colorMask;
  2509. colorMask.className = "im-colormask";
  2510. input.parentNode.insertBefore(colorMask, input);
  2511. input.parentNode.removeChild(input);
  2512. colorMask.appendChild(input);
  2513. colorMask.appendChild(template);
  2514. input.style.left = template.offsetLeft + "px";
  2515. $(colorMask).on("mouseleave", function(e) {
  2516. return EventHandlers.mouseleaveEvent.call(input, [ e ]);
  2517. });
  2518. $(colorMask).on("mouseenter", function(e) {
  2519. return EventHandlers.mouseenterEvent.call(input, [ e ]);
  2520. });
  2521. $(colorMask).on("click", function(e) {
  2522. caret(input, findCaretPos(e.clientX));
  2523. return EventHandlers.clickEvent.call(input, [ e ]);
  2524. });
  2525. }
  2526. Inputmask.prototype.positionColorMask = function(input, template) {
  2527. input.style.left = template.offsetLeft + "px";
  2528. };
  2529. function renderColorMask(input, caretPos, clear) {
  2530. var maskTemplate = [], isStatic = false, test, testPos, ndxIntlzr, pos = 0;
  2531. function setEntry(entry) {
  2532. if (entry === undefined) entry = "";
  2533. if (!isStatic && (test.fn === null || testPos.input === undefined)) {
  2534. isStatic = true;
  2535. maskTemplate.push("<span class='im-static'>" + entry);
  2536. } else if (isStatic && (test.fn !== null && testPos.input !== undefined || test.def === "")) {
  2537. isStatic = false;
  2538. var mtl = maskTemplate.length;
  2539. maskTemplate[mtl - 1] = maskTemplate[mtl - 1] + "</span>";
  2540. maskTemplate.push(entry);
  2541. } else maskTemplate.push(entry);
  2542. }
  2543. function setCaret() {
  2544. if (document.activeElement === input) {
  2545. 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">');
  2546. maskTemplate.splice(caretPos.end + 1, 0, "</mark>");
  2547. }
  2548. }
  2549. if (colorMask !== undefined) {
  2550. var buffer = getBuffer();
  2551. if (caretPos === undefined) {
  2552. caretPos = caret(input);
  2553. } else if (caretPos.begin === undefined) {
  2554. caretPos = {
  2555. begin: caretPos,
  2556. end: caretPos
  2557. };
  2558. }
  2559. if (clear !== true) {
  2560. var lvp = getLastValidPosition();
  2561. do {
  2562. if (getMaskSet().validPositions[pos]) {
  2563. testPos = getMaskSet().validPositions[pos];
  2564. test = testPos.match;
  2565. ndxIntlzr = testPos.locator.slice();
  2566. setEntry(buffer[pos]);
  2567. } else {
  2568. testPos = getTestTemplate(pos, ndxIntlzr, pos - 1);
  2569. test = testPos.match;
  2570. ndxIntlzr = testPos.locator.slice();
  2571. if (opts.jitMasking === false || pos < lvp || typeof opts.jitMasking === "number" && isFinite(opts.jitMasking) && opts.jitMasking > pos) {
  2572. setEntry(getPlaceholder(pos, test));
  2573. } else isStatic = false;
  2574. }
  2575. pos++;
  2576. } while ((maxLength === undefined || pos < maxLength) && (test.fn !== null || test.def !== "") || lvp > pos || isStatic);
  2577. if (isStatic) setEntry();
  2578. setCaret();
  2579. }
  2580. var template = colorMask.getElementsByTagName("div")[0];
  2581. template.innerHTML = maskTemplate.join("");
  2582. input.inputmask.positionColorMask(input, template);
  2583. }
  2584. }
  2585. function mask(elem) {
  2586. function isElementTypeSupported(input, opts) {
  2587. function patchValueProperty(npt) {
  2588. var valueGet;
  2589. var valueSet;
  2590. function patchValhook(type) {
  2591. if ($.valHooks && ($.valHooks[type] === undefined || $.valHooks[type].inputmaskpatch !== true)) {
  2592. var valhookGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function(elem) {
  2593. return elem.value;
  2594. };
  2595. var valhookSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function(elem, value) {
  2596. elem.value = value;
  2597. return elem;
  2598. };
  2599. $.valHooks[type] = {
  2600. get: function get(elem) {
  2601. if (elem.inputmask) {
  2602. if (elem.inputmask.opts.autoUnmask) {
  2603. return elem.inputmask.unmaskedvalue();
  2604. } else {
  2605. var result = valhookGet(elem);
  2606. return getLastValidPosition(undefined, undefined, elem.inputmask.maskset.validPositions) !== -1 || opts.nullable !== true ? result : "";
  2607. }
  2608. } else return valhookGet(elem);
  2609. },
  2610. set: function set(elem, value) {
  2611. var $elem = $(elem), result;
  2612. result = valhookSet(elem, value);
  2613. if (elem.inputmask) {
  2614. $elem.trigger("setvalue", [ value ]);
  2615. }
  2616. return result;
  2617. },
  2618. inputmaskpatch: true
  2619. };
  2620. }
  2621. }
  2622. function getter() {
  2623. if (this.inputmask) {
  2624. 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) : "";
  2625. } else return valueGet.call(this);
  2626. }
  2627. function setter(value) {
  2628. valueSet.call(this, value);
  2629. if (this.inputmask) {
  2630. $(this).trigger("setvalue", [ value ]);
  2631. }
  2632. }
  2633. function installNativeValueSetFallback(npt) {
  2634. EventRuler.on(npt, "mouseenter", function(event) {
  2635. var $input = $(this), input = this, value = input.inputmask._valueGet();
  2636. if (value !== getBuffer().join("")) {
  2637. $input.trigger("setvalue");
  2638. }
  2639. });
  2640. }
  2641. if (!npt.inputmask.__valueGet) {
  2642. if (opts.noValuePatching !== true) {
  2643. if (Object.getOwnPropertyDescriptor) {
  2644. if (typeof Object.getPrototypeOf !== "function") {
  2645. Object.getPrototypeOf = _typeof("test".__proto__) === "object" ? function(object) {
  2646. return object.__proto__;
  2647. } : function(object) {
  2648. return object.constructor.prototype;
  2649. };
  2650. }
  2651. var valueProperty = Object.getPrototypeOf ? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(npt), "value") : undefined;
  2652. if (valueProperty && valueProperty.get && valueProperty.set) {
  2653. valueGet = valueProperty.get;
  2654. valueSet = valueProperty.set;
  2655. Object.defineProperty(npt, "value", {
  2656. get: getter,
  2657. set: setter,
  2658. configurable: true
  2659. });
  2660. } else if (npt.tagName !== "INPUT") {
  2661. valueGet = function valueGet() {
  2662. return this.textContent;
  2663. };
  2664. valueSet = function valueSet(value) {
  2665. this.textContent = value;
  2666. };
  2667. Object.defineProperty(npt, "value", {
  2668. get: getter,
  2669. set: setter,
  2670. configurable: true
  2671. });
  2672. }
  2673. } else if (document.__lookupGetter__ && npt.__lookupGetter__("value")) {
  2674. valueGet = npt.__lookupGetter__("value");
  2675. valueSet = npt.__lookupSetter__("value");
  2676. npt.__defineGetter__("value", getter);
  2677. npt.__defineSetter__("value", setter);
  2678. }
  2679. npt.inputmask.__valueGet = valueGet;
  2680. npt.inputmask.__valueSet = valueSet;
  2681. }
  2682. npt.inputmask._valueGet = function(overruleRTL) {
  2683. return isRTL && overruleRTL !== true ? valueGet.call(this.el).split("").reverse().join("") : valueGet.call(this.el);
  2684. };
  2685. npt.inputmask._valueSet = function(value, overruleRTL) {
  2686. valueSet.call(this.el, value === null || value === undefined ? "" : overruleRTL !== true && isRTL ? value.split("").reverse().join("") : value);
  2687. };
  2688. if (valueGet === undefined) {
  2689. valueGet = function valueGet() {
  2690. return this.value;
  2691. };
  2692. valueSet = function valueSet(value) {
  2693. this.value = value;
  2694. };
  2695. patchValhook(npt.type);
  2696. installNativeValueSetFallback(npt);
  2697. }
  2698. }
  2699. }
  2700. var elementType = input.getAttribute("type");
  2701. var isSupported = input.tagName === "INPUT" && $.inArray(elementType, opts.supportsInputType) !== -1 || input.isContentEditable || input.tagName === "TEXTAREA";
  2702. if (!isSupported) {
  2703. if (input.tagName === "INPUT") {
  2704. var el = document.createElement("input");
  2705. el.setAttribute("type", elementType);
  2706. isSupported = el.type === "text";
  2707. el = null;
  2708. } else isSupported = "partial";
  2709. }
  2710. if (isSupported !== false) {
  2711. patchValueProperty(input);
  2712. } else input.inputmask = undefined;
  2713. return isSupported;
  2714. }
  2715. EventRuler.off(elem);
  2716. var isSupported = isElementTypeSupported(elem, opts);
  2717. if (isSupported !== false) {
  2718. el = elem;
  2719. $el = $(el);
  2720. originalPlaceholder = el.placeholder;
  2721. maxLength = el !== undefined ? el.maxLength : undefined;
  2722. if (maxLength === -1) maxLength = undefined;
  2723. if (opts.colorMask === true) {
  2724. initializeColorMask(el);
  2725. }
  2726. if (mobile) {
  2727. if ("inputmode" in el) {
  2728. el.inputmode = opts.inputmode;
  2729. el.setAttribute("inputmode", opts.inputmode);
  2730. }
  2731. if (opts.disablePredictiveText === true) {
  2732. if ("autocorrect" in el) {
  2733. el.autocorrect = false;
  2734. } else {
  2735. if (opts.colorMask !== true) {
  2736. initializeColorMask(el);
  2737. }
  2738. el.type = "password";
  2739. }
  2740. }
  2741. }
  2742. if (isSupported === true) {
  2743. el.setAttribute("im-insert", opts.insertMode);
  2744. EventRuler.on(el, "submit", EventHandlers.submitEvent);
  2745. EventRuler.on(el, "reset", EventHandlers.resetEvent);
  2746. EventRuler.on(el, "blur", EventHandlers.blurEvent);
  2747. EventRuler.on(el, "focus", EventHandlers.focusEvent);
  2748. if (opts.colorMask !== true) {
  2749. EventRuler.on(el, "click", EventHandlers.clickEvent);
  2750. EventRuler.on(el, "mouseleave", EventHandlers.mouseleaveEvent);
  2751. EventRuler.on(el, "mouseenter", EventHandlers.mouseenterEvent);
  2752. }
  2753. EventRuler.on(el, "paste", EventHandlers.pasteEvent);
  2754. EventRuler.on(el, "cut", EventHandlers.cutEvent);
  2755. EventRuler.on(el, "complete", opts.oncomplete);
  2756. EventRuler.on(el, "incomplete", opts.onincomplete);
  2757. EventRuler.on(el, "cleared", opts.oncleared);
  2758. if (!mobile && opts.inputEventOnly !== true) {
  2759. EventRuler.on(el, "keydown", EventHandlers.keydownEvent);
  2760. EventRuler.on(el, "keypress", EventHandlers.keypressEvent);
  2761. } else {
  2762. el.removeAttribute("maxLength");
  2763. }
  2764. EventRuler.on(el, "input", EventHandlers.inputFallBackEvent);
  2765. EventRuler.on(el, "beforeinput", EventHandlers.beforeInputEvent);
  2766. }
  2767. EventRuler.on(el, "setvalue", EventHandlers.setValueEvent);
  2768. undoValue = getBufferTemplate().join("");
  2769. if (el.inputmask._valueGet(true) !== "" || opts.clearMaskOnLostFocus === false || document.activeElement === el) {
  2770. var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(inputmask, el.inputmask._valueGet(true), opts) || el.inputmask._valueGet(true) : el.inputmask._valueGet(true);
  2771. if (initialValue !== "") checkVal(el, true, false, initialValue.split(""));
  2772. var buffer = getBuffer().slice();
  2773. undoValue = buffer.join("");
  2774. if (isComplete(buffer) === false) {
  2775. if (opts.clearIncomplete) {
  2776. resetMaskSet();
  2777. }
  2778. }
  2779. if (opts.clearMaskOnLostFocus && document.activeElement !== el) {
  2780. if (getLastValidPosition() === -1) {
  2781. buffer = [];
  2782. } else {
  2783. clearOptionalTail(buffer);
  2784. }
  2785. }
  2786. if (opts.clearMaskOnLostFocus === false || opts.showMaskOnFocus && document.activeElement === el || el.inputmask._valueGet(true) !== "") writeBuffer(el, buffer);
  2787. if (document.activeElement === el) {
  2788. caret(el, seekNext(getLastValidPosition()));
  2789. }
  2790. }
  2791. }
  2792. }
  2793. var valueBuffer;
  2794. if (actionObj !== undefined) {
  2795. switch (actionObj.action) {
  2796. case "isComplete":
  2797. el = actionObj.el;
  2798. return isComplete(getBuffer());
  2799. case "unmaskedvalue":
  2800. if (el === undefined || actionObj.value !== undefined) {
  2801. valueBuffer = actionObj.value;
  2802. valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(inputmask, valueBuffer, opts) || valueBuffer : valueBuffer).split("");
  2803. checkVal.call(this, undefined, false, false, valueBuffer);
  2804. if ($.isFunction(opts.onBeforeWrite)) opts.onBeforeWrite.call(inputmask, undefined, getBuffer(), 0, opts);
  2805. }
  2806. return unmaskedvalue(el);
  2807. case "mask":
  2808. mask(el);
  2809. break;
  2810. case "format":
  2811. valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(inputmask, actionObj.value, opts) || actionObj.value : actionObj.value).split("");
  2812. checkVal.call(this, undefined, true, false, valueBuffer);
  2813. if (actionObj.metadata) {
  2814. return {
  2815. value: isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join(""),
  2816. metadata: maskScope.call(this, {
  2817. action: "getmetadata"
  2818. }, maskset, opts)
  2819. };
  2820. }
  2821. return isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join("");
  2822. case "isValid":
  2823. if (actionObj.value) {
  2824. valueBuffer = actionObj.value.split("");
  2825. checkVal.call(this, undefined, true, true, valueBuffer);
  2826. } else {
  2827. actionObj.value = getBuffer().join("");
  2828. }
  2829. var buffer = getBuffer();
  2830. var rl = determineLastRequiredPosition(), lmib = buffer.length - 1;
  2831. for (;lmib > rl; lmib--) {
  2832. if (isMask(lmib)) break;
  2833. }
  2834. buffer.splice(rl, lmib + 1 - rl);
  2835. return isComplete(buffer) && actionObj.value === getBuffer().join("");
  2836. case "getemptymask":
  2837. return getBufferTemplate().join("");
  2838. case "remove":
  2839. if (el && el.inputmask) {
  2840. $.data(el, "_inputmask_opts", null);
  2841. $el = $(el);
  2842. el.inputmask._valueSet(opts.autoUnmask ? unmaskedvalue(el) : el.inputmask._valueGet(true));
  2843. EventRuler.off(el);
  2844. if (el.inputmask.colorMask) {
  2845. colorMask = el.inputmask.colorMask;
  2846. colorMask.removeChild(el);
  2847. colorMask.parentNode.insertBefore(el, colorMask);
  2848. colorMask.parentNode.removeChild(colorMask);
  2849. }
  2850. var valueProperty;
  2851. if (Object.getOwnPropertyDescriptor && Object.getPrototypeOf) {
  2852. valueProperty = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(el), "value");
  2853. if (valueProperty) {
  2854. if (el.inputmask.__valueGet) {
  2855. Object.defineProperty(el, "value", {
  2856. get: el.inputmask.__valueGet,
  2857. set: el.inputmask.__valueSet,
  2858. configurable: true
  2859. });
  2860. }
  2861. }
  2862. } else if (document.__lookupGetter__ && el.__lookupGetter__("value")) {
  2863. if (el.inputmask.__valueGet) {
  2864. el.__defineGetter__("value", el.inputmask.__valueGet);
  2865. el.__defineSetter__("value", el.inputmask.__valueSet);
  2866. }
  2867. }
  2868. el.inputmask = undefined;
  2869. }
  2870. return el;
  2871. break;
  2872. case "getmetadata":
  2873. if ($.isArray(maskset.metadata)) {
  2874. var maskTarget = getMaskTemplate(true, 0, false).join("");
  2875. $.each(maskset.metadata, function(ndx, mtdt) {
  2876. if (mtdt.mask === maskTarget) {
  2877. maskTarget = mtdt;
  2878. return false;
  2879. }
  2880. });
  2881. return maskTarget;
  2882. }
  2883. return maskset.metadata;
  2884. }
  2885. }
  2886. }
  2887. return Inputmask;
  2888. });
  2889. }, function(module, exports, __webpack_require__) {
  2890. "use strict";
  2891. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
  2892. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) {
  2893. return typeof obj;
  2894. } : function(obj) {
  2895. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  2896. };
  2897. (function(factory) {
  2898. if (true) {
  2899. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(4) ], __WEBPACK_AMD_DEFINE_FACTORY__ = factory,
  2900. __WEBPACK_AMD_DEFINE_RESULT__ = typeof __WEBPACK_AMD_DEFINE_FACTORY__ === "function" ? __WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__) : __WEBPACK_AMD_DEFINE_FACTORY__,
  2901. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  2902. } else {}
  2903. })(function($) {
  2904. return $;
  2905. });
  2906. }, function(module, exports) {
  2907. module.exports = jQuery;
  2908. }, function(module, exports, __webpack_require__) {
  2909. "use strict";
  2910. var __WEBPACK_AMD_DEFINE_RESULT__;
  2911. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) {
  2912. return typeof obj;
  2913. } : function(obj) {
  2914. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  2915. };
  2916. if (true) !(__WEBPACK_AMD_DEFINE_RESULT__ = function() {
  2917. return window || new (eval("require('jsdom')")("").window)();
  2918. }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); else {}
  2919. }, function(module, exports, __webpack_require__) {
  2920. "use strict";
  2921. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
  2922. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) {
  2923. return typeof obj;
  2924. } : function(obj) {
  2925. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  2926. };
  2927. (function(factory) {
  2928. if (true) {
  2929. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(2) ], __WEBPACK_AMD_DEFINE_FACTORY__ = factory,
  2930. __WEBPACK_AMD_DEFINE_RESULT__ = typeof __WEBPACK_AMD_DEFINE_FACTORY__ === "function" ? __WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__) : __WEBPACK_AMD_DEFINE_FACTORY__,
  2931. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  2932. } else {}
  2933. })(function(Inputmask) {
  2934. var $ = Inputmask.dependencyLib;
  2935. var formatCode = {
  2936. d: [ "[1-9]|[12][0-9]|3[01]", Date.prototype.setDate, "day", Date.prototype.getDate ],
  2937. dd: [ "0[1-9]|[12][0-9]|3[01]", Date.prototype.setDate, "day", function() {
  2938. return pad(Date.prototype.getDate.call(this), 2);
  2939. } ],
  2940. ddd: [ "" ],
  2941. dddd: [ "" ],
  2942. m: [ "[1-9]|1[012]", Date.prototype.setMonth, "month", function() {
  2943. return Date.prototype.getMonth.call(this) + 1;
  2944. } ],
  2945. mm: [ "0[1-9]|1[012]", Date.prototype.setMonth, "month", function() {
  2946. return pad(Date.prototype.getMonth.call(this) + 1, 2);
  2947. } ],
  2948. mmm: [ "" ],
  2949. mmmm: [ "" ],
  2950. yy: [ "[0-9]{2}", Date.prototype.setFullYear, "year", function() {
  2951. return pad(Date.prototype.getFullYear.call(this), 2);
  2952. } ],
  2953. yyyy: [ "[0-9]{4}", Date.prototype.setFullYear, "year", function() {
  2954. return pad(Date.prototype.getFullYear.call(this), 4);
  2955. } ],
  2956. h: [ "[1-9]|1[0-2]", Date.prototype.setHours, "hours", Date.prototype.getHours ],
  2957. hh: [ "0[1-9]|1[0-2]", Date.prototype.setHours, "hours", function() {
  2958. return pad(Date.prototype.getHours.call(this), 2);
  2959. } ],
  2960. hhh: [ "[0-9]+", Date.prototype.setHours, "hours", Date.prototype.getHours ],
  2961. H: [ "1?[0-9]|2[0-3]", Date.prototype.setHours, "hours", Date.prototype.getHours ],
  2962. HH: [ "[01][0-9]|2[0-3]", Date.prototype.setHours, "hours", function() {
  2963. return pad(Date.prototype.getHours.call(this), 2);
  2964. } ],
  2965. HHH: [ "[0-9]+", Date.prototype.setHours, "hours", Date.prototype.getHours ],
  2966. M: [ "[1-5]?[0-9]", Date.prototype.setMinutes, "minutes", Date.prototype.getMinutes ],
  2967. MM: [ "[0-5][0-9]", Date.prototype.setMinutes, "minutes", function() {
  2968. return pad(Date.prototype.getMinutes.call(this), 2);
  2969. } ],
  2970. s: [ "[1-5]?[0-9]", Date.prototype.setSeconds, "seconds", Date.prototype.getSeconds ],
  2971. ss: [ "[0-5][0-9]", Date.prototype.setSeconds, "seconds", function() {
  2972. return pad(Date.prototype.getSeconds.call(this), 2);
  2973. } ],
  2974. l: [ "[0-9]{3}", Date.prototype.setMilliseconds, "milliseconds", function() {
  2975. return pad(Date.prototype.getMilliseconds.call(this), 3);
  2976. } ],
  2977. L: [ "[0-9]{2}", Date.prototype.setMilliseconds, "milliseconds", function() {
  2978. return pad(Date.prototype.getMilliseconds.call(this), 2);
  2979. } ],
  2980. t: [ "[ap]" ],
  2981. tt: [ "[ap]m" ],
  2982. T: [ "[AP]" ],
  2983. TT: [ "[AP]M" ],
  2984. Z: [ "" ],
  2985. o: [ "" ],
  2986. S: [ "" ]
  2987. }, formatAlias = {
  2988. isoDate: "yyyy-mm-dd",
  2989. isoTime: "HH:MM:ss",
  2990. isoDateTime: "yyyy-mm-dd'T'HH:MM:ss",
  2991. isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
  2992. };
  2993. function getTokenizer(opts) {
  2994. if (!opts.tokenizer) {
  2995. var tokens = [];
  2996. for (var ndx in formatCode) {
  2997. if (tokens.indexOf(ndx[0]) === -1) tokens.push(ndx[0]);
  2998. }
  2999. opts.tokenizer = "(" + tokens.join("+|") + ")+?|.";
  3000. opts.tokenizer = new RegExp(opts.tokenizer, "g");
  3001. }
  3002. return opts.tokenizer;
  3003. }
  3004. function isValidDate(dateParts, currentResult) {
  3005. 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;
  3006. }
  3007. function isDateInRange(dateParts, opts) {
  3008. var result = true;
  3009. if (opts.min) {
  3010. if (dateParts["rawyear"]) {
  3011. var rawYear = dateParts["rawyear"].replace(/[^0-9]/g, ""), minYear = opts.min.year.substr(0, rawYear.length);
  3012. result = minYear <= rawYear;
  3013. }
  3014. if (dateParts["year"] === dateParts["rawyear"]) {
  3015. if (opts.min.date.getTime() === opts.min.date.getTime()) {
  3016. result = opts.min.date.getTime() <= dateParts.date.getTime();
  3017. }
  3018. }
  3019. }
  3020. if (result && opts.max && opts.max.date.getTime() === opts.max.date.getTime()) {
  3021. result = opts.max.date.getTime() >= dateParts.date.getTime();
  3022. }
  3023. return result;
  3024. }
  3025. function parse(format, dateObjValue, opts, raw) {
  3026. var mask = "", match;
  3027. while (match = getTokenizer(opts).exec(format)) {
  3028. if (dateObjValue === undefined) {
  3029. if (formatCode[match[0]]) {
  3030. mask += "(" + formatCode[match[0]][0] + ")";
  3031. } else {
  3032. switch (match[0]) {
  3033. case "[":
  3034. mask += "(";
  3035. break;
  3036. case "]":
  3037. mask += ")?";
  3038. break;
  3039. default:
  3040. mask += Inputmask.escapeRegex(match[0]);
  3041. }
  3042. }
  3043. } else {
  3044. if (formatCode[match[0]]) {
  3045. if (raw !== true && formatCode[match[0]][3]) {
  3046. var getFn = formatCode[match[0]][3];
  3047. mask += getFn.call(dateObjValue.date);
  3048. } else if (formatCode[match[0]][2]) mask += dateObjValue["raw" + formatCode[match[0]][2]]; else mask += match[0];
  3049. } else mask += match[0];
  3050. }
  3051. }
  3052. return mask;
  3053. }
  3054. function pad(val, len) {
  3055. val = String(val);
  3056. len = len || 2;
  3057. while (val.length < len) {
  3058. val = "0" + val;
  3059. }
  3060. return val;
  3061. }
  3062. function analyseMask(maskString, format, opts) {
  3063. var dateObj = {
  3064. date: new Date(1, 0, 1)
  3065. }, targetProp, mask = maskString, match, dateOperation, targetValidator;
  3066. function extendProperty(value) {
  3067. var correctedValue = value.replace(/[^0-9]/g, "0");
  3068. if (correctedValue != value) {
  3069. var enteredPart = value.replace(/[^0-9]/g, ""), min = (opts.min && opts.min[targetProp] || value).toString(), max = (opts.max && opts.max[targetProp] || value).toString();
  3070. correctedValue = enteredPart + (enteredPart < min.slice(0, enteredPart.length) ? min.slice(enteredPart.length) : enteredPart > max.slice(0, enteredPart.length) ? max.slice(enteredPart.length) : correctedValue.toString().slice(enteredPart.length));
  3071. }
  3072. return correctedValue;
  3073. }
  3074. function setValue(dateObj, value, opts) {
  3075. dateObj[targetProp] = extendProperty(value);
  3076. dateObj["raw" + targetProp] = value;
  3077. if (dateOperation !== undefined) dateOperation.call(dateObj.date, targetProp == "month" ? parseInt(dateObj[targetProp]) - 1 : dateObj[targetProp]);
  3078. }
  3079. if (typeof mask === "string") {
  3080. while (match = getTokenizer(opts).exec(format)) {
  3081. var value = mask.slice(0, match[0].length);
  3082. if (formatCode.hasOwnProperty(match[0])) {
  3083. targetValidator = formatCode[match[0]][0];
  3084. targetProp = formatCode[match[0]][2];
  3085. dateOperation = formatCode[match[0]][1];
  3086. setValue(dateObj, value, opts);
  3087. }
  3088. mask = mask.slice(value.length);
  3089. }
  3090. return dateObj;
  3091. } else if (mask && (typeof mask === "undefined" ? "undefined" : _typeof(mask)) === "object" && mask.hasOwnProperty("date")) {
  3092. return mask;
  3093. }
  3094. return undefined;
  3095. }
  3096. Inputmask.extendAliases({
  3097. datetime: {
  3098. mask: function mask(opts) {
  3099. formatCode.S = opts.i18n.ordinalSuffix.join("|");
  3100. opts.inputFormat = formatAlias[opts.inputFormat] || opts.inputFormat;
  3101. opts.displayFormat = formatAlias[opts.displayFormat] || opts.displayFormat || opts.inputFormat;
  3102. opts.outputFormat = formatAlias[opts.outputFormat] || opts.outputFormat || opts.inputFormat;
  3103. opts.placeholder = opts.placeholder !== "" ? opts.placeholder : opts.inputFormat.replace(/[\[\]]/, "");
  3104. opts.regex = parse(opts.inputFormat, undefined, opts);
  3105. return null;
  3106. },
  3107. placeholder: "",
  3108. inputFormat: "isoDateTime",
  3109. displayFormat: undefined,
  3110. outputFormat: undefined,
  3111. min: null,
  3112. max: null,
  3113. i18n: {
  3114. dayNames: [ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ],
  3115. 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" ],
  3116. ordinalSuffix: [ "st", "nd", "rd", "th" ]
  3117. },
  3118. postValidation: function postValidation(buffer, pos, currentResult, opts) {
  3119. opts.min = analyseMask(opts.min, opts.inputFormat, opts);
  3120. opts.max = analyseMask(opts.max, opts.inputFormat, opts);
  3121. var result = currentResult, dateParts = analyseMask(buffer.join(""), opts.inputFormat, opts);
  3122. if (result && dateParts.date.getTime() === dateParts.date.getTime()) {
  3123. result = isValidDate(dateParts, result);
  3124. result = result && isDateInRange(dateParts, opts);
  3125. }
  3126. if (pos && result && currentResult.pos !== pos) {
  3127. return {
  3128. buffer: parse(opts.inputFormat, dateParts, opts),
  3129. refreshFromBuffer: {
  3130. start: pos,
  3131. end: currentResult.pos
  3132. }
  3133. };
  3134. }
  3135. return result;
  3136. },
  3137. onKeyDown: function onKeyDown(e, buffer, caretPos, opts) {
  3138. var input = this;
  3139. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  3140. var today = new Date(), match, date = "";
  3141. while (match = getTokenizer(opts).exec(opts.inputFormat)) {
  3142. if (match[0].charAt(0) === "d") {
  3143. date += pad(today.getDate(), match[0].length);
  3144. } else if (match[0].charAt(0) === "m") {
  3145. date += pad(today.getMonth() + 1, match[0].length);
  3146. } else if (match[0] === "yyyy") {
  3147. date += today.getFullYear().toString();
  3148. } else if (match[0].charAt(0) === "y") {
  3149. date += pad(today.getYear(), match[0].length);
  3150. }
  3151. }
  3152. input.inputmask._valueSet(date);
  3153. $(input).trigger("setvalue");
  3154. }
  3155. },
  3156. onUnMask: function onUnMask(maskedValue, unmaskedValue, opts) {
  3157. return parse(opts.outputFormat, analyseMask(maskedValue, opts.inputFormat, opts), opts, true);
  3158. },
  3159. casing: function casing(elem, test, pos, validPositions) {
  3160. if (test.nativeDef.indexOf("[ap]") == 0) return elem.toLowerCase();
  3161. if (test.nativeDef.indexOf("[AP]") == 0) return elem.toUpperCase();
  3162. return elem;
  3163. },
  3164. insertMode: false
  3165. }
  3166. });
  3167. return Inputmask;
  3168. });
  3169. }, function(module, exports, __webpack_require__) {
  3170. "use strict";
  3171. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
  3172. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) {
  3173. return typeof obj;
  3174. } : function(obj) {
  3175. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  3176. };
  3177. (function(factory) {
  3178. if (true) {
  3179. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(2) ], __WEBPACK_AMD_DEFINE_FACTORY__ = factory,
  3180. __WEBPACK_AMD_DEFINE_RESULT__ = typeof __WEBPACK_AMD_DEFINE_FACTORY__ === "function" ? __WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__) : __WEBPACK_AMD_DEFINE_FACTORY__,
  3181. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  3182. } else {}
  3183. })(function(Inputmask) {
  3184. var $ = Inputmask.dependencyLib;
  3185. function autoEscape(txt, opts) {
  3186. var escapedTxt = "";
  3187. for (var i = 0; i < txt.length; i++) {
  3188. 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)) {
  3189. escapedTxt += "\\" + txt.charAt(i);
  3190. } else escapedTxt += txt.charAt(i);
  3191. }
  3192. return escapedTxt;
  3193. }
  3194. function alignDigits(buffer, opts) {
  3195. if (opts.numericInput) {
  3196. var radixPosition = $.inArray(opts.radixPoint, buffer);
  3197. if (radixPosition === -1) {
  3198. buffer.push(opts.radixPoint);
  3199. radixPosition = buffer.length - 1;
  3200. }
  3201. for (var i = 1; i <= opts.digits; i++) {
  3202. buffer[radixPosition + i] = buffer[radixPosition + i] || "0";
  3203. }
  3204. }
  3205. return buffer;
  3206. }
  3207. Inputmask.extendAliases({
  3208. numeric: {
  3209. mask: function mask(opts) {
  3210. if (opts.repeat !== 0 && isNaN(opts.integerDigits)) {
  3211. opts.integerDigits = opts.repeat;
  3212. }
  3213. opts.repeat = 0;
  3214. if (opts.groupSeparator === opts.radixPoint && opts.digits && opts.digits !== "0") {
  3215. if (opts.radixPoint === ".") {
  3216. opts.groupSeparator = ",";
  3217. } else if (opts.radixPoint === ",") {
  3218. opts.groupSeparator = ".";
  3219. } else opts.groupSeparator = "";
  3220. }
  3221. if (opts.groupSeparator === " ") {
  3222. opts.skipOptionalPartCharacter = undefined;
  3223. }
  3224. opts.autoGroup = opts.autoGroup && opts.groupSeparator !== "";
  3225. if (opts.autoGroup) {
  3226. if (typeof opts.groupSize == "string" && isFinite(opts.groupSize)) opts.groupSize = parseInt(opts.groupSize);
  3227. if (isFinite(opts.integerDigits)) {
  3228. var seps = Math.floor(opts.integerDigits / opts.groupSize);
  3229. var mod = opts.integerDigits % opts.groupSize;
  3230. opts.integerDigits = parseInt(opts.integerDigits) + (mod === 0 ? seps - 1 : seps);
  3231. if (opts.integerDigits < 1) {
  3232. opts.integerDigits = "*";
  3233. }
  3234. }
  3235. }
  3236. if (opts.placeholder.length > 1) {
  3237. opts.placeholder = opts.placeholder.charAt(0);
  3238. }
  3239. if (opts.positionCaretOnClick === "radixFocus" && opts.placeholder === "" && opts.integerOptional === false) {
  3240. opts.positionCaretOnClick = "lvp";
  3241. }
  3242. opts.definitions[";"] = opts.definitions["~"];
  3243. opts.definitions[";"].definitionSymbol = "~";
  3244. if (opts.numericInput === true) {
  3245. opts.positionCaretOnClick = opts.positionCaretOnClick === "radixFocus" ? "lvp" : opts.positionCaretOnClick;
  3246. opts.digitsOptional = false;
  3247. if (isNaN(opts.digits)) opts.digits = 2;
  3248. opts.decimalProtect = false;
  3249. }
  3250. var mask = "[+]";
  3251. mask += autoEscape(opts.prefix, opts);
  3252. if (opts.integerOptional === true) {
  3253. mask += "~{1," + opts.integerDigits + "}";
  3254. } else mask += "~{" + opts.integerDigits + "}";
  3255. if (opts.digits !== undefined) {
  3256. var radixDef = opts.decimalProtect ? ":" : opts.radixPoint;
  3257. var dq = opts.digits.toString().split(",");
  3258. if (isFinite(dq[0]) && dq[1] && isFinite(dq[1])) {
  3259. mask += radixDef + ";{" + opts.digits + "}";
  3260. } else if (isNaN(opts.digits) || parseInt(opts.digits) > 0) {
  3261. if (opts.digitsOptional) {
  3262. mask += "[" + radixDef + ";{1," + opts.digits + "}]";
  3263. } else mask += radixDef + ";{" + opts.digits + "}";
  3264. }
  3265. }
  3266. mask += autoEscape(opts.suffix, opts);
  3267. mask += "[-]";
  3268. opts.greedy = false;
  3269. return mask;
  3270. },
  3271. placeholder: "",
  3272. greedy: false,
  3273. digits: "*",
  3274. digitsOptional: true,
  3275. enforceDigitsOnBlur: false,
  3276. radixPoint: ".",
  3277. positionCaretOnClick: "radixFocus",
  3278. groupSize: 3,
  3279. groupSeparator: "",
  3280. autoGroup: false,
  3281. allowMinus: true,
  3282. negationSymbol: {
  3283. front: "-",
  3284. back: ""
  3285. },
  3286. integerDigits: "+",
  3287. integerOptional: true,
  3288. prefix: "",
  3289. suffix: "",
  3290. rightAlign: true,
  3291. decimalProtect: true,
  3292. min: null,
  3293. max: null,
  3294. step: 1,
  3295. insertMode: true,
  3296. autoUnmask: false,
  3297. unmaskAsNumber: false,
  3298. inputmode: "numeric",
  3299. preValidation: function preValidation(buffer, pos, c, isSelection, opts, maskset) {
  3300. if (c === "-" || c === opts.negationSymbol.front) {
  3301. if (opts.allowMinus !== true) return false;
  3302. opts.isNegative = opts.isNegative === undefined ? true : !opts.isNegative;
  3303. if (buffer.join("") === "") return true;
  3304. return {
  3305. caret: maskset.validPositions[pos] ? pos : undefined,
  3306. dopost: true
  3307. };
  3308. }
  3309. if (isSelection === false && c === opts.radixPoint && opts.digits !== undefined && (isNaN(opts.digits) || parseInt(opts.digits) > 0)) {
  3310. var radixPos = $.inArray(opts.radixPoint, buffer);
  3311. if (radixPos !== -1 && maskset.validPositions[radixPos] !== undefined) {
  3312. if (opts.numericInput === true) {
  3313. return pos === radixPos;
  3314. }
  3315. return {
  3316. caret: radixPos + 1
  3317. };
  3318. }
  3319. }
  3320. return true;
  3321. },
  3322. postValidation: function postValidation(buffer, pos, currentResult, opts) {
  3323. function buildPostMask(buffer, opts) {
  3324. var postMask = "";
  3325. postMask += "(" + opts.groupSeparator + "*{" + opts.groupSize + "}){*}";
  3326. if (opts.radixPoint !== "") {
  3327. var radixSplit = buffer.join("").split(opts.radixPoint);
  3328. if (radixSplit[1]) {
  3329. postMask += opts.radixPoint + "*{" + radixSplit[1].match(/^\d*\??\d*/)[0].length + "}";
  3330. }
  3331. }
  3332. return postMask;
  3333. }
  3334. var suffix = opts.suffix.split(""), prefix = opts.prefix.split("");
  3335. if (currentResult.pos === undefined && currentResult.caret !== undefined && currentResult.dopost !== true) return currentResult;
  3336. var caretPos = currentResult.caret !== undefined ? currentResult.caret : currentResult.pos;
  3337. var maskedValue = buffer.slice();
  3338. if (opts.numericInput) {
  3339. caretPos = maskedValue.length - caretPos - 1;
  3340. maskedValue = maskedValue.reverse();
  3341. }
  3342. var charAtPos = maskedValue[caretPos];
  3343. if (charAtPos === opts.groupSeparator) {
  3344. caretPos += 1;
  3345. charAtPos = maskedValue[caretPos];
  3346. }
  3347. if (caretPos === maskedValue.length - opts.suffix.length - 1 && charAtPos === opts.radixPoint) return currentResult;
  3348. if (charAtPos !== undefined) {
  3349. if (charAtPos !== opts.radixPoint && charAtPos !== opts.negationSymbol.front && charAtPos !== opts.negationSymbol.back) {
  3350. maskedValue[caretPos] = "?";
  3351. if (opts.prefix.length > 0 && caretPos >= (opts.isNegative === false ? 1 : 0) && caretPos < opts.prefix.length - 1 + (opts.isNegative === false ? 1 : 0)) {
  3352. prefix[caretPos - (opts.isNegative === false ? 1 : 0)] = "?";
  3353. } else if (opts.suffix.length > 0 && caretPos >= maskedValue.length - opts.suffix.length - (opts.isNegative === false ? 1 : 0)) {
  3354. suffix[caretPos - (maskedValue.length - opts.suffix.length - (opts.isNegative === false ? 1 : 0))] = "?";
  3355. }
  3356. }
  3357. }
  3358. prefix = prefix.join("");
  3359. suffix = suffix.join("");
  3360. var processValue = maskedValue.join("").replace(prefix, "");
  3361. processValue = processValue.replace(suffix, "");
  3362. processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
  3363. processValue = processValue.replace(new RegExp("[-" + Inputmask.escapeRegex(opts.negationSymbol.front) + "]", "g"), "");
  3364. processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), "");
  3365. if (isNaN(opts.placeholder)) {
  3366. processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.placeholder), "g"), "");
  3367. }
  3368. if (processValue.length > 1 && processValue.indexOf(opts.radixPoint) !== 1) {
  3369. if (charAtPos === "0") {
  3370. processValue = processValue.replace(/^\?/g, "");
  3371. }
  3372. processValue = processValue.replace(/^0/g, "");
  3373. }
  3374. if (processValue.charAt(0) === opts.radixPoint && opts.radixPoint !== "" && opts.numericInput !== true) {
  3375. processValue = "0" + processValue;
  3376. }
  3377. if (processValue !== "") {
  3378. processValue = processValue.split("");
  3379. if ((!opts.digitsOptional || opts.enforceDigitsOnBlur && currentResult.event === "blur") && isFinite(opts.digits)) {
  3380. var radixPosition = $.inArray(opts.radixPoint, processValue);
  3381. var rpb = $.inArray(opts.radixPoint, maskedValue);
  3382. if (radixPosition === -1) {
  3383. processValue.push(opts.radixPoint);
  3384. radixPosition = processValue.length - 1;
  3385. }
  3386. for (var i = 1; i <= opts.digits; i++) {
  3387. if ((!opts.digitsOptional || opts.enforceDigitsOnBlur && currentResult.event === "blur") && (processValue[radixPosition + i] === undefined || processValue[radixPosition + i] === opts.placeholder.charAt(0))) {
  3388. processValue[radixPosition + i] = currentResult.placeholder || opts.placeholder.charAt(0);
  3389. } else if (rpb !== -1 && maskedValue[rpb + i] !== undefined) {
  3390. processValue[radixPosition + i] = processValue[radixPosition + i] || maskedValue[rpb + i];
  3391. }
  3392. }
  3393. }
  3394. if (opts.autoGroup === true && opts.groupSeparator !== "" && (charAtPos !== opts.radixPoint || currentResult.pos !== undefined || currentResult.dopost)) {
  3395. var addRadix = processValue[processValue.length - 1] === opts.radixPoint && currentResult.c === opts.radixPoint;
  3396. processValue = Inputmask(buildPostMask(processValue, opts), {
  3397. numericInput: true,
  3398. jitMasking: true,
  3399. definitions: {
  3400. "*": {
  3401. validator: "[0-9?]",
  3402. cardinality: 1
  3403. }
  3404. }
  3405. }).format(processValue.join(""));
  3406. if (addRadix) processValue += opts.radixPoint;
  3407. if (processValue.charAt(0) === opts.groupSeparator) {
  3408. processValue.substr(1);
  3409. }
  3410. } else processValue = processValue.join("");
  3411. }
  3412. if (opts.isNegative && currentResult.event === "blur") {
  3413. opts.isNegative = processValue !== "0";
  3414. }
  3415. processValue = prefix + processValue;
  3416. processValue += suffix;
  3417. if (opts.isNegative) {
  3418. processValue = opts.negationSymbol.front + processValue;
  3419. processValue += opts.negationSymbol.back;
  3420. }
  3421. processValue = processValue.split("");
  3422. if (charAtPos !== undefined) {
  3423. if (charAtPos !== opts.radixPoint && charAtPos !== opts.negationSymbol.front && charAtPos !== opts.negationSymbol.back) {
  3424. caretPos = $.inArray("?", processValue);
  3425. if (caretPos > -1) {
  3426. processValue[caretPos] = charAtPos;
  3427. } else caretPos = currentResult.caret || 0;
  3428. } else if (charAtPos === opts.radixPoint || charAtPos === opts.negationSymbol.front || charAtPos === opts.negationSymbol.back) {
  3429. var newCaretPos = $.inArray(charAtPos, processValue);
  3430. if (newCaretPos !== -1) caretPos = newCaretPos;
  3431. }
  3432. }
  3433. if (opts.numericInput) {
  3434. caretPos = processValue.length - caretPos - 1;
  3435. processValue = processValue.reverse();
  3436. }
  3437. var rslt = {
  3438. caret: (charAtPos === undefined || currentResult.pos !== undefined) && caretPos !== undefined ? caretPos + (opts.numericInput ? -1 : 1) : caretPos,
  3439. buffer: processValue,
  3440. refreshFromBuffer: currentResult.dopost || buffer.join("") !== processValue.join("")
  3441. };
  3442. return rslt.refreshFromBuffer ? rslt : currentResult;
  3443. },
  3444. onBeforeWrite: function onBeforeWrite(e, buffer, caretPos, opts) {
  3445. function parseMinMaxOptions(opts) {
  3446. if (opts.parseMinMaxOptions === undefined) {
  3447. if (opts.min !== null) {
  3448. opts.min = opts.min.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
  3449. if (opts.radixPoint === ",") opts.min = opts.min.replace(opts.radixPoint, ".");
  3450. opts.min = isFinite(opts.min) ? parseFloat(opts.min) : NaN;
  3451. if (isNaN(opts.min)) opts.min = Number.MIN_VALUE;
  3452. }
  3453. if (opts.max !== null) {
  3454. opts.max = opts.max.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
  3455. if (opts.radixPoint === ",") opts.max = opts.max.replace(opts.radixPoint, ".");
  3456. opts.max = isFinite(opts.max) ? parseFloat(opts.max) : NaN;
  3457. if (isNaN(opts.max)) opts.max = Number.MAX_VALUE;
  3458. }
  3459. opts.parseMinMaxOptions = "done";
  3460. }
  3461. }
  3462. if (e) {
  3463. switch (e.type) {
  3464. case "keydown":
  3465. return opts.postValidation(buffer, caretPos, {
  3466. caret: caretPos,
  3467. dopost: true
  3468. }, opts);
  3469. case "blur":
  3470. case "checkval":
  3471. var unmasked;
  3472. parseMinMaxOptions(opts);
  3473. if (opts.min !== null || opts.max !== null) {
  3474. unmasked = opts.onUnMask(buffer.join(""), undefined, $.extend({}, opts, {
  3475. unmaskAsNumber: true
  3476. }));
  3477. if (opts.min !== null && unmasked < opts.min) {
  3478. opts.isNegative = opts.min < 0;
  3479. return opts.postValidation(opts.min.toString().replace(".", opts.radixPoint).split(""), caretPos, {
  3480. caret: caretPos,
  3481. dopost: true,
  3482. placeholder: "0"
  3483. }, opts);
  3484. } else if (opts.max !== null && unmasked > opts.max) {
  3485. opts.isNegative = opts.max < 0;
  3486. return opts.postValidation(opts.max.toString().replace(".", opts.radixPoint).split(""), caretPos, {
  3487. caret: caretPos,
  3488. dopost: true,
  3489. placeholder: "0"
  3490. }, opts);
  3491. }
  3492. }
  3493. return opts.postValidation(buffer, caretPos, {
  3494. caret: caretPos,
  3495. placeholder: "0",
  3496. event: "blur"
  3497. }, opts);
  3498. case "_checkval":
  3499. return {
  3500. caret: caretPos
  3501. };
  3502. default:
  3503. break;
  3504. }
  3505. }
  3506. },
  3507. regex: {
  3508. integerPart: function integerPart(opts, emptyCheck) {
  3509. return emptyCheck ? new RegExp("[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "+]?") : new RegExp("[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "+]?\\d+");
  3510. },
  3511. integerNPart: function integerNPart(opts) {
  3512. return new RegExp("[\\d" + Inputmask.escapeRegex(opts.groupSeparator) + Inputmask.escapeRegex(opts.placeholder.charAt(0)) + "]+");
  3513. }
  3514. },
  3515. definitions: {
  3516. "~": {
  3517. validator: function validator(chrs, maskset, pos, strict, opts, isSelection) {
  3518. var isValid, l;
  3519. if (chrs === "k" || chrs === "m") {
  3520. isValid = {
  3521. insert: [],
  3522. c: 0
  3523. };
  3524. for (var i = 0, l = chrs === "k" ? 2 : 5; i < l; i++) {
  3525. isValid.insert.push({
  3526. pos: pos + i,
  3527. c: 0
  3528. });
  3529. }
  3530. isValid.pos = pos + l;
  3531. return isValid;
  3532. }
  3533. isValid = strict ? new RegExp("[0-9" + Inputmask.escapeRegex(opts.groupSeparator) + "]").test(chrs) : new RegExp("[0-9]").test(chrs);
  3534. if (isValid === true) {
  3535. if (opts.numericInput !== true && maskset.validPositions[pos] !== undefined && maskset.validPositions[pos].match.def === "~" && !isSelection) {
  3536. var processValue = maskset.buffer.join("");
  3537. processValue = processValue.replace(new RegExp("[-" + Inputmask.escapeRegex(opts.negationSymbol.front) + "]", "g"), "");
  3538. processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), "");
  3539. var pvRadixSplit = processValue.split(opts.radixPoint);
  3540. if (pvRadixSplit.length > 1) {
  3541. pvRadixSplit[1] = pvRadixSplit[1].replace(/0/g, opts.placeholder.charAt(0));
  3542. }
  3543. if (pvRadixSplit[0] === "0") {
  3544. pvRadixSplit[0] = pvRadixSplit[0].replace(/0/g, opts.placeholder.charAt(0));
  3545. }
  3546. processValue = pvRadixSplit[0] + opts.radixPoint + pvRadixSplit[1] || "";
  3547. var bufferTemplate = maskset._buffer.join("");
  3548. if (processValue === opts.radixPoint) {
  3549. processValue = bufferTemplate;
  3550. }
  3551. while (processValue.match(Inputmask.escapeRegex(bufferTemplate) + "$") === null) {
  3552. bufferTemplate = bufferTemplate.slice(1);
  3553. }
  3554. processValue = processValue.replace(bufferTemplate, "");
  3555. processValue = processValue.split("");
  3556. if (processValue[pos] === undefined) {
  3557. isValid = {
  3558. pos: pos,
  3559. remove: pos
  3560. };
  3561. } else {
  3562. isValid = {
  3563. pos: pos
  3564. };
  3565. }
  3566. }
  3567. } else if (!strict && chrs === opts.radixPoint && maskset.validPositions[pos - 1] === undefined) {
  3568. isValid = {
  3569. insert: {
  3570. pos: pos,
  3571. c: 0
  3572. },
  3573. pos: pos + 1
  3574. };
  3575. }
  3576. return isValid;
  3577. },
  3578. cardinality: 1
  3579. },
  3580. "+": {
  3581. validator: function validator(chrs, maskset, pos, strict, opts) {
  3582. return opts.allowMinus && (chrs === "-" || chrs === opts.negationSymbol.front);
  3583. },
  3584. cardinality: 1,
  3585. placeholder: ""
  3586. },
  3587. "-": {
  3588. validator: function validator(chrs, maskset, pos, strict, opts) {
  3589. return opts.allowMinus && chrs === opts.negationSymbol.back;
  3590. },
  3591. cardinality: 1,
  3592. placeholder: ""
  3593. },
  3594. ":": {
  3595. validator: function validator(chrs, maskset, pos, strict, opts) {
  3596. var radix = "[" + Inputmask.escapeRegex(opts.radixPoint) + "]";
  3597. var isValid = new RegExp(radix).test(chrs);
  3598. if (isValid && maskset.validPositions[pos] && maskset.validPositions[pos].match.placeholder === opts.radixPoint) {
  3599. isValid = {
  3600. caret: pos + 1
  3601. };
  3602. }
  3603. return isValid;
  3604. },
  3605. cardinality: 1,
  3606. placeholder: function placeholder(opts) {
  3607. return opts.radixPoint;
  3608. }
  3609. }
  3610. },
  3611. onUnMask: function onUnMask(maskedValue, unmaskedValue, opts) {
  3612. if (unmaskedValue === "" && opts.nullable === true) {
  3613. return unmaskedValue;
  3614. }
  3615. var processValue = maskedValue.replace(opts.prefix, "");
  3616. processValue = processValue.replace(opts.suffix, "");
  3617. processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
  3618. if (opts.placeholder.charAt(0) !== "") {
  3619. processValue = processValue.replace(new RegExp(opts.placeholder.charAt(0), "g"), "0");
  3620. }
  3621. if (opts.unmaskAsNumber) {
  3622. if (opts.radixPoint !== "" && processValue.indexOf(opts.radixPoint) !== -1) processValue = processValue.replace(Inputmask.escapeRegex.call(this, opts.radixPoint), ".");
  3623. processValue = processValue.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), "-");
  3624. processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), "");
  3625. return Number(processValue);
  3626. }
  3627. return processValue;
  3628. },
  3629. isComplete: function isComplete(buffer, opts) {
  3630. var maskedValue = (opts.numericInput ? buffer.slice().reverse() : buffer).join("");
  3631. maskedValue = maskedValue.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), "-");
  3632. maskedValue = maskedValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), "");
  3633. maskedValue = maskedValue.replace(opts.prefix, "");
  3634. maskedValue = maskedValue.replace(opts.suffix, "");
  3635. maskedValue = maskedValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator) + "([0-9]{3})", "g"), "$1");
  3636. if (opts.radixPoint === ",") maskedValue = maskedValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".");
  3637. return isFinite(maskedValue);
  3638. },
  3639. onBeforeMask: function onBeforeMask(initialValue, opts) {
  3640. opts.isNegative = undefined;
  3641. if (typeof initialValue == "number" && opts.radixPoint !== "") {
  3642. initialValue = initialValue.toString().replace(".", opts.radixPoint);
  3643. }
  3644. initialValue = initialValue.toString().charAt(initialValue.length - 1) === opts.radixPoint ? initialValue.toString().substr(0, initialValue.length - 1) : initialValue.toString();
  3645. if (opts.radixPoint !== "" && isFinite(initialValue)) {
  3646. var vs = initialValue.split("."), groupSize = opts.groupSeparator !== "" ? parseInt(opts.groupSize) : 0;
  3647. if (vs.length === 2 && (vs[0].length > groupSize || vs[1].length > groupSize || vs[0].length <= groupSize && vs[1].length < groupSize)) {
  3648. initialValue = initialValue.replace(".", opts.radixPoint);
  3649. }
  3650. }
  3651. var kommaMatches = initialValue.match(/,/g);
  3652. var dotMatches = initialValue.match(/\./g);
  3653. if (dotMatches && kommaMatches) {
  3654. if (dotMatches.length > kommaMatches.length) {
  3655. initialValue = initialValue.replace(/\./g, "");
  3656. initialValue = initialValue.replace(",", opts.radixPoint);
  3657. } else if (kommaMatches.length > dotMatches.length) {
  3658. initialValue = initialValue.replace(/,/g, "");
  3659. initialValue = initialValue.replace(".", opts.radixPoint);
  3660. } else {
  3661. initialValue = initialValue.indexOf(".") < initialValue.indexOf(",") ? initialValue.replace(/\./g, "") : initialValue.replace(/,/g, "");
  3662. }
  3663. } else {
  3664. initialValue = initialValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
  3665. }
  3666. if (opts.digits === 0) {
  3667. if (initialValue.indexOf(".") !== -1) {
  3668. initialValue = initialValue.substring(0, initialValue.indexOf("."));
  3669. } else if (initialValue.indexOf(",") !== -1) {
  3670. initialValue = initialValue.substring(0, initialValue.indexOf(","));
  3671. }
  3672. }
  3673. if (opts.radixPoint !== "" && isFinite(opts.digits)) {
  3674. if (initialValue.indexOf(opts.radixPoint) !== -1) {
  3675. var valueParts = initialValue.split(opts.radixPoint), decPart = valueParts[1].match(new RegExp("\\d*"))[0];
  3676. if (parseInt(opts.digits) < decPart.toString().length) {
  3677. var digitsFactor = Math.pow(10, parseInt(opts.digits));
  3678. initialValue = initialValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".");
  3679. initialValue = Math.round(parseFloat(initialValue) * digitsFactor) / digitsFactor;
  3680. initialValue = initialValue.toString().replace(".", opts.radixPoint);
  3681. }
  3682. }
  3683. }
  3684. return alignDigits(initialValue.toString().split(""), opts).join("");
  3685. },
  3686. onKeyDown: function onKeyDown(e, buffer, caretPos, opts) {
  3687. var $input = $(this);
  3688. if (e.ctrlKey) {
  3689. switch (e.keyCode) {
  3690. case Inputmask.keyCode.UP:
  3691. $input.val(parseFloat(this.inputmask.unmaskedvalue()) + parseInt(opts.step));
  3692. $input.trigger("setvalue");
  3693. break;
  3694. case Inputmask.keyCode.DOWN:
  3695. $input.val(parseFloat(this.inputmask.unmaskedvalue()) - parseInt(opts.step));
  3696. $input.trigger("setvalue");
  3697. break;
  3698. }
  3699. }
  3700. }
  3701. },
  3702. currency: {
  3703. prefix: "$ ",
  3704. groupSeparator: ",",
  3705. alias: "numeric",
  3706. placeholder: "0",
  3707. autoGroup: true,
  3708. digits: 2,
  3709. digitsOptional: false,
  3710. clearMaskOnLostFocus: false
  3711. },
  3712. decimal: {
  3713. alias: "numeric"
  3714. },
  3715. integer: {
  3716. alias: "numeric",
  3717. digits: 0,
  3718. radixPoint: ""
  3719. },
  3720. percentage: {
  3721. alias: "numeric",
  3722. digits: 2,
  3723. digitsOptional: true,
  3724. radixPoint: ".",
  3725. placeholder: "0",
  3726. autoGroup: false,
  3727. min: 0,
  3728. max: 100,
  3729. suffix: " %",
  3730. allowMinus: false
  3731. }
  3732. });
  3733. return Inputmask;
  3734. });
  3735. }, function(module, exports, __webpack_require__) {
  3736. "use strict";
  3737. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
  3738. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) {
  3739. return typeof obj;
  3740. } : function(obj) {
  3741. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  3742. };
  3743. (function(factory) {
  3744. if (true) {
  3745. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(4), __webpack_require__(2) ],
  3746. __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__,
  3747. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  3748. } else {}
  3749. })(function($, Inputmask) {
  3750. if ($.fn.inputmask === undefined) {
  3751. $.fn.inputmask = function(fn, options) {
  3752. var nptmask, input = this[0];
  3753. if (options === undefined) options = {};
  3754. if (typeof fn === "string") {
  3755. switch (fn) {
  3756. case "unmaskedvalue":
  3757. return input && input.inputmask ? input.inputmask.unmaskedvalue() : $(input).val();
  3758. case "remove":
  3759. return this.each(function() {
  3760. if (this.inputmask) this.inputmask.remove();
  3761. });
  3762. case "getemptymask":
  3763. return input && input.inputmask ? input.inputmask.getemptymask() : "";
  3764. case "hasMaskedValue":
  3765. return input && input.inputmask ? input.inputmask.hasMaskedValue() : false;
  3766. case "isComplete":
  3767. return input && input.inputmask ? input.inputmask.isComplete() : true;
  3768. case "getmetadata":
  3769. return input && input.inputmask ? input.inputmask.getmetadata() : undefined;
  3770. case "setvalue":
  3771. Inputmask.setValue(input, options);
  3772. break;
  3773. case "option":
  3774. if (typeof options === "string") {
  3775. if (input && input.inputmask !== undefined) {
  3776. return input.inputmask.option(options);
  3777. }
  3778. } else {
  3779. return this.each(function() {
  3780. if (this.inputmask !== undefined) {
  3781. return this.inputmask.option(options);
  3782. }
  3783. });
  3784. }
  3785. break;
  3786. default:
  3787. options.alias = fn;
  3788. nptmask = new Inputmask(options);
  3789. return this.each(function() {
  3790. nptmask.mask(this);
  3791. });
  3792. }
  3793. } else if (Array.isArray(fn)) {
  3794. options.alias = fn;
  3795. nptmask = new Inputmask(options);
  3796. return this.each(function() {
  3797. nptmask.mask(this);
  3798. });
  3799. } else if ((typeof fn === "undefined" ? "undefined" : _typeof(fn)) == "object") {
  3800. nptmask = new Inputmask(fn);
  3801. if (fn.mask === undefined && fn.alias === undefined) {
  3802. return this.each(function() {
  3803. if (this.inputmask !== undefined) {
  3804. return this.inputmask.option(fn);
  3805. } else nptmask.mask(this);
  3806. });
  3807. } else {
  3808. return this.each(function() {
  3809. nptmask.mask(this);
  3810. });
  3811. }
  3812. } else if (fn === undefined) {
  3813. return this.each(function() {
  3814. nptmask = new Inputmask(options);
  3815. nptmask.mask(this);
  3816. });
  3817. }
  3818. };
  3819. }
  3820. return $.fn.inputmask;
  3821. });
  3822. } ]);