jquery.inputmask.bundle.js 215 KB

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