inputmask.bundle.js 216 KB

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