jquery.inputmask.bundle.js 217 KB

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