jquery.inputmask.bundle.js 217 KB

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