scripts.js 1.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010
  1. /*!
  2. * jQuery JavaScript Library v1.12.4
  3. * http://jquery.com/
  4. *
  5. * Includes Sizzle.js
  6. * http://sizzlejs.com/
  7. *
  8. * Copyright jQuery Foundation and other contributors
  9. * Released under the MIT license
  10. * http://jquery.org/license
  11. *
  12. * Date: 2016-05-20T17:17Z
  13. */
  14. (function( global, factory ) {
  15. if ( typeof module === "object" && typeof module.exports === "object" ) {
  16. // For CommonJS and CommonJS-like environments where a proper `window`
  17. // is present, execute the factory and get jQuery.
  18. // For environments that do not have a `window` with a `document`
  19. // (such as Node.js), expose a factory as module.exports.
  20. // This accentuates the need for the creation of a real `window`.
  21. // e.g. var jQuery = require("jquery")(window);
  22. // See ticket #14549 for more info.
  23. module.exports = global.document ?
  24. factory( global, true ) :
  25. function( w ) {
  26. if ( !w.document ) {
  27. throw new Error( "jQuery requires a window with a document" );
  28. }
  29. return factory( w );
  30. };
  31. } else {
  32. factory( global );
  33. }
  34. // Pass this if window is not defined yet
  35. }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  36. // Support: Firefox 18+
  37. // Can't be in strict mode, several libs including ASP.NET trace
  38. // the stack via arguments.caller.callee and Firefox dies if
  39. // you try to trace through "use strict" call chains. (#13335)
  40. //"use strict";
  41. var deletedIds = [];
  42. var document = window.document;
  43. var slice = deletedIds.slice;
  44. var concat = deletedIds.concat;
  45. var push = deletedIds.push;
  46. var indexOf = deletedIds.indexOf;
  47. var class2type = {};
  48. var toString = class2type.toString;
  49. var hasOwn = class2type.hasOwnProperty;
  50. var support = {};
  51. var
  52. version = "1.12.4",
  53. // Define a local copy of jQuery
  54. jQuery = function( selector, context ) {
  55. // The jQuery object is actually just the init constructor 'enhanced'
  56. // Need init if jQuery is called (just allow error to be thrown if not included)
  57. return new jQuery.fn.init( selector, context );
  58. },
  59. // Support: Android<4.1, IE<9
  60. // Make sure we trim BOM and NBSP
  61. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
  62. // Matches dashed string for camelizing
  63. rmsPrefix = /^-ms-/,
  64. rdashAlpha = /-([\da-z])/gi,
  65. // Used by jQuery.camelCase as callback to replace()
  66. fcamelCase = function( all, letter ) {
  67. return letter.toUpperCase();
  68. };
  69. jQuery.fn = jQuery.prototype = {
  70. // The current version of jQuery being used
  71. jquery: version,
  72. constructor: jQuery,
  73. // Start with an empty selector
  74. selector: "",
  75. // The default length of a jQuery object is 0
  76. length: 0,
  77. toArray: function() {
  78. return slice.call( this );
  79. },
  80. // Get the Nth element in the matched element set OR
  81. // Get the whole matched element set as a clean array
  82. get: function( num ) {
  83. return num != null ?
  84. // Return just the one element from the set
  85. ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
  86. // Return all the elements in a clean array
  87. slice.call( this );
  88. },
  89. // Take an array of elements and push it onto the stack
  90. // (returning the new matched element set)
  91. pushStack: function( elems ) {
  92. // Build a new jQuery matched element set
  93. var ret = jQuery.merge( this.constructor(), elems );
  94. // Add the old object onto the stack (as a reference)
  95. ret.prevObject = this;
  96. ret.context = this.context;
  97. // Return the newly-formed element set
  98. return ret;
  99. },
  100. // Execute a callback for every element in the matched set.
  101. each: function( callback ) {
  102. return jQuery.each( this, callback );
  103. },
  104. map: function( callback ) {
  105. return this.pushStack( jQuery.map( this, function( elem, i ) {
  106. return callback.call( elem, i, elem );
  107. } ) );
  108. },
  109. slice: function() {
  110. return this.pushStack( slice.apply( this, arguments ) );
  111. },
  112. first: function() {
  113. return this.eq( 0 );
  114. },
  115. last: function() {
  116. return this.eq( -1 );
  117. },
  118. eq: function( i ) {
  119. var len = this.length,
  120. j = +i + ( i < 0 ? len : 0 );
  121. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  122. },
  123. end: function() {
  124. return this.prevObject || this.constructor();
  125. },
  126. // For internal use only.
  127. // Behaves like an Array's method, not like a jQuery method.
  128. push: push,
  129. sort: deletedIds.sort,
  130. splice: deletedIds.splice
  131. };
  132. jQuery.extend = jQuery.fn.extend = function() {
  133. var src, copyIsArray, copy, name, options, clone,
  134. target = arguments[ 0 ] || {},
  135. i = 1,
  136. length = arguments.length,
  137. deep = false;
  138. // Handle a deep copy situation
  139. if ( typeof target === "boolean" ) {
  140. deep = target;
  141. // skip the boolean and the target
  142. target = arguments[ i ] || {};
  143. i++;
  144. }
  145. // Handle case when target is a string or something (possible in deep copy)
  146. if ( typeof target !== "object" && !jQuery.isFunction( target ) ) {
  147. target = {};
  148. }
  149. // extend jQuery itself if only one argument is passed
  150. if ( i === length ) {
  151. target = this;
  152. i--;
  153. }
  154. for ( ; i < length; i++ ) {
  155. // Only deal with non-null/undefined values
  156. if ( ( options = arguments[ i ] ) != null ) {
  157. // Extend the base object
  158. for ( name in options ) {
  159. src = target[ name ];
  160. copy = options[ name ];
  161. // Prevent never-ending loop
  162. if ( target === copy ) {
  163. continue;
  164. }
  165. // Recurse if we're merging plain objects or arrays
  166. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  167. ( copyIsArray = jQuery.isArray( copy ) ) ) ) {
  168. if ( copyIsArray ) {
  169. copyIsArray = false;
  170. clone = src && jQuery.isArray( src ) ? src : [];
  171. } else {
  172. clone = src && jQuery.isPlainObject( src ) ? src : {};
  173. }
  174. // Never move original objects, clone them
  175. target[ name ] = jQuery.extend( deep, clone, copy );
  176. // Don't bring in undefined values
  177. } else if ( copy !== undefined ) {
  178. target[ name ] = copy;
  179. }
  180. }
  181. }
  182. }
  183. // Return the modified object
  184. return target;
  185. };
  186. jQuery.extend( {
  187. // Unique for each copy of jQuery on the page
  188. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  189. // Assume jQuery is ready without the ready module
  190. isReady: true,
  191. error: function( msg ) {
  192. throw new Error( msg );
  193. },
  194. noop: function() {},
  195. // See test/unit/core.js for details concerning isFunction.
  196. // Since version 1.3, DOM methods and functions like alert
  197. // aren't supported. They return false on IE (#2968).
  198. isFunction: function( obj ) {
  199. return jQuery.type( obj ) === "function";
  200. },
  201. isArray: Array.isArray || function( obj ) {
  202. return jQuery.type( obj ) === "array";
  203. },
  204. isWindow: function( obj ) {
  205. /* jshint eqeqeq: false */
  206. return obj != null && obj == obj.window;
  207. },
  208. isNumeric: function( obj ) {
  209. // parseFloat NaNs numeric-cast false positives (null|true|false|"")
  210. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  211. // subtraction forces infinities to NaN
  212. // adding 1 corrects loss of precision from parseFloat (#15100)
  213. var realStringObj = obj && obj.toString();
  214. return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0;
  215. },
  216. isEmptyObject: function( obj ) {
  217. var name;
  218. for ( name in obj ) {
  219. return false;
  220. }
  221. return true;
  222. },
  223. isPlainObject: function( obj ) {
  224. var key;
  225. // Must be an Object.
  226. // Because of IE, we also have to check the presence of the constructor property.
  227. // Make sure that DOM nodes and window objects don't pass through, as well
  228. if ( !obj || jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
  229. return false;
  230. }
  231. try {
  232. // Not own constructor property must be Object
  233. if ( obj.constructor &&
  234. !hasOwn.call( obj, "constructor" ) &&
  235. !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
  236. return false;
  237. }
  238. } catch ( e ) {
  239. // IE8,9 Will throw exceptions on certain host objects #9897
  240. return false;
  241. }
  242. // Support: IE<9
  243. // Handle iteration over inherited properties before own properties.
  244. if ( !support.ownFirst ) {
  245. for ( key in obj ) {
  246. return hasOwn.call( obj, key );
  247. }
  248. }
  249. // Own properties are enumerated firstly, so to speed up,
  250. // if last one is own, then all properties are own.
  251. for ( key in obj ) {}
  252. return key === undefined || hasOwn.call( obj, key );
  253. },
  254. type: function( obj ) {
  255. if ( obj == null ) {
  256. return obj + "";
  257. }
  258. return typeof obj === "object" || typeof obj === "function" ?
  259. class2type[ toString.call( obj ) ] || "object" :
  260. typeof obj;
  261. },
  262. // Workarounds based on findings by Jim Driscoll
  263. // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
  264. globalEval: function( data ) {
  265. if ( data && jQuery.trim( data ) ) {
  266. // We use execScript on Internet Explorer
  267. // We use an anonymous function so that context is window
  268. // rather than jQuery in Firefox
  269. ( window.execScript || function( data ) {
  270. window[ "eval" ].call( window, data ); // jscs:ignore requireDotNotation
  271. } )( data );
  272. }
  273. },
  274. // Convert dashed to camelCase; used by the css and data modules
  275. // Microsoft forgot to hump their vendor prefix (#9572)
  276. camelCase: function( string ) {
  277. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  278. },
  279. nodeName: function( elem, name ) {
  280. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  281. },
  282. each: function( obj, callback ) {
  283. var length, i = 0;
  284. if ( isArrayLike( obj ) ) {
  285. length = obj.length;
  286. for ( ; i < length; i++ ) {
  287. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  288. break;
  289. }
  290. }
  291. } else {
  292. for ( i in obj ) {
  293. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  294. break;
  295. }
  296. }
  297. }
  298. return obj;
  299. },
  300. // Support: Android<4.1, IE<9
  301. trim: function( text ) {
  302. return text == null ?
  303. "" :
  304. ( text + "" ).replace( rtrim, "" );
  305. },
  306. // results is for internal usage only
  307. makeArray: function( arr, results ) {
  308. var ret = results || [];
  309. if ( arr != null ) {
  310. if ( isArrayLike( Object( arr ) ) ) {
  311. jQuery.merge( ret,
  312. typeof arr === "string" ?
  313. [ arr ] : arr
  314. );
  315. } else {
  316. push.call( ret, arr );
  317. }
  318. }
  319. return ret;
  320. },
  321. inArray: function( elem, arr, i ) {
  322. var len;
  323. if ( arr ) {
  324. if ( indexOf ) {
  325. return indexOf.call( arr, elem, i );
  326. }
  327. len = arr.length;
  328. i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
  329. for ( ; i < len; i++ ) {
  330. // Skip accessing in sparse arrays
  331. if ( i in arr && arr[ i ] === elem ) {
  332. return i;
  333. }
  334. }
  335. }
  336. return -1;
  337. },
  338. merge: function( first, second ) {
  339. var len = +second.length,
  340. j = 0,
  341. i = first.length;
  342. while ( j < len ) {
  343. first[ i++ ] = second[ j++ ];
  344. }
  345. // Support: IE<9
  346. // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
  347. if ( len !== len ) {
  348. while ( second[ j ] !== undefined ) {
  349. first[ i++ ] = second[ j++ ];
  350. }
  351. }
  352. first.length = i;
  353. return first;
  354. },
  355. grep: function( elems, callback, invert ) {
  356. var callbackInverse,
  357. matches = [],
  358. i = 0,
  359. length = elems.length,
  360. callbackExpect = !invert;
  361. // Go through the array, only saving the items
  362. // that pass the validator function
  363. for ( ; i < length; i++ ) {
  364. callbackInverse = !callback( elems[ i ], i );
  365. if ( callbackInverse !== callbackExpect ) {
  366. matches.push( elems[ i ] );
  367. }
  368. }
  369. return matches;
  370. },
  371. // arg is for internal usage only
  372. map: function( elems, callback, arg ) {
  373. var length, value,
  374. i = 0,
  375. ret = [];
  376. // Go through the array, translating each of the items to their new values
  377. if ( isArrayLike( elems ) ) {
  378. length = elems.length;
  379. for ( ; i < length; i++ ) {
  380. value = callback( elems[ i ], i, arg );
  381. if ( value != null ) {
  382. ret.push( value );
  383. }
  384. }
  385. // Go through every key on the object,
  386. } else {
  387. for ( i in elems ) {
  388. value = callback( elems[ i ], i, arg );
  389. if ( value != null ) {
  390. ret.push( value );
  391. }
  392. }
  393. }
  394. // Flatten any nested arrays
  395. return concat.apply( [], ret );
  396. },
  397. // A global GUID counter for objects
  398. guid: 1,
  399. // Bind a function to a context, optionally partially applying any
  400. // arguments.
  401. proxy: function( fn, context ) {
  402. var args, proxy, tmp;
  403. if ( typeof context === "string" ) {
  404. tmp = fn[ context ];
  405. context = fn;
  406. fn = tmp;
  407. }
  408. // Quick check to determine if target is callable, in the spec
  409. // this throws a TypeError, but we will just return undefined.
  410. if ( !jQuery.isFunction( fn ) ) {
  411. return undefined;
  412. }
  413. // Simulated bind
  414. args = slice.call( arguments, 2 );
  415. proxy = function() {
  416. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  417. };
  418. // Set the guid of unique handler to the same of original handler, so it can be removed
  419. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  420. return proxy;
  421. },
  422. now: function() {
  423. return +( new Date() );
  424. },
  425. // jQuery.support is not used in Core but other projects attach their
  426. // properties to it so it needs to exist.
  427. support: support
  428. } );
  429. // JSHint would error on this code due to the Symbol not being defined in ES5.
  430. // Defining this global in .jshintrc would create a danger of using the global
  431. // unguarded in another place, it seems safer to just disable JSHint for these
  432. // three lines.
  433. /* jshint ignore: start */
  434. if ( typeof Symbol === "function" ) {
  435. jQuery.fn[ Symbol.iterator ] = deletedIds[ Symbol.iterator ];
  436. }
  437. /* jshint ignore: end */
  438. // Populate the class2type map
  439. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  440. function( i, name ) {
  441. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  442. } );
  443. function isArrayLike( obj ) {
  444. // Support: iOS 8.2 (not reproducible in simulator)
  445. // `in` check used to prevent JIT error (gh-2145)
  446. // hasOwn isn't used here due to false negatives
  447. // regarding Nodelist length in IE
  448. var length = !!obj && "length" in obj && obj.length,
  449. type = jQuery.type( obj );
  450. if ( type === "function" || jQuery.isWindow( obj ) ) {
  451. return false;
  452. }
  453. return type === "array" || length === 0 ||
  454. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  455. }
  456. var Sizzle =
  457. /*!
  458. * Sizzle CSS Selector Engine v2.2.1
  459. * http://sizzlejs.com/
  460. *
  461. * Copyright jQuery Foundation and other contributors
  462. * Released under the MIT license
  463. * http://jquery.org/license
  464. *
  465. * Date: 2015-10-17
  466. */
  467. (function( window ) {
  468. var i,
  469. support,
  470. Expr,
  471. getText,
  472. isXML,
  473. tokenize,
  474. compile,
  475. select,
  476. outermostContext,
  477. sortInput,
  478. hasDuplicate,
  479. // Local document vars
  480. setDocument,
  481. document,
  482. docElem,
  483. documentIsHTML,
  484. rbuggyQSA,
  485. rbuggyMatches,
  486. matches,
  487. contains,
  488. // Instance-specific data
  489. expando = "sizzle" + 1 * new Date(),
  490. preferredDoc = window.document,
  491. dirruns = 0,
  492. done = 0,
  493. classCache = createCache(),
  494. tokenCache = createCache(),
  495. compilerCache = createCache(),
  496. sortOrder = function( a, b ) {
  497. if ( a === b ) {
  498. hasDuplicate = true;
  499. }
  500. return 0;
  501. },
  502. // General-purpose constants
  503. MAX_NEGATIVE = 1 << 31,
  504. // Instance methods
  505. hasOwn = ({}).hasOwnProperty,
  506. arr = [],
  507. pop = arr.pop,
  508. push_native = arr.push,
  509. push = arr.push,
  510. slice = arr.slice,
  511. // Use a stripped-down indexOf as it's faster than native
  512. // http://jsperf.com/thor-indexof-vs-for/5
  513. indexOf = function( list, elem ) {
  514. var i = 0,
  515. len = list.length;
  516. for ( ; i < len; i++ ) {
  517. if ( list[i] === elem ) {
  518. return i;
  519. }
  520. }
  521. return -1;
  522. },
  523. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  524. // Regular expressions
  525. // http://www.w3.org/TR/css3-selectors/#whitespace
  526. whitespace = "[\\x20\\t\\r\\n\\f]",
  527. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  528. identifier = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
  529. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  530. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  531. // Operator (capture 2)
  532. "*([*^$|!~]?=)" + whitespace +
  533. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  534. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  535. "*\\]",
  536. pseudos = ":(" + identifier + ")(?:\\((" +
  537. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  538. // 1. quoted (capture 3; capture 4 or capture 5)
  539. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  540. // 2. simple (capture 6)
  541. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  542. // 3. anything else (capture 2)
  543. ".*" +
  544. ")\\)|)",
  545. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  546. rwhitespace = new RegExp( whitespace + "+", "g" ),
  547. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  548. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  549. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  550. rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
  551. rpseudo = new RegExp( pseudos ),
  552. ridentifier = new RegExp( "^" + identifier + "$" ),
  553. matchExpr = {
  554. "ID": new RegExp( "^#(" + identifier + ")" ),
  555. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  556. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  557. "ATTR": new RegExp( "^" + attributes ),
  558. "PSEUDO": new RegExp( "^" + pseudos ),
  559. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  560. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  561. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  562. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  563. // For use in libraries implementing .is()
  564. // We use this for POS matching in `select`
  565. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  566. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  567. },
  568. rinputs = /^(?:input|select|textarea|button)$/i,
  569. rheader = /^h\d$/i,
  570. rnative = /^[^{]+\{\s*\[native \w/,
  571. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  572. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  573. rsibling = /[+~]/,
  574. rescape = /'|\\/g,
  575. // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  576. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  577. funescape = function( _, escaped, escapedWhitespace ) {
  578. var high = "0x" + escaped - 0x10000;
  579. // NaN means non-codepoint
  580. // Support: Firefox<24
  581. // Workaround erroneous numeric interpretation of +"0x"
  582. return high !== high || escapedWhitespace ?
  583. escaped :
  584. high < 0 ?
  585. // BMP codepoint
  586. String.fromCharCode( high + 0x10000 ) :
  587. // Supplemental Plane codepoint (surrogate pair)
  588. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  589. },
  590. // Used for iframes
  591. // See setDocument()
  592. // Removing the function wrapper causes a "Permission Denied"
  593. // error in IE
  594. unloadHandler = function() {
  595. setDocument();
  596. };
  597. // Optimize for push.apply( _, NodeList )
  598. try {
  599. push.apply(
  600. (arr = slice.call( preferredDoc.childNodes )),
  601. preferredDoc.childNodes
  602. );
  603. // Support: Android<4.0
  604. // Detect silently failing push.apply
  605. arr[ preferredDoc.childNodes.length ].nodeType;
  606. } catch ( e ) {
  607. push = { apply: arr.length ?
  608. // Leverage slice if possible
  609. function( target, els ) {
  610. push_native.apply( target, slice.call(els) );
  611. } :
  612. // Support: IE<9
  613. // Otherwise append directly
  614. function( target, els ) {
  615. var j = target.length,
  616. i = 0;
  617. // Can't trust NodeList.length
  618. while ( (target[j++] = els[i++]) ) {}
  619. target.length = j - 1;
  620. }
  621. };
  622. }
  623. function Sizzle( selector, context, results, seed ) {
  624. var m, i, elem, nid, nidselect, match, groups, newSelector,
  625. newContext = context && context.ownerDocument,
  626. // nodeType defaults to 9, since context defaults to document
  627. nodeType = context ? context.nodeType : 9;
  628. results = results || [];
  629. // Return early from calls with invalid selector or context
  630. if ( typeof selector !== "string" || !selector ||
  631. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  632. return results;
  633. }
  634. // Try to shortcut find operations (as opposed to filters) in HTML documents
  635. if ( !seed ) {
  636. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  637. setDocument( context );
  638. }
  639. context = context || document;
  640. if ( documentIsHTML ) {
  641. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  642. // (excepting DocumentFragment context, where the methods don't exist)
  643. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  644. // ID selector
  645. if ( (m = match[1]) ) {
  646. // Document context
  647. if ( nodeType === 9 ) {
  648. if ( (elem = context.getElementById( m )) ) {
  649. // Support: IE, Opera, Webkit
  650. // TODO: identify versions
  651. // getElementById can match elements by name instead of ID
  652. if ( elem.id === m ) {
  653. results.push( elem );
  654. return results;
  655. }
  656. } else {
  657. return results;
  658. }
  659. // Element context
  660. } else {
  661. // Support: IE, Opera, Webkit
  662. // TODO: identify versions
  663. // getElementById can match elements by name instead of ID
  664. if ( newContext && (elem = newContext.getElementById( m )) &&
  665. contains( context, elem ) &&
  666. elem.id === m ) {
  667. results.push( elem );
  668. return results;
  669. }
  670. }
  671. // Type selector
  672. } else if ( match[2] ) {
  673. push.apply( results, context.getElementsByTagName( selector ) );
  674. return results;
  675. // Class selector
  676. } else if ( (m = match[3]) && support.getElementsByClassName &&
  677. context.getElementsByClassName ) {
  678. push.apply( results, context.getElementsByClassName( m ) );
  679. return results;
  680. }
  681. }
  682. // Take advantage of querySelectorAll
  683. if ( support.qsa &&
  684. !compilerCache[ selector + " " ] &&
  685. (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
  686. if ( nodeType !== 1 ) {
  687. newContext = context;
  688. newSelector = selector;
  689. // qSA looks outside Element context, which is not what we want
  690. // Thanks to Andrew Dupont for this workaround technique
  691. // Support: IE <=8
  692. // Exclude object elements
  693. } else if ( context.nodeName.toLowerCase() !== "object" ) {
  694. // Capture the context ID, setting it first if necessary
  695. if ( (nid = context.getAttribute( "id" )) ) {
  696. nid = nid.replace( rescape, "\\$&" );
  697. } else {
  698. context.setAttribute( "id", (nid = expando) );
  699. }
  700. // Prefix every selector in the list
  701. groups = tokenize( selector );
  702. i = groups.length;
  703. nidselect = ridentifier.test( nid ) ? "#" + nid : "[id='" + nid + "']";
  704. while ( i-- ) {
  705. groups[i] = nidselect + " " + toSelector( groups[i] );
  706. }
  707. newSelector = groups.join( "," );
  708. // Expand context for sibling selectors
  709. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  710. context;
  711. }
  712. if ( newSelector ) {
  713. try {
  714. push.apply( results,
  715. newContext.querySelectorAll( newSelector )
  716. );
  717. return results;
  718. } catch ( qsaError ) {
  719. } finally {
  720. if ( nid === expando ) {
  721. context.removeAttribute( "id" );
  722. }
  723. }
  724. }
  725. }
  726. }
  727. }
  728. // All others
  729. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  730. }
  731. /**
  732. * Create key-value caches of limited size
  733. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  734. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  735. * deleting the oldest entry
  736. */
  737. function createCache() {
  738. var keys = [];
  739. function cache( key, value ) {
  740. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  741. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  742. // Only keep the most recent entries
  743. delete cache[ keys.shift() ];
  744. }
  745. return (cache[ key + " " ] = value);
  746. }
  747. return cache;
  748. }
  749. /**
  750. * Mark a function for special use by Sizzle
  751. * @param {Function} fn The function to mark
  752. */
  753. function markFunction( fn ) {
  754. fn[ expando ] = true;
  755. return fn;
  756. }
  757. /**
  758. * Support testing using an element
  759. * @param {Function} fn Passed the created div and expects a boolean result
  760. */
  761. function assert( fn ) {
  762. var div = document.createElement("div");
  763. try {
  764. return !!fn( div );
  765. } catch (e) {
  766. return false;
  767. } finally {
  768. // Remove from its parent by default
  769. if ( div.parentNode ) {
  770. div.parentNode.removeChild( div );
  771. }
  772. // release memory in IE
  773. div = null;
  774. }
  775. }
  776. /**
  777. * Adds the same handler for all of the specified attrs
  778. * @param {String} attrs Pipe-separated list of attributes
  779. * @param {Function} handler The method that will be applied
  780. */
  781. function addHandle( attrs, handler ) {
  782. var arr = attrs.split("|"),
  783. i = arr.length;
  784. while ( i-- ) {
  785. Expr.attrHandle[ arr[i] ] = handler;
  786. }
  787. }
  788. /**
  789. * Checks document order of two siblings
  790. * @param {Element} a
  791. * @param {Element} b
  792. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  793. */
  794. function siblingCheck( a, b ) {
  795. var cur = b && a,
  796. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  797. ( ~b.sourceIndex || MAX_NEGATIVE ) -
  798. ( ~a.sourceIndex || MAX_NEGATIVE );
  799. // Use IE sourceIndex if available on both nodes
  800. if ( diff ) {
  801. return diff;
  802. }
  803. // Check if b follows a
  804. if ( cur ) {
  805. while ( (cur = cur.nextSibling) ) {
  806. if ( cur === b ) {
  807. return -1;
  808. }
  809. }
  810. }
  811. return a ? 1 : -1;
  812. }
  813. /**
  814. * Returns a function to use in pseudos for input types
  815. * @param {String} type
  816. */
  817. function createInputPseudo( type ) {
  818. return function( elem ) {
  819. var name = elem.nodeName.toLowerCase();
  820. return name === "input" && elem.type === type;
  821. };
  822. }
  823. /**
  824. * Returns a function to use in pseudos for buttons
  825. * @param {String} type
  826. */
  827. function createButtonPseudo( type ) {
  828. return function( elem ) {
  829. var name = elem.nodeName.toLowerCase();
  830. return (name === "input" || name === "button") && elem.type === type;
  831. };
  832. }
  833. /**
  834. * Returns a function to use in pseudos for positionals
  835. * @param {Function} fn
  836. */
  837. function createPositionalPseudo( fn ) {
  838. return markFunction(function( argument ) {
  839. argument = +argument;
  840. return markFunction(function( seed, matches ) {
  841. var j,
  842. matchIndexes = fn( [], seed.length, argument ),
  843. i = matchIndexes.length;
  844. // Match elements found at the specified indexes
  845. while ( i-- ) {
  846. if ( seed[ (j = matchIndexes[i]) ] ) {
  847. seed[j] = !(matches[j] = seed[j]);
  848. }
  849. }
  850. });
  851. });
  852. }
  853. /**
  854. * Checks a node for validity as a Sizzle context
  855. * @param {Element|Object=} context
  856. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  857. */
  858. function testContext( context ) {
  859. return context && typeof context.getElementsByTagName !== "undefined" && context;
  860. }
  861. // Expose support vars for convenience
  862. support = Sizzle.support = {};
  863. /**
  864. * Detects XML nodes
  865. * @param {Element|Object} elem An element or a document
  866. * @returns {Boolean} True iff elem is a non-HTML XML node
  867. */
  868. isXML = Sizzle.isXML = function( elem ) {
  869. // documentElement is verified for cases where it doesn't yet exist
  870. // (such as loading iframes in IE - #4833)
  871. var documentElement = elem && (elem.ownerDocument || elem).documentElement;
  872. return documentElement ? documentElement.nodeName !== "HTML" : false;
  873. };
  874. /**
  875. * Sets document-related variables once based on the current document
  876. * @param {Element|Object} [doc] An element or document object to use to set the document
  877. * @returns {Object} Returns the current document
  878. */
  879. setDocument = Sizzle.setDocument = function( node ) {
  880. var hasCompare, parent,
  881. doc = node ? node.ownerDocument || node : preferredDoc;
  882. // Return early if doc is invalid or already selected
  883. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  884. return document;
  885. }
  886. // Update global variables
  887. document = doc;
  888. docElem = document.documentElement;
  889. documentIsHTML = !isXML( document );
  890. // Support: IE 9-11, Edge
  891. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  892. if ( (parent = document.defaultView) && parent.top !== parent ) {
  893. // Support: IE 11
  894. if ( parent.addEventListener ) {
  895. parent.addEventListener( "unload", unloadHandler, false );
  896. // Support: IE 9 - 10 only
  897. } else if ( parent.attachEvent ) {
  898. parent.attachEvent( "onunload", unloadHandler );
  899. }
  900. }
  901. /* Attributes
  902. ---------------------------------------------------------------------- */
  903. // Support: IE<8
  904. // Verify that getAttribute really returns attributes and not properties
  905. // (excepting IE8 booleans)
  906. support.attributes = assert(function( div ) {
  907. div.className = "i";
  908. return !div.getAttribute("className");
  909. });
  910. /* getElement(s)By*
  911. ---------------------------------------------------------------------- */
  912. // Check if getElementsByTagName("*") returns only elements
  913. support.getElementsByTagName = assert(function( div ) {
  914. div.appendChild( document.createComment("") );
  915. return !div.getElementsByTagName("*").length;
  916. });
  917. // Support: IE<9
  918. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  919. // Support: IE<10
  920. // Check if getElementById returns elements by name
  921. // The broken getElementById methods don't pick up programatically-set names,
  922. // so use a roundabout getElementsByName test
  923. support.getById = assert(function( div ) {
  924. docElem.appendChild( div ).id = expando;
  925. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  926. });
  927. // ID find and filter
  928. if ( support.getById ) {
  929. Expr.find["ID"] = function( id, context ) {
  930. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  931. var m = context.getElementById( id );
  932. return m ? [ m ] : [];
  933. }
  934. };
  935. Expr.filter["ID"] = function( id ) {
  936. var attrId = id.replace( runescape, funescape );
  937. return function( elem ) {
  938. return elem.getAttribute("id") === attrId;
  939. };
  940. };
  941. } else {
  942. // Support: IE6/7
  943. // getElementById is not reliable as a find shortcut
  944. delete Expr.find["ID"];
  945. Expr.filter["ID"] = function( id ) {
  946. var attrId = id.replace( runescape, funescape );
  947. return function( elem ) {
  948. var node = typeof elem.getAttributeNode !== "undefined" &&
  949. elem.getAttributeNode("id");
  950. return node && node.value === attrId;
  951. };
  952. };
  953. }
  954. // Tag
  955. Expr.find["TAG"] = support.getElementsByTagName ?
  956. function( tag, context ) {
  957. if ( typeof context.getElementsByTagName !== "undefined" ) {
  958. return context.getElementsByTagName( tag );
  959. // DocumentFragment nodes don't have gEBTN
  960. } else if ( support.qsa ) {
  961. return context.querySelectorAll( tag );
  962. }
  963. } :
  964. function( tag, context ) {
  965. var elem,
  966. tmp = [],
  967. i = 0,
  968. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  969. results = context.getElementsByTagName( tag );
  970. // Filter out possible comments
  971. if ( tag === "*" ) {
  972. while ( (elem = results[i++]) ) {
  973. if ( elem.nodeType === 1 ) {
  974. tmp.push( elem );
  975. }
  976. }
  977. return tmp;
  978. }
  979. return results;
  980. };
  981. // Class
  982. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  983. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  984. return context.getElementsByClassName( className );
  985. }
  986. };
  987. /* QSA/matchesSelector
  988. ---------------------------------------------------------------------- */
  989. // QSA and matchesSelector support
  990. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  991. rbuggyMatches = [];
  992. // qSa(:focus) reports false when true (Chrome 21)
  993. // We allow this because of a bug in IE8/9 that throws an error
  994. // whenever `document.activeElement` is accessed on an iframe
  995. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  996. // See http://bugs.jquery.com/ticket/13378
  997. rbuggyQSA = [];
  998. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  999. // Build QSA regex
  1000. // Regex strategy adopted from Diego Perini
  1001. assert(function( div ) {
  1002. // Select is set to empty string on purpose
  1003. // This is to test IE's treatment of not explicitly
  1004. // setting a boolean content attribute,
  1005. // since its presence should be enough
  1006. // http://bugs.jquery.com/ticket/12359
  1007. docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" +
  1008. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  1009. "<option selected=''></option></select>";
  1010. // Support: IE8, Opera 11-12.16
  1011. // Nothing should be selected when empty strings follow ^= or $= or *=
  1012. // The test attribute must be unknown in Opera but "safe" for WinRT
  1013. // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  1014. if ( div.querySelectorAll("[msallowcapture^='']").length ) {
  1015. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  1016. }
  1017. // Support: IE8
  1018. // Boolean attributes and "value" are not treated correctly
  1019. if ( !div.querySelectorAll("[selected]").length ) {
  1020. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  1021. }
  1022. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  1023. if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  1024. rbuggyQSA.push("~=");
  1025. }
  1026. // Webkit/Opera - :checked should return selected option elements
  1027. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1028. // IE8 throws error here and will not see later tests
  1029. if ( !div.querySelectorAll(":checked").length ) {
  1030. rbuggyQSA.push(":checked");
  1031. }
  1032. // Support: Safari 8+, iOS 8+
  1033. // https://bugs.webkit.org/show_bug.cgi?id=136851
  1034. // In-page `selector#id sibing-combinator selector` fails
  1035. if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) {
  1036. rbuggyQSA.push(".#.+[+~]");
  1037. }
  1038. });
  1039. assert(function( div ) {
  1040. // Support: Windows 8 Native Apps
  1041. // The type and name attributes are restricted during .innerHTML assignment
  1042. var input = document.createElement("input");
  1043. input.setAttribute( "type", "hidden" );
  1044. div.appendChild( input ).setAttribute( "name", "D" );
  1045. // Support: IE8
  1046. // Enforce case-sensitivity of name attribute
  1047. if ( div.querySelectorAll("[name=d]").length ) {
  1048. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  1049. }
  1050. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  1051. // IE8 throws error here and will not see later tests
  1052. if ( !div.querySelectorAll(":enabled").length ) {
  1053. rbuggyQSA.push( ":enabled", ":disabled" );
  1054. }
  1055. // Opera 10-11 does not throw on post-comma invalid pseudos
  1056. div.querySelectorAll("*,:x");
  1057. rbuggyQSA.push(",.*:");
  1058. });
  1059. }
  1060. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  1061. docElem.webkitMatchesSelector ||
  1062. docElem.mozMatchesSelector ||
  1063. docElem.oMatchesSelector ||
  1064. docElem.msMatchesSelector) )) ) {
  1065. assert(function( div ) {
  1066. // Check to see if it's possible to do matchesSelector
  1067. // on a disconnected node (IE 9)
  1068. support.disconnectedMatch = matches.call( div, "div" );
  1069. // This should fail with an exception
  1070. // Gecko does not error, returns false instead
  1071. matches.call( div, "[s!='']:x" );
  1072. rbuggyMatches.push( "!=", pseudos );
  1073. });
  1074. }
  1075. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  1076. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  1077. /* Contains
  1078. ---------------------------------------------------------------------- */
  1079. hasCompare = rnative.test( docElem.compareDocumentPosition );
  1080. // Element contains another
  1081. // Purposefully self-exclusive
  1082. // As in, an element does not contain itself
  1083. contains = hasCompare || rnative.test( docElem.contains ) ?
  1084. function( a, b ) {
  1085. var adown = a.nodeType === 9 ? a.documentElement : a,
  1086. bup = b && b.parentNode;
  1087. return a === bup || !!( bup && bup.nodeType === 1 && (
  1088. adown.contains ?
  1089. adown.contains( bup ) :
  1090. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  1091. ));
  1092. } :
  1093. function( a, b ) {
  1094. if ( b ) {
  1095. while ( (b = b.parentNode) ) {
  1096. if ( b === a ) {
  1097. return true;
  1098. }
  1099. }
  1100. }
  1101. return false;
  1102. };
  1103. /* Sorting
  1104. ---------------------------------------------------------------------- */
  1105. // Document order sorting
  1106. sortOrder = hasCompare ?
  1107. function( a, b ) {
  1108. // Flag for duplicate removal
  1109. if ( a === b ) {
  1110. hasDuplicate = true;
  1111. return 0;
  1112. }
  1113. // Sort on method existence if only one input has compareDocumentPosition
  1114. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  1115. if ( compare ) {
  1116. return compare;
  1117. }
  1118. // Calculate position if both inputs belong to the same document
  1119. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  1120. a.compareDocumentPosition( b ) :
  1121. // Otherwise we know they are disconnected
  1122. 1;
  1123. // Disconnected nodes
  1124. if ( compare & 1 ||
  1125. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  1126. // Choose the first element that is related to our preferred document
  1127. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  1128. return -1;
  1129. }
  1130. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  1131. return 1;
  1132. }
  1133. // Maintain original order
  1134. return sortInput ?
  1135. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  1136. 0;
  1137. }
  1138. return compare & 4 ? -1 : 1;
  1139. } :
  1140. function( a, b ) {
  1141. // Exit early if the nodes are identical
  1142. if ( a === b ) {
  1143. hasDuplicate = true;
  1144. return 0;
  1145. }
  1146. var cur,
  1147. i = 0,
  1148. aup = a.parentNode,
  1149. bup = b.parentNode,
  1150. ap = [ a ],
  1151. bp = [ b ];
  1152. // Parentless nodes are either documents or disconnected
  1153. if ( !aup || !bup ) {
  1154. return a === document ? -1 :
  1155. b === document ? 1 :
  1156. aup ? -1 :
  1157. bup ? 1 :
  1158. sortInput ?
  1159. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  1160. 0;
  1161. // If the nodes are siblings, we can do a quick check
  1162. } else if ( aup === bup ) {
  1163. return siblingCheck( a, b );
  1164. }
  1165. // Otherwise we need full lists of their ancestors for comparison
  1166. cur = a;
  1167. while ( (cur = cur.parentNode) ) {
  1168. ap.unshift( cur );
  1169. }
  1170. cur = b;
  1171. while ( (cur = cur.parentNode) ) {
  1172. bp.unshift( cur );
  1173. }
  1174. // Walk down the tree looking for a discrepancy
  1175. while ( ap[i] === bp[i] ) {
  1176. i++;
  1177. }
  1178. return i ?
  1179. // Do a sibling check if the nodes have a common ancestor
  1180. siblingCheck( ap[i], bp[i] ) :
  1181. // Otherwise nodes in our document sort first
  1182. ap[i] === preferredDoc ? -1 :
  1183. bp[i] === preferredDoc ? 1 :
  1184. 0;
  1185. };
  1186. return document;
  1187. };
  1188. Sizzle.matches = function( expr, elements ) {
  1189. return Sizzle( expr, null, null, elements );
  1190. };
  1191. Sizzle.matchesSelector = function( elem, expr ) {
  1192. // Set document vars if needed
  1193. if ( ( elem.ownerDocument || elem ) !== document ) {
  1194. setDocument( elem );
  1195. }
  1196. // Make sure that attribute selectors are quoted
  1197. expr = expr.replace( rattributeQuotes, "='$1']" );
  1198. if ( support.matchesSelector && documentIsHTML &&
  1199. !compilerCache[ expr + " " ] &&
  1200. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  1201. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  1202. try {
  1203. var ret = matches.call( elem, expr );
  1204. // IE 9's matchesSelector returns false on disconnected nodes
  1205. if ( ret || support.disconnectedMatch ||
  1206. // As well, disconnected nodes are said to be in a document
  1207. // fragment in IE 9
  1208. elem.document && elem.document.nodeType !== 11 ) {
  1209. return ret;
  1210. }
  1211. } catch (e) {}
  1212. }
  1213. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  1214. };
  1215. Sizzle.contains = function( context, elem ) {
  1216. // Set document vars if needed
  1217. if ( ( context.ownerDocument || context ) !== document ) {
  1218. setDocument( context );
  1219. }
  1220. return contains( context, elem );
  1221. };
  1222. Sizzle.attr = function( elem, name ) {
  1223. // Set document vars if needed
  1224. if ( ( elem.ownerDocument || elem ) !== document ) {
  1225. setDocument( elem );
  1226. }
  1227. var fn = Expr.attrHandle[ name.toLowerCase() ],
  1228. // Don't get fooled by Object.prototype properties (jQuery #13807)
  1229. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  1230. fn( elem, name, !documentIsHTML ) :
  1231. undefined;
  1232. return val !== undefined ?
  1233. val :
  1234. support.attributes || !documentIsHTML ?
  1235. elem.getAttribute( name ) :
  1236. (val = elem.getAttributeNode(name)) && val.specified ?
  1237. val.value :
  1238. null;
  1239. };
  1240. Sizzle.error = function( msg ) {
  1241. throw new Error( "Syntax error, unrecognized expression: " + msg );
  1242. };
  1243. /**
  1244. * Document sorting and removing duplicates
  1245. * @param {ArrayLike} results
  1246. */
  1247. Sizzle.uniqueSort = function( results ) {
  1248. var elem,
  1249. duplicates = [],
  1250. j = 0,
  1251. i = 0;
  1252. // Unless we *know* we can detect duplicates, assume their presence
  1253. hasDuplicate = !support.detectDuplicates;
  1254. sortInput = !support.sortStable && results.slice( 0 );
  1255. results.sort( sortOrder );
  1256. if ( hasDuplicate ) {
  1257. while ( (elem = results[i++]) ) {
  1258. if ( elem === results[ i ] ) {
  1259. j = duplicates.push( i );
  1260. }
  1261. }
  1262. while ( j-- ) {
  1263. results.splice( duplicates[ j ], 1 );
  1264. }
  1265. }
  1266. // Clear input after sorting to release objects
  1267. // See https://github.com/jquery/sizzle/pull/225
  1268. sortInput = null;
  1269. return results;
  1270. };
  1271. /**
  1272. * Utility function for retrieving the text value of an array of DOM nodes
  1273. * @param {Array|Element} elem
  1274. */
  1275. getText = Sizzle.getText = function( elem ) {
  1276. var node,
  1277. ret = "",
  1278. i = 0,
  1279. nodeType = elem.nodeType;
  1280. if ( !nodeType ) {
  1281. // If no nodeType, this is expected to be an array
  1282. while ( (node = elem[i++]) ) {
  1283. // Do not traverse comment nodes
  1284. ret += getText( node );
  1285. }
  1286. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  1287. // Use textContent for elements
  1288. // innerText usage removed for consistency of new lines (jQuery #11153)
  1289. if ( typeof elem.textContent === "string" ) {
  1290. return elem.textContent;
  1291. } else {
  1292. // Traverse its children
  1293. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  1294. ret += getText( elem );
  1295. }
  1296. }
  1297. } else if ( nodeType === 3 || nodeType === 4 ) {
  1298. return elem.nodeValue;
  1299. }
  1300. // Do not include comment or processing instruction nodes
  1301. return ret;
  1302. };
  1303. Expr = Sizzle.selectors = {
  1304. // Can be adjusted by the user
  1305. cacheLength: 50,
  1306. createPseudo: markFunction,
  1307. match: matchExpr,
  1308. attrHandle: {},
  1309. find: {},
  1310. relative: {
  1311. ">": { dir: "parentNode", first: true },
  1312. " ": { dir: "parentNode" },
  1313. "+": { dir: "previousSibling", first: true },
  1314. "~": { dir: "previousSibling" }
  1315. },
  1316. preFilter: {
  1317. "ATTR": function( match ) {
  1318. match[1] = match[1].replace( runescape, funescape );
  1319. // Move the given value to match[3] whether quoted or unquoted
  1320. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  1321. if ( match[2] === "~=" ) {
  1322. match[3] = " " + match[3] + " ";
  1323. }
  1324. return match.slice( 0, 4 );
  1325. },
  1326. "CHILD": function( match ) {
  1327. /* matches from matchExpr["CHILD"]
  1328. 1 type (only|nth|...)
  1329. 2 what (child|of-type)
  1330. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  1331. 4 xn-component of xn+y argument ([+-]?\d*n|)
  1332. 5 sign of xn-component
  1333. 6 x of xn-component
  1334. 7 sign of y-component
  1335. 8 y of y-component
  1336. */
  1337. match[1] = match[1].toLowerCase();
  1338. if ( match[1].slice( 0, 3 ) === "nth" ) {
  1339. // nth-* requires argument
  1340. if ( !match[3] ) {
  1341. Sizzle.error( match[0] );
  1342. }
  1343. // numeric x and y parameters for Expr.filter.CHILD
  1344. // remember that false/true cast respectively to 0/1
  1345. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  1346. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  1347. // other types prohibit arguments
  1348. } else if ( match[3] ) {
  1349. Sizzle.error( match[0] );
  1350. }
  1351. return match;
  1352. },
  1353. "PSEUDO": function( match ) {
  1354. var excess,
  1355. unquoted = !match[6] && match[2];
  1356. if ( matchExpr["CHILD"].test( match[0] ) ) {
  1357. return null;
  1358. }
  1359. // Accept quoted arguments as-is
  1360. if ( match[3] ) {
  1361. match[2] = match[4] || match[5] || "";
  1362. // Strip excess characters from unquoted arguments
  1363. } else if ( unquoted && rpseudo.test( unquoted ) &&
  1364. // Get excess from tokenize (recursively)
  1365. (excess = tokenize( unquoted, true )) &&
  1366. // advance to the next closing parenthesis
  1367. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  1368. // excess is a negative index
  1369. match[0] = match[0].slice( 0, excess );
  1370. match[2] = unquoted.slice( 0, excess );
  1371. }
  1372. // Return only captures needed by the pseudo filter method (type and argument)
  1373. return match.slice( 0, 3 );
  1374. }
  1375. },
  1376. filter: {
  1377. "TAG": function( nodeNameSelector ) {
  1378. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  1379. return nodeNameSelector === "*" ?
  1380. function() { return true; } :
  1381. function( elem ) {
  1382. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  1383. };
  1384. },
  1385. "CLASS": function( className ) {
  1386. var pattern = classCache[ className + " " ];
  1387. return pattern ||
  1388. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  1389. classCache( className, function( elem ) {
  1390. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  1391. });
  1392. },
  1393. "ATTR": function( name, operator, check ) {
  1394. return function( elem ) {
  1395. var result = Sizzle.attr( elem, name );
  1396. if ( result == null ) {
  1397. return operator === "!=";
  1398. }
  1399. if ( !operator ) {
  1400. return true;
  1401. }
  1402. result += "";
  1403. return operator === "=" ? result === check :
  1404. operator === "!=" ? result !== check :
  1405. operator === "^=" ? check && result.indexOf( check ) === 0 :
  1406. operator === "*=" ? check && result.indexOf( check ) > -1 :
  1407. operator === "$=" ? check && result.slice( -check.length ) === check :
  1408. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  1409. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  1410. false;
  1411. };
  1412. },
  1413. "CHILD": function( type, what, argument, first, last ) {
  1414. var simple = type.slice( 0, 3 ) !== "nth",
  1415. forward = type.slice( -4 ) !== "last",
  1416. ofType = what === "of-type";
  1417. return first === 1 && last === 0 ?
  1418. // Shortcut for :nth-*(n)
  1419. function( elem ) {
  1420. return !!elem.parentNode;
  1421. } :
  1422. function( elem, context, xml ) {
  1423. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  1424. dir = simple !== forward ? "nextSibling" : "previousSibling",
  1425. parent = elem.parentNode,
  1426. name = ofType && elem.nodeName.toLowerCase(),
  1427. useCache = !xml && !ofType,
  1428. diff = false;
  1429. if ( parent ) {
  1430. // :(first|last|only)-(child|of-type)
  1431. if ( simple ) {
  1432. while ( dir ) {
  1433. node = elem;
  1434. while ( (node = node[ dir ]) ) {
  1435. if ( ofType ?
  1436. node.nodeName.toLowerCase() === name :
  1437. node.nodeType === 1 ) {
  1438. return false;
  1439. }
  1440. }
  1441. // Reverse direction for :only-* (if we haven't yet done so)
  1442. start = dir = type === "only" && !start && "nextSibling";
  1443. }
  1444. return true;
  1445. }
  1446. start = [ forward ? parent.firstChild : parent.lastChild ];
  1447. // non-xml :nth-child(...) stores cache data on `parent`
  1448. if ( forward && useCache ) {
  1449. // Seek `elem` from a previously-cached index
  1450. // ...in a gzip-friendly way
  1451. node = parent;
  1452. outerCache = node[ expando ] || (node[ expando ] = {});
  1453. // Support: IE <9 only
  1454. // Defend against cloned attroperties (jQuery gh-1709)
  1455. uniqueCache = outerCache[ node.uniqueID ] ||
  1456. (outerCache[ node.uniqueID ] = {});
  1457. cache = uniqueCache[ type ] || [];
  1458. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  1459. diff = nodeIndex && cache[ 2 ];
  1460. node = nodeIndex && parent.childNodes[ nodeIndex ];
  1461. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1462. // Fallback to seeking `elem` from the start
  1463. (diff = nodeIndex = 0) || start.pop()) ) {
  1464. // When found, cache indexes on `parent` and break
  1465. if ( node.nodeType === 1 && ++diff && node === elem ) {
  1466. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  1467. break;
  1468. }
  1469. }
  1470. } else {
  1471. // Use previously-cached element index if available
  1472. if ( useCache ) {
  1473. // ...in a gzip-friendly way
  1474. node = elem;
  1475. outerCache = node[ expando ] || (node[ expando ] = {});
  1476. // Support: IE <9 only
  1477. // Defend against cloned attroperties (jQuery gh-1709)
  1478. uniqueCache = outerCache[ node.uniqueID ] ||
  1479. (outerCache[ node.uniqueID ] = {});
  1480. cache = uniqueCache[ type ] || [];
  1481. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  1482. diff = nodeIndex;
  1483. }
  1484. // xml :nth-child(...)
  1485. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  1486. if ( diff === false ) {
  1487. // Use the same loop as above to seek `elem` from the start
  1488. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1489. (diff = nodeIndex = 0) || start.pop()) ) {
  1490. if ( ( ofType ?
  1491. node.nodeName.toLowerCase() === name :
  1492. node.nodeType === 1 ) &&
  1493. ++diff ) {
  1494. // Cache the index of each encountered element
  1495. if ( useCache ) {
  1496. outerCache = node[ expando ] || (node[ expando ] = {});
  1497. // Support: IE <9 only
  1498. // Defend against cloned attroperties (jQuery gh-1709)
  1499. uniqueCache = outerCache[ node.uniqueID ] ||
  1500. (outerCache[ node.uniqueID ] = {});
  1501. uniqueCache[ type ] = [ dirruns, diff ];
  1502. }
  1503. if ( node === elem ) {
  1504. break;
  1505. }
  1506. }
  1507. }
  1508. }
  1509. }
  1510. // Incorporate the offset, then check against cycle size
  1511. diff -= last;
  1512. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  1513. }
  1514. };
  1515. },
  1516. "PSEUDO": function( pseudo, argument ) {
  1517. // pseudo-class names are case-insensitive
  1518. // http://www.w3.org/TR/selectors/#pseudo-classes
  1519. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  1520. // Remember that setFilters inherits from pseudos
  1521. var args,
  1522. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  1523. Sizzle.error( "unsupported pseudo: " + pseudo );
  1524. // The user may use createPseudo to indicate that
  1525. // arguments are needed to create the filter function
  1526. // just as Sizzle does
  1527. if ( fn[ expando ] ) {
  1528. return fn( argument );
  1529. }
  1530. // But maintain support for old signatures
  1531. if ( fn.length > 1 ) {
  1532. args = [ pseudo, pseudo, "", argument ];
  1533. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  1534. markFunction(function( seed, matches ) {
  1535. var idx,
  1536. matched = fn( seed, argument ),
  1537. i = matched.length;
  1538. while ( i-- ) {
  1539. idx = indexOf( seed, matched[i] );
  1540. seed[ idx ] = !( matches[ idx ] = matched[i] );
  1541. }
  1542. }) :
  1543. function( elem ) {
  1544. return fn( elem, 0, args );
  1545. };
  1546. }
  1547. return fn;
  1548. }
  1549. },
  1550. pseudos: {
  1551. // Potentially complex pseudos
  1552. "not": markFunction(function( selector ) {
  1553. // Trim the selector passed to compile
  1554. // to avoid treating leading and trailing
  1555. // spaces as combinators
  1556. var input = [],
  1557. results = [],
  1558. matcher = compile( selector.replace( rtrim, "$1" ) );
  1559. return matcher[ expando ] ?
  1560. markFunction(function( seed, matches, context, xml ) {
  1561. var elem,
  1562. unmatched = matcher( seed, null, xml, [] ),
  1563. i = seed.length;
  1564. // Match elements unmatched by `matcher`
  1565. while ( i-- ) {
  1566. if ( (elem = unmatched[i]) ) {
  1567. seed[i] = !(matches[i] = elem);
  1568. }
  1569. }
  1570. }) :
  1571. function( elem, context, xml ) {
  1572. input[0] = elem;
  1573. matcher( input, null, xml, results );
  1574. // Don't keep the element (issue #299)
  1575. input[0] = null;
  1576. return !results.pop();
  1577. };
  1578. }),
  1579. "has": markFunction(function( selector ) {
  1580. return function( elem ) {
  1581. return Sizzle( selector, elem ).length > 0;
  1582. };
  1583. }),
  1584. "contains": markFunction(function( text ) {
  1585. text = text.replace( runescape, funescape );
  1586. return function( elem ) {
  1587. return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
  1588. };
  1589. }),
  1590. // "Whether an element is represented by a :lang() selector
  1591. // is based solely on the element's language value
  1592. // being equal to the identifier C,
  1593. // or beginning with the identifier C immediately followed by "-".
  1594. // The matching of C against the element's language value is performed case-insensitively.
  1595. // The identifier C does not have to be a valid language name."
  1596. // http://www.w3.org/TR/selectors/#lang-pseudo
  1597. "lang": markFunction( function( lang ) {
  1598. // lang value must be a valid identifier
  1599. if ( !ridentifier.test(lang || "") ) {
  1600. Sizzle.error( "unsupported lang: " + lang );
  1601. }
  1602. lang = lang.replace( runescape, funescape ).toLowerCase();
  1603. return function( elem ) {
  1604. var elemLang;
  1605. do {
  1606. if ( (elemLang = documentIsHTML ?
  1607. elem.lang :
  1608. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  1609. elemLang = elemLang.toLowerCase();
  1610. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  1611. }
  1612. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  1613. return false;
  1614. };
  1615. }),
  1616. // Miscellaneous
  1617. "target": function( elem ) {
  1618. var hash = window.location && window.location.hash;
  1619. return hash && hash.slice( 1 ) === elem.id;
  1620. },
  1621. "root": function( elem ) {
  1622. return elem === docElem;
  1623. },
  1624. "focus": function( elem ) {
  1625. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  1626. },
  1627. // Boolean properties
  1628. "enabled": function( elem ) {
  1629. return elem.disabled === false;
  1630. },
  1631. "disabled": function( elem ) {
  1632. return elem.disabled === true;
  1633. },
  1634. "checked": function( elem ) {
  1635. // In CSS3, :checked should return both checked and selected elements
  1636. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1637. var nodeName = elem.nodeName.toLowerCase();
  1638. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  1639. },
  1640. "selected": function( elem ) {
  1641. // Accessing this property makes selected-by-default
  1642. // options in Safari work properly
  1643. if ( elem.parentNode ) {
  1644. elem.parentNode.selectedIndex;
  1645. }
  1646. return elem.selected === true;
  1647. },
  1648. // Contents
  1649. "empty": function( elem ) {
  1650. // http://www.w3.org/TR/selectors/#empty-pseudo
  1651. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  1652. // but not by others (comment: 8; processing instruction: 7; etc.)
  1653. // nodeType < 6 works because attributes (2) do not appear as children
  1654. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  1655. if ( elem.nodeType < 6 ) {
  1656. return false;
  1657. }
  1658. }
  1659. return true;
  1660. },
  1661. "parent": function( elem ) {
  1662. return !Expr.pseudos["empty"]( elem );
  1663. },
  1664. // Element/input types
  1665. "header": function( elem ) {
  1666. return rheader.test( elem.nodeName );
  1667. },
  1668. "input": function( elem ) {
  1669. return rinputs.test( elem.nodeName );
  1670. },
  1671. "button": function( elem ) {
  1672. var name = elem.nodeName.toLowerCase();
  1673. return name === "input" && elem.type === "button" || name === "button";
  1674. },
  1675. "text": function( elem ) {
  1676. var attr;
  1677. return elem.nodeName.toLowerCase() === "input" &&
  1678. elem.type === "text" &&
  1679. // Support: IE<8
  1680. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  1681. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  1682. },
  1683. // Position-in-collection
  1684. "first": createPositionalPseudo(function() {
  1685. return [ 0 ];
  1686. }),
  1687. "last": createPositionalPseudo(function( matchIndexes, length ) {
  1688. return [ length - 1 ];
  1689. }),
  1690. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1691. return [ argument < 0 ? argument + length : argument ];
  1692. }),
  1693. "even": createPositionalPseudo(function( matchIndexes, length ) {
  1694. var i = 0;
  1695. for ( ; i < length; i += 2 ) {
  1696. matchIndexes.push( i );
  1697. }
  1698. return matchIndexes;
  1699. }),
  1700. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  1701. var i = 1;
  1702. for ( ; i < length; i += 2 ) {
  1703. matchIndexes.push( i );
  1704. }
  1705. return matchIndexes;
  1706. }),
  1707. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1708. var i = argument < 0 ? argument + length : argument;
  1709. for ( ; --i >= 0; ) {
  1710. matchIndexes.push( i );
  1711. }
  1712. return matchIndexes;
  1713. }),
  1714. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1715. var i = argument < 0 ? argument + length : argument;
  1716. for ( ; ++i < length; ) {
  1717. matchIndexes.push( i );
  1718. }
  1719. return matchIndexes;
  1720. })
  1721. }
  1722. };
  1723. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  1724. // Add button/input type pseudos
  1725. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  1726. Expr.pseudos[ i ] = createInputPseudo( i );
  1727. }
  1728. for ( i in { submit: true, reset: true } ) {
  1729. Expr.pseudos[ i ] = createButtonPseudo( i );
  1730. }
  1731. // Easy API for creating new setFilters
  1732. function setFilters() {}
  1733. setFilters.prototype = Expr.filters = Expr.pseudos;
  1734. Expr.setFilters = new setFilters();
  1735. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  1736. var matched, match, tokens, type,
  1737. soFar, groups, preFilters,
  1738. cached = tokenCache[ selector + " " ];
  1739. if ( cached ) {
  1740. return parseOnly ? 0 : cached.slice( 0 );
  1741. }
  1742. soFar = selector;
  1743. groups = [];
  1744. preFilters = Expr.preFilter;
  1745. while ( soFar ) {
  1746. // Comma and first run
  1747. if ( !matched || (match = rcomma.exec( soFar )) ) {
  1748. if ( match ) {
  1749. // Don't consume trailing commas as valid
  1750. soFar = soFar.slice( match[0].length ) || soFar;
  1751. }
  1752. groups.push( (tokens = []) );
  1753. }
  1754. matched = false;
  1755. // Combinators
  1756. if ( (match = rcombinators.exec( soFar )) ) {
  1757. matched = match.shift();
  1758. tokens.push({
  1759. value: matched,
  1760. // Cast descendant combinators to space
  1761. type: match[0].replace( rtrim, " " )
  1762. });
  1763. soFar = soFar.slice( matched.length );
  1764. }
  1765. // Filters
  1766. for ( type in Expr.filter ) {
  1767. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  1768. (match = preFilters[ type ]( match ))) ) {
  1769. matched = match.shift();
  1770. tokens.push({
  1771. value: matched,
  1772. type: type,
  1773. matches: match
  1774. });
  1775. soFar = soFar.slice( matched.length );
  1776. }
  1777. }
  1778. if ( !matched ) {
  1779. break;
  1780. }
  1781. }
  1782. // Return the length of the invalid excess
  1783. // if we're just parsing
  1784. // Otherwise, throw an error or return tokens
  1785. return parseOnly ?
  1786. soFar.length :
  1787. soFar ?
  1788. Sizzle.error( selector ) :
  1789. // Cache the tokens
  1790. tokenCache( selector, groups ).slice( 0 );
  1791. };
  1792. function toSelector( tokens ) {
  1793. var i = 0,
  1794. len = tokens.length,
  1795. selector = "";
  1796. for ( ; i < len; i++ ) {
  1797. selector += tokens[i].value;
  1798. }
  1799. return selector;
  1800. }
  1801. function addCombinator( matcher, combinator, base ) {
  1802. var dir = combinator.dir,
  1803. checkNonElements = base && dir === "parentNode",
  1804. doneName = done++;
  1805. return combinator.first ?
  1806. // Check against closest ancestor/preceding element
  1807. function( elem, context, xml ) {
  1808. while ( (elem = elem[ dir ]) ) {
  1809. if ( elem.nodeType === 1 || checkNonElements ) {
  1810. return matcher( elem, context, xml );
  1811. }
  1812. }
  1813. } :
  1814. // Check against all ancestor/preceding elements
  1815. function( elem, context, xml ) {
  1816. var oldCache, uniqueCache, outerCache,
  1817. newCache = [ dirruns, doneName ];
  1818. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  1819. if ( xml ) {
  1820. while ( (elem = elem[ dir ]) ) {
  1821. if ( elem.nodeType === 1 || checkNonElements ) {
  1822. if ( matcher( elem, context, xml ) ) {
  1823. return true;
  1824. }
  1825. }
  1826. }
  1827. } else {
  1828. while ( (elem = elem[ dir ]) ) {
  1829. if ( elem.nodeType === 1 || checkNonElements ) {
  1830. outerCache = elem[ expando ] || (elem[ expando ] = {});
  1831. // Support: IE <9 only
  1832. // Defend against cloned attroperties (jQuery gh-1709)
  1833. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  1834. if ( (oldCache = uniqueCache[ dir ]) &&
  1835. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  1836. // Assign to newCache so results back-propagate to previous elements
  1837. return (newCache[ 2 ] = oldCache[ 2 ]);
  1838. } else {
  1839. // Reuse newcache so results back-propagate to previous elements
  1840. uniqueCache[ dir ] = newCache;
  1841. // A match means we're done; a fail means we have to keep checking
  1842. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  1843. return true;
  1844. }
  1845. }
  1846. }
  1847. }
  1848. }
  1849. };
  1850. }
  1851. function elementMatcher( matchers ) {
  1852. return matchers.length > 1 ?
  1853. function( elem, context, xml ) {
  1854. var i = matchers.length;
  1855. while ( i-- ) {
  1856. if ( !matchers[i]( elem, context, xml ) ) {
  1857. return false;
  1858. }
  1859. }
  1860. return true;
  1861. } :
  1862. matchers[0];
  1863. }
  1864. function multipleContexts( selector, contexts, results ) {
  1865. var i = 0,
  1866. len = contexts.length;
  1867. for ( ; i < len; i++ ) {
  1868. Sizzle( selector, contexts[i], results );
  1869. }
  1870. return results;
  1871. }
  1872. function condense( unmatched, map, filter, context, xml ) {
  1873. var elem,
  1874. newUnmatched = [],
  1875. i = 0,
  1876. len = unmatched.length,
  1877. mapped = map != null;
  1878. for ( ; i < len; i++ ) {
  1879. if ( (elem = unmatched[i]) ) {
  1880. if ( !filter || filter( elem, context, xml ) ) {
  1881. newUnmatched.push( elem );
  1882. if ( mapped ) {
  1883. map.push( i );
  1884. }
  1885. }
  1886. }
  1887. }
  1888. return newUnmatched;
  1889. }
  1890. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  1891. if ( postFilter && !postFilter[ expando ] ) {
  1892. postFilter = setMatcher( postFilter );
  1893. }
  1894. if ( postFinder && !postFinder[ expando ] ) {
  1895. postFinder = setMatcher( postFinder, postSelector );
  1896. }
  1897. return markFunction(function( seed, results, context, xml ) {
  1898. var temp, i, elem,
  1899. preMap = [],
  1900. postMap = [],
  1901. preexisting = results.length,
  1902. // Get initial elements from seed or context
  1903. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  1904. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  1905. matcherIn = preFilter && ( seed || !selector ) ?
  1906. condense( elems, preMap, preFilter, context, xml ) :
  1907. elems,
  1908. matcherOut = matcher ?
  1909. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  1910. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  1911. // ...intermediate processing is necessary
  1912. [] :
  1913. // ...otherwise use results directly
  1914. results :
  1915. matcherIn;
  1916. // Find primary matches
  1917. if ( matcher ) {
  1918. matcher( matcherIn, matcherOut, context, xml );
  1919. }
  1920. // Apply postFilter
  1921. if ( postFilter ) {
  1922. temp = condense( matcherOut, postMap );
  1923. postFilter( temp, [], context, xml );
  1924. // Un-match failing elements by moving them back to matcherIn
  1925. i = temp.length;
  1926. while ( i-- ) {
  1927. if ( (elem = temp[i]) ) {
  1928. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  1929. }
  1930. }
  1931. }
  1932. if ( seed ) {
  1933. if ( postFinder || preFilter ) {
  1934. if ( postFinder ) {
  1935. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  1936. temp = [];
  1937. i = matcherOut.length;
  1938. while ( i-- ) {
  1939. if ( (elem = matcherOut[i]) ) {
  1940. // Restore matcherIn since elem is not yet a final match
  1941. temp.push( (matcherIn[i] = elem) );
  1942. }
  1943. }
  1944. postFinder( null, (matcherOut = []), temp, xml );
  1945. }
  1946. // Move matched elements from seed to results to keep them synchronized
  1947. i = matcherOut.length;
  1948. while ( i-- ) {
  1949. if ( (elem = matcherOut[i]) &&
  1950. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  1951. seed[temp] = !(results[temp] = elem);
  1952. }
  1953. }
  1954. }
  1955. // Add elements to results, through postFinder if defined
  1956. } else {
  1957. matcherOut = condense(
  1958. matcherOut === results ?
  1959. matcherOut.splice( preexisting, matcherOut.length ) :
  1960. matcherOut
  1961. );
  1962. if ( postFinder ) {
  1963. postFinder( null, results, matcherOut, xml );
  1964. } else {
  1965. push.apply( results, matcherOut );
  1966. }
  1967. }
  1968. });
  1969. }
  1970. function matcherFromTokens( tokens ) {
  1971. var checkContext, matcher, j,
  1972. len = tokens.length,
  1973. leadingRelative = Expr.relative[ tokens[0].type ],
  1974. implicitRelative = leadingRelative || Expr.relative[" "],
  1975. i = leadingRelative ? 1 : 0,
  1976. // The foundational matcher ensures that elements are reachable from top-level context(s)
  1977. matchContext = addCombinator( function( elem ) {
  1978. return elem === checkContext;
  1979. }, implicitRelative, true ),
  1980. matchAnyContext = addCombinator( function( elem ) {
  1981. return indexOf( checkContext, elem ) > -1;
  1982. }, implicitRelative, true ),
  1983. matchers = [ function( elem, context, xml ) {
  1984. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  1985. (checkContext = context).nodeType ?
  1986. matchContext( elem, context, xml ) :
  1987. matchAnyContext( elem, context, xml ) );
  1988. // Avoid hanging onto element (issue #299)
  1989. checkContext = null;
  1990. return ret;
  1991. } ];
  1992. for ( ; i < len; i++ ) {
  1993. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  1994. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  1995. } else {
  1996. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  1997. // Return special upon seeing a positional matcher
  1998. if ( matcher[ expando ] ) {
  1999. // Find the next relative operator (if any) for proper handling
  2000. j = ++i;
  2001. for ( ; j < len; j++ ) {
  2002. if ( Expr.relative[ tokens[j].type ] ) {
  2003. break;
  2004. }
  2005. }
  2006. return setMatcher(
  2007. i > 1 && elementMatcher( matchers ),
  2008. i > 1 && toSelector(
  2009. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  2010. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  2011. ).replace( rtrim, "$1" ),
  2012. matcher,
  2013. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  2014. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  2015. j < len && toSelector( tokens )
  2016. );
  2017. }
  2018. matchers.push( matcher );
  2019. }
  2020. }
  2021. return elementMatcher( matchers );
  2022. }
  2023. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  2024. var bySet = setMatchers.length > 0,
  2025. byElement = elementMatchers.length > 0,
  2026. superMatcher = function( seed, context, xml, results, outermost ) {
  2027. var elem, j, matcher,
  2028. matchedCount = 0,
  2029. i = "0",
  2030. unmatched = seed && [],
  2031. setMatched = [],
  2032. contextBackup = outermostContext,
  2033. // We must always have either seed elements or outermost context
  2034. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  2035. // Use integer dirruns iff this is the outermost matcher
  2036. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  2037. len = elems.length;
  2038. if ( outermost ) {
  2039. outermostContext = context === document || context || outermost;
  2040. }
  2041. // Add elements passing elementMatchers directly to results
  2042. // Support: IE<9, Safari
  2043. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  2044. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  2045. if ( byElement && elem ) {
  2046. j = 0;
  2047. if ( !context && elem.ownerDocument !== document ) {
  2048. setDocument( elem );
  2049. xml = !documentIsHTML;
  2050. }
  2051. while ( (matcher = elementMatchers[j++]) ) {
  2052. if ( matcher( elem, context || document, xml) ) {
  2053. results.push( elem );
  2054. break;
  2055. }
  2056. }
  2057. if ( outermost ) {
  2058. dirruns = dirrunsUnique;
  2059. }
  2060. }
  2061. // Track unmatched elements for set filters
  2062. if ( bySet ) {
  2063. // They will have gone through all possible matchers
  2064. if ( (elem = !matcher && elem) ) {
  2065. matchedCount--;
  2066. }
  2067. // Lengthen the array for every element, matched or not
  2068. if ( seed ) {
  2069. unmatched.push( elem );
  2070. }
  2071. }
  2072. }
  2073. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  2074. // makes the latter nonnegative.
  2075. matchedCount += i;
  2076. // Apply set filters to unmatched elements
  2077. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  2078. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  2079. // no element matchers and no seed.
  2080. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  2081. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  2082. // numerically zero.
  2083. if ( bySet && i !== matchedCount ) {
  2084. j = 0;
  2085. while ( (matcher = setMatchers[j++]) ) {
  2086. matcher( unmatched, setMatched, context, xml );
  2087. }
  2088. if ( seed ) {
  2089. // Reintegrate element matches to eliminate the need for sorting
  2090. if ( matchedCount > 0 ) {
  2091. while ( i-- ) {
  2092. if ( !(unmatched[i] || setMatched[i]) ) {
  2093. setMatched[i] = pop.call( results );
  2094. }
  2095. }
  2096. }
  2097. // Discard index placeholder values to get only actual matches
  2098. setMatched = condense( setMatched );
  2099. }
  2100. // Add matches to results
  2101. push.apply( results, setMatched );
  2102. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  2103. if ( outermost && !seed && setMatched.length > 0 &&
  2104. ( matchedCount + setMatchers.length ) > 1 ) {
  2105. Sizzle.uniqueSort( results );
  2106. }
  2107. }
  2108. // Override manipulation of globals by nested matchers
  2109. if ( outermost ) {
  2110. dirruns = dirrunsUnique;
  2111. outermostContext = contextBackup;
  2112. }
  2113. return unmatched;
  2114. };
  2115. return bySet ?
  2116. markFunction( superMatcher ) :
  2117. superMatcher;
  2118. }
  2119. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  2120. var i,
  2121. setMatchers = [],
  2122. elementMatchers = [],
  2123. cached = compilerCache[ selector + " " ];
  2124. if ( !cached ) {
  2125. // Generate a function of recursive functions that can be used to check each element
  2126. if ( !match ) {
  2127. match = tokenize( selector );
  2128. }
  2129. i = match.length;
  2130. while ( i-- ) {
  2131. cached = matcherFromTokens( match[i] );
  2132. if ( cached[ expando ] ) {
  2133. setMatchers.push( cached );
  2134. } else {
  2135. elementMatchers.push( cached );
  2136. }
  2137. }
  2138. // Cache the compiled function
  2139. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  2140. // Save selector and tokenization
  2141. cached.selector = selector;
  2142. }
  2143. return cached;
  2144. };
  2145. /**
  2146. * A low-level selection function that works with Sizzle's compiled
  2147. * selector functions
  2148. * @param {String|Function} selector A selector or a pre-compiled
  2149. * selector function built with Sizzle.compile
  2150. * @param {Element} context
  2151. * @param {Array} [results]
  2152. * @param {Array} [seed] A set of elements to match against
  2153. */
  2154. select = Sizzle.select = function( selector, context, results, seed ) {
  2155. var i, tokens, token, type, find,
  2156. compiled = typeof selector === "function" && selector,
  2157. match = !seed && tokenize( (selector = compiled.selector || selector) );
  2158. results = results || [];
  2159. // Try to minimize operations if there is only one selector in the list and no seed
  2160. // (the latter of which guarantees us context)
  2161. if ( match.length === 1 ) {
  2162. // Reduce context if the leading compound selector is an ID
  2163. tokens = match[0] = match[0].slice( 0 );
  2164. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  2165. support.getById && context.nodeType === 9 && documentIsHTML &&
  2166. Expr.relative[ tokens[1].type ] ) {
  2167. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  2168. if ( !context ) {
  2169. return results;
  2170. // Precompiled matchers will still verify ancestry, so step up a level
  2171. } else if ( compiled ) {
  2172. context = context.parentNode;
  2173. }
  2174. selector = selector.slice( tokens.shift().value.length );
  2175. }
  2176. // Fetch a seed set for right-to-left matching
  2177. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  2178. while ( i-- ) {
  2179. token = tokens[i];
  2180. // Abort if we hit a combinator
  2181. if ( Expr.relative[ (type = token.type) ] ) {
  2182. break;
  2183. }
  2184. if ( (find = Expr.find[ type ]) ) {
  2185. // Search, expanding context for leading sibling combinators
  2186. if ( (seed = find(
  2187. token.matches[0].replace( runescape, funescape ),
  2188. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  2189. )) ) {
  2190. // If seed is empty or no tokens remain, we can return early
  2191. tokens.splice( i, 1 );
  2192. selector = seed.length && toSelector( tokens );
  2193. if ( !selector ) {
  2194. push.apply( results, seed );
  2195. return results;
  2196. }
  2197. break;
  2198. }
  2199. }
  2200. }
  2201. }
  2202. // Compile and execute a filtering function if one is not provided
  2203. // Provide `match` to avoid retokenization if we modified the selector above
  2204. ( compiled || compile( selector, match ) )(
  2205. seed,
  2206. context,
  2207. !documentIsHTML,
  2208. results,
  2209. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  2210. );
  2211. return results;
  2212. };
  2213. // One-time assignments
  2214. // Sort stability
  2215. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  2216. // Support: Chrome 14-35+
  2217. // Always assume duplicates if they aren't passed to the comparison function
  2218. support.detectDuplicates = !!hasDuplicate;
  2219. // Initialize against the default document
  2220. setDocument();
  2221. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  2222. // Detached nodes confoundingly follow *each other*
  2223. support.sortDetached = assert(function( div1 ) {
  2224. // Should return 1, but returns 4 (following)
  2225. return div1.compareDocumentPosition( document.createElement("div") ) & 1;
  2226. });
  2227. // Support: IE<8
  2228. // Prevent attribute/property "interpolation"
  2229. // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  2230. if ( !assert(function( div ) {
  2231. div.innerHTML = "<a href='#'></a>";
  2232. return div.firstChild.getAttribute("href") === "#" ;
  2233. }) ) {
  2234. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  2235. if ( !isXML ) {
  2236. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  2237. }
  2238. });
  2239. }
  2240. // Support: IE<9
  2241. // Use defaultValue in place of getAttribute("value")
  2242. if ( !support.attributes || !assert(function( div ) {
  2243. div.innerHTML = "<input/>";
  2244. div.firstChild.setAttribute( "value", "" );
  2245. return div.firstChild.getAttribute( "value" ) === "";
  2246. }) ) {
  2247. addHandle( "value", function( elem, name, isXML ) {
  2248. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  2249. return elem.defaultValue;
  2250. }
  2251. });
  2252. }
  2253. // Support: IE<9
  2254. // Use getAttributeNode to fetch booleans when getAttribute lies
  2255. if ( !assert(function( div ) {
  2256. return div.getAttribute("disabled") == null;
  2257. }) ) {
  2258. addHandle( booleans, function( elem, name, isXML ) {
  2259. var val;
  2260. if ( !isXML ) {
  2261. return elem[ name ] === true ? name.toLowerCase() :
  2262. (val = elem.getAttributeNode( name )) && val.specified ?
  2263. val.value :
  2264. null;
  2265. }
  2266. });
  2267. }
  2268. return Sizzle;
  2269. })( window );
  2270. jQuery.find = Sizzle;
  2271. jQuery.expr = Sizzle.selectors;
  2272. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  2273. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  2274. jQuery.text = Sizzle.getText;
  2275. jQuery.isXMLDoc = Sizzle.isXML;
  2276. jQuery.contains = Sizzle.contains;
  2277. var dir = function( elem, dir, until ) {
  2278. var matched = [],
  2279. truncate = until !== undefined;
  2280. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  2281. if ( elem.nodeType === 1 ) {
  2282. if ( truncate && jQuery( elem ).is( until ) ) {
  2283. break;
  2284. }
  2285. matched.push( elem );
  2286. }
  2287. }
  2288. return matched;
  2289. };
  2290. var siblings = function( n, elem ) {
  2291. var matched = [];
  2292. for ( ; n; n = n.nextSibling ) {
  2293. if ( n.nodeType === 1 && n !== elem ) {
  2294. matched.push( n );
  2295. }
  2296. }
  2297. return matched;
  2298. };
  2299. var rneedsContext = jQuery.expr.match.needsContext;
  2300. var rsingleTag = ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ );
  2301. var risSimple = /^.[^:#\[\.,]*$/;
  2302. // Implement the identical functionality for filter and not
  2303. function winnow( elements, qualifier, not ) {
  2304. if ( jQuery.isFunction( qualifier ) ) {
  2305. return jQuery.grep( elements, function( elem, i ) {
  2306. /* jshint -W018 */
  2307. return !!qualifier.call( elem, i, elem ) !== not;
  2308. } );
  2309. }
  2310. if ( qualifier.nodeType ) {
  2311. return jQuery.grep( elements, function( elem ) {
  2312. return ( elem === qualifier ) !== not;
  2313. } );
  2314. }
  2315. if ( typeof qualifier === "string" ) {
  2316. if ( risSimple.test( qualifier ) ) {
  2317. return jQuery.filter( qualifier, elements, not );
  2318. }
  2319. qualifier = jQuery.filter( qualifier, elements );
  2320. }
  2321. return jQuery.grep( elements, function( elem ) {
  2322. return ( jQuery.inArray( elem, qualifier ) > -1 ) !== not;
  2323. } );
  2324. }
  2325. jQuery.filter = function( expr, elems, not ) {
  2326. var elem = elems[ 0 ];
  2327. if ( not ) {
  2328. expr = ":not(" + expr + ")";
  2329. }
  2330. return elems.length === 1 && elem.nodeType === 1 ?
  2331. jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
  2332. jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  2333. return elem.nodeType === 1;
  2334. } ) );
  2335. };
  2336. jQuery.fn.extend( {
  2337. find: function( selector ) {
  2338. var i,
  2339. ret = [],
  2340. self = this,
  2341. len = self.length;
  2342. if ( typeof selector !== "string" ) {
  2343. return this.pushStack( jQuery( selector ).filter( function() {
  2344. for ( i = 0; i < len; i++ ) {
  2345. if ( jQuery.contains( self[ i ], this ) ) {
  2346. return true;
  2347. }
  2348. }
  2349. } ) );
  2350. }
  2351. for ( i = 0; i < len; i++ ) {
  2352. jQuery.find( selector, self[ i ], ret );
  2353. }
  2354. // Needed because $( selector, context ) becomes $( context ).find( selector )
  2355. ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
  2356. ret.selector = this.selector ? this.selector + " " + selector : selector;
  2357. return ret;
  2358. },
  2359. filter: function( selector ) {
  2360. return this.pushStack( winnow( this, selector || [], false ) );
  2361. },
  2362. not: function( selector ) {
  2363. return this.pushStack( winnow( this, selector || [], true ) );
  2364. },
  2365. is: function( selector ) {
  2366. return !!winnow(
  2367. this,
  2368. // If this is a positional/relative selector, check membership in the returned set
  2369. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  2370. typeof selector === "string" && rneedsContext.test( selector ) ?
  2371. jQuery( selector ) :
  2372. selector || [],
  2373. false
  2374. ).length;
  2375. }
  2376. } );
  2377. // Initialize a jQuery object
  2378. // A central reference to the root jQuery(document)
  2379. var rootjQuery,
  2380. // A simple way to check for HTML strings
  2381. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  2382. // Strict HTML recognition (#11290: must start with <)
  2383. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
  2384. init = jQuery.fn.init = function( selector, context, root ) {
  2385. var match, elem;
  2386. // HANDLE: $(""), $(null), $(undefined), $(false)
  2387. if ( !selector ) {
  2388. return this;
  2389. }
  2390. // init accepts an alternate rootjQuery
  2391. // so migrate can support jQuery.sub (gh-2101)
  2392. root = root || rootjQuery;
  2393. // Handle HTML strings
  2394. if ( typeof selector === "string" ) {
  2395. if ( selector.charAt( 0 ) === "<" &&
  2396. selector.charAt( selector.length - 1 ) === ">" &&
  2397. selector.length >= 3 ) {
  2398. // Assume that strings that start and end with <> are HTML and skip the regex check
  2399. match = [ null, selector, null ];
  2400. } else {
  2401. match = rquickExpr.exec( selector );
  2402. }
  2403. // Match html or make sure no context is specified for #id
  2404. if ( match && ( match[ 1 ] || !context ) ) {
  2405. // HANDLE: $(html) -> $(array)
  2406. if ( match[ 1 ] ) {
  2407. context = context instanceof jQuery ? context[ 0 ] : context;
  2408. // scripts is true for back-compat
  2409. // Intentionally let the error be thrown if parseHTML is not present
  2410. jQuery.merge( this, jQuery.parseHTML(
  2411. match[ 1 ],
  2412. context && context.nodeType ? context.ownerDocument || context : document,
  2413. true
  2414. ) );
  2415. // HANDLE: $(html, props)
  2416. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  2417. for ( match in context ) {
  2418. // Properties of context are called as methods if possible
  2419. if ( jQuery.isFunction( this[ match ] ) ) {
  2420. this[ match ]( context[ match ] );
  2421. // ...and otherwise set as attributes
  2422. } else {
  2423. this.attr( match, context[ match ] );
  2424. }
  2425. }
  2426. }
  2427. return this;
  2428. // HANDLE: $(#id)
  2429. } else {
  2430. elem = document.getElementById( match[ 2 ] );
  2431. // Check parentNode to catch when Blackberry 4.6 returns
  2432. // nodes that are no longer in the document #6963
  2433. if ( elem && elem.parentNode ) {
  2434. // Handle the case where IE and Opera return items
  2435. // by name instead of ID
  2436. if ( elem.id !== match[ 2 ] ) {
  2437. return rootjQuery.find( selector );
  2438. }
  2439. // Otherwise, we inject the element directly into the jQuery object
  2440. this.length = 1;
  2441. this[ 0 ] = elem;
  2442. }
  2443. this.context = document;
  2444. this.selector = selector;
  2445. return this;
  2446. }
  2447. // HANDLE: $(expr, $(...))
  2448. } else if ( !context || context.jquery ) {
  2449. return ( context || root ).find( selector );
  2450. // HANDLE: $(expr, context)
  2451. // (which is just equivalent to: $(context).find(expr)
  2452. } else {
  2453. return this.constructor( context ).find( selector );
  2454. }
  2455. // HANDLE: $(DOMElement)
  2456. } else if ( selector.nodeType ) {
  2457. this.context = this[ 0 ] = selector;
  2458. this.length = 1;
  2459. return this;
  2460. // HANDLE: $(function)
  2461. // Shortcut for document ready
  2462. } else if ( jQuery.isFunction( selector ) ) {
  2463. return typeof root.ready !== "undefined" ?
  2464. root.ready( selector ) :
  2465. // Execute immediately if ready is not present
  2466. selector( jQuery );
  2467. }
  2468. if ( selector.selector !== undefined ) {
  2469. this.selector = selector.selector;
  2470. this.context = selector.context;
  2471. }
  2472. return jQuery.makeArray( selector, this );
  2473. };
  2474. // Give the init function the jQuery prototype for later instantiation
  2475. init.prototype = jQuery.fn;
  2476. // Initialize central reference
  2477. rootjQuery = jQuery( document );
  2478. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  2479. // methods guaranteed to produce a unique set when starting from a unique set
  2480. guaranteedUnique = {
  2481. children: true,
  2482. contents: true,
  2483. next: true,
  2484. prev: true
  2485. };
  2486. jQuery.fn.extend( {
  2487. has: function( target ) {
  2488. var i,
  2489. targets = jQuery( target, this ),
  2490. len = targets.length;
  2491. return this.filter( function() {
  2492. for ( i = 0; i < len; i++ ) {
  2493. if ( jQuery.contains( this, targets[ i ] ) ) {
  2494. return true;
  2495. }
  2496. }
  2497. } );
  2498. },
  2499. closest: function( selectors, context ) {
  2500. var cur,
  2501. i = 0,
  2502. l = this.length,
  2503. matched = [],
  2504. pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
  2505. jQuery( selectors, context || this.context ) :
  2506. 0;
  2507. for ( ; i < l; i++ ) {
  2508. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  2509. // Always skip document fragments
  2510. if ( cur.nodeType < 11 && ( pos ?
  2511. pos.index( cur ) > -1 :
  2512. // Don't pass non-elements to Sizzle
  2513. cur.nodeType === 1 &&
  2514. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  2515. matched.push( cur );
  2516. break;
  2517. }
  2518. }
  2519. }
  2520. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  2521. },
  2522. // Determine the position of an element within
  2523. // the matched set of elements
  2524. index: function( elem ) {
  2525. // No argument, return index in parent
  2526. if ( !elem ) {
  2527. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  2528. }
  2529. // index in selector
  2530. if ( typeof elem === "string" ) {
  2531. return jQuery.inArray( this[ 0 ], jQuery( elem ) );
  2532. }
  2533. // Locate the position of the desired element
  2534. return jQuery.inArray(
  2535. // If it receives a jQuery object, the first element is used
  2536. elem.jquery ? elem[ 0 ] : elem, this );
  2537. },
  2538. add: function( selector, context ) {
  2539. return this.pushStack(
  2540. jQuery.uniqueSort(
  2541. jQuery.merge( this.get(), jQuery( selector, context ) )
  2542. )
  2543. );
  2544. },
  2545. addBack: function( selector ) {
  2546. return this.add( selector == null ?
  2547. this.prevObject : this.prevObject.filter( selector )
  2548. );
  2549. }
  2550. } );
  2551. function sibling( cur, dir ) {
  2552. do {
  2553. cur = cur[ dir ];
  2554. } while ( cur && cur.nodeType !== 1 );
  2555. return cur;
  2556. }
  2557. jQuery.each( {
  2558. parent: function( elem ) {
  2559. var parent = elem.parentNode;
  2560. return parent && parent.nodeType !== 11 ? parent : null;
  2561. },
  2562. parents: function( elem ) {
  2563. return dir( elem, "parentNode" );
  2564. },
  2565. parentsUntil: function( elem, i, until ) {
  2566. return dir( elem, "parentNode", until );
  2567. },
  2568. next: function( elem ) {
  2569. return sibling( elem, "nextSibling" );
  2570. },
  2571. prev: function( elem ) {
  2572. return sibling( elem, "previousSibling" );
  2573. },
  2574. nextAll: function( elem ) {
  2575. return dir( elem, "nextSibling" );
  2576. },
  2577. prevAll: function( elem ) {
  2578. return dir( elem, "previousSibling" );
  2579. },
  2580. nextUntil: function( elem, i, until ) {
  2581. return dir( elem, "nextSibling", until );
  2582. },
  2583. prevUntil: function( elem, i, until ) {
  2584. return dir( elem, "previousSibling", until );
  2585. },
  2586. siblings: function( elem ) {
  2587. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  2588. },
  2589. children: function( elem ) {
  2590. return siblings( elem.firstChild );
  2591. },
  2592. contents: function( elem ) {
  2593. return jQuery.nodeName( elem, "iframe" ) ?
  2594. elem.contentDocument || elem.contentWindow.document :
  2595. jQuery.merge( [], elem.childNodes );
  2596. }
  2597. }, function( name, fn ) {
  2598. jQuery.fn[ name ] = function( until, selector ) {
  2599. var ret = jQuery.map( this, fn, until );
  2600. if ( name.slice( -5 ) !== "Until" ) {
  2601. selector = until;
  2602. }
  2603. if ( selector && typeof selector === "string" ) {
  2604. ret = jQuery.filter( selector, ret );
  2605. }
  2606. if ( this.length > 1 ) {
  2607. // Remove duplicates
  2608. if ( !guaranteedUnique[ name ] ) {
  2609. ret = jQuery.uniqueSort( ret );
  2610. }
  2611. // Reverse order for parents* and prev-derivatives
  2612. if ( rparentsprev.test( name ) ) {
  2613. ret = ret.reverse();
  2614. }
  2615. }
  2616. return this.pushStack( ret );
  2617. };
  2618. } );
  2619. var rnotwhite = ( /\S+/g );
  2620. // Convert String-formatted options into Object-formatted ones
  2621. function createOptions( options ) {
  2622. var object = {};
  2623. jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
  2624. object[ flag ] = true;
  2625. } );
  2626. return object;
  2627. }
  2628. /*
  2629. * Create a callback list using the following parameters:
  2630. *
  2631. * options: an optional list of space-separated options that will change how
  2632. * the callback list behaves or a more traditional option object
  2633. *
  2634. * By default a callback list will act like an event callback list and can be
  2635. * "fired" multiple times.
  2636. *
  2637. * Possible options:
  2638. *
  2639. * once: will ensure the callback list can only be fired once (like a Deferred)
  2640. *
  2641. * memory: will keep track of previous values and will call any callback added
  2642. * after the list has been fired right away with the latest "memorized"
  2643. * values (like a Deferred)
  2644. *
  2645. * unique: will ensure a callback can only be added once (no duplicate in the list)
  2646. *
  2647. * stopOnFalse: interrupt callings when a callback returns false
  2648. *
  2649. */
  2650. jQuery.Callbacks = function( options ) {
  2651. // Convert options from String-formatted to Object-formatted if needed
  2652. // (we check in cache first)
  2653. options = typeof options === "string" ?
  2654. createOptions( options ) :
  2655. jQuery.extend( {}, options );
  2656. var // Flag to know if list is currently firing
  2657. firing,
  2658. // Last fire value for non-forgettable lists
  2659. memory,
  2660. // Flag to know if list was already fired
  2661. fired,
  2662. // Flag to prevent firing
  2663. locked,
  2664. // Actual callback list
  2665. list = [],
  2666. // Queue of execution data for repeatable lists
  2667. queue = [],
  2668. // Index of currently firing callback (modified by add/remove as needed)
  2669. firingIndex = -1,
  2670. // Fire callbacks
  2671. fire = function() {
  2672. // Enforce single-firing
  2673. locked = options.once;
  2674. // Execute callbacks for all pending executions,
  2675. // respecting firingIndex overrides and runtime changes
  2676. fired = firing = true;
  2677. for ( ; queue.length; firingIndex = -1 ) {
  2678. memory = queue.shift();
  2679. while ( ++firingIndex < list.length ) {
  2680. // Run callback and check for early termination
  2681. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  2682. options.stopOnFalse ) {
  2683. // Jump to end and forget the data so .add doesn't re-fire
  2684. firingIndex = list.length;
  2685. memory = false;
  2686. }
  2687. }
  2688. }
  2689. // Forget the data if we're done with it
  2690. if ( !options.memory ) {
  2691. memory = false;
  2692. }
  2693. firing = false;
  2694. // Clean up if we're done firing for good
  2695. if ( locked ) {
  2696. // Keep an empty list if we have data for future add calls
  2697. if ( memory ) {
  2698. list = [];
  2699. // Otherwise, this object is spent
  2700. } else {
  2701. list = "";
  2702. }
  2703. }
  2704. },
  2705. // Actual Callbacks object
  2706. self = {
  2707. // Add a callback or a collection of callbacks to the list
  2708. add: function() {
  2709. if ( list ) {
  2710. // If we have memory from a past run, we should fire after adding
  2711. if ( memory && !firing ) {
  2712. firingIndex = list.length - 1;
  2713. queue.push( memory );
  2714. }
  2715. ( function add( args ) {
  2716. jQuery.each( args, function( _, arg ) {
  2717. if ( jQuery.isFunction( arg ) ) {
  2718. if ( !options.unique || !self.has( arg ) ) {
  2719. list.push( arg );
  2720. }
  2721. } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) {
  2722. // Inspect recursively
  2723. add( arg );
  2724. }
  2725. } );
  2726. } )( arguments );
  2727. if ( memory && !firing ) {
  2728. fire();
  2729. }
  2730. }
  2731. return this;
  2732. },
  2733. // Remove a callback from the list
  2734. remove: function() {
  2735. jQuery.each( arguments, function( _, arg ) {
  2736. var index;
  2737. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  2738. list.splice( index, 1 );
  2739. // Handle firing indexes
  2740. if ( index <= firingIndex ) {
  2741. firingIndex--;
  2742. }
  2743. }
  2744. } );
  2745. return this;
  2746. },
  2747. // Check if a given callback is in the list.
  2748. // If no argument is given, return whether or not list has callbacks attached.
  2749. has: function( fn ) {
  2750. return fn ?
  2751. jQuery.inArray( fn, list ) > -1 :
  2752. list.length > 0;
  2753. },
  2754. // Remove all callbacks from the list
  2755. empty: function() {
  2756. if ( list ) {
  2757. list = [];
  2758. }
  2759. return this;
  2760. },
  2761. // Disable .fire and .add
  2762. // Abort any current/pending executions
  2763. // Clear all callbacks and values
  2764. disable: function() {
  2765. locked = queue = [];
  2766. list = memory = "";
  2767. return this;
  2768. },
  2769. disabled: function() {
  2770. return !list;
  2771. },
  2772. // Disable .fire
  2773. // Also disable .add unless we have memory (since it would have no effect)
  2774. // Abort any pending executions
  2775. lock: function() {
  2776. locked = true;
  2777. if ( !memory ) {
  2778. self.disable();
  2779. }
  2780. return this;
  2781. },
  2782. locked: function() {
  2783. return !!locked;
  2784. },
  2785. // Call all callbacks with the given context and arguments
  2786. fireWith: function( context, args ) {
  2787. if ( !locked ) {
  2788. args = args || [];
  2789. args = [ context, args.slice ? args.slice() : args ];
  2790. queue.push( args );
  2791. if ( !firing ) {
  2792. fire();
  2793. }
  2794. }
  2795. return this;
  2796. },
  2797. // Call all the callbacks with the given arguments
  2798. fire: function() {
  2799. self.fireWith( this, arguments );
  2800. return this;
  2801. },
  2802. // To know if the callbacks have already been called at least once
  2803. fired: function() {
  2804. return !!fired;
  2805. }
  2806. };
  2807. return self;
  2808. };
  2809. jQuery.extend( {
  2810. Deferred: function( func ) {
  2811. var tuples = [
  2812. // action, add listener, listener list, final state
  2813. [ "resolve", "done", jQuery.Callbacks( "once memory" ), "resolved" ],
  2814. [ "reject", "fail", jQuery.Callbacks( "once memory" ), "rejected" ],
  2815. [ "notify", "progress", jQuery.Callbacks( "memory" ) ]
  2816. ],
  2817. state = "pending",
  2818. promise = {
  2819. state: function() {
  2820. return state;
  2821. },
  2822. always: function() {
  2823. deferred.done( arguments ).fail( arguments );
  2824. return this;
  2825. },
  2826. then: function( /* fnDone, fnFail, fnProgress */ ) {
  2827. var fns = arguments;
  2828. return jQuery.Deferred( function( newDefer ) {
  2829. jQuery.each( tuples, function( i, tuple ) {
  2830. var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
  2831. // deferred[ done | fail | progress ] for forwarding actions to newDefer
  2832. deferred[ tuple[ 1 ] ]( function() {
  2833. var returned = fn && fn.apply( this, arguments );
  2834. if ( returned && jQuery.isFunction( returned.promise ) ) {
  2835. returned.promise()
  2836. .progress( newDefer.notify )
  2837. .done( newDefer.resolve )
  2838. .fail( newDefer.reject );
  2839. } else {
  2840. newDefer[ tuple[ 0 ] + "With" ](
  2841. this === promise ? newDefer.promise() : this,
  2842. fn ? [ returned ] : arguments
  2843. );
  2844. }
  2845. } );
  2846. } );
  2847. fns = null;
  2848. } ).promise();
  2849. },
  2850. // Get a promise for this deferred
  2851. // If obj is provided, the promise aspect is added to the object
  2852. promise: function( obj ) {
  2853. return obj != null ? jQuery.extend( obj, promise ) : promise;
  2854. }
  2855. },
  2856. deferred = {};
  2857. // Keep pipe for back-compat
  2858. promise.pipe = promise.then;
  2859. // Add list-specific methods
  2860. jQuery.each( tuples, function( i, tuple ) {
  2861. var list = tuple[ 2 ],
  2862. stateString = tuple[ 3 ];
  2863. // promise[ done | fail | progress ] = list.add
  2864. promise[ tuple[ 1 ] ] = list.add;
  2865. // Handle state
  2866. if ( stateString ) {
  2867. list.add( function() {
  2868. // state = [ resolved | rejected ]
  2869. state = stateString;
  2870. // [ reject_list | resolve_list ].disable; progress_list.lock
  2871. }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
  2872. }
  2873. // deferred[ resolve | reject | notify ]
  2874. deferred[ tuple[ 0 ] ] = function() {
  2875. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments );
  2876. return this;
  2877. };
  2878. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  2879. } );
  2880. // Make the deferred a promise
  2881. promise.promise( deferred );
  2882. // Call given func if any
  2883. if ( func ) {
  2884. func.call( deferred, deferred );
  2885. }
  2886. // All done!
  2887. return deferred;
  2888. },
  2889. // Deferred helper
  2890. when: function( subordinate /* , ..., subordinateN */ ) {
  2891. var i = 0,
  2892. resolveValues = slice.call( arguments ),
  2893. length = resolveValues.length,
  2894. // the count of uncompleted subordinates
  2895. remaining = length !== 1 ||
  2896. ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
  2897. // the master Deferred.
  2898. // If resolveValues consist of only a single Deferred, just use that.
  2899. deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
  2900. // Update function for both resolve and progress values
  2901. updateFunc = function( i, contexts, values ) {
  2902. return function( value ) {
  2903. contexts[ i ] = this;
  2904. values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  2905. if ( values === progressValues ) {
  2906. deferred.notifyWith( contexts, values );
  2907. } else if ( !( --remaining ) ) {
  2908. deferred.resolveWith( contexts, values );
  2909. }
  2910. };
  2911. },
  2912. progressValues, progressContexts, resolveContexts;
  2913. // add listeners to Deferred subordinates; treat others as resolved
  2914. if ( length > 1 ) {
  2915. progressValues = new Array( length );
  2916. progressContexts = new Array( length );
  2917. resolveContexts = new Array( length );
  2918. for ( ; i < length; i++ ) {
  2919. if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
  2920. resolveValues[ i ].promise()
  2921. .progress( updateFunc( i, progressContexts, progressValues ) )
  2922. .done( updateFunc( i, resolveContexts, resolveValues ) )
  2923. .fail( deferred.reject );
  2924. } else {
  2925. --remaining;
  2926. }
  2927. }
  2928. }
  2929. // if we're not waiting on anything, resolve the master
  2930. if ( !remaining ) {
  2931. deferred.resolveWith( resolveContexts, resolveValues );
  2932. }
  2933. return deferred.promise();
  2934. }
  2935. } );
  2936. // The deferred used on DOM ready
  2937. var readyList;
  2938. jQuery.fn.ready = function( fn ) {
  2939. // Add the callback
  2940. jQuery.ready.promise().done( fn );
  2941. return this;
  2942. };
  2943. jQuery.extend( {
  2944. // Is the DOM ready to be used? Set to true once it occurs.
  2945. isReady: false,
  2946. // A counter to track how many items to wait for before
  2947. // the ready event fires. See #6781
  2948. readyWait: 1,
  2949. // Hold (or release) the ready event
  2950. holdReady: function( hold ) {
  2951. if ( hold ) {
  2952. jQuery.readyWait++;
  2953. } else {
  2954. jQuery.ready( true );
  2955. }
  2956. },
  2957. // Handle when the DOM is ready
  2958. ready: function( wait ) {
  2959. // Abort if there are pending holds or we're already ready
  2960. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  2961. return;
  2962. }
  2963. // Remember that the DOM is ready
  2964. jQuery.isReady = true;
  2965. // If a normal DOM Ready event fired, decrement, and wait if need be
  2966. if ( wait !== true && --jQuery.readyWait > 0 ) {
  2967. return;
  2968. }
  2969. // If there are functions bound, to execute
  2970. readyList.resolveWith( document, [ jQuery ] );
  2971. // Trigger any bound ready events
  2972. if ( jQuery.fn.triggerHandler ) {
  2973. jQuery( document ).triggerHandler( "ready" );
  2974. jQuery( document ).off( "ready" );
  2975. }
  2976. }
  2977. } );
  2978. /**
  2979. * Clean-up method for dom ready events
  2980. */
  2981. function detach() {
  2982. if ( document.addEventListener ) {
  2983. document.removeEventListener( "DOMContentLoaded", completed );
  2984. window.removeEventListener( "load", completed );
  2985. } else {
  2986. document.detachEvent( "onreadystatechange", completed );
  2987. window.detachEvent( "onload", completed );
  2988. }
  2989. }
  2990. /**
  2991. * The ready event handler and self cleanup method
  2992. */
  2993. function completed() {
  2994. // readyState === "complete" is good enough for us to call the dom ready in oldIE
  2995. if ( document.addEventListener ||
  2996. window.event.type === "load" ||
  2997. document.readyState === "complete" ) {
  2998. detach();
  2999. jQuery.ready();
  3000. }
  3001. }
  3002. jQuery.ready.promise = function( obj ) {
  3003. if ( !readyList ) {
  3004. readyList = jQuery.Deferred();
  3005. // Catch cases where $(document).ready() is called
  3006. // after the browser event has already occurred.
  3007. // Support: IE6-10
  3008. // Older IE sometimes signals "interactive" too soon
  3009. if ( document.readyState === "complete" ||
  3010. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  3011. // Handle it asynchronously to allow scripts the opportunity to delay ready
  3012. window.setTimeout( jQuery.ready );
  3013. // Standards-based browsers support DOMContentLoaded
  3014. } else if ( document.addEventListener ) {
  3015. // Use the handy event callback
  3016. document.addEventListener( "DOMContentLoaded", completed );
  3017. // A fallback to window.onload, that will always work
  3018. window.addEventListener( "load", completed );
  3019. // If IE event model is used
  3020. } else {
  3021. // Ensure firing before onload, maybe late but safe also for iframes
  3022. document.attachEvent( "onreadystatechange", completed );
  3023. // A fallback to window.onload, that will always work
  3024. window.attachEvent( "onload", completed );
  3025. // If IE and not a frame
  3026. // continually check to see if the document is ready
  3027. var top = false;
  3028. try {
  3029. top = window.frameElement == null && document.documentElement;
  3030. } catch ( e ) {}
  3031. if ( top && top.doScroll ) {
  3032. ( function doScrollCheck() {
  3033. if ( !jQuery.isReady ) {
  3034. try {
  3035. // Use the trick by Diego Perini
  3036. // http://javascript.nwbox.com/IEContentLoaded/
  3037. top.doScroll( "left" );
  3038. } catch ( e ) {
  3039. return window.setTimeout( doScrollCheck, 50 );
  3040. }
  3041. // detach all dom ready events
  3042. detach();
  3043. // and execute any waiting functions
  3044. jQuery.ready();
  3045. }
  3046. } )();
  3047. }
  3048. }
  3049. }
  3050. return readyList.promise( obj );
  3051. };
  3052. // Kick off the DOM ready check even if the user does not
  3053. jQuery.ready.promise();
  3054. // Support: IE<9
  3055. // Iteration over object's inherited properties before its own
  3056. var i;
  3057. for ( i in jQuery( support ) ) {
  3058. break;
  3059. }
  3060. support.ownFirst = i === "0";
  3061. // Note: most support tests are defined in their respective modules.
  3062. // false until the test is run
  3063. support.inlineBlockNeedsLayout = false;
  3064. // Execute ASAP in case we need to set body.style.zoom
  3065. jQuery( function() {
  3066. // Minified: var a,b,c,d
  3067. var val, div, body, container;
  3068. body = document.getElementsByTagName( "body" )[ 0 ];
  3069. if ( !body || !body.style ) {
  3070. // Return for frameset docs that don't have a body
  3071. return;
  3072. }
  3073. // Setup
  3074. div = document.createElement( "div" );
  3075. container = document.createElement( "div" );
  3076. container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
  3077. body.appendChild( container ).appendChild( div );
  3078. if ( typeof div.style.zoom !== "undefined" ) {
  3079. // Support: IE<8
  3080. // Check if natively block-level elements act like inline-block
  3081. // elements when setting their display to 'inline' and giving
  3082. // them layout
  3083. div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1";
  3084. support.inlineBlockNeedsLayout = val = div.offsetWidth === 3;
  3085. if ( val ) {
  3086. // Prevent IE 6 from affecting layout for positioned elements #11048
  3087. // Prevent IE from shrinking the body in IE 7 mode #12869
  3088. // Support: IE<8
  3089. body.style.zoom = 1;
  3090. }
  3091. }
  3092. body.removeChild( container );
  3093. } );
  3094. ( function() {
  3095. var div = document.createElement( "div" );
  3096. // Support: IE<9
  3097. support.deleteExpando = true;
  3098. try {
  3099. delete div.test;
  3100. } catch ( e ) {
  3101. support.deleteExpando = false;
  3102. }
  3103. // Null elements to avoid leaks in IE.
  3104. div = null;
  3105. } )();
  3106. var acceptData = function( elem ) {
  3107. var noData = jQuery.noData[ ( elem.nodeName + " " ).toLowerCase() ],
  3108. nodeType = +elem.nodeType || 1;
  3109. // Do not set data on non-element DOM nodes because it will not be cleared (#8335).
  3110. return nodeType !== 1 && nodeType !== 9 ?
  3111. false :
  3112. // Nodes accept data unless otherwise specified; rejection can be conditional
  3113. !noData || noData !== true && elem.getAttribute( "classid" ) === noData;
  3114. };
  3115. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  3116. rmultiDash = /([A-Z])/g;
  3117. function dataAttr( elem, key, data ) {
  3118. // If nothing was found internally, try to fetch any
  3119. // data from the HTML5 data-* attribute
  3120. if ( data === undefined && elem.nodeType === 1 ) {
  3121. var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
  3122. data = elem.getAttribute( name );
  3123. if ( typeof data === "string" ) {
  3124. try {
  3125. data = data === "true" ? true :
  3126. data === "false" ? false :
  3127. data === "null" ? null :
  3128. // Only convert to a number if it doesn't change the string
  3129. +data + "" === data ? +data :
  3130. rbrace.test( data ) ? jQuery.parseJSON( data ) :
  3131. data;
  3132. } catch ( e ) {}
  3133. // Make sure we set the data so it isn't changed later
  3134. jQuery.data( elem, key, data );
  3135. } else {
  3136. data = undefined;
  3137. }
  3138. }
  3139. return data;
  3140. }
  3141. // checks a cache object for emptiness
  3142. function isEmptyDataObject( obj ) {
  3143. var name;
  3144. for ( name in obj ) {
  3145. // if the public data object is empty, the private is still empty
  3146. if ( name === "data" && jQuery.isEmptyObject( obj[ name ] ) ) {
  3147. continue;
  3148. }
  3149. if ( name !== "toJSON" ) {
  3150. return false;
  3151. }
  3152. }
  3153. return true;
  3154. }
  3155. function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
  3156. if ( !acceptData( elem ) ) {
  3157. return;
  3158. }
  3159. var ret, thisCache,
  3160. internalKey = jQuery.expando,
  3161. // We have to handle DOM nodes and JS objects differently because IE6-7
  3162. // can't GC object references properly across the DOM-JS boundary
  3163. isNode = elem.nodeType,
  3164. // Only DOM nodes need the global jQuery cache; JS object data is
  3165. // attached directly to the object so GC can occur automatically
  3166. cache = isNode ? jQuery.cache : elem,
  3167. // Only defining an ID for JS objects if its cache already exists allows
  3168. // the code to shortcut on the same path as a DOM node with no cache
  3169. id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
  3170. // Avoid doing any more work than we need to when trying to get data on an
  3171. // object that has no data at all
  3172. if ( ( !id || !cache[ id ] || ( !pvt && !cache[ id ].data ) ) &&
  3173. data === undefined && typeof name === "string" ) {
  3174. return;
  3175. }
  3176. if ( !id ) {
  3177. // Only DOM nodes need a new unique ID for each element since their data
  3178. // ends up in the global cache
  3179. if ( isNode ) {
  3180. id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++;
  3181. } else {
  3182. id = internalKey;
  3183. }
  3184. }
  3185. if ( !cache[ id ] ) {
  3186. // Avoid exposing jQuery metadata on plain JS objects when the object
  3187. // is serialized using JSON.stringify
  3188. cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
  3189. }
  3190. // An object can be passed to jQuery.data instead of a key/value pair; this gets
  3191. // shallow copied over onto the existing cache
  3192. if ( typeof name === "object" || typeof name === "function" ) {
  3193. if ( pvt ) {
  3194. cache[ id ] = jQuery.extend( cache[ id ], name );
  3195. } else {
  3196. cache[ id ].data = jQuery.extend( cache[ id ].data, name );
  3197. }
  3198. }
  3199. thisCache = cache[ id ];
  3200. // jQuery data() is stored in a separate object inside the object's internal data
  3201. // cache in order to avoid key collisions between internal data and user-defined
  3202. // data.
  3203. if ( !pvt ) {
  3204. if ( !thisCache.data ) {
  3205. thisCache.data = {};
  3206. }
  3207. thisCache = thisCache.data;
  3208. }
  3209. if ( data !== undefined ) {
  3210. thisCache[ jQuery.camelCase( name ) ] = data;
  3211. }
  3212. // Check for both converted-to-camel and non-converted data property names
  3213. // If a data property was specified
  3214. if ( typeof name === "string" ) {
  3215. // First Try to find as-is property data
  3216. ret = thisCache[ name ];
  3217. // Test for null|undefined property data
  3218. if ( ret == null ) {
  3219. // Try to find the camelCased property
  3220. ret = thisCache[ jQuery.camelCase( name ) ];
  3221. }
  3222. } else {
  3223. ret = thisCache;
  3224. }
  3225. return ret;
  3226. }
  3227. function internalRemoveData( elem, name, pvt ) {
  3228. if ( !acceptData( elem ) ) {
  3229. return;
  3230. }
  3231. var thisCache, i,
  3232. isNode = elem.nodeType,
  3233. // See jQuery.data for more information
  3234. cache = isNode ? jQuery.cache : elem,
  3235. id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
  3236. // If there is already no cache entry for this object, there is no
  3237. // purpose in continuing
  3238. if ( !cache[ id ] ) {
  3239. return;
  3240. }
  3241. if ( name ) {
  3242. thisCache = pvt ? cache[ id ] : cache[ id ].data;
  3243. if ( thisCache ) {
  3244. // Support array or space separated string names for data keys
  3245. if ( !jQuery.isArray( name ) ) {
  3246. // try the string as a key before any manipulation
  3247. if ( name in thisCache ) {
  3248. name = [ name ];
  3249. } else {
  3250. // split the camel cased version by spaces unless a key with the spaces exists
  3251. name = jQuery.camelCase( name );
  3252. if ( name in thisCache ) {
  3253. name = [ name ];
  3254. } else {
  3255. name = name.split( " " );
  3256. }
  3257. }
  3258. } else {
  3259. // If "name" is an array of keys...
  3260. // When data is initially created, via ("key", "val") signature,
  3261. // keys will be converted to camelCase.
  3262. // Since there is no way to tell _how_ a key was added, remove
  3263. // both plain key and camelCase key. #12786
  3264. // This will only penalize the array argument path.
  3265. name = name.concat( jQuery.map( name, jQuery.camelCase ) );
  3266. }
  3267. i = name.length;
  3268. while ( i-- ) {
  3269. delete thisCache[ name[ i ] ];
  3270. }
  3271. // If there is no data left in the cache, we want to continue
  3272. // and let the cache object itself get destroyed
  3273. if ( pvt ? !isEmptyDataObject( thisCache ) : !jQuery.isEmptyObject( thisCache ) ) {
  3274. return;
  3275. }
  3276. }
  3277. }
  3278. // See jQuery.data for more information
  3279. if ( !pvt ) {
  3280. delete cache[ id ].data;
  3281. // Don't destroy the parent cache unless the internal data object
  3282. // had been the only thing left in it
  3283. if ( !isEmptyDataObject( cache[ id ] ) ) {
  3284. return;
  3285. }
  3286. }
  3287. // Destroy the cache
  3288. if ( isNode ) {
  3289. jQuery.cleanData( [ elem ], true );
  3290. // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
  3291. /* jshint eqeqeq: false */
  3292. } else if ( support.deleteExpando || cache != cache.window ) {
  3293. /* jshint eqeqeq: true */
  3294. delete cache[ id ];
  3295. // When all else fails, undefined
  3296. } else {
  3297. cache[ id ] = undefined;
  3298. }
  3299. }
  3300. jQuery.extend( {
  3301. cache: {},
  3302. // The following elements (space-suffixed to avoid Object.prototype collisions)
  3303. // throw uncatchable exceptions if you attempt to set expando properties
  3304. noData: {
  3305. "applet ": true,
  3306. "embed ": true,
  3307. // ...but Flash objects (which have this classid) *can* handle expandos
  3308. "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
  3309. },
  3310. hasData: function( elem ) {
  3311. elem = elem.nodeType ? jQuery.cache[ elem[ jQuery.expando ] ] : elem[ jQuery.expando ];
  3312. return !!elem && !isEmptyDataObject( elem );
  3313. },
  3314. data: function( elem, name, data ) {
  3315. return internalData( elem, name, data );
  3316. },
  3317. removeData: function( elem, name ) {
  3318. return internalRemoveData( elem, name );
  3319. },
  3320. // For internal use only.
  3321. _data: function( elem, name, data ) {
  3322. return internalData( elem, name, data, true );
  3323. },
  3324. _removeData: function( elem, name ) {
  3325. return internalRemoveData( elem, name, true );
  3326. }
  3327. } );
  3328. jQuery.fn.extend( {
  3329. data: function( key, value ) {
  3330. var i, name, data,
  3331. elem = this[ 0 ],
  3332. attrs = elem && elem.attributes;
  3333. // Special expections of .data basically thwart jQuery.access,
  3334. // so implement the relevant behavior ourselves
  3335. // Gets all values
  3336. if ( key === undefined ) {
  3337. if ( this.length ) {
  3338. data = jQuery.data( elem );
  3339. if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
  3340. i = attrs.length;
  3341. while ( i-- ) {
  3342. // Support: IE11+
  3343. // The attrs elements can be null (#14894)
  3344. if ( attrs[ i ] ) {
  3345. name = attrs[ i ].name;
  3346. if ( name.indexOf( "data-" ) === 0 ) {
  3347. name = jQuery.camelCase( name.slice( 5 ) );
  3348. dataAttr( elem, name, data[ name ] );
  3349. }
  3350. }
  3351. }
  3352. jQuery._data( elem, "parsedAttrs", true );
  3353. }
  3354. }
  3355. return data;
  3356. }
  3357. // Sets multiple values
  3358. if ( typeof key === "object" ) {
  3359. return this.each( function() {
  3360. jQuery.data( this, key );
  3361. } );
  3362. }
  3363. return arguments.length > 1 ?
  3364. // Sets one value
  3365. this.each( function() {
  3366. jQuery.data( this, key, value );
  3367. } ) :
  3368. // Gets one value
  3369. // Try to fetch any internally stored data first
  3370. elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined;
  3371. },
  3372. removeData: function( key ) {
  3373. return this.each( function() {
  3374. jQuery.removeData( this, key );
  3375. } );
  3376. }
  3377. } );
  3378. jQuery.extend( {
  3379. queue: function( elem, type, data ) {
  3380. var queue;
  3381. if ( elem ) {
  3382. type = ( type || "fx" ) + "queue";
  3383. queue = jQuery._data( elem, type );
  3384. // Speed up dequeue by getting out quickly if this is just a lookup
  3385. if ( data ) {
  3386. if ( !queue || jQuery.isArray( data ) ) {
  3387. queue = jQuery._data( elem, type, jQuery.makeArray( data ) );
  3388. } else {
  3389. queue.push( data );
  3390. }
  3391. }
  3392. return queue || [];
  3393. }
  3394. },
  3395. dequeue: function( elem, type ) {
  3396. type = type || "fx";
  3397. var queue = jQuery.queue( elem, type ),
  3398. startLength = queue.length,
  3399. fn = queue.shift(),
  3400. hooks = jQuery._queueHooks( elem, type ),
  3401. next = function() {
  3402. jQuery.dequeue( elem, type );
  3403. };
  3404. // If the fx queue is dequeued, always remove the progress sentinel
  3405. if ( fn === "inprogress" ) {
  3406. fn = queue.shift();
  3407. startLength--;
  3408. }
  3409. if ( fn ) {
  3410. // Add a progress sentinel to prevent the fx queue from being
  3411. // automatically dequeued
  3412. if ( type === "fx" ) {
  3413. queue.unshift( "inprogress" );
  3414. }
  3415. // clear up the last queue stop function
  3416. delete hooks.stop;
  3417. fn.call( elem, next, hooks );
  3418. }
  3419. if ( !startLength && hooks ) {
  3420. hooks.empty.fire();
  3421. }
  3422. },
  3423. // not intended for public consumption - generates a queueHooks object,
  3424. // or returns the current one
  3425. _queueHooks: function( elem, type ) {
  3426. var key = type + "queueHooks";
  3427. return jQuery._data( elem, key ) || jQuery._data( elem, key, {
  3428. empty: jQuery.Callbacks( "once memory" ).add( function() {
  3429. jQuery._removeData( elem, type + "queue" );
  3430. jQuery._removeData( elem, key );
  3431. } )
  3432. } );
  3433. }
  3434. } );
  3435. jQuery.fn.extend( {
  3436. queue: function( type, data ) {
  3437. var setter = 2;
  3438. if ( typeof type !== "string" ) {
  3439. data = type;
  3440. type = "fx";
  3441. setter--;
  3442. }
  3443. if ( arguments.length < setter ) {
  3444. return jQuery.queue( this[ 0 ], type );
  3445. }
  3446. return data === undefined ?
  3447. this :
  3448. this.each( function() {
  3449. var queue = jQuery.queue( this, type, data );
  3450. // ensure a hooks for this queue
  3451. jQuery._queueHooks( this, type );
  3452. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  3453. jQuery.dequeue( this, type );
  3454. }
  3455. } );
  3456. },
  3457. dequeue: function( type ) {
  3458. return this.each( function() {
  3459. jQuery.dequeue( this, type );
  3460. } );
  3461. },
  3462. clearQueue: function( type ) {
  3463. return this.queue( type || "fx", [] );
  3464. },
  3465. // Get a promise resolved when queues of a certain type
  3466. // are emptied (fx is the type by default)
  3467. promise: function( type, obj ) {
  3468. var tmp,
  3469. count = 1,
  3470. defer = jQuery.Deferred(),
  3471. elements = this,
  3472. i = this.length,
  3473. resolve = function() {
  3474. if ( !( --count ) ) {
  3475. defer.resolveWith( elements, [ elements ] );
  3476. }
  3477. };
  3478. if ( typeof type !== "string" ) {
  3479. obj = type;
  3480. type = undefined;
  3481. }
  3482. type = type || "fx";
  3483. while ( i-- ) {
  3484. tmp = jQuery._data( elements[ i ], type + "queueHooks" );
  3485. if ( tmp && tmp.empty ) {
  3486. count++;
  3487. tmp.empty.add( resolve );
  3488. }
  3489. }
  3490. resolve();
  3491. return defer.promise( obj );
  3492. }
  3493. } );
  3494. ( function() {
  3495. var shrinkWrapBlocksVal;
  3496. support.shrinkWrapBlocks = function() {
  3497. if ( shrinkWrapBlocksVal != null ) {
  3498. return shrinkWrapBlocksVal;
  3499. }
  3500. // Will be changed later if needed.
  3501. shrinkWrapBlocksVal = false;
  3502. // Minified: var b,c,d
  3503. var div, body, container;
  3504. body = document.getElementsByTagName( "body" )[ 0 ];
  3505. if ( !body || !body.style ) {
  3506. // Test fired too early or in an unsupported environment, exit.
  3507. return;
  3508. }
  3509. // Setup
  3510. div = document.createElement( "div" );
  3511. container = document.createElement( "div" );
  3512. container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
  3513. body.appendChild( container ).appendChild( div );
  3514. // Support: IE6
  3515. // Check if elements with layout shrink-wrap their children
  3516. if ( typeof div.style.zoom !== "undefined" ) {
  3517. // Reset CSS: box-sizing; display; margin; border
  3518. div.style.cssText =
  3519. // Support: Firefox<29, Android 2.3
  3520. // Vendor-prefix box-sizing
  3521. "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
  3522. "box-sizing:content-box;display:block;margin:0;border:0;" +
  3523. "padding:1px;width:1px;zoom:1";
  3524. div.appendChild( document.createElement( "div" ) ).style.width = "5px";
  3525. shrinkWrapBlocksVal = div.offsetWidth !== 3;
  3526. }
  3527. body.removeChild( container );
  3528. return shrinkWrapBlocksVal;
  3529. };
  3530. } )();
  3531. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  3532. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  3533. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  3534. var isHidden = function( elem, el ) {
  3535. // isHidden might be called from jQuery#filter function;
  3536. // in that case, element will be second argument
  3537. elem = el || elem;
  3538. return jQuery.css( elem, "display" ) === "none" ||
  3539. !jQuery.contains( elem.ownerDocument, elem );
  3540. };
  3541. function adjustCSS( elem, prop, valueParts, tween ) {
  3542. var adjusted,
  3543. scale = 1,
  3544. maxIterations = 20,
  3545. currentValue = tween ?
  3546. function() { return tween.cur(); } :
  3547. function() { return jQuery.css( elem, prop, "" ); },
  3548. initial = currentValue(),
  3549. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  3550. // Starting value computation is required for potential unit mismatches
  3551. initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  3552. rcssNum.exec( jQuery.css( elem, prop ) );
  3553. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  3554. // Trust units reported by jQuery.css
  3555. unit = unit || initialInUnit[ 3 ];
  3556. // Make sure we update the tween properties later on
  3557. valueParts = valueParts || [];
  3558. // Iteratively approximate from a nonzero starting point
  3559. initialInUnit = +initial || 1;
  3560. do {
  3561. // If previous iteration zeroed out, double until we get *something*.
  3562. // Use string for doubling so we don't accidentally see scale as unchanged below
  3563. scale = scale || ".5";
  3564. // Adjust and apply
  3565. initialInUnit = initialInUnit / scale;
  3566. jQuery.style( elem, prop, initialInUnit + unit );
  3567. // Update scale, tolerating zero or NaN from tween.cur()
  3568. // Break the loop if scale is unchanged or perfect, or if we've just had enough.
  3569. } while (
  3570. scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
  3571. );
  3572. }
  3573. if ( valueParts ) {
  3574. initialInUnit = +initialInUnit || +initial || 0;
  3575. // Apply relative offset (+=/-=) if specified
  3576. adjusted = valueParts[ 1 ] ?
  3577. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  3578. +valueParts[ 2 ];
  3579. if ( tween ) {
  3580. tween.unit = unit;
  3581. tween.start = initialInUnit;
  3582. tween.end = adjusted;
  3583. }
  3584. }
  3585. return adjusted;
  3586. }
  3587. // Multifunctional method to get and set values of a collection
  3588. // The value/s can optionally be executed if it's a function
  3589. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  3590. var i = 0,
  3591. length = elems.length,
  3592. bulk = key == null;
  3593. // Sets many values
  3594. if ( jQuery.type( key ) === "object" ) {
  3595. chainable = true;
  3596. for ( i in key ) {
  3597. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  3598. }
  3599. // Sets one value
  3600. } else if ( value !== undefined ) {
  3601. chainable = true;
  3602. if ( !jQuery.isFunction( value ) ) {
  3603. raw = true;
  3604. }
  3605. if ( bulk ) {
  3606. // Bulk operations run against the entire set
  3607. if ( raw ) {
  3608. fn.call( elems, value );
  3609. fn = null;
  3610. // ...except when executing function values
  3611. } else {
  3612. bulk = fn;
  3613. fn = function( elem, key, value ) {
  3614. return bulk.call( jQuery( elem ), value );
  3615. };
  3616. }
  3617. }
  3618. if ( fn ) {
  3619. for ( ; i < length; i++ ) {
  3620. fn(
  3621. elems[ i ],
  3622. key,
  3623. raw ? value : value.call( elems[ i ], i, fn( elems[ i ], key ) )
  3624. );
  3625. }
  3626. }
  3627. }
  3628. return chainable ?
  3629. elems :
  3630. // Gets
  3631. bulk ?
  3632. fn.call( elems ) :
  3633. length ? fn( elems[ 0 ], key ) : emptyGet;
  3634. };
  3635. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  3636. var rtagName = ( /<([\w:-]+)/ );
  3637. var rscriptType = ( /^$|\/(?:java|ecma)script/i );
  3638. var rleadingWhitespace = ( /^\s+/ );
  3639. var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|" +
  3640. "details|dialog|figcaption|figure|footer|header|hgroup|main|" +
  3641. "mark|meter|nav|output|picture|progress|section|summary|template|time|video";
  3642. function createSafeFragment( document ) {
  3643. var list = nodeNames.split( "|" ),
  3644. safeFrag = document.createDocumentFragment();
  3645. if ( safeFrag.createElement ) {
  3646. while ( list.length ) {
  3647. safeFrag.createElement(
  3648. list.pop()
  3649. );
  3650. }
  3651. }
  3652. return safeFrag;
  3653. }
  3654. ( function() {
  3655. var div = document.createElement( "div" ),
  3656. fragment = document.createDocumentFragment(),
  3657. input = document.createElement( "input" );
  3658. // Setup
  3659. div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
  3660. // IE strips leading whitespace when .innerHTML is used
  3661. support.leadingWhitespace = div.firstChild.nodeType === 3;
  3662. // Make sure that tbody elements aren't automatically inserted
  3663. // IE will insert them into empty tables
  3664. support.tbody = !div.getElementsByTagName( "tbody" ).length;
  3665. // Make sure that link elements get serialized correctly by innerHTML
  3666. // This requires a wrapper element in IE
  3667. support.htmlSerialize = !!div.getElementsByTagName( "link" ).length;
  3668. // Makes sure cloning an html5 element does not cause problems
  3669. // Where outerHTML is undefined, this still works
  3670. support.html5Clone =
  3671. document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav></:nav>";
  3672. // Check if a disconnected checkbox will retain its checked
  3673. // value of true after appended to the DOM (IE6/7)
  3674. input.type = "checkbox";
  3675. input.checked = true;
  3676. fragment.appendChild( input );
  3677. support.appendChecked = input.checked;
  3678. // Make sure textarea (and checkbox) defaultValue is properly cloned
  3679. // Support: IE6-IE11+
  3680. div.innerHTML = "<textarea>x</textarea>";
  3681. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  3682. // #11217 - WebKit loses check when the name is after the checked attribute
  3683. fragment.appendChild( div );
  3684. // Support: Windows Web Apps (WWA)
  3685. // `name` and `type` must use .setAttribute for WWA (#14901)
  3686. input = document.createElement( "input" );
  3687. input.setAttribute( "type", "radio" );
  3688. input.setAttribute( "checked", "checked" );
  3689. input.setAttribute( "name", "t" );
  3690. div.appendChild( input );
  3691. // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
  3692. // old WebKit doesn't clone checked state correctly in fragments
  3693. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  3694. // Support: IE<9
  3695. // Cloned elements keep attachEvent handlers, we use addEventListener on IE9+
  3696. support.noCloneEvent = !!div.addEventListener;
  3697. // Support: IE<9
  3698. // Since attributes and properties are the same in IE,
  3699. // cleanData must set properties to undefined rather than use removeAttribute
  3700. div[ jQuery.expando ] = 1;
  3701. support.attributes = !div.getAttribute( jQuery.expando );
  3702. } )();
  3703. // We have to close these tags to support XHTML (#13200)
  3704. var wrapMap = {
  3705. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  3706. legend: [ 1, "<fieldset>", "</fieldset>" ],
  3707. area: [ 1, "<map>", "</map>" ],
  3708. // Support: IE8
  3709. param: [ 1, "<object>", "</object>" ],
  3710. thead: [ 1, "<table>", "</table>" ],
  3711. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  3712. col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
  3713. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  3714. // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
  3715. // unless wrapped in a div with non-breaking characters in front of it.
  3716. _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
  3717. };
  3718. // Support: IE8-IE9
  3719. wrapMap.optgroup = wrapMap.option;
  3720. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  3721. wrapMap.th = wrapMap.td;
  3722. function getAll( context, tag ) {
  3723. var elems, elem,
  3724. i = 0,
  3725. found = typeof context.getElementsByTagName !== "undefined" ?
  3726. context.getElementsByTagName( tag || "*" ) :
  3727. typeof context.querySelectorAll !== "undefined" ?
  3728. context.querySelectorAll( tag || "*" ) :
  3729. undefined;
  3730. if ( !found ) {
  3731. for ( found = [], elems = context.childNodes || context;
  3732. ( elem = elems[ i ] ) != null;
  3733. i++
  3734. ) {
  3735. if ( !tag || jQuery.nodeName( elem, tag ) ) {
  3736. found.push( elem );
  3737. } else {
  3738. jQuery.merge( found, getAll( elem, tag ) );
  3739. }
  3740. }
  3741. }
  3742. return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
  3743. jQuery.merge( [ context ], found ) :
  3744. found;
  3745. }
  3746. // Mark scripts as having already been evaluated
  3747. function setGlobalEval( elems, refElements ) {
  3748. var elem,
  3749. i = 0;
  3750. for ( ; ( elem = elems[ i ] ) != null; i++ ) {
  3751. jQuery._data(
  3752. elem,
  3753. "globalEval",
  3754. !refElements || jQuery._data( refElements[ i ], "globalEval" )
  3755. );
  3756. }
  3757. }
  3758. var rhtml = /<|&#?\w+;/,
  3759. rtbody = /<tbody/i;
  3760. function fixDefaultChecked( elem ) {
  3761. if ( rcheckableType.test( elem.type ) ) {
  3762. elem.defaultChecked = elem.checked;
  3763. }
  3764. }
  3765. function buildFragment( elems, context, scripts, selection, ignored ) {
  3766. var j, elem, contains,
  3767. tmp, tag, tbody, wrap,
  3768. l = elems.length,
  3769. // Ensure a safe fragment
  3770. safe = createSafeFragment( context ),
  3771. nodes = [],
  3772. i = 0;
  3773. for ( ; i < l; i++ ) {
  3774. elem = elems[ i ];
  3775. if ( elem || elem === 0 ) {
  3776. // Add nodes directly
  3777. if ( jQuery.type( elem ) === "object" ) {
  3778. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  3779. // Convert non-html into a text node
  3780. } else if ( !rhtml.test( elem ) ) {
  3781. nodes.push( context.createTextNode( elem ) );
  3782. // Convert html into DOM nodes
  3783. } else {
  3784. tmp = tmp || safe.appendChild( context.createElement( "div" ) );
  3785. // Deserialize a standard representation
  3786. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  3787. wrap = wrapMap[ tag ] || wrapMap._default;
  3788. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  3789. // Descend through wrappers to the right content
  3790. j = wrap[ 0 ];
  3791. while ( j-- ) {
  3792. tmp = tmp.lastChild;
  3793. }
  3794. // Manually add leading whitespace removed by IE
  3795. if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
  3796. nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[ 0 ] ) );
  3797. }
  3798. // Remove IE's autoinserted <tbody> from table fragments
  3799. if ( !support.tbody ) {
  3800. // String was a <table>, *may* have spurious <tbody>
  3801. elem = tag === "table" && !rtbody.test( elem ) ?
  3802. tmp.firstChild :
  3803. // String was a bare <thead> or <tfoot>
  3804. wrap[ 1 ] === "<table>" && !rtbody.test( elem ) ?
  3805. tmp :
  3806. 0;
  3807. j = elem && elem.childNodes.length;
  3808. while ( j-- ) {
  3809. if ( jQuery.nodeName( ( tbody = elem.childNodes[ j ] ), "tbody" ) &&
  3810. !tbody.childNodes.length ) {
  3811. elem.removeChild( tbody );
  3812. }
  3813. }
  3814. }
  3815. jQuery.merge( nodes, tmp.childNodes );
  3816. // Fix #12392 for WebKit and IE > 9
  3817. tmp.textContent = "";
  3818. // Fix #12392 for oldIE
  3819. while ( tmp.firstChild ) {
  3820. tmp.removeChild( tmp.firstChild );
  3821. }
  3822. // Remember the top-level container for proper cleanup
  3823. tmp = safe.lastChild;
  3824. }
  3825. }
  3826. }
  3827. // Fix #11356: Clear elements from fragment
  3828. if ( tmp ) {
  3829. safe.removeChild( tmp );
  3830. }
  3831. // Reset defaultChecked for any radios and checkboxes
  3832. // about to be appended to the DOM in IE 6/7 (#8060)
  3833. if ( !support.appendChecked ) {
  3834. jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
  3835. }
  3836. i = 0;
  3837. while ( ( elem = nodes[ i++ ] ) ) {
  3838. // Skip elements already in the context collection (trac-4087)
  3839. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  3840. if ( ignored ) {
  3841. ignored.push( elem );
  3842. }
  3843. continue;
  3844. }
  3845. contains = jQuery.contains( elem.ownerDocument, elem );
  3846. // Append to fragment
  3847. tmp = getAll( safe.appendChild( elem ), "script" );
  3848. // Preserve script evaluation history
  3849. if ( contains ) {
  3850. setGlobalEval( tmp );
  3851. }
  3852. // Capture executables
  3853. if ( scripts ) {
  3854. j = 0;
  3855. while ( ( elem = tmp[ j++ ] ) ) {
  3856. if ( rscriptType.test( elem.type || "" ) ) {
  3857. scripts.push( elem );
  3858. }
  3859. }
  3860. }
  3861. }
  3862. tmp = null;
  3863. return safe;
  3864. }
  3865. ( function() {
  3866. var i, eventName,
  3867. div = document.createElement( "div" );
  3868. // Support: IE<9 (lack submit/change bubble), Firefox (lack focus(in | out) events)
  3869. for ( i in { submit: true, change: true, focusin: true } ) {
  3870. eventName = "on" + i;
  3871. if ( !( support[ i ] = eventName in window ) ) {
  3872. // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
  3873. div.setAttribute( eventName, "t" );
  3874. support[ i ] = div.attributes[ eventName ].expando === false;
  3875. }
  3876. }
  3877. // Null elements to avoid leaks in IE.
  3878. div = null;
  3879. } )();
  3880. var rformElems = /^(?:input|select|textarea)$/i,
  3881. rkeyEvent = /^key/,
  3882. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  3883. rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  3884. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  3885. function returnTrue() {
  3886. return true;
  3887. }
  3888. function returnFalse() {
  3889. return false;
  3890. }
  3891. // Support: IE9
  3892. // See #13393 for more info
  3893. function safeActiveElement() {
  3894. try {
  3895. return document.activeElement;
  3896. } catch ( err ) { }
  3897. }
  3898. function on( elem, types, selector, data, fn, one ) {
  3899. var origFn, type;
  3900. // Types can be a map of types/handlers
  3901. if ( typeof types === "object" ) {
  3902. // ( types-Object, selector, data )
  3903. if ( typeof selector !== "string" ) {
  3904. // ( types-Object, data )
  3905. data = data || selector;
  3906. selector = undefined;
  3907. }
  3908. for ( type in types ) {
  3909. on( elem, type, selector, data, types[ type ], one );
  3910. }
  3911. return elem;
  3912. }
  3913. if ( data == null && fn == null ) {
  3914. // ( types, fn )
  3915. fn = selector;
  3916. data = selector = undefined;
  3917. } else if ( fn == null ) {
  3918. if ( typeof selector === "string" ) {
  3919. // ( types, selector, fn )
  3920. fn = data;
  3921. data = undefined;
  3922. } else {
  3923. // ( types, data, fn )
  3924. fn = data;
  3925. data = selector;
  3926. selector = undefined;
  3927. }
  3928. }
  3929. if ( fn === false ) {
  3930. fn = returnFalse;
  3931. } else if ( !fn ) {
  3932. return elem;
  3933. }
  3934. if ( one === 1 ) {
  3935. origFn = fn;
  3936. fn = function( event ) {
  3937. // Can use an empty set, since event contains the info
  3938. jQuery().off( event );
  3939. return origFn.apply( this, arguments );
  3940. };
  3941. // Use same guid so caller can remove using origFn
  3942. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  3943. }
  3944. return elem.each( function() {
  3945. jQuery.event.add( this, types, fn, data, selector );
  3946. } );
  3947. }
  3948. /*
  3949. * Helper functions for managing events -- not part of the public interface.
  3950. * Props to Dean Edwards' addEvent library for many of the ideas.
  3951. */
  3952. jQuery.event = {
  3953. global: {},
  3954. add: function( elem, types, handler, data, selector ) {
  3955. var tmp, events, t, handleObjIn,
  3956. special, eventHandle, handleObj,
  3957. handlers, type, namespaces, origType,
  3958. elemData = jQuery._data( elem );
  3959. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  3960. if ( !elemData ) {
  3961. return;
  3962. }
  3963. // Caller can pass in an object of custom data in lieu of the handler
  3964. if ( handler.handler ) {
  3965. handleObjIn = handler;
  3966. handler = handleObjIn.handler;
  3967. selector = handleObjIn.selector;
  3968. }
  3969. // Make sure that the handler has a unique ID, used to find/remove it later
  3970. if ( !handler.guid ) {
  3971. handler.guid = jQuery.guid++;
  3972. }
  3973. // Init the element's event structure and main handler, if this is the first
  3974. if ( !( events = elemData.events ) ) {
  3975. events = elemData.events = {};
  3976. }
  3977. if ( !( eventHandle = elemData.handle ) ) {
  3978. eventHandle = elemData.handle = function( e ) {
  3979. // Discard the second event of a jQuery.event.trigger() and
  3980. // when an event is called after a page has unloaded
  3981. return typeof jQuery !== "undefined" &&
  3982. ( !e || jQuery.event.triggered !== e.type ) ?
  3983. jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
  3984. undefined;
  3985. };
  3986. // Add elem as a property of the handle fn to prevent a memory leak
  3987. // with IE non-native events
  3988. eventHandle.elem = elem;
  3989. }
  3990. // Handle multiple events separated by a space
  3991. types = ( types || "" ).match( rnotwhite ) || [ "" ];
  3992. t = types.length;
  3993. while ( t-- ) {
  3994. tmp = rtypenamespace.exec( types[ t ] ) || [];
  3995. type = origType = tmp[ 1 ];
  3996. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  3997. // There *must* be a type, no attaching namespace-only handlers
  3998. if ( !type ) {
  3999. continue;
  4000. }
  4001. // If event changes its type, use the special event handlers for the changed type
  4002. special = jQuery.event.special[ type ] || {};
  4003. // If selector defined, determine special event api type, otherwise given type
  4004. type = ( selector ? special.delegateType : special.bindType ) || type;
  4005. // Update special based on newly reset type
  4006. special = jQuery.event.special[ type ] || {};
  4007. // handleObj is passed to all event handlers
  4008. handleObj = jQuery.extend( {
  4009. type: type,
  4010. origType: origType,
  4011. data: data,
  4012. handler: handler,
  4013. guid: handler.guid,
  4014. selector: selector,
  4015. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  4016. namespace: namespaces.join( "." )
  4017. }, handleObjIn );
  4018. // Init the event handler queue if we're the first
  4019. if ( !( handlers = events[ type ] ) ) {
  4020. handlers = events[ type ] = [];
  4021. handlers.delegateCount = 0;
  4022. // Only use addEventListener/attachEvent if the special events handler returns false
  4023. if ( !special.setup ||
  4024. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  4025. // Bind the global event handler to the element
  4026. if ( elem.addEventListener ) {
  4027. elem.addEventListener( type, eventHandle, false );
  4028. } else if ( elem.attachEvent ) {
  4029. elem.attachEvent( "on" + type, eventHandle );
  4030. }
  4031. }
  4032. }
  4033. if ( special.add ) {
  4034. special.add.call( elem, handleObj );
  4035. if ( !handleObj.handler.guid ) {
  4036. handleObj.handler.guid = handler.guid;
  4037. }
  4038. }
  4039. // Add to the element's handler list, delegates in front
  4040. if ( selector ) {
  4041. handlers.splice( handlers.delegateCount++, 0, handleObj );
  4042. } else {
  4043. handlers.push( handleObj );
  4044. }
  4045. // Keep track of which events have ever been used, for event optimization
  4046. jQuery.event.global[ type ] = true;
  4047. }
  4048. // Nullify elem to prevent memory leaks in IE
  4049. elem = null;
  4050. },
  4051. // Detach an event or set of events from an element
  4052. remove: function( elem, types, handler, selector, mappedTypes ) {
  4053. var j, handleObj, tmp,
  4054. origCount, t, events,
  4055. special, handlers, type,
  4056. namespaces, origType,
  4057. elemData = jQuery.hasData( elem ) && jQuery._data( elem );
  4058. if ( !elemData || !( events = elemData.events ) ) {
  4059. return;
  4060. }
  4061. // Once for each type.namespace in types; type may be omitted
  4062. types = ( types || "" ).match( rnotwhite ) || [ "" ];
  4063. t = types.length;
  4064. while ( t-- ) {
  4065. tmp = rtypenamespace.exec( types[ t ] ) || [];
  4066. type = origType = tmp[ 1 ];
  4067. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  4068. // Unbind all events (on this namespace, if provided) for the element
  4069. if ( !type ) {
  4070. for ( type in events ) {
  4071. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  4072. }
  4073. continue;
  4074. }
  4075. special = jQuery.event.special[ type ] || {};
  4076. type = ( selector ? special.delegateType : special.bindType ) || type;
  4077. handlers = events[ type ] || [];
  4078. tmp = tmp[ 2 ] &&
  4079. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  4080. // Remove matching events
  4081. origCount = j = handlers.length;
  4082. while ( j-- ) {
  4083. handleObj = handlers[ j ];
  4084. if ( ( mappedTypes || origType === handleObj.origType ) &&
  4085. ( !handler || handler.guid === handleObj.guid ) &&
  4086. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  4087. ( !selector || selector === handleObj.selector ||
  4088. selector === "**" && handleObj.selector ) ) {
  4089. handlers.splice( j, 1 );
  4090. if ( handleObj.selector ) {
  4091. handlers.delegateCount--;
  4092. }
  4093. if ( special.remove ) {
  4094. special.remove.call( elem, handleObj );
  4095. }
  4096. }
  4097. }
  4098. // Remove generic event handler if we removed something and no more handlers exist
  4099. // (avoids potential for endless recursion during removal of special event handlers)
  4100. if ( origCount && !handlers.length ) {
  4101. if ( !special.teardown ||
  4102. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  4103. jQuery.removeEvent( elem, type, elemData.handle );
  4104. }
  4105. delete events[ type ];
  4106. }
  4107. }
  4108. // Remove the expando if it's no longer used
  4109. if ( jQuery.isEmptyObject( events ) ) {
  4110. delete elemData.handle;
  4111. // removeData also checks for emptiness and clears the expando if empty
  4112. // so use it instead of delete
  4113. jQuery._removeData( elem, "events" );
  4114. }
  4115. },
  4116. trigger: function( event, data, elem, onlyHandlers ) {
  4117. var handle, ontype, cur,
  4118. bubbleType, special, tmp, i,
  4119. eventPath = [ elem || document ],
  4120. type = hasOwn.call( event, "type" ) ? event.type : event,
  4121. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  4122. cur = tmp = elem = elem || document;
  4123. // Don't do events on text and comment nodes
  4124. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  4125. return;
  4126. }
  4127. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  4128. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  4129. return;
  4130. }
  4131. if ( type.indexOf( "." ) > -1 ) {
  4132. // Namespaced trigger; create a regexp to match event type in handle()
  4133. namespaces = type.split( "." );
  4134. type = namespaces.shift();
  4135. namespaces.sort();
  4136. }
  4137. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  4138. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  4139. event = event[ jQuery.expando ] ?
  4140. event :
  4141. new jQuery.Event( type, typeof event === "object" && event );
  4142. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  4143. event.isTrigger = onlyHandlers ? 2 : 3;
  4144. event.namespace = namespaces.join( "." );
  4145. event.rnamespace = event.namespace ?
  4146. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  4147. null;
  4148. // Clean up the event in case it is being reused
  4149. event.result = undefined;
  4150. if ( !event.target ) {
  4151. event.target = elem;
  4152. }
  4153. // Clone any incoming data and prepend the event, creating the handler arg list
  4154. data = data == null ?
  4155. [ event ] :
  4156. jQuery.makeArray( data, [ event ] );
  4157. // Allow special events to draw outside the lines
  4158. special = jQuery.event.special[ type ] || {};
  4159. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  4160. return;
  4161. }
  4162. // Determine event propagation path in advance, per W3C events spec (#9951)
  4163. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  4164. if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
  4165. bubbleType = special.delegateType || type;
  4166. if ( !rfocusMorph.test( bubbleType + type ) ) {
  4167. cur = cur.parentNode;
  4168. }
  4169. for ( ; cur; cur = cur.parentNode ) {
  4170. eventPath.push( cur );
  4171. tmp = cur;
  4172. }
  4173. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  4174. if ( tmp === ( elem.ownerDocument || document ) ) {
  4175. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  4176. }
  4177. }
  4178. // Fire handlers on the event path
  4179. i = 0;
  4180. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  4181. event.type = i > 1 ?
  4182. bubbleType :
  4183. special.bindType || type;
  4184. // jQuery handler
  4185. handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] &&
  4186. jQuery._data( cur, "handle" );
  4187. if ( handle ) {
  4188. handle.apply( cur, data );
  4189. }
  4190. // Native handler
  4191. handle = ontype && cur[ ontype ];
  4192. if ( handle && handle.apply && acceptData( cur ) ) {
  4193. event.result = handle.apply( cur, data );
  4194. if ( event.result === false ) {
  4195. event.preventDefault();
  4196. }
  4197. }
  4198. }
  4199. event.type = type;
  4200. // If nobody prevented the default action, do it now
  4201. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  4202. if (
  4203. ( !special._default ||
  4204. special._default.apply( eventPath.pop(), data ) === false
  4205. ) && acceptData( elem )
  4206. ) {
  4207. // Call a native DOM method on the target with the same name name as the event.
  4208. // Can't use an .isFunction() check here because IE6/7 fails that test.
  4209. // Don't do default actions on window, that's where global variables be (#6170)
  4210. if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
  4211. // Don't re-trigger an onFOO event when we call its FOO() method
  4212. tmp = elem[ ontype ];
  4213. if ( tmp ) {
  4214. elem[ ontype ] = null;
  4215. }
  4216. // Prevent re-triggering of the same event, since we already bubbled it above
  4217. jQuery.event.triggered = type;
  4218. try {
  4219. elem[ type ]();
  4220. } catch ( e ) {
  4221. // IE<9 dies on focus/blur to hidden element (#1486,#12518)
  4222. // only reproducible on winXP IE8 native, not IE9 in IE8 mode
  4223. }
  4224. jQuery.event.triggered = undefined;
  4225. if ( tmp ) {
  4226. elem[ ontype ] = tmp;
  4227. }
  4228. }
  4229. }
  4230. }
  4231. return event.result;
  4232. },
  4233. dispatch: function( event ) {
  4234. // Make a writable jQuery.Event from the native event object
  4235. event = jQuery.event.fix( event );
  4236. var i, j, ret, matched, handleObj,
  4237. handlerQueue = [],
  4238. args = slice.call( arguments ),
  4239. handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
  4240. special = jQuery.event.special[ event.type ] || {};
  4241. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  4242. args[ 0 ] = event;
  4243. event.delegateTarget = this;
  4244. // Call the preDispatch hook for the mapped type, and let it bail if desired
  4245. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  4246. return;
  4247. }
  4248. // Determine handlers
  4249. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  4250. // Run delegates first; they may want to stop propagation beneath us
  4251. i = 0;
  4252. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  4253. event.currentTarget = matched.elem;
  4254. j = 0;
  4255. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  4256. !event.isImmediatePropagationStopped() ) {
  4257. // Triggered event must either 1) have no namespace, or 2) have namespace(s)
  4258. // a subset or equal to those in the bound event (both can have no namespace).
  4259. if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {
  4260. event.handleObj = handleObj;
  4261. event.data = handleObj.data;
  4262. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  4263. handleObj.handler ).apply( matched.elem, args );
  4264. if ( ret !== undefined ) {
  4265. if ( ( event.result = ret ) === false ) {
  4266. event.preventDefault();
  4267. event.stopPropagation();
  4268. }
  4269. }
  4270. }
  4271. }
  4272. }
  4273. // Call the postDispatch hook for the mapped type
  4274. if ( special.postDispatch ) {
  4275. special.postDispatch.call( this, event );
  4276. }
  4277. return event.result;
  4278. },
  4279. handlers: function( event, handlers ) {
  4280. var i, matches, sel, handleObj,
  4281. handlerQueue = [],
  4282. delegateCount = handlers.delegateCount,
  4283. cur = event.target;
  4284. // Support (at least): Chrome, IE9
  4285. // Find delegate handlers
  4286. // Black-hole SVG <use> instance trees (#13180)
  4287. //
  4288. // Support: Firefox<=42+
  4289. // Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343)
  4290. if ( delegateCount && cur.nodeType &&
  4291. ( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) {
  4292. /* jshint eqeqeq: false */
  4293. for ( ; cur != this; cur = cur.parentNode || this ) {
  4294. /* jshint eqeqeq: true */
  4295. // Don't check non-elements (#13208)
  4296. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  4297. if ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== "click" ) ) {
  4298. matches = [];
  4299. for ( i = 0; i < delegateCount; i++ ) {
  4300. handleObj = handlers[ i ];
  4301. // Don't conflict with Object.prototype properties (#13203)
  4302. sel = handleObj.selector + " ";
  4303. if ( matches[ sel ] === undefined ) {
  4304. matches[ sel ] = handleObj.needsContext ?
  4305. jQuery( sel, this ).index( cur ) > -1 :
  4306. jQuery.find( sel, this, null, [ cur ] ).length;
  4307. }
  4308. if ( matches[ sel ] ) {
  4309. matches.push( handleObj );
  4310. }
  4311. }
  4312. if ( matches.length ) {
  4313. handlerQueue.push( { elem: cur, handlers: matches } );
  4314. }
  4315. }
  4316. }
  4317. }
  4318. // Add the remaining (directly-bound) handlers
  4319. if ( delegateCount < handlers.length ) {
  4320. handlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } );
  4321. }
  4322. return handlerQueue;
  4323. },
  4324. fix: function( event ) {
  4325. if ( event[ jQuery.expando ] ) {
  4326. return event;
  4327. }
  4328. // Create a writable copy of the event object and normalize some properties
  4329. var i, prop, copy,
  4330. type = event.type,
  4331. originalEvent = event,
  4332. fixHook = this.fixHooks[ type ];
  4333. if ( !fixHook ) {
  4334. this.fixHooks[ type ] = fixHook =
  4335. rmouseEvent.test( type ) ? this.mouseHooks :
  4336. rkeyEvent.test( type ) ? this.keyHooks :
  4337. {};
  4338. }
  4339. copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
  4340. event = new jQuery.Event( originalEvent );
  4341. i = copy.length;
  4342. while ( i-- ) {
  4343. prop = copy[ i ];
  4344. event[ prop ] = originalEvent[ prop ];
  4345. }
  4346. // Support: IE<9
  4347. // Fix target property (#1925)
  4348. if ( !event.target ) {
  4349. event.target = originalEvent.srcElement || document;
  4350. }
  4351. // Support: Safari 6-8+
  4352. // Target should not be a text node (#504, #13143)
  4353. if ( event.target.nodeType === 3 ) {
  4354. event.target = event.target.parentNode;
  4355. }
  4356. // Support: IE<9
  4357. // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
  4358. event.metaKey = !!event.metaKey;
  4359. return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
  4360. },
  4361. // Includes some event props shared by KeyEvent and MouseEvent
  4362. props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " +
  4363. "metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ),
  4364. fixHooks: {},
  4365. keyHooks: {
  4366. props: "char charCode key keyCode".split( " " ),
  4367. filter: function( event, original ) {
  4368. // Add which for key events
  4369. if ( event.which == null ) {
  4370. event.which = original.charCode != null ? original.charCode : original.keyCode;
  4371. }
  4372. return event;
  4373. }
  4374. },
  4375. mouseHooks: {
  4376. props: ( "button buttons clientX clientY fromElement offsetX offsetY " +
  4377. "pageX pageY screenX screenY toElement" ).split( " " ),
  4378. filter: function( event, original ) {
  4379. var body, eventDoc, doc,
  4380. button = original.button,
  4381. fromElement = original.fromElement;
  4382. // Calculate pageX/Y if missing and clientX/Y available
  4383. if ( event.pageX == null && original.clientX != null ) {
  4384. eventDoc = event.target.ownerDocument || document;
  4385. doc = eventDoc.documentElement;
  4386. body = eventDoc.body;
  4387. event.pageX = original.clientX +
  4388. ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) -
  4389. ( doc && doc.clientLeft || body && body.clientLeft || 0 );
  4390. event.pageY = original.clientY +
  4391. ( doc && doc.scrollTop || body && body.scrollTop || 0 ) -
  4392. ( doc && doc.clientTop || body && body.clientTop || 0 );
  4393. }
  4394. // Add relatedTarget, if necessary
  4395. if ( !event.relatedTarget && fromElement ) {
  4396. event.relatedTarget = fromElement === event.target ?
  4397. original.toElement :
  4398. fromElement;
  4399. }
  4400. // Add which for click: 1 === left; 2 === middle; 3 === right
  4401. // Note: button is not normalized, so don't use it
  4402. if ( !event.which && button !== undefined ) {
  4403. event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
  4404. }
  4405. return event;
  4406. }
  4407. },
  4408. special: {
  4409. load: {
  4410. // Prevent triggered image.load events from bubbling to window.load
  4411. noBubble: true
  4412. },
  4413. focus: {
  4414. // Fire native event if possible so blur/focus sequence is correct
  4415. trigger: function() {
  4416. if ( this !== safeActiveElement() && this.focus ) {
  4417. try {
  4418. this.focus();
  4419. return false;
  4420. } catch ( e ) {
  4421. // Support: IE<9
  4422. // If we error on focus to hidden element (#1486, #12518),
  4423. // let .trigger() run the handlers
  4424. }
  4425. }
  4426. },
  4427. delegateType: "focusin"
  4428. },
  4429. blur: {
  4430. trigger: function() {
  4431. if ( this === safeActiveElement() && this.blur ) {
  4432. this.blur();
  4433. return false;
  4434. }
  4435. },
  4436. delegateType: "focusout"
  4437. },
  4438. click: {
  4439. // For checkbox, fire native event so checked state will be right
  4440. trigger: function() {
  4441. if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
  4442. this.click();
  4443. return false;
  4444. }
  4445. },
  4446. // For cross-browser consistency, don't fire native .click() on links
  4447. _default: function( event ) {
  4448. return jQuery.nodeName( event.target, "a" );
  4449. }
  4450. },
  4451. beforeunload: {
  4452. postDispatch: function( event ) {
  4453. // Support: Firefox 20+
  4454. // Firefox doesn't alert if the returnValue field is not set.
  4455. if ( event.result !== undefined && event.originalEvent ) {
  4456. event.originalEvent.returnValue = event.result;
  4457. }
  4458. }
  4459. }
  4460. },
  4461. // Piggyback on a donor event to simulate a different one
  4462. simulate: function( type, elem, event ) {
  4463. var e = jQuery.extend(
  4464. new jQuery.Event(),
  4465. event,
  4466. {
  4467. type: type,
  4468. isSimulated: true
  4469. // Previously, `originalEvent: {}` was set here, so stopPropagation call
  4470. // would not be triggered on donor event, since in our own
  4471. // jQuery.event.stopPropagation function we had a check for existence of
  4472. // originalEvent.stopPropagation method, so, consequently it would be a noop.
  4473. //
  4474. // Guard for simulated events was moved to jQuery.event.stopPropagation function
  4475. // since `originalEvent` should point to the original event for the
  4476. // constancy with other events and for more focused logic
  4477. }
  4478. );
  4479. jQuery.event.trigger( e, null, elem );
  4480. if ( e.isDefaultPrevented() ) {
  4481. event.preventDefault();
  4482. }
  4483. }
  4484. };
  4485. jQuery.removeEvent = document.removeEventListener ?
  4486. function( elem, type, handle ) {
  4487. // This "if" is needed for plain objects
  4488. if ( elem.removeEventListener ) {
  4489. elem.removeEventListener( type, handle );
  4490. }
  4491. } :
  4492. function( elem, type, handle ) {
  4493. var name = "on" + type;
  4494. if ( elem.detachEvent ) {
  4495. // #8545, #7054, preventing memory leaks for custom events in IE6-8
  4496. // detachEvent needed property on element, by name of that event,
  4497. // to properly expose it to GC
  4498. if ( typeof elem[ name ] === "undefined" ) {
  4499. elem[ name ] = null;
  4500. }
  4501. elem.detachEvent( name, handle );
  4502. }
  4503. };
  4504. jQuery.Event = function( src, props ) {
  4505. // Allow instantiation without the 'new' keyword
  4506. if ( !( this instanceof jQuery.Event ) ) {
  4507. return new jQuery.Event( src, props );
  4508. }
  4509. // Event object
  4510. if ( src && src.type ) {
  4511. this.originalEvent = src;
  4512. this.type = src.type;
  4513. // Events bubbling up the document may have been marked as prevented
  4514. // by a handler lower down the tree; reflect the correct value.
  4515. this.isDefaultPrevented = src.defaultPrevented ||
  4516. src.defaultPrevented === undefined &&
  4517. // Support: IE < 9, Android < 4.0
  4518. src.returnValue === false ?
  4519. returnTrue :
  4520. returnFalse;
  4521. // Event type
  4522. } else {
  4523. this.type = src;
  4524. }
  4525. // Put explicitly provided properties onto the event object
  4526. if ( props ) {
  4527. jQuery.extend( this, props );
  4528. }
  4529. // Create a timestamp if incoming event doesn't have one
  4530. this.timeStamp = src && src.timeStamp || jQuery.now();
  4531. // Mark it as fixed
  4532. this[ jQuery.expando ] = true;
  4533. };
  4534. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  4535. // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  4536. jQuery.Event.prototype = {
  4537. constructor: jQuery.Event,
  4538. isDefaultPrevented: returnFalse,
  4539. isPropagationStopped: returnFalse,
  4540. isImmediatePropagationStopped: returnFalse,
  4541. preventDefault: function() {
  4542. var e = this.originalEvent;
  4543. this.isDefaultPrevented = returnTrue;
  4544. if ( !e ) {
  4545. return;
  4546. }
  4547. // If preventDefault exists, run it on the original event
  4548. if ( e.preventDefault ) {
  4549. e.preventDefault();
  4550. // Support: IE
  4551. // Otherwise set the returnValue property of the original event to false
  4552. } else {
  4553. e.returnValue = false;
  4554. }
  4555. },
  4556. stopPropagation: function() {
  4557. var e = this.originalEvent;
  4558. this.isPropagationStopped = returnTrue;
  4559. if ( !e || this.isSimulated ) {
  4560. return;
  4561. }
  4562. // If stopPropagation exists, run it on the original event
  4563. if ( e.stopPropagation ) {
  4564. e.stopPropagation();
  4565. }
  4566. // Support: IE
  4567. // Set the cancelBubble property of the original event to true
  4568. e.cancelBubble = true;
  4569. },
  4570. stopImmediatePropagation: function() {
  4571. var e = this.originalEvent;
  4572. this.isImmediatePropagationStopped = returnTrue;
  4573. if ( e && e.stopImmediatePropagation ) {
  4574. e.stopImmediatePropagation();
  4575. }
  4576. this.stopPropagation();
  4577. }
  4578. };
  4579. // Create mouseenter/leave events using mouseover/out and event-time checks
  4580. // so that event delegation works in jQuery.
  4581. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  4582. //
  4583. // Support: Safari 7 only
  4584. // Safari sends mouseenter too often; see:
  4585. // https://code.google.com/p/chromium/issues/detail?id=470258
  4586. // for the description of the bug (it existed in older Chrome versions as well).
  4587. jQuery.each( {
  4588. mouseenter: "mouseover",
  4589. mouseleave: "mouseout",
  4590. pointerenter: "pointerover",
  4591. pointerleave: "pointerout"
  4592. }, function( orig, fix ) {
  4593. jQuery.event.special[ orig ] = {
  4594. delegateType: fix,
  4595. bindType: fix,
  4596. handle: function( event ) {
  4597. var ret,
  4598. target = this,
  4599. related = event.relatedTarget,
  4600. handleObj = event.handleObj;
  4601. // For mouseenter/leave call the handler if related is outside the target.
  4602. // NB: No relatedTarget if the mouse left/entered the browser window
  4603. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  4604. event.type = handleObj.origType;
  4605. ret = handleObj.handler.apply( this, arguments );
  4606. event.type = fix;
  4607. }
  4608. return ret;
  4609. }
  4610. };
  4611. } );
  4612. // IE submit delegation
  4613. if ( !support.submit ) {
  4614. jQuery.event.special.submit = {
  4615. setup: function() {
  4616. // Only need this for delegated form submit events
  4617. if ( jQuery.nodeName( this, "form" ) ) {
  4618. return false;
  4619. }
  4620. // Lazy-add a submit handler when a descendant form may potentially be submitted
  4621. jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
  4622. // Node name check avoids a VML-related crash in IE (#9807)
  4623. var elem = e.target,
  4624. form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ?
  4625. // Support: IE <=8
  4626. // We use jQuery.prop instead of elem.form
  4627. // to allow fixing the IE8 delegated submit issue (gh-2332)
  4628. // by 3rd party polyfills/workarounds.
  4629. jQuery.prop( elem, "form" ) :
  4630. undefined;
  4631. if ( form && !jQuery._data( form, "submit" ) ) {
  4632. jQuery.event.add( form, "submit._submit", function( event ) {
  4633. event._submitBubble = true;
  4634. } );
  4635. jQuery._data( form, "submit", true );
  4636. }
  4637. } );
  4638. // return undefined since we don't need an event listener
  4639. },
  4640. postDispatch: function( event ) {
  4641. // If form was submitted by the user, bubble the event up the tree
  4642. if ( event._submitBubble ) {
  4643. delete event._submitBubble;
  4644. if ( this.parentNode && !event.isTrigger ) {
  4645. jQuery.event.simulate( "submit", this.parentNode, event );
  4646. }
  4647. }
  4648. },
  4649. teardown: function() {
  4650. // Only need this for delegated form submit events
  4651. if ( jQuery.nodeName( this, "form" ) ) {
  4652. return false;
  4653. }
  4654. // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
  4655. jQuery.event.remove( this, "._submit" );
  4656. }
  4657. };
  4658. }
  4659. // IE change delegation and checkbox/radio fix
  4660. if ( !support.change ) {
  4661. jQuery.event.special.change = {
  4662. setup: function() {
  4663. if ( rformElems.test( this.nodeName ) ) {
  4664. // IE doesn't fire change on a check/radio until blur; trigger it on click
  4665. // after a propertychange. Eat the blur-change in special.change.handle.
  4666. // This still fires onchange a second time for check/radio after blur.
  4667. if ( this.type === "checkbox" || this.type === "radio" ) {
  4668. jQuery.event.add( this, "propertychange._change", function( event ) {
  4669. if ( event.originalEvent.propertyName === "checked" ) {
  4670. this._justChanged = true;
  4671. }
  4672. } );
  4673. jQuery.event.add( this, "click._change", function( event ) {
  4674. if ( this._justChanged && !event.isTrigger ) {
  4675. this._justChanged = false;
  4676. }
  4677. // Allow triggered, simulated change events (#11500)
  4678. jQuery.event.simulate( "change", this, event );
  4679. } );
  4680. }
  4681. return false;
  4682. }
  4683. // Delegated event; lazy-add a change handler on descendant inputs
  4684. jQuery.event.add( this, "beforeactivate._change", function( e ) {
  4685. var elem = e.target;
  4686. if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "change" ) ) {
  4687. jQuery.event.add( elem, "change._change", function( event ) {
  4688. if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
  4689. jQuery.event.simulate( "change", this.parentNode, event );
  4690. }
  4691. } );
  4692. jQuery._data( elem, "change", true );
  4693. }
  4694. } );
  4695. },
  4696. handle: function( event ) {
  4697. var elem = event.target;
  4698. // Swallow native change events from checkbox/radio, we already triggered them above
  4699. if ( this !== elem || event.isSimulated || event.isTrigger ||
  4700. ( elem.type !== "radio" && elem.type !== "checkbox" ) ) {
  4701. return event.handleObj.handler.apply( this, arguments );
  4702. }
  4703. },
  4704. teardown: function() {
  4705. jQuery.event.remove( this, "._change" );
  4706. return !rformElems.test( this.nodeName );
  4707. }
  4708. };
  4709. }
  4710. // Support: Firefox
  4711. // Firefox doesn't have focus(in | out) events
  4712. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  4713. //
  4714. // Support: Chrome, Safari
  4715. // focus(in | out) events fire after focus & blur events,
  4716. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  4717. // Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857
  4718. if ( !support.focusin ) {
  4719. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  4720. // Attach a single capturing handler on the document while someone wants focusin/focusout
  4721. var handler = function( event ) {
  4722. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  4723. };
  4724. jQuery.event.special[ fix ] = {
  4725. setup: function() {
  4726. var doc = this.ownerDocument || this,
  4727. attaches = jQuery._data( doc, fix );
  4728. if ( !attaches ) {
  4729. doc.addEventListener( orig, handler, true );
  4730. }
  4731. jQuery._data( doc, fix, ( attaches || 0 ) + 1 );
  4732. },
  4733. teardown: function() {
  4734. var doc = this.ownerDocument || this,
  4735. attaches = jQuery._data( doc, fix ) - 1;
  4736. if ( !attaches ) {
  4737. doc.removeEventListener( orig, handler, true );
  4738. jQuery._removeData( doc, fix );
  4739. } else {
  4740. jQuery._data( doc, fix, attaches );
  4741. }
  4742. }
  4743. };
  4744. } );
  4745. }
  4746. jQuery.fn.extend( {
  4747. on: function( types, selector, data, fn ) {
  4748. return on( this, types, selector, data, fn );
  4749. },
  4750. one: function( types, selector, data, fn ) {
  4751. return on( this, types, selector, data, fn, 1 );
  4752. },
  4753. off: function( types, selector, fn ) {
  4754. var handleObj, type;
  4755. if ( types && types.preventDefault && types.handleObj ) {
  4756. // ( event ) dispatched jQuery.Event
  4757. handleObj = types.handleObj;
  4758. jQuery( types.delegateTarget ).off(
  4759. handleObj.namespace ?
  4760. handleObj.origType + "." + handleObj.namespace :
  4761. handleObj.origType,
  4762. handleObj.selector,
  4763. handleObj.handler
  4764. );
  4765. return this;
  4766. }
  4767. if ( typeof types === "object" ) {
  4768. // ( types-object [, selector] )
  4769. for ( type in types ) {
  4770. this.off( type, selector, types[ type ] );
  4771. }
  4772. return this;
  4773. }
  4774. if ( selector === false || typeof selector === "function" ) {
  4775. // ( types [, fn] )
  4776. fn = selector;
  4777. selector = undefined;
  4778. }
  4779. if ( fn === false ) {
  4780. fn = returnFalse;
  4781. }
  4782. return this.each( function() {
  4783. jQuery.event.remove( this, types, fn, selector );
  4784. } );
  4785. },
  4786. trigger: function( type, data ) {
  4787. return this.each( function() {
  4788. jQuery.event.trigger( type, data, this );
  4789. } );
  4790. },
  4791. triggerHandler: function( type, data ) {
  4792. var elem = this[ 0 ];
  4793. if ( elem ) {
  4794. return jQuery.event.trigger( type, data, elem, true );
  4795. }
  4796. }
  4797. } );
  4798. var rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
  4799. rnoshimcache = new RegExp( "<(?:" + nodeNames + ")[\\s/>]", "i" ),
  4800. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,
  4801. // Support: IE 10-11, Edge 10240+
  4802. // In IE/Edge using regex groups here causes severe slowdowns.
  4803. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  4804. rnoInnerhtml = /<script|<style|<link/i,
  4805. // checked="checked" or checked
  4806. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  4807. rscriptTypeMasked = /^true\/(.*)/,
  4808. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
  4809. safeFragment = createSafeFragment( document ),
  4810. fragmentDiv = safeFragment.appendChild( document.createElement( "div" ) );
  4811. // Support: IE<8
  4812. // Manipulating tables requires a tbody
  4813. function manipulationTarget( elem, content ) {
  4814. return jQuery.nodeName( elem, "table" ) &&
  4815. jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
  4816. elem.getElementsByTagName( "tbody" )[ 0 ] ||
  4817. elem.appendChild( elem.ownerDocument.createElement( "tbody" ) ) :
  4818. elem;
  4819. }
  4820. // Replace/restore the type attribute of script elements for safe DOM manipulation
  4821. function disableScript( elem ) {
  4822. elem.type = ( jQuery.find.attr( elem, "type" ) !== null ) + "/" + elem.type;
  4823. return elem;
  4824. }
  4825. function restoreScript( elem ) {
  4826. var match = rscriptTypeMasked.exec( elem.type );
  4827. if ( match ) {
  4828. elem.type = match[ 1 ];
  4829. } else {
  4830. elem.removeAttribute( "type" );
  4831. }
  4832. return elem;
  4833. }
  4834. function cloneCopyEvent( src, dest ) {
  4835. if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
  4836. return;
  4837. }
  4838. var type, i, l,
  4839. oldData = jQuery._data( src ),
  4840. curData = jQuery._data( dest, oldData ),
  4841. events = oldData.events;
  4842. if ( events ) {
  4843. delete curData.handle;
  4844. curData.events = {};
  4845. for ( type in events ) {
  4846. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  4847. jQuery.event.add( dest, type, events[ type ][ i ] );
  4848. }
  4849. }
  4850. }
  4851. // make the cloned public data object a copy from the original
  4852. if ( curData.data ) {
  4853. curData.data = jQuery.extend( {}, curData.data );
  4854. }
  4855. }
  4856. function fixCloneNodeIssues( src, dest ) {
  4857. var nodeName, e, data;
  4858. // We do not need to do anything for non-Elements
  4859. if ( dest.nodeType !== 1 ) {
  4860. return;
  4861. }
  4862. nodeName = dest.nodeName.toLowerCase();
  4863. // IE6-8 copies events bound via attachEvent when using cloneNode.
  4864. if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
  4865. data = jQuery._data( dest );
  4866. for ( e in data.events ) {
  4867. jQuery.removeEvent( dest, e, data.handle );
  4868. }
  4869. // Event data gets referenced instead of copied if the expando gets copied too
  4870. dest.removeAttribute( jQuery.expando );
  4871. }
  4872. // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
  4873. if ( nodeName === "script" && dest.text !== src.text ) {
  4874. disableScript( dest ).text = src.text;
  4875. restoreScript( dest );
  4876. // IE6-10 improperly clones children of object elements using classid.
  4877. // IE10 throws NoModificationAllowedError if parent is null, #12132.
  4878. } else if ( nodeName === "object" ) {
  4879. if ( dest.parentNode ) {
  4880. dest.outerHTML = src.outerHTML;
  4881. }
  4882. // This path appears unavoidable for IE9. When cloning an object
  4883. // element in IE9, the outerHTML strategy above is not sufficient.
  4884. // If the src has innerHTML and the destination does not,
  4885. // copy the src.innerHTML into the dest.innerHTML. #10324
  4886. if ( support.html5Clone && ( src.innerHTML && !jQuery.trim( dest.innerHTML ) ) ) {
  4887. dest.innerHTML = src.innerHTML;
  4888. }
  4889. } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  4890. // IE6-8 fails to persist the checked state of a cloned checkbox
  4891. // or radio button. Worse, IE6-7 fail to give the cloned element
  4892. // a checked appearance if the defaultChecked value isn't also set
  4893. dest.defaultChecked = dest.checked = src.checked;
  4894. // IE6-7 get confused and end up setting the value of a cloned
  4895. // checkbox/radio button to an empty string instead of "on"
  4896. if ( dest.value !== src.value ) {
  4897. dest.value = src.value;
  4898. }
  4899. // IE6-8 fails to return the selected option to the default selected
  4900. // state when cloning options
  4901. } else if ( nodeName === "option" ) {
  4902. dest.defaultSelected = dest.selected = src.defaultSelected;
  4903. // IE6-8 fails to set the defaultValue to the correct value when
  4904. // cloning other types of input fields
  4905. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  4906. dest.defaultValue = src.defaultValue;
  4907. }
  4908. }
  4909. function domManip( collection, args, callback, ignored ) {
  4910. // Flatten any nested arrays
  4911. args = concat.apply( [], args );
  4912. var first, node, hasScripts,
  4913. scripts, doc, fragment,
  4914. i = 0,
  4915. l = collection.length,
  4916. iNoClone = l - 1,
  4917. value = args[ 0 ],
  4918. isFunction = jQuery.isFunction( value );
  4919. // We can't cloneNode fragments that contain checked, in WebKit
  4920. if ( isFunction ||
  4921. ( l > 1 && typeof value === "string" &&
  4922. !support.checkClone && rchecked.test( value ) ) ) {
  4923. return collection.each( function( index ) {
  4924. var self = collection.eq( index );
  4925. if ( isFunction ) {
  4926. args[ 0 ] = value.call( this, index, self.html() );
  4927. }
  4928. domManip( self, args, callback, ignored );
  4929. } );
  4930. }
  4931. if ( l ) {
  4932. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  4933. first = fragment.firstChild;
  4934. if ( fragment.childNodes.length === 1 ) {
  4935. fragment = first;
  4936. }
  4937. // Require either new content or an interest in ignored elements to invoke the callback
  4938. if ( first || ignored ) {
  4939. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  4940. hasScripts = scripts.length;
  4941. // Use the original fragment for the last item
  4942. // instead of the first because it can end up
  4943. // being emptied incorrectly in certain situations (#8070).
  4944. for ( ; i < l; i++ ) {
  4945. node = fragment;
  4946. if ( i !== iNoClone ) {
  4947. node = jQuery.clone( node, true, true );
  4948. // Keep references to cloned scripts for later restoration
  4949. if ( hasScripts ) {
  4950. // Support: Android<4.1, PhantomJS<2
  4951. // push.apply(_, arraylike) throws on ancient WebKit
  4952. jQuery.merge( scripts, getAll( node, "script" ) );
  4953. }
  4954. }
  4955. callback.call( collection[ i ], node, i );
  4956. }
  4957. if ( hasScripts ) {
  4958. doc = scripts[ scripts.length - 1 ].ownerDocument;
  4959. // Reenable scripts
  4960. jQuery.map( scripts, restoreScript );
  4961. // Evaluate executable scripts on first document insertion
  4962. for ( i = 0; i < hasScripts; i++ ) {
  4963. node = scripts[ i ];
  4964. if ( rscriptType.test( node.type || "" ) &&
  4965. !jQuery._data( node, "globalEval" ) &&
  4966. jQuery.contains( doc, node ) ) {
  4967. if ( node.src ) {
  4968. // Optional AJAX dependency, but won't run scripts if not present
  4969. if ( jQuery._evalUrl ) {
  4970. jQuery._evalUrl( node.src );
  4971. }
  4972. } else {
  4973. jQuery.globalEval(
  4974. ( node.text || node.textContent || node.innerHTML || "" )
  4975. .replace( rcleanScript, "" )
  4976. );
  4977. }
  4978. }
  4979. }
  4980. }
  4981. // Fix #11809: Avoid leaking memory
  4982. fragment = first = null;
  4983. }
  4984. }
  4985. return collection;
  4986. }
  4987. function remove( elem, selector, keepData ) {
  4988. var node,
  4989. elems = selector ? jQuery.filter( selector, elem ) : elem,
  4990. i = 0;
  4991. for ( ; ( node = elems[ i ] ) != null; i++ ) {
  4992. if ( !keepData && node.nodeType === 1 ) {
  4993. jQuery.cleanData( getAll( node ) );
  4994. }
  4995. if ( node.parentNode ) {
  4996. if ( keepData && jQuery.contains( node.ownerDocument, node ) ) {
  4997. setGlobalEval( getAll( node, "script" ) );
  4998. }
  4999. node.parentNode.removeChild( node );
  5000. }
  5001. }
  5002. return elem;
  5003. }
  5004. jQuery.extend( {
  5005. htmlPrefilter: function( html ) {
  5006. return html.replace( rxhtmlTag, "<$1></$2>" );
  5007. },
  5008. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  5009. var destElements, node, clone, i, srcElements,
  5010. inPage = jQuery.contains( elem.ownerDocument, elem );
  5011. if ( support.html5Clone || jQuery.isXMLDoc( elem ) ||
  5012. !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
  5013. clone = elem.cloneNode( true );
  5014. // IE<=8 does not properly clone detached, unknown element nodes
  5015. } else {
  5016. fragmentDiv.innerHTML = elem.outerHTML;
  5017. fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
  5018. }
  5019. if ( ( !support.noCloneEvent || !support.noCloneChecked ) &&
  5020. ( elem.nodeType === 1 || elem.nodeType === 11 ) && !jQuery.isXMLDoc( elem ) ) {
  5021. // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
  5022. destElements = getAll( clone );
  5023. srcElements = getAll( elem );
  5024. // Fix all IE cloning issues
  5025. for ( i = 0; ( node = srcElements[ i ] ) != null; ++i ) {
  5026. // Ensure that the destination node is not null; Fixes #9587
  5027. if ( destElements[ i ] ) {
  5028. fixCloneNodeIssues( node, destElements[ i ] );
  5029. }
  5030. }
  5031. }
  5032. // Copy the events from the original to the clone
  5033. if ( dataAndEvents ) {
  5034. if ( deepDataAndEvents ) {
  5035. srcElements = srcElements || getAll( elem );
  5036. destElements = destElements || getAll( clone );
  5037. for ( i = 0; ( node = srcElements[ i ] ) != null; i++ ) {
  5038. cloneCopyEvent( node, destElements[ i ] );
  5039. }
  5040. } else {
  5041. cloneCopyEvent( elem, clone );
  5042. }
  5043. }
  5044. // Preserve script evaluation history
  5045. destElements = getAll( clone, "script" );
  5046. if ( destElements.length > 0 ) {
  5047. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  5048. }
  5049. destElements = srcElements = node = null;
  5050. // Return the cloned set
  5051. return clone;
  5052. },
  5053. cleanData: function( elems, /* internal */ forceAcceptData ) {
  5054. var elem, type, id, data,
  5055. i = 0,
  5056. internalKey = jQuery.expando,
  5057. cache = jQuery.cache,
  5058. attributes = support.attributes,
  5059. special = jQuery.event.special;
  5060. for ( ; ( elem = elems[ i ] ) != null; i++ ) {
  5061. if ( forceAcceptData || acceptData( elem ) ) {
  5062. id = elem[ internalKey ];
  5063. data = id && cache[ id ];
  5064. if ( data ) {
  5065. if ( data.events ) {
  5066. for ( type in data.events ) {
  5067. if ( special[ type ] ) {
  5068. jQuery.event.remove( elem, type );
  5069. // This is a shortcut to avoid jQuery.event.remove's overhead
  5070. } else {
  5071. jQuery.removeEvent( elem, type, data.handle );
  5072. }
  5073. }
  5074. }
  5075. // Remove cache only if it was not already removed by jQuery.event.remove
  5076. if ( cache[ id ] ) {
  5077. delete cache[ id ];
  5078. // Support: IE<9
  5079. // IE does not allow us to delete expando properties from nodes
  5080. // IE creates expando attributes along with the property
  5081. // IE does not have a removeAttribute function on Document nodes
  5082. if ( !attributes && typeof elem.removeAttribute !== "undefined" ) {
  5083. elem.removeAttribute( internalKey );
  5084. // Webkit & Blink performance suffers when deleting properties
  5085. // from DOM nodes, so set to undefined instead
  5086. // https://code.google.com/p/chromium/issues/detail?id=378607
  5087. } else {
  5088. elem[ internalKey ] = undefined;
  5089. }
  5090. deletedIds.push( id );
  5091. }
  5092. }
  5093. }
  5094. }
  5095. }
  5096. } );
  5097. jQuery.fn.extend( {
  5098. // Keep domManip exposed until 3.0 (gh-2225)
  5099. domManip: domManip,
  5100. detach: function( selector ) {
  5101. return remove( this, selector, true );
  5102. },
  5103. remove: function( selector ) {
  5104. return remove( this, selector );
  5105. },
  5106. text: function( value ) {
  5107. return access( this, function( value ) {
  5108. return value === undefined ?
  5109. jQuery.text( this ) :
  5110. this.empty().append(
  5111. ( this[ 0 ] && this[ 0 ].ownerDocument || document ).createTextNode( value )
  5112. );
  5113. }, null, value, arguments.length );
  5114. },
  5115. append: function() {
  5116. return domManip( this, arguments, function( elem ) {
  5117. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  5118. var target = manipulationTarget( this, elem );
  5119. target.appendChild( elem );
  5120. }
  5121. } );
  5122. },
  5123. prepend: function() {
  5124. return domManip( this, arguments, function( elem ) {
  5125. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  5126. var target = manipulationTarget( this, elem );
  5127. target.insertBefore( elem, target.firstChild );
  5128. }
  5129. } );
  5130. },
  5131. before: function() {
  5132. return domManip( this, arguments, function( elem ) {
  5133. if ( this.parentNode ) {
  5134. this.parentNode.insertBefore( elem, this );
  5135. }
  5136. } );
  5137. },
  5138. after: function() {
  5139. return domManip( this, arguments, function( elem ) {
  5140. if ( this.parentNode ) {
  5141. this.parentNode.insertBefore( elem, this.nextSibling );
  5142. }
  5143. } );
  5144. },
  5145. empty: function() {
  5146. var elem,
  5147. i = 0;
  5148. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  5149. // Remove element nodes and prevent memory leaks
  5150. if ( elem.nodeType === 1 ) {
  5151. jQuery.cleanData( getAll( elem, false ) );
  5152. }
  5153. // Remove any remaining nodes
  5154. while ( elem.firstChild ) {
  5155. elem.removeChild( elem.firstChild );
  5156. }
  5157. // If this is a select, ensure that it displays empty (#12336)
  5158. // Support: IE<9
  5159. if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
  5160. elem.options.length = 0;
  5161. }
  5162. }
  5163. return this;
  5164. },
  5165. clone: function( dataAndEvents, deepDataAndEvents ) {
  5166. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  5167. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  5168. return this.map( function() {
  5169. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  5170. } );
  5171. },
  5172. html: function( value ) {
  5173. return access( this, function( value ) {
  5174. var elem = this[ 0 ] || {},
  5175. i = 0,
  5176. l = this.length;
  5177. if ( value === undefined ) {
  5178. return elem.nodeType === 1 ?
  5179. elem.innerHTML.replace( rinlinejQuery, "" ) :
  5180. undefined;
  5181. }
  5182. // See if we can take a shortcut and just use innerHTML
  5183. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  5184. ( support.htmlSerialize || !rnoshimcache.test( value ) ) &&
  5185. ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
  5186. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  5187. value = jQuery.htmlPrefilter( value );
  5188. try {
  5189. for ( ; i < l; i++ ) {
  5190. // Remove element nodes and prevent memory leaks
  5191. elem = this[ i ] || {};
  5192. if ( elem.nodeType === 1 ) {
  5193. jQuery.cleanData( getAll( elem, false ) );
  5194. elem.innerHTML = value;
  5195. }
  5196. }
  5197. elem = 0;
  5198. // If using innerHTML throws an exception, use the fallback method
  5199. } catch ( e ) {}
  5200. }
  5201. if ( elem ) {
  5202. this.empty().append( value );
  5203. }
  5204. }, null, value, arguments.length );
  5205. },
  5206. replaceWith: function() {
  5207. var ignored = [];
  5208. // Make the changes, replacing each non-ignored context element with the new content
  5209. return domManip( this, arguments, function( elem ) {
  5210. var parent = this.parentNode;
  5211. if ( jQuery.inArray( this, ignored ) < 0 ) {
  5212. jQuery.cleanData( getAll( this ) );
  5213. if ( parent ) {
  5214. parent.replaceChild( elem, this );
  5215. }
  5216. }
  5217. // Force callback invocation
  5218. }, ignored );
  5219. }
  5220. } );
  5221. jQuery.each( {
  5222. appendTo: "append",
  5223. prependTo: "prepend",
  5224. insertBefore: "before",
  5225. insertAfter: "after",
  5226. replaceAll: "replaceWith"
  5227. }, function( name, original ) {
  5228. jQuery.fn[ name ] = function( selector ) {
  5229. var elems,
  5230. i = 0,
  5231. ret = [],
  5232. insert = jQuery( selector ),
  5233. last = insert.length - 1;
  5234. for ( ; i <= last; i++ ) {
  5235. elems = i === last ? this : this.clone( true );
  5236. jQuery( insert[ i ] )[ original ]( elems );
  5237. // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
  5238. push.apply( ret, elems.get() );
  5239. }
  5240. return this.pushStack( ret );
  5241. };
  5242. } );
  5243. var iframe,
  5244. elemdisplay = {
  5245. // Support: Firefox
  5246. // We have to pre-define these values for FF (#10227)
  5247. HTML: "block",
  5248. BODY: "block"
  5249. };
  5250. /**
  5251. * Retrieve the actual display of a element
  5252. * @param {String} name nodeName of the element
  5253. * @param {Object} doc Document object
  5254. */
  5255. // Called only from within defaultDisplay
  5256. function actualDisplay( name, doc ) {
  5257. var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
  5258. display = jQuery.css( elem[ 0 ], "display" );
  5259. // We don't have any data stored on the element,
  5260. // so use "detach" method as fast way to get rid of the element
  5261. elem.detach();
  5262. return display;
  5263. }
  5264. /**
  5265. * Try to determine the default display value of an element
  5266. * @param {String} nodeName
  5267. */
  5268. function defaultDisplay( nodeName ) {
  5269. var doc = document,
  5270. display = elemdisplay[ nodeName ];
  5271. if ( !display ) {
  5272. display = actualDisplay( nodeName, doc );
  5273. // If the simple way fails, read from inside an iframe
  5274. if ( display === "none" || !display ) {
  5275. // Use the already-created iframe if possible
  5276. iframe = ( iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" ) )
  5277. .appendTo( doc.documentElement );
  5278. // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
  5279. doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document;
  5280. // Support: IE
  5281. doc.write();
  5282. doc.close();
  5283. display = actualDisplay( nodeName, doc );
  5284. iframe.detach();
  5285. }
  5286. // Store the correct default display
  5287. elemdisplay[ nodeName ] = display;
  5288. }
  5289. return display;
  5290. }
  5291. var rmargin = ( /^margin/ );
  5292. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  5293. var swap = function( elem, options, callback, args ) {
  5294. var ret, name,
  5295. old = {};
  5296. // Remember the old values, and insert the new ones
  5297. for ( name in options ) {
  5298. old[ name ] = elem.style[ name ];
  5299. elem.style[ name ] = options[ name ];
  5300. }
  5301. ret = callback.apply( elem, args || [] );
  5302. // Revert the old values
  5303. for ( name in options ) {
  5304. elem.style[ name ] = old[ name ];
  5305. }
  5306. return ret;
  5307. };
  5308. var documentElement = document.documentElement;
  5309. ( function() {
  5310. var pixelPositionVal, pixelMarginRightVal, boxSizingReliableVal,
  5311. reliableHiddenOffsetsVal, reliableMarginRightVal, reliableMarginLeftVal,
  5312. container = document.createElement( "div" ),
  5313. div = document.createElement( "div" );
  5314. // Finish early in limited (non-browser) environments
  5315. if ( !div.style ) {
  5316. return;
  5317. }
  5318. div.style.cssText = "float:left;opacity:.5";
  5319. // Support: IE<9
  5320. // Make sure that element opacity exists (as opposed to filter)
  5321. support.opacity = div.style.opacity === "0.5";
  5322. // Verify style float existence
  5323. // (IE uses styleFloat instead of cssFloat)
  5324. support.cssFloat = !!div.style.cssFloat;
  5325. div.style.backgroundClip = "content-box";
  5326. div.cloneNode( true ).style.backgroundClip = "";
  5327. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  5328. container = document.createElement( "div" );
  5329. container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
  5330. "padding:0;margin-top:1px;position:absolute";
  5331. div.innerHTML = "";
  5332. container.appendChild( div );
  5333. // Support: Firefox<29, Android 2.3
  5334. // Vendor-prefix box-sizing
  5335. support.boxSizing = div.style.boxSizing === "" || div.style.MozBoxSizing === "" ||
  5336. div.style.WebkitBoxSizing === "";
  5337. jQuery.extend( support, {
  5338. reliableHiddenOffsets: function() {
  5339. if ( pixelPositionVal == null ) {
  5340. computeStyleTests();
  5341. }
  5342. return reliableHiddenOffsetsVal;
  5343. },
  5344. boxSizingReliable: function() {
  5345. // We're checking for pixelPositionVal here instead of boxSizingReliableVal
  5346. // since that compresses better and they're computed together anyway.
  5347. if ( pixelPositionVal == null ) {
  5348. computeStyleTests();
  5349. }
  5350. return boxSizingReliableVal;
  5351. },
  5352. pixelMarginRight: function() {
  5353. // Support: Android 4.0-4.3
  5354. if ( pixelPositionVal == null ) {
  5355. computeStyleTests();
  5356. }
  5357. return pixelMarginRightVal;
  5358. },
  5359. pixelPosition: function() {
  5360. if ( pixelPositionVal == null ) {
  5361. computeStyleTests();
  5362. }
  5363. return pixelPositionVal;
  5364. },
  5365. reliableMarginRight: function() {
  5366. // Support: Android 2.3
  5367. if ( pixelPositionVal == null ) {
  5368. computeStyleTests();
  5369. }
  5370. return reliableMarginRightVal;
  5371. },
  5372. reliableMarginLeft: function() {
  5373. // Support: IE <=8 only, Android 4.0 - 4.3 only, Firefox <=3 - 37
  5374. if ( pixelPositionVal == null ) {
  5375. computeStyleTests();
  5376. }
  5377. return reliableMarginLeftVal;
  5378. }
  5379. } );
  5380. function computeStyleTests() {
  5381. var contents, divStyle,
  5382. documentElement = document.documentElement;
  5383. // Setup
  5384. documentElement.appendChild( container );
  5385. div.style.cssText =
  5386. // Support: Android 2.3
  5387. // Vendor-prefix box-sizing
  5388. "-webkit-box-sizing:border-box;box-sizing:border-box;" +
  5389. "position:relative;display:block;" +
  5390. "margin:auto;border:1px;padding:1px;" +
  5391. "top:1%;width:50%";
  5392. // Support: IE<9
  5393. // Assume reasonable values in the absence of getComputedStyle
  5394. pixelPositionVal = boxSizingReliableVal = reliableMarginLeftVal = false;
  5395. pixelMarginRightVal = reliableMarginRightVal = true;
  5396. // Check for getComputedStyle so that this code is not run in IE<9.
  5397. if ( window.getComputedStyle ) {
  5398. divStyle = window.getComputedStyle( div );
  5399. pixelPositionVal = ( divStyle || {} ).top !== "1%";
  5400. reliableMarginLeftVal = ( divStyle || {} ).marginLeft === "2px";
  5401. boxSizingReliableVal = ( divStyle || { width: "4px" } ).width === "4px";
  5402. // Support: Android 4.0 - 4.3 only
  5403. // Some styles come back with percentage values, even though they shouldn't
  5404. div.style.marginRight = "50%";
  5405. pixelMarginRightVal = ( divStyle || { marginRight: "4px" } ).marginRight === "4px";
  5406. // Support: Android 2.3 only
  5407. // Div with explicit width and no margin-right incorrectly
  5408. // gets computed margin-right based on width of container (#3333)
  5409. // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  5410. contents = div.appendChild( document.createElement( "div" ) );
  5411. // Reset CSS: box-sizing; display; margin; border; padding
  5412. contents.style.cssText = div.style.cssText =
  5413. // Support: Android 2.3
  5414. // Vendor-prefix box-sizing
  5415. "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
  5416. "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
  5417. contents.style.marginRight = contents.style.width = "0";
  5418. div.style.width = "1px";
  5419. reliableMarginRightVal =
  5420. !parseFloat( ( window.getComputedStyle( contents ) || {} ).marginRight );
  5421. div.removeChild( contents );
  5422. }
  5423. // Support: IE6-8
  5424. // First check that getClientRects works as expected
  5425. // Check if table cells still have offsetWidth/Height when they are set
  5426. // to display:none and there are still other visible table cells in a
  5427. // table row; if so, offsetWidth/Height are not reliable for use when
  5428. // determining if an element has been hidden directly using
  5429. // display:none (it is still safe to use offsets if a parent element is
  5430. // hidden; don safety goggles and see bug #4512 for more information).
  5431. div.style.display = "none";
  5432. reliableHiddenOffsetsVal = div.getClientRects().length === 0;
  5433. if ( reliableHiddenOffsetsVal ) {
  5434. div.style.display = "";
  5435. div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
  5436. div.childNodes[ 0 ].style.borderCollapse = "separate";
  5437. contents = div.getElementsByTagName( "td" );
  5438. contents[ 0 ].style.cssText = "margin:0;border:0;padding:0;display:none";
  5439. reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
  5440. if ( reliableHiddenOffsetsVal ) {
  5441. contents[ 0 ].style.display = "";
  5442. contents[ 1 ].style.display = "none";
  5443. reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
  5444. }
  5445. }
  5446. // Teardown
  5447. documentElement.removeChild( container );
  5448. }
  5449. } )();
  5450. var getStyles, curCSS,
  5451. rposition = /^(top|right|bottom|left)$/;
  5452. if ( window.getComputedStyle ) {
  5453. getStyles = function( elem ) {
  5454. // Support: IE<=11+, Firefox<=30+ (#15098, #14150)
  5455. // IE throws on elements created in popups
  5456. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  5457. var view = elem.ownerDocument.defaultView;
  5458. if ( !view || !view.opener ) {
  5459. view = window;
  5460. }
  5461. return view.getComputedStyle( elem );
  5462. };
  5463. curCSS = function( elem, name, computed ) {
  5464. var width, minWidth, maxWidth, ret,
  5465. style = elem.style;
  5466. computed = computed || getStyles( elem );
  5467. // getPropertyValue is only needed for .css('filter') in IE9, see #12537
  5468. ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined;
  5469. // Support: Opera 12.1x only
  5470. // Fall back to style even without computed
  5471. // computed is undefined for elems on document fragments
  5472. if ( ( ret === "" || ret === undefined ) && !jQuery.contains( elem.ownerDocument, elem ) ) {
  5473. ret = jQuery.style( elem, name );
  5474. }
  5475. if ( computed ) {
  5476. // A tribute to the "awesome hack by Dean Edwards"
  5477. // Chrome < 17 and Safari 5.0 uses "computed value"
  5478. // instead of "used value" for margin-right
  5479. // Safari 5.1.7 (at least) returns percentage for a larger set of values,
  5480. // but width seems to be reliably pixels
  5481. // this is against the CSSOM draft spec:
  5482. // http://dev.w3.org/csswg/cssom/#resolved-values
  5483. if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {
  5484. // Remember the original values
  5485. width = style.width;
  5486. minWidth = style.minWidth;
  5487. maxWidth = style.maxWidth;
  5488. // Put in the new values to get a computed value out
  5489. style.minWidth = style.maxWidth = style.width = ret;
  5490. ret = computed.width;
  5491. // Revert the changed values
  5492. style.width = width;
  5493. style.minWidth = minWidth;
  5494. style.maxWidth = maxWidth;
  5495. }
  5496. }
  5497. // Support: IE
  5498. // IE returns zIndex value as an integer.
  5499. return ret === undefined ?
  5500. ret :
  5501. ret + "";
  5502. };
  5503. } else if ( documentElement.currentStyle ) {
  5504. getStyles = function( elem ) {
  5505. return elem.currentStyle;
  5506. };
  5507. curCSS = function( elem, name, computed ) {
  5508. var left, rs, rsLeft, ret,
  5509. style = elem.style;
  5510. computed = computed || getStyles( elem );
  5511. ret = computed ? computed[ name ] : undefined;
  5512. // Avoid setting ret to empty string here
  5513. // so we don't default to auto
  5514. if ( ret == null && style && style[ name ] ) {
  5515. ret = style[ name ];
  5516. }
  5517. // From the awesome hack by Dean Edwards
  5518. // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
  5519. // If we're not dealing with a regular pixel number
  5520. // but a number that has a weird ending, we need to convert it to pixels
  5521. // but not position css attributes, as those are
  5522. // proportional to the parent element instead
  5523. // and we can't measure the parent instead because it
  5524. // might trigger a "stacking dolls" problem
  5525. if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
  5526. // Remember the original values
  5527. left = style.left;
  5528. rs = elem.runtimeStyle;
  5529. rsLeft = rs && rs.left;
  5530. // Put in the new values to get a computed value out
  5531. if ( rsLeft ) {
  5532. rs.left = elem.currentStyle.left;
  5533. }
  5534. style.left = name === "fontSize" ? "1em" : ret;
  5535. ret = style.pixelLeft + "px";
  5536. // Revert the changed values
  5537. style.left = left;
  5538. if ( rsLeft ) {
  5539. rs.left = rsLeft;
  5540. }
  5541. }
  5542. // Support: IE
  5543. // IE returns zIndex value as an integer.
  5544. return ret === undefined ?
  5545. ret :
  5546. ret + "" || "auto";
  5547. };
  5548. }
  5549. function addGetHookIf( conditionFn, hookFn ) {
  5550. // Define the hook, we'll check on the first run if it's really needed.
  5551. return {
  5552. get: function() {
  5553. if ( conditionFn() ) {
  5554. // Hook not needed (or it's not possible to use it due
  5555. // to missing dependency), remove it.
  5556. delete this.get;
  5557. return;
  5558. }
  5559. // Hook needed; redefine it so that the support test is not executed again.
  5560. return ( this.get = hookFn ).apply( this, arguments );
  5561. }
  5562. };
  5563. }
  5564. var
  5565. ralpha = /alpha\([^)]*\)/i,
  5566. ropacity = /opacity\s*=\s*([^)]*)/i,
  5567. // swappable if display is none or starts with table except
  5568. // "table", "table-cell", or "table-caption"
  5569. // see here for display values:
  5570. // https://developer.mozilla.org/en-US/docs/CSS/display
  5571. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  5572. rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
  5573. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  5574. cssNormalTransform = {
  5575. letterSpacing: "0",
  5576. fontWeight: "400"
  5577. },
  5578. cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
  5579. emptyStyle = document.createElement( "div" ).style;
  5580. // return a css property mapped to a potentially vendor prefixed property
  5581. function vendorPropName( name ) {
  5582. // shortcut for names that are not vendor prefixed
  5583. if ( name in emptyStyle ) {
  5584. return name;
  5585. }
  5586. // check for vendor prefixed names
  5587. var capName = name.charAt( 0 ).toUpperCase() + name.slice( 1 ),
  5588. i = cssPrefixes.length;
  5589. while ( i-- ) {
  5590. name = cssPrefixes[ i ] + capName;
  5591. if ( name in emptyStyle ) {
  5592. return name;
  5593. }
  5594. }
  5595. }
  5596. function showHide( elements, show ) {
  5597. var display, elem, hidden,
  5598. values = [],
  5599. index = 0,
  5600. length = elements.length;
  5601. for ( ; index < length; index++ ) {
  5602. elem = elements[ index ];
  5603. if ( !elem.style ) {
  5604. continue;
  5605. }
  5606. values[ index ] = jQuery._data( elem, "olddisplay" );
  5607. display = elem.style.display;
  5608. if ( show ) {
  5609. // Reset the inline display of this element to learn if it is
  5610. // being hidden by cascaded rules or not
  5611. if ( !values[ index ] && display === "none" ) {
  5612. elem.style.display = "";
  5613. }
  5614. // Set elements which have been overridden with display: none
  5615. // in a stylesheet to whatever the default browser style is
  5616. // for such an element
  5617. if ( elem.style.display === "" && isHidden( elem ) ) {
  5618. values[ index ] =
  5619. jQuery._data( elem, "olddisplay", defaultDisplay( elem.nodeName ) );
  5620. }
  5621. } else {
  5622. hidden = isHidden( elem );
  5623. if ( display && display !== "none" || !hidden ) {
  5624. jQuery._data(
  5625. elem,
  5626. "olddisplay",
  5627. hidden ? display : jQuery.css( elem, "display" )
  5628. );
  5629. }
  5630. }
  5631. }
  5632. // Set the display of most of the elements in a second loop
  5633. // to avoid the constant reflow
  5634. for ( index = 0; index < length; index++ ) {
  5635. elem = elements[ index ];
  5636. if ( !elem.style ) {
  5637. continue;
  5638. }
  5639. if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
  5640. elem.style.display = show ? values[ index ] || "" : "none";
  5641. }
  5642. }
  5643. return elements;
  5644. }
  5645. function setPositiveNumber( elem, value, subtract ) {
  5646. var matches = rnumsplit.exec( value );
  5647. return matches ?
  5648. // Guard against undefined "subtract", e.g., when used as in cssHooks
  5649. Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
  5650. value;
  5651. }
  5652. function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
  5653. var i = extra === ( isBorderBox ? "border" : "content" ) ?
  5654. // If we already have the right measurement, avoid augmentation
  5655. 4 :
  5656. // Otherwise initialize for horizontal or vertical properties
  5657. name === "width" ? 1 : 0,
  5658. val = 0;
  5659. for ( ; i < 4; i += 2 ) {
  5660. // both box models exclude margin, so add it if we want it
  5661. if ( extra === "margin" ) {
  5662. val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
  5663. }
  5664. if ( isBorderBox ) {
  5665. // border-box includes padding, so remove it if we want content
  5666. if ( extra === "content" ) {
  5667. val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  5668. }
  5669. // at this point, extra isn't border nor margin, so remove border
  5670. if ( extra !== "margin" ) {
  5671. val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  5672. }
  5673. } else {
  5674. // at this point, extra isn't content, so add padding
  5675. val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  5676. // at this point, extra isn't content nor padding, so add border
  5677. if ( extra !== "padding" ) {
  5678. val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  5679. }
  5680. }
  5681. }
  5682. return val;
  5683. }
  5684. function getWidthOrHeight( elem, name, extra ) {
  5685. // Start with offset property, which is equivalent to the border-box value
  5686. var valueIsBorderBox = true,
  5687. val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
  5688. styles = getStyles( elem ),
  5689. isBorderBox = support.boxSizing &&
  5690. jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  5691. // some non-html elements return undefined for offsetWidth, so check for null/undefined
  5692. // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
  5693. // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
  5694. if ( val <= 0 || val == null ) {
  5695. // Fall back to computed then uncomputed css if necessary
  5696. val = curCSS( elem, name, styles );
  5697. if ( val < 0 || val == null ) {
  5698. val = elem.style[ name ];
  5699. }
  5700. // Computed unit is not pixels. Stop here and return.
  5701. if ( rnumnonpx.test( val ) ) {
  5702. return val;
  5703. }
  5704. // we need the check for style in case a browser which returns unreliable values
  5705. // for getComputedStyle silently falls back to the reliable elem.style
  5706. valueIsBorderBox = isBorderBox &&
  5707. ( support.boxSizingReliable() || val === elem.style[ name ] );
  5708. // Normalize "", auto, and prepare for extra
  5709. val = parseFloat( val ) || 0;
  5710. }
  5711. // use the active box-sizing model to add/subtract irrelevant styles
  5712. return ( val +
  5713. augmentWidthOrHeight(
  5714. elem,
  5715. name,
  5716. extra || ( isBorderBox ? "border" : "content" ),
  5717. valueIsBorderBox,
  5718. styles
  5719. )
  5720. ) + "px";
  5721. }
  5722. jQuery.extend( {
  5723. // Add in style property hooks for overriding the default
  5724. // behavior of getting and setting a style property
  5725. cssHooks: {
  5726. opacity: {
  5727. get: function( elem, computed ) {
  5728. if ( computed ) {
  5729. // We should always get a number back from opacity
  5730. var ret = curCSS( elem, "opacity" );
  5731. return ret === "" ? "1" : ret;
  5732. }
  5733. }
  5734. }
  5735. },
  5736. // Don't automatically add "px" to these possibly-unitless properties
  5737. cssNumber: {
  5738. "animationIterationCount": true,
  5739. "columnCount": true,
  5740. "fillOpacity": true,
  5741. "flexGrow": true,
  5742. "flexShrink": true,
  5743. "fontWeight": true,
  5744. "lineHeight": true,
  5745. "opacity": true,
  5746. "order": true,
  5747. "orphans": true,
  5748. "widows": true,
  5749. "zIndex": true,
  5750. "zoom": true
  5751. },
  5752. // Add in properties whose names you wish to fix before
  5753. // setting or getting the value
  5754. cssProps: {
  5755. // normalize float css property
  5756. "float": support.cssFloat ? "cssFloat" : "styleFloat"
  5757. },
  5758. // Get and set the style property on a DOM Node
  5759. style: function( elem, name, value, extra ) {
  5760. // Don't set styles on text and comment nodes
  5761. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  5762. return;
  5763. }
  5764. // Make sure that we're working with the right name
  5765. var ret, type, hooks,
  5766. origName = jQuery.camelCase( name ),
  5767. style = elem.style;
  5768. name = jQuery.cssProps[ origName ] ||
  5769. ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
  5770. // gets hook for the prefixed version
  5771. // followed by the unprefixed version
  5772. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  5773. // Check if we're setting a value
  5774. if ( value !== undefined ) {
  5775. type = typeof value;
  5776. // Convert "+=" or "-=" to relative numbers (#7345)
  5777. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  5778. value = adjustCSS( elem, name, ret );
  5779. // Fixes bug #9237
  5780. type = "number";
  5781. }
  5782. // Make sure that null and NaN values aren't set. See: #7116
  5783. if ( value == null || value !== value ) {
  5784. return;
  5785. }
  5786. // If a number was passed in, add the unit (except for certain CSS properties)
  5787. if ( type === "number" ) {
  5788. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  5789. }
  5790. // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
  5791. // but it would mean to define eight
  5792. // (for every problematic property) identical functions
  5793. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  5794. style[ name ] = "inherit";
  5795. }
  5796. // If a hook was provided, use that value, otherwise just set the specified value
  5797. if ( !hooks || !( "set" in hooks ) ||
  5798. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  5799. // Support: IE
  5800. // Swallow errors from 'invalid' CSS values (#5509)
  5801. try {
  5802. style[ name ] = value;
  5803. } catch ( e ) {}
  5804. }
  5805. } else {
  5806. // If a hook was provided get the non-computed value from there
  5807. if ( hooks && "get" in hooks &&
  5808. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  5809. return ret;
  5810. }
  5811. // Otherwise just get the value from the style object
  5812. return style[ name ];
  5813. }
  5814. },
  5815. css: function( elem, name, extra, styles ) {
  5816. var num, val, hooks,
  5817. origName = jQuery.camelCase( name );
  5818. // Make sure that we're working with the right name
  5819. name = jQuery.cssProps[ origName ] ||
  5820. ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
  5821. // gets hook for the prefixed version
  5822. // followed by the unprefixed version
  5823. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  5824. // If a hook was provided get the computed value from there
  5825. if ( hooks && "get" in hooks ) {
  5826. val = hooks.get( elem, true, extra );
  5827. }
  5828. // Otherwise, if a way to get the computed value exists, use that
  5829. if ( val === undefined ) {
  5830. val = curCSS( elem, name, styles );
  5831. }
  5832. //convert "normal" to computed value
  5833. if ( val === "normal" && name in cssNormalTransform ) {
  5834. val = cssNormalTransform[ name ];
  5835. }
  5836. // Return, converting to number if forced or a qualifier was provided and val looks numeric
  5837. if ( extra === "" || extra ) {
  5838. num = parseFloat( val );
  5839. return extra === true || isFinite( num ) ? num || 0 : val;
  5840. }
  5841. return val;
  5842. }
  5843. } );
  5844. jQuery.each( [ "height", "width" ], function( i, name ) {
  5845. jQuery.cssHooks[ name ] = {
  5846. get: function( elem, computed, extra ) {
  5847. if ( computed ) {
  5848. // certain elements can have dimension info if we invisibly show them
  5849. // however, it must have a current display style that would benefit from this
  5850. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  5851. elem.offsetWidth === 0 ?
  5852. swap( elem, cssShow, function() {
  5853. return getWidthOrHeight( elem, name, extra );
  5854. } ) :
  5855. getWidthOrHeight( elem, name, extra );
  5856. }
  5857. },
  5858. set: function( elem, value, extra ) {
  5859. var styles = extra && getStyles( elem );
  5860. return setPositiveNumber( elem, value, extra ?
  5861. augmentWidthOrHeight(
  5862. elem,
  5863. name,
  5864. extra,
  5865. support.boxSizing &&
  5866. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  5867. styles
  5868. ) : 0
  5869. );
  5870. }
  5871. };
  5872. } );
  5873. if ( !support.opacity ) {
  5874. jQuery.cssHooks.opacity = {
  5875. get: function( elem, computed ) {
  5876. // IE uses filters for opacity
  5877. return ropacity.test( ( computed && elem.currentStyle ?
  5878. elem.currentStyle.filter :
  5879. elem.style.filter ) || "" ) ?
  5880. ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
  5881. computed ? "1" : "";
  5882. },
  5883. set: function( elem, value ) {
  5884. var style = elem.style,
  5885. currentStyle = elem.currentStyle,
  5886. opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
  5887. filter = currentStyle && currentStyle.filter || style.filter || "";
  5888. // IE has trouble with opacity if it does not have layout
  5889. // Force it by setting the zoom level
  5890. style.zoom = 1;
  5891. // if setting opacity to 1, and no other filters exist -
  5892. // attempt to remove filter attribute #6652
  5893. // if value === "", then remove inline opacity #12685
  5894. if ( ( value >= 1 || value === "" ) &&
  5895. jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
  5896. style.removeAttribute ) {
  5897. // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
  5898. // if "filter:" is present at all, clearType is disabled, we want to avoid this
  5899. // style.removeAttribute is IE Only, but so apparently is this code path...
  5900. style.removeAttribute( "filter" );
  5901. // if there is no filter style applied in a css rule
  5902. // or unset inline opacity, we are done
  5903. if ( value === "" || currentStyle && !currentStyle.filter ) {
  5904. return;
  5905. }
  5906. }
  5907. // otherwise, set new filter values
  5908. style.filter = ralpha.test( filter ) ?
  5909. filter.replace( ralpha, opacity ) :
  5910. filter + " " + opacity;
  5911. }
  5912. };
  5913. }
  5914. jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
  5915. function( elem, computed ) {
  5916. if ( computed ) {
  5917. return swap( elem, { "display": "inline-block" },
  5918. curCSS, [ elem, "marginRight" ] );
  5919. }
  5920. }
  5921. );
  5922. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  5923. function( elem, computed ) {
  5924. if ( computed ) {
  5925. return (
  5926. parseFloat( curCSS( elem, "marginLeft" ) ) ||
  5927. // Support: IE<=11+
  5928. // Running getBoundingClientRect on a disconnected node in IE throws an error
  5929. // Support: IE8 only
  5930. // getClientRects() errors on disconnected elems
  5931. ( jQuery.contains( elem.ownerDocument, elem ) ?
  5932. elem.getBoundingClientRect().left -
  5933. swap( elem, { marginLeft: 0 }, function() {
  5934. return elem.getBoundingClientRect().left;
  5935. } ) :
  5936. 0
  5937. )
  5938. ) + "px";
  5939. }
  5940. }
  5941. );
  5942. // These hooks are used by animate to expand properties
  5943. jQuery.each( {
  5944. margin: "",
  5945. padding: "",
  5946. border: "Width"
  5947. }, function( prefix, suffix ) {
  5948. jQuery.cssHooks[ prefix + suffix ] = {
  5949. expand: function( value ) {
  5950. var i = 0,
  5951. expanded = {},
  5952. // assumes a single number if not a string
  5953. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  5954. for ( ; i < 4; i++ ) {
  5955. expanded[ prefix + cssExpand[ i ] + suffix ] =
  5956. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  5957. }
  5958. return expanded;
  5959. }
  5960. };
  5961. if ( !rmargin.test( prefix ) ) {
  5962. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  5963. }
  5964. } );
  5965. jQuery.fn.extend( {
  5966. css: function( name, value ) {
  5967. return access( this, function( elem, name, value ) {
  5968. var styles, len,
  5969. map = {},
  5970. i = 0;
  5971. if ( jQuery.isArray( name ) ) {
  5972. styles = getStyles( elem );
  5973. len = name.length;
  5974. for ( ; i < len; i++ ) {
  5975. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  5976. }
  5977. return map;
  5978. }
  5979. return value !== undefined ?
  5980. jQuery.style( elem, name, value ) :
  5981. jQuery.css( elem, name );
  5982. }, name, value, arguments.length > 1 );
  5983. },
  5984. show: function() {
  5985. return showHide( this, true );
  5986. },
  5987. hide: function() {
  5988. return showHide( this );
  5989. },
  5990. toggle: function( state ) {
  5991. if ( typeof state === "boolean" ) {
  5992. return state ? this.show() : this.hide();
  5993. }
  5994. return this.each( function() {
  5995. if ( isHidden( this ) ) {
  5996. jQuery( this ).show();
  5997. } else {
  5998. jQuery( this ).hide();
  5999. }
  6000. } );
  6001. }
  6002. } );
  6003. function Tween( elem, options, prop, end, easing ) {
  6004. return new Tween.prototype.init( elem, options, prop, end, easing );
  6005. }
  6006. jQuery.Tween = Tween;
  6007. Tween.prototype = {
  6008. constructor: Tween,
  6009. init: function( elem, options, prop, end, easing, unit ) {
  6010. this.elem = elem;
  6011. this.prop = prop;
  6012. this.easing = easing || jQuery.easing._default;
  6013. this.options = options;
  6014. this.start = this.now = this.cur();
  6015. this.end = end;
  6016. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  6017. },
  6018. cur: function() {
  6019. var hooks = Tween.propHooks[ this.prop ];
  6020. return hooks && hooks.get ?
  6021. hooks.get( this ) :
  6022. Tween.propHooks._default.get( this );
  6023. },
  6024. run: function( percent ) {
  6025. var eased,
  6026. hooks = Tween.propHooks[ this.prop ];
  6027. if ( this.options.duration ) {
  6028. this.pos = eased = jQuery.easing[ this.easing ](
  6029. percent, this.options.duration * percent, 0, 1, this.options.duration
  6030. );
  6031. } else {
  6032. this.pos = eased = percent;
  6033. }
  6034. this.now = ( this.end - this.start ) * eased + this.start;
  6035. if ( this.options.step ) {
  6036. this.options.step.call( this.elem, this.now, this );
  6037. }
  6038. if ( hooks && hooks.set ) {
  6039. hooks.set( this );
  6040. } else {
  6041. Tween.propHooks._default.set( this );
  6042. }
  6043. return this;
  6044. }
  6045. };
  6046. Tween.prototype.init.prototype = Tween.prototype;
  6047. Tween.propHooks = {
  6048. _default: {
  6049. get: function( tween ) {
  6050. var result;
  6051. // Use a property on the element directly when it is not a DOM element,
  6052. // or when there is no matching style property that exists.
  6053. if ( tween.elem.nodeType !== 1 ||
  6054. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  6055. return tween.elem[ tween.prop ];
  6056. }
  6057. // passing an empty string as a 3rd parameter to .css will automatically
  6058. // attempt a parseFloat and fallback to a string if the parse fails
  6059. // so, simple values such as "10px" are parsed to Float.
  6060. // complex values such as "rotate(1rad)" are returned as is.
  6061. result = jQuery.css( tween.elem, tween.prop, "" );
  6062. // Empty strings, null, undefined and "auto" are converted to 0.
  6063. return !result || result === "auto" ? 0 : result;
  6064. },
  6065. set: function( tween ) {
  6066. // use step hook for back compat - use cssHook if its there - use .style if its
  6067. // available and use plain properties where available
  6068. if ( jQuery.fx.step[ tween.prop ] ) {
  6069. jQuery.fx.step[ tween.prop ]( tween );
  6070. } else if ( tween.elem.nodeType === 1 &&
  6071. ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null ||
  6072. jQuery.cssHooks[ tween.prop ] ) ) {
  6073. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  6074. } else {
  6075. tween.elem[ tween.prop ] = tween.now;
  6076. }
  6077. }
  6078. }
  6079. };
  6080. // Support: IE <=9
  6081. // Panic based approach to setting things on disconnected nodes
  6082. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  6083. set: function( tween ) {
  6084. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  6085. tween.elem[ tween.prop ] = tween.now;
  6086. }
  6087. }
  6088. };
  6089. jQuery.easing = {
  6090. linear: function( p ) {
  6091. return p;
  6092. },
  6093. swing: function( p ) {
  6094. return 0.5 - Math.cos( p * Math.PI ) / 2;
  6095. },
  6096. _default: "swing"
  6097. };
  6098. jQuery.fx = Tween.prototype.init;
  6099. // Back Compat <1.8 extension point
  6100. jQuery.fx.step = {};
  6101. var
  6102. fxNow, timerId,
  6103. rfxtypes = /^(?:toggle|show|hide)$/,
  6104. rrun = /queueHooks$/;
  6105. // Animations created synchronously will run synchronously
  6106. function createFxNow() {
  6107. window.setTimeout( function() {
  6108. fxNow = undefined;
  6109. } );
  6110. return ( fxNow = jQuery.now() );
  6111. }
  6112. // Generate parameters to create a standard animation
  6113. function genFx( type, includeWidth ) {
  6114. var which,
  6115. attrs = { height: type },
  6116. i = 0;
  6117. // if we include width, step value is 1 to do all cssExpand values,
  6118. // if we don't include width, step value is 2 to skip over Left and Right
  6119. includeWidth = includeWidth ? 1 : 0;
  6120. for ( ; i < 4 ; i += 2 - includeWidth ) {
  6121. which = cssExpand[ i ];
  6122. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  6123. }
  6124. if ( includeWidth ) {
  6125. attrs.opacity = attrs.width = type;
  6126. }
  6127. return attrs;
  6128. }
  6129. function createTween( value, prop, animation ) {
  6130. var tween,
  6131. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  6132. index = 0,
  6133. length = collection.length;
  6134. for ( ; index < length; index++ ) {
  6135. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  6136. // we're done with this property
  6137. return tween;
  6138. }
  6139. }
  6140. }
  6141. function defaultPrefilter( elem, props, opts ) {
  6142. /* jshint validthis: true */
  6143. var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
  6144. anim = this,
  6145. orig = {},
  6146. style = elem.style,
  6147. hidden = elem.nodeType && isHidden( elem ),
  6148. dataShow = jQuery._data( elem, "fxshow" );
  6149. // handle queue: false promises
  6150. if ( !opts.queue ) {
  6151. hooks = jQuery._queueHooks( elem, "fx" );
  6152. if ( hooks.unqueued == null ) {
  6153. hooks.unqueued = 0;
  6154. oldfire = hooks.empty.fire;
  6155. hooks.empty.fire = function() {
  6156. if ( !hooks.unqueued ) {
  6157. oldfire();
  6158. }
  6159. };
  6160. }
  6161. hooks.unqueued++;
  6162. anim.always( function() {
  6163. // doing this makes sure that the complete handler will be called
  6164. // before this completes
  6165. anim.always( function() {
  6166. hooks.unqueued--;
  6167. if ( !jQuery.queue( elem, "fx" ).length ) {
  6168. hooks.empty.fire();
  6169. }
  6170. } );
  6171. } );
  6172. }
  6173. // height/width overflow pass
  6174. if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
  6175. // Make sure that nothing sneaks out
  6176. // Record all 3 overflow attributes because IE does not
  6177. // change the overflow attribute when overflowX and
  6178. // overflowY are set to the same value
  6179. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  6180. // Set display property to inline-block for height/width
  6181. // animations on inline elements that are having width/height animated
  6182. display = jQuery.css( elem, "display" );
  6183. // Test default display if display is currently "none"
  6184. checkDisplay = display === "none" ?
  6185. jQuery._data( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
  6186. if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
  6187. // inline-level elements accept inline-block;
  6188. // block-level elements need to be inline with layout
  6189. if ( !support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) {
  6190. style.display = "inline-block";
  6191. } else {
  6192. style.zoom = 1;
  6193. }
  6194. }
  6195. }
  6196. if ( opts.overflow ) {
  6197. style.overflow = "hidden";
  6198. if ( !support.shrinkWrapBlocks() ) {
  6199. anim.always( function() {
  6200. style.overflow = opts.overflow[ 0 ];
  6201. style.overflowX = opts.overflow[ 1 ];
  6202. style.overflowY = opts.overflow[ 2 ];
  6203. } );
  6204. }
  6205. }
  6206. // show/hide pass
  6207. for ( prop in props ) {
  6208. value = props[ prop ];
  6209. if ( rfxtypes.exec( value ) ) {
  6210. delete props[ prop ];
  6211. toggle = toggle || value === "toggle";
  6212. if ( value === ( hidden ? "hide" : "show" ) ) {
  6213. // If there is dataShow left over from a stopped hide or show
  6214. // and we are going to proceed with show, we should pretend to be hidden
  6215. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  6216. hidden = true;
  6217. } else {
  6218. continue;
  6219. }
  6220. }
  6221. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  6222. // Any non-fx value stops us from restoring the original display value
  6223. } else {
  6224. display = undefined;
  6225. }
  6226. }
  6227. if ( !jQuery.isEmptyObject( orig ) ) {
  6228. if ( dataShow ) {
  6229. if ( "hidden" in dataShow ) {
  6230. hidden = dataShow.hidden;
  6231. }
  6232. } else {
  6233. dataShow = jQuery._data( elem, "fxshow", {} );
  6234. }
  6235. // store state if its toggle - enables .stop().toggle() to "reverse"
  6236. if ( toggle ) {
  6237. dataShow.hidden = !hidden;
  6238. }
  6239. if ( hidden ) {
  6240. jQuery( elem ).show();
  6241. } else {
  6242. anim.done( function() {
  6243. jQuery( elem ).hide();
  6244. } );
  6245. }
  6246. anim.done( function() {
  6247. var prop;
  6248. jQuery._removeData( elem, "fxshow" );
  6249. for ( prop in orig ) {
  6250. jQuery.style( elem, prop, orig[ prop ] );
  6251. }
  6252. } );
  6253. for ( prop in orig ) {
  6254. tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  6255. if ( !( prop in dataShow ) ) {
  6256. dataShow[ prop ] = tween.start;
  6257. if ( hidden ) {
  6258. tween.end = tween.start;
  6259. tween.start = prop === "width" || prop === "height" ? 1 : 0;
  6260. }
  6261. }
  6262. }
  6263. // If this is a noop like .hide().hide(), restore an overwritten display value
  6264. } else if ( ( display === "none" ? defaultDisplay( elem.nodeName ) : display ) === "inline" ) {
  6265. style.display = display;
  6266. }
  6267. }
  6268. function propFilter( props, specialEasing ) {
  6269. var index, name, easing, value, hooks;
  6270. // camelCase, specialEasing and expand cssHook pass
  6271. for ( index in props ) {
  6272. name = jQuery.camelCase( index );
  6273. easing = specialEasing[ name ];
  6274. value = props[ index ];
  6275. if ( jQuery.isArray( value ) ) {
  6276. easing = value[ 1 ];
  6277. value = props[ index ] = value[ 0 ];
  6278. }
  6279. if ( index !== name ) {
  6280. props[ name ] = value;
  6281. delete props[ index ];
  6282. }
  6283. hooks = jQuery.cssHooks[ name ];
  6284. if ( hooks && "expand" in hooks ) {
  6285. value = hooks.expand( value );
  6286. delete props[ name ];
  6287. // not quite $.extend, this wont overwrite keys already present.
  6288. // also - reusing 'index' from above because we have the correct "name"
  6289. for ( index in value ) {
  6290. if ( !( index in props ) ) {
  6291. props[ index ] = value[ index ];
  6292. specialEasing[ index ] = easing;
  6293. }
  6294. }
  6295. } else {
  6296. specialEasing[ name ] = easing;
  6297. }
  6298. }
  6299. }
  6300. function Animation( elem, properties, options ) {
  6301. var result,
  6302. stopped,
  6303. index = 0,
  6304. length = Animation.prefilters.length,
  6305. deferred = jQuery.Deferred().always( function() {
  6306. // don't match elem in the :animated selector
  6307. delete tick.elem;
  6308. } ),
  6309. tick = function() {
  6310. if ( stopped ) {
  6311. return false;
  6312. }
  6313. var currentTime = fxNow || createFxNow(),
  6314. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  6315. // Support: Android 2.3
  6316. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  6317. temp = remaining / animation.duration || 0,
  6318. percent = 1 - temp,
  6319. index = 0,
  6320. length = animation.tweens.length;
  6321. for ( ; index < length ; index++ ) {
  6322. animation.tweens[ index ].run( percent );
  6323. }
  6324. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  6325. if ( percent < 1 && length ) {
  6326. return remaining;
  6327. } else {
  6328. deferred.resolveWith( elem, [ animation ] );
  6329. return false;
  6330. }
  6331. },
  6332. animation = deferred.promise( {
  6333. elem: elem,
  6334. props: jQuery.extend( {}, properties ),
  6335. opts: jQuery.extend( true, {
  6336. specialEasing: {},
  6337. easing: jQuery.easing._default
  6338. }, options ),
  6339. originalProperties: properties,
  6340. originalOptions: options,
  6341. startTime: fxNow || createFxNow(),
  6342. duration: options.duration,
  6343. tweens: [],
  6344. createTween: function( prop, end ) {
  6345. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  6346. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  6347. animation.tweens.push( tween );
  6348. return tween;
  6349. },
  6350. stop: function( gotoEnd ) {
  6351. var index = 0,
  6352. // if we are going to the end, we want to run all the tweens
  6353. // otherwise we skip this part
  6354. length = gotoEnd ? animation.tweens.length : 0;
  6355. if ( stopped ) {
  6356. return this;
  6357. }
  6358. stopped = true;
  6359. for ( ; index < length ; index++ ) {
  6360. animation.tweens[ index ].run( 1 );
  6361. }
  6362. // resolve when we played the last frame
  6363. // otherwise, reject
  6364. if ( gotoEnd ) {
  6365. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  6366. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  6367. } else {
  6368. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  6369. }
  6370. return this;
  6371. }
  6372. } ),
  6373. props = animation.props;
  6374. propFilter( props, animation.opts.specialEasing );
  6375. for ( ; index < length ; index++ ) {
  6376. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  6377. if ( result ) {
  6378. if ( jQuery.isFunction( result.stop ) ) {
  6379. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  6380. jQuery.proxy( result.stop, result );
  6381. }
  6382. return result;
  6383. }
  6384. }
  6385. jQuery.map( props, createTween, animation );
  6386. if ( jQuery.isFunction( animation.opts.start ) ) {
  6387. animation.opts.start.call( elem, animation );
  6388. }
  6389. jQuery.fx.timer(
  6390. jQuery.extend( tick, {
  6391. elem: elem,
  6392. anim: animation,
  6393. queue: animation.opts.queue
  6394. } )
  6395. );
  6396. // attach callbacks from options
  6397. return animation.progress( animation.opts.progress )
  6398. .done( animation.opts.done, animation.opts.complete )
  6399. .fail( animation.opts.fail )
  6400. .always( animation.opts.always );
  6401. }
  6402. jQuery.Animation = jQuery.extend( Animation, {
  6403. tweeners: {
  6404. "*": [ function( prop, value ) {
  6405. var tween = this.createTween( prop, value );
  6406. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  6407. return tween;
  6408. } ]
  6409. },
  6410. tweener: function( props, callback ) {
  6411. if ( jQuery.isFunction( props ) ) {
  6412. callback = props;
  6413. props = [ "*" ];
  6414. } else {
  6415. props = props.match( rnotwhite );
  6416. }
  6417. var prop,
  6418. index = 0,
  6419. length = props.length;
  6420. for ( ; index < length ; index++ ) {
  6421. prop = props[ index ];
  6422. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  6423. Animation.tweeners[ prop ].unshift( callback );
  6424. }
  6425. },
  6426. prefilters: [ defaultPrefilter ],
  6427. prefilter: function( callback, prepend ) {
  6428. if ( prepend ) {
  6429. Animation.prefilters.unshift( callback );
  6430. } else {
  6431. Animation.prefilters.push( callback );
  6432. }
  6433. }
  6434. } );
  6435. jQuery.speed = function( speed, easing, fn ) {
  6436. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  6437. complete: fn || !fn && easing ||
  6438. jQuery.isFunction( speed ) && speed,
  6439. duration: speed,
  6440. easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
  6441. };
  6442. opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
  6443. opt.duration in jQuery.fx.speeds ?
  6444. jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
  6445. // normalize opt.queue - true/undefined/null -> "fx"
  6446. if ( opt.queue == null || opt.queue === true ) {
  6447. opt.queue = "fx";
  6448. }
  6449. // Queueing
  6450. opt.old = opt.complete;
  6451. opt.complete = function() {
  6452. if ( jQuery.isFunction( opt.old ) ) {
  6453. opt.old.call( this );
  6454. }
  6455. if ( opt.queue ) {
  6456. jQuery.dequeue( this, opt.queue );
  6457. }
  6458. };
  6459. return opt;
  6460. };
  6461. jQuery.fn.extend( {
  6462. fadeTo: function( speed, to, easing, callback ) {
  6463. // show any hidden elements after setting opacity to 0
  6464. return this.filter( isHidden ).css( "opacity", 0 ).show()
  6465. // animate to the value specified
  6466. .end().animate( { opacity: to }, speed, easing, callback );
  6467. },
  6468. animate: function( prop, speed, easing, callback ) {
  6469. var empty = jQuery.isEmptyObject( prop ),
  6470. optall = jQuery.speed( speed, easing, callback ),
  6471. doAnimation = function() {
  6472. // Operate on a copy of prop so per-property easing won't be lost
  6473. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  6474. // Empty animations, or finishing resolves immediately
  6475. if ( empty || jQuery._data( this, "finish" ) ) {
  6476. anim.stop( true );
  6477. }
  6478. };
  6479. doAnimation.finish = doAnimation;
  6480. return empty || optall.queue === false ?
  6481. this.each( doAnimation ) :
  6482. this.queue( optall.queue, doAnimation );
  6483. },
  6484. stop: function( type, clearQueue, gotoEnd ) {
  6485. var stopQueue = function( hooks ) {
  6486. var stop = hooks.stop;
  6487. delete hooks.stop;
  6488. stop( gotoEnd );
  6489. };
  6490. if ( typeof type !== "string" ) {
  6491. gotoEnd = clearQueue;
  6492. clearQueue = type;
  6493. type = undefined;
  6494. }
  6495. if ( clearQueue && type !== false ) {
  6496. this.queue( type || "fx", [] );
  6497. }
  6498. return this.each( function() {
  6499. var dequeue = true,
  6500. index = type != null && type + "queueHooks",
  6501. timers = jQuery.timers,
  6502. data = jQuery._data( this );
  6503. if ( index ) {
  6504. if ( data[ index ] && data[ index ].stop ) {
  6505. stopQueue( data[ index ] );
  6506. }
  6507. } else {
  6508. for ( index in data ) {
  6509. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  6510. stopQueue( data[ index ] );
  6511. }
  6512. }
  6513. }
  6514. for ( index = timers.length; index--; ) {
  6515. if ( timers[ index ].elem === this &&
  6516. ( type == null || timers[ index ].queue === type ) ) {
  6517. timers[ index ].anim.stop( gotoEnd );
  6518. dequeue = false;
  6519. timers.splice( index, 1 );
  6520. }
  6521. }
  6522. // start the next in the queue if the last step wasn't forced
  6523. // timers currently will call their complete callbacks, which will dequeue
  6524. // but only if they were gotoEnd
  6525. if ( dequeue || !gotoEnd ) {
  6526. jQuery.dequeue( this, type );
  6527. }
  6528. } );
  6529. },
  6530. finish: function( type ) {
  6531. if ( type !== false ) {
  6532. type = type || "fx";
  6533. }
  6534. return this.each( function() {
  6535. var index,
  6536. data = jQuery._data( this ),
  6537. queue = data[ type + "queue" ],
  6538. hooks = data[ type + "queueHooks" ],
  6539. timers = jQuery.timers,
  6540. length = queue ? queue.length : 0;
  6541. // enable finishing flag on private data
  6542. data.finish = true;
  6543. // empty the queue first
  6544. jQuery.queue( this, type, [] );
  6545. if ( hooks && hooks.stop ) {
  6546. hooks.stop.call( this, true );
  6547. }
  6548. // look for any active animations, and finish them
  6549. for ( index = timers.length; index--; ) {
  6550. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  6551. timers[ index ].anim.stop( true );
  6552. timers.splice( index, 1 );
  6553. }
  6554. }
  6555. // look for any animations in the old queue and finish them
  6556. for ( index = 0; index < length; index++ ) {
  6557. if ( queue[ index ] && queue[ index ].finish ) {
  6558. queue[ index ].finish.call( this );
  6559. }
  6560. }
  6561. // turn off finishing flag
  6562. delete data.finish;
  6563. } );
  6564. }
  6565. } );
  6566. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  6567. var cssFn = jQuery.fn[ name ];
  6568. jQuery.fn[ name ] = function( speed, easing, callback ) {
  6569. return speed == null || typeof speed === "boolean" ?
  6570. cssFn.apply( this, arguments ) :
  6571. this.animate( genFx( name, true ), speed, easing, callback );
  6572. };
  6573. } );
  6574. // Generate shortcuts for custom animations
  6575. jQuery.each( {
  6576. slideDown: genFx( "show" ),
  6577. slideUp: genFx( "hide" ),
  6578. slideToggle: genFx( "toggle" ),
  6579. fadeIn: { opacity: "show" },
  6580. fadeOut: { opacity: "hide" },
  6581. fadeToggle: { opacity: "toggle" }
  6582. }, function( name, props ) {
  6583. jQuery.fn[ name ] = function( speed, easing, callback ) {
  6584. return this.animate( props, speed, easing, callback );
  6585. };
  6586. } );
  6587. jQuery.timers = [];
  6588. jQuery.fx.tick = function() {
  6589. var timer,
  6590. timers = jQuery.timers,
  6591. i = 0;
  6592. fxNow = jQuery.now();
  6593. for ( ; i < timers.length; i++ ) {
  6594. timer = timers[ i ];
  6595. // Checks the timer has not already been removed
  6596. if ( !timer() && timers[ i ] === timer ) {
  6597. timers.splice( i--, 1 );
  6598. }
  6599. }
  6600. if ( !timers.length ) {
  6601. jQuery.fx.stop();
  6602. }
  6603. fxNow = undefined;
  6604. };
  6605. jQuery.fx.timer = function( timer ) {
  6606. jQuery.timers.push( timer );
  6607. if ( timer() ) {
  6608. jQuery.fx.start();
  6609. } else {
  6610. jQuery.timers.pop();
  6611. }
  6612. };
  6613. jQuery.fx.interval = 13;
  6614. jQuery.fx.start = function() {
  6615. if ( !timerId ) {
  6616. timerId = window.setInterval( jQuery.fx.tick, jQuery.fx.interval );
  6617. }
  6618. };
  6619. jQuery.fx.stop = function() {
  6620. window.clearInterval( timerId );
  6621. timerId = null;
  6622. };
  6623. jQuery.fx.speeds = {
  6624. slow: 600,
  6625. fast: 200,
  6626. // Default speed
  6627. _default: 400
  6628. };
  6629. // Based off of the plugin by Clint Helfers, with permission.
  6630. // http://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  6631. jQuery.fn.delay = function( time, type ) {
  6632. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  6633. type = type || "fx";
  6634. return this.queue( type, function( next, hooks ) {
  6635. var timeout = window.setTimeout( next, time );
  6636. hooks.stop = function() {
  6637. window.clearTimeout( timeout );
  6638. };
  6639. } );
  6640. };
  6641. ( function() {
  6642. var a,
  6643. input = document.createElement( "input" ),
  6644. div = document.createElement( "div" ),
  6645. select = document.createElement( "select" ),
  6646. opt = select.appendChild( document.createElement( "option" ) );
  6647. // Setup
  6648. div = document.createElement( "div" );
  6649. div.setAttribute( "className", "t" );
  6650. div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
  6651. a = div.getElementsByTagName( "a" )[ 0 ];
  6652. // Support: Windows Web Apps (WWA)
  6653. // `type` must use .setAttribute for WWA (#14901)
  6654. input.setAttribute( "type", "checkbox" );
  6655. div.appendChild( input );
  6656. a = div.getElementsByTagName( "a" )[ 0 ];
  6657. // First batch of tests.
  6658. a.style.cssText = "top:1px";
  6659. // Test setAttribute on camelCase class.
  6660. // If it works, we need attrFixes when doing get/setAttribute (ie6/7)
  6661. support.getSetAttribute = div.className !== "t";
  6662. // Get the style information from getAttribute
  6663. // (IE uses .cssText instead)
  6664. support.style = /top/.test( a.getAttribute( "style" ) );
  6665. // Make sure that URLs aren't manipulated
  6666. // (IE normalizes it by default)
  6667. support.hrefNormalized = a.getAttribute( "href" ) === "/a";
  6668. // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
  6669. support.checkOn = !!input.value;
  6670. // Make sure that a selected-by-default option has a working selected property.
  6671. // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
  6672. support.optSelected = opt.selected;
  6673. // Tests for enctype support on a form (#6743)
  6674. support.enctype = !!document.createElement( "form" ).enctype;
  6675. // Make sure that the options inside disabled selects aren't marked as disabled
  6676. // (WebKit marks them as disabled)
  6677. select.disabled = true;
  6678. support.optDisabled = !opt.disabled;
  6679. // Support: IE8 only
  6680. // Check if we can trust getAttribute("value")
  6681. input = document.createElement( "input" );
  6682. input.setAttribute( "value", "" );
  6683. support.input = input.getAttribute( "value" ) === "";
  6684. // Check if an input maintains its value after becoming a radio
  6685. input.value = "t";
  6686. input.setAttribute( "type", "radio" );
  6687. support.radioValue = input.value === "t";
  6688. } )();
  6689. var rreturn = /\r/g,
  6690. rspaces = /[\x20\t\r\n\f]+/g;
  6691. jQuery.fn.extend( {
  6692. val: function( value ) {
  6693. var hooks, ret, isFunction,
  6694. elem = this[ 0 ];
  6695. if ( !arguments.length ) {
  6696. if ( elem ) {
  6697. hooks = jQuery.valHooks[ elem.type ] ||
  6698. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  6699. if (
  6700. hooks &&
  6701. "get" in hooks &&
  6702. ( ret = hooks.get( elem, "value" ) ) !== undefined
  6703. ) {
  6704. return ret;
  6705. }
  6706. ret = elem.value;
  6707. return typeof ret === "string" ?
  6708. // handle most common string cases
  6709. ret.replace( rreturn, "" ) :
  6710. // handle cases where value is null/undef or number
  6711. ret == null ? "" : ret;
  6712. }
  6713. return;
  6714. }
  6715. isFunction = jQuery.isFunction( value );
  6716. return this.each( function( i ) {
  6717. var val;
  6718. if ( this.nodeType !== 1 ) {
  6719. return;
  6720. }
  6721. if ( isFunction ) {
  6722. val = value.call( this, i, jQuery( this ).val() );
  6723. } else {
  6724. val = value;
  6725. }
  6726. // Treat null/undefined as ""; convert numbers to string
  6727. if ( val == null ) {
  6728. val = "";
  6729. } else if ( typeof val === "number" ) {
  6730. val += "";
  6731. } else if ( jQuery.isArray( val ) ) {
  6732. val = jQuery.map( val, function( value ) {
  6733. return value == null ? "" : value + "";
  6734. } );
  6735. }
  6736. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  6737. // If set returns undefined, fall back to normal setting
  6738. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  6739. this.value = val;
  6740. }
  6741. } );
  6742. }
  6743. } );
  6744. jQuery.extend( {
  6745. valHooks: {
  6746. option: {
  6747. get: function( elem ) {
  6748. var val = jQuery.find.attr( elem, "value" );
  6749. return val != null ?
  6750. val :
  6751. // Support: IE10-11+
  6752. // option.text throws exceptions (#14686, #14858)
  6753. // Strip and collapse whitespace
  6754. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  6755. jQuery.trim( jQuery.text( elem ) ).replace( rspaces, " " );
  6756. }
  6757. },
  6758. select: {
  6759. get: function( elem ) {
  6760. var value, option,
  6761. options = elem.options,
  6762. index = elem.selectedIndex,
  6763. one = elem.type === "select-one" || index < 0,
  6764. values = one ? null : [],
  6765. max = one ? index + 1 : options.length,
  6766. i = index < 0 ?
  6767. max :
  6768. one ? index : 0;
  6769. // Loop through all the selected options
  6770. for ( ; i < max; i++ ) {
  6771. option = options[ i ];
  6772. // oldIE doesn't update selected after form reset (#2551)
  6773. if ( ( option.selected || i === index ) &&
  6774. // Don't return options that are disabled or in a disabled optgroup
  6775. ( support.optDisabled ?
  6776. !option.disabled :
  6777. option.getAttribute( "disabled" ) === null ) &&
  6778. ( !option.parentNode.disabled ||
  6779. !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
  6780. // Get the specific value for the option
  6781. value = jQuery( option ).val();
  6782. // We don't need an array for one selects
  6783. if ( one ) {
  6784. return value;
  6785. }
  6786. // Multi-Selects return an array
  6787. values.push( value );
  6788. }
  6789. }
  6790. return values;
  6791. },
  6792. set: function( elem, value ) {
  6793. var optionSet, option,
  6794. options = elem.options,
  6795. values = jQuery.makeArray( value ),
  6796. i = options.length;
  6797. while ( i-- ) {
  6798. option = options[ i ];
  6799. if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 ) {
  6800. // Support: IE6
  6801. // When new option element is added to select box we need to
  6802. // force reflow of newly added node in order to workaround delay
  6803. // of initialization properties
  6804. try {
  6805. option.selected = optionSet = true;
  6806. } catch ( _ ) {
  6807. // Will be executed only in IE6
  6808. option.scrollHeight;
  6809. }
  6810. } else {
  6811. option.selected = false;
  6812. }
  6813. }
  6814. // Force browsers to behave consistently when non-matching value is set
  6815. if ( !optionSet ) {
  6816. elem.selectedIndex = -1;
  6817. }
  6818. return options;
  6819. }
  6820. }
  6821. }
  6822. } );
  6823. // Radios and checkboxes getter/setter
  6824. jQuery.each( [ "radio", "checkbox" ], function() {
  6825. jQuery.valHooks[ this ] = {
  6826. set: function( elem, value ) {
  6827. if ( jQuery.isArray( value ) ) {
  6828. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  6829. }
  6830. }
  6831. };
  6832. if ( !support.checkOn ) {
  6833. jQuery.valHooks[ this ].get = function( elem ) {
  6834. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  6835. };
  6836. }
  6837. } );
  6838. var nodeHook, boolHook,
  6839. attrHandle = jQuery.expr.attrHandle,
  6840. ruseDefault = /^(?:checked|selected)$/i,
  6841. getSetAttribute = support.getSetAttribute,
  6842. getSetInput = support.input;
  6843. jQuery.fn.extend( {
  6844. attr: function( name, value ) {
  6845. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  6846. },
  6847. removeAttr: function( name ) {
  6848. return this.each( function() {
  6849. jQuery.removeAttr( this, name );
  6850. } );
  6851. }
  6852. } );
  6853. jQuery.extend( {
  6854. attr: function( elem, name, value ) {
  6855. var ret, hooks,
  6856. nType = elem.nodeType;
  6857. // Don't get/set attributes on text, comment and attribute nodes
  6858. if ( nType === 3 || nType === 8 || nType === 2 ) {
  6859. return;
  6860. }
  6861. // Fallback to prop when attributes are not supported
  6862. if ( typeof elem.getAttribute === "undefined" ) {
  6863. return jQuery.prop( elem, name, value );
  6864. }
  6865. // All attributes are lowercase
  6866. // Grab necessary hook if one is defined
  6867. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  6868. name = name.toLowerCase();
  6869. hooks = jQuery.attrHooks[ name ] ||
  6870. ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
  6871. }
  6872. if ( value !== undefined ) {
  6873. if ( value === null ) {
  6874. jQuery.removeAttr( elem, name );
  6875. return;
  6876. }
  6877. if ( hooks && "set" in hooks &&
  6878. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  6879. return ret;
  6880. }
  6881. elem.setAttribute( name, value + "" );
  6882. return value;
  6883. }
  6884. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  6885. return ret;
  6886. }
  6887. ret = jQuery.find.attr( elem, name );
  6888. // Non-existent attributes return null, we normalize to undefined
  6889. return ret == null ? undefined : ret;
  6890. },
  6891. attrHooks: {
  6892. type: {
  6893. set: function( elem, value ) {
  6894. if ( !support.radioValue && value === "radio" &&
  6895. jQuery.nodeName( elem, "input" ) ) {
  6896. // Setting the type on a radio button after the value resets the value in IE8-9
  6897. // Reset value to default in case type is set after value during creation
  6898. var val = elem.value;
  6899. elem.setAttribute( "type", value );
  6900. if ( val ) {
  6901. elem.value = val;
  6902. }
  6903. return value;
  6904. }
  6905. }
  6906. }
  6907. },
  6908. removeAttr: function( elem, value ) {
  6909. var name, propName,
  6910. i = 0,
  6911. attrNames = value && value.match( rnotwhite );
  6912. if ( attrNames && elem.nodeType === 1 ) {
  6913. while ( ( name = attrNames[ i++ ] ) ) {
  6914. propName = jQuery.propFix[ name ] || name;
  6915. // Boolean attributes get special treatment (#10870)
  6916. if ( jQuery.expr.match.bool.test( name ) ) {
  6917. // Set corresponding property to false
  6918. if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
  6919. elem[ propName ] = false;
  6920. // Support: IE<9
  6921. // Also clear defaultChecked/defaultSelected (if appropriate)
  6922. } else {
  6923. elem[ jQuery.camelCase( "default-" + name ) ] =
  6924. elem[ propName ] = false;
  6925. }
  6926. // See #9699 for explanation of this approach (setting first, then removal)
  6927. } else {
  6928. jQuery.attr( elem, name, "" );
  6929. }
  6930. elem.removeAttribute( getSetAttribute ? name : propName );
  6931. }
  6932. }
  6933. }
  6934. } );
  6935. // Hooks for boolean attributes
  6936. boolHook = {
  6937. set: function( elem, value, name ) {
  6938. if ( value === false ) {
  6939. // Remove boolean attributes when set to false
  6940. jQuery.removeAttr( elem, name );
  6941. } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
  6942. // IE<8 needs the *property* name
  6943. elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
  6944. } else {
  6945. // Support: IE<9
  6946. // Use defaultChecked and defaultSelected for oldIE
  6947. elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
  6948. }
  6949. return name;
  6950. }
  6951. };
  6952. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  6953. var getter = attrHandle[ name ] || jQuery.find.attr;
  6954. if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
  6955. attrHandle[ name ] = function( elem, name, isXML ) {
  6956. var ret, handle;
  6957. if ( !isXML ) {
  6958. // Avoid an infinite loop by temporarily removing this function from the getter
  6959. handle = attrHandle[ name ];
  6960. attrHandle[ name ] = ret;
  6961. ret = getter( elem, name, isXML ) != null ?
  6962. name.toLowerCase() :
  6963. null;
  6964. attrHandle[ name ] = handle;
  6965. }
  6966. return ret;
  6967. };
  6968. } else {
  6969. attrHandle[ name ] = function( elem, name, isXML ) {
  6970. if ( !isXML ) {
  6971. return elem[ jQuery.camelCase( "default-" + name ) ] ?
  6972. name.toLowerCase() :
  6973. null;
  6974. }
  6975. };
  6976. }
  6977. } );
  6978. // fix oldIE attroperties
  6979. if ( !getSetInput || !getSetAttribute ) {
  6980. jQuery.attrHooks.value = {
  6981. set: function( elem, value, name ) {
  6982. if ( jQuery.nodeName( elem, "input" ) ) {
  6983. // Does not return so that setAttribute is also used
  6984. elem.defaultValue = value;
  6985. } else {
  6986. // Use nodeHook if defined (#1954); otherwise setAttribute is fine
  6987. return nodeHook && nodeHook.set( elem, value, name );
  6988. }
  6989. }
  6990. };
  6991. }
  6992. // IE6/7 do not support getting/setting some attributes with get/setAttribute
  6993. if ( !getSetAttribute ) {
  6994. // Use this for any attribute in IE6/7
  6995. // This fixes almost every IE6/7 issue
  6996. nodeHook = {
  6997. set: function( elem, value, name ) {
  6998. // Set the existing or create a new attribute node
  6999. var ret = elem.getAttributeNode( name );
  7000. if ( !ret ) {
  7001. elem.setAttributeNode(
  7002. ( ret = elem.ownerDocument.createAttribute( name ) )
  7003. );
  7004. }
  7005. ret.value = value += "";
  7006. // Break association with cloned elements by also using setAttribute (#9646)
  7007. if ( name === "value" || value === elem.getAttribute( name ) ) {
  7008. return value;
  7009. }
  7010. }
  7011. };
  7012. // Some attributes are constructed with empty-string values when not defined
  7013. attrHandle.id = attrHandle.name = attrHandle.coords =
  7014. function( elem, name, isXML ) {
  7015. var ret;
  7016. if ( !isXML ) {
  7017. return ( ret = elem.getAttributeNode( name ) ) && ret.value !== "" ?
  7018. ret.value :
  7019. null;
  7020. }
  7021. };
  7022. // Fixing value retrieval on a button requires this module
  7023. jQuery.valHooks.button = {
  7024. get: function( elem, name ) {
  7025. var ret = elem.getAttributeNode( name );
  7026. if ( ret && ret.specified ) {
  7027. return ret.value;
  7028. }
  7029. },
  7030. set: nodeHook.set
  7031. };
  7032. // Set contenteditable to false on removals(#10429)
  7033. // Setting to empty string throws an error as an invalid value
  7034. jQuery.attrHooks.contenteditable = {
  7035. set: function( elem, value, name ) {
  7036. nodeHook.set( elem, value === "" ? false : value, name );
  7037. }
  7038. };
  7039. // Set width and height to auto instead of 0 on empty string( Bug #8150 )
  7040. // This is for removals
  7041. jQuery.each( [ "width", "height" ], function( i, name ) {
  7042. jQuery.attrHooks[ name ] = {
  7043. set: function( elem, value ) {
  7044. if ( value === "" ) {
  7045. elem.setAttribute( name, "auto" );
  7046. return value;
  7047. }
  7048. }
  7049. };
  7050. } );
  7051. }
  7052. if ( !support.style ) {
  7053. jQuery.attrHooks.style = {
  7054. get: function( elem ) {
  7055. // Return undefined in the case of empty string
  7056. // Note: IE uppercases css property names, but if we were to .toLowerCase()
  7057. // .cssText, that would destroy case sensitivity in URL's, like in "background"
  7058. return elem.style.cssText || undefined;
  7059. },
  7060. set: function( elem, value ) {
  7061. return ( elem.style.cssText = value + "" );
  7062. }
  7063. };
  7064. }
  7065. var rfocusable = /^(?:input|select|textarea|button|object)$/i,
  7066. rclickable = /^(?:a|area)$/i;
  7067. jQuery.fn.extend( {
  7068. prop: function( name, value ) {
  7069. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  7070. },
  7071. removeProp: function( name ) {
  7072. name = jQuery.propFix[ name ] || name;
  7073. return this.each( function() {
  7074. // try/catch handles cases where IE balks (such as removing a property on window)
  7075. try {
  7076. this[ name ] = undefined;
  7077. delete this[ name ];
  7078. } catch ( e ) {}
  7079. } );
  7080. }
  7081. } );
  7082. jQuery.extend( {
  7083. prop: function( elem, name, value ) {
  7084. var ret, hooks,
  7085. nType = elem.nodeType;
  7086. // Don't get/set properties on text, comment and attribute nodes
  7087. if ( nType === 3 || nType === 8 || nType === 2 ) {
  7088. return;
  7089. }
  7090. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  7091. // Fix name and attach hooks
  7092. name = jQuery.propFix[ name ] || name;
  7093. hooks = jQuery.propHooks[ name ];
  7094. }
  7095. if ( value !== undefined ) {
  7096. if ( hooks && "set" in hooks &&
  7097. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  7098. return ret;
  7099. }
  7100. return ( elem[ name ] = value );
  7101. }
  7102. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  7103. return ret;
  7104. }
  7105. return elem[ name ];
  7106. },
  7107. propHooks: {
  7108. tabIndex: {
  7109. get: function( elem ) {
  7110. // elem.tabIndex doesn't always return the
  7111. // correct value when it hasn't been explicitly set
  7112. // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  7113. // Use proper attribute retrieval(#12072)
  7114. var tabindex = jQuery.find.attr( elem, "tabindex" );
  7115. return tabindex ?
  7116. parseInt( tabindex, 10 ) :
  7117. rfocusable.test( elem.nodeName ) ||
  7118. rclickable.test( elem.nodeName ) && elem.href ?
  7119. 0 :
  7120. -1;
  7121. }
  7122. }
  7123. },
  7124. propFix: {
  7125. "for": "htmlFor",
  7126. "class": "className"
  7127. }
  7128. } );
  7129. // Some attributes require a special call on IE
  7130. // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  7131. if ( !support.hrefNormalized ) {
  7132. // href/src property should get the full normalized URL (#10299/#12915)
  7133. jQuery.each( [ "href", "src" ], function( i, name ) {
  7134. jQuery.propHooks[ name ] = {
  7135. get: function( elem ) {
  7136. return elem.getAttribute( name, 4 );
  7137. }
  7138. };
  7139. } );
  7140. }
  7141. // Support: Safari, IE9+
  7142. // Accessing the selectedIndex property
  7143. // forces the browser to respect setting selected
  7144. // on the option
  7145. // The getter ensures a default option is selected
  7146. // when in an optgroup
  7147. if ( !support.optSelected ) {
  7148. jQuery.propHooks.selected = {
  7149. get: function( elem ) {
  7150. var parent = elem.parentNode;
  7151. if ( parent ) {
  7152. parent.selectedIndex;
  7153. // Make sure that it also works with optgroups, see #5701
  7154. if ( parent.parentNode ) {
  7155. parent.parentNode.selectedIndex;
  7156. }
  7157. }
  7158. return null;
  7159. },
  7160. set: function( elem ) {
  7161. var parent = elem.parentNode;
  7162. if ( parent ) {
  7163. parent.selectedIndex;
  7164. if ( parent.parentNode ) {
  7165. parent.parentNode.selectedIndex;
  7166. }
  7167. }
  7168. }
  7169. };
  7170. }
  7171. jQuery.each( [
  7172. "tabIndex",
  7173. "readOnly",
  7174. "maxLength",
  7175. "cellSpacing",
  7176. "cellPadding",
  7177. "rowSpan",
  7178. "colSpan",
  7179. "useMap",
  7180. "frameBorder",
  7181. "contentEditable"
  7182. ], function() {
  7183. jQuery.propFix[ this.toLowerCase() ] = this;
  7184. } );
  7185. // IE6/7 call enctype encoding
  7186. if ( !support.enctype ) {
  7187. jQuery.propFix.enctype = "encoding";
  7188. }
  7189. var rclass = /[\t\r\n\f]/g;
  7190. function getClass( elem ) {
  7191. return jQuery.attr( elem, "class" ) || "";
  7192. }
  7193. jQuery.fn.extend( {
  7194. addClass: function( value ) {
  7195. var classes, elem, cur, curValue, clazz, j, finalValue,
  7196. i = 0;
  7197. if ( jQuery.isFunction( value ) ) {
  7198. return this.each( function( j ) {
  7199. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  7200. } );
  7201. }
  7202. if ( typeof value === "string" && value ) {
  7203. classes = value.match( rnotwhite ) || [];
  7204. while ( ( elem = this[ i++ ] ) ) {
  7205. curValue = getClass( elem );
  7206. cur = elem.nodeType === 1 &&
  7207. ( " " + curValue + " " ).replace( rclass, " " );
  7208. if ( cur ) {
  7209. j = 0;
  7210. while ( ( clazz = classes[ j++ ] ) ) {
  7211. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  7212. cur += clazz + " ";
  7213. }
  7214. }
  7215. // only assign if different to avoid unneeded rendering.
  7216. finalValue = jQuery.trim( cur );
  7217. if ( curValue !== finalValue ) {
  7218. jQuery.attr( elem, "class", finalValue );
  7219. }
  7220. }
  7221. }
  7222. }
  7223. return this;
  7224. },
  7225. removeClass: function( value ) {
  7226. var classes, elem, cur, curValue, clazz, j, finalValue,
  7227. i = 0;
  7228. if ( jQuery.isFunction( value ) ) {
  7229. return this.each( function( j ) {
  7230. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  7231. } );
  7232. }
  7233. if ( !arguments.length ) {
  7234. return this.attr( "class", "" );
  7235. }
  7236. if ( typeof value === "string" && value ) {
  7237. classes = value.match( rnotwhite ) || [];
  7238. while ( ( elem = this[ i++ ] ) ) {
  7239. curValue = getClass( elem );
  7240. // This expression is here for better compressibility (see addClass)
  7241. cur = elem.nodeType === 1 &&
  7242. ( " " + curValue + " " ).replace( rclass, " " );
  7243. if ( cur ) {
  7244. j = 0;
  7245. while ( ( clazz = classes[ j++ ] ) ) {
  7246. // Remove *all* instances
  7247. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  7248. cur = cur.replace( " " + clazz + " ", " " );
  7249. }
  7250. }
  7251. // Only assign if different to avoid unneeded rendering.
  7252. finalValue = jQuery.trim( cur );
  7253. if ( curValue !== finalValue ) {
  7254. jQuery.attr( elem, "class", finalValue );
  7255. }
  7256. }
  7257. }
  7258. }
  7259. return this;
  7260. },
  7261. toggleClass: function( value, stateVal ) {
  7262. var type = typeof value;
  7263. if ( typeof stateVal === "boolean" && type === "string" ) {
  7264. return stateVal ? this.addClass( value ) : this.removeClass( value );
  7265. }
  7266. if ( jQuery.isFunction( value ) ) {
  7267. return this.each( function( i ) {
  7268. jQuery( this ).toggleClass(
  7269. value.call( this, i, getClass( this ), stateVal ),
  7270. stateVal
  7271. );
  7272. } );
  7273. }
  7274. return this.each( function() {
  7275. var className, i, self, classNames;
  7276. if ( type === "string" ) {
  7277. // Toggle individual class names
  7278. i = 0;
  7279. self = jQuery( this );
  7280. classNames = value.match( rnotwhite ) || [];
  7281. while ( ( className = classNames[ i++ ] ) ) {
  7282. // Check each className given, space separated list
  7283. if ( self.hasClass( className ) ) {
  7284. self.removeClass( className );
  7285. } else {
  7286. self.addClass( className );
  7287. }
  7288. }
  7289. // Toggle whole class name
  7290. } else if ( value === undefined || type === "boolean" ) {
  7291. className = getClass( this );
  7292. if ( className ) {
  7293. // store className if set
  7294. jQuery._data( this, "__className__", className );
  7295. }
  7296. // If the element has a class name or if we're passed "false",
  7297. // then remove the whole classname (if there was one, the above saved it).
  7298. // Otherwise bring back whatever was previously saved (if anything),
  7299. // falling back to the empty string if nothing was stored.
  7300. jQuery.attr( this, "class",
  7301. className || value === false ?
  7302. "" :
  7303. jQuery._data( this, "__className__" ) || ""
  7304. );
  7305. }
  7306. } );
  7307. },
  7308. hasClass: function( selector ) {
  7309. var className, elem,
  7310. i = 0;
  7311. className = " " + selector + " ";
  7312. while ( ( elem = this[ i++ ] ) ) {
  7313. if ( elem.nodeType === 1 &&
  7314. ( " " + getClass( elem ) + " " ).replace( rclass, " " )
  7315. .indexOf( className ) > -1
  7316. ) {
  7317. return true;
  7318. }
  7319. }
  7320. return false;
  7321. }
  7322. } );
  7323. // Return jQuery for attributes-only inclusion
  7324. jQuery.each( ( "blur focus focusin focusout load resize scroll unload click dblclick " +
  7325. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  7326. "change select submit keydown keypress keyup error contextmenu" ).split( " " ),
  7327. function( i, name ) {
  7328. // Handle event binding
  7329. jQuery.fn[ name ] = function( data, fn ) {
  7330. return arguments.length > 0 ?
  7331. this.on( name, null, data, fn ) :
  7332. this.trigger( name );
  7333. };
  7334. } );
  7335. jQuery.fn.extend( {
  7336. hover: function( fnOver, fnOut ) {
  7337. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  7338. }
  7339. } );
  7340. var location = window.location;
  7341. var nonce = jQuery.now();
  7342. var rquery = ( /\?/ );
  7343. var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
  7344. jQuery.parseJSON = function( data ) {
  7345. // Attempt to parse using the native JSON parser first
  7346. if ( window.JSON && window.JSON.parse ) {
  7347. // Support: Android 2.3
  7348. // Workaround failure to string-cast null input
  7349. return window.JSON.parse( data + "" );
  7350. }
  7351. var requireNonComma,
  7352. depth = null,
  7353. str = jQuery.trim( data + "" );
  7354. // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
  7355. // after removing valid tokens
  7356. return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) {
  7357. // Force termination if we see a misplaced comma
  7358. if ( requireNonComma && comma ) {
  7359. depth = 0;
  7360. }
  7361. // Perform no more replacements after returning to outermost depth
  7362. if ( depth === 0 ) {
  7363. return token;
  7364. }
  7365. // Commas must not follow "[", "{", or ","
  7366. requireNonComma = open || comma;
  7367. // Determine new depth
  7368. // array/object open ("[" or "{"): depth += true - false (increment)
  7369. // array/object close ("]" or "}"): depth += false - true (decrement)
  7370. // other cases ("," or primitive): depth += true - true (numeric cast)
  7371. depth += !close - !open;
  7372. // Remove this token
  7373. return "";
  7374. } ) ) ?
  7375. ( Function( "return " + str ) )() :
  7376. jQuery.error( "Invalid JSON: " + data );
  7377. };
  7378. // Cross-browser xml parsing
  7379. jQuery.parseXML = function( data ) {
  7380. var xml, tmp;
  7381. if ( !data || typeof data !== "string" ) {
  7382. return null;
  7383. }
  7384. try {
  7385. if ( window.DOMParser ) { // Standard
  7386. tmp = new window.DOMParser();
  7387. xml = tmp.parseFromString( data, "text/xml" );
  7388. } else { // IE
  7389. xml = new window.ActiveXObject( "Microsoft.XMLDOM" );
  7390. xml.async = "false";
  7391. xml.loadXML( data );
  7392. }
  7393. } catch ( e ) {
  7394. xml = undefined;
  7395. }
  7396. if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
  7397. jQuery.error( "Invalid XML: " + data );
  7398. }
  7399. return xml;
  7400. };
  7401. var
  7402. rhash = /#.*$/,
  7403. rts = /([?&])_=[^&]*/,
  7404. // IE leaves an \r character at EOL
  7405. rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg,
  7406. // #7653, #8125, #8152: local protocol detection
  7407. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  7408. rnoContent = /^(?:GET|HEAD)$/,
  7409. rprotocol = /^\/\//,
  7410. rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
  7411. /* Prefilters
  7412. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  7413. * 2) These are called:
  7414. * - BEFORE asking for a transport
  7415. * - AFTER param serialization (s.data is a string if s.processData is true)
  7416. * 3) key is the dataType
  7417. * 4) the catchall symbol "*" can be used
  7418. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  7419. */
  7420. prefilters = {},
  7421. /* Transports bindings
  7422. * 1) key is the dataType
  7423. * 2) the catchall symbol "*" can be used
  7424. * 3) selection will start with transport dataType and THEN go to "*" if needed
  7425. */
  7426. transports = {},
  7427. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  7428. allTypes = "*/".concat( "*" ),
  7429. // Document location
  7430. ajaxLocation = location.href,
  7431. // Segment location into parts
  7432. ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
  7433. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  7434. function addToPrefiltersOrTransports( structure ) {
  7435. // dataTypeExpression is optional and defaults to "*"
  7436. return function( dataTypeExpression, func ) {
  7437. if ( typeof dataTypeExpression !== "string" ) {
  7438. func = dataTypeExpression;
  7439. dataTypeExpression = "*";
  7440. }
  7441. var dataType,
  7442. i = 0,
  7443. dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
  7444. if ( jQuery.isFunction( func ) ) {
  7445. // For each dataType in the dataTypeExpression
  7446. while ( ( dataType = dataTypes[ i++ ] ) ) {
  7447. // Prepend if requested
  7448. if ( dataType.charAt( 0 ) === "+" ) {
  7449. dataType = dataType.slice( 1 ) || "*";
  7450. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  7451. // Otherwise append
  7452. } else {
  7453. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  7454. }
  7455. }
  7456. }
  7457. };
  7458. }
  7459. // Base inspection function for prefilters and transports
  7460. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  7461. var inspected = {},
  7462. seekingTransport = ( structure === transports );
  7463. function inspect( dataType ) {
  7464. var selected;
  7465. inspected[ dataType ] = true;
  7466. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  7467. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  7468. if ( typeof dataTypeOrTransport === "string" &&
  7469. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  7470. options.dataTypes.unshift( dataTypeOrTransport );
  7471. inspect( dataTypeOrTransport );
  7472. return false;
  7473. } else if ( seekingTransport ) {
  7474. return !( selected = dataTypeOrTransport );
  7475. }
  7476. } );
  7477. return selected;
  7478. }
  7479. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  7480. }
  7481. // A special extend for ajax options
  7482. // that takes "flat" options (not to be deep extended)
  7483. // Fixes #9887
  7484. function ajaxExtend( target, src ) {
  7485. var deep, key,
  7486. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  7487. for ( key in src ) {
  7488. if ( src[ key ] !== undefined ) {
  7489. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  7490. }
  7491. }
  7492. if ( deep ) {
  7493. jQuery.extend( true, target, deep );
  7494. }
  7495. return target;
  7496. }
  7497. /* Handles responses to an ajax request:
  7498. * - finds the right dataType (mediates between content-type and expected dataType)
  7499. * - returns the corresponding response
  7500. */
  7501. function ajaxHandleResponses( s, jqXHR, responses ) {
  7502. var firstDataType, ct, finalDataType, type,
  7503. contents = s.contents,
  7504. dataTypes = s.dataTypes;
  7505. // Remove auto dataType and get content-type in the process
  7506. while ( dataTypes[ 0 ] === "*" ) {
  7507. dataTypes.shift();
  7508. if ( ct === undefined ) {
  7509. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  7510. }
  7511. }
  7512. // Check if we're dealing with a known content-type
  7513. if ( ct ) {
  7514. for ( type in contents ) {
  7515. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  7516. dataTypes.unshift( type );
  7517. break;
  7518. }
  7519. }
  7520. }
  7521. // Check to see if we have a response for the expected dataType
  7522. if ( dataTypes[ 0 ] in responses ) {
  7523. finalDataType = dataTypes[ 0 ];
  7524. } else {
  7525. // Try convertible dataTypes
  7526. for ( type in responses ) {
  7527. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  7528. finalDataType = type;
  7529. break;
  7530. }
  7531. if ( !firstDataType ) {
  7532. firstDataType = type;
  7533. }
  7534. }
  7535. // Or just use first one
  7536. finalDataType = finalDataType || firstDataType;
  7537. }
  7538. // If we found a dataType
  7539. // We add the dataType to the list if needed
  7540. // and return the corresponding response
  7541. if ( finalDataType ) {
  7542. if ( finalDataType !== dataTypes[ 0 ] ) {
  7543. dataTypes.unshift( finalDataType );
  7544. }
  7545. return responses[ finalDataType ];
  7546. }
  7547. }
  7548. /* Chain conversions given the request and the original response
  7549. * Also sets the responseXXX fields on the jqXHR instance
  7550. */
  7551. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  7552. var conv2, current, conv, tmp, prev,
  7553. converters = {},
  7554. // Work with a copy of dataTypes in case we need to modify it for conversion
  7555. dataTypes = s.dataTypes.slice();
  7556. // Create converters map with lowercased keys
  7557. if ( dataTypes[ 1 ] ) {
  7558. for ( conv in s.converters ) {
  7559. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  7560. }
  7561. }
  7562. current = dataTypes.shift();
  7563. // Convert to each sequential dataType
  7564. while ( current ) {
  7565. if ( s.responseFields[ current ] ) {
  7566. jqXHR[ s.responseFields[ current ] ] = response;
  7567. }
  7568. // Apply the dataFilter if provided
  7569. if ( !prev && isSuccess && s.dataFilter ) {
  7570. response = s.dataFilter( response, s.dataType );
  7571. }
  7572. prev = current;
  7573. current = dataTypes.shift();
  7574. if ( current ) {
  7575. // There's only work to do if current dataType is non-auto
  7576. if ( current === "*" ) {
  7577. current = prev;
  7578. // Convert response if prev dataType is non-auto and differs from current
  7579. } else if ( prev !== "*" && prev !== current ) {
  7580. // Seek a direct converter
  7581. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  7582. // If none found, seek a pair
  7583. if ( !conv ) {
  7584. for ( conv2 in converters ) {
  7585. // If conv2 outputs current
  7586. tmp = conv2.split( " " );
  7587. if ( tmp[ 1 ] === current ) {
  7588. // If prev can be converted to accepted input
  7589. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  7590. converters[ "* " + tmp[ 0 ] ];
  7591. if ( conv ) {
  7592. // Condense equivalence converters
  7593. if ( conv === true ) {
  7594. conv = converters[ conv2 ];
  7595. // Otherwise, insert the intermediate dataType
  7596. } else if ( converters[ conv2 ] !== true ) {
  7597. current = tmp[ 0 ];
  7598. dataTypes.unshift( tmp[ 1 ] );
  7599. }
  7600. break;
  7601. }
  7602. }
  7603. }
  7604. }
  7605. // Apply converter (if not an equivalence)
  7606. if ( conv !== true ) {
  7607. // Unless errors are allowed to bubble, catch and return them
  7608. if ( conv && s[ "throws" ] ) { // jscs:ignore requireDotNotation
  7609. response = conv( response );
  7610. } else {
  7611. try {
  7612. response = conv( response );
  7613. } catch ( e ) {
  7614. return {
  7615. state: "parsererror",
  7616. error: conv ? e : "No conversion from " + prev + " to " + current
  7617. };
  7618. }
  7619. }
  7620. }
  7621. }
  7622. }
  7623. }
  7624. return { state: "success", data: response };
  7625. }
  7626. jQuery.extend( {
  7627. // Counter for holding the number of active queries
  7628. active: 0,
  7629. // Last-Modified header cache for next request
  7630. lastModified: {},
  7631. etag: {},
  7632. ajaxSettings: {
  7633. url: ajaxLocation,
  7634. type: "GET",
  7635. isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
  7636. global: true,
  7637. processData: true,
  7638. async: true,
  7639. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  7640. /*
  7641. timeout: 0,
  7642. data: null,
  7643. dataType: null,
  7644. username: null,
  7645. password: null,
  7646. cache: null,
  7647. throws: false,
  7648. traditional: false,
  7649. headers: {},
  7650. */
  7651. accepts: {
  7652. "*": allTypes,
  7653. text: "text/plain",
  7654. html: "text/html",
  7655. xml: "application/xml, text/xml",
  7656. json: "application/json, text/javascript"
  7657. },
  7658. contents: {
  7659. xml: /\bxml\b/,
  7660. html: /\bhtml/,
  7661. json: /\bjson\b/
  7662. },
  7663. responseFields: {
  7664. xml: "responseXML",
  7665. text: "responseText",
  7666. json: "responseJSON"
  7667. },
  7668. // Data converters
  7669. // Keys separate source (or catchall "*") and destination types with a single space
  7670. converters: {
  7671. // Convert anything to text
  7672. "* text": String,
  7673. // Text to html (true = no transformation)
  7674. "text html": true,
  7675. // Evaluate text as a json expression
  7676. "text json": jQuery.parseJSON,
  7677. // Parse text as xml
  7678. "text xml": jQuery.parseXML
  7679. },
  7680. // For options that shouldn't be deep extended:
  7681. // you can add your own custom options here if
  7682. // and when you create one that shouldn't be
  7683. // deep extended (see ajaxExtend)
  7684. flatOptions: {
  7685. url: true,
  7686. context: true
  7687. }
  7688. },
  7689. // Creates a full fledged settings object into target
  7690. // with both ajaxSettings and settings fields.
  7691. // If target is omitted, writes into ajaxSettings.
  7692. ajaxSetup: function( target, settings ) {
  7693. return settings ?
  7694. // Building a settings object
  7695. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  7696. // Extending ajaxSettings
  7697. ajaxExtend( jQuery.ajaxSettings, target );
  7698. },
  7699. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  7700. ajaxTransport: addToPrefiltersOrTransports( transports ),
  7701. // Main method
  7702. ajax: function( url, options ) {
  7703. // If url is an object, simulate pre-1.5 signature
  7704. if ( typeof url === "object" ) {
  7705. options = url;
  7706. url = undefined;
  7707. }
  7708. // Force options to be an object
  7709. options = options || {};
  7710. var
  7711. // Cross-domain detection vars
  7712. parts,
  7713. // Loop variable
  7714. i,
  7715. // URL without anti-cache param
  7716. cacheURL,
  7717. // Response headers as string
  7718. responseHeadersString,
  7719. // timeout handle
  7720. timeoutTimer,
  7721. // To know if global events are to be dispatched
  7722. fireGlobals,
  7723. transport,
  7724. // Response headers
  7725. responseHeaders,
  7726. // Create the final options object
  7727. s = jQuery.ajaxSetup( {}, options ),
  7728. // Callbacks context
  7729. callbackContext = s.context || s,
  7730. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  7731. globalEventContext = s.context &&
  7732. ( callbackContext.nodeType || callbackContext.jquery ) ?
  7733. jQuery( callbackContext ) :
  7734. jQuery.event,
  7735. // Deferreds
  7736. deferred = jQuery.Deferred(),
  7737. completeDeferred = jQuery.Callbacks( "once memory" ),
  7738. // Status-dependent callbacks
  7739. statusCode = s.statusCode || {},
  7740. // Headers (they are sent all at once)
  7741. requestHeaders = {},
  7742. requestHeadersNames = {},
  7743. // The jqXHR state
  7744. state = 0,
  7745. // Default abort message
  7746. strAbort = "canceled",
  7747. // Fake xhr
  7748. jqXHR = {
  7749. readyState: 0,
  7750. // Builds headers hashtable if needed
  7751. getResponseHeader: function( key ) {
  7752. var match;
  7753. if ( state === 2 ) {
  7754. if ( !responseHeaders ) {
  7755. responseHeaders = {};
  7756. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  7757. responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ];
  7758. }
  7759. }
  7760. match = responseHeaders[ key.toLowerCase() ];
  7761. }
  7762. return match == null ? null : match;
  7763. },
  7764. // Raw string
  7765. getAllResponseHeaders: function() {
  7766. return state === 2 ? responseHeadersString : null;
  7767. },
  7768. // Caches the header
  7769. setRequestHeader: function( name, value ) {
  7770. var lname = name.toLowerCase();
  7771. if ( !state ) {
  7772. name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
  7773. requestHeaders[ name ] = value;
  7774. }
  7775. return this;
  7776. },
  7777. // Overrides response content-type header
  7778. overrideMimeType: function( type ) {
  7779. if ( !state ) {
  7780. s.mimeType = type;
  7781. }
  7782. return this;
  7783. },
  7784. // Status-dependent callbacks
  7785. statusCode: function( map ) {
  7786. var code;
  7787. if ( map ) {
  7788. if ( state < 2 ) {
  7789. for ( code in map ) {
  7790. // Lazy-add the new callback in a way that preserves old ones
  7791. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  7792. }
  7793. } else {
  7794. // Execute the appropriate callbacks
  7795. jqXHR.always( map[ jqXHR.status ] );
  7796. }
  7797. }
  7798. return this;
  7799. },
  7800. // Cancel the request
  7801. abort: function( statusText ) {
  7802. var finalText = statusText || strAbort;
  7803. if ( transport ) {
  7804. transport.abort( finalText );
  7805. }
  7806. done( 0, finalText );
  7807. return this;
  7808. }
  7809. };
  7810. // Attach deferreds
  7811. deferred.promise( jqXHR ).complete = completeDeferred.add;
  7812. jqXHR.success = jqXHR.done;
  7813. jqXHR.error = jqXHR.fail;
  7814. // Remove hash character (#7531: and string promotion)
  7815. // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
  7816. // Handle falsy url in the settings object (#10093: consistency with old signature)
  7817. // We also use the url parameter if available
  7818. s.url = ( ( url || s.url || ajaxLocation ) + "" )
  7819. .replace( rhash, "" )
  7820. .replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
  7821. // Alias method option to type as per ticket #12004
  7822. s.type = options.method || options.type || s.method || s.type;
  7823. // Extract dataTypes list
  7824. s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
  7825. // A cross-domain request is in order when we have a protocol:host:port mismatch
  7826. if ( s.crossDomain == null ) {
  7827. parts = rurl.exec( s.url.toLowerCase() );
  7828. s.crossDomain = !!( parts &&
  7829. ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
  7830. ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
  7831. ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
  7832. );
  7833. }
  7834. // Convert data if not already a string
  7835. if ( s.data && s.processData && typeof s.data !== "string" ) {
  7836. s.data = jQuery.param( s.data, s.traditional );
  7837. }
  7838. // Apply prefilters
  7839. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  7840. // If request was aborted inside a prefilter, stop there
  7841. if ( state === 2 ) {
  7842. return jqXHR;
  7843. }
  7844. // We can fire global events as of now if asked to
  7845. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  7846. fireGlobals = jQuery.event && s.global;
  7847. // Watch for a new set of requests
  7848. if ( fireGlobals && jQuery.active++ === 0 ) {
  7849. jQuery.event.trigger( "ajaxStart" );
  7850. }
  7851. // Uppercase the type
  7852. s.type = s.type.toUpperCase();
  7853. // Determine if request has content
  7854. s.hasContent = !rnoContent.test( s.type );
  7855. // Save the URL in case we're toying with the If-Modified-Since
  7856. // and/or If-None-Match header later on
  7857. cacheURL = s.url;
  7858. // More options handling for requests with no content
  7859. if ( !s.hasContent ) {
  7860. // If data is available, append data to url
  7861. if ( s.data ) {
  7862. cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
  7863. // #9682: remove data so that it's not used in an eventual retry
  7864. delete s.data;
  7865. }
  7866. // Add anti-cache in url if needed
  7867. if ( s.cache === false ) {
  7868. s.url = rts.test( cacheURL ) ?
  7869. // If there is already a '_' parameter, set its value
  7870. cacheURL.replace( rts, "$1_=" + nonce++ ) :
  7871. // Otherwise add one to the end
  7872. cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
  7873. }
  7874. }
  7875. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  7876. if ( s.ifModified ) {
  7877. if ( jQuery.lastModified[ cacheURL ] ) {
  7878. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  7879. }
  7880. if ( jQuery.etag[ cacheURL ] ) {
  7881. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  7882. }
  7883. }
  7884. // Set the correct header, if data is being sent
  7885. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  7886. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  7887. }
  7888. // Set the Accepts header for the server, depending on the dataType
  7889. jqXHR.setRequestHeader(
  7890. "Accept",
  7891. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  7892. s.accepts[ s.dataTypes[ 0 ] ] +
  7893. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  7894. s.accepts[ "*" ]
  7895. );
  7896. // Check for headers option
  7897. for ( i in s.headers ) {
  7898. jqXHR.setRequestHeader( i, s.headers[ i ] );
  7899. }
  7900. // Allow custom headers/mimetypes and early abort
  7901. if ( s.beforeSend &&
  7902. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
  7903. // Abort if not done already and return
  7904. return jqXHR.abort();
  7905. }
  7906. // aborting is no longer a cancellation
  7907. strAbort = "abort";
  7908. // Install callbacks on deferreds
  7909. for ( i in { success: 1, error: 1, complete: 1 } ) {
  7910. jqXHR[ i ]( s[ i ] );
  7911. }
  7912. // Get transport
  7913. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  7914. // If no transport, we auto-abort
  7915. if ( !transport ) {
  7916. done( -1, "No Transport" );
  7917. } else {
  7918. jqXHR.readyState = 1;
  7919. // Send global event
  7920. if ( fireGlobals ) {
  7921. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  7922. }
  7923. // If request was aborted inside ajaxSend, stop there
  7924. if ( state === 2 ) {
  7925. return jqXHR;
  7926. }
  7927. // Timeout
  7928. if ( s.async && s.timeout > 0 ) {
  7929. timeoutTimer = window.setTimeout( function() {
  7930. jqXHR.abort( "timeout" );
  7931. }, s.timeout );
  7932. }
  7933. try {
  7934. state = 1;
  7935. transport.send( requestHeaders, done );
  7936. } catch ( e ) {
  7937. // Propagate exception as error if not done
  7938. if ( state < 2 ) {
  7939. done( -1, e );
  7940. // Simply rethrow otherwise
  7941. } else {
  7942. throw e;
  7943. }
  7944. }
  7945. }
  7946. // Callback for when everything is done
  7947. function done( status, nativeStatusText, responses, headers ) {
  7948. var isSuccess, success, error, response, modified,
  7949. statusText = nativeStatusText;
  7950. // Called once
  7951. if ( state === 2 ) {
  7952. return;
  7953. }
  7954. // State is "done" now
  7955. state = 2;
  7956. // Clear timeout if it exists
  7957. if ( timeoutTimer ) {
  7958. window.clearTimeout( timeoutTimer );
  7959. }
  7960. // Dereference transport for early garbage collection
  7961. // (no matter how long the jqXHR object will be used)
  7962. transport = undefined;
  7963. // Cache response headers
  7964. responseHeadersString = headers || "";
  7965. // Set readyState
  7966. jqXHR.readyState = status > 0 ? 4 : 0;
  7967. // Determine if successful
  7968. isSuccess = status >= 200 && status < 300 || status === 304;
  7969. // Get response data
  7970. if ( responses ) {
  7971. response = ajaxHandleResponses( s, jqXHR, responses );
  7972. }
  7973. // Convert no matter what (that way responseXXX fields are always set)
  7974. response = ajaxConvert( s, response, jqXHR, isSuccess );
  7975. // If successful, handle type chaining
  7976. if ( isSuccess ) {
  7977. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  7978. if ( s.ifModified ) {
  7979. modified = jqXHR.getResponseHeader( "Last-Modified" );
  7980. if ( modified ) {
  7981. jQuery.lastModified[ cacheURL ] = modified;
  7982. }
  7983. modified = jqXHR.getResponseHeader( "etag" );
  7984. if ( modified ) {
  7985. jQuery.etag[ cacheURL ] = modified;
  7986. }
  7987. }
  7988. // if no content
  7989. if ( status === 204 || s.type === "HEAD" ) {
  7990. statusText = "nocontent";
  7991. // if not modified
  7992. } else if ( status === 304 ) {
  7993. statusText = "notmodified";
  7994. // If we have data, let's convert it
  7995. } else {
  7996. statusText = response.state;
  7997. success = response.data;
  7998. error = response.error;
  7999. isSuccess = !error;
  8000. }
  8001. } else {
  8002. // We extract error from statusText
  8003. // then normalize statusText and status for non-aborts
  8004. error = statusText;
  8005. if ( status || !statusText ) {
  8006. statusText = "error";
  8007. if ( status < 0 ) {
  8008. status = 0;
  8009. }
  8010. }
  8011. }
  8012. // Set data for the fake xhr object
  8013. jqXHR.status = status;
  8014. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  8015. // Success/Error
  8016. if ( isSuccess ) {
  8017. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  8018. } else {
  8019. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  8020. }
  8021. // Status-dependent callbacks
  8022. jqXHR.statusCode( statusCode );
  8023. statusCode = undefined;
  8024. if ( fireGlobals ) {
  8025. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  8026. [ jqXHR, s, isSuccess ? success : error ] );
  8027. }
  8028. // Complete
  8029. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  8030. if ( fireGlobals ) {
  8031. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  8032. // Handle the global AJAX counter
  8033. if ( !( --jQuery.active ) ) {
  8034. jQuery.event.trigger( "ajaxStop" );
  8035. }
  8036. }
  8037. }
  8038. return jqXHR;
  8039. },
  8040. getJSON: function( url, data, callback ) {
  8041. return jQuery.get( url, data, callback, "json" );
  8042. },
  8043. getScript: function( url, callback ) {
  8044. return jQuery.get( url, undefined, callback, "script" );
  8045. }
  8046. } );
  8047. jQuery.each( [ "get", "post" ], function( i, method ) {
  8048. jQuery[ method ] = function( url, data, callback, type ) {
  8049. // shift arguments if data argument was omitted
  8050. if ( jQuery.isFunction( data ) ) {
  8051. type = type || callback;
  8052. callback = data;
  8053. data = undefined;
  8054. }
  8055. // The url can be an options object (which then must have .url)
  8056. return jQuery.ajax( jQuery.extend( {
  8057. url: url,
  8058. type: method,
  8059. dataType: type,
  8060. data: data,
  8061. success: callback
  8062. }, jQuery.isPlainObject( url ) && url ) );
  8063. };
  8064. } );
  8065. jQuery._evalUrl = function( url ) {
  8066. return jQuery.ajax( {
  8067. url: url,
  8068. // Make this explicit, since user can override this through ajaxSetup (#11264)
  8069. type: "GET",
  8070. dataType: "script",
  8071. cache: true,
  8072. async: false,
  8073. global: false,
  8074. "throws": true
  8075. } );
  8076. };
  8077. jQuery.fn.extend( {
  8078. wrapAll: function( html ) {
  8079. if ( jQuery.isFunction( html ) ) {
  8080. return this.each( function( i ) {
  8081. jQuery( this ).wrapAll( html.call( this, i ) );
  8082. } );
  8083. }
  8084. if ( this[ 0 ] ) {
  8085. // The elements to wrap the target around
  8086. var wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  8087. if ( this[ 0 ].parentNode ) {
  8088. wrap.insertBefore( this[ 0 ] );
  8089. }
  8090. wrap.map( function() {
  8091. var elem = this;
  8092. while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
  8093. elem = elem.firstChild;
  8094. }
  8095. return elem;
  8096. } ).append( this );
  8097. }
  8098. return this;
  8099. },
  8100. wrapInner: function( html ) {
  8101. if ( jQuery.isFunction( html ) ) {
  8102. return this.each( function( i ) {
  8103. jQuery( this ).wrapInner( html.call( this, i ) );
  8104. } );
  8105. }
  8106. return this.each( function() {
  8107. var self = jQuery( this ),
  8108. contents = self.contents();
  8109. if ( contents.length ) {
  8110. contents.wrapAll( html );
  8111. } else {
  8112. self.append( html );
  8113. }
  8114. } );
  8115. },
  8116. wrap: function( html ) {
  8117. var isFunction = jQuery.isFunction( html );
  8118. return this.each( function( i ) {
  8119. jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );
  8120. } );
  8121. },
  8122. unwrap: function() {
  8123. return this.parent().each( function() {
  8124. if ( !jQuery.nodeName( this, "body" ) ) {
  8125. jQuery( this ).replaceWith( this.childNodes );
  8126. }
  8127. } ).end();
  8128. }
  8129. } );
  8130. function getDisplay( elem ) {
  8131. return elem.style && elem.style.display || jQuery.css( elem, "display" );
  8132. }
  8133. function filterHidden( elem ) {
  8134. // Disconnected elements are considered hidden
  8135. if ( !jQuery.contains( elem.ownerDocument || document, elem ) ) {
  8136. return true;
  8137. }
  8138. while ( elem && elem.nodeType === 1 ) {
  8139. if ( getDisplay( elem ) === "none" || elem.type === "hidden" ) {
  8140. return true;
  8141. }
  8142. elem = elem.parentNode;
  8143. }
  8144. return false;
  8145. }
  8146. jQuery.expr.filters.hidden = function( elem ) {
  8147. // Support: Opera <= 12.12
  8148. // Opera reports offsetWidths and offsetHeights less than zero on some elements
  8149. return support.reliableHiddenOffsets() ?
  8150. ( elem.offsetWidth <= 0 && elem.offsetHeight <= 0 &&
  8151. !elem.getClientRects().length ) :
  8152. filterHidden( elem );
  8153. };
  8154. jQuery.expr.filters.visible = function( elem ) {
  8155. return !jQuery.expr.filters.hidden( elem );
  8156. };
  8157. var r20 = /%20/g,
  8158. rbracket = /\[\]$/,
  8159. rCRLF = /\r?\n/g,
  8160. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  8161. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  8162. function buildParams( prefix, obj, traditional, add ) {
  8163. var name;
  8164. if ( jQuery.isArray( obj ) ) {
  8165. // Serialize array item.
  8166. jQuery.each( obj, function( i, v ) {
  8167. if ( traditional || rbracket.test( prefix ) ) {
  8168. // Treat each array item as a scalar.
  8169. add( prefix, v );
  8170. } else {
  8171. // Item is non-scalar (array or object), encode its numeric index.
  8172. buildParams(
  8173. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  8174. v,
  8175. traditional,
  8176. add
  8177. );
  8178. }
  8179. } );
  8180. } else if ( !traditional && jQuery.type( obj ) === "object" ) {
  8181. // Serialize object item.
  8182. for ( name in obj ) {
  8183. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  8184. }
  8185. } else {
  8186. // Serialize scalar item.
  8187. add( prefix, obj );
  8188. }
  8189. }
  8190. // Serialize an array of form elements or a set of
  8191. // key/values into a query string
  8192. jQuery.param = function( a, traditional ) {
  8193. var prefix,
  8194. s = [],
  8195. add = function( key, value ) {
  8196. // If value is a function, invoke it and return its value
  8197. value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
  8198. s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
  8199. };
  8200. // Set traditional to true for jQuery <= 1.3.2 behavior.
  8201. if ( traditional === undefined ) {
  8202. traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
  8203. }
  8204. // If an array was passed in, assume that it is an array of form elements.
  8205. if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  8206. // Serialize the form elements
  8207. jQuery.each( a, function() {
  8208. add( this.name, this.value );
  8209. } );
  8210. } else {
  8211. // If traditional, encode the "old" way (the way 1.3.2 or older
  8212. // did it), otherwise encode params recursively.
  8213. for ( prefix in a ) {
  8214. buildParams( prefix, a[ prefix ], traditional, add );
  8215. }
  8216. }
  8217. // Return the resulting serialization
  8218. return s.join( "&" ).replace( r20, "+" );
  8219. };
  8220. jQuery.fn.extend( {
  8221. serialize: function() {
  8222. return jQuery.param( this.serializeArray() );
  8223. },
  8224. serializeArray: function() {
  8225. return this.map( function() {
  8226. // Can add propHook for "elements" to filter or add form elements
  8227. var elements = jQuery.prop( this, "elements" );
  8228. return elements ? jQuery.makeArray( elements ) : this;
  8229. } )
  8230. .filter( function() {
  8231. var type = this.type;
  8232. // Use .is(":disabled") so that fieldset[disabled] works
  8233. return this.name && !jQuery( this ).is( ":disabled" ) &&
  8234. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  8235. ( this.checked || !rcheckableType.test( type ) );
  8236. } )
  8237. .map( function( i, elem ) {
  8238. var val = jQuery( this ).val();
  8239. return val == null ?
  8240. null :
  8241. jQuery.isArray( val ) ?
  8242. jQuery.map( val, function( val ) {
  8243. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  8244. } ) :
  8245. { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  8246. } ).get();
  8247. }
  8248. } );
  8249. // Create the request object
  8250. // (This is still attached to ajaxSettings for backward compatibility)
  8251. jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
  8252. // Support: IE6-IE8
  8253. function() {
  8254. // XHR cannot access local files, always use ActiveX for that case
  8255. if ( this.isLocal ) {
  8256. return createActiveXHR();
  8257. }
  8258. // Support: IE 9-11
  8259. // IE seems to error on cross-domain PATCH requests when ActiveX XHR
  8260. // is used. In IE 9+ always use the native XHR.
  8261. // Note: this condition won't catch Edge as it doesn't define
  8262. // document.documentMode but it also doesn't support ActiveX so it won't
  8263. // reach this code.
  8264. if ( document.documentMode > 8 ) {
  8265. return createStandardXHR();
  8266. }
  8267. // Support: IE<9
  8268. // oldIE XHR does not support non-RFC2616 methods (#13240)
  8269. // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
  8270. // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
  8271. // Although this check for six methods instead of eight
  8272. // since IE also does not support "trace" and "connect"
  8273. return /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
  8274. createStandardXHR() || createActiveXHR();
  8275. } :
  8276. // For all other browsers, use the standard XMLHttpRequest object
  8277. createStandardXHR;
  8278. var xhrId = 0,
  8279. xhrCallbacks = {},
  8280. xhrSupported = jQuery.ajaxSettings.xhr();
  8281. // Support: IE<10
  8282. // Open requests must be manually aborted on unload (#5280)
  8283. // See https://support.microsoft.com/kb/2856746 for more info
  8284. if ( window.attachEvent ) {
  8285. window.attachEvent( "onunload", function() {
  8286. for ( var key in xhrCallbacks ) {
  8287. xhrCallbacks[ key ]( undefined, true );
  8288. }
  8289. } );
  8290. }
  8291. // Determine support properties
  8292. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  8293. xhrSupported = support.ajax = !!xhrSupported;
  8294. // Create transport if the browser can provide an xhr
  8295. if ( xhrSupported ) {
  8296. jQuery.ajaxTransport( function( options ) {
  8297. // Cross domain only allowed if supported through XMLHttpRequest
  8298. if ( !options.crossDomain || support.cors ) {
  8299. var callback;
  8300. return {
  8301. send: function( headers, complete ) {
  8302. var i,
  8303. xhr = options.xhr(),
  8304. id = ++xhrId;
  8305. // Open the socket
  8306. xhr.open(
  8307. options.type,
  8308. options.url,
  8309. options.async,
  8310. options.username,
  8311. options.password
  8312. );
  8313. // Apply custom fields if provided
  8314. if ( options.xhrFields ) {
  8315. for ( i in options.xhrFields ) {
  8316. xhr[ i ] = options.xhrFields[ i ];
  8317. }
  8318. }
  8319. // Override mime type if needed
  8320. if ( options.mimeType && xhr.overrideMimeType ) {
  8321. xhr.overrideMimeType( options.mimeType );
  8322. }
  8323. // X-Requested-With header
  8324. // For cross-domain requests, seeing as conditions for a preflight are
  8325. // akin to a jigsaw puzzle, we simply never set it to be sure.
  8326. // (it can always be set on a per-request basis or even using ajaxSetup)
  8327. // For same-domain requests, won't change header if already provided.
  8328. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  8329. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  8330. }
  8331. // Set headers
  8332. for ( i in headers ) {
  8333. // Support: IE<9
  8334. // IE's ActiveXObject throws a 'Type Mismatch' exception when setting
  8335. // request header to a null-value.
  8336. //
  8337. // To keep consistent with other XHR implementations, cast the value
  8338. // to string and ignore `undefined`.
  8339. if ( headers[ i ] !== undefined ) {
  8340. xhr.setRequestHeader( i, headers[ i ] + "" );
  8341. }
  8342. }
  8343. // Do send the request
  8344. // This may raise an exception which is actually
  8345. // handled in jQuery.ajax (so no try/catch here)
  8346. xhr.send( ( options.hasContent && options.data ) || null );
  8347. // Listener
  8348. callback = function( _, isAbort ) {
  8349. var status, statusText, responses;
  8350. // Was never called and is aborted or complete
  8351. if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
  8352. // Clean up
  8353. delete xhrCallbacks[ id ];
  8354. callback = undefined;
  8355. xhr.onreadystatechange = jQuery.noop;
  8356. // Abort manually if needed
  8357. if ( isAbort ) {
  8358. if ( xhr.readyState !== 4 ) {
  8359. xhr.abort();
  8360. }
  8361. } else {
  8362. responses = {};
  8363. status = xhr.status;
  8364. // Support: IE<10
  8365. // Accessing binary-data responseText throws an exception
  8366. // (#11426)
  8367. if ( typeof xhr.responseText === "string" ) {
  8368. responses.text = xhr.responseText;
  8369. }
  8370. // Firefox throws an exception when accessing
  8371. // statusText for faulty cross-domain requests
  8372. try {
  8373. statusText = xhr.statusText;
  8374. } catch ( e ) {
  8375. // We normalize with Webkit giving an empty statusText
  8376. statusText = "";
  8377. }
  8378. // Filter status for non standard behaviors
  8379. // If the request is local and we have data: assume a success
  8380. // (success with no data won't get notified, that's the best we
  8381. // can do given current implementations)
  8382. if ( !status && options.isLocal && !options.crossDomain ) {
  8383. status = responses.text ? 200 : 404;
  8384. // IE - #1450: sometimes returns 1223 when it should be 204
  8385. } else if ( status === 1223 ) {
  8386. status = 204;
  8387. }
  8388. }
  8389. }
  8390. // Call complete if needed
  8391. if ( responses ) {
  8392. complete( status, statusText, responses, xhr.getAllResponseHeaders() );
  8393. }
  8394. };
  8395. // Do send the request
  8396. // `xhr.send` may raise an exception, but it will be
  8397. // handled in jQuery.ajax (so no try/catch here)
  8398. if ( !options.async ) {
  8399. // If we're in sync mode we fire the callback
  8400. callback();
  8401. } else if ( xhr.readyState === 4 ) {
  8402. // (IE6 & IE7) if it's in cache and has been
  8403. // retrieved directly we need to fire the callback
  8404. window.setTimeout( callback );
  8405. } else {
  8406. // Register the callback, but delay it in case `xhr.send` throws
  8407. // Add to the list of active xhr callbacks
  8408. xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
  8409. }
  8410. },
  8411. abort: function() {
  8412. if ( callback ) {
  8413. callback( undefined, true );
  8414. }
  8415. }
  8416. };
  8417. }
  8418. } );
  8419. }
  8420. // Functions to create xhrs
  8421. function createStandardXHR() {
  8422. try {
  8423. return new window.XMLHttpRequest();
  8424. } catch ( e ) {}
  8425. }
  8426. function createActiveXHR() {
  8427. try {
  8428. return new window.ActiveXObject( "Microsoft.XMLHTTP" );
  8429. } catch ( e ) {}
  8430. }
  8431. // Install script dataType
  8432. jQuery.ajaxSetup( {
  8433. accepts: {
  8434. script: "text/javascript, application/javascript, " +
  8435. "application/ecmascript, application/x-ecmascript"
  8436. },
  8437. contents: {
  8438. script: /\b(?:java|ecma)script\b/
  8439. },
  8440. converters: {
  8441. "text script": function( text ) {
  8442. jQuery.globalEval( text );
  8443. return text;
  8444. }
  8445. }
  8446. } );
  8447. // Handle cache's special case and global
  8448. jQuery.ajaxPrefilter( "script", function( s ) {
  8449. if ( s.cache === undefined ) {
  8450. s.cache = false;
  8451. }
  8452. if ( s.crossDomain ) {
  8453. s.type = "GET";
  8454. s.global = false;
  8455. }
  8456. } );
  8457. // Bind script tag hack transport
  8458. jQuery.ajaxTransport( "script", function( s ) {
  8459. // This transport only deals with cross domain requests
  8460. if ( s.crossDomain ) {
  8461. var script,
  8462. head = document.head || jQuery( "head" )[ 0 ] || document.documentElement;
  8463. return {
  8464. send: function( _, callback ) {
  8465. script = document.createElement( "script" );
  8466. script.async = true;
  8467. if ( s.scriptCharset ) {
  8468. script.charset = s.scriptCharset;
  8469. }
  8470. script.src = s.url;
  8471. // Attach handlers for all browsers
  8472. script.onload = script.onreadystatechange = function( _, isAbort ) {
  8473. if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
  8474. // Handle memory leak in IE
  8475. script.onload = script.onreadystatechange = null;
  8476. // Remove the script
  8477. if ( script.parentNode ) {
  8478. script.parentNode.removeChild( script );
  8479. }
  8480. // Dereference the script
  8481. script = null;
  8482. // Callback if not abort
  8483. if ( !isAbort ) {
  8484. callback( 200, "success" );
  8485. }
  8486. }
  8487. };
  8488. // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
  8489. // Use native DOM manipulation to avoid our domManip AJAX trickery
  8490. head.insertBefore( script, head.firstChild );
  8491. },
  8492. abort: function() {
  8493. if ( script ) {
  8494. script.onload( undefined, true );
  8495. }
  8496. }
  8497. };
  8498. }
  8499. } );
  8500. var oldCallbacks = [],
  8501. rjsonp = /(=)\?(?=&|$)|\?\?/;
  8502. // Default jsonp settings
  8503. jQuery.ajaxSetup( {
  8504. jsonp: "callback",
  8505. jsonpCallback: function() {
  8506. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  8507. this[ callback ] = true;
  8508. return callback;
  8509. }
  8510. } );
  8511. // Detect, normalize options and install callbacks for jsonp requests
  8512. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  8513. var callbackName, overwritten, responseContainer,
  8514. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  8515. "url" :
  8516. typeof s.data === "string" &&
  8517. ( s.contentType || "" )
  8518. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  8519. rjsonp.test( s.data ) && "data"
  8520. );
  8521. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  8522. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  8523. // Get callback name, remembering preexisting value associated with it
  8524. callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
  8525. s.jsonpCallback() :
  8526. s.jsonpCallback;
  8527. // Insert callback into url or form data
  8528. if ( jsonProp ) {
  8529. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  8530. } else if ( s.jsonp !== false ) {
  8531. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  8532. }
  8533. // Use data converter to retrieve json after script execution
  8534. s.converters[ "script json" ] = function() {
  8535. if ( !responseContainer ) {
  8536. jQuery.error( callbackName + " was not called" );
  8537. }
  8538. return responseContainer[ 0 ];
  8539. };
  8540. // force json dataType
  8541. s.dataTypes[ 0 ] = "json";
  8542. // Install callback
  8543. overwritten = window[ callbackName ];
  8544. window[ callbackName ] = function() {
  8545. responseContainer = arguments;
  8546. };
  8547. // Clean-up function (fires after converters)
  8548. jqXHR.always( function() {
  8549. // If previous value didn't exist - remove it
  8550. if ( overwritten === undefined ) {
  8551. jQuery( window ).removeProp( callbackName );
  8552. // Otherwise restore preexisting value
  8553. } else {
  8554. window[ callbackName ] = overwritten;
  8555. }
  8556. // Save back as free
  8557. if ( s[ callbackName ] ) {
  8558. // make sure that re-using the options doesn't screw things around
  8559. s.jsonpCallback = originalSettings.jsonpCallback;
  8560. // save the callback name for future use
  8561. oldCallbacks.push( callbackName );
  8562. }
  8563. // Call if it was a function and we have a response
  8564. if ( responseContainer && jQuery.isFunction( overwritten ) ) {
  8565. overwritten( responseContainer[ 0 ] );
  8566. }
  8567. responseContainer = overwritten = undefined;
  8568. } );
  8569. // Delegate to script
  8570. return "script";
  8571. }
  8572. } );
  8573. // data: string of html
  8574. // context (optional): If specified, the fragment will be created in this context,
  8575. // defaults to document
  8576. // keepScripts (optional): If true, will include scripts passed in the html string
  8577. jQuery.parseHTML = function( data, context, keepScripts ) {
  8578. if ( !data || typeof data !== "string" ) {
  8579. return null;
  8580. }
  8581. if ( typeof context === "boolean" ) {
  8582. keepScripts = context;
  8583. context = false;
  8584. }
  8585. context = context || document;
  8586. var parsed = rsingleTag.exec( data ),
  8587. scripts = !keepScripts && [];
  8588. // Single tag
  8589. if ( parsed ) {
  8590. return [ context.createElement( parsed[ 1 ] ) ];
  8591. }
  8592. parsed = buildFragment( [ data ], context, scripts );
  8593. if ( scripts && scripts.length ) {
  8594. jQuery( scripts ).remove();
  8595. }
  8596. return jQuery.merge( [], parsed.childNodes );
  8597. };
  8598. // Keep a copy of the old load method
  8599. var _load = jQuery.fn.load;
  8600. /**
  8601. * Load a url into a page
  8602. */
  8603. jQuery.fn.load = function( url, params, callback ) {
  8604. if ( typeof url !== "string" && _load ) {
  8605. return _load.apply( this, arguments );
  8606. }
  8607. var selector, type, response,
  8608. self = this,
  8609. off = url.indexOf( " " );
  8610. if ( off > -1 ) {
  8611. selector = jQuery.trim( url.slice( off, url.length ) );
  8612. url = url.slice( 0, off );
  8613. }
  8614. // If it's a function
  8615. if ( jQuery.isFunction( params ) ) {
  8616. // We assume that it's the callback
  8617. callback = params;
  8618. params = undefined;
  8619. // Otherwise, build a param string
  8620. } else if ( params && typeof params === "object" ) {
  8621. type = "POST";
  8622. }
  8623. // If we have elements to modify, make the request
  8624. if ( self.length > 0 ) {
  8625. jQuery.ajax( {
  8626. url: url,
  8627. // If "type" variable is undefined, then "GET" method will be used.
  8628. // Make value of this field explicit since
  8629. // user can override it through ajaxSetup method
  8630. type: type || "GET",
  8631. dataType: "html",
  8632. data: params
  8633. } ).done( function( responseText ) {
  8634. // Save response for use in complete callback
  8635. response = arguments;
  8636. self.html( selector ?
  8637. // If a selector was specified, locate the right elements in a dummy div
  8638. // Exclude scripts to avoid IE 'Permission Denied' errors
  8639. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  8640. // Otherwise use the full result
  8641. responseText );
  8642. // If the request succeeds, this function gets "data", "status", "jqXHR"
  8643. // but they are ignored because response was set above.
  8644. // If it fails, this function gets "jqXHR", "status", "error"
  8645. } ).always( callback && function( jqXHR, status ) {
  8646. self.each( function() {
  8647. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  8648. } );
  8649. } );
  8650. }
  8651. return this;
  8652. };
  8653. // Attach a bunch of functions for handling common AJAX events
  8654. jQuery.each( [
  8655. "ajaxStart",
  8656. "ajaxStop",
  8657. "ajaxComplete",
  8658. "ajaxError",
  8659. "ajaxSuccess",
  8660. "ajaxSend"
  8661. ], function( i, type ) {
  8662. jQuery.fn[ type ] = function( fn ) {
  8663. return this.on( type, fn );
  8664. };
  8665. } );
  8666. jQuery.expr.filters.animated = function( elem ) {
  8667. return jQuery.grep( jQuery.timers, function( fn ) {
  8668. return elem === fn.elem;
  8669. } ).length;
  8670. };
  8671. /**
  8672. * Gets a window from an element
  8673. */
  8674. function getWindow( elem ) {
  8675. return jQuery.isWindow( elem ) ?
  8676. elem :
  8677. elem.nodeType === 9 ?
  8678. elem.defaultView || elem.parentWindow :
  8679. false;
  8680. }
  8681. jQuery.offset = {
  8682. setOffset: function( elem, options, i ) {
  8683. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  8684. position = jQuery.css( elem, "position" ),
  8685. curElem = jQuery( elem ),
  8686. props = {};
  8687. // set position first, in-case top/left are set even on static elem
  8688. if ( position === "static" ) {
  8689. elem.style.position = "relative";
  8690. }
  8691. curOffset = curElem.offset();
  8692. curCSSTop = jQuery.css( elem, "top" );
  8693. curCSSLeft = jQuery.css( elem, "left" );
  8694. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  8695. jQuery.inArray( "auto", [ curCSSTop, curCSSLeft ] ) > -1;
  8696. // need to be able to calculate position if either top or left
  8697. // is auto and position is either absolute or fixed
  8698. if ( calculatePosition ) {
  8699. curPosition = curElem.position();
  8700. curTop = curPosition.top;
  8701. curLeft = curPosition.left;
  8702. } else {
  8703. curTop = parseFloat( curCSSTop ) || 0;
  8704. curLeft = parseFloat( curCSSLeft ) || 0;
  8705. }
  8706. if ( jQuery.isFunction( options ) ) {
  8707. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  8708. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  8709. }
  8710. if ( options.top != null ) {
  8711. props.top = ( options.top - curOffset.top ) + curTop;
  8712. }
  8713. if ( options.left != null ) {
  8714. props.left = ( options.left - curOffset.left ) + curLeft;
  8715. }
  8716. if ( "using" in options ) {
  8717. options.using.call( elem, props );
  8718. } else {
  8719. curElem.css( props );
  8720. }
  8721. }
  8722. };
  8723. jQuery.fn.extend( {
  8724. offset: function( options ) {
  8725. if ( arguments.length ) {
  8726. return options === undefined ?
  8727. this :
  8728. this.each( function( i ) {
  8729. jQuery.offset.setOffset( this, options, i );
  8730. } );
  8731. }
  8732. var docElem, win,
  8733. box = { top: 0, left: 0 },
  8734. elem = this[ 0 ],
  8735. doc = elem && elem.ownerDocument;
  8736. if ( !doc ) {
  8737. return;
  8738. }
  8739. docElem = doc.documentElement;
  8740. // Make sure it's not a disconnected DOM node
  8741. if ( !jQuery.contains( docElem, elem ) ) {
  8742. return box;
  8743. }
  8744. // If we don't have gBCR, just use 0,0 rather than error
  8745. // BlackBerry 5, iOS 3 (original iPhone)
  8746. if ( typeof elem.getBoundingClientRect !== "undefined" ) {
  8747. box = elem.getBoundingClientRect();
  8748. }
  8749. win = getWindow( doc );
  8750. return {
  8751. top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
  8752. left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
  8753. };
  8754. },
  8755. position: function() {
  8756. if ( !this[ 0 ] ) {
  8757. return;
  8758. }
  8759. var offsetParent, offset,
  8760. parentOffset = { top: 0, left: 0 },
  8761. elem = this[ 0 ];
  8762. // Fixed elements are offset from window (parentOffset = {top:0, left: 0},
  8763. // because it is its only offset parent
  8764. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  8765. // we assume that getBoundingClientRect is available when computed position is fixed
  8766. offset = elem.getBoundingClientRect();
  8767. } else {
  8768. // Get *real* offsetParent
  8769. offsetParent = this.offsetParent();
  8770. // Get correct offsets
  8771. offset = this.offset();
  8772. if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
  8773. parentOffset = offsetParent.offset();
  8774. }
  8775. // Add offsetParent borders
  8776. parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
  8777. parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
  8778. }
  8779. // Subtract parent offsets and element margins
  8780. // note: when an element has margin: auto the offsetLeft and marginLeft
  8781. // are the same in Safari causing offset.left to incorrectly be 0
  8782. return {
  8783. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  8784. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  8785. };
  8786. },
  8787. offsetParent: function() {
  8788. return this.map( function() {
  8789. var offsetParent = this.offsetParent;
  8790. while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) &&
  8791. jQuery.css( offsetParent, "position" ) === "static" ) ) {
  8792. offsetParent = offsetParent.offsetParent;
  8793. }
  8794. return offsetParent || documentElement;
  8795. } );
  8796. }
  8797. } );
  8798. // Create scrollLeft and scrollTop methods
  8799. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  8800. var top = /Y/.test( prop );
  8801. jQuery.fn[ method ] = function( val ) {
  8802. return access( this, function( elem, method, val ) {
  8803. var win = getWindow( elem );
  8804. if ( val === undefined ) {
  8805. return win ? ( prop in win ) ? win[ prop ] :
  8806. win.document.documentElement[ method ] :
  8807. elem[ method ];
  8808. }
  8809. if ( win ) {
  8810. win.scrollTo(
  8811. !top ? val : jQuery( win ).scrollLeft(),
  8812. top ? val : jQuery( win ).scrollTop()
  8813. );
  8814. } else {
  8815. elem[ method ] = val;
  8816. }
  8817. }, method, val, arguments.length, null );
  8818. };
  8819. } );
  8820. // Support: Safari<7-8+, Chrome<37-44+
  8821. // Add the top/left cssHooks using jQuery.fn.position
  8822. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  8823. // getComputedStyle returns percent when specified for top/left/bottom/right
  8824. // rather than make the css module depend on the offset module, we just check for it here
  8825. jQuery.each( [ "top", "left" ], function( i, prop ) {
  8826. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  8827. function( elem, computed ) {
  8828. if ( computed ) {
  8829. computed = curCSS( elem, prop );
  8830. // if curCSS returns percentage, fallback to offset
  8831. return rnumnonpx.test( computed ) ?
  8832. jQuery( elem ).position()[ prop ] + "px" :
  8833. computed;
  8834. }
  8835. }
  8836. );
  8837. } );
  8838. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  8839. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  8840. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  8841. function( defaultExtra, funcName ) {
  8842. // margin is only for outerHeight, outerWidth
  8843. jQuery.fn[ funcName ] = function( margin, value ) {
  8844. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  8845. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  8846. return access( this, function( elem, type, value ) {
  8847. var doc;
  8848. if ( jQuery.isWindow( elem ) ) {
  8849. // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
  8850. // isn't a whole lot we can do. See pull request at this URL for discussion:
  8851. // https://github.com/jquery/jquery/pull/764
  8852. return elem.document.documentElement[ "client" + name ];
  8853. }
  8854. // Get document width or height
  8855. if ( elem.nodeType === 9 ) {
  8856. doc = elem.documentElement;
  8857. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  8858. // whichever is greatest
  8859. // unfortunately, this causes bug #3838 in IE6/8 only,
  8860. // but there is currently no good, small way to fix it.
  8861. return Math.max(
  8862. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  8863. elem.body[ "offset" + name ], doc[ "offset" + name ],
  8864. doc[ "client" + name ]
  8865. );
  8866. }
  8867. return value === undefined ?
  8868. // Get width or height on the element, requesting but not forcing parseFloat
  8869. jQuery.css( elem, type, extra ) :
  8870. // Set width or height on the element
  8871. jQuery.style( elem, type, value, extra );
  8872. }, type, chainable ? margin : undefined, chainable, null );
  8873. };
  8874. } );
  8875. } );
  8876. jQuery.fn.extend( {
  8877. bind: function( types, data, fn ) {
  8878. return this.on( types, null, data, fn );
  8879. },
  8880. unbind: function( types, fn ) {
  8881. return this.off( types, null, fn );
  8882. },
  8883. delegate: function( selector, types, data, fn ) {
  8884. return this.on( types, selector, data, fn );
  8885. },
  8886. undelegate: function( selector, types, fn ) {
  8887. // ( namespace ) or ( selector, types [, fn] )
  8888. return arguments.length === 1 ?
  8889. this.off( selector, "**" ) :
  8890. this.off( types, selector || "**", fn );
  8891. }
  8892. } );
  8893. // The number of elements contained in the matched element set
  8894. jQuery.fn.size = function() {
  8895. return this.length;
  8896. };
  8897. jQuery.fn.andSelf = jQuery.fn.addBack;
  8898. // Register as a named AMD module, since jQuery can be concatenated with other
  8899. // files that may use define, but not via a proper concatenation script that
  8900. // understands anonymous AMD modules. A named AMD is safest and most robust
  8901. // way to register. Lowercase jquery is used because AMD module names are
  8902. // derived from file names, and jQuery is normally delivered in a lowercase
  8903. // file name. Do this after creating the global so that if an AMD module wants
  8904. // to call noConflict to hide this version of jQuery, it will work.
  8905. // Note that for maximum portability, libraries that are not jQuery should
  8906. // declare themselves as anonymous modules, and avoid setting a global if an
  8907. // AMD loader is present. jQuery is a special case. For more information, see
  8908. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  8909. if ( typeof define === "function" && define.amd ) {
  8910. define( "jquery", [], function() {
  8911. return jQuery;
  8912. } );
  8913. }
  8914. var
  8915. // Map over jQuery in case of overwrite
  8916. _jQuery = window.jQuery,
  8917. // Map over the $ in case of overwrite
  8918. _$ = window.$;
  8919. jQuery.noConflict = function( deep ) {
  8920. if ( window.$ === jQuery ) {
  8921. window.$ = _$;
  8922. }
  8923. if ( deep && window.jQuery === jQuery ) {
  8924. window.jQuery = _jQuery;
  8925. }
  8926. return jQuery;
  8927. };
  8928. // Expose jQuery and $ identifiers, even in
  8929. // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  8930. // and CommonJS for browser emulators (#13566)
  8931. if ( !noGlobal ) {
  8932. window.jQuery = window.$ = jQuery;
  8933. }
  8934. return jQuery;
  8935. }));
  8936. /*!
  8937. * Bootstrap v4.5.3 (https://getbootstrap.com/)
  8938. * Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  8939. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  8940. */
  8941. (function (global, factory) {
  8942. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('jquery')) :
  8943. typeof define === 'function' && define.amd ? define(['exports', 'jquery'], factory) :
  8944. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bootstrap = {}, global.jQuery));
  8945. }(this, (function (exports, $) { 'use strict';
  8946. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  8947. var $__default = /*#__PURE__*/_interopDefaultLegacy($);
  8948. function _defineProperties(target, props) {
  8949. for (var i = 0; i < props.length; i++) {
  8950. var descriptor = props[i];
  8951. descriptor.enumerable = descriptor.enumerable || false;
  8952. descriptor.configurable = true;
  8953. if ("value" in descriptor) descriptor.writable = true;
  8954. Object.defineProperty(target, descriptor.key, descriptor);
  8955. }
  8956. }
  8957. function _createClass(Constructor, protoProps, staticProps) {
  8958. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  8959. if (staticProps) _defineProperties(Constructor, staticProps);
  8960. return Constructor;
  8961. }
  8962. function _extends() {
  8963. _extends = Object.assign || function (target) {
  8964. for (var i = 1; i < arguments.length; i++) {
  8965. var source = arguments[i];
  8966. for (var key in source) {
  8967. if (Object.prototype.hasOwnProperty.call(source, key)) {
  8968. target[key] = source[key];
  8969. }
  8970. }
  8971. }
  8972. return target;
  8973. };
  8974. return _extends.apply(this, arguments);
  8975. }
  8976. function _inheritsLoose(subClass, superClass) {
  8977. subClass.prototype = Object.create(superClass.prototype);
  8978. subClass.prototype.constructor = subClass;
  8979. subClass.__proto__ = superClass;
  8980. }
  8981. /**
  8982. * --------------------------------------------------------------------------
  8983. * Bootstrap (v4.5.3): util.js
  8984. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  8985. * --------------------------------------------------------------------------
  8986. */
  8987. /**
  8988. * ------------------------------------------------------------------------
  8989. * Private TransitionEnd Helpers
  8990. * ------------------------------------------------------------------------
  8991. */
  8992. var TRANSITION_END = 'transitionend';
  8993. var MAX_UID = 1000000;
  8994. var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  8995. function toType(obj) {
  8996. if (obj === null || typeof obj === 'undefined') {
  8997. return "" + obj;
  8998. }
  8999. return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  9000. }
  9001. function getSpecialTransitionEndEvent() {
  9002. return {
  9003. bindType: TRANSITION_END,
  9004. delegateType: TRANSITION_END,
  9005. handle: function handle(event) {
  9006. if ($__default['default'](event.target).is(this)) {
  9007. return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
  9008. }
  9009. return undefined;
  9010. }
  9011. };
  9012. }
  9013. function transitionEndEmulator(duration) {
  9014. var _this = this;
  9015. var called = false;
  9016. $__default['default'](this).one(Util.TRANSITION_END, function () {
  9017. called = true;
  9018. });
  9019. setTimeout(function () {
  9020. if (!called) {
  9021. Util.triggerTransitionEnd(_this);
  9022. }
  9023. }, duration);
  9024. return this;
  9025. }
  9026. function setTransitionEndSupport() {
  9027. $__default['default'].fn.emulateTransitionEnd = transitionEndEmulator;
  9028. $__default['default'].event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  9029. }
  9030. /**
  9031. * --------------------------------------------------------------------------
  9032. * Public Util Api
  9033. * --------------------------------------------------------------------------
  9034. */
  9035. var Util = {
  9036. TRANSITION_END: 'bsTransitionEnd',
  9037. getUID: function getUID(prefix) {
  9038. do {
  9039. prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
  9040. } while (document.getElementById(prefix));
  9041. return prefix;
  9042. },
  9043. getSelectorFromElement: function getSelectorFromElement(element) {
  9044. var selector = element.getAttribute('data-target');
  9045. if (!selector || selector === '#') {
  9046. var hrefAttr = element.getAttribute('href');
  9047. selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
  9048. }
  9049. try {
  9050. return document.querySelector(selector) ? selector : null;
  9051. } catch (_) {
  9052. return null;
  9053. }
  9054. },
  9055. getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
  9056. if (!element) {
  9057. return 0;
  9058. } // Get transition-duration of the element
  9059. var transitionDuration = $__default['default'](element).css('transition-duration');
  9060. var transitionDelay = $__default['default'](element).css('transition-delay');
  9061. var floatTransitionDuration = parseFloat(transitionDuration);
  9062. var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  9063. if (!floatTransitionDuration && !floatTransitionDelay) {
  9064. return 0;
  9065. } // If multiple durations are defined, take the first
  9066. transitionDuration = transitionDuration.split(',')[0];
  9067. transitionDelay = transitionDelay.split(',')[0];
  9068. return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  9069. },
  9070. reflow: function reflow(element) {
  9071. return element.offsetHeight;
  9072. },
  9073. triggerTransitionEnd: function triggerTransitionEnd(element) {
  9074. $__default['default'](element).trigger(TRANSITION_END);
  9075. },
  9076. supportsTransitionEnd: function supportsTransitionEnd() {
  9077. return Boolean(TRANSITION_END);
  9078. },
  9079. isElement: function isElement(obj) {
  9080. return (obj[0] || obj).nodeType;
  9081. },
  9082. typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
  9083. for (var property in configTypes) {
  9084. if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
  9085. var expectedTypes = configTypes[property];
  9086. var value = config[property];
  9087. var valueType = value && Util.isElement(value) ? 'element' : toType(value);
  9088. if (!new RegExp(expectedTypes).test(valueType)) {
  9089. throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
  9090. }
  9091. }
  9092. }
  9093. },
  9094. findShadowRoot: function findShadowRoot(element) {
  9095. if (!document.documentElement.attachShadow) {
  9096. return null;
  9097. } // Can find the shadow root otherwise it'll return the document
  9098. if (typeof element.getRootNode === 'function') {
  9099. var root = element.getRootNode();
  9100. return root instanceof ShadowRoot ? root : null;
  9101. }
  9102. if (element instanceof ShadowRoot) {
  9103. return element;
  9104. } // when we don't find a shadow root
  9105. if (!element.parentNode) {
  9106. return null;
  9107. }
  9108. return Util.findShadowRoot(element.parentNode);
  9109. },
  9110. jQueryDetection: function jQueryDetection() {
  9111. if (typeof $__default['default'] === 'undefined') {
  9112. throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.');
  9113. }
  9114. var version = $__default['default'].fn.jquery.split(' ')[0].split('.');
  9115. var minMajor = 1;
  9116. var ltMajor = 2;
  9117. var minMinor = 9;
  9118. var minPatch = 1;
  9119. var maxMajor = 4;
  9120. if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
  9121. throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
  9122. }
  9123. }
  9124. };
  9125. Util.jQueryDetection();
  9126. setTransitionEndSupport();
  9127. /**
  9128. * ------------------------------------------------------------------------
  9129. * Constants
  9130. * ------------------------------------------------------------------------
  9131. */
  9132. var NAME = 'alert';
  9133. var VERSION = '4.5.3';
  9134. var DATA_KEY = 'bs.alert';
  9135. var EVENT_KEY = "." + DATA_KEY;
  9136. var DATA_API_KEY = '.data-api';
  9137. var JQUERY_NO_CONFLICT = $__default['default'].fn[NAME];
  9138. var SELECTOR_DISMISS = '[data-dismiss="alert"]';
  9139. var EVENT_CLOSE = "close" + EVENT_KEY;
  9140. var EVENT_CLOSED = "closed" + EVENT_KEY;
  9141. var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY;
  9142. var CLASS_NAME_ALERT = 'alert';
  9143. var CLASS_NAME_FADE = 'fade';
  9144. var CLASS_NAME_SHOW = 'show';
  9145. /**
  9146. * ------------------------------------------------------------------------
  9147. * Class Definition
  9148. * ------------------------------------------------------------------------
  9149. */
  9150. var Alert = /*#__PURE__*/function () {
  9151. function Alert(element) {
  9152. this._element = element;
  9153. } // Getters
  9154. var _proto = Alert.prototype;
  9155. // Public
  9156. _proto.close = function close(element) {
  9157. var rootElement = this._element;
  9158. if (element) {
  9159. rootElement = this._getRootElement(element);
  9160. }
  9161. var customEvent = this._triggerCloseEvent(rootElement);
  9162. if (customEvent.isDefaultPrevented()) {
  9163. return;
  9164. }
  9165. this._removeElement(rootElement);
  9166. };
  9167. _proto.dispose = function dispose() {
  9168. $__default['default'].removeData(this._element, DATA_KEY);
  9169. this._element = null;
  9170. } // Private
  9171. ;
  9172. _proto._getRootElement = function _getRootElement(element) {
  9173. var selector = Util.getSelectorFromElement(element);
  9174. var parent = false;
  9175. if (selector) {
  9176. parent = document.querySelector(selector);
  9177. }
  9178. if (!parent) {
  9179. parent = $__default['default'](element).closest("." + CLASS_NAME_ALERT)[0];
  9180. }
  9181. return parent;
  9182. };
  9183. _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
  9184. var closeEvent = $__default['default'].Event(EVENT_CLOSE);
  9185. $__default['default'](element).trigger(closeEvent);
  9186. return closeEvent;
  9187. };
  9188. _proto._removeElement = function _removeElement(element) {
  9189. var _this = this;
  9190. $__default['default'](element).removeClass(CLASS_NAME_SHOW);
  9191. if (!$__default['default'](element).hasClass(CLASS_NAME_FADE)) {
  9192. this._destroyElement(element);
  9193. return;
  9194. }
  9195. var transitionDuration = Util.getTransitionDurationFromElement(element);
  9196. $__default['default'](element).one(Util.TRANSITION_END, function (event) {
  9197. return _this._destroyElement(element, event);
  9198. }).emulateTransitionEnd(transitionDuration);
  9199. };
  9200. _proto._destroyElement = function _destroyElement(element) {
  9201. $__default['default'](element).detach().trigger(EVENT_CLOSED).remove();
  9202. } // Static
  9203. ;
  9204. Alert._jQueryInterface = function _jQueryInterface(config) {
  9205. return this.each(function () {
  9206. var $element = $__default['default'](this);
  9207. var data = $element.data(DATA_KEY);
  9208. if (!data) {
  9209. data = new Alert(this);
  9210. $element.data(DATA_KEY, data);
  9211. }
  9212. if (config === 'close') {
  9213. data[config](this);
  9214. }
  9215. });
  9216. };
  9217. Alert._handleDismiss = function _handleDismiss(alertInstance) {
  9218. return function (event) {
  9219. if (event) {
  9220. event.preventDefault();
  9221. }
  9222. alertInstance.close(this);
  9223. };
  9224. };
  9225. _createClass(Alert, null, [{
  9226. key: "VERSION",
  9227. get: function get() {
  9228. return VERSION;
  9229. }
  9230. }]);
  9231. return Alert;
  9232. }();
  9233. /**
  9234. * ------------------------------------------------------------------------
  9235. * Data Api implementation
  9236. * ------------------------------------------------------------------------
  9237. */
  9238. $__default['default'](document).on(EVENT_CLICK_DATA_API, SELECTOR_DISMISS, Alert._handleDismiss(new Alert()));
  9239. /**
  9240. * ------------------------------------------------------------------------
  9241. * jQuery
  9242. * ------------------------------------------------------------------------
  9243. */
  9244. $__default['default'].fn[NAME] = Alert._jQueryInterface;
  9245. $__default['default'].fn[NAME].Constructor = Alert;
  9246. $__default['default'].fn[NAME].noConflict = function () {
  9247. $__default['default'].fn[NAME] = JQUERY_NO_CONFLICT;
  9248. return Alert._jQueryInterface;
  9249. };
  9250. /**
  9251. * ------------------------------------------------------------------------
  9252. * Constants
  9253. * ------------------------------------------------------------------------
  9254. */
  9255. var NAME$1 = 'button';
  9256. var VERSION$1 = '4.5.3';
  9257. var DATA_KEY$1 = 'bs.button';
  9258. var EVENT_KEY$1 = "." + DATA_KEY$1;
  9259. var DATA_API_KEY$1 = '.data-api';
  9260. var JQUERY_NO_CONFLICT$1 = $__default['default'].fn[NAME$1];
  9261. var CLASS_NAME_ACTIVE = 'active';
  9262. var CLASS_NAME_BUTTON = 'btn';
  9263. var CLASS_NAME_FOCUS = 'focus';
  9264. var SELECTOR_DATA_TOGGLE_CARROT = '[data-toggle^="button"]';
  9265. var SELECTOR_DATA_TOGGLES = '[data-toggle="buttons"]';
  9266. var SELECTOR_DATA_TOGGLE = '[data-toggle="button"]';
  9267. var SELECTOR_DATA_TOGGLES_BUTTONS = '[data-toggle="buttons"] .btn';
  9268. var SELECTOR_INPUT = 'input:not([type="hidden"])';
  9269. var SELECTOR_ACTIVE = '.active';
  9270. var SELECTOR_BUTTON = '.btn';
  9271. var EVENT_CLICK_DATA_API$1 = "click" + EVENT_KEY$1 + DATA_API_KEY$1;
  9272. var EVENT_FOCUS_BLUR_DATA_API = "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1);
  9273. var EVENT_LOAD_DATA_API = "load" + EVENT_KEY$1 + DATA_API_KEY$1;
  9274. /**
  9275. * ------------------------------------------------------------------------
  9276. * Class Definition
  9277. * ------------------------------------------------------------------------
  9278. */
  9279. var Button = /*#__PURE__*/function () {
  9280. function Button(element) {
  9281. this._element = element;
  9282. this.shouldAvoidTriggerChange = false;
  9283. } // Getters
  9284. var _proto = Button.prototype;
  9285. // Public
  9286. _proto.toggle = function toggle() {
  9287. var triggerChangeEvent = true;
  9288. var addAriaPressed = true;
  9289. var rootElement = $__default['default'](this._element).closest(SELECTOR_DATA_TOGGLES)[0];
  9290. if (rootElement) {
  9291. var input = this._element.querySelector(SELECTOR_INPUT);
  9292. if (input) {
  9293. if (input.type === 'radio') {
  9294. if (input.checked && this._element.classList.contains(CLASS_NAME_ACTIVE)) {
  9295. triggerChangeEvent = false;
  9296. } else {
  9297. var activeElement = rootElement.querySelector(SELECTOR_ACTIVE);
  9298. if (activeElement) {
  9299. $__default['default'](activeElement).removeClass(CLASS_NAME_ACTIVE);
  9300. }
  9301. }
  9302. }
  9303. if (triggerChangeEvent) {
  9304. // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
  9305. if (input.type === 'checkbox' || input.type === 'radio') {
  9306. input.checked = !this._element.classList.contains(CLASS_NAME_ACTIVE);
  9307. }
  9308. if (!this.shouldAvoidTriggerChange) {
  9309. $__default['default'](input).trigger('change');
  9310. }
  9311. }
  9312. input.focus();
  9313. addAriaPressed = false;
  9314. }
  9315. }
  9316. if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {
  9317. if (addAriaPressed) {
  9318. this._element.setAttribute('aria-pressed', !this._element.classList.contains(CLASS_NAME_ACTIVE));
  9319. }
  9320. if (triggerChangeEvent) {
  9321. $__default['default'](this._element).toggleClass(CLASS_NAME_ACTIVE);
  9322. }
  9323. }
  9324. };
  9325. _proto.dispose = function dispose() {
  9326. $__default['default'].removeData(this._element, DATA_KEY$1);
  9327. this._element = null;
  9328. } // Static
  9329. ;
  9330. Button._jQueryInterface = function _jQueryInterface(config, avoidTriggerChange) {
  9331. return this.each(function () {
  9332. var $element = $__default['default'](this);
  9333. var data = $element.data(DATA_KEY$1);
  9334. if (!data) {
  9335. data = new Button(this);
  9336. $element.data(DATA_KEY$1, data);
  9337. }
  9338. data.shouldAvoidTriggerChange = avoidTriggerChange;
  9339. if (config === 'toggle') {
  9340. data[config]();
  9341. }
  9342. });
  9343. };
  9344. _createClass(Button, null, [{
  9345. key: "VERSION",
  9346. get: function get() {
  9347. return VERSION$1;
  9348. }
  9349. }]);
  9350. return Button;
  9351. }();
  9352. /**
  9353. * ------------------------------------------------------------------------
  9354. * Data Api implementation
  9355. * ------------------------------------------------------------------------
  9356. */
  9357. $__default['default'](document).on(EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE_CARROT, function (event) {
  9358. var button = event.target;
  9359. var initialButton = button;
  9360. if (!$__default['default'](button).hasClass(CLASS_NAME_BUTTON)) {
  9361. button = $__default['default'](button).closest(SELECTOR_BUTTON)[0];
  9362. }
  9363. if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {
  9364. event.preventDefault(); // work around Firefox bug #1540995
  9365. } else {
  9366. var inputBtn = button.querySelector(SELECTOR_INPUT);
  9367. if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {
  9368. event.preventDefault(); // work around Firefox bug #1540995
  9369. return;
  9370. }
  9371. if (initialButton.tagName === 'INPUT' || button.tagName !== 'LABEL') {
  9372. Button._jQueryInterface.call($__default['default'](button), 'toggle', initialButton.tagName === 'INPUT');
  9373. }
  9374. }
  9375. }).on(EVENT_FOCUS_BLUR_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, function (event) {
  9376. var button = $__default['default'](event.target).closest(SELECTOR_BUTTON)[0];
  9377. $__default['default'](button).toggleClass(CLASS_NAME_FOCUS, /^focus(in)?$/.test(event.type));
  9378. });
  9379. $__default['default'](window).on(EVENT_LOAD_DATA_API, function () {
  9380. // ensure correct active class is set to match the controls' actual values/states
  9381. // find all checkboxes/readio buttons inside data-toggle groups
  9382. var buttons = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLES_BUTTONS));
  9383. for (var i = 0, len = buttons.length; i < len; i++) {
  9384. var button = buttons[i];
  9385. var input = button.querySelector(SELECTOR_INPUT);
  9386. if (input.checked || input.hasAttribute('checked')) {
  9387. button.classList.add(CLASS_NAME_ACTIVE);
  9388. } else {
  9389. button.classList.remove(CLASS_NAME_ACTIVE);
  9390. }
  9391. } // find all button toggles
  9392. buttons = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE));
  9393. for (var _i = 0, _len = buttons.length; _i < _len; _i++) {
  9394. var _button = buttons[_i];
  9395. if (_button.getAttribute('aria-pressed') === 'true') {
  9396. _button.classList.add(CLASS_NAME_ACTIVE);
  9397. } else {
  9398. _button.classList.remove(CLASS_NAME_ACTIVE);
  9399. }
  9400. }
  9401. });
  9402. /**
  9403. * ------------------------------------------------------------------------
  9404. * jQuery
  9405. * ------------------------------------------------------------------------
  9406. */
  9407. $__default['default'].fn[NAME$1] = Button._jQueryInterface;
  9408. $__default['default'].fn[NAME$1].Constructor = Button;
  9409. $__default['default'].fn[NAME$1].noConflict = function () {
  9410. $__default['default'].fn[NAME$1] = JQUERY_NO_CONFLICT$1;
  9411. return Button._jQueryInterface;
  9412. };
  9413. /**
  9414. * ------------------------------------------------------------------------
  9415. * Constants
  9416. * ------------------------------------------------------------------------
  9417. */
  9418. var NAME$2 = 'carousel';
  9419. var VERSION$2 = '4.5.3';
  9420. var DATA_KEY$2 = 'bs.carousel';
  9421. var EVENT_KEY$2 = "." + DATA_KEY$2;
  9422. var DATA_API_KEY$2 = '.data-api';
  9423. var JQUERY_NO_CONFLICT$2 = $__default['default'].fn[NAME$2];
  9424. var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  9425. var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
  9426. var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  9427. var SWIPE_THRESHOLD = 40;
  9428. var Default = {
  9429. interval: 5000,
  9430. keyboard: true,
  9431. slide: false,
  9432. pause: 'hover',
  9433. wrap: true,
  9434. touch: true
  9435. };
  9436. var DefaultType = {
  9437. interval: '(number|boolean)',
  9438. keyboard: 'boolean',
  9439. slide: '(boolean|string)',
  9440. pause: '(string|boolean)',
  9441. wrap: 'boolean',
  9442. touch: 'boolean'
  9443. };
  9444. var DIRECTION_NEXT = 'next';
  9445. var DIRECTION_PREV = 'prev';
  9446. var DIRECTION_LEFT = 'left';
  9447. var DIRECTION_RIGHT = 'right';
  9448. var EVENT_SLIDE = "slide" + EVENT_KEY$2;
  9449. var EVENT_SLID = "slid" + EVENT_KEY$2;
  9450. var EVENT_KEYDOWN = "keydown" + EVENT_KEY$2;
  9451. var EVENT_MOUSEENTER = "mouseenter" + EVENT_KEY$2;
  9452. var EVENT_MOUSELEAVE = "mouseleave" + EVENT_KEY$2;
  9453. var EVENT_TOUCHSTART = "touchstart" + EVENT_KEY$2;
  9454. var EVENT_TOUCHMOVE = "touchmove" + EVENT_KEY$2;
  9455. var EVENT_TOUCHEND = "touchend" + EVENT_KEY$2;
  9456. var EVENT_POINTERDOWN = "pointerdown" + EVENT_KEY$2;
  9457. var EVENT_POINTERUP = "pointerup" + EVENT_KEY$2;
  9458. var EVENT_DRAG_START = "dragstart" + EVENT_KEY$2;
  9459. var EVENT_LOAD_DATA_API$1 = "load" + EVENT_KEY$2 + DATA_API_KEY$2;
  9460. var EVENT_CLICK_DATA_API$2 = "click" + EVENT_KEY$2 + DATA_API_KEY$2;
  9461. var CLASS_NAME_CAROUSEL = 'carousel';
  9462. var CLASS_NAME_ACTIVE$1 = 'active';
  9463. var CLASS_NAME_SLIDE = 'slide';
  9464. var CLASS_NAME_RIGHT = 'carousel-item-right';
  9465. var CLASS_NAME_LEFT = 'carousel-item-left';
  9466. var CLASS_NAME_NEXT = 'carousel-item-next';
  9467. var CLASS_NAME_PREV = 'carousel-item-prev';
  9468. var CLASS_NAME_POINTER_EVENT = 'pointer-event';
  9469. var SELECTOR_ACTIVE$1 = '.active';
  9470. var SELECTOR_ACTIVE_ITEM = '.active.carousel-item';
  9471. var SELECTOR_ITEM = '.carousel-item';
  9472. var SELECTOR_ITEM_IMG = '.carousel-item img';
  9473. var SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev';
  9474. var SELECTOR_INDICATORS = '.carousel-indicators';
  9475. var SELECTOR_DATA_SLIDE = '[data-slide], [data-slide-to]';
  9476. var SELECTOR_DATA_RIDE = '[data-ride="carousel"]';
  9477. var PointerType = {
  9478. TOUCH: 'touch',
  9479. PEN: 'pen'
  9480. };
  9481. /**
  9482. * ------------------------------------------------------------------------
  9483. * Class Definition
  9484. * ------------------------------------------------------------------------
  9485. */
  9486. var Carousel = /*#__PURE__*/function () {
  9487. function Carousel(element, config) {
  9488. this._items = null;
  9489. this._interval = null;
  9490. this._activeElement = null;
  9491. this._isPaused = false;
  9492. this._isSliding = false;
  9493. this.touchTimeout = null;
  9494. this.touchStartX = 0;
  9495. this.touchDeltaX = 0;
  9496. this._config = this._getConfig(config);
  9497. this._element = element;
  9498. this._indicatorsElement = this._element.querySelector(SELECTOR_INDICATORS);
  9499. this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  9500. this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
  9501. this._addEventListeners();
  9502. } // Getters
  9503. var _proto = Carousel.prototype;
  9504. // Public
  9505. _proto.next = function next() {
  9506. if (!this._isSliding) {
  9507. this._slide(DIRECTION_NEXT);
  9508. }
  9509. };
  9510. _proto.nextWhenVisible = function nextWhenVisible() {
  9511. var $element = $__default['default'](this._element); // Don't call next when the page isn't visible
  9512. // or the carousel or its parent isn't visible
  9513. if (!document.hidden && $element.is(':visible') && $element.css('visibility') !== 'hidden') {
  9514. this.next();
  9515. }
  9516. };
  9517. _proto.prev = function prev() {
  9518. if (!this._isSliding) {
  9519. this._slide(DIRECTION_PREV);
  9520. }
  9521. };
  9522. _proto.pause = function pause(event) {
  9523. if (!event) {
  9524. this._isPaused = true;
  9525. }
  9526. if (this._element.querySelector(SELECTOR_NEXT_PREV)) {
  9527. Util.triggerTransitionEnd(this._element);
  9528. this.cycle(true);
  9529. }
  9530. clearInterval(this._interval);
  9531. this._interval = null;
  9532. };
  9533. _proto.cycle = function cycle(event) {
  9534. if (!event) {
  9535. this._isPaused = false;
  9536. }
  9537. if (this._interval) {
  9538. clearInterval(this._interval);
  9539. this._interval = null;
  9540. }
  9541. if (this._config.interval && !this._isPaused) {
  9542. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  9543. }
  9544. };
  9545. _proto.to = function to(index) {
  9546. var _this = this;
  9547. this._activeElement = this._element.querySelector(SELECTOR_ACTIVE_ITEM);
  9548. var activeIndex = this._getItemIndex(this._activeElement);
  9549. if (index > this._items.length - 1 || index < 0) {
  9550. return;
  9551. }
  9552. if (this._isSliding) {
  9553. $__default['default'](this._element).one(EVENT_SLID, function () {
  9554. return _this.to(index);
  9555. });
  9556. return;
  9557. }
  9558. if (activeIndex === index) {
  9559. this.pause();
  9560. this.cycle();
  9561. return;
  9562. }
  9563. var direction = index > activeIndex ? DIRECTION_NEXT : DIRECTION_PREV;
  9564. this._slide(direction, this._items[index]);
  9565. };
  9566. _proto.dispose = function dispose() {
  9567. $__default['default'](this._element).off(EVENT_KEY$2);
  9568. $__default['default'].removeData(this._element, DATA_KEY$2);
  9569. this._items = null;
  9570. this._config = null;
  9571. this._element = null;
  9572. this._interval = null;
  9573. this._isPaused = null;
  9574. this._isSliding = null;
  9575. this._activeElement = null;
  9576. this._indicatorsElement = null;
  9577. } // Private
  9578. ;
  9579. _proto._getConfig = function _getConfig(config) {
  9580. config = _extends({}, Default, config);
  9581. Util.typeCheckConfig(NAME$2, config, DefaultType);
  9582. return config;
  9583. };
  9584. _proto._handleSwipe = function _handleSwipe() {
  9585. var absDeltax = Math.abs(this.touchDeltaX);
  9586. if (absDeltax <= SWIPE_THRESHOLD) {
  9587. return;
  9588. }
  9589. var direction = absDeltax / this.touchDeltaX;
  9590. this.touchDeltaX = 0; // swipe left
  9591. if (direction > 0) {
  9592. this.prev();
  9593. } // swipe right
  9594. if (direction < 0) {
  9595. this.next();
  9596. }
  9597. };
  9598. _proto._addEventListeners = function _addEventListeners() {
  9599. var _this2 = this;
  9600. if (this._config.keyboard) {
  9601. $__default['default'](this._element).on(EVENT_KEYDOWN, function (event) {
  9602. return _this2._keydown(event);
  9603. });
  9604. }
  9605. if (this._config.pause === 'hover') {
  9606. $__default['default'](this._element).on(EVENT_MOUSEENTER, function (event) {
  9607. return _this2.pause(event);
  9608. }).on(EVENT_MOUSELEAVE, function (event) {
  9609. return _this2.cycle(event);
  9610. });
  9611. }
  9612. if (this._config.touch) {
  9613. this._addTouchEventListeners();
  9614. }
  9615. };
  9616. _proto._addTouchEventListeners = function _addTouchEventListeners() {
  9617. var _this3 = this;
  9618. if (!this._touchSupported) {
  9619. return;
  9620. }
  9621. var start = function start(event) {
  9622. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  9623. _this3.touchStartX = event.originalEvent.clientX;
  9624. } else if (!_this3._pointerEvent) {
  9625. _this3.touchStartX = event.originalEvent.touches[0].clientX;
  9626. }
  9627. };
  9628. var move = function move(event) {
  9629. // ensure swiping with one touch and not pinching
  9630. if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
  9631. _this3.touchDeltaX = 0;
  9632. } else {
  9633. _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
  9634. }
  9635. };
  9636. var end = function end(event) {
  9637. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  9638. _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
  9639. }
  9640. _this3._handleSwipe();
  9641. if (_this3._config.pause === 'hover') {
  9642. // If it's a touch-enabled device, mouseenter/leave are fired as
  9643. // part of the mouse compatibility events on first tap - the carousel
  9644. // would stop cycling until user tapped out of it;
  9645. // here, we listen for touchend, explicitly pause the carousel
  9646. // (as if it's the second time we tap on it, mouseenter compat event
  9647. // is NOT fired) and after a timeout (to allow for mouse compatibility
  9648. // events to fire) we explicitly restart cycling
  9649. _this3.pause();
  9650. if (_this3.touchTimeout) {
  9651. clearTimeout(_this3.touchTimeout);
  9652. }
  9653. _this3.touchTimeout = setTimeout(function (event) {
  9654. return _this3.cycle(event);
  9655. }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
  9656. }
  9657. };
  9658. $__default['default'](this._element.querySelectorAll(SELECTOR_ITEM_IMG)).on(EVENT_DRAG_START, function (e) {
  9659. return e.preventDefault();
  9660. });
  9661. if (this._pointerEvent) {
  9662. $__default['default'](this._element).on(EVENT_POINTERDOWN, function (event) {
  9663. return start(event);
  9664. });
  9665. $__default['default'](this._element).on(EVENT_POINTERUP, function (event) {
  9666. return end(event);
  9667. });
  9668. this._element.classList.add(CLASS_NAME_POINTER_EVENT);
  9669. } else {
  9670. $__default['default'](this._element).on(EVENT_TOUCHSTART, function (event) {
  9671. return start(event);
  9672. });
  9673. $__default['default'](this._element).on(EVENT_TOUCHMOVE, function (event) {
  9674. return move(event);
  9675. });
  9676. $__default['default'](this._element).on(EVENT_TOUCHEND, function (event) {
  9677. return end(event);
  9678. });
  9679. }
  9680. };
  9681. _proto._keydown = function _keydown(event) {
  9682. if (/input|textarea/i.test(event.target.tagName)) {
  9683. return;
  9684. }
  9685. switch (event.which) {
  9686. case ARROW_LEFT_KEYCODE:
  9687. event.preventDefault();
  9688. this.prev();
  9689. break;
  9690. case ARROW_RIGHT_KEYCODE:
  9691. event.preventDefault();
  9692. this.next();
  9693. break;
  9694. }
  9695. };
  9696. _proto._getItemIndex = function _getItemIndex(element) {
  9697. this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(SELECTOR_ITEM)) : [];
  9698. return this._items.indexOf(element);
  9699. };
  9700. _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
  9701. var isNextDirection = direction === DIRECTION_NEXT;
  9702. var isPrevDirection = direction === DIRECTION_PREV;
  9703. var activeIndex = this._getItemIndex(activeElement);
  9704. var lastItemIndex = this._items.length - 1;
  9705. var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
  9706. if (isGoingToWrap && !this._config.wrap) {
  9707. return activeElement;
  9708. }
  9709. var delta = direction === DIRECTION_PREV ? -1 : 1;
  9710. var itemIndex = (activeIndex + delta) % this._items.length;
  9711. return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
  9712. };
  9713. _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
  9714. var targetIndex = this._getItemIndex(relatedTarget);
  9715. var fromIndex = this._getItemIndex(this._element.querySelector(SELECTOR_ACTIVE_ITEM));
  9716. var slideEvent = $__default['default'].Event(EVENT_SLIDE, {
  9717. relatedTarget: relatedTarget,
  9718. direction: eventDirectionName,
  9719. from: fromIndex,
  9720. to: targetIndex
  9721. });
  9722. $__default['default'](this._element).trigger(slideEvent);
  9723. return slideEvent;
  9724. };
  9725. _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
  9726. if (this._indicatorsElement) {
  9727. var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(SELECTOR_ACTIVE$1));
  9728. $__default['default'](indicators).removeClass(CLASS_NAME_ACTIVE$1);
  9729. var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
  9730. if (nextIndicator) {
  9731. $__default['default'](nextIndicator).addClass(CLASS_NAME_ACTIVE$1);
  9732. }
  9733. }
  9734. };
  9735. _proto._slide = function _slide(direction, element) {
  9736. var _this4 = this;
  9737. var activeElement = this._element.querySelector(SELECTOR_ACTIVE_ITEM);
  9738. var activeElementIndex = this._getItemIndex(activeElement);
  9739. var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
  9740. var nextElementIndex = this._getItemIndex(nextElement);
  9741. var isCycling = Boolean(this._interval);
  9742. var directionalClassName;
  9743. var orderClassName;
  9744. var eventDirectionName;
  9745. if (direction === DIRECTION_NEXT) {
  9746. directionalClassName = CLASS_NAME_LEFT;
  9747. orderClassName = CLASS_NAME_NEXT;
  9748. eventDirectionName = DIRECTION_LEFT;
  9749. } else {
  9750. directionalClassName = CLASS_NAME_RIGHT;
  9751. orderClassName = CLASS_NAME_PREV;
  9752. eventDirectionName = DIRECTION_RIGHT;
  9753. }
  9754. if (nextElement && $__default['default'](nextElement).hasClass(CLASS_NAME_ACTIVE$1)) {
  9755. this._isSliding = false;
  9756. return;
  9757. }
  9758. var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  9759. if (slideEvent.isDefaultPrevented()) {
  9760. return;
  9761. }
  9762. if (!activeElement || !nextElement) {
  9763. // Some weirdness is happening, so we bail
  9764. return;
  9765. }
  9766. this._isSliding = true;
  9767. if (isCycling) {
  9768. this.pause();
  9769. }
  9770. this._setActiveIndicatorElement(nextElement);
  9771. var slidEvent = $__default['default'].Event(EVENT_SLID, {
  9772. relatedTarget: nextElement,
  9773. direction: eventDirectionName,
  9774. from: activeElementIndex,
  9775. to: nextElementIndex
  9776. });
  9777. if ($__default['default'](this._element).hasClass(CLASS_NAME_SLIDE)) {
  9778. $__default['default'](nextElement).addClass(orderClassName);
  9779. Util.reflow(nextElement);
  9780. $__default['default'](activeElement).addClass(directionalClassName);
  9781. $__default['default'](nextElement).addClass(directionalClassName);
  9782. var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
  9783. if (nextElementInterval) {
  9784. this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
  9785. this._config.interval = nextElementInterval;
  9786. } else {
  9787. this._config.interval = this._config.defaultInterval || this._config.interval;
  9788. }
  9789. var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
  9790. $__default['default'](activeElement).one(Util.TRANSITION_END, function () {
  9791. $__default['default'](nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(CLASS_NAME_ACTIVE$1);
  9792. $__default['default'](activeElement).removeClass(CLASS_NAME_ACTIVE$1 + " " + orderClassName + " " + directionalClassName);
  9793. _this4._isSliding = false;
  9794. setTimeout(function () {
  9795. return $__default['default'](_this4._element).trigger(slidEvent);
  9796. }, 0);
  9797. }).emulateTransitionEnd(transitionDuration);
  9798. } else {
  9799. $__default['default'](activeElement).removeClass(CLASS_NAME_ACTIVE$1);
  9800. $__default['default'](nextElement).addClass(CLASS_NAME_ACTIVE$1);
  9801. this._isSliding = false;
  9802. $__default['default'](this._element).trigger(slidEvent);
  9803. }
  9804. if (isCycling) {
  9805. this.cycle();
  9806. }
  9807. } // Static
  9808. ;
  9809. Carousel._jQueryInterface = function _jQueryInterface(config) {
  9810. return this.each(function () {
  9811. var data = $__default['default'](this).data(DATA_KEY$2);
  9812. var _config = _extends({}, Default, $__default['default'](this).data());
  9813. if (typeof config === 'object') {
  9814. _config = _extends({}, _config, config);
  9815. }
  9816. var action = typeof config === 'string' ? config : _config.slide;
  9817. if (!data) {
  9818. data = new Carousel(this, _config);
  9819. $__default['default'](this).data(DATA_KEY$2, data);
  9820. }
  9821. if (typeof config === 'number') {
  9822. data.to(config);
  9823. } else if (typeof action === 'string') {
  9824. if (typeof data[action] === 'undefined') {
  9825. throw new TypeError("No method named \"" + action + "\"");
  9826. }
  9827. data[action]();
  9828. } else if (_config.interval && _config.ride) {
  9829. data.pause();
  9830. data.cycle();
  9831. }
  9832. });
  9833. };
  9834. Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
  9835. var selector = Util.getSelectorFromElement(this);
  9836. if (!selector) {
  9837. return;
  9838. }
  9839. var target = $__default['default'](selector)[0];
  9840. if (!target || !$__default['default'](target).hasClass(CLASS_NAME_CAROUSEL)) {
  9841. return;
  9842. }
  9843. var config = _extends({}, $__default['default'](target).data(), $__default['default'](this).data());
  9844. var slideIndex = this.getAttribute('data-slide-to');
  9845. if (slideIndex) {
  9846. config.interval = false;
  9847. }
  9848. Carousel._jQueryInterface.call($__default['default'](target), config);
  9849. if (slideIndex) {
  9850. $__default['default'](target).data(DATA_KEY$2).to(slideIndex);
  9851. }
  9852. event.preventDefault();
  9853. };
  9854. _createClass(Carousel, null, [{
  9855. key: "VERSION",
  9856. get: function get() {
  9857. return VERSION$2;
  9858. }
  9859. }, {
  9860. key: "Default",
  9861. get: function get() {
  9862. return Default;
  9863. }
  9864. }]);
  9865. return Carousel;
  9866. }();
  9867. /**
  9868. * ------------------------------------------------------------------------
  9869. * Data Api implementation
  9870. * ------------------------------------------------------------------------
  9871. */
  9872. $__default['default'](document).on(EVENT_CLICK_DATA_API$2, SELECTOR_DATA_SLIDE, Carousel._dataApiClickHandler);
  9873. $__default['default'](window).on(EVENT_LOAD_DATA_API$1, function () {
  9874. var carousels = [].slice.call(document.querySelectorAll(SELECTOR_DATA_RIDE));
  9875. for (var i = 0, len = carousels.length; i < len; i++) {
  9876. var $carousel = $__default['default'](carousels[i]);
  9877. Carousel._jQueryInterface.call($carousel, $carousel.data());
  9878. }
  9879. });
  9880. /**
  9881. * ------------------------------------------------------------------------
  9882. * jQuery
  9883. * ------------------------------------------------------------------------
  9884. */
  9885. $__default['default'].fn[NAME$2] = Carousel._jQueryInterface;
  9886. $__default['default'].fn[NAME$2].Constructor = Carousel;
  9887. $__default['default'].fn[NAME$2].noConflict = function () {
  9888. $__default['default'].fn[NAME$2] = JQUERY_NO_CONFLICT$2;
  9889. return Carousel._jQueryInterface;
  9890. };
  9891. /**
  9892. * ------------------------------------------------------------------------
  9893. * Constants
  9894. * ------------------------------------------------------------------------
  9895. */
  9896. var NAME$3 = 'collapse';
  9897. var VERSION$3 = '4.5.3';
  9898. var DATA_KEY$3 = 'bs.collapse';
  9899. var EVENT_KEY$3 = "." + DATA_KEY$3;
  9900. var DATA_API_KEY$3 = '.data-api';
  9901. var JQUERY_NO_CONFLICT$3 = $__default['default'].fn[NAME$3];
  9902. var Default$1 = {
  9903. toggle: true,
  9904. parent: ''
  9905. };
  9906. var DefaultType$1 = {
  9907. toggle: 'boolean',
  9908. parent: '(string|element)'
  9909. };
  9910. var EVENT_SHOW = "show" + EVENT_KEY$3;
  9911. var EVENT_SHOWN = "shown" + EVENT_KEY$3;
  9912. var EVENT_HIDE = "hide" + EVENT_KEY$3;
  9913. var EVENT_HIDDEN = "hidden" + EVENT_KEY$3;
  9914. var EVENT_CLICK_DATA_API$3 = "click" + EVENT_KEY$3 + DATA_API_KEY$3;
  9915. var CLASS_NAME_SHOW$1 = 'show';
  9916. var CLASS_NAME_COLLAPSE = 'collapse';
  9917. var CLASS_NAME_COLLAPSING = 'collapsing';
  9918. var CLASS_NAME_COLLAPSED = 'collapsed';
  9919. var DIMENSION_WIDTH = 'width';
  9920. var DIMENSION_HEIGHT = 'height';
  9921. var SELECTOR_ACTIVES = '.show, .collapsing';
  9922. var SELECTOR_DATA_TOGGLE$1 = '[data-toggle="collapse"]';
  9923. /**
  9924. * ------------------------------------------------------------------------
  9925. * Class Definition
  9926. * ------------------------------------------------------------------------
  9927. */
  9928. var Collapse = /*#__PURE__*/function () {
  9929. function Collapse(element, config) {
  9930. this._isTransitioning = false;
  9931. this._element = element;
  9932. this._config = this._getConfig(config);
  9933. this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
  9934. var toggleList = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE$1));
  9935. for (var i = 0, len = toggleList.length; i < len; i++) {
  9936. var elem = toggleList[i];
  9937. var selector = Util.getSelectorFromElement(elem);
  9938. var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
  9939. return foundElem === element;
  9940. });
  9941. if (selector !== null && filterElement.length > 0) {
  9942. this._selector = selector;
  9943. this._triggerArray.push(elem);
  9944. }
  9945. }
  9946. this._parent = this._config.parent ? this._getParent() : null;
  9947. if (!this._config.parent) {
  9948. this._addAriaAndCollapsedClass(this._element, this._triggerArray);
  9949. }
  9950. if (this._config.toggle) {
  9951. this.toggle();
  9952. }
  9953. } // Getters
  9954. var _proto = Collapse.prototype;
  9955. // Public
  9956. _proto.toggle = function toggle() {
  9957. if ($__default['default'](this._element).hasClass(CLASS_NAME_SHOW$1)) {
  9958. this.hide();
  9959. } else {
  9960. this.show();
  9961. }
  9962. };
  9963. _proto.show = function show() {
  9964. var _this = this;
  9965. if (this._isTransitioning || $__default['default'](this._element).hasClass(CLASS_NAME_SHOW$1)) {
  9966. return;
  9967. }
  9968. var actives;
  9969. var activesData;
  9970. if (this._parent) {
  9971. actives = [].slice.call(this._parent.querySelectorAll(SELECTOR_ACTIVES)).filter(function (elem) {
  9972. if (typeof _this._config.parent === 'string') {
  9973. return elem.getAttribute('data-parent') === _this._config.parent;
  9974. }
  9975. return elem.classList.contains(CLASS_NAME_COLLAPSE);
  9976. });
  9977. if (actives.length === 0) {
  9978. actives = null;
  9979. }
  9980. }
  9981. if (actives) {
  9982. activesData = $__default['default'](actives).not(this._selector).data(DATA_KEY$3);
  9983. if (activesData && activesData._isTransitioning) {
  9984. return;
  9985. }
  9986. }
  9987. var startEvent = $__default['default'].Event(EVENT_SHOW);
  9988. $__default['default'](this._element).trigger(startEvent);
  9989. if (startEvent.isDefaultPrevented()) {
  9990. return;
  9991. }
  9992. if (actives) {
  9993. Collapse._jQueryInterface.call($__default['default'](actives).not(this._selector), 'hide');
  9994. if (!activesData) {
  9995. $__default['default'](actives).data(DATA_KEY$3, null);
  9996. }
  9997. }
  9998. var dimension = this._getDimension();
  9999. $__default['default'](this._element).removeClass(CLASS_NAME_COLLAPSE).addClass(CLASS_NAME_COLLAPSING);
  10000. this._element.style[dimension] = 0;
  10001. if (this._triggerArray.length) {
  10002. $__default['default'](this._triggerArray).removeClass(CLASS_NAME_COLLAPSED).attr('aria-expanded', true);
  10003. }
  10004. this.setTransitioning(true);
  10005. var complete = function complete() {
  10006. $__default['default'](_this._element).removeClass(CLASS_NAME_COLLAPSING).addClass(CLASS_NAME_COLLAPSE + " " + CLASS_NAME_SHOW$1);
  10007. _this._element.style[dimension] = '';
  10008. _this.setTransitioning(false);
  10009. $__default['default'](_this._element).trigger(EVENT_SHOWN);
  10010. };
  10011. var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  10012. var scrollSize = "scroll" + capitalizedDimension;
  10013. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  10014. $__default['default'](this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  10015. this._element.style[dimension] = this._element[scrollSize] + "px";
  10016. };
  10017. _proto.hide = function hide() {
  10018. var _this2 = this;
  10019. if (this._isTransitioning || !$__default['default'](this._element).hasClass(CLASS_NAME_SHOW$1)) {
  10020. return;
  10021. }
  10022. var startEvent = $__default['default'].Event(EVENT_HIDE);
  10023. $__default['default'](this._element).trigger(startEvent);
  10024. if (startEvent.isDefaultPrevented()) {
  10025. return;
  10026. }
  10027. var dimension = this._getDimension();
  10028. this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
  10029. Util.reflow(this._element);
  10030. $__default['default'](this._element).addClass(CLASS_NAME_COLLAPSING).removeClass(CLASS_NAME_COLLAPSE + " " + CLASS_NAME_SHOW$1);
  10031. var triggerArrayLength = this._triggerArray.length;
  10032. if (triggerArrayLength > 0) {
  10033. for (var i = 0; i < triggerArrayLength; i++) {
  10034. var trigger = this._triggerArray[i];
  10035. var selector = Util.getSelectorFromElement(trigger);
  10036. if (selector !== null) {
  10037. var $elem = $__default['default']([].slice.call(document.querySelectorAll(selector)));
  10038. if (!$elem.hasClass(CLASS_NAME_SHOW$1)) {
  10039. $__default['default'](trigger).addClass(CLASS_NAME_COLLAPSED).attr('aria-expanded', false);
  10040. }
  10041. }
  10042. }
  10043. }
  10044. this.setTransitioning(true);
  10045. var complete = function complete() {
  10046. _this2.setTransitioning(false);
  10047. $__default['default'](_this2._element).removeClass(CLASS_NAME_COLLAPSING).addClass(CLASS_NAME_COLLAPSE).trigger(EVENT_HIDDEN);
  10048. };
  10049. this._element.style[dimension] = '';
  10050. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  10051. $__default['default'](this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  10052. };
  10053. _proto.setTransitioning = function setTransitioning(isTransitioning) {
  10054. this._isTransitioning = isTransitioning;
  10055. };
  10056. _proto.dispose = function dispose() {
  10057. $__default['default'].removeData(this._element, DATA_KEY$3);
  10058. this._config = null;
  10059. this._parent = null;
  10060. this._element = null;
  10061. this._triggerArray = null;
  10062. this._isTransitioning = null;
  10063. } // Private
  10064. ;
  10065. _proto._getConfig = function _getConfig(config) {
  10066. config = _extends({}, Default$1, config);
  10067. config.toggle = Boolean(config.toggle); // Coerce string values
  10068. Util.typeCheckConfig(NAME$3, config, DefaultType$1);
  10069. return config;
  10070. };
  10071. _proto._getDimension = function _getDimension() {
  10072. var hasWidth = $__default['default'](this._element).hasClass(DIMENSION_WIDTH);
  10073. return hasWidth ? DIMENSION_WIDTH : DIMENSION_HEIGHT;
  10074. };
  10075. _proto._getParent = function _getParent() {
  10076. var _this3 = this;
  10077. var parent;
  10078. if (Util.isElement(this._config.parent)) {
  10079. parent = this._config.parent; // It's a jQuery object
  10080. if (typeof this._config.parent.jquery !== 'undefined') {
  10081. parent = this._config.parent[0];
  10082. }
  10083. } else {
  10084. parent = document.querySelector(this._config.parent);
  10085. }
  10086. var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
  10087. var children = [].slice.call(parent.querySelectorAll(selector));
  10088. $__default['default'](children).each(function (i, element) {
  10089. _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
  10090. });
  10091. return parent;
  10092. };
  10093. _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
  10094. var isOpen = $__default['default'](element).hasClass(CLASS_NAME_SHOW$1);
  10095. if (triggerArray.length) {
  10096. $__default['default'](triggerArray).toggleClass(CLASS_NAME_COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
  10097. }
  10098. } // Static
  10099. ;
  10100. Collapse._getTargetFromElement = function _getTargetFromElement(element) {
  10101. var selector = Util.getSelectorFromElement(element);
  10102. return selector ? document.querySelector(selector) : null;
  10103. };
  10104. Collapse._jQueryInterface = function _jQueryInterface(config) {
  10105. return this.each(function () {
  10106. var $element = $__default['default'](this);
  10107. var data = $element.data(DATA_KEY$3);
  10108. var _config = _extends({}, Default$1, $element.data(), typeof config === 'object' && config ? config : {});
  10109. if (!data && _config.toggle && typeof config === 'string' && /show|hide/.test(config)) {
  10110. _config.toggle = false;
  10111. }
  10112. if (!data) {
  10113. data = new Collapse(this, _config);
  10114. $element.data(DATA_KEY$3, data);
  10115. }
  10116. if (typeof config === 'string') {
  10117. if (typeof data[config] === 'undefined') {
  10118. throw new TypeError("No method named \"" + config + "\"");
  10119. }
  10120. data[config]();
  10121. }
  10122. });
  10123. };
  10124. _createClass(Collapse, null, [{
  10125. key: "VERSION",
  10126. get: function get() {
  10127. return VERSION$3;
  10128. }
  10129. }, {
  10130. key: "Default",
  10131. get: function get() {
  10132. return Default$1;
  10133. }
  10134. }]);
  10135. return Collapse;
  10136. }();
  10137. /**
  10138. * ------------------------------------------------------------------------
  10139. * Data Api implementation
  10140. * ------------------------------------------------------------------------
  10141. */
  10142. $__default['default'](document).on(EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$1, function (event) {
  10143. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  10144. if (event.currentTarget.tagName === 'A') {
  10145. event.preventDefault();
  10146. }
  10147. var $trigger = $__default['default'](this);
  10148. var selector = Util.getSelectorFromElement(this);
  10149. var selectors = [].slice.call(document.querySelectorAll(selector));
  10150. $__default['default'](selectors).each(function () {
  10151. var $target = $__default['default'](this);
  10152. var data = $target.data(DATA_KEY$3);
  10153. var config = data ? 'toggle' : $trigger.data();
  10154. Collapse._jQueryInterface.call($target, config);
  10155. });
  10156. });
  10157. /**
  10158. * ------------------------------------------------------------------------
  10159. * jQuery
  10160. * ------------------------------------------------------------------------
  10161. */
  10162. $__default['default'].fn[NAME$3] = Collapse._jQueryInterface;
  10163. $__default['default'].fn[NAME$3].Constructor = Collapse;
  10164. $__default['default'].fn[NAME$3].noConflict = function () {
  10165. $__default['default'].fn[NAME$3] = JQUERY_NO_CONFLICT$3;
  10166. return Collapse._jQueryInterface;
  10167. };
  10168. /**!
  10169. * @fileOverview Kickass library to create and place poppers near their reference elements.
  10170. * @version 1.16.1
  10171. * @license
  10172. * Copyright (c) 2016 Federico Zivolo and contributors
  10173. *
  10174. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10175. * of this software and associated documentation files (the "Software"), to deal
  10176. * in the Software without restriction, including without limitation the rights
  10177. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10178. * copies of the Software, and to permit persons to whom the Software is
  10179. * furnished to do so, subject to the following conditions:
  10180. *
  10181. * The above copyright notice and this permission notice shall be included in all
  10182. * copies or substantial portions of the Software.
  10183. *
  10184. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  10185. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  10186. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  10187. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  10188. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  10189. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  10190. * SOFTWARE.
  10191. */
  10192. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  10193. var timeoutDuration = function () {
  10194. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  10195. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  10196. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  10197. return 1;
  10198. }
  10199. }
  10200. return 0;
  10201. }();
  10202. function microtaskDebounce(fn) {
  10203. var called = false;
  10204. return function () {
  10205. if (called) {
  10206. return;
  10207. }
  10208. called = true;
  10209. window.Promise.resolve().then(function () {
  10210. called = false;
  10211. fn();
  10212. });
  10213. };
  10214. }
  10215. function taskDebounce(fn) {
  10216. var scheduled = false;
  10217. return function () {
  10218. if (!scheduled) {
  10219. scheduled = true;
  10220. setTimeout(function () {
  10221. scheduled = false;
  10222. fn();
  10223. }, timeoutDuration);
  10224. }
  10225. };
  10226. }
  10227. var supportsMicroTasks = isBrowser && window.Promise;
  10228. /**
  10229. * Create a debounced version of a method, that's asynchronously deferred
  10230. * but called in the minimum time possible.
  10231. *
  10232. * @method
  10233. * @memberof Popper.Utils
  10234. * @argument {Function} fn
  10235. * @returns {Function}
  10236. */
  10237. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  10238. /**
  10239. * Check if the given variable is a function
  10240. * @method
  10241. * @memberof Popper.Utils
  10242. * @argument {Any} functionToCheck - variable to check
  10243. * @returns {Boolean} answer to: is a function?
  10244. */
  10245. function isFunction(functionToCheck) {
  10246. var getType = {};
  10247. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  10248. }
  10249. /**
  10250. * Get CSS computed property of the given element
  10251. * @method
  10252. * @memberof Popper.Utils
  10253. * @argument {Eement} element
  10254. * @argument {String} property
  10255. */
  10256. function getStyleComputedProperty(element, property) {
  10257. if (element.nodeType !== 1) {
  10258. return [];
  10259. }
  10260. // NOTE: 1 DOM access here
  10261. var window = element.ownerDocument.defaultView;
  10262. var css = window.getComputedStyle(element, null);
  10263. return property ? css[property] : css;
  10264. }
  10265. /**
  10266. * Returns the parentNode or the host of the element
  10267. * @method
  10268. * @memberof Popper.Utils
  10269. * @argument {Element} element
  10270. * @returns {Element} parent
  10271. */
  10272. function getParentNode(element) {
  10273. if (element.nodeName === 'HTML') {
  10274. return element;
  10275. }
  10276. return element.parentNode || element.host;
  10277. }
  10278. /**
  10279. * Returns the scrolling parent of the given element
  10280. * @method
  10281. * @memberof Popper.Utils
  10282. * @argument {Element} element
  10283. * @returns {Element} scroll parent
  10284. */
  10285. function getScrollParent(element) {
  10286. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  10287. if (!element) {
  10288. return document.body;
  10289. }
  10290. switch (element.nodeName) {
  10291. case 'HTML':
  10292. case 'BODY':
  10293. return element.ownerDocument.body;
  10294. case '#document':
  10295. return element.body;
  10296. }
  10297. // Firefox want us to check `-x` and `-y` variations as well
  10298. var _getStyleComputedProp = getStyleComputedProperty(element),
  10299. overflow = _getStyleComputedProp.overflow,
  10300. overflowX = _getStyleComputedProp.overflowX,
  10301. overflowY = _getStyleComputedProp.overflowY;
  10302. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  10303. return element;
  10304. }
  10305. return getScrollParent(getParentNode(element));
  10306. }
  10307. /**
  10308. * Returns the reference node of the reference object, or the reference object itself.
  10309. * @method
  10310. * @memberof Popper.Utils
  10311. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  10312. * @returns {Element} parent
  10313. */
  10314. function getReferenceNode(reference) {
  10315. return reference && reference.referenceNode ? reference.referenceNode : reference;
  10316. }
  10317. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  10318. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  10319. /**
  10320. * Determines if the browser is Internet Explorer
  10321. * @method
  10322. * @memberof Popper.Utils
  10323. * @param {Number} version to check
  10324. * @returns {Boolean} isIE
  10325. */
  10326. function isIE(version) {
  10327. if (version === 11) {
  10328. return isIE11;
  10329. }
  10330. if (version === 10) {
  10331. return isIE10;
  10332. }
  10333. return isIE11 || isIE10;
  10334. }
  10335. /**
  10336. * Returns the offset parent of the given element
  10337. * @method
  10338. * @memberof Popper.Utils
  10339. * @argument {Element} element
  10340. * @returns {Element} offset parent
  10341. */
  10342. function getOffsetParent(element) {
  10343. if (!element) {
  10344. return document.documentElement;
  10345. }
  10346. var noOffsetParent = isIE(10) ? document.body : null;
  10347. // NOTE: 1 DOM access here
  10348. var offsetParent = element.offsetParent || null;
  10349. // Skip hidden elements which don't have an offsetParent
  10350. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  10351. offsetParent = (element = element.nextElementSibling).offsetParent;
  10352. }
  10353. var nodeName = offsetParent && offsetParent.nodeName;
  10354. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  10355. return element ? element.ownerDocument.documentElement : document.documentElement;
  10356. }
  10357. // .offsetParent will return the closest TH, TD or TABLE in case
  10358. // no offsetParent is present, I hate this job...
  10359. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  10360. return getOffsetParent(offsetParent);
  10361. }
  10362. return offsetParent;
  10363. }
  10364. function isOffsetContainer(element) {
  10365. var nodeName = element.nodeName;
  10366. if (nodeName === 'BODY') {
  10367. return false;
  10368. }
  10369. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  10370. }
  10371. /**
  10372. * Finds the root node (document, shadowDOM root) of the given element
  10373. * @method
  10374. * @memberof Popper.Utils
  10375. * @argument {Element} node
  10376. * @returns {Element} root node
  10377. */
  10378. function getRoot(node) {
  10379. if (node.parentNode !== null) {
  10380. return getRoot(node.parentNode);
  10381. }
  10382. return node;
  10383. }
  10384. /**
  10385. * Finds the offset parent common to the two provided nodes
  10386. * @method
  10387. * @memberof Popper.Utils
  10388. * @argument {Element} element1
  10389. * @argument {Element} element2
  10390. * @returns {Element} common offset parent
  10391. */
  10392. function findCommonOffsetParent(element1, element2) {
  10393. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  10394. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  10395. return document.documentElement;
  10396. }
  10397. // Here we make sure to give as "start" the element that comes first in the DOM
  10398. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  10399. var start = order ? element1 : element2;
  10400. var end = order ? element2 : element1;
  10401. // Get common ancestor container
  10402. var range = document.createRange();
  10403. range.setStart(start, 0);
  10404. range.setEnd(end, 0);
  10405. var commonAncestorContainer = range.commonAncestorContainer;
  10406. // Both nodes are inside #document
  10407. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  10408. if (isOffsetContainer(commonAncestorContainer)) {
  10409. return commonAncestorContainer;
  10410. }
  10411. return getOffsetParent(commonAncestorContainer);
  10412. }
  10413. // one of the nodes is inside shadowDOM, find which one
  10414. var element1root = getRoot(element1);
  10415. if (element1root.host) {
  10416. return findCommonOffsetParent(element1root.host, element2);
  10417. } else {
  10418. return findCommonOffsetParent(element1, getRoot(element2).host);
  10419. }
  10420. }
  10421. /**
  10422. * Gets the scroll value of the given element in the given side (top and left)
  10423. * @method
  10424. * @memberof Popper.Utils
  10425. * @argument {Element} element
  10426. * @argument {String} side `top` or `left`
  10427. * @returns {number} amount of scrolled pixels
  10428. */
  10429. function getScroll(element) {
  10430. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  10431. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  10432. var nodeName = element.nodeName;
  10433. if (nodeName === 'BODY' || nodeName === 'HTML') {
  10434. var html = element.ownerDocument.documentElement;
  10435. var scrollingElement = element.ownerDocument.scrollingElement || html;
  10436. return scrollingElement[upperSide];
  10437. }
  10438. return element[upperSide];
  10439. }
  10440. /*
  10441. * Sum or subtract the element scroll values (left and top) from a given rect object
  10442. * @method
  10443. * @memberof Popper.Utils
  10444. * @param {Object} rect - Rect object you want to change
  10445. * @param {HTMLElement} element - The element from the function reads the scroll values
  10446. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  10447. * @return {Object} rect - The modifier rect object
  10448. */
  10449. function includeScroll(rect, element) {
  10450. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  10451. var scrollTop = getScroll(element, 'top');
  10452. var scrollLeft = getScroll(element, 'left');
  10453. var modifier = subtract ? -1 : 1;
  10454. rect.top += scrollTop * modifier;
  10455. rect.bottom += scrollTop * modifier;
  10456. rect.left += scrollLeft * modifier;
  10457. rect.right += scrollLeft * modifier;
  10458. return rect;
  10459. }
  10460. /*
  10461. * Helper to detect borders of a given element
  10462. * @method
  10463. * @memberof Popper.Utils
  10464. * @param {CSSStyleDeclaration} styles
  10465. * Result of `getStyleComputedProperty` on the given element
  10466. * @param {String} axis - `x` or `y`
  10467. * @return {number} borders - The borders size of the given axis
  10468. */
  10469. function getBordersSize(styles, axis) {
  10470. var sideA = axis === 'x' ? 'Left' : 'Top';
  10471. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  10472. return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
  10473. }
  10474. function getSize(axis, body, html, computedStyle) {
  10475. return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE(10) ? parseInt(html['offset' + axis]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')]) : 0);
  10476. }
  10477. function getWindowSizes(document) {
  10478. var body = document.body;
  10479. var html = document.documentElement;
  10480. var computedStyle = isIE(10) && getComputedStyle(html);
  10481. return {
  10482. height: getSize('Height', body, html, computedStyle),
  10483. width: getSize('Width', body, html, computedStyle)
  10484. };
  10485. }
  10486. var classCallCheck = function (instance, Constructor) {
  10487. if (!(instance instanceof Constructor)) {
  10488. throw new TypeError("Cannot call a class as a function");
  10489. }
  10490. };
  10491. var createClass = function () {
  10492. function defineProperties(target, props) {
  10493. for (var i = 0; i < props.length; i++) {
  10494. var descriptor = props[i];
  10495. descriptor.enumerable = descriptor.enumerable || false;
  10496. descriptor.configurable = true;
  10497. if ("value" in descriptor) descriptor.writable = true;
  10498. Object.defineProperty(target, descriptor.key, descriptor);
  10499. }
  10500. }
  10501. return function (Constructor, protoProps, staticProps) {
  10502. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  10503. if (staticProps) defineProperties(Constructor, staticProps);
  10504. return Constructor;
  10505. };
  10506. }();
  10507. var defineProperty = function (obj, key, value) {
  10508. if (key in obj) {
  10509. Object.defineProperty(obj, key, {
  10510. value: value,
  10511. enumerable: true,
  10512. configurable: true,
  10513. writable: true
  10514. });
  10515. } else {
  10516. obj[key] = value;
  10517. }
  10518. return obj;
  10519. };
  10520. var _extends$1 = Object.assign || function (target) {
  10521. for (var i = 1; i < arguments.length; i++) {
  10522. var source = arguments[i];
  10523. for (var key in source) {
  10524. if (Object.prototype.hasOwnProperty.call(source, key)) {
  10525. target[key] = source[key];
  10526. }
  10527. }
  10528. }
  10529. return target;
  10530. };
  10531. /**
  10532. * Given element offsets, generate an output similar to getBoundingClientRect
  10533. * @method
  10534. * @memberof Popper.Utils
  10535. * @argument {Object} offsets
  10536. * @returns {Object} ClientRect like output
  10537. */
  10538. function getClientRect(offsets) {
  10539. return _extends$1({}, offsets, {
  10540. right: offsets.left + offsets.width,
  10541. bottom: offsets.top + offsets.height
  10542. });
  10543. }
  10544. /**
  10545. * Get bounding client rect of given element
  10546. * @method
  10547. * @memberof Popper.Utils
  10548. * @param {HTMLElement} element
  10549. * @return {Object} client rect
  10550. */
  10551. function getBoundingClientRect(element) {
  10552. var rect = {};
  10553. // IE10 10 FIX: Please, don't ask, the element isn't
  10554. // considered in DOM in some circumstances...
  10555. // This isn't reproducible in IE10 compatibility mode of IE11
  10556. try {
  10557. if (isIE(10)) {
  10558. rect = element.getBoundingClientRect();
  10559. var scrollTop = getScroll(element, 'top');
  10560. var scrollLeft = getScroll(element, 'left');
  10561. rect.top += scrollTop;
  10562. rect.left += scrollLeft;
  10563. rect.bottom += scrollTop;
  10564. rect.right += scrollLeft;
  10565. } else {
  10566. rect = element.getBoundingClientRect();
  10567. }
  10568. } catch (e) {}
  10569. var result = {
  10570. left: rect.left,
  10571. top: rect.top,
  10572. width: rect.right - rect.left,
  10573. height: rect.bottom - rect.top
  10574. };
  10575. // subtract scrollbar size from sizes
  10576. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  10577. var width = sizes.width || element.clientWidth || result.width;
  10578. var height = sizes.height || element.clientHeight || result.height;
  10579. var horizScrollbar = element.offsetWidth - width;
  10580. var vertScrollbar = element.offsetHeight - height;
  10581. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  10582. // we make this check conditional for performance reasons
  10583. if (horizScrollbar || vertScrollbar) {
  10584. var styles = getStyleComputedProperty(element);
  10585. horizScrollbar -= getBordersSize(styles, 'x');
  10586. vertScrollbar -= getBordersSize(styles, 'y');
  10587. result.width -= horizScrollbar;
  10588. result.height -= vertScrollbar;
  10589. }
  10590. return getClientRect(result);
  10591. }
  10592. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  10593. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  10594. var isIE10 = isIE(10);
  10595. var isHTML = parent.nodeName === 'HTML';
  10596. var childrenRect = getBoundingClientRect(children);
  10597. var parentRect = getBoundingClientRect(parent);
  10598. var scrollParent = getScrollParent(children);
  10599. var styles = getStyleComputedProperty(parent);
  10600. var borderTopWidth = parseFloat(styles.borderTopWidth);
  10601. var borderLeftWidth = parseFloat(styles.borderLeftWidth);
  10602. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  10603. if (fixedPosition && isHTML) {
  10604. parentRect.top = Math.max(parentRect.top, 0);
  10605. parentRect.left = Math.max(parentRect.left, 0);
  10606. }
  10607. var offsets = getClientRect({
  10608. top: childrenRect.top - parentRect.top - borderTopWidth,
  10609. left: childrenRect.left - parentRect.left - borderLeftWidth,
  10610. width: childrenRect.width,
  10611. height: childrenRect.height
  10612. });
  10613. offsets.marginTop = 0;
  10614. offsets.marginLeft = 0;
  10615. // Subtract margins of documentElement in case it's being used as parent
  10616. // we do this only on HTML because it's the only element that behaves
  10617. // differently when margins are applied to it. The margins are included in
  10618. // the box of the documentElement, in the other cases not.
  10619. if (!isIE10 && isHTML) {
  10620. var marginTop = parseFloat(styles.marginTop);
  10621. var marginLeft = parseFloat(styles.marginLeft);
  10622. offsets.top -= borderTopWidth - marginTop;
  10623. offsets.bottom -= borderTopWidth - marginTop;
  10624. offsets.left -= borderLeftWidth - marginLeft;
  10625. offsets.right -= borderLeftWidth - marginLeft;
  10626. // Attach marginTop and marginLeft because in some circumstances we may need them
  10627. offsets.marginTop = marginTop;
  10628. offsets.marginLeft = marginLeft;
  10629. }
  10630. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  10631. offsets = includeScroll(offsets, parent);
  10632. }
  10633. return offsets;
  10634. }
  10635. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  10636. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10637. var html = element.ownerDocument.documentElement;
  10638. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  10639. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  10640. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  10641. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  10642. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  10643. var offset = {
  10644. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  10645. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  10646. width: width,
  10647. height: height
  10648. };
  10649. return getClientRect(offset);
  10650. }
  10651. /**
  10652. * Check if the given element is fixed or is inside a fixed parent
  10653. * @method
  10654. * @memberof Popper.Utils
  10655. * @argument {Element} element
  10656. * @argument {Element} customContainer
  10657. * @returns {Boolean} answer to "isFixed?"
  10658. */
  10659. function isFixed(element) {
  10660. var nodeName = element.nodeName;
  10661. if (nodeName === 'BODY' || nodeName === 'HTML') {
  10662. return false;
  10663. }
  10664. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  10665. return true;
  10666. }
  10667. var parentNode = getParentNode(element);
  10668. if (!parentNode) {
  10669. return false;
  10670. }
  10671. return isFixed(parentNode);
  10672. }
  10673. /**
  10674. * Finds the first parent of an element that has a transformed property defined
  10675. * @method
  10676. * @memberof Popper.Utils
  10677. * @argument {Element} element
  10678. * @returns {Element} first transformed parent or documentElement
  10679. */
  10680. function getFixedPositionOffsetParent(element) {
  10681. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  10682. if (!element || !element.parentElement || isIE()) {
  10683. return document.documentElement;
  10684. }
  10685. var el = element.parentElement;
  10686. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  10687. el = el.parentElement;
  10688. }
  10689. return el || document.documentElement;
  10690. }
  10691. /**
  10692. * Computed the boundaries limits and return them
  10693. * @method
  10694. * @memberof Popper.Utils
  10695. * @param {HTMLElement} popper
  10696. * @param {HTMLElement} reference
  10697. * @param {number} padding
  10698. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  10699. * @param {Boolean} fixedPosition - Is in fixed position mode
  10700. * @returns {Object} Coordinates of the boundaries
  10701. */
  10702. function getBoundaries(popper, reference, padding, boundariesElement) {
  10703. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  10704. // NOTE: 1 DOM access here
  10705. var boundaries = { top: 0, left: 0 };
  10706. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  10707. // Handle viewport case
  10708. if (boundariesElement === 'viewport') {
  10709. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  10710. } else {
  10711. // Handle other cases based on DOM element used as boundaries
  10712. var boundariesNode = void 0;
  10713. if (boundariesElement === 'scrollParent') {
  10714. boundariesNode = getScrollParent(getParentNode(reference));
  10715. if (boundariesNode.nodeName === 'BODY') {
  10716. boundariesNode = popper.ownerDocument.documentElement;
  10717. }
  10718. } else if (boundariesElement === 'window') {
  10719. boundariesNode = popper.ownerDocument.documentElement;
  10720. } else {
  10721. boundariesNode = boundariesElement;
  10722. }
  10723. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  10724. // In case of HTML, we need a different computation
  10725. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  10726. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  10727. height = _getWindowSizes.height,
  10728. width = _getWindowSizes.width;
  10729. boundaries.top += offsets.top - offsets.marginTop;
  10730. boundaries.bottom = height + offsets.top;
  10731. boundaries.left += offsets.left - offsets.marginLeft;
  10732. boundaries.right = width + offsets.left;
  10733. } else {
  10734. // for all the other DOM elements, this one is good
  10735. boundaries = offsets;
  10736. }
  10737. }
  10738. // Add paddings
  10739. padding = padding || 0;
  10740. var isPaddingNumber = typeof padding === 'number';
  10741. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  10742. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  10743. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  10744. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  10745. return boundaries;
  10746. }
  10747. function getArea(_ref) {
  10748. var width = _ref.width,
  10749. height = _ref.height;
  10750. return width * height;
  10751. }
  10752. /**
  10753. * Utility used to transform the `auto` placement to the placement with more
  10754. * available space.
  10755. * @method
  10756. * @memberof Popper.Utils
  10757. * @argument {Object} data - The data object generated by update method
  10758. * @argument {Object} options - Modifiers configuration and options
  10759. * @returns {Object} The data object, properly modified
  10760. */
  10761. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  10762. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  10763. if (placement.indexOf('auto') === -1) {
  10764. return placement;
  10765. }
  10766. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  10767. var rects = {
  10768. top: {
  10769. width: boundaries.width,
  10770. height: refRect.top - boundaries.top
  10771. },
  10772. right: {
  10773. width: boundaries.right - refRect.right,
  10774. height: boundaries.height
  10775. },
  10776. bottom: {
  10777. width: boundaries.width,
  10778. height: boundaries.bottom - refRect.bottom
  10779. },
  10780. left: {
  10781. width: refRect.left - boundaries.left,
  10782. height: boundaries.height
  10783. }
  10784. };
  10785. var sortedAreas = Object.keys(rects).map(function (key) {
  10786. return _extends$1({
  10787. key: key
  10788. }, rects[key], {
  10789. area: getArea(rects[key])
  10790. });
  10791. }).sort(function (a, b) {
  10792. return b.area - a.area;
  10793. });
  10794. var filteredAreas = sortedAreas.filter(function (_ref2) {
  10795. var width = _ref2.width,
  10796. height = _ref2.height;
  10797. return width >= popper.clientWidth && height >= popper.clientHeight;
  10798. });
  10799. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  10800. var variation = placement.split('-')[1];
  10801. return computedPlacement + (variation ? '-' + variation : '');
  10802. }
  10803. /**
  10804. * Get offsets to the reference element
  10805. * @method
  10806. * @memberof Popper.Utils
  10807. * @param {Object} state
  10808. * @param {Element} popper - the popper element
  10809. * @param {Element} reference - the reference element (the popper will be relative to this)
  10810. * @param {Element} fixedPosition - is in fixed position mode
  10811. * @returns {Object} An object containing the offsets which will be applied to the popper
  10812. */
  10813. function getReferenceOffsets(state, popper, reference) {
  10814. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  10815. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  10816. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  10817. }
  10818. /**
  10819. * Get the outer sizes of the given element (offset size + margins)
  10820. * @method
  10821. * @memberof Popper.Utils
  10822. * @argument {Element} element
  10823. * @returns {Object} object containing width and height properties
  10824. */
  10825. function getOuterSizes(element) {
  10826. var window = element.ownerDocument.defaultView;
  10827. var styles = window.getComputedStyle(element);
  10828. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  10829. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  10830. var result = {
  10831. width: element.offsetWidth + y,
  10832. height: element.offsetHeight + x
  10833. };
  10834. return result;
  10835. }
  10836. /**
  10837. * Get the opposite placement of the given one
  10838. * @method
  10839. * @memberof Popper.Utils
  10840. * @argument {String} placement
  10841. * @returns {String} flipped placement
  10842. */
  10843. function getOppositePlacement(placement) {
  10844. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  10845. return placement.replace(/left|right|bottom|top/g, function (matched) {
  10846. return hash[matched];
  10847. });
  10848. }
  10849. /**
  10850. * Get offsets to the popper
  10851. * @method
  10852. * @memberof Popper.Utils
  10853. * @param {Object} position - CSS position the Popper will get applied
  10854. * @param {HTMLElement} popper - the popper element
  10855. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  10856. * @param {String} placement - one of the valid placement options
  10857. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  10858. */
  10859. function getPopperOffsets(popper, referenceOffsets, placement) {
  10860. placement = placement.split('-')[0];
  10861. // Get popper node sizes
  10862. var popperRect = getOuterSizes(popper);
  10863. // Add position, width and height to our offsets object
  10864. var popperOffsets = {
  10865. width: popperRect.width,
  10866. height: popperRect.height
  10867. };
  10868. // depending by the popper placement we have to compute its offsets slightly differently
  10869. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  10870. var mainSide = isHoriz ? 'top' : 'left';
  10871. var secondarySide = isHoriz ? 'left' : 'top';
  10872. var measurement = isHoriz ? 'height' : 'width';
  10873. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  10874. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  10875. if (placement === secondarySide) {
  10876. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  10877. } else {
  10878. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  10879. }
  10880. return popperOffsets;
  10881. }
  10882. /**
  10883. * Mimics the `find` method of Array
  10884. * @method
  10885. * @memberof Popper.Utils
  10886. * @argument {Array} arr
  10887. * @argument prop
  10888. * @argument value
  10889. * @returns index or -1
  10890. */
  10891. function find(arr, check) {
  10892. // use native find if supported
  10893. if (Array.prototype.find) {
  10894. return arr.find(check);
  10895. }
  10896. // use `filter` to obtain the same behavior of `find`
  10897. return arr.filter(check)[0];
  10898. }
  10899. /**
  10900. * Return the index of the matching object
  10901. * @method
  10902. * @memberof Popper.Utils
  10903. * @argument {Array} arr
  10904. * @argument prop
  10905. * @argument value
  10906. * @returns index or -1
  10907. */
  10908. function findIndex(arr, prop, value) {
  10909. // use native findIndex if supported
  10910. if (Array.prototype.findIndex) {
  10911. return arr.findIndex(function (cur) {
  10912. return cur[prop] === value;
  10913. });
  10914. }
  10915. // use `find` + `indexOf` if `findIndex` isn't supported
  10916. var match = find(arr, function (obj) {
  10917. return obj[prop] === value;
  10918. });
  10919. return arr.indexOf(match);
  10920. }
  10921. /**
  10922. * Loop trough the list of modifiers and run them in order,
  10923. * each of them will then edit the data object.
  10924. * @method
  10925. * @memberof Popper.Utils
  10926. * @param {dataObject} data
  10927. * @param {Array} modifiers
  10928. * @param {String} ends - Optional modifier name used as stopper
  10929. * @returns {dataObject}
  10930. */
  10931. function runModifiers(modifiers, data, ends) {
  10932. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  10933. modifiersToRun.forEach(function (modifier) {
  10934. if (modifier['function']) {
  10935. // eslint-disable-line dot-notation
  10936. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  10937. }
  10938. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  10939. if (modifier.enabled && isFunction(fn)) {
  10940. // Add properties to offsets to make them a complete clientRect object
  10941. // we do this before each modifier to make sure the previous one doesn't
  10942. // mess with these values
  10943. data.offsets.popper = getClientRect(data.offsets.popper);
  10944. data.offsets.reference = getClientRect(data.offsets.reference);
  10945. data = fn(data, modifier);
  10946. }
  10947. });
  10948. return data;
  10949. }
  10950. /**
  10951. * Updates the position of the popper, computing the new offsets and applying
  10952. * the new style.<br />
  10953. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  10954. * @method
  10955. * @memberof Popper
  10956. */
  10957. function update() {
  10958. // if popper is destroyed, don't perform any further update
  10959. if (this.state.isDestroyed) {
  10960. return;
  10961. }
  10962. var data = {
  10963. instance: this,
  10964. styles: {},
  10965. arrowStyles: {},
  10966. attributes: {},
  10967. flipped: false,
  10968. offsets: {}
  10969. };
  10970. // compute reference element offsets
  10971. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  10972. // compute auto placement, store placement inside the data object,
  10973. // modifiers will be able to edit `placement` if needed
  10974. // and refer to originalPlacement to know the original value
  10975. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  10976. // store the computed placement inside `originalPlacement`
  10977. data.originalPlacement = data.placement;
  10978. data.positionFixed = this.options.positionFixed;
  10979. // compute the popper offsets
  10980. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  10981. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  10982. // run the modifiers
  10983. data = runModifiers(this.modifiers, data);
  10984. // the first `update` will call `onCreate` callback
  10985. // the other ones will call `onUpdate` callback
  10986. if (!this.state.isCreated) {
  10987. this.state.isCreated = true;
  10988. this.options.onCreate(data);
  10989. } else {
  10990. this.options.onUpdate(data);
  10991. }
  10992. }
  10993. /**
  10994. * Helper used to know if the given modifier is enabled.
  10995. * @method
  10996. * @memberof Popper.Utils
  10997. * @returns {Boolean}
  10998. */
  10999. function isModifierEnabled(modifiers, modifierName) {
  11000. return modifiers.some(function (_ref) {
  11001. var name = _ref.name,
  11002. enabled = _ref.enabled;
  11003. return enabled && name === modifierName;
  11004. });
  11005. }
  11006. /**
  11007. * Get the prefixed supported property name
  11008. * @method
  11009. * @memberof Popper.Utils
  11010. * @argument {String} property (camelCase)
  11011. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  11012. */
  11013. function getSupportedPropertyName(property) {
  11014. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  11015. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  11016. for (var i = 0; i < prefixes.length; i++) {
  11017. var prefix = prefixes[i];
  11018. var toCheck = prefix ? '' + prefix + upperProp : property;
  11019. if (typeof document.body.style[toCheck] !== 'undefined') {
  11020. return toCheck;
  11021. }
  11022. }
  11023. return null;
  11024. }
  11025. /**
  11026. * Destroys the popper.
  11027. * @method
  11028. * @memberof Popper
  11029. */
  11030. function destroy() {
  11031. this.state.isDestroyed = true;
  11032. // touch DOM only if `applyStyle` modifier is enabled
  11033. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  11034. this.popper.removeAttribute('x-placement');
  11035. this.popper.style.position = '';
  11036. this.popper.style.top = '';
  11037. this.popper.style.left = '';
  11038. this.popper.style.right = '';
  11039. this.popper.style.bottom = '';
  11040. this.popper.style.willChange = '';
  11041. this.popper.style[getSupportedPropertyName('transform')] = '';
  11042. }
  11043. this.disableEventListeners();
  11044. // remove the popper if user explicitly asked for the deletion on destroy
  11045. // do not use `remove` because IE11 doesn't support it
  11046. if (this.options.removeOnDestroy) {
  11047. this.popper.parentNode.removeChild(this.popper);
  11048. }
  11049. return this;
  11050. }
  11051. /**
  11052. * Get the window associated with the element
  11053. * @argument {Element} element
  11054. * @returns {Window}
  11055. */
  11056. function getWindow(element) {
  11057. var ownerDocument = element.ownerDocument;
  11058. return ownerDocument ? ownerDocument.defaultView : window;
  11059. }
  11060. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  11061. var isBody = scrollParent.nodeName === 'BODY';
  11062. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  11063. target.addEventListener(event, callback, { passive: true });
  11064. if (!isBody) {
  11065. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  11066. }
  11067. scrollParents.push(target);
  11068. }
  11069. /**
  11070. * Setup needed event listeners used to update the popper position
  11071. * @method
  11072. * @memberof Popper.Utils
  11073. * @private
  11074. */
  11075. function setupEventListeners(reference, options, state, updateBound) {
  11076. // Resize event listener on window
  11077. state.updateBound = updateBound;
  11078. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  11079. // Scroll event listener on scroll parents
  11080. var scrollElement = getScrollParent(reference);
  11081. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  11082. state.scrollElement = scrollElement;
  11083. state.eventsEnabled = true;
  11084. return state;
  11085. }
  11086. /**
  11087. * It will add resize/scroll events and start recalculating
  11088. * position of the popper element when they are triggered.
  11089. * @method
  11090. * @memberof Popper
  11091. */
  11092. function enableEventListeners() {
  11093. if (!this.state.eventsEnabled) {
  11094. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  11095. }
  11096. }
  11097. /**
  11098. * Remove event listeners used to update the popper position
  11099. * @method
  11100. * @memberof Popper.Utils
  11101. * @private
  11102. */
  11103. function removeEventListeners(reference, state) {
  11104. // Remove resize event listener on window
  11105. getWindow(reference).removeEventListener('resize', state.updateBound);
  11106. // Remove scroll event listener on scroll parents
  11107. state.scrollParents.forEach(function (target) {
  11108. target.removeEventListener('scroll', state.updateBound);
  11109. });
  11110. // Reset state
  11111. state.updateBound = null;
  11112. state.scrollParents = [];
  11113. state.scrollElement = null;
  11114. state.eventsEnabled = false;
  11115. return state;
  11116. }
  11117. /**
  11118. * It will remove resize/scroll events and won't recalculate popper position
  11119. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  11120. * unless you call `update` method manually.
  11121. * @method
  11122. * @memberof Popper
  11123. */
  11124. function disableEventListeners() {
  11125. if (this.state.eventsEnabled) {
  11126. cancelAnimationFrame(this.scheduleUpdate);
  11127. this.state = removeEventListeners(this.reference, this.state);
  11128. }
  11129. }
  11130. /**
  11131. * Tells if a given input is a number
  11132. * @method
  11133. * @memberof Popper.Utils
  11134. * @param {*} input to check
  11135. * @return {Boolean}
  11136. */
  11137. function isNumeric(n) {
  11138. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  11139. }
  11140. /**
  11141. * Set the style to the given popper
  11142. * @method
  11143. * @memberof Popper.Utils
  11144. * @argument {Element} element - Element to apply the style to
  11145. * @argument {Object} styles
  11146. * Object with a list of properties and values which will be applied to the element
  11147. */
  11148. function setStyles(element, styles) {
  11149. Object.keys(styles).forEach(function (prop) {
  11150. var unit = '';
  11151. // add unit if the value is numeric and is one of the following
  11152. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  11153. unit = 'px';
  11154. }
  11155. element.style[prop] = styles[prop] + unit;
  11156. });
  11157. }
  11158. /**
  11159. * Set the attributes to the given popper
  11160. * @method
  11161. * @memberof Popper.Utils
  11162. * @argument {Element} element - Element to apply the attributes to
  11163. * @argument {Object} styles
  11164. * Object with a list of properties and values which will be applied to the element
  11165. */
  11166. function setAttributes(element, attributes) {
  11167. Object.keys(attributes).forEach(function (prop) {
  11168. var value = attributes[prop];
  11169. if (value !== false) {
  11170. element.setAttribute(prop, attributes[prop]);
  11171. } else {
  11172. element.removeAttribute(prop);
  11173. }
  11174. });
  11175. }
  11176. /**
  11177. * @function
  11178. * @memberof Modifiers
  11179. * @argument {Object} data - The data object generated by `update` method
  11180. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  11181. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  11182. * @argument {Object} options - Modifiers configuration and options
  11183. * @returns {Object} The same data object
  11184. */
  11185. function applyStyle(data) {
  11186. // any property present in `data.styles` will be applied to the popper,
  11187. // in this way we can make the 3rd party modifiers add custom styles to it
  11188. // Be aware, modifiers could override the properties defined in the previous
  11189. // lines of this modifier!
  11190. setStyles(data.instance.popper, data.styles);
  11191. // any property present in `data.attributes` will be applied to the popper,
  11192. // they will be set as HTML attributes of the element
  11193. setAttributes(data.instance.popper, data.attributes);
  11194. // if arrowElement is defined and arrowStyles has some properties
  11195. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  11196. setStyles(data.arrowElement, data.arrowStyles);
  11197. }
  11198. return data;
  11199. }
  11200. /**
  11201. * Set the x-placement attribute before everything else because it could be used
  11202. * to add margins to the popper margins needs to be calculated to get the
  11203. * correct popper offsets.
  11204. * @method
  11205. * @memberof Popper.modifiers
  11206. * @param {HTMLElement} reference - The reference element used to position the popper
  11207. * @param {HTMLElement} popper - The HTML element used as popper
  11208. * @param {Object} options - Popper.js options
  11209. */
  11210. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  11211. // compute reference element offsets
  11212. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  11213. // compute auto placement, store placement inside the data object,
  11214. // modifiers will be able to edit `placement` if needed
  11215. // and refer to originalPlacement to know the original value
  11216. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  11217. popper.setAttribute('x-placement', placement);
  11218. // Apply `position` to popper before anything else because
  11219. // without the position applied we can't guarantee correct computations
  11220. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  11221. return options;
  11222. }
  11223. /**
  11224. * @function
  11225. * @memberof Popper.Utils
  11226. * @argument {Object} data - The data object generated by `update` method
  11227. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  11228. * @returns {Object} The popper's position offsets rounded
  11229. *
  11230. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  11231. * good as it can be within reason.
  11232. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  11233. *
  11234. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  11235. * as well on High DPI screens).
  11236. *
  11237. * Firefox prefers no rounding for positioning and does not have blurriness on
  11238. * high DPI screens.
  11239. *
  11240. * Only horizontal placement and left/right values need to be considered.
  11241. */
  11242. function getRoundedOffsets(data, shouldRound) {
  11243. var _data$offsets = data.offsets,
  11244. popper = _data$offsets.popper,
  11245. reference = _data$offsets.reference;
  11246. var round = Math.round,
  11247. floor = Math.floor;
  11248. var noRound = function noRound(v) {
  11249. return v;
  11250. };
  11251. var referenceWidth = round(reference.width);
  11252. var popperWidth = round(popper.width);
  11253. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  11254. var isVariation = data.placement.indexOf('-') !== -1;
  11255. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  11256. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  11257. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  11258. var verticalToInteger = !shouldRound ? noRound : round;
  11259. return {
  11260. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  11261. top: verticalToInteger(popper.top),
  11262. bottom: verticalToInteger(popper.bottom),
  11263. right: horizontalToInteger(popper.right)
  11264. };
  11265. }
  11266. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  11267. /**
  11268. * @function
  11269. * @memberof Modifiers
  11270. * @argument {Object} data - The data object generated by `update` method
  11271. * @argument {Object} options - Modifiers configuration and options
  11272. * @returns {Object} The data object, properly modified
  11273. */
  11274. function computeStyle(data, options) {
  11275. var x = options.x,
  11276. y = options.y;
  11277. var popper = data.offsets.popper;
  11278. // Remove this legacy support in Popper.js v2
  11279. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  11280. return modifier.name === 'applyStyle';
  11281. }).gpuAcceleration;
  11282. if (legacyGpuAccelerationOption !== undefined) {
  11283. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  11284. }
  11285. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  11286. var offsetParent = getOffsetParent(data.instance.popper);
  11287. var offsetParentRect = getBoundingClientRect(offsetParent);
  11288. // Styles
  11289. var styles = {
  11290. position: popper.position
  11291. };
  11292. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  11293. var sideA = x === 'bottom' ? 'top' : 'bottom';
  11294. var sideB = y === 'right' ? 'left' : 'right';
  11295. // if gpuAcceleration is set to `true` and transform is supported,
  11296. // we use `translate3d` to apply the position to the popper we
  11297. // automatically use the supported prefixed version if needed
  11298. var prefixedProperty = getSupportedPropertyName('transform');
  11299. // now, let's make a step back and look at this code closely (wtf?)
  11300. // If the content of the popper grows once it's been positioned, it
  11301. // may happen that the popper gets misplaced because of the new content
  11302. // overflowing its reference element
  11303. // To avoid this problem, we provide two options (x and y), which allow
  11304. // the consumer to define the offset origin.
  11305. // If we position a popper on top of a reference element, we can set
  11306. // `x` to `top` to make the popper grow towards its top instead of
  11307. // its bottom.
  11308. var left = void 0,
  11309. top = void 0;
  11310. if (sideA === 'bottom') {
  11311. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  11312. // and not the bottom of the html element
  11313. if (offsetParent.nodeName === 'HTML') {
  11314. top = -offsetParent.clientHeight + offsets.bottom;
  11315. } else {
  11316. top = -offsetParentRect.height + offsets.bottom;
  11317. }
  11318. } else {
  11319. top = offsets.top;
  11320. }
  11321. if (sideB === 'right') {
  11322. if (offsetParent.nodeName === 'HTML') {
  11323. left = -offsetParent.clientWidth + offsets.right;
  11324. } else {
  11325. left = -offsetParentRect.width + offsets.right;
  11326. }
  11327. } else {
  11328. left = offsets.left;
  11329. }
  11330. if (gpuAcceleration && prefixedProperty) {
  11331. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  11332. styles[sideA] = 0;
  11333. styles[sideB] = 0;
  11334. styles.willChange = 'transform';
  11335. } else {
  11336. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  11337. var invertTop = sideA === 'bottom' ? -1 : 1;
  11338. var invertLeft = sideB === 'right' ? -1 : 1;
  11339. styles[sideA] = top * invertTop;
  11340. styles[sideB] = left * invertLeft;
  11341. styles.willChange = sideA + ', ' + sideB;
  11342. }
  11343. // Attributes
  11344. var attributes = {
  11345. 'x-placement': data.placement
  11346. };
  11347. // Update `data` attributes, styles and arrowStyles
  11348. data.attributes = _extends$1({}, attributes, data.attributes);
  11349. data.styles = _extends$1({}, styles, data.styles);
  11350. data.arrowStyles = _extends$1({}, data.offsets.arrow, data.arrowStyles);
  11351. return data;
  11352. }
  11353. /**
  11354. * Helper used to know if the given modifier depends from another one.<br />
  11355. * It checks if the needed modifier is listed and enabled.
  11356. * @method
  11357. * @memberof Popper.Utils
  11358. * @param {Array} modifiers - list of modifiers
  11359. * @param {String} requestingName - name of requesting modifier
  11360. * @param {String} requestedName - name of requested modifier
  11361. * @returns {Boolean}
  11362. */
  11363. function isModifierRequired(modifiers, requestingName, requestedName) {
  11364. var requesting = find(modifiers, function (_ref) {
  11365. var name = _ref.name;
  11366. return name === requestingName;
  11367. });
  11368. var isRequired = !!requesting && modifiers.some(function (modifier) {
  11369. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  11370. });
  11371. if (!isRequired) {
  11372. var _requesting = '`' + requestingName + '`';
  11373. var requested = '`' + requestedName + '`';
  11374. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  11375. }
  11376. return isRequired;
  11377. }
  11378. /**
  11379. * @function
  11380. * @memberof Modifiers
  11381. * @argument {Object} data - The data object generated by update method
  11382. * @argument {Object} options - Modifiers configuration and options
  11383. * @returns {Object} The data object, properly modified
  11384. */
  11385. function arrow(data, options) {
  11386. var _data$offsets$arrow;
  11387. // arrow depends on keepTogether in order to work
  11388. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  11389. return data;
  11390. }
  11391. var arrowElement = options.element;
  11392. // if arrowElement is a string, suppose it's a CSS selector
  11393. if (typeof arrowElement === 'string') {
  11394. arrowElement = data.instance.popper.querySelector(arrowElement);
  11395. // if arrowElement is not found, don't run the modifier
  11396. if (!arrowElement) {
  11397. return data;
  11398. }
  11399. } else {
  11400. // if the arrowElement isn't a query selector we must check that the
  11401. // provided DOM node is child of its popper node
  11402. if (!data.instance.popper.contains(arrowElement)) {
  11403. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  11404. return data;
  11405. }
  11406. }
  11407. var placement = data.placement.split('-')[0];
  11408. var _data$offsets = data.offsets,
  11409. popper = _data$offsets.popper,
  11410. reference = _data$offsets.reference;
  11411. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  11412. var len = isVertical ? 'height' : 'width';
  11413. var sideCapitalized = isVertical ? 'Top' : 'Left';
  11414. var side = sideCapitalized.toLowerCase();
  11415. var altSide = isVertical ? 'left' : 'top';
  11416. var opSide = isVertical ? 'bottom' : 'right';
  11417. var arrowElementSize = getOuterSizes(arrowElement)[len];
  11418. //
  11419. // extends keepTogether behavior making sure the popper and its
  11420. // reference have enough pixels in conjunction
  11421. //
  11422. // top/left side
  11423. if (reference[opSide] - arrowElementSize < popper[side]) {
  11424. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  11425. }
  11426. // bottom/right side
  11427. if (reference[side] + arrowElementSize > popper[opSide]) {
  11428. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  11429. }
  11430. data.offsets.popper = getClientRect(data.offsets.popper);
  11431. // compute center of the popper
  11432. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  11433. // Compute the sideValue using the updated popper offsets
  11434. // take popper margin in account because we don't have this info available
  11435. var css = getStyleComputedProperty(data.instance.popper);
  11436. var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
  11437. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
  11438. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  11439. // prevent arrowElement from being placed not contiguously to its popper
  11440. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  11441. data.arrowElement = arrowElement;
  11442. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  11443. return data;
  11444. }
  11445. /**
  11446. * Get the opposite placement variation of the given one
  11447. * @method
  11448. * @memberof Popper.Utils
  11449. * @argument {String} placement variation
  11450. * @returns {String} flipped placement variation
  11451. */
  11452. function getOppositeVariation(variation) {
  11453. if (variation === 'end') {
  11454. return 'start';
  11455. } else if (variation === 'start') {
  11456. return 'end';
  11457. }
  11458. return variation;
  11459. }
  11460. /**
  11461. * List of accepted placements to use as values of the `placement` option.<br />
  11462. * Valid placements are:
  11463. * - `auto`
  11464. * - `top`
  11465. * - `right`
  11466. * - `bottom`
  11467. * - `left`
  11468. *
  11469. * Each placement can have a variation from this list:
  11470. * - `-start`
  11471. * - `-end`
  11472. *
  11473. * Variations are interpreted easily if you think of them as the left to right
  11474. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  11475. * is right.<br />
  11476. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  11477. *
  11478. * Some valid examples are:
  11479. * - `top-end` (on top of reference, right aligned)
  11480. * - `right-start` (on right of reference, top aligned)
  11481. * - `bottom` (on bottom, centered)
  11482. * - `auto-end` (on the side with more space available, alignment depends by placement)
  11483. *
  11484. * @static
  11485. * @type {Array}
  11486. * @enum {String}
  11487. * @readonly
  11488. * @method placements
  11489. * @memberof Popper
  11490. */
  11491. var placements = ['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start'];
  11492. // Get rid of `auto` `auto-start` and `auto-end`
  11493. var validPlacements = placements.slice(3);
  11494. /**
  11495. * Given an initial placement, returns all the subsequent placements
  11496. * clockwise (or counter-clockwise).
  11497. *
  11498. * @method
  11499. * @memberof Popper.Utils
  11500. * @argument {String} placement - A valid placement (it accepts variations)
  11501. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  11502. * @returns {Array} placements including their variations
  11503. */
  11504. function clockwise(placement) {
  11505. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  11506. var index = validPlacements.indexOf(placement);
  11507. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  11508. return counter ? arr.reverse() : arr;
  11509. }
  11510. var BEHAVIORS = {
  11511. FLIP: 'flip',
  11512. CLOCKWISE: 'clockwise',
  11513. COUNTERCLOCKWISE: 'counterclockwise'
  11514. };
  11515. /**
  11516. * @function
  11517. * @memberof Modifiers
  11518. * @argument {Object} data - The data object generated by update method
  11519. * @argument {Object} options - Modifiers configuration and options
  11520. * @returns {Object} The data object, properly modified
  11521. */
  11522. function flip(data, options) {
  11523. // if `inner` modifier is enabled, we can't use the `flip` modifier
  11524. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  11525. return data;
  11526. }
  11527. if (data.flipped && data.placement === data.originalPlacement) {
  11528. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  11529. return data;
  11530. }
  11531. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  11532. var placement = data.placement.split('-')[0];
  11533. var placementOpposite = getOppositePlacement(placement);
  11534. var variation = data.placement.split('-')[1] || '';
  11535. var flipOrder = [];
  11536. switch (options.behavior) {
  11537. case BEHAVIORS.FLIP:
  11538. flipOrder = [placement, placementOpposite];
  11539. break;
  11540. case BEHAVIORS.CLOCKWISE:
  11541. flipOrder = clockwise(placement);
  11542. break;
  11543. case BEHAVIORS.COUNTERCLOCKWISE:
  11544. flipOrder = clockwise(placement, true);
  11545. break;
  11546. default:
  11547. flipOrder = options.behavior;
  11548. }
  11549. flipOrder.forEach(function (step, index) {
  11550. if (placement !== step || flipOrder.length === index + 1) {
  11551. return data;
  11552. }
  11553. placement = data.placement.split('-')[0];
  11554. placementOpposite = getOppositePlacement(placement);
  11555. var popperOffsets = data.offsets.popper;
  11556. var refOffsets = data.offsets.reference;
  11557. // using floor because the reference offsets may contain decimals we are not going to consider here
  11558. var floor = Math.floor;
  11559. var overlapsRef = placement === 'left' && floor(popperOffsets.right) > floor(refOffsets.left) || placement === 'right' && floor(popperOffsets.left) < floor(refOffsets.right) || placement === 'top' && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === 'bottom' && floor(popperOffsets.top) < floor(refOffsets.bottom);
  11560. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  11561. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  11562. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  11563. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  11564. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  11565. // flip the variation if required
  11566. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  11567. // flips variation if reference element overflows boundaries
  11568. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  11569. // flips variation if popper content overflows boundaries
  11570. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  11571. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  11572. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  11573. // this boolean to detect any flip loop
  11574. data.flipped = true;
  11575. if (overlapsRef || overflowsBoundaries) {
  11576. placement = flipOrder[index + 1];
  11577. }
  11578. if (flippedVariation) {
  11579. variation = getOppositeVariation(variation);
  11580. }
  11581. data.placement = placement + (variation ? '-' + variation : '');
  11582. // this object contains `position`, we want to preserve it along with
  11583. // any additional property we may add in the future
  11584. data.offsets.popper = _extends$1({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  11585. data = runModifiers(data.instance.modifiers, data, 'flip');
  11586. }
  11587. });
  11588. return data;
  11589. }
  11590. /**
  11591. * @function
  11592. * @memberof Modifiers
  11593. * @argument {Object} data - The data object generated by update method
  11594. * @argument {Object} options - Modifiers configuration and options
  11595. * @returns {Object} The data object, properly modified
  11596. */
  11597. function keepTogether(data) {
  11598. var _data$offsets = data.offsets,
  11599. popper = _data$offsets.popper,
  11600. reference = _data$offsets.reference;
  11601. var placement = data.placement.split('-')[0];
  11602. var floor = Math.floor;
  11603. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  11604. var side = isVertical ? 'right' : 'bottom';
  11605. var opSide = isVertical ? 'left' : 'top';
  11606. var measurement = isVertical ? 'width' : 'height';
  11607. if (popper[side] < floor(reference[opSide])) {
  11608. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  11609. }
  11610. if (popper[opSide] > floor(reference[side])) {
  11611. data.offsets.popper[opSide] = floor(reference[side]);
  11612. }
  11613. return data;
  11614. }
  11615. /**
  11616. * Converts a string containing value + unit into a px value number
  11617. * @function
  11618. * @memberof {modifiers~offset}
  11619. * @private
  11620. * @argument {String} str - Value + unit string
  11621. * @argument {String} measurement - `height` or `width`
  11622. * @argument {Object} popperOffsets
  11623. * @argument {Object} referenceOffsets
  11624. * @returns {Number|String}
  11625. * Value in pixels, or original string if no values were extracted
  11626. */
  11627. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  11628. // separate value from unit
  11629. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  11630. var value = +split[1];
  11631. var unit = split[2];
  11632. // If it's not a number it's an operator, I guess
  11633. if (!value) {
  11634. return str;
  11635. }
  11636. if (unit.indexOf('%') === 0) {
  11637. var element = void 0;
  11638. switch (unit) {
  11639. case '%p':
  11640. element = popperOffsets;
  11641. break;
  11642. case '%':
  11643. case '%r':
  11644. default:
  11645. element = referenceOffsets;
  11646. }
  11647. var rect = getClientRect(element);
  11648. return rect[measurement] / 100 * value;
  11649. } else if (unit === 'vh' || unit === 'vw') {
  11650. // if is a vh or vw, we calculate the size based on the viewport
  11651. var size = void 0;
  11652. if (unit === 'vh') {
  11653. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  11654. } else {
  11655. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  11656. }
  11657. return size / 100 * value;
  11658. } else {
  11659. // if is an explicit pixel unit, we get rid of the unit and keep the value
  11660. // if is an implicit unit, it's px, and we return just the value
  11661. return value;
  11662. }
  11663. }
  11664. /**
  11665. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  11666. * @function
  11667. * @memberof {modifiers~offset}
  11668. * @private
  11669. * @argument {String} offset
  11670. * @argument {Object} popperOffsets
  11671. * @argument {Object} referenceOffsets
  11672. * @argument {String} basePlacement
  11673. * @returns {Array} a two cells array with x and y offsets in numbers
  11674. */
  11675. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  11676. var offsets = [0, 0];
  11677. // Use height if placement is left or right and index is 0 otherwise use width
  11678. // in this way the first offset will use an axis and the second one
  11679. // will use the other one
  11680. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  11681. // Split the offset string to obtain a list of values and operands
  11682. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  11683. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  11684. return frag.trim();
  11685. });
  11686. // Detect if the offset string contains a pair of values or a single one
  11687. // they could be separated by comma or space
  11688. var divider = fragments.indexOf(find(fragments, function (frag) {
  11689. return frag.search(/,|\s/) !== -1;
  11690. }));
  11691. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  11692. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  11693. }
  11694. // If divider is found, we divide the list of values and operands to divide
  11695. // them by ofset X and Y.
  11696. var splitRegex = /\s*,\s*|\s+/;
  11697. var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments];
  11698. // Convert the values with units to absolute pixels to allow our computations
  11699. ops = ops.map(function (op, index) {
  11700. // Most of the units rely on the orientation of the popper
  11701. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  11702. var mergeWithPrevious = false;
  11703. return op
  11704. // This aggregates any `+` or `-` sign that aren't considered operators
  11705. // e.g.: 10 + +5 => [10, +, +5]
  11706. .reduce(function (a, b) {
  11707. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  11708. a[a.length - 1] = b;
  11709. mergeWithPrevious = true;
  11710. return a;
  11711. } else if (mergeWithPrevious) {
  11712. a[a.length - 1] += b;
  11713. mergeWithPrevious = false;
  11714. return a;
  11715. } else {
  11716. return a.concat(b);
  11717. }
  11718. }, [])
  11719. // Here we convert the string values into number values (in px)
  11720. .map(function (str) {
  11721. return toValue(str, measurement, popperOffsets, referenceOffsets);
  11722. });
  11723. });
  11724. // Loop trough the offsets arrays and execute the operations
  11725. ops.forEach(function (op, index) {
  11726. op.forEach(function (frag, index2) {
  11727. if (isNumeric(frag)) {
  11728. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  11729. }
  11730. });
  11731. });
  11732. return offsets;
  11733. }
  11734. /**
  11735. * @function
  11736. * @memberof Modifiers
  11737. * @argument {Object} data - The data object generated by update method
  11738. * @argument {Object} options - Modifiers configuration and options
  11739. * @argument {Number|String} options.offset=0
  11740. * The offset value as described in the modifier description
  11741. * @returns {Object} The data object, properly modified
  11742. */
  11743. function offset(data, _ref) {
  11744. var offset = _ref.offset;
  11745. var placement = data.placement,
  11746. _data$offsets = data.offsets,
  11747. popper = _data$offsets.popper,
  11748. reference = _data$offsets.reference;
  11749. var basePlacement = placement.split('-')[0];
  11750. var offsets = void 0;
  11751. if (isNumeric(+offset)) {
  11752. offsets = [+offset, 0];
  11753. } else {
  11754. offsets = parseOffset(offset, popper, reference, basePlacement);
  11755. }
  11756. if (basePlacement === 'left') {
  11757. popper.top += offsets[0];
  11758. popper.left -= offsets[1];
  11759. } else if (basePlacement === 'right') {
  11760. popper.top += offsets[0];
  11761. popper.left += offsets[1];
  11762. } else if (basePlacement === 'top') {
  11763. popper.left += offsets[0];
  11764. popper.top -= offsets[1];
  11765. } else if (basePlacement === 'bottom') {
  11766. popper.left += offsets[0];
  11767. popper.top += offsets[1];
  11768. }
  11769. data.popper = popper;
  11770. return data;
  11771. }
  11772. /**
  11773. * @function
  11774. * @memberof Modifiers
  11775. * @argument {Object} data - The data object generated by `update` method
  11776. * @argument {Object} options - Modifiers configuration and options
  11777. * @returns {Object} The data object, properly modified
  11778. */
  11779. function preventOverflow(data, options) {
  11780. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  11781. // If offsetParent is the reference element, we really want to
  11782. // go one step up and use the next offsetParent as reference to
  11783. // avoid to make this modifier completely useless and look like broken
  11784. if (data.instance.reference === boundariesElement) {
  11785. boundariesElement = getOffsetParent(boundariesElement);
  11786. }
  11787. // NOTE: DOM access here
  11788. // resets the popper's position so that the document size can be calculated excluding
  11789. // the size of the popper element itself
  11790. var transformProp = getSupportedPropertyName('transform');
  11791. var popperStyles = data.instance.popper.style; // assignment to help minification
  11792. var top = popperStyles.top,
  11793. left = popperStyles.left,
  11794. transform = popperStyles[transformProp];
  11795. popperStyles.top = '';
  11796. popperStyles.left = '';
  11797. popperStyles[transformProp] = '';
  11798. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  11799. // NOTE: DOM access here
  11800. // restores the original style properties after the offsets have been computed
  11801. popperStyles.top = top;
  11802. popperStyles.left = left;
  11803. popperStyles[transformProp] = transform;
  11804. options.boundaries = boundaries;
  11805. var order = options.priority;
  11806. var popper = data.offsets.popper;
  11807. var check = {
  11808. primary: function primary(placement) {
  11809. var value = popper[placement];
  11810. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  11811. value = Math.max(popper[placement], boundaries[placement]);
  11812. }
  11813. return defineProperty({}, placement, value);
  11814. },
  11815. secondary: function secondary(placement) {
  11816. var mainSide = placement === 'right' ? 'left' : 'top';
  11817. var value = popper[mainSide];
  11818. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  11819. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  11820. }
  11821. return defineProperty({}, mainSide, value);
  11822. }
  11823. };
  11824. order.forEach(function (placement) {
  11825. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  11826. popper = _extends$1({}, popper, check[side](placement));
  11827. });
  11828. data.offsets.popper = popper;
  11829. return data;
  11830. }
  11831. /**
  11832. * @function
  11833. * @memberof Modifiers
  11834. * @argument {Object} data - The data object generated by `update` method
  11835. * @argument {Object} options - Modifiers configuration and options
  11836. * @returns {Object} The data object, properly modified
  11837. */
  11838. function shift(data) {
  11839. var placement = data.placement;
  11840. var basePlacement = placement.split('-')[0];
  11841. var shiftvariation = placement.split('-')[1];
  11842. // if shift shiftvariation is specified, run the modifier
  11843. if (shiftvariation) {
  11844. var _data$offsets = data.offsets,
  11845. reference = _data$offsets.reference,
  11846. popper = _data$offsets.popper;
  11847. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  11848. var side = isVertical ? 'left' : 'top';
  11849. var measurement = isVertical ? 'width' : 'height';
  11850. var shiftOffsets = {
  11851. start: defineProperty({}, side, reference[side]),
  11852. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  11853. };
  11854. data.offsets.popper = _extends$1({}, popper, shiftOffsets[shiftvariation]);
  11855. }
  11856. return data;
  11857. }
  11858. /**
  11859. * @function
  11860. * @memberof Modifiers
  11861. * @argument {Object} data - The data object generated by update method
  11862. * @argument {Object} options - Modifiers configuration and options
  11863. * @returns {Object} The data object, properly modified
  11864. */
  11865. function hide(data) {
  11866. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  11867. return data;
  11868. }
  11869. var refRect = data.offsets.reference;
  11870. var bound = find(data.instance.modifiers, function (modifier) {
  11871. return modifier.name === 'preventOverflow';
  11872. }).boundaries;
  11873. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  11874. // Avoid unnecessary DOM access if visibility hasn't changed
  11875. if (data.hide === true) {
  11876. return data;
  11877. }
  11878. data.hide = true;
  11879. data.attributes['x-out-of-boundaries'] = '';
  11880. } else {
  11881. // Avoid unnecessary DOM access if visibility hasn't changed
  11882. if (data.hide === false) {
  11883. return data;
  11884. }
  11885. data.hide = false;
  11886. data.attributes['x-out-of-boundaries'] = false;
  11887. }
  11888. return data;
  11889. }
  11890. /**
  11891. * @function
  11892. * @memberof Modifiers
  11893. * @argument {Object} data - The data object generated by `update` method
  11894. * @argument {Object} options - Modifiers configuration and options
  11895. * @returns {Object} The data object, properly modified
  11896. */
  11897. function inner(data) {
  11898. var placement = data.placement;
  11899. var basePlacement = placement.split('-')[0];
  11900. var _data$offsets = data.offsets,
  11901. popper = _data$offsets.popper,
  11902. reference = _data$offsets.reference;
  11903. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  11904. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  11905. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  11906. data.placement = getOppositePlacement(placement);
  11907. data.offsets.popper = getClientRect(popper);
  11908. return data;
  11909. }
  11910. /**
  11911. * Modifier function, each modifier can have a function of this type assigned
  11912. * to its `fn` property.<br />
  11913. * These functions will be called on each update, this means that you must
  11914. * make sure they are performant enough to avoid performance bottlenecks.
  11915. *
  11916. * @function ModifierFn
  11917. * @argument {dataObject} data - The data object generated by `update` method
  11918. * @argument {Object} options - Modifiers configuration and options
  11919. * @returns {dataObject} The data object, properly modified
  11920. */
  11921. /**
  11922. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  11923. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  11924. * needed by the library.
  11925. *
  11926. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  11927. * All the other properties are configurations that could be tweaked.
  11928. * @namespace modifiers
  11929. */
  11930. var modifiers = {
  11931. /**
  11932. * Modifier used to shift the popper on the start or end of its reference
  11933. * element.<br />
  11934. * It will read the variation of the `placement` property.<br />
  11935. * It can be one either `-end` or `-start`.
  11936. * @memberof modifiers
  11937. * @inner
  11938. */
  11939. shift: {
  11940. /** @prop {number} order=100 - Index used to define the order of execution */
  11941. order: 100,
  11942. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  11943. enabled: true,
  11944. /** @prop {ModifierFn} */
  11945. fn: shift
  11946. },
  11947. /**
  11948. * The `offset` modifier can shift your popper on both its axis.
  11949. *
  11950. * It accepts the following units:
  11951. * - `px` or unit-less, interpreted as pixels
  11952. * - `%` or `%r`, percentage relative to the length of the reference element
  11953. * - `%p`, percentage relative to the length of the popper element
  11954. * - `vw`, CSS viewport width unit
  11955. * - `vh`, CSS viewport height unit
  11956. *
  11957. * For length is intended the main axis relative to the placement of the popper.<br />
  11958. * This means that if the placement is `top` or `bottom`, the length will be the
  11959. * `width`. In case of `left` or `right`, it will be the `height`.
  11960. *
  11961. * You can provide a single value (as `Number` or `String`), or a pair of values
  11962. * as `String` divided by a comma or one (or more) white spaces.<br />
  11963. * The latter is a deprecated method because it leads to confusion and will be
  11964. * removed in v2.<br />
  11965. * Additionally, it accepts additions and subtractions between different units.
  11966. * Note that multiplications and divisions aren't supported.
  11967. *
  11968. * Valid examples are:
  11969. * ```
  11970. * 10
  11971. * '10%'
  11972. * '10, 10'
  11973. * '10%, 10'
  11974. * '10 + 10%'
  11975. * '10 - 5vh + 3%'
  11976. * '-10px + 5vh, 5px - 6%'
  11977. * ```
  11978. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  11979. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  11980. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  11981. *
  11982. * @memberof modifiers
  11983. * @inner
  11984. */
  11985. offset: {
  11986. /** @prop {number} order=200 - Index used to define the order of execution */
  11987. order: 200,
  11988. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  11989. enabled: true,
  11990. /** @prop {ModifierFn} */
  11991. fn: offset,
  11992. /** @prop {Number|String} offset=0
  11993. * The offset value as described in the modifier description
  11994. */
  11995. offset: 0
  11996. },
  11997. /**
  11998. * Modifier used to prevent the popper from being positioned outside the boundary.
  11999. *
  12000. * A scenario exists where the reference itself is not within the boundaries.<br />
  12001. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  12002. * In this case we need to decide whether the popper should either:
  12003. *
  12004. * - detach from the reference and remain "trapped" in the boundaries, or
  12005. * - if it should ignore the boundary and "escape with its reference"
  12006. *
  12007. * When `escapeWithReference` is set to`true` and reference is completely
  12008. * outside its boundaries, the popper will overflow (or completely leave)
  12009. * the boundaries in order to remain attached to the edge of the reference.
  12010. *
  12011. * @memberof modifiers
  12012. * @inner
  12013. */
  12014. preventOverflow: {
  12015. /** @prop {number} order=300 - Index used to define the order of execution */
  12016. order: 300,
  12017. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  12018. enabled: true,
  12019. /** @prop {ModifierFn} */
  12020. fn: preventOverflow,
  12021. /**
  12022. * @prop {Array} [priority=['left','right','top','bottom']]
  12023. * Popper will try to prevent overflow following these priorities by default,
  12024. * then, it could overflow on the left and on top of the `boundariesElement`
  12025. */
  12026. priority: ['left', 'right', 'top', 'bottom'],
  12027. /**
  12028. * @prop {number} padding=5
  12029. * Amount of pixel used to define a minimum distance between the boundaries
  12030. * and the popper. This makes sure the popper always has a little padding
  12031. * between the edges of its container
  12032. */
  12033. padding: 5,
  12034. /**
  12035. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  12036. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  12037. * `viewport` or any DOM element.
  12038. */
  12039. boundariesElement: 'scrollParent'
  12040. },
  12041. /**
  12042. * Modifier used to make sure the reference and its popper stay near each other
  12043. * without leaving any gap between the two. Especially useful when the arrow is
  12044. * enabled and you want to ensure that it points to its reference element.
  12045. * It cares only about the first axis. You can still have poppers with margin
  12046. * between the popper and its reference element.
  12047. * @memberof modifiers
  12048. * @inner
  12049. */
  12050. keepTogether: {
  12051. /** @prop {number} order=400 - Index used to define the order of execution */
  12052. order: 400,
  12053. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  12054. enabled: true,
  12055. /** @prop {ModifierFn} */
  12056. fn: keepTogether
  12057. },
  12058. /**
  12059. * This modifier is used to move the `arrowElement` of the popper to make
  12060. * sure it is positioned between the reference element and its popper element.
  12061. * It will read the outer size of the `arrowElement` node to detect how many
  12062. * pixels of conjunction are needed.
  12063. *
  12064. * It has no effect if no `arrowElement` is provided.
  12065. * @memberof modifiers
  12066. * @inner
  12067. */
  12068. arrow: {
  12069. /** @prop {number} order=500 - Index used to define the order of execution */
  12070. order: 500,
  12071. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  12072. enabled: true,
  12073. /** @prop {ModifierFn} */
  12074. fn: arrow,
  12075. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  12076. element: '[x-arrow]'
  12077. },
  12078. /**
  12079. * Modifier used to flip the popper's placement when it starts to overlap its
  12080. * reference element.
  12081. *
  12082. * Requires the `preventOverflow` modifier before it in order to work.
  12083. *
  12084. * **NOTE:** this modifier will interrupt the current update cycle and will
  12085. * restart it if it detects the need to flip the placement.
  12086. * @memberof modifiers
  12087. * @inner
  12088. */
  12089. flip: {
  12090. /** @prop {number} order=600 - Index used to define the order of execution */
  12091. order: 600,
  12092. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  12093. enabled: true,
  12094. /** @prop {ModifierFn} */
  12095. fn: flip,
  12096. /**
  12097. * @prop {String|Array} behavior='flip'
  12098. * The behavior used to change the popper's placement. It can be one of
  12099. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  12100. * placements (with optional variations)
  12101. */
  12102. behavior: 'flip',
  12103. /**
  12104. * @prop {number} padding=5
  12105. * The popper will flip if it hits the edges of the `boundariesElement`
  12106. */
  12107. padding: 5,
  12108. /**
  12109. * @prop {String|HTMLElement} boundariesElement='viewport'
  12110. * The element which will define the boundaries of the popper position.
  12111. * The popper will never be placed outside of the defined boundaries
  12112. * (except if `keepTogether` is enabled)
  12113. */
  12114. boundariesElement: 'viewport',
  12115. /**
  12116. * @prop {Boolean} flipVariations=false
  12117. * The popper will switch placement variation between `-start` and `-end` when
  12118. * the reference element overlaps its boundaries.
  12119. *
  12120. * The original placement should have a set variation.
  12121. */
  12122. flipVariations: false,
  12123. /**
  12124. * @prop {Boolean} flipVariationsByContent=false
  12125. * The popper will switch placement variation between `-start` and `-end` when
  12126. * the popper element overlaps its reference boundaries.
  12127. *
  12128. * The original placement should have a set variation.
  12129. */
  12130. flipVariationsByContent: false
  12131. },
  12132. /**
  12133. * Modifier used to make the popper flow toward the inner of the reference element.
  12134. * By default, when this modifier is disabled, the popper will be placed outside
  12135. * the reference element.
  12136. * @memberof modifiers
  12137. * @inner
  12138. */
  12139. inner: {
  12140. /** @prop {number} order=700 - Index used to define the order of execution */
  12141. order: 700,
  12142. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  12143. enabled: false,
  12144. /** @prop {ModifierFn} */
  12145. fn: inner
  12146. },
  12147. /**
  12148. * Modifier used to hide the popper when its reference element is outside of the
  12149. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  12150. * be used to hide with a CSS selector the popper when its reference is
  12151. * out of boundaries.
  12152. *
  12153. * Requires the `preventOverflow` modifier before it in order to work.
  12154. * @memberof modifiers
  12155. * @inner
  12156. */
  12157. hide: {
  12158. /** @prop {number} order=800 - Index used to define the order of execution */
  12159. order: 800,
  12160. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  12161. enabled: true,
  12162. /** @prop {ModifierFn} */
  12163. fn: hide
  12164. },
  12165. /**
  12166. * Computes the style that will be applied to the popper element to gets
  12167. * properly positioned.
  12168. *
  12169. * Note that this modifier will not touch the DOM, it just prepares the styles
  12170. * so that `applyStyle` modifier can apply it. This separation is useful
  12171. * in case you need to replace `applyStyle` with a custom implementation.
  12172. *
  12173. * This modifier has `850` as `order` value to maintain backward compatibility
  12174. * with previous versions of Popper.js. Expect the modifiers ordering method
  12175. * to change in future major versions of the library.
  12176. *
  12177. * @memberof modifiers
  12178. * @inner
  12179. */
  12180. computeStyle: {
  12181. /** @prop {number} order=850 - Index used to define the order of execution */
  12182. order: 850,
  12183. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  12184. enabled: true,
  12185. /** @prop {ModifierFn} */
  12186. fn: computeStyle,
  12187. /**
  12188. * @prop {Boolean} gpuAcceleration=true
  12189. * If true, it uses the CSS 3D transformation to position the popper.
  12190. * Otherwise, it will use the `top` and `left` properties
  12191. */
  12192. gpuAcceleration: true,
  12193. /**
  12194. * @prop {string} [x='bottom']
  12195. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  12196. * Change this if your popper should grow in a direction different from `bottom`
  12197. */
  12198. x: 'bottom',
  12199. /**
  12200. * @prop {string} [x='left']
  12201. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  12202. * Change this if your popper should grow in a direction different from `right`
  12203. */
  12204. y: 'right'
  12205. },
  12206. /**
  12207. * Applies the computed styles to the popper element.
  12208. *
  12209. * All the DOM manipulations are limited to this modifier. This is useful in case
  12210. * you want to integrate Popper.js inside a framework or view library and you
  12211. * want to delegate all the DOM manipulations to it.
  12212. *
  12213. * Note that if you disable this modifier, you must make sure the popper element
  12214. * has its position set to `absolute` before Popper.js can do its work!
  12215. *
  12216. * Just disable this modifier and define your own to achieve the desired effect.
  12217. *
  12218. * @memberof modifiers
  12219. * @inner
  12220. */
  12221. applyStyle: {
  12222. /** @prop {number} order=900 - Index used to define the order of execution */
  12223. order: 900,
  12224. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  12225. enabled: true,
  12226. /** @prop {ModifierFn} */
  12227. fn: applyStyle,
  12228. /** @prop {Function} */
  12229. onLoad: applyStyleOnLoad,
  12230. /**
  12231. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  12232. * @prop {Boolean} gpuAcceleration=true
  12233. * If true, it uses the CSS 3D transformation to position the popper.
  12234. * Otherwise, it will use the `top` and `left` properties
  12235. */
  12236. gpuAcceleration: undefined
  12237. }
  12238. };
  12239. /**
  12240. * The `dataObject` is an object containing all the information used by Popper.js.
  12241. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  12242. * @name dataObject
  12243. * @property {Object} data.instance The Popper.js instance
  12244. * @property {String} data.placement Placement applied to popper
  12245. * @property {String} data.originalPlacement Placement originally defined on init
  12246. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  12247. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  12248. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  12249. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  12250. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  12251. * @property {Object} data.boundaries Offsets of the popper boundaries
  12252. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  12253. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  12254. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  12255. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  12256. */
  12257. /**
  12258. * Default options provided to Popper.js constructor.<br />
  12259. * These can be overridden using the `options` argument of Popper.js.<br />
  12260. * To override an option, simply pass an object with the same
  12261. * structure of the `options` object, as the 3rd argument. For example:
  12262. * ```
  12263. * new Popper(ref, pop, {
  12264. * modifiers: {
  12265. * preventOverflow: { enabled: false }
  12266. * }
  12267. * })
  12268. * ```
  12269. * @type {Object}
  12270. * @static
  12271. * @memberof Popper
  12272. */
  12273. var Defaults = {
  12274. /**
  12275. * Popper's placement.
  12276. * @prop {Popper.placements} placement='bottom'
  12277. */
  12278. placement: 'bottom',
  12279. /**
  12280. * Set this to true if you want popper to position it self in 'fixed' mode
  12281. * @prop {Boolean} positionFixed=false
  12282. */
  12283. positionFixed: false,
  12284. /**
  12285. * Whether events (resize, scroll) are initially enabled.
  12286. * @prop {Boolean} eventsEnabled=true
  12287. */
  12288. eventsEnabled: true,
  12289. /**
  12290. * Set to true if you want to automatically remove the popper when
  12291. * you call the `destroy` method.
  12292. * @prop {Boolean} removeOnDestroy=false
  12293. */
  12294. removeOnDestroy: false,
  12295. /**
  12296. * Callback called when the popper is created.<br />
  12297. * By default, it is set to no-op.<br />
  12298. * Access Popper.js instance with `data.instance`.
  12299. * @prop {onCreate}
  12300. */
  12301. onCreate: function onCreate() {},
  12302. /**
  12303. * Callback called when the popper is updated. This callback is not called
  12304. * on the initialization/creation of the popper, but only on subsequent
  12305. * updates.<br />
  12306. * By default, it is set to no-op.<br />
  12307. * Access Popper.js instance with `data.instance`.
  12308. * @prop {onUpdate}
  12309. */
  12310. onUpdate: function onUpdate() {},
  12311. /**
  12312. * List of modifiers used to modify the offsets before they are applied to the popper.
  12313. * They provide most of the functionalities of Popper.js.
  12314. * @prop {modifiers}
  12315. */
  12316. modifiers: modifiers
  12317. };
  12318. /**
  12319. * @callback onCreate
  12320. * @param {dataObject} data
  12321. */
  12322. /**
  12323. * @callback onUpdate
  12324. * @param {dataObject} data
  12325. */
  12326. // Utils
  12327. // Methods
  12328. var Popper = function () {
  12329. /**
  12330. * Creates a new Popper.js instance.
  12331. * @class Popper
  12332. * @param {Element|referenceObject} reference - The reference element used to position the popper
  12333. * @param {Element} popper - The HTML / XML element used as the popper
  12334. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  12335. * @return {Object} instance - The generated Popper.js instance
  12336. */
  12337. function Popper(reference, popper) {
  12338. var _this = this;
  12339. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  12340. classCallCheck(this, Popper);
  12341. this.scheduleUpdate = function () {
  12342. return requestAnimationFrame(_this.update);
  12343. };
  12344. // make update() debounced, so that it only runs at most once-per-tick
  12345. this.update = debounce(this.update.bind(this));
  12346. // with {} we create a new object with the options inside it
  12347. this.options = _extends$1({}, Popper.Defaults, options);
  12348. // init state
  12349. this.state = {
  12350. isDestroyed: false,
  12351. isCreated: false,
  12352. scrollParents: []
  12353. };
  12354. // get reference and popper elements (allow jQuery wrappers)
  12355. this.reference = reference && reference.jquery ? reference[0] : reference;
  12356. this.popper = popper && popper.jquery ? popper[0] : popper;
  12357. // Deep merge modifiers options
  12358. this.options.modifiers = {};
  12359. Object.keys(_extends$1({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  12360. _this.options.modifiers[name] = _extends$1({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  12361. });
  12362. // Refactoring modifiers' list (Object => Array)
  12363. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  12364. return _extends$1({
  12365. name: name
  12366. }, _this.options.modifiers[name]);
  12367. })
  12368. // sort the modifiers by order
  12369. .sort(function (a, b) {
  12370. return a.order - b.order;
  12371. });
  12372. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  12373. // such code is executed in the same order of its modifier
  12374. // they could add new properties to their options configuration
  12375. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  12376. this.modifiers.forEach(function (modifierOptions) {
  12377. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  12378. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  12379. }
  12380. });
  12381. // fire the first update to position the popper in the right place
  12382. this.update();
  12383. var eventsEnabled = this.options.eventsEnabled;
  12384. if (eventsEnabled) {
  12385. // setup event listeners, they will take care of update the position in specific situations
  12386. this.enableEventListeners();
  12387. }
  12388. this.state.eventsEnabled = eventsEnabled;
  12389. }
  12390. // We can't use class properties because they don't get listed in the
  12391. // class prototype and break stuff like Sinon stubs
  12392. createClass(Popper, [{
  12393. key: 'update',
  12394. value: function update$$1() {
  12395. return update.call(this);
  12396. }
  12397. }, {
  12398. key: 'destroy',
  12399. value: function destroy$$1() {
  12400. return destroy.call(this);
  12401. }
  12402. }, {
  12403. key: 'enableEventListeners',
  12404. value: function enableEventListeners$$1() {
  12405. return enableEventListeners.call(this);
  12406. }
  12407. }, {
  12408. key: 'disableEventListeners',
  12409. value: function disableEventListeners$$1() {
  12410. return disableEventListeners.call(this);
  12411. }
  12412. /**
  12413. * Schedules an update. It will run on the next UI update available.
  12414. * @method scheduleUpdate
  12415. * @memberof Popper
  12416. */
  12417. /**
  12418. * Collection of utilities useful when writing custom modifiers.
  12419. * Starting from version 1.7, this method is available only if you
  12420. * include `popper-utils.js` before `popper.js`.
  12421. *
  12422. * **DEPRECATION**: This way to access PopperUtils is deprecated
  12423. * and will be removed in v2! Use the PopperUtils module directly instead.
  12424. * Due to the high instability of the methods contained in Utils, we can't
  12425. * guarantee them to follow semver. Use them at your own risk!
  12426. * @static
  12427. * @private
  12428. * @type {Object}
  12429. * @deprecated since version 1.8
  12430. * @member Utils
  12431. * @memberof Popper
  12432. */
  12433. }]);
  12434. return Popper;
  12435. }();
  12436. /**
  12437. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  12438. * and lets you use it as replacement of a real DOM node.<br />
  12439. * You can use this method to position a popper relatively to a set of coordinates
  12440. * in case you don't have a DOM node to use as reference.
  12441. *
  12442. * ```
  12443. * new Popper(referenceObject, popperNode);
  12444. * ```
  12445. *
  12446. * NB: This feature isn't supported in Internet Explorer 10.
  12447. * @name referenceObject
  12448. * @property {Function} data.getBoundingClientRect
  12449. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  12450. * @property {number} data.clientWidth
  12451. * An ES6 getter that will return the width of the virtual reference element.
  12452. * @property {number} data.clientHeight
  12453. * An ES6 getter that will return the height of the virtual reference element.
  12454. */
  12455. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  12456. Popper.placements = placements;
  12457. Popper.Defaults = Defaults;
  12458. /**
  12459. * ------------------------------------------------------------------------
  12460. * Constants
  12461. * ------------------------------------------------------------------------
  12462. */
  12463. var NAME$4 = 'dropdown';
  12464. var VERSION$4 = '4.5.3';
  12465. var DATA_KEY$4 = 'bs.dropdown';
  12466. var EVENT_KEY$4 = "." + DATA_KEY$4;
  12467. var DATA_API_KEY$4 = '.data-api';
  12468. var JQUERY_NO_CONFLICT$4 = $__default['default'].fn[NAME$4];
  12469. var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
  12470. var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
  12471. var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
  12472. var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
  12473. var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
  12474. var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
  12475. var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
  12476. var EVENT_HIDE$1 = "hide" + EVENT_KEY$4;
  12477. var EVENT_HIDDEN$1 = "hidden" + EVENT_KEY$4;
  12478. var EVENT_SHOW$1 = "show" + EVENT_KEY$4;
  12479. var EVENT_SHOWN$1 = "shown" + EVENT_KEY$4;
  12480. var EVENT_CLICK = "click" + EVENT_KEY$4;
  12481. var EVENT_CLICK_DATA_API$4 = "click" + EVENT_KEY$4 + DATA_API_KEY$4;
  12482. var EVENT_KEYDOWN_DATA_API = "keydown" + EVENT_KEY$4 + DATA_API_KEY$4;
  12483. var EVENT_KEYUP_DATA_API = "keyup" + EVENT_KEY$4 + DATA_API_KEY$4;
  12484. var CLASS_NAME_DISABLED = 'disabled';
  12485. var CLASS_NAME_SHOW$2 = 'show';
  12486. var CLASS_NAME_DROPUP = 'dropup';
  12487. var CLASS_NAME_DROPRIGHT = 'dropright';
  12488. var CLASS_NAME_DROPLEFT = 'dropleft';
  12489. var CLASS_NAME_MENURIGHT = 'dropdown-menu-right';
  12490. var CLASS_NAME_POSITION_STATIC = 'position-static';
  12491. var SELECTOR_DATA_TOGGLE$2 = '[data-toggle="dropdown"]';
  12492. var SELECTOR_FORM_CHILD = '.dropdown form';
  12493. var SELECTOR_MENU = '.dropdown-menu';
  12494. var SELECTOR_NAVBAR_NAV = '.navbar-nav';
  12495. var SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
  12496. var PLACEMENT_TOP = 'top-start';
  12497. var PLACEMENT_TOPEND = 'top-end';
  12498. var PLACEMENT_BOTTOM = 'bottom-start';
  12499. var PLACEMENT_BOTTOMEND = 'bottom-end';
  12500. var PLACEMENT_RIGHT = 'right-start';
  12501. var PLACEMENT_LEFT = 'left-start';
  12502. var Default$2 = {
  12503. offset: 0,
  12504. flip: true,
  12505. boundary: 'scrollParent',
  12506. reference: 'toggle',
  12507. display: 'dynamic',
  12508. popperConfig: null
  12509. };
  12510. var DefaultType$2 = {
  12511. offset: '(number|string|function)',
  12512. flip: 'boolean',
  12513. boundary: '(string|element)',
  12514. reference: '(string|element)',
  12515. display: 'string',
  12516. popperConfig: '(null|object)'
  12517. };
  12518. /**
  12519. * ------------------------------------------------------------------------
  12520. * Class Definition
  12521. * ------------------------------------------------------------------------
  12522. */
  12523. var Dropdown = /*#__PURE__*/function () {
  12524. function Dropdown(element, config) {
  12525. this._element = element;
  12526. this._popper = null;
  12527. this._config = this._getConfig(config);
  12528. this._menu = this._getMenuElement();
  12529. this._inNavbar = this._detectNavbar();
  12530. this._addEventListeners();
  12531. } // Getters
  12532. var _proto = Dropdown.prototype;
  12533. // Public
  12534. _proto.toggle = function toggle() {
  12535. if (this._element.disabled || $__default['default'](this._element).hasClass(CLASS_NAME_DISABLED)) {
  12536. return;
  12537. }
  12538. var isActive = $__default['default'](this._menu).hasClass(CLASS_NAME_SHOW$2);
  12539. Dropdown._clearMenus();
  12540. if (isActive) {
  12541. return;
  12542. }
  12543. this.show(true);
  12544. };
  12545. _proto.show = function show(usePopper) {
  12546. if (usePopper === void 0) {
  12547. usePopper = false;
  12548. }
  12549. if (this._element.disabled || $__default['default'](this._element).hasClass(CLASS_NAME_DISABLED) || $__default['default'](this._menu).hasClass(CLASS_NAME_SHOW$2)) {
  12550. return;
  12551. }
  12552. var relatedTarget = {
  12553. relatedTarget: this._element
  12554. };
  12555. var showEvent = $__default['default'].Event(EVENT_SHOW$1, relatedTarget);
  12556. var parent = Dropdown._getParentFromElement(this._element);
  12557. $__default['default'](parent).trigger(showEvent);
  12558. if (showEvent.isDefaultPrevented()) {
  12559. return;
  12560. } // Disable totally Popper.js for Dropdown in Navbar
  12561. if (!this._inNavbar && usePopper) {
  12562. /**
  12563. * Check for Popper dependency
  12564. * Popper - https://popper.js.org
  12565. */
  12566. if (typeof Popper === 'undefined') {
  12567. throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
  12568. }
  12569. var referenceElement = this._element;
  12570. if (this._config.reference === 'parent') {
  12571. referenceElement = parent;
  12572. } else if (Util.isElement(this._config.reference)) {
  12573. referenceElement = this._config.reference; // Check if it's jQuery element
  12574. if (typeof this._config.reference.jquery !== 'undefined') {
  12575. referenceElement = this._config.reference[0];
  12576. }
  12577. } // If boundary is not `scrollParent`, then set position to `static`
  12578. // to allow the menu to "escape" the scroll parent's boundaries
  12579. // https://github.com/twbs/bootstrap/issues/24251
  12580. if (this._config.boundary !== 'scrollParent') {
  12581. $__default['default'](parent).addClass(CLASS_NAME_POSITION_STATIC);
  12582. }
  12583. this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
  12584. } // If this is a touch-enabled device we add extra
  12585. // empty mouseover listeners to the body's immediate children;
  12586. // only needed because of broken event delegation on iOS
  12587. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  12588. if ('ontouchstart' in document.documentElement && $__default['default'](parent).closest(SELECTOR_NAVBAR_NAV).length === 0) {
  12589. $__default['default'](document.body).children().on('mouseover', null, $__default['default'].noop);
  12590. }
  12591. this._element.focus();
  12592. this._element.setAttribute('aria-expanded', true);
  12593. $__default['default'](this._menu).toggleClass(CLASS_NAME_SHOW$2);
  12594. $__default['default'](parent).toggleClass(CLASS_NAME_SHOW$2).trigger($__default['default'].Event(EVENT_SHOWN$1, relatedTarget));
  12595. };
  12596. _proto.hide = function hide() {
  12597. if (this._element.disabled || $__default['default'](this._element).hasClass(CLASS_NAME_DISABLED) || !$__default['default'](this._menu).hasClass(CLASS_NAME_SHOW$2)) {
  12598. return;
  12599. }
  12600. var relatedTarget = {
  12601. relatedTarget: this._element
  12602. };
  12603. var hideEvent = $__default['default'].Event(EVENT_HIDE$1, relatedTarget);
  12604. var parent = Dropdown._getParentFromElement(this._element);
  12605. $__default['default'](parent).trigger(hideEvent);
  12606. if (hideEvent.isDefaultPrevented()) {
  12607. return;
  12608. }
  12609. if (this._popper) {
  12610. this._popper.destroy();
  12611. }
  12612. $__default['default'](this._menu).toggleClass(CLASS_NAME_SHOW$2);
  12613. $__default['default'](parent).toggleClass(CLASS_NAME_SHOW$2).trigger($__default['default'].Event(EVENT_HIDDEN$1, relatedTarget));
  12614. };
  12615. _proto.dispose = function dispose() {
  12616. $__default['default'].removeData(this._element, DATA_KEY$4);
  12617. $__default['default'](this._element).off(EVENT_KEY$4);
  12618. this._element = null;
  12619. this._menu = null;
  12620. if (this._popper !== null) {
  12621. this._popper.destroy();
  12622. this._popper = null;
  12623. }
  12624. };
  12625. _proto.update = function update() {
  12626. this._inNavbar = this._detectNavbar();
  12627. if (this._popper !== null) {
  12628. this._popper.scheduleUpdate();
  12629. }
  12630. } // Private
  12631. ;
  12632. _proto._addEventListeners = function _addEventListeners() {
  12633. var _this = this;
  12634. $__default['default'](this._element).on(EVENT_CLICK, function (event) {
  12635. event.preventDefault();
  12636. event.stopPropagation();
  12637. _this.toggle();
  12638. });
  12639. };
  12640. _proto._getConfig = function _getConfig(config) {
  12641. config = _extends({}, this.constructor.Default, $__default['default'](this._element).data(), config);
  12642. Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
  12643. return config;
  12644. };
  12645. _proto._getMenuElement = function _getMenuElement() {
  12646. if (!this._menu) {
  12647. var parent = Dropdown._getParentFromElement(this._element);
  12648. if (parent) {
  12649. this._menu = parent.querySelector(SELECTOR_MENU);
  12650. }
  12651. }
  12652. return this._menu;
  12653. };
  12654. _proto._getPlacement = function _getPlacement() {
  12655. var $parentDropdown = $__default['default'](this._element.parentNode);
  12656. var placement = PLACEMENT_BOTTOM; // Handle dropup
  12657. if ($parentDropdown.hasClass(CLASS_NAME_DROPUP)) {
  12658. placement = $__default['default'](this._menu).hasClass(CLASS_NAME_MENURIGHT) ? PLACEMENT_TOPEND : PLACEMENT_TOP;
  12659. } else if ($parentDropdown.hasClass(CLASS_NAME_DROPRIGHT)) {
  12660. placement = PLACEMENT_RIGHT;
  12661. } else if ($parentDropdown.hasClass(CLASS_NAME_DROPLEFT)) {
  12662. placement = PLACEMENT_LEFT;
  12663. } else if ($__default['default'](this._menu).hasClass(CLASS_NAME_MENURIGHT)) {
  12664. placement = PLACEMENT_BOTTOMEND;
  12665. }
  12666. return placement;
  12667. };
  12668. _proto._detectNavbar = function _detectNavbar() {
  12669. return $__default['default'](this._element).closest('.navbar').length > 0;
  12670. };
  12671. _proto._getOffset = function _getOffset() {
  12672. var _this2 = this;
  12673. var offset = {};
  12674. if (typeof this._config.offset === 'function') {
  12675. offset.fn = function (data) {
  12676. data.offsets = _extends({}, data.offsets, _this2._config.offset(data.offsets, _this2._element) || {});
  12677. return data;
  12678. };
  12679. } else {
  12680. offset.offset = this._config.offset;
  12681. }
  12682. return offset;
  12683. };
  12684. _proto._getPopperConfig = function _getPopperConfig() {
  12685. var popperConfig = {
  12686. placement: this._getPlacement(),
  12687. modifiers: {
  12688. offset: this._getOffset(),
  12689. flip: {
  12690. enabled: this._config.flip
  12691. },
  12692. preventOverflow: {
  12693. boundariesElement: this._config.boundary
  12694. }
  12695. }
  12696. }; // Disable Popper.js if we have a static display
  12697. if (this._config.display === 'static') {
  12698. popperConfig.modifiers.applyStyle = {
  12699. enabled: false
  12700. };
  12701. }
  12702. return _extends({}, popperConfig, this._config.popperConfig);
  12703. } // Static
  12704. ;
  12705. Dropdown._jQueryInterface = function _jQueryInterface(config) {
  12706. return this.each(function () {
  12707. var data = $__default['default'](this).data(DATA_KEY$4);
  12708. var _config = typeof config === 'object' ? config : null;
  12709. if (!data) {
  12710. data = new Dropdown(this, _config);
  12711. $__default['default'](this).data(DATA_KEY$4, data);
  12712. }
  12713. if (typeof config === 'string') {
  12714. if (typeof data[config] === 'undefined') {
  12715. throw new TypeError("No method named \"" + config + "\"");
  12716. }
  12717. data[config]();
  12718. }
  12719. });
  12720. };
  12721. Dropdown._clearMenus = function _clearMenus(event) {
  12722. if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
  12723. return;
  12724. }
  12725. var toggles = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE$2));
  12726. for (var i = 0, len = toggles.length; i < len; i++) {
  12727. var parent = Dropdown._getParentFromElement(toggles[i]);
  12728. var context = $__default['default'](toggles[i]).data(DATA_KEY$4);
  12729. var relatedTarget = {
  12730. relatedTarget: toggles[i]
  12731. };
  12732. if (event && event.type === 'click') {
  12733. relatedTarget.clickEvent = event;
  12734. }
  12735. if (!context) {
  12736. continue;
  12737. }
  12738. var dropdownMenu = context._menu;
  12739. if (!$__default['default'](parent).hasClass(CLASS_NAME_SHOW$2)) {
  12740. continue;
  12741. }
  12742. if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $__default['default'].contains(parent, event.target)) {
  12743. continue;
  12744. }
  12745. var hideEvent = $__default['default'].Event(EVENT_HIDE$1, relatedTarget);
  12746. $__default['default'](parent).trigger(hideEvent);
  12747. if (hideEvent.isDefaultPrevented()) {
  12748. continue;
  12749. } // If this is a touch-enabled device we remove the extra
  12750. // empty mouseover listeners we added for iOS support
  12751. if ('ontouchstart' in document.documentElement) {
  12752. $__default['default'](document.body).children().off('mouseover', null, $__default['default'].noop);
  12753. }
  12754. toggles[i].setAttribute('aria-expanded', 'false');
  12755. if (context._popper) {
  12756. context._popper.destroy();
  12757. }
  12758. $__default['default'](dropdownMenu).removeClass(CLASS_NAME_SHOW$2);
  12759. $__default['default'](parent).removeClass(CLASS_NAME_SHOW$2).trigger($__default['default'].Event(EVENT_HIDDEN$1, relatedTarget));
  12760. }
  12761. };
  12762. Dropdown._getParentFromElement = function _getParentFromElement(element) {
  12763. var parent;
  12764. var selector = Util.getSelectorFromElement(element);
  12765. if (selector) {
  12766. parent = document.querySelector(selector);
  12767. }
  12768. return parent || element.parentNode;
  12769. } // eslint-disable-next-line complexity
  12770. ;
  12771. Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
  12772. // If not input/textarea:
  12773. // - And not a key in REGEXP_KEYDOWN => not a dropdown command
  12774. // If input/textarea:
  12775. // - If space key => not a dropdown command
  12776. // - If key is other than escape
  12777. // - If key is not up or down => not a dropdown command
  12778. // - If trigger inside the menu => not a dropdown command
  12779. if (/input|textarea/i.test(event.target.tagName) ? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && (event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE || $__default['default'](event.target).closest(SELECTOR_MENU).length) : !REGEXP_KEYDOWN.test(event.which)) {
  12780. return;
  12781. }
  12782. if (this.disabled || $__default['default'](this).hasClass(CLASS_NAME_DISABLED)) {
  12783. return;
  12784. }
  12785. var parent = Dropdown._getParentFromElement(this);
  12786. var isActive = $__default['default'](parent).hasClass(CLASS_NAME_SHOW$2);
  12787. if (!isActive && event.which === ESCAPE_KEYCODE) {
  12788. return;
  12789. }
  12790. event.preventDefault();
  12791. event.stopPropagation();
  12792. if (!isActive || event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE) {
  12793. if (event.which === ESCAPE_KEYCODE) {
  12794. $__default['default'](parent.querySelector(SELECTOR_DATA_TOGGLE$2)).trigger('focus');
  12795. }
  12796. $__default['default'](this).trigger('click');
  12797. return;
  12798. }
  12799. var items = [].slice.call(parent.querySelectorAll(SELECTOR_VISIBLE_ITEMS)).filter(function (item) {
  12800. return $__default['default'](item).is(':visible');
  12801. });
  12802. if (items.length === 0) {
  12803. return;
  12804. }
  12805. var index = items.indexOf(event.target);
  12806. if (event.which === ARROW_UP_KEYCODE && index > 0) {
  12807. // Up
  12808. index--;
  12809. }
  12810. if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
  12811. // Down
  12812. index++;
  12813. }
  12814. if (index < 0) {
  12815. index = 0;
  12816. }
  12817. items[index].focus();
  12818. };
  12819. _createClass(Dropdown, null, [{
  12820. key: "VERSION",
  12821. get: function get() {
  12822. return VERSION$4;
  12823. }
  12824. }, {
  12825. key: "Default",
  12826. get: function get() {
  12827. return Default$2;
  12828. }
  12829. }, {
  12830. key: "DefaultType",
  12831. get: function get() {
  12832. return DefaultType$2;
  12833. }
  12834. }]);
  12835. return Dropdown;
  12836. }();
  12837. /**
  12838. * ------------------------------------------------------------------------
  12839. * Data Api implementation
  12840. * ------------------------------------------------------------------------
  12841. */
  12842. $__default['default'](document).on(EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$2, Dropdown._dataApiKeydownHandler).on(EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown._dataApiKeydownHandler).on(EVENT_CLICK_DATA_API$4 + " " + EVENT_KEYUP_DATA_API, Dropdown._clearMenus).on(EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$2, function (event) {
  12843. event.preventDefault();
  12844. event.stopPropagation();
  12845. Dropdown._jQueryInterface.call($__default['default'](this), 'toggle');
  12846. }).on(EVENT_CLICK_DATA_API$4, SELECTOR_FORM_CHILD, function (e) {
  12847. e.stopPropagation();
  12848. });
  12849. /**
  12850. * ------------------------------------------------------------------------
  12851. * jQuery
  12852. * ------------------------------------------------------------------------
  12853. */
  12854. $__default['default'].fn[NAME$4] = Dropdown._jQueryInterface;
  12855. $__default['default'].fn[NAME$4].Constructor = Dropdown;
  12856. $__default['default'].fn[NAME$4].noConflict = function () {
  12857. $__default['default'].fn[NAME$4] = JQUERY_NO_CONFLICT$4;
  12858. return Dropdown._jQueryInterface;
  12859. };
  12860. /**
  12861. * ------------------------------------------------------------------------
  12862. * Constants
  12863. * ------------------------------------------------------------------------
  12864. */
  12865. var NAME$5 = 'modal';
  12866. var VERSION$5 = '4.5.3';
  12867. var DATA_KEY$5 = 'bs.modal';
  12868. var EVENT_KEY$5 = "." + DATA_KEY$5;
  12869. var DATA_API_KEY$5 = '.data-api';
  12870. var JQUERY_NO_CONFLICT$5 = $__default['default'].fn[NAME$5];
  12871. var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
  12872. var Default$3 = {
  12873. backdrop: true,
  12874. keyboard: true,
  12875. focus: true,
  12876. show: true
  12877. };
  12878. var DefaultType$3 = {
  12879. backdrop: '(boolean|string)',
  12880. keyboard: 'boolean',
  12881. focus: 'boolean',
  12882. show: 'boolean'
  12883. };
  12884. var EVENT_HIDE$2 = "hide" + EVENT_KEY$5;
  12885. var EVENT_HIDE_PREVENTED = "hidePrevented" + EVENT_KEY$5;
  12886. var EVENT_HIDDEN$2 = "hidden" + EVENT_KEY$5;
  12887. var EVENT_SHOW$2 = "show" + EVENT_KEY$5;
  12888. var EVENT_SHOWN$2 = "shown" + EVENT_KEY$5;
  12889. var EVENT_FOCUSIN = "focusin" + EVENT_KEY$5;
  12890. var EVENT_RESIZE = "resize" + EVENT_KEY$5;
  12891. var EVENT_CLICK_DISMISS = "click.dismiss" + EVENT_KEY$5;
  12892. var EVENT_KEYDOWN_DISMISS = "keydown.dismiss" + EVENT_KEY$5;
  12893. var EVENT_MOUSEUP_DISMISS = "mouseup.dismiss" + EVENT_KEY$5;
  12894. var EVENT_MOUSEDOWN_DISMISS = "mousedown.dismiss" + EVENT_KEY$5;
  12895. var EVENT_CLICK_DATA_API$5 = "click" + EVENT_KEY$5 + DATA_API_KEY$5;
  12896. var CLASS_NAME_SCROLLABLE = 'modal-dialog-scrollable';
  12897. var CLASS_NAME_SCROLLBAR_MEASURER = 'modal-scrollbar-measure';
  12898. var CLASS_NAME_BACKDROP = 'modal-backdrop';
  12899. var CLASS_NAME_OPEN = 'modal-open';
  12900. var CLASS_NAME_FADE$1 = 'fade';
  12901. var CLASS_NAME_SHOW$3 = 'show';
  12902. var CLASS_NAME_STATIC = 'modal-static';
  12903. var SELECTOR_DIALOG = '.modal-dialog';
  12904. var SELECTOR_MODAL_BODY = '.modal-body';
  12905. var SELECTOR_DATA_TOGGLE$3 = '[data-toggle="modal"]';
  12906. var SELECTOR_DATA_DISMISS = '[data-dismiss="modal"]';
  12907. var SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
  12908. var SELECTOR_STICKY_CONTENT = '.sticky-top';
  12909. /**
  12910. * ------------------------------------------------------------------------
  12911. * Class Definition
  12912. * ------------------------------------------------------------------------
  12913. */
  12914. var Modal = /*#__PURE__*/function () {
  12915. function Modal(element, config) {
  12916. this._config = this._getConfig(config);
  12917. this._element = element;
  12918. this._dialog = element.querySelector(SELECTOR_DIALOG);
  12919. this._backdrop = null;
  12920. this._isShown = false;
  12921. this._isBodyOverflowing = false;
  12922. this._ignoreBackdropClick = false;
  12923. this._isTransitioning = false;
  12924. this._scrollbarWidth = 0;
  12925. } // Getters
  12926. var _proto = Modal.prototype;
  12927. // Public
  12928. _proto.toggle = function toggle(relatedTarget) {
  12929. return this._isShown ? this.hide() : this.show(relatedTarget);
  12930. };
  12931. _proto.show = function show(relatedTarget) {
  12932. var _this = this;
  12933. if (this._isShown || this._isTransitioning) {
  12934. return;
  12935. }
  12936. if ($__default['default'](this._element).hasClass(CLASS_NAME_FADE$1)) {
  12937. this._isTransitioning = true;
  12938. }
  12939. var showEvent = $__default['default'].Event(EVENT_SHOW$2, {
  12940. relatedTarget: relatedTarget
  12941. });
  12942. $__default['default'](this._element).trigger(showEvent);
  12943. if (this._isShown || showEvent.isDefaultPrevented()) {
  12944. return;
  12945. }
  12946. this._isShown = true;
  12947. this._checkScrollbar();
  12948. this._setScrollbar();
  12949. this._adjustDialog();
  12950. this._setEscapeEvent();
  12951. this._setResizeEvent();
  12952. $__default['default'](this._element).on(EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, function (event) {
  12953. return _this.hide(event);
  12954. });
  12955. $__default['default'](this._dialog).on(EVENT_MOUSEDOWN_DISMISS, function () {
  12956. $__default['default'](_this._element).one(EVENT_MOUSEUP_DISMISS, function (event) {
  12957. if ($__default['default'](event.target).is(_this._element)) {
  12958. _this._ignoreBackdropClick = true;
  12959. }
  12960. });
  12961. });
  12962. this._showBackdrop(function () {
  12963. return _this._showElement(relatedTarget);
  12964. });
  12965. };
  12966. _proto.hide = function hide(event) {
  12967. var _this2 = this;
  12968. if (event) {
  12969. event.preventDefault();
  12970. }
  12971. if (!this._isShown || this._isTransitioning) {
  12972. return;
  12973. }
  12974. var hideEvent = $__default['default'].Event(EVENT_HIDE$2);
  12975. $__default['default'](this._element).trigger(hideEvent);
  12976. if (!this._isShown || hideEvent.isDefaultPrevented()) {
  12977. return;
  12978. }
  12979. this._isShown = false;
  12980. var transition = $__default['default'](this._element).hasClass(CLASS_NAME_FADE$1);
  12981. if (transition) {
  12982. this._isTransitioning = true;
  12983. }
  12984. this._setEscapeEvent();
  12985. this._setResizeEvent();
  12986. $__default['default'](document).off(EVENT_FOCUSIN);
  12987. $__default['default'](this._element).removeClass(CLASS_NAME_SHOW$3);
  12988. $__default['default'](this._element).off(EVENT_CLICK_DISMISS);
  12989. $__default['default'](this._dialog).off(EVENT_MOUSEDOWN_DISMISS);
  12990. if (transition) {
  12991. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  12992. $__default['default'](this._element).one(Util.TRANSITION_END, function (event) {
  12993. return _this2._hideModal(event);
  12994. }).emulateTransitionEnd(transitionDuration);
  12995. } else {
  12996. this._hideModal();
  12997. }
  12998. };
  12999. _proto.dispose = function dispose() {
  13000. [window, this._element, this._dialog].forEach(function (htmlElement) {
  13001. return $__default['default'](htmlElement).off(EVENT_KEY$5);
  13002. });
  13003. /**
  13004. * `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API`
  13005. * Do not move `document` in `htmlElements` array
  13006. * It will remove `EVENT_CLICK_DATA_API` event that should remain
  13007. */
  13008. $__default['default'](document).off(EVENT_FOCUSIN);
  13009. $__default['default'].removeData(this._element, DATA_KEY$5);
  13010. this._config = null;
  13011. this._element = null;
  13012. this._dialog = null;
  13013. this._backdrop = null;
  13014. this._isShown = null;
  13015. this._isBodyOverflowing = null;
  13016. this._ignoreBackdropClick = null;
  13017. this._isTransitioning = null;
  13018. this._scrollbarWidth = null;
  13019. };
  13020. _proto.handleUpdate = function handleUpdate() {
  13021. this._adjustDialog();
  13022. } // Private
  13023. ;
  13024. _proto._getConfig = function _getConfig(config) {
  13025. config = _extends({}, Default$3, config);
  13026. Util.typeCheckConfig(NAME$5, config, DefaultType$3);
  13027. return config;
  13028. };
  13029. _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
  13030. var _this3 = this;
  13031. if (this._config.backdrop === 'static') {
  13032. var hideEventPrevented = $__default['default'].Event(EVENT_HIDE_PREVENTED);
  13033. $__default['default'](this._element).trigger(hideEventPrevented);
  13034. if (hideEventPrevented.isDefaultPrevented()) {
  13035. return;
  13036. }
  13037. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  13038. if (!isModalOverflowing) {
  13039. this._element.style.overflowY = 'hidden';
  13040. }
  13041. this._element.classList.add(CLASS_NAME_STATIC);
  13042. var modalTransitionDuration = Util.getTransitionDurationFromElement(this._dialog);
  13043. $__default['default'](this._element).off(Util.TRANSITION_END);
  13044. $__default['default'](this._element).one(Util.TRANSITION_END, function () {
  13045. _this3._element.classList.remove(CLASS_NAME_STATIC);
  13046. if (!isModalOverflowing) {
  13047. $__default['default'](_this3._element).one(Util.TRANSITION_END, function () {
  13048. _this3._element.style.overflowY = '';
  13049. }).emulateTransitionEnd(_this3._element, modalTransitionDuration);
  13050. }
  13051. }).emulateTransitionEnd(modalTransitionDuration);
  13052. this._element.focus();
  13053. } else {
  13054. this.hide();
  13055. }
  13056. };
  13057. _proto._showElement = function _showElement(relatedTarget) {
  13058. var _this4 = this;
  13059. var transition = $__default['default'](this._element).hasClass(CLASS_NAME_FADE$1);
  13060. var modalBody = this._dialog ? this._dialog.querySelector(SELECTOR_MODAL_BODY) : null;
  13061. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  13062. // Don't move modal's DOM position
  13063. document.body.appendChild(this._element);
  13064. }
  13065. this._element.style.display = 'block';
  13066. this._element.removeAttribute('aria-hidden');
  13067. this._element.setAttribute('aria-modal', true);
  13068. this._element.setAttribute('role', 'dialog');
  13069. if ($__default['default'](this._dialog).hasClass(CLASS_NAME_SCROLLABLE) && modalBody) {
  13070. modalBody.scrollTop = 0;
  13071. } else {
  13072. this._element.scrollTop = 0;
  13073. }
  13074. if (transition) {
  13075. Util.reflow(this._element);
  13076. }
  13077. $__default['default'](this._element).addClass(CLASS_NAME_SHOW$3);
  13078. if (this._config.focus) {
  13079. this._enforceFocus();
  13080. }
  13081. var shownEvent = $__default['default'].Event(EVENT_SHOWN$2, {
  13082. relatedTarget: relatedTarget
  13083. });
  13084. var transitionComplete = function transitionComplete() {
  13085. if (_this4._config.focus) {
  13086. _this4._element.focus();
  13087. }
  13088. _this4._isTransitioning = false;
  13089. $__default['default'](_this4._element).trigger(shownEvent);
  13090. };
  13091. if (transition) {
  13092. var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
  13093. $__default['default'](this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
  13094. } else {
  13095. transitionComplete();
  13096. }
  13097. };
  13098. _proto._enforceFocus = function _enforceFocus() {
  13099. var _this5 = this;
  13100. $__default['default'](document).off(EVENT_FOCUSIN) // Guard against infinite focus loop
  13101. .on(EVENT_FOCUSIN, function (event) {
  13102. if (document !== event.target && _this5._element !== event.target && $__default['default'](_this5._element).has(event.target).length === 0) {
  13103. _this5._element.focus();
  13104. }
  13105. });
  13106. };
  13107. _proto._setEscapeEvent = function _setEscapeEvent() {
  13108. var _this6 = this;
  13109. if (this._isShown) {
  13110. $__default['default'](this._element).on(EVENT_KEYDOWN_DISMISS, function (event) {
  13111. if (_this6._config.keyboard && event.which === ESCAPE_KEYCODE$1) {
  13112. event.preventDefault();
  13113. _this6.hide();
  13114. } else if (!_this6._config.keyboard && event.which === ESCAPE_KEYCODE$1) {
  13115. _this6._triggerBackdropTransition();
  13116. }
  13117. });
  13118. } else if (!this._isShown) {
  13119. $__default['default'](this._element).off(EVENT_KEYDOWN_DISMISS);
  13120. }
  13121. };
  13122. _proto._setResizeEvent = function _setResizeEvent() {
  13123. var _this7 = this;
  13124. if (this._isShown) {
  13125. $__default['default'](window).on(EVENT_RESIZE, function (event) {
  13126. return _this7.handleUpdate(event);
  13127. });
  13128. } else {
  13129. $__default['default'](window).off(EVENT_RESIZE);
  13130. }
  13131. };
  13132. _proto._hideModal = function _hideModal() {
  13133. var _this8 = this;
  13134. this._element.style.display = 'none';
  13135. this._element.setAttribute('aria-hidden', true);
  13136. this._element.removeAttribute('aria-modal');
  13137. this._element.removeAttribute('role');
  13138. this._isTransitioning = false;
  13139. this._showBackdrop(function () {
  13140. $__default['default'](document.body).removeClass(CLASS_NAME_OPEN);
  13141. _this8._resetAdjustments();
  13142. _this8._resetScrollbar();
  13143. $__default['default'](_this8._element).trigger(EVENT_HIDDEN$2);
  13144. });
  13145. };
  13146. _proto._removeBackdrop = function _removeBackdrop() {
  13147. if (this._backdrop) {
  13148. $__default['default'](this._backdrop).remove();
  13149. this._backdrop = null;
  13150. }
  13151. };
  13152. _proto._showBackdrop = function _showBackdrop(callback) {
  13153. var _this9 = this;
  13154. var animate = $__default['default'](this._element).hasClass(CLASS_NAME_FADE$1) ? CLASS_NAME_FADE$1 : '';
  13155. if (this._isShown && this._config.backdrop) {
  13156. this._backdrop = document.createElement('div');
  13157. this._backdrop.className = CLASS_NAME_BACKDROP;
  13158. if (animate) {
  13159. this._backdrop.classList.add(animate);
  13160. }
  13161. $__default['default'](this._backdrop).appendTo(document.body);
  13162. $__default['default'](this._element).on(EVENT_CLICK_DISMISS, function (event) {
  13163. if (_this9._ignoreBackdropClick) {
  13164. _this9._ignoreBackdropClick = false;
  13165. return;
  13166. }
  13167. if (event.target !== event.currentTarget) {
  13168. return;
  13169. }
  13170. _this9._triggerBackdropTransition();
  13171. });
  13172. if (animate) {
  13173. Util.reflow(this._backdrop);
  13174. }
  13175. $__default['default'](this._backdrop).addClass(CLASS_NAME_SHOW$3);
  13176. if (!callback) {
  13177. return;
  13178. }
  13179. if (!animate) {
  13180. callback();
  13181. return;
  13182. }
  13183. var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  13184. $__default['default'](this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
  13185. } else if (!this._isShown && this._backdrop) {
  13186. $__default['default'](this._backdrop).removeClass(CLASS_NAME_SHOW$3);
  13187. var callbackRemove = function callbackRemove() {
  13188. _this9._removeBackdrop();
  13189. if (callback) {
  13190. callback();
  13191. }
  13192. };
  13193. if ($__default['default'](this._element).hasClass(CLASS_NAME_FADE$1)) {
  13194. var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  13195. $__default['default'](this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
  13196. } else {
  13197. callbackRemove();
  13198. }
  13199. } else if (callback) {
  13200. callback();
  13201. }
  13202. } // ----------------------------------------------------------------------
  13203. // the following methods are used to handle overflowing modals
  13204. // todo (fat): these should probably be refactored out of modal.js
  13205. // ----------------------------------------------------------------------
  13206. ;
  13207. _proto._adjustDialog = function _adjustDialog() {
  13208. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  13209. if (!this._isBodyOverflowing && isModalOverflowing) {
  13210. this._element.style.paddingLeft = this._scrollbarWidth + "px";
  13211. }
  13212. if (this._isBodyOverflowing && !isModalOverflowing) {
  13213. this._element.style.paddingRight = this._scrollbarWidth + "px";
  13214. }
  13215. };
  13216. _proto._resetAdjustments = function _resetAdjustments() {
  13217. this._element.style.paddingLeft = '';
  13218. this._element.style.paddingRight = '';
  13219. };
  13220. _proto._checkScrollbar = function _checkScrollbar() {
  13221. var rect = document.body.getBoundingClientRect();
  13222. this._isBodyOverflowing = Math.round(rect.left + rect.right) < window.innerWidth;
  13223. this._scrollbarWidth = this._getScrollbarWidth();
  13224. };
  13225. _proto._setScrollbar = function _setScrollbar() {
  13226. var _this10 = this;
  13227. if (this._isBodyOverflowing) {
  13228. // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
  13229. // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
  13230. var fixedContent = [].slice.call(document.querySelectorAll(SELECTOR_FIXED_CONTENT));
  13231. var stickyContent = [].slice.call(document.querySelectorAll(SELECTOR_STICKY_CONTENT)); // Adjust fixed content padding
  13232. $__default['default'](fixedContent).each(function (index, element) {
  13233. var actualPadding = element.style.paddingRight;
  13234. var calculatedPadding = $__default['default'](element).css('padding-right');
  13235. $__default['default'](element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px");
  13236. }); // Adjust sticky content margin
  13237. $__default['default'](stickyContent).each(function (index, element) {
  13238. var actualMargin = element.style.marginRight;
  13239. var calculatedMargin = $__default['default'](element).css('margin-right');
  13240. $__default['default'](element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px");
  13241. }); // Adjust body padding
  13242. var actualPadding = document.body.style.paddingRight;
  13243. var calculatedPadding = $__default['default'](document.body).css('padding-right');
  13244. $__default['default'](document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
  13245. }
  13246. $__default['default'](document.body).addClass(CLASS_NAME_OPEN);
  13247. };
  13248. _proto._resetScrollbar = function _resetScrollbar() {
  13249. // Restore fixed content padding
  13250. var fixedContent = [].slice.call(document.querySelectorAll(SELECTOR_FIXED_CONTENT));
  13251. $__default['default'](fixedContent).each(function (index, element) {
  13252. var padding = $__default['default'](element).data('padding-right');
  13253. $__default['default'](element).removeData('padding-right');
  13254. element.style.paddingRight = padding ? padding : '';
  13255. }); // Restore sticky content
  13256. var elements = [].slice.call(document.querySelectorAll("" + SELECTOR_STICKY_CONTENT));
  13257. $__default['default'](elements).each(function (index, element) {
  13258. var margin = $__default['default'](element).data('margin-right');
  13259. if (typeof margin !== 'undefined') {
  13260. $__default['default'](element).css('margin-right', margin).removeData('margin-right');
  13261. }
  13262. }); // Restore body padding
  13263. var padding = $__default['default'](document.body).data('padding-right');
  13264. $__default['default'](document.body).removeData('padding-right');
  13265. document.body.style.paddingRight = padding ? padding : '';
  13266. };
  13267. _proto._getScrollbarWidth = function _getScrollbarWidth() {
  13268. // thx d.walsh
  13269. var scrollDiv = document.createElement('div');
  13270. scrollDiv.className = CLASS_NAME_SCROLLBAR_MEASURER;
  13271. document.body.appendChild(scrollDiv);
  13272. var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  13273. document.body.removeChild(scrollDiv);
  13274. return scrollbarWidth;
  13275. } // Static
  13276. ;
  13277. Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
  13278. return this.each(function () {
  13279. var data = $__default['default'](this).data(DATA_KEY$5);
  13280. var _config = _extends({}, Default$3, $__default['default'](this).data(), typeof config === 'object' && config ? config : {});
  13281. if (!data) {
  13282. data = new Modal(this, _config);
  13283. $__default['default'](this).data(DATA_KEY$5, data);
  13284. }
  13285. if (typeof config === 'string') {
  13286. if (typeof data[config] === 'undefined') {
  13287. throw new TypeError("No method named \"" + config + "\"");
  13288. }
  13289. data[config](relatedTarget);
  13290. } else if (_config.show) {
  13291. data.show(relatedTarget);
  13292. }
  13293. });
  13294. };
  13295. _createClass(Modal, null, [{
  13296. key: "VERSION",
  13297. get: function get() {
  13298. return VERSION$5;
  13299. }
  13300. }, {
  13301. key: "Default",
  13302. get: function get() {
  13303. return Default$3;
  13304. }
  13305. }]);
  13306. return Modal;
  13307. }();
  13308. /**
  13309. * ------------------------------------------------------------------------
  13310. * Data Api implementation
  13311. * ------------------------------------------------------------------------
  13312. */
  13313. $__default['default'](document).on(EVENT_CLICK_DATA_API$5, SELECTOR_DATA_TOGGLE$3, function (event) {
  13314. var _this11 = this;
  13315. var target;
  13316. var selector = Util.getSelectorFromElement(this);
  13317. if (selector) {
  13318. target = document.querySelector(selector);
  13319. }
  13320. var config = $__default['default'](target).data(DATA_KEY$5) ? 'toggle' : _extends({}, $__default['default'](target).data(), $__default['default'](this).data());
  13321. if (this.tagName === 'A' || this.tagName === 'AREA') {
  13322. event.preventDefault();
  13323. }
  13324. var $target = $__default['default'](target).one(EVENT_SHOW$2, function (showEvent) {
  13325. if (showEvent.isDefaultPrevented()) {
  13326. // Only register focus restorer if modal will actually get shown
  13327. return;
  13328. }
  13329. $target.one(EVENT_HIDDEN$2, function () {
  13330. if ($__default['default'](_this11).is(':visible')) {
  13331. _this11.focus();
  13332. }
  13333. });
  13334. });
  13335. Modal._jQueryInterface.call($__default['default'](target), config, this);
  13336. });
  13337. /**
  13338. * ------------------------------------------------------------------------
  13339. * jQuery
  13340. * ------------------------------------------------------------------------
  13341. */
  13342. $__default['default'].fn[NAME$5] = Modal._jQueryInterface;
  13343. $__default['default'].fn[NAME$5].Constructor = Modal;
  13344. $__default['default'].fn[NAME$5].noConflict = function () {
  13345. $__default['default'].fn[NAME$5] = JQUERY_NO_CONFLICT$5;
  13346. return Modal._jQueryInterface;
  13347. };
  13348. /**
  13349. * --------------------------------------------------------------------------
  13350. * Bootstrap (v4.5.3): tools/sanitizer.js
  13351. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  13352. * --------------------------------------------------------------------------
  13353. */
  13354. var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  13355. var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  13356. var DefaultWhitelist = {
  13357. // Global attributes allowed on any supplied element below.
  13358. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  13359. a: ['target', 'href', 'title', 'rel'],
  13360. area: [],
  13361. b: [],
  13362. br: [],
  13363. col: [],
  13364. code: [],
  13365. div: [],
  13366. em: [],
  13367. hr: [],
  13368. h1: [],
  13369. h2: [],
  13370. h3: [],
  13371. h4: [],
  13372. h5: [],
  13373. h6: [],
  13374. i: [],
  13375. img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
  13376. li: [],
  13377. ol: [],
  13378. p: [],
  13379. pre: [],
  13380. s: [],
  13381. small: [],
  13382. span: [],
  13383. sub: [],
  13384. sup: [],
  13385. strong: [],
  13386. u: [],
  13387. ul: []
  13388. };
  13389. /**
  13390. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  13391. *
  13392. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  13393. */
  13394. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^#&/:?]*(?:[#/?]|$))/gi;
  13395. /**
  13396. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  13397. *
  13398. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  13399. */
  13400. var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i;
  13401. function allowedAttribute(attr, allowedAttributeList) {
  13402. var attrName = attr.nodeName.toLowerCase();
  13403. if (allowedAttributeList.indexOf(attrName) !== -1) {
  13404. if (uriAttrs.indexOf(attrName) !== -1) {
  13405. return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
  13406. }
  13407. return true;
  13408. }
  13409. var regExp = allowedAttributeList.filter(function (attrRegex) {
  13410. return attrRegex instanceof RegExp;
  13411. }); // Check if a regular expression validates the attribute.
  13412. for (var i = 0, len = regExp.length; i < len; i++) {
  13413. if (attrName.match(regExp[i])) {
  13414. return true;
  13415. }
  13416. }
  13417. return false;
  13418. }
  13419. function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  13420. if (unsafeHtml.length === 0) {
  13421. return unsafeHtml;
  13422. }
  13423. if (sanitizeFn && typeof sanitizeFn === 'function') {
  13424. return sanitizeFn(unsafeHtml);
  13425. }
  13426. var domParser = new window.DOMParser();
  13427. var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  13428. var whitelistKeys = Object.keys(whiteList);
  13429. var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
  13430. var _loop = function _loop(i, len) {
  13431. var el = elements[i];
  13432. var elName = el.nodeName.toLowerCase();
  13433. if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
  13434. el.parentNode.removeChild(el);
  13435. return "continue";
  13436. }
  13437. var attributeList = [].slice.call(el.attributes);
  13438. var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
  13439. attributeList.forEach(function (attr) {
  13440. if (!allowedAttribute(attr, whitelistedAttributes)) {
  13441. el.removeAttribute(attr.nodeName);
  13442. }
  13443. });
  13444. };
  13445. for (var i = 0, len = elements.length; i < len; i++) {
  13446. var _ret = _loop(i);
  13447. if (_ret === "continue") continue;
  13448. }
  13449. return createdDocument.body.innerHTML;
  13450. }
  13451. /**
  13452. * ------------------------------------------------------------------------
  13453. * Constants
  13454. * ------------------------------------------------------------------------
  13455. */
  13456. var NAME$6 = 'tooltip';
  13457. var VERSION$6 = '4.5.3';
  13458. var DATA_KEY$6 = 'bs.tooltip';
  13459. var EVENT_KEY$6 = "." + DATA_KEY$6;
  13460. var JQUERY_NO_CONFLICT$6 = $__default['default'].fn[NAME$6];
  13461. var CLASS_PREFIX = 'bs-tooltip';
  13462. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  13463. var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
  13464. var DefaultType$4 = {
  13465. animation: 'boolean',
  13466. template: 'string',
  13467. title: '(string|element|function)',
  13468. trigger: 'string',
  13469. delay: '(number|object)',
  13470. html: 'boolean',
  13471. selector: '(string|boolean)',
  13472. placement: '(string|function)',
  13473. offset: '(number|string|function)',
  13474. container: '(string|element|boolean)',
  13475. fallbackPlacement: '(string|array)',
  13476. boundary: '(string|element)',
  13477. sanitize: 'boolean',
  13478. sanitizeFn: '(null|function)',
  13479. whiteList: 'object',
  13480. popperConfig: '(null|object)'
  13481. };
  13482. var AttachmentMap = {
  13483. AUTO: 'auto',
  13484. TOP: 'top',
  13485. RIGHT: 'right',
  13486. BOTTOM: 'bottom',
  13487. LEFT: 'left'
  13488. };
  13489. var Default$4 = {
  13490. animation: true,
  13491. template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
  13492. trigger: 'hover focus',
  13493. title: '',
  13494. delay: 0,
  13495. html: false,
  13496. selector: false,
  13497. placement: 'top',
  13498. offset: 0,
  13499. container: false,
  13500. fallbackPlacement: 'flip',
  13501. boundary: 'scrollParent',
  13502. sanitize: true,
  13503. sanitizeFn: null,
  13504. whiteList: DefaultWhitelist,
  13505. popperConfig: null
  13506. };
  13507. var HOVER_STATE_SHOW = 'show';
  13508. var HOVER_STATE_OUT = 'out';
  13509. var Event = {
  13510. HIDE: "hide" + EVENT_KEY$6,
  13511. HIDDEN: "hidden" + EVENT_KEY$6,
  13512. SHOW: "show" + EVENT_KEY$6,
  13513. SHOWN: "shown" + EVENT_KEY$6,
  13514. INSERTED: "inserted" + EVENT_KEY$6,
  13515. CLICK: "click" + EVENT_KEY$6,
  13516. FOCUSIN: "focusin" + EVENT_KEY$6,
  13517. FOCUSOUT: "focusout" + EVENT_KEY$6,
  13518. MOUSEENTER: "mouseenter" + EVENT_KEY$6,
  13519. MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  13520. };
  13521. var CLASS_NAME_FADE$2 = 'fade';
  13522. var CLASS_NAME_SHOW$4 = 'show';
  13523. var SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
  13524. var SELECTOR_ARROW = '.arrow';
  13525. var TRIGGER_HOVER = 'hover';
  13526. var TRIGGER_FOCUS = 'focus';
  13527. var TRIGGER_CLICK = 'click';
  13528. var TRIGGER_MANUAL = 'manual';
  13529. /**
  13530. * ------------------------------------------------------------------------
  13531. * Class Definition
  13532. * ------------------------------------------------------------------------
  13533. */
  13534. var Tooltip = /*#__PURE__*/function () {
  13535. function Tooltip(element, config) {
  13536. if (typeof Popper === 'undefined') {
  13537. throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
  13538. } // private
  13539. this._isEnabled = true;
  13540. this._timeout = 0;
  13541. this._hoverState = '';
  13542. this._activeTrigger = {};
  13543. this._popper = null; // Protected
  13544. this.element = element;
  13545. this.config = this._getConfig(config);
  13546. this.tip = null;
  13547. this._setListeners();
  13548. } // Getters
  13549. var _proto = Tooltip.prototype;
  13550. // Public
  13551. _proto.enable = function enable() {
  13552. this._isEnabled = true;
  13553. };
  13554. _proto.disable = function disable() {
  13555. this._isEnabled = false;
  13556. };
  13557. _proto.toggleEnabled = function toggleEnabled() {
  13558. this._isEnabled = !this._isEnabled;
  13559. };
  13560. _proto.toggle = function toggle(event) {
  13561. if (!this._isEnabled) {
  13562. return;
  13563. }
  13564. if (event) {
  13565. var dataKey = this.constructor.DATA_KEY;
  13566. var context = $__default['default'](event.currentTarget).data(dataKey);
  13567. if (!context) {
  13568. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  13569. $__default['default'](event.currentTarget).data(dataKey, context);
  13570. }
  13571. context._activeTrigger.click = !context._activeTrigger.click;
  13572. if (context._isWithActiveTrigger()) {
  13573. context._enter(null, context);
  13574. } else {
  13575. context._leave(null, context);
  13576. }
  13577. } else {
  13578. if ($__default['default'](this.getTipElement()).hasClass(CLASS_NAME_SHOW$4)) {
  13579. this._leave(null, this);
  13580. return;
  13581. }
  13582. this._enter(null, this);
  13583. }
  13584. };
  13585. _proto.dispose = function dispose() {
  13586. clearTimeout(this._timeout);
  13587. $__default['default'].removeData(this.element, this.constructor.DATA_KEY);
  13588. $__default['default'](this.element).off(this.constructor.EVENT_KEY);
  13589. $__default['default'](this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler);
  13590. if (this.tip) {
  13591. $__default['default'](this.tip).remove();
  13592. }
  13593. this._isEnabled = null;
  13594. this._timeout = null;
  13595. this._hoverState = null;
  13596. this._activeTrigger = null;
  13597. if (this._popper) {
  13598. this._popper.destroy();
  13599. }
  13600. this._popper = null;
  13601. this.element = null;
  13602. this.config = null;
  13603. this.tip = null;
  13604. };
  13605. _proto.show = function show() {
  13606. var _this = this;
  13607. if ($__default['default'](this.element).css('display') === 'none') {
  13608. throw new Error('Please use show on visible elements');
  13609. }
  13610. var showEvent = $__default['default'].Event(this.constructor.Event.SHOW);
  13611. if (this.isWithContent() && this._isEnabled) {
  13612. $__default['default'](this.element).trigger(showEvent);
  13613. var shadowRoot = Util.findShadowRoot(this.element);
  13614. var isInTheDom = $__default['default'].contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
  13615. if (showEvent.isDefaultPrevented() || !isInTheDom) {
  13616. return;
  13617. }
  13618. var tip = this.getTipElement();
  13619. var tipId = Util.getUID(this.constructor.NAME);
  13620. tip.setAttribute('id', tipId);
  13621. this.element.setAttribute('aria-describedby', tipId);
  13622. this.setContent();
  13623. if (this.config.animation) {
  13624. $__default['default'](tip).addClass(CLASS_NAME_FADE$2);
  13625. }
  13626. var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
  13627. var attachment = this._getAttachment(placement);
  13628. this.addAttachmentClass(attachment);
  13629. var container = this._getContainer();
  13630. $__default['default'](tip).data(this.constructor.DATA_KEY, this);
  13631. if (!$__default['default'].contains(this.element.ownerDocument.documentElement, this.tip)) {
  13632. $__default['default'](tip).appendTo(container);
  13633. }
  13634. $__default['default'](this.element).trigger(this.constructor.Event.INSERTED);
  13635. this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
  13636. $__default['default'](tip).addClass(CLASS_NAME_SHOW$4); // If this is a touch-enabled device we add extra
  13637. // empty mouseover listeners to the body's immediate children;
  13638. // only needed because of broken event delegation on iOS
  13639. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  13640. if ('ontouchstart' in document.documentElement) {
  13641. $__default['default'](document.body).children().on('mouseover', null, $__default['default'].noop);
  13642. }
  13643. var complete = function complete() {
  13644. if (_this.config.animation) {
  13645. _this._fixTransition();
  13646. }
  13647. var prevHoverState = _this._hoverState;
  13648. _this._hoverState = null;
  13649. $__default['default'](_this.element).trigger(_this.constructor.Event.SHOWN);
  13650. if (prevHoverState === HOVER_STATE_OUT) {
  13651. _this._leave(null, _this);
  13652. }
  13653. };
  13654. if ($__default['default'](this.tip).hasClass(CLASS_NAME_FADE$2)) {
  13655. var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
  13656. $__default['default'](this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  13657. } else {
  13658. complete();
  13659. }
  13660. }
  13661. };
  13662. _proto.hide = function hide(callback) {
  13663. var _this2 = this;
  13664. var tip = this.getTipElement();
  13665. var hideEvent = $__default['default'].Event(this.constructor.Event.HIDE);
  13666. var complete = function complete() {
  13667. if (_this2._hoverState !== HOVER_STATE_SHOW && tip.parentNode) {
  13668. tip.parentNode.removeChild(tip);
  13669. }
  13670. _this2._cleanTipClass();
  13671. _this2.element.removeAttribute('aria-describedby');
  13672. $__default['default'](_this2.element).trigger(_this2.constructor.Event.HIDDEN);
  13673. if (_this2._popper !== null) {
  13674. _this2._popper.destroy();
  13675. }
  13676. if (callback) {
  13677. callback();
  13678. }
  13679. };
  13680. $__default['default'](this.element).trigger(hideEvent);
  13681. if (hideEvent.isDefaultPrevented()) {
  13682. return;
  13683. }
  13684. $__default['default'](tip).removeClass(CLASS_NAME_SHOW$4); // If this is a touch-enabled device we remove the extra
  13685. // empty mouseover listeners we added for iOS support
  13686. if ('ontouchstart' in document.documentElement) {
  13687. $__default['default'](document.body).children().off('mouseover', null, $__default['default'].noop);
  13688. }
  13689. this._activeTrigger[TRIGGER_CLICK] = false;
  13690. this._activeTrigger[TRIGGER_FOCUS] = false;
  13691. this._activeTrigger[TRIGGER_HOVER] = false;
  13692. if ($__default['default'](this.tip).hasClass(CLASS_NAME_FADE$2)) {
  13693. var transitionDuration = Util.getTransitionDurationFromElement(tip);
  13694. $__default['default'](tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  13695. } else {
  13696. complete();
  13697. }
  13698. this._hoverState = '';
  13699. };
  13700. _proto.update = function update() {
  13701. if (this._popper !== null) {
  13702. this._popper.scheduleUpdate();
  13703. }
  13704. } // Protected
  13705. ;
  13706. _proto.isWithContent = function isWithContent() {
  13707. return Boolean(this.getTitle());
  13708. };
  13709. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  13710. $__default['default'](this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  13711. };
  13712. _proto.getTipElement = function getTipElement() {
  13713. this.tip = this.tip || $__default['default'](this.config.template)[0];
  13714. return this.tip;
  13715. };
  13716. _proto.setContent = function setContent() {
  13717. var tip = this.getTipElement();
  13718. this.setElementContent($__default['default'](tip.querySelectorAll(SELECTOR_TOOLTIP_INNER)), this.getTitle());
  13719. $__default['default'](tip).removeClass(CLASS_NAME_FADE$2 + " " + CLASS_NAME_SHOW$4);
  13720. };
  13721. _proto.setElementContent = function setElementContent($element, content) {
  13722. if (typeof content === 'object' && (content.nodeType || content.jquery)) {
  13723. // Content is a DOM node or a jQuery
  13724. if (this.config.html) {
  13725. if (!$__default['default'](content).parent().is($element)) {
  13726. $element.empty().append(content);
  13727. }
  13728. } else {
  13729. $element.text($__default['default'](content).text());
  13730. }
  13731. return;
  13732. }
  13733. if (this.config.html) {
  13734. if (this.config.sanitize) {
  13735. content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
  13736. }
  13737. $element.html(content);
  13738. } else {
  13739. $element.text(content);
  13740. }
  13741. };
  13742. _proto.getTitle = function getTitle() {
  13743. var title = this.element.getAttribute('data-original-title');
  13744. if (!title) {
  13745. title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
  13746. }
  13747. return title;
  13748. } // Private
  13749. ;
  13750. _proto._getPopperConfig = function _getPopperConfig(attachment) {
  13751. var _this3 = this;
  13752. var defaultBsConfig = {
  13753. placement: attachment,
  13754. modifiers: {
  13755. offset: this._getOffset(),
  13756. flip: {
  13757. behavior: this.config.fallbackPlacement
  13758. },
  13759. arrow: {
  13760. element: SELECTOR_ARROW
  13761. },
  13762. preventOverflow: {
  13763. boundariesElement: this.config.boundary
  13764. }
  13765. },
  13766. onCreate: function onCreate(data) {
  13767. if (data.originalPlacement !== data.placement) {
  13768. _this3._handlePopperPlacementChange(data);
  13769. }
  13770. },
  13771. onUpdate: function onUpdate(data) {
  13772. return _this3._handlePopperPlacementChange(data);
  13773. }
  13774. };
  13775. return _extends({}, defaultBsConfig, this.config.popperConfig);
  13776. };
  13777. _proto._getOffset = function _getOffset() {
  13778. var _this4 = this;
  13779. var offset = {};
  13780. if (typeof this.config.offset === 'function') {
  13781. offset.fn = function (data) {
  13782. data.offsets = _extends({}, data.offsets, _this4.config.offset(data.offsets, _this4.element) || {});
  13783. return data;
  13784. };
  13785. } else {
  13786. offset.offset = this.config.offset;
  13787. }
  13788. return offset;
  13789. };
  13790. _proto._getContainer = function _getContainer() {
  13791. if (this.config.container === false) {
  13792. return document.body;
  13793. }
  13794. if (Util.isElement(this.config.container)) {
  13795. return $__default['default'](this.config.container);
  13796. }
  13797. return $__default['default'](document).find(this.config.container);
  13798. };
  13799. _proto._getAttachment = function _getAttachment(placement) {
  13800. return AttachmentMap[placement.toUpperCase()];
  13801. };
  13802. _proto._setListeners = function _setListeners() {
  13803. var _this5 = this;
  13804. var triggers = this.config.trigger.split(' ');
  13805. triggers.forEach(function (trigger) {
  13806. if (trigger === 'click') {
  13807. $__default['default'](_this5.element).on(_this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
  13808. return _this5.toggle(event);
  13809. });
  13810. } else if (trigger !== TRIGGER_MANUAL) {
  13811. var eventIn = trigger === TRIGGER_HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
  13812. var eventOut = trigger === TRIGGER_HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT;
  13813. $__default['default'](_this5.element).on(eventIn, _this5.config.selector, function (event) {
  13814. return _this5._enter(event);
  13815. }).on(eventOut, _this5.config.selector, function (event) {
  13816. return _this5._leave(event);
  13817. });
  13818. }
  13819. });
  13820. this._hideModalHandler = function () {
  13821. if (_this5.element) {
  13822. _this5.hide();
  13823. }
  13824. };
  13825. $__default['default'](this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler);
  13826. if (this.config.selector) {
  13827. this.config = _extends({}, this.config, {
  13828. trigger: 'manual',
  13829. selector: ''
  13830. });
  13831. } else {
  13832. this._fixTitle();
  13833. }
  13834. };
  13835. _proto._fixTitle = function _fixTitle() {
  13836. var titleType = typeof this.element.getAttribute('data-original-title');
  13837. if (this.element.getAttribute('title') || titleType !== 'string') {
  13838. this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
  13839. this.element.setAttribute('title', '');
  13840. }
  13841. };
  13842. _proto._enter = function _enter(event, context) {
  13843. var dataKey = this.constructor.DATA_KEY;
  13844. context = context || $__default['default'](event.currentTarget).data(dataKey);
  13845. if (!context) {
  13846. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  13847. $__default['default'](event.currentTarget).data(dataKey, context);
  13848. }
  13849. if (event) {
  13850. context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
  13851. }
  13852. if ($__default['default'](context.getTipElement()).hasClass(CLASS_NAME_SHOW$4) || context._hoverState === HOVER_STATE_SHOW) {
  13853. context._hoverState = HOVER_STATE_SHOW;
  13854. return;
  13855. }
  13856. clearTimeout(context._timeout);
  13857. context._hoverState = HOVER_STATE_SHOW;
  13858. if (!context.config.delay || !context.config.delay.show) {
  13859. context.show();
  13860. return;
  13861. }
  13862. context._timeout = setTimeout(function () {
  13863. if (context._hoverState === HOVER_STATE_SHOW) {
  13864. context.show();
  13865. }
  13866. }, context.config.delay.show);
  13867. };
  13868. _proto._leave = function _leave(event, context) {
  13869. var dataKey = this.constructor.DATA_KEY;
  13870. context = context || $__default['default'](event.currentTarget).data(dataKey);
  13871. if (!context) {
  13872. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  13873. $__default['default'](event.currentTarget).data(dataKey, context);
  13874. }
  13875. if (event) {
  13876. context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = false;
  13877. }
  13878. if (context._isWithActiveTrigger()) {
  13879. return;
  13880. }
  13881. clearTimeout(context._timeout);
  13882. context._hoverState = HOVER_STATE_OUT;
  13883. if (!context.config.delay || !context.config.delay.hide) {
  13884. context.hide();
  13885. return;
  13886. }
  13887. context._timeout = setTimeout(function () {
  13888. if (context._hoverState === HOVER_STATE_OUT) {
  13889. context.hide();
  13890. }
  13891. }, context.config.delay.hide);
  13892. };
  13893. _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
  13894. for (var trigger in this._activeTrigger) {
  13895. if (this._activeTrigger[trigger]) {
  13896. return true;
  13897. }
  13898. }
  13899. return false;
  13900. };
  13901. _proto._getConfig = function _getConfig(config) {
  13902. var dataAttributes = $__default['default'](this.element).data();
  13903. Object.keys(dataAttributes).forEach(function (dataAttr) {
  13904. if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
  13905. delete dataAttributes[dataAttr];
  13906. }
  13907. });
  13908. config = _extends({}, this.constructor.Default, dataAttributes, typeof config === 'object' && config ? config : {});
  13909. if (typeof config.delay === 'number') {
  13910. config.delay = {
  13911. show: config.delay,
  13912. hide: config.delay
  13913. };
  13914. }
  13915. if (typeof config.title === 'number') {
  13916. config.title = config.title.toString();
  13917. }
  13918. if (typeof config.content === 'number') {
  13919. config.content = config.content.toString();
  13920. }
  13921. Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
  13922. if (config.sanitize) {
  13923. config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
  13924. }
  13925. return config;
  13926. };
  13927. _proto._getDelegateConfig = function _getDelegateConfig() {
  13928. var config = {};
  13929. if (this.config) {
  13930. for (var key in this.config) {
  13931. if (this.constructor.Default[key] !== this.config[key]) {
  13932. config[key] = this.config[key];
  13933. }
  13934. }
  13935. }
  13936. return config;
  13937. };
  13938. _proto._cleanTipClass = function _cleanTipClass() {
  13939. var $tip = $__default['default'](this.getTipElement());
  13940. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  13941. if (tabClass !== null && tabClass.length) {
  13942. $tip.removeClass(tabClass.join(''));
  13943. }
  13944. };
  13945. _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
  13946. this.tip = popperData.instance.popper;
  13947. this._cleanTipClass();
  13948. this.addAttachmentClass(this._getAttachment(popperData.placement));
  13949. };
  13950. _proto._fixTransition = function _fixTransition() {
  13951. var tip = this.getTipElement();
  13952. var initConfigAnimation = this.config.animation;
  13953. if (tip.getAttribute('x-placement') !== null) {
  13954. return;
  13955. }
  13956. $__default['default'](tip).removeClass(CLASS_NAME_FADE$2);
  13957. this.config.animation = false;
  13958. this.hide();
  13959. this.show();
  13960. this.config.animation = initConfigAnimation;
  13961. } // Static
  13962. ;
  13963. Tooltip._jQueryInterface = function _jQueryInterface(config) {
  13964. return this.each(function () {
  13965. var $element = $__default['default'](this);
  13966. var data = $element.data(DATA_KEY$6);
  13967. var _config = typeof config === 'object' && config;
  13968. if (!data && /dispose|hide/.test(config)) {
  13969. return;
  13970. }
  13971. if (!data) {
  13972. data = new Tooltip(this, _config);
  13973. $element.data(DATA_KEY$6, data);
  13974. }
  13975. if (typeof config === 'string') {
  13976. if (typeof data[config] === 'undefined') {
  13977. throw new TypeError("No method named \"" + config + "\"");
  13978. }
  13979. data[config]();
  13980. }
  13981. });
  13982. };
  13983. _createClass(Tooltip, null, [{
  13984. key: "VERSION",
  13985. get: function get() {
  13986. return VERSION$6;
  13987. }
  13988. }, {
  13989. key: "Default",
  13990. get: function get() {
  13991. return Default$4;
  13992. }
  13993. }, {
  13994. key: "NAME",
  13995. get: function get() {
  13996. return NAME$6;
  13997. }
  13998. }, {
  13999. key: "DATA_KEY",
  14000. get: function get() {
  14001. return DATA_KEY$6;
  14002. }
  14003. }, {
  14004. key: "Event",
  14005. get: function get() {
  14006. return Event;
  14007. }
  14008. }, {
  14009. key: "EVENT_KEY",
  14010. get: function get() {
  14011. return EVENT_KEY$6;
  14012. }
  14013. }, {
  14014. key: "DefaultType",
  14015. get: function get() {
  14016. return DefaultType$4;
  14017. }
  14018. }]);
  14019. return Tooltip;
  14020. }();
  14021. /**
  14022. * ------------------------------------------------------------------------
  14023. * jQuery
  14024. * ------------------------------------------------------------------------
  14025. */
  14026. $__default['default'].fn[NAME$6] = Tooltip._jQueryInterface;
  14027. $__default['default'].fn[NAME$6].Constructor = Tooltip;
  14028. $__default['default'].fn[NAME$6].noConflict = function () {
  14029. $__default['default'].fn[NAME$6] = JQUERY_NO_CONFLICT$6;
  14030. return Tooltip._jQueryInterface;
  14031. };
  14032. /**
  14033. * ------------------------------------------------------------------------
  14034. * Constants
  14035. * ------------------------------------------------------------------------
  14036. */
  14037. var NAME$7 = 'popover';
  14038. var VERSION$7 = '4.5.3';
  14039. var DATA_KEY$7 = 'bs.popover';
  14040. var EVENT_KEY$7 = "." + DATA_KEY$7;
  14041. var JQUERY_NO_CONFLICT$7 = $__default['default'].fn[NAME$7];
  14042. var CLASS_PREFIX$1 = 'bs-popover';
  14043. var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
  14044. var Default$5 = _extends({}, Tooltip.Default, {
  14045. placement: 'right',
  14046. trigger: 'click',
  14047. content: '',
  14048. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  14049. });
  14050. var DefaultType$5 = _extends({}, Tooltip.DefaultType, {
  14051. content: '(string|element|function)'
  14052. });
  14053. var CLASS_NAME_FADE$3 = 'fade';
  14054. var CLASS_NAME_SHOW$5 = 'show';
  14055. var SELECTOR_TITLE = '.popover-header';
  14056. var SELECTOR_CONTENT = '.popover-body';
  14057. var Event$1 = {
  14058. HIDE: "hide" + EVENT_KEY$7,
  14059. HIDDEN: "hidden" + EVENT_KEY$7,
  14060. SHOW: "show" + EVENT_KEY$7,
  14061. SHOWN: "shown" + EVENT_KEY$7,
  14062. INSERTED: "inserted" + EVENT_KEY$7,
  14063. CLICK: "click" + EVENT_KEY$7,
  14064. FOCUSIN: "focusin" + EVENT_KEY$7,
  14065. FOCUSOUT: "focusout" + EVENT_KEY$7,
  14066. MOUSEENTER: "mouseenter" + EVENT_KEY$7,
  14067. MOUSELEAVE: "mouseleave" + EVENT_KEY$7
  14068. };
  14069. /**
  14070. * ------------------------------------------------------------------------
  14071. * Class Definition
  14072. * ------------------------------------------------------------------------
  14073. */
  14074. var Popover = /*#__PURE__*/function (_Tooltip) {
  14075. _inheritsLoose(Popover, _Tooltip);
  14076. function Popover() {
  14077. return _Tooltip.apply(this, arguments) || this;
  14078. }
  14079. var _proto = Popover.prototype;
  14080. // Overrides
  14081. _proto.isWithContent = function isWithContent() {
  14082. return this.getTitle() || this._getContent();
  14083. };
  14084. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  14085. $__default['default'](this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment);
  14086. };
  14087. _proto.getTipElement = function getTipElement() {
  14088. this.tip = this.tip || $__default['default'](this.config.template)[0];
  14089. return this.tip;
  14090. };
  14091. _proto.setContent = function setContent() {
  14092. var $tip = $__default['default'](this.getTipElement()); // We use append for html objects to maintain js events
  14093. this.setElementContent($tip.find(SELECTOR_TITLE), this.getTitle());
  14094. var content = this._getContent();
  14095. if (typeof content === 'function') {
  14096. content = content.call(this.element);
  14097. }
  14098. this.setElementContent($tip.find(SELECTOR_CONTENT), content);
  14099. $tip.removeClass(CLASS_NAME_FADE$3 + " " + CLASS_NAME_SHOW$5);
  14100. } // Private
  14101. ;
  14102. _proto._getContent = function _getContent() {
  14103. return this.element.getAttribute('data-content') || this.config.content;
  14104. };
  14105. _proto._cleanTipClass = function _cleanTipClass() {
  14106. var $tip = $__default['default'](this.getTipElement());
  14107. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1);
  14108. if (tabClass !== null && tabClass.length > 0) {
  14109. $tip.removeClass(tabClass.join(''));
  14110. }
  14111. } // Static
  14112. ;
  14113. Popover._jQueryInterface = function _jQueryInterface(config) {
  14114. return this.each(function () {
  14115. var data = $__default['default'](this).data(DATA_KEY$7);
  14116. var _config = typeof config === 'object' ? config : null;
  14117. if (!data && /dispose|hide/.test(config)) {
  14118. return;
  14119. }
  14120. if (!data) {
  14121. data = new Popover(this, _config);
  14122. $__default['default'](this).data(DATA_KEY$7, data);
  14123. }
  14124. if (typeof config === 'string') {
  14125. if (typeof data[config] === 'undefined') {
  14126. throw new TypeError("No method named \"" + config + "\"");
  14127. }
  14128. data[config]();
  14129. }
  14130. });
  14131. };
  14132. _createClass(Popover, null, [{
  14133. key: "VERSION",
  14134. // Getters
  14135. get: function get() {
  14136. return VERSION$7;
  14137. }
  14138. }, {
  14139. key: "Default",
  14140. get: function get() {
  14141. return Default$5;
  14142. }
  14143. }, {
  14144. key: "NAME",
  14145. get: function get() {
  14146. return NAME$7;
  14147. }
  14148. }, {
  14149. key: "DATA_KEY",
  14150. get: function get() {
  14151. return DATA_KEY$7;
  14152. }
  14153. }, {
  14154. key: "Event",
  14155. get: function get() {
  14156. return Event$1;
  14157. }
  14158. }, {
  14159. key: "EVENT_KEY",
  14160. get: function get() {
  14161. return EVENT_KEY$7;
  14162. }
  14163. }, {
  14164. key: "DefaultType",
  14165. get: function get() {
  14166. return DefaultType$5;
  14167. }
  14168. }]);
  14169. return Popover;
  14170. }(Tooltip);
  14171. /**
  14172. * ------------------------------------------------------------------------
  14173. * jQuery
  14174. * ------------------------------------------------------------------------
  14175. */
  14176. $__default['default'].fn[NAME$7] = Popover._jQueryInterface;
  14177. $__default['default'].fn[NAME$7].Constructor = Popover;
  14178. $__default['default'].fn[NAME$7].noConflict = function () {
  14179. $__default['default'].fn[NAME$7] = JQUERY_NO_CONFLICT$7;
  14180. return Popover._jQueryInterface;
  14181. };
  14182. /**
  14183. * ------------------------------------------------------------------------
  14184. * Constants
  14185. * ------------------------------------------------------------------------
  14186. */
  14187. var NAME$8 = 'scrollspy';
  14188. var VERSION$8 = '4.5.3';
  14189. var DATA_KEY$8 = 'bs.scrollspy';
  14190. var EVENT_KEY$8 = "." + DATA_KEY$8;
  14191. var DATA_API_KEY$6 = '.data-api';
  14192. var JQUERY_NO_CONFLICT$8 = $__default['default'].fn[NAME$8];
  14193. var Default$6 = {
  14194. offset: 10,
  14195. method: 'auto',
  14196. target: ''
  14197. };
  14198. var DefaultType$6 = {
  14199. offset: 'number',
  14200. method: 'string',
  14201. target: '(string|element)'
  14202. };
  14203. var EVENT_ACTIVATE = "activate" + EVENT_KEY$8;
  14204. var EVENT_SCROLL = "scroll" + EVENT_KEY$8;
  14205. var EVENT_LOAD_DATA_API$2 = "load" + EVENT_KEY$8 + DATA_API_KEY$6;
  14206. var CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
  14207. var CLASS_NAME_ACTIVE$2 = 'active';
  14208. var SELECTOR_DATA_SPY = '[data-spy="scroll"]';
  14209. var SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
  14210. var SELECTOR_NAV_LINKS = '.nav-link';
  14211. var SELECTOR_NAV_ITEMS = '.nav-item';
  14212. var SELECTOR_LIST_ITEMS = '.list-group-item';
  14213. var SELECTOR_DROPDOWN = '.dropdown';
  14214. var SELECTOR_DROPDOWN_ITEMS = '.dropdown-item';
  14215. var SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
  14216. var METHOD_OFFSET = 'offset';
  14217. var METHOD_POSITION = 'position';
  14218. /**
  14219. * ------------------------------------------------------------------------
  14220. * Class Definition
  14221. * ------------------------------------------------------------------------
  14222. */
  14223. var ScrollSpy = /*#__PURE__*/function () {
  14224. function ScrollSpy(element, config) {
  14225. var _this = this;
  14226. this._element = element;
  14227. this._scrollElement = element.tagName === 'BODY' ? window : element;
  14228. this._config = this._getConfig(config);
  14229. this._selector = this._config.target + " " + SELECTOR_NAV_LINKS + "," + (this._config.target + " " + SELECTOR_LIST_ITEMS + ",") + (this._config.target + " " + SELECTOR_DROPDOWN_ITEMS);
  14230. this._offsets = [];
  14231. this._targets = [];
  14232. this._activeTarget = null;
  14233. this._scrollHeight = 0;
  14234. $__default['default'](this._scrollElement).on(EVENT_SCROLL, function (event) {
  14235. return _this._process(event);
  14236. });
  14237. this.refresh();
  14238. this._process();
  14239. } // Getters
  14240. var _proto = ScrollSpy.prototype;
  14241. // Public
  14242. _proto.refresh = function refresh() {
  14243. var _this2 = this;
  14244. var autoMethod = this._scrollElement === this._scrollElement.window ? METHOD_OFFSET : METHOD_POSITION;
  14245. var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
  14246. var offsetBase = offsetMethod === METHOD_POSITION ? this._getScrollTop() : 0;
  14247. this._offsets = [];
  14248. this._targets = [];
  14249. this._scrollHeight = this._getScrollHeight();
  14250. var targets = [].slice.call(document.querySelectorAll(this._selector));
  14251. targets.map(function (element) {
  14252. var target;
  14253. var targetSelector = Util.getSelectorFromElement(element);
  14254. if (targetSelector) {
  14255. target = document.querySelector(targetSelector);
  14256. }
  14257. if (target) {
  14258. var targetBCR = target.getBoundingClientRect();
  14259. if (targetBCR.width || targetBCR.height) {
  14260. // TODO (fat): remove sketch reliance on jQuery position/offset
  14261. return [$__default['default'](target)[offsetMethod]().top + offsetBase, targetSelector];
  14262. }
  14263. }
  14264. return null;
  14265. }).filter(function (item) {
  14266. return item;
  14267. }).sort(function (a, b) {
  14268. return a[0] - b[0];
  14269. }).forEach(function (item) {
  14270. _this2._offsets.push(item[0]);
  14271. _this2._targets.push(item[1]);
  14272. });
  14273. };
  14274. _proto.dispose = function dispose() {
  14275. $__default['default'].removeData(this._element, DATA_KEY$8);
  14276. $__default['default'](this._scrollElement).off(EVENT_KEY$8);
  14277. this._element = null;
  14278. this._scrollElement = null;
  14279. this._config = null;
  14280. this._selector = null;
  14281. this._offsets = null;
  14282. this._targets = null;
  14283. this._activeTarget = null;
  14284. this._scrollHeight = null;
  14285. } // Private
  14286. ;
  14287. _proto._getConfig = function _getConfig(config) {
  14288. config = _extends({}, Default$6, typeof config === 'object' && config ? config : {});
  14289. if (typeof config.target !== 'string' && Util.isElement(config.target)) {
  14290. var id = $__default['default'](config.target).attr('id');
  14291. if (!id) {
  14292. id = Util.getUID(NAME$8);
  14293. $__default['default'](config.target).attr('id', id);
  14294. }
  14295. config.target = "#" + id;
  14296. }
  14297. Util.typeCheckConfig(NAME$8, config, DefaultType$6);
  14298. return config;
  14299. };
  14300. _proto._getScrollTop = function _getScrollTop() {
  14301. return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
  14302. };
  14303. _proto._getScrollHeight = function _getScrollHeight() {
  14304. return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  14305. };
  14306. _proto._getOffsetHeight = function _getOffsetHeight() {
  14307. return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
  14308. };
  14309. _proto._process = function _process() {
  14310. var scrollTop = this._getScrollTop() + this._config.offset;
  14311. var scrollHeight = this._getScrollHeight();
  14312. var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
  14313. if (this._scrollHeight !== scrollHeight) {
  14314. this.refresh();
  14315. }
  14316. if (scrollTop >= maxScroll) {
  14317. var target = this._targets[this._targets.length - 1];
  14318. if (this._activeTarget !== target) {
  14319. this._activate(target);
  14320. }
  14321. return;
  14322. }
  14323. if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
  14324. this._activeTarget = null;
  14325. this._clear();
  14326. return;
  14327. }
  14328. for (var i = this._offsets.length; i--;) {
  14329. var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
  14330. if (isActiveTarget) {
  14331. this._activate(this._targets[i]);
  14332. }
  14333. }
  14334. };
  14335. _proto._activate = function _activate(target) {
  14336. this._activeTarget = target;
  14337. this._clear();
  14338. var queries = this._selector.split(',').map(function (selector) {
  14339. return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
  14340. });
  14341. var $link = $__default['default']([].slice.call(document.querySelectorAll(queries.join(','))));
  14342. if ($link.hasClass(CLASS_NAME_DROPDOWN_ITEM)) {
  14343. $link.closest(SELECTOR_DROPDOWN).find(SELECTOR_DROPDOWN_TOGGLE).addClass(CLASS_NAME_ACTIVE$2);
  14344. $link.addClass(CLASS_NAME_ACTIVE$2);
  14345. } else {
  14346. // Set triggered link as active
  14347. $link.addClass(CLASS_NAME_ACTIVE$2); // Set triggered links parents as active
  14348. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  14349. $link.parents(SELECTOR_NAV_LIST_GROUP).prev(SELECTOR_NAV_LINKS + ", " + SELECTOR_LIST_ITEMS).addClass(CLASS_NAME_ACTIVE$2); // Handle special case when .nav-link is inside .nav-item
  14350. $link.parents(SELECTOR_NAV_LIST_GROUP).prev(SELECTOR_NAV_ITEMS).children(SELECTOR_NAV_LINKS).addClass(CLASS_NAME_ACTIVE$2);
  14351. }
  14352. $__default['default'](this._scrollElement).trigger(EVENT_ACTIVATE, {
  14353. relatedTarget: target
  14354. });
  14355. };
  14356. _proto._clear = function _clear() {
  14357. [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
  14358. return node.classList.contains(CLASS_NAME_ACTIVE$2);
  14359. }).forEach(function (node) {
  14360. return node.classList.remove(CLASS_NAME_ACTIVE$2);
  14361. });
  14362. } // Static
  14363. ;
  14364. ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
  14365. return this.each(function () {
  14366. var data = $__default['default'](this).data(DATA_KEY$8);
  14367. var _config = typeof config === 'object' && config;
  14368. if (!data) {
  14369. data = new ScrollSpy(this, _config);
  14370. $__default['default'](this).data(DATA_KEY$8, data);
  14371. }
  14372. if (typeof config === 'string') {
  14373. if (typeof data[config] === 'undefined') {
  14374. throw new TypeError("No method named \"" + config + "\"");
  14375. }
  14376. data[config]();
  14377. }
  14378. });
  14379. };
  14380. _createClass(ScrollSpy, null, [{
  14381. key: "VERSION",
  14382. get: function get() {
  14383. return VERSION$8;
  14384. }
  14385. }, {
  14386. key: "Default",
  14387. get: function get() {
  14388. return Default$6;
  14389. }
  14390. }]);
  14391. return ScrollSpy;
  14392. }();
  14393. /**
  14394. * ------------------------------------------------------------------------
  14395. * Data Api implementation
  14396. * ------------------------------------------------------------------------
  14397. */
  14398. $__default['default'](window).on(EVENT_LOAD_DATA_API$2, function () {
  14399. var scrollSpys = [].slice.call(document.querySelectorAll(SELECTOR_DATA_SPY));
  14400. var scrollSpysLength = scrollSpys.length;
  14401. for (var i = scrollSpysLength; i--;) {
  14402. var $spy = $__default['default'](scrollSpys[i]);
  14403. ScrollSpy._jQueryInterface.call($spy, $spy.data());
  14404. }
  14405. });
  14406. /**
  14407. * ------------------------------------------------------------------------
  14408. * jQuery
  14409. * ------------------------------------------------------------------------
  14410. */
  14411. $__default['default'].fn[NAME$8] = ScrollSpy._jQueryInterface;
  14412. $__default['default'].fn[NAME$8].Constructor = ScrollSpy;
  14413. $__default['default'].fn[NAME$8].noConflict = function () {
  14414. $__default['default'].fn[NAME$8] = JQUERY_NO_CONFLICT$8;
  14415. return ScrollSpy._jQueryInterface;
  14416. };
  14417. /**
  14418. * ------------------------------------------------------------------------
  14419. * Constants
  14420. * ------------------------------------------------------------------------
  14421. */
  14422. var NAME$9 = 'tab';
  14423. var VERSION$9 = '4.5.3';
  14424. var DATA_KEY$9 = 'bs.tab';
  14425. var EVENT_KEY$9 = "." + DATA_KEY$9;
  14426. var DATA_API_KEY$7 = '.data-api';
  14427. var JQUERY_NO_CONFLICT$9 = $__default['default'].fn[NAME$9];
  14428. var EVENT_HIDE$3 = "hide" + EVENT_KEY$9;
  14429. var EVENT_HIDDEN$3 = "hidden" + EVENT_KEY$9;
  14430. var EVENT_SHOW$3 = "show" + EVENT_KEY$9;
  14431. var EVENT_SHOWN$3 = "shown" + EVENT_KEY$9;
  14432. var EVENT_CLICK_DATA_API$6 = "click" + EVENT_KEY$9 + DATA_API_KEY$7;
  14433. var CLASS_NAME_DROPDOWN_MENU = 'dropdown-menu';
  14434. var CLASS_NAME_ACTIVE$3 = 'active';
  14435. var CLASS_NAME_DISABLED$1 = 'disabled';
  14436. var CLASS_NAME_FADE$4 = 'fade';
  14437. var CLASS_NAME_SHOW$6 = 'show';
  14438. var SELECTOR_DROPDOWN$1 = '.dropdown';
  14439. var SELECTOR_NAV_LIST_GROUP$1 = '.nav, .list-group';
  14440. var SELECTOR_ACTIVE$2 = '.active';
  14441. var SELECTOR_ACTIVE_UL = '> li > .active';
  14442. var SELECTOR_DATA_TOGGLE$4 = '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]';
  14443. var SELECTOR_DROPDOWN_TOGGLE$1 = '.dropdown-toggle';
  14444. var SELECTOR_DROPDOWN_ACTIVE_CHILD = '> .dropdown-menu .active';
  14445. /**
  14446. * ------------------------------------------------------------------------
  14447. * Class Definition
  14448. * ------------------------------------------------------------------------
  14449. */
  14450. var Tab = /*#__PURE__*/function () {
  14451. function Tab(element) {
  14452. this._element = element;
  14453. } // Getters
  14454. var _proto = Tab.prototype;
  14455. // Public
  14456. _proto.show = function show() {
  14457. var _this = this;
  14458. if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $__default['default'](this._element).hasClass(CLASS_NAME_ACTIVE$3) || $__default['default'](this._element).hasClass(CLASS_NAME_DISABLED$1)) {
  14459. return;
  14460. }
  14461. var target;
  14462. var previous;
  14463. var listElement = $__default['default'](this._element).closest(SELECTOR_NAV_LIST_GROUP$1)[0];
  14464. var selector = Util.getSelectorFromElement(this._element);
  14465. if (listElement) {
  14466. var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? SELECTOR_ACTIVE_UL : SELECTOR_ACTIVE$2;
  14467. previous = $__default['default'].makeArray($__default['default'](listElement).find(itemSelector));
  14468. previous = previous[previous.length - 1];
  14469. }
  14470. var hideEvent = $__default['default'].Event(EVENT_HIDE$3, {
  14471. relatedTarget: this._element
  14472. });
  14473. var showEvent = $__default['default'].Event(EVENT_SHOW$3, {
  14474. relatedTarget: previous
  14475. });
  14476. if (previous) {
  14477. $__default['default'](previous).trigger(hideEvent);
  14478. }
  14479. $__default['default'](this._element).trigger(showEvent);
  14480. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
  14481. return;
  14482. }
  14483. if (selector) {
  14484. target = document.querySelector(selector);
  14485. }
  14486. this._activate(this._element, listElement);
  14487. var complete = function complete() {
  14488. var hiddenEvent = $__default['default'].Event(EVENT_HIDDEN$3, {
  14489. relatedTarget: _this._element
  14490. });
  14491. var shownEvent = $__default['default'].Event(EVENT_SHOWN$3, {
  14492. relatedTarget: previous
  14493. });
  14494. $__default['default'](previous).trigger(hiddenEvent);
  14495. $__default['default'](_this._element).trigger(shownEvent);
  14496. };
  14497. if (target) {
  14498. this._activate(target, target.parentNode, complete);
  14499. } else {
  14500. complete();
  14501. }
  14502. };
  14503. _proto.dispose = function dispose() {
  14504. $__default['default'].removeData(this._element, DATA_KEY$9);
  14505. this._element = null;
  14506. } // Private
  14507. ;
  14508. _proto._activate = function _activate(element, container, callback) {
  14509. var _this2 = this;
  14510. var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $__default['default'](container).find(SELECTOR_ACTIVE_UL) : $__default['default'](container).children(SELECTOR_ACTIVE$2);
  14511. var active = activeElements[0];
  14512. var isTransitioning = callback && active && $__default['default'](active).hasClass(CLASS_NAME_FADE$4);
  14513. var complete = function complete() {
  14514. return _this2._transitionComplete(element, active, callback);
  14515. };
  14516. if (active && isTransitioning) {
  14517. var transitionDuration = Util.getTransitionDurationFromElement(active);
  14518. $__default['default'](active).removeClass(CLASS_NAME_SHOW$6).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  14519. } else {
  14520. complete();
  14521. }
  14522. };
  14523. _proto._transitionComplete = function _transitionComplete(element, active, callback) {
  14524. if (active) {
  14525. $__default['default'](active).removeClass(CLASS_NAME_ACTIVE$3);
  14526. var dropdownChild = $__default['default'](active.parentNode).find(SELECTOR_DROPDOWN_ACTIVE_CHILD)[0];
  14527. if (dropdownChild) {
  14528. $__default['default'](dropdownChild).removeClass(CLASS_NAME_ACTIVE$3);
  14529. }
  14530. if (active.getAttribute('role') === 'tab') {
  14531. active.setAttribute('aria-selected', false);
  14532. }
  14533. }
  14534. $__default['default'](element).addClass(CLASS_NAME_ACTIVE$3);
  14535. if (element.getAttribute('role') === 'tab') {
  14536. element.setAttribute('aria-selected', true);
  14537. }
  14538. Util.reflow(element);
  14539. if (element.classList.contains(CLASS_NAME_FADE$4)) {
  14540. element.classList.add(CLASS_NAME_SHOW$6);
  14541. }
  14542. if (element.parentNode && $__default['default'](element.parentNode).hasClass(CLASS_NAME_DROPDOWN_MENU)) {
  14543. var dropdownElement = $__default['default'](element).closest(SELECTOR_DROPDOWN$1)[0];
  14544. if (dropdownElement) {
  14545. var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(SELECTOR_DROPDOWN_TOGGLE$1));
  14546. $__default['default'](dropdownToggleList).addClass(CLASS_NAME_ACTIVE$3);
  14547. }
  14548. element.setAttribute('aria-expanded', true);
  14549. }
  14550. if (callback) {
  14551. callback();
  14552. }
  14553. } // Static
  14554. ;
  14555. Tab._jQueryInterface = function _jQueryInterface(config) {
  14556. return this.each(function () {
  14557. var $this = $__default['default'](this);
  14558. var data = $this.data(DATA_KEY$9);
  14559. if (!data) {
  14560. data = new Tab(this);
  14561. $this.data(DATA_KEY$9, data);
  14562. }
  14563. if (typeof config === 'string') {
  14564. if (typeof data[config] === 'undefined') {
  14565. throw new TypeError("No method named \"" + config + "\"");
  14566. }
  14567. data[config]();
  14568. }
  14569. });
  14570. };
  14571. _createClass(Tab, null, [{
  14572. key: "VERSION",
  14573. get: function get() {
  14574. return VERSION$9;
  14575. }
  14576. }]);
  14577. return Tab;
  14578. }();
  14579. /**
  14580. * ------------------------------------------------------------------------
  14581. * Data Api implementation
  14582. * ------------------------------------------------------------------------
  14583. */
  14584. $__default['default'](document).on(EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$4, function (event) {
  14585. event.preventDefault();
  14586. Tab._jQueryInterface.call($__default['default'](this), 'show');
  14587. });
  14588. /**
  14589. * ------------------------------------------------------------------------
  14590. * jQuery
  14591. * ------------------------------------------------------------------------
  14592. */
  14593. $__default['default'].fn[NAME$9] = Tab._jQueryInterface;
  14594. $__default['default'].fn[NAME$9].Constructor = Tab;
  14595. $__default['default'].fn[NAME$9].noConflict = function () {
  14596. $__default['default'].fn[NAME$9] = JQUERY_NO_CONFLICT$9;
  14597. return Tab._jQueryInterface;
  14598. };
  14599. /**
  14600. * ------------------------------------------------------------------------
  14601. * Constants
  14602. * ------------------------------------------------------------------------
  14603. */
  14604. var NAME$a = 'toast';
  14605. var VERSION$a = '4.5.3';
  14606. var DATA_KEY$a = 'bs.toast';
  14607. var EVENT_KEY$a = "." + DATA_KEY$a;
  14608. var JQUERY_NO_CONFLICT$a = $__default['default'].fn[NAME$a];
  14609. var EVENT_CLICK_DISMISS$1 = "click.dismiss" + EVENT_KEY$a;
  14610. var EVENT_HIDE$4 = "hide" + EVENT_KEY$a;
  14611. var EVENT_HIDDEN$4 = "hidden" + EVENT_KEY$a;
  14612. var EVENT_SHOW$4 = "show" + EVENT_KEY$a;
  14613. var EVENT_SHOWN$4 = "shown" + EVENT_KEY$a;
  14614. var CLASS_NAME_FADE$5 = 'fade';
  14615. var CLASS_NAME_HIDE = 'hide';
  14616. var CLASS_NAME_SHOW$7 = 'show';
  14617. var CLASS_NAME_SHOWING = 'showing';
  14618. var DefaultType$7 = {
  14619. animation: 'boolean',
  14620. autohide: 'boolean',
  14621. delay: 'number'
  14622. };
  14623. var Default$7 = {
  14624. animation: true,
  14625. autohide: true,
  14626. delay: 500
  14627. };
  14628. var SELECTOR_DATA_DISMISS$1 = '[data-dismiss="toast"]';
  14629. /**
  14630. * ------------------------------------------------------------------------
  14631. * Class Definition
  14632. * ------------------------------------------------------------------------
  14633. */
  14634. var Toast = /*#__PURE__*/function () {
  14635. function Toast(element, config) {
  14636. this._element = element;
  14637. this._config = this._getConfig(config);
  14638. this._timeout = null;
  14639. this._setListeners();
  14640. } // Getters
  14641. var _proto = Toast.prototype;
  14642. // Public
  14643. _proto.show = function show() {
  14644. var _this = this;
  14645. var showEvent = $__default['default'].Event(EVENT_SHOW$4);
  14646. $__default['default'](this._element).trigger(showEvent);
  14647. if (showEvent.isDefaultPrevented()) {
  14648. return;
  14649. }
  14650. this._clearTimeout();
  14651. if (this._config.animation) {
  14652. this._element.classList.add(CLASS_NAME_FADE$5);
  14653. }
  14654. var complete = function complete() {
  14655. _this._element.classList.remove(CLASS_NAME_SHOWING);
  14656. _this._element.classList.add(CLASS_NAME_SHOW$7);
  14657. $__default['default'](_this._element).trigger(EVENT_SHOWN$4);
  14658. if (_this._config.autohide) {
  14659. _this._timeout = setTimeout(function () {
  14660. _this.hide();
  14661. }, _this._config.delay);
  14662. }
  14663. };
  14664. this._element.classList.remove(CLASS_NAME_HIDE);
  14665. Util.reflow(this._element);
  14666. this._element.classList.add(CLASS_NAME_SHOWING);
  14667. if (this._config.animation) {
  14668. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  14669. $__default['default'](this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  14670. } else {
  14671. complete();
  14672. }
  14673. };
  14674. _proto.hide = function hide() {
  14675. if (!this._element.classList.contains(CLASS_NAME_SHOW$7)) {
  14676. return;
  14677. }
  14678. var hideEvent = $__default['default'].Event(EVENT_HIDE$4);
  14679. $__default['default'](this._element).trigger(hideEvent);
  14680. if (hideEvent.isDefaultPrevented()) {
  14681. return;
  14682. }
  14683. this._close();
  14684. };
  14685. _proto.dispose = function dispose() {
  14686. this._clearTimeout();
  14687. if (this._element.classList.contains(CLASS_NAME_SHOW$7)) {
  14688. this._element.classList.remove(CLASS_NAME_SHOW$7);
  14689. }
  14690. $__default['default'](this._element).off(EVENT_CLICK_DISMISS$1);
  14691. $__default['default'].removeData(this._element, DATA_KEY$a);
  14692. this._element = null;
  14693. this._config = null;
  14694. } // Private
  14695. ;
  14696. _proto._getConfig = function _getConfig(config) {
  14697. config = _extends({}, Default$7, $__default['default'](this._element).data(), typeof config === 'object' && config ? config : {});
  14698. Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType);
  14699. return config;
  14700. };
  14701. _proto._setListeners = function _setListeners() {
  14702. var _this2 = this;
  14703. $__default['default'](this._element).on(EVENT_CLICK_DISMISS$1, SELECTOR_DATA_DISMISS$1, function () {
  14704. return _this2.hide();
  14705. });
  14706. };
  14707. _proto._close = function _close() {
  14708. var _this3 = this;
  14709. var complete = function complete() {
  14710. _this3._element.classList.add(CLASS_NAME_HIDE);
  14711. $__default['default'](_this3._element).trigger(EVENT_HIDDEN$4);
  14712. };
  14713. this._element.classList.remove(CLASS_NAME_SHOW$7);
  14714. if (this._config.animation) {
  14715. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  14716. $__default['default'](this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  14717. } else {
  14718. complete();
  14719. }
  14720. };
  14721. _proto._clearTimeout = function _clearTimeout() {
  14722. clearTimeout(this._timeout);
  14723. this._timeout = null;
  14724. } // Static
  14725. ;
  14726. Toast._jQueryInterface = function _jQueryInterface(config) {
  14727. return this.each(function () {
  14728. var $element = $__default['default'](this);
  14729. var data = $element.data(DATA_KEY$a);
  14730. var _config = typeof config === 'object' && config;
  14731. if (!data) {
  14732. data = new Toast(this, _config);
  14733. $element.data(DATA_KEY$a, data);
  14734. }
  14735. if (typeof config === 'string') {
  14736. if (typeof data[config] === 'undefined') {
  14737. throw new TypeError("No method named \"" + config + "\"");
  14738. }
  14739. data[config](this);
  14740. }
  14741. });
  14742. };
  14743. _createClass(Toast, null, [{
  14744. key: "VERSION",
  14745. get: function get() {
  14746. return VERSION$a;
  14747. }
  14748. }, {
  14749. key: "DefaultType",
  14750. get: function get() {
  14751. return DefaultType$7;
  14752. }
  14753. }, {
  14754. key: "Default",
  14755. get: function get() {
  14756. return Default$7;
  14757. }
  14758. }]);
  14759. return Toast;
  14760. }();
  14761. /**
  14762. * ------------------------------------------------------------------------
  14763. * jQuery
  14764. * ------------------------------------------------------------------------
  14765. */
  14766. $__default['default'].fn[NAME$a] = Toast._jQueryInterface;
  14767. $__default['default'].fn[NAME$a].Constructor = Toast;
  14768. $__default['default'].fn[NAME$a].noConflict = function () {
  14769. $__default['default'].fn[NAME$a] = JQUERY_NO_CONFLICT$a;
  14770. return Toast._jQueryInterface;
  14771. };
  14772. exports.Alert = Alert;
  14773. exports.Button = Button;
  14774. exports.Carousel = Carousel;
  14775. exports.Collapse = Collapse;
  14776. exports.Dropdown = Dropdown;
  14777. exports.Modal = Modal;
  14778. exports.Popover = Popover;
  14779. exports.Scrollspy = ScrollSpy;
  14780. exports.Tab = Tab;
  14781. exports.Toast = Toast;
  14782. exports.Tooltip = Tooltip;
  14783. exports.Util = Util;
  14784. Object.defineProperty(exports, '__esModule', { value: true });
  14785. })));
  14786. //# sourceMappingURL=bootstrap.bundle.js.map
  14787. /*!
  14788. * iCheck v1.0.3, http://git.io/arlzeA
  14789. * ===================================
  14790. * Powerful jQuery and Zepto plugin for checkboxes and radio buttons customization
  14791. *
  14792. * (c) 2013 Damir Sultanov, http://fronteed.com
  14793. * MIT Licensed
  14794. */
  14795. (function($) {
  14796. // Cached vars
  14797. var _iCheck = 'iCheck',
  14798. _iCheckHelper = _iCheck + '-helper',
  14799. _checkbox = 'checkbox',
  14800. _radio = 'radio',
  14801. _checked = 'checked',
  14802. _unchecked = 'un' + _checked,
  14803. _disabled = 'disabled',
  14804. _determinate = 'determinate',
  14805. _indeterminate = 'in' + _determinate,
  14806. _update = 'update',
  14807. _type = 'type',
  14808. _click = 'click',
  14809. _touch = 'touchbegin.i touchend.i',
  14810. _add = 'addClass',
  14811. _remove = 'removeClass',
  14812. _callback = 'trigger',
  14813. _label = 'label',
  14814. _cursor = 'cursor',
  14815. _mobile = /ip(hone|od|ad)|android|blackberry|windows phone|opera mini|silk/i.test(navigator.userAgent) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
  14816. // Plugin init
  14817. $.fn[_iCheck] = function(options, fire) {
  14818. // Walker
  14819. var handle = 'input[type="' + _checkbox + '"], input[type="' + _radio + '"]',
  14820. stack = $(),
  14821. walker = function(object) {
  14822. object.each(function() {
  14823. var self = $(this);
  14824. if (self.is(handle)) {
  14825. stack = stack.add(self);
  14826. } else {
  14827. stack = stack.add(self.find(handle));
  14828. }
  14829. });
  14830. };
  14831. // Check if we should operate with some method
  14832. if (/^(check|uncheck|toggle|indeterminate|determinate|disable|enable|update|destroy)$/i.test(options)) {
  14833. // Normalize method's name
  14834. options = options.toLowerCase();
  14835. // Find checkboxes and radio buttons
  14836. walker(this);
  14837. return stack.each(function() {
  14838. var self = $(this);
  14839. if (options == 'destroy') {
  14840. tidy(self, 'ifDestroyed');
  14841. } else {
  14842. operate(self, true, options);
  14843. }
  14844. // Fire method's callback
  14845. if ($.isFunction(fire)) {
  14846. fire();
  14847. }
  14848. });
  14849. // Customization
  14850. } else if (typeof options == 'object' || !options) {
  14851. // Check if any options were passed
  14852. var settings = $.extend({
  14853. checkedClass: _checked,
  14854. disabledClass: _disabled,
  14855. indeterminateClass: _indeterminate,
  14856. labelHover: true
  14857. }, options),
  14858. selector = settings.handle,
  14859. hoverClass = settings.hoverClass || 'hover',
  14860. focusClass = settings.focusClass || 'focus',
  14861. activeClass = settings.activeClass || 'active',
  14862. labelHover = !!settings.labelHover,
  14863. labelHoverClass = settings.labelHoverClass || 'hover',
  14864. // Setup clickable area
  14865. area = ('' + settings.increaseArea).replace('%', '') | 0;
  14866. // Selector limit
  14867. if (selector == _checkbox || selector == _radio) {
  14868. handle = 'input[type="' + selector + '"]';
  14869. }
  14870. // Clickable area limit
  14871. if (area < -50) {
  14872. area = -50;
  14873. }
  14874. // Walk around the selector
  14875. walker(this);
  14876. return stack.each(function() {
  14877. var self = $(this);
  14878. // If already customized
  14879. tidy(self);
  14880. var node = this,
  14881. id = node.id,
  14882. // Layer styles
  14883. offset = -area + '%',
  14884. size = 100 + (area * 2) + '%',
  14885. layer = {
  14886. position: 'absolute',
  14887. top: offset,
  14888. left: offset,
  14889. display: 'block',
  14890. width: size,
  14891. height: size,
  14892. margin: 0,
  14893. padding: 0,
  14894. background: '#fff',
  14895. border: 0,
  14896. opacity: 0
  14897. },
  14898. // Choose how to hide input
  14899. hide = _mobile ? {
  14900. position: 'absolute',
  14901. visibility: 'hidden'
  14902. } : area ? layer : {
  14903. position: 'absolute',
  14904. opacity: 0
  14905. },
  14906. // Get proper class
  14907. className = node[_type] == _checkbox ? settings.checkboxClass || 'i' + _checkbox : settings.radioClass || 'i' + _radio,
  14908. // Find assigned labels
  14909. label = $(_label + '[for="' + id + '"]').add(self.closest(_label)),
  14910. // Check ARIA option
  14911. aria = !!settings.aria,
  14912. // Set ARIA placeholder
  14913. ariaID = _iCheck + '-' + Math.random().toString(36).substr(2,6),
  14914. // Parent & helper
  14915. parent = '<div class="' + className + '" ' + (aria ? 'role="' + node[_type] + '" ' : ''),
  14916. helper;
  14917. // Set ARIA "labelledby"
  14918. if (aria) {
  14919. label.each(function() {
  14920. parent += 'aria-labelledby="';
  14921. if (this.id) {
  14922. parent += this.id;
  14923. } else {
  14924. this.id = ariaID;
  14925. parent += ariaID;
  14926. }
  14927. parent += '"';
  14928. });
  14929. }
  14930. // Wrap input
  14931. parent = self.wrap(parent + '/>')[_callback]('ifCreated').parent().append(settings.insert);
  14932. // Layer addition
  14933. helper = $('<ins class="' + _iCheckHelper + '"/>').css(layer).appendTo(parent);
  14934. // Finalize customization
  14935. self.data(_iCheck, {o: settings, s: self.attr('style')}).css(hide);
  14936. !!settings.inheritClass && parent[_add](node.className || '');
  14937. !!settings.inheritID && id && parent.attr('id', _iCheck + '-' + id);
  14938. parent.css('position') == 'static' && parent.css('position', 'relative');
  14939. operate(self, true, _update);
  14940. // Label events
  14941. if (label.length) {
  14942. label.on(_click + '.i mouseover.i mouseout.i ' + _touch, function(event) {
  14943. var type = event[_type],
  14944. item = $(this);
  14945. // Do nothing if input is disabled
  14946. if (!node[_disabled]) {
  14947. // Click
  14948. if (type == _click) {
  14949. if ($(event.target).is('a')) {
  14950. return;
  14951. }
  14952. operate(self, false, true);
  14953. // Hover state
  14954. } else if (labelHover) {
  14955. // mouseout|touchend
  14956. if (/ut|nd/.test(type)) {
  14957. parent[_remove](hoverClass);
  14958. item[_remove](labelHoverClass);
  14959. } else {
  14960. parent[_add](hoverClass);
  14961. item[_add](labelHoverClass);
  14962. }
  14963. }
  14964. if (_mobile) {
  14965. event.stopPropagation();
  14966. } else {
  14967. return false;
  14968. }
  14969. }
  14970. });
  14971. }
  14972. // Input events
  14973. self.on(_click + '.i focus.i blur.i keyup.i keydown.i keypress.i', function(event) {
  14974. var type = event[_type],
  14975. key = event.keyCode;
  14976. // Click
  14977. if (type == _click) {
  14978. return false;
  14979. // Keydown
  14980. } else if (type == 'keydown' && key == 32) {
  14981. if (!(node[_type] == _radio && node[_checked])) {
  14982. if (node[_checked]) {
  14983. off(self, _checked);
  14984. } else {
  14985. on(self, _checked);
  14986. }
  14987. }
  14988. return false;
  14989. // Keyup
  14990. } else if (type == 'keyup' && node[_type] == _radio) {
  14991. !node[_checked] && on(self, _checked);
  14992. // Focus/blur
  14993. } else if (/us|ur/.test(type)) {
  14994. parent[type == 'blur' ? _remove : _add](focusClass);
  14995. }
  14996. });
  14997. // Helper events
  14998. helper.on(_click + ' mousedown mouseup mouseover mouseout ' + _touch, function(event) {
  14999. var type = event[_type],
  15000. // mousedown|mouseup
  15001. toggle = /wn|up/.test(type) ? activeClass : hoverClass;
  15002. // Do nothing if input is disabled
  15003. if (!node[_disabled]) {
  15004. // Click
  15005. if (type == _click) {
  15006. operate(self, false, true);
  15007. // Active and hover states
  15008. } else {
  15009. // State is on
  15010. if (/wn|er|in/.test(type)) {
  15011. // mousedown|mouseover|touchbegin
  15012. parent[_add](toggle);
  15013. // State is off
  15014. } else {
  15015. parent[_remove](toggle + ' ' + activeClass);
  15016. }
  15017. // Label hover
  15018. if (label.length && labelHover && toggle == hoverClass) {
  15019. // mouseout|touchend
  15020. label[/ut|nd/.test(type) ? _remove : _add](labelHoverClass);
  15021. }
  15022. }
  15023. if (_mobile) {
  15024. event.stopPropagation();
  15025. } else {
  15026. return false;
  15027. }
  15028. }
  15029. });
  15030. });
  15031. } else {
  15032. return this;
  15033. }
  15034. };
  15035. // Do something with inputs
  15036. function operate(input, direct, method) {
  15037. var node = input[0],
  15038. state = /er/.test(method) ? _indeterminate : /bl/.test(method) ? _disabled : _checked,
  15039. active = method == _update ? {
  15040. checked: node[_checked],
  15041. disabled: node[_disabled],
  15042. indeterminate: input.attr(_indeterminate) == 'true' || input.attr(_determinate) == 'false'
  15043. } : node[state];
  15044. // Check, disable or indeterminate
  15045. if (/^(ch|di|in)/.test(method) && !active) {
  15046. on(input, state);
  15047. // Uncheck, enable or determinate
  15048. } else if (/^(un|en|de)/.test(method) && active) {
  15049. off(input, state);
  15050. // Update
  15051. } else if (method == _update) {
  15052. // Handle states
  15053. for (var each in active) {
  15054. if (active[each]) {
  15055. on(input, each, true);
  15056. } else {
  15057. off(input, each, true);
  15058. }
  15059. }
  15060. } else if (!direct || method == 'toggle') {
  15061. // Helper or label was clicked
  15062. if (!direct) {
  15063. input[_callback]('ifClicked');
  15064. }
  15065. // Toggle checked state
  15066. if (active) {
  15067. if (node[_type] !== _radio) {
  15068. off(input, state);
  15069. }
  15070. } else {
  15071. on(input, state);
  15072. }
  15073. }
  15074. }
  15075. // Add checked, disabled or indeterminate state
  15076. function on(input, state, keep) {
  15077. var node = input[0],
  15078. parent = input.parent(),
  15079. checked = state == _checked,
  15080. indeterminate = state == _indeterminate,
  15081. disabled = state == _disabled,
  15082. callback = indeterminate ? _determinate : checked ? _unchecked : 'enabled',
  15083. regular = option(input, callback + capitalize(node[_type])),
  15084. specific = option(input, state + capitalize(node[_type]));
  15085. // Prevent unnecessary actions
  15086. if (node[state] !== true) {
  15087. // Toggle assigned radio buttons
  15088. if (!keep && state == _checked && node[_type] == _radio && node.name) {
  15089. var form = input.closest('form'),
  15090. inputs = 'input[name="' + node.name + '"]';
  15091. inputs = form.length ? form.find(inputs) : $(inputs);
  15092. inputs.each(function() {
  15093. if (this !== node && $(this).data(_iCheck)) {
  15094. off($(this), state);
  15095. }
  15096. });
  15097. }
  15098. // Indeterminate state
  15099. if (indeterminate) {
  15100. // Add indeterminate state
  15101. node[state] = true;
  15102. // Remove checked state
  15103. if (node[_checked]) {
  15104. off(input, _checked, 'force');
  15105. }
  15106. // Checked or disabled state
  15107. } else {
  15108. // Add checked or disabled state
  15109. if (!keep) {
  15110. node[state] = true;
  15111. }
  15112. // Remove indeterminate state
  15113. if (checked && node[_indeterminate]) {
  15114. off(input, _indeterminate, false);
  15115. }
  15116. }
  15117. // Trigger callbacks
  15118. callbacks(input, checked, state, keep);
  15119. }
  15120. // Add proper cursor
  15121. if (node[_disabled] && !!option(input, _cursor, true)) {
  15122. parent.find('.' + _iCheckHelper).css(_cursor, 'default');
  15123. }
  15124. // Add state class
  15125. parent[_add](specific || option(input, state) || '');
  15126. // Set ARIA attribute
  15127. if (!!parent.attr('role') && !indeterminate) {
  15128. parent.attr('aria-' + (disabled ? _disabled : _checked), 'true');
  15129. }
  15130. // Remove regular state class
  15131. parent[_remove](regular || option(input, callback) || '');
  15132. }
  15133. // Remove checked, disabled or indeterminate state
  15134. function off(input, state, keep) {
  15135. var node = input[0],
  15136. parent = input.parent(),
  15137. checked = state == _checked,
  15138. indeterminate = state == _indeterminate,
  15139. disabled = state == _disabled,
  15140. callback = indeterminate ? _determinate : checked ? _unchecked : 'enabled',
  15141. regular = option(input, callback + capitalize(node[_type])),
  15142. specific = option(input, state + capitalize(node[_type]));
  15143. // Prevent unnecessary actions
  15144. if (node[state] !== false) {
  15145. // Toggle state
  15146. if (indeterminate || !keep || keep == 'force') {
  15147. node[state] = false;
  15148. }
  15149. // Trigger callbacks
  15150. callbacks(input, checked, callback, keep);
  15151. }
  15152. // Add proper cursor
  15153. if (!node[_disabled] && !!option(input, _cursor, true)) {
  15154. parent.find('.' + _iCheckHelper).css(_cursor, 'pointer');
  15155. }
  15156. // Remove state class
  15157. parent[_remove](specific || option(input, state) || '');
  15158. // Set ARIA attribute
  15159. if (!!parent.attr('role') && !indeterminate) {
  15160. parent.attr('aria-' + (disabled ? _disabled : _checked), 'false');
  15161. }
  15162. // Add regular state class
  15163. parent[_add](regular || option(input, callback) || '');
  15164. }
  15165. // Remove all traces
  15166. function tidy(input, callback) {
  15167. if (input.data(_iCheck)) {
  15168. // Remove everything except input
  15169. input.parent().html(input.attr('style', input.data(_iCheck).s || ''));
  15170. // Callback
  15171. if (callback) {
  15172. input[_callback](callback);
  15173. }
  15174. // Unbind events
  15175. input.off('.i').unwrap();
  15176. $(_label + '[for="' + input[0].id + '"]').add(input.closest(_label)).off('.i');
  15177. }
  15178. }
  15179. // Get some option
  15180. function option(input, state, regular) {
  15181. if (input.data(_iCheck)) {
  15182. return input.data(_iCheck).o[state + (regular ? '' : 'Class')];
  15183. }
  15184. }
  15185. // Capitalize some string
  15186. function capitalize(string) {
  15187. return string.charAt(0).toUpperCase() + string.slice(1);
  15188. }
  15189. // Executable handlers
  15190. function callbacks(input, checked, callback, keep) {
  15191. if (!keep) {
  15192. if (checked) {
  15193. input[_callback]('ifToggled');
  15194. }
  15195. input[_callback]('change')[_callback]('ifChanged')[_callback]('if' + capitalize(callback));
  15196. }
  15197. }
  15198. })(window.jQuery || window.Zepto);
  15199. /**
  15200. * WHMCS core JS library reference
  15201. *
  15202. * @copyright Copyright (c) WHMCS Limited 2005-2017
  15203. * @license http://www.whmcs.com/license/ WHMCS Eula
  15204. */
  15205. (function (window, factory) {
  15206. if (typeof window.WHMCS !== 'object') {
  15207. window.WHMCS = factory;
  15208. }
  15209. }(
  15210. window,
  15211. {
  15212. hasModule: function (name) {
  15213. return (typeof WHMCS[name] !== 'undefined'
  15214. && Object.getOwnPropertyNames(WHMCS[name]).length > 0);
  15215. },
  15216. loadModule: function (name, module) {
  15217. if (this.hasModule(name)) {
  15218. return;
  15219. }
  15220. WHMCS[name] = {};
  15221. if (typeof module === 'function') {
  15222. (module).apply(WHMCS[name]);
  15223. } else {
  15224. for (var key in module) {
  15225. if (module.hasOwnProperty(key)) {
  15226. WHMCS[name][key] = {};
  15227. (module[key]).apply(WHMCS[name][key]);
  15228. }
  15229. }
  15230. }
  15231. }
  15232. }
  15233. ));
  15234. jQuery(document).ready(function() {
  15235. jQuery(document).on('click', '.disable-on-click', function () {
  15236. jQuery(this).addClass('disabled');
  15237. if (jQuery(this).hasClass('spinner-on-click')) {
  15238. var icon = $(this).find('i.fas,i.far,i.fal,i.fab');
  15239. jQuery(icon)
  15240. .removeAttr('class')
  15241. .addClass('fas fa-spinner fa-spin');
  15242. }
  15243. })
  15244. .on('click', '#openTicketSubmit.disabled', function () {
  15245. return false;
  15246. });
  15247. });
  15248. function scrollToGatewayInputError() {
  15249. var displayError = jQuery('.gateway-errors,.assisted-cc-input-feedback').first(),
  15250. frm = displayError.closest('form');
  15251. if (!frm) {
  15252. frm = jQuery('form').first();
  15253. }
  15254. frm.find('button[type="submit"],input[type="submit"]')
  15255. .prop('disabled', false)
  15256. .removeClass('disabled')
  15257. .find('i.fas,i.far,i.fal,i.fab')
  15258. .removeAttr('class')
  15259. .addClass('fas fa-arrow-circle-right')
  15260. .find('span').toggle();
  15261. if (displayError.length) {
  15262. if (elementOutOfViewPort(displayError[0])) {
  15263. jQuery('html, body').animate(
  15264. {
  15265. scrollTop: displayError.offset().top - 50
  15266. },
  15267. 500
  15268. );
  15269. }
  15270. }
  15271. }
  15272. function elementOutOfViewPort(element) {
  15273. // Get element's bounding
  15274. var bounding = element.getBoundingClientRect();
  15275. // Check if it's out of the viewport on each side
  15276. var out = {};
  15277. out.top = bounding.top < 0;
  15278. out.left = bounding.left < 0;
  15279. out.bottom = bounding.bottom > (window.innerHeight || document.documentElement.clientHeight);
  15280. out.right = bounding.right > (window.innerWidth || document.documentElement.clientWidth);
  15281. out.any = out.top || out.left || out.bottom || out.right;
  15282. return out.any;
  15283. };
  15284. /**
  15285. * WHMCS authentication module
  15286. *
  15287. * @copyright Copyright (c) WHMCS Limited 2005-2017
  15288. * @license http://www.whmcs.com/license/ WHMCS Eula
  15289. */
  15290. (function(module) {
  15291. if (!WHMCS.hasModule('authn')) {
  15292. WHMCS.loadModule('authn', module);
  15293. }
  15294. })({
  15295. provider: function () {
  15296. var callbackFired = false;
  15297. /**
  15298. * @return {jQuery}
  15299. */
  15300. this.feedbackContainer = function () {
  15301. return jQuery(".providerLinkingFeedback");
  15302. };
  15303. /**
  15304. * @returns {jQuery}
  15305. */
  15306. this.btnContainer = function () {
  15307. return jQuery(".providerPreLinking");
  15308. };
  15309. this.feedbackMessage = function (context) {
  15310. if (typeof context === 'undefined') {
  15311. context = 'complete_sign_in';
  15312. }
  15313. var msgContainer = jQuery('p.providerLinkingMsg-preLink-' + context);
  15314. if (msgContainer.length) {
  15315. return msgContainer.first().html();
  15316. }
  15317. return '';
  15318. };
  15319. this.showProgressMessage = function(callback) {
  15320. this.feedbackContainer().fadeIn('fast', function () {
  15321. if (typeof callback === 'function' && !callbackFired) {
  15322. callbackFired = true;
  15323. callback();
  15324. }
  15325. });
  15326. };
  15327. this.preLinkInit = function (callback) {
  15328. var icon = '<i class="fas fa-fw fa-spinner fa-spin"></i> ';
  15329. this.feedbackContainer()
  15330. .removeClass('alert-danger alert-success')
  15331. .addClass('alert alert-info')
  15332. .html(icon + this.feedbackMessage())
  15333. .hide();
  15334. var btnContainer = this.btnContainer();
  15335. if (btnContainer.length) {
  15336. if (btnContainer.data('hideOnPrelink')) {
  15337. var self = this;
  15338. btnContainer.fadeOut('false', function ()
  15339. {
  15340. self.showProgressMessage(callback)
  15341. });
  15342. } else if (btnContainer.data('disableOnPrelink')) {
  15343. btnContainer.find('.btn').addClass('disabled');
  15344. this.showProgressMessage(callback);
  15345. } else {
  15346. this.showProgressMessage(callback);
  15347. }
  15348. } else {
  15349. this.showProgressMessage(callback);
  15350. }
  15351. };
  15352. this.displayError = function (provider, errorCondition, providerErrorText){
  15353. jQuery('#providerLinkingMessages .provider-name').html(provider);
  15354. var feedbackMsg = this.feedbackMessage('connect_error');
  15355. if (errorCondition) {
  15356. var errorMsg = this.feedbackMessage(errorCondition);
  15357. if (errorMsg) {
  15358. feedbackMsg = errorMsg
  15359. }
  15360. }
  15361. if (providerErrorText && $('.btn-logged-in-admin').length > 0) {
  15362. feedbackMsg += ' Error: ' + providerErrorText;
  15363. }
  15364. this.feedbackContainer().removeClass('alert-info alert-success')
  15365. .addClass('alert alert-danger')
  15366. .html(feedbackMsg).slideDown();
  15367. };
  15368. this.displaySuccess = function (data, context, provider) {
  15369. var icon = provider.icon;
  15370. var htmlTarget = context.htmlTarget;
  15371. var targetLogin = context.targetLogin;
  15372. var targetRegister = context.targetRegister;
  15373. var displayName = provider.name;
  15374. var feedbackMsg = '';
  15375. switch (data.result) {
  15376. case "logged_in":
  15377. case "2fa_needed":
  15378. feedbackMsg = this.feedbackMessage('2fa_needed');
  15379. this.feedbackContainer().removeClass('alert-danger alert-warning alert-success')
  15380. .addClass('alert alert-info')
  15381. .html(feedbackMsg);
  15382. window.location = data.redirect_url
  15383. ? decodeURIComponent(data.redirect_url)
  15384. : decodeURIComponent(context.redirectUrl);
  15385. break;
  15386. case "linking_complete":
  15387. var accountInfo = '';
  15388. if (data.remote_account.email) {
  15389. accountInfo = data.remote_account.email;
  15390. } else {
  15391. accountInfo = data.remote_account.firstname + " " + data.remote_account.lastname;
  15392. }
  15393. accountInfo = accountInfo.trim();
  15394. feedbackMsg = this.feedbackMessage('linking_complete').trim().replace(':displayName', displayName);
  15395. if (accountInfo) {
  15396. feedbackMsg = feedbackMsg.replace(/\.$/, ' (' + accountInfo + ').');
  15397. }
  15398. this.feedbackContainer().removeClass('alert-danger alert-warning alert-info')
  15399. .addClass('alert alert-success')
  15400. .html(icon + feedbackMsg);
  15401. break;
  15402. case "login_to_link":
  15403. if (htmlTarget === targetLogin) {
  15404. feedbackMsg = this.feedbackMessage('login_to_link-signin-required');
  15405. this.feedbackContainer().removeClass('alert-danger alert-success alert-info')
  15406. .addClass('alert alert-warning')
  15407. .html(icon + feedbackMsg);
  15408. } else {
  15409. var emailField = jQuery("input[name=email]");
  15410. var firstNameField = jQuery("input[name=firstname]");
  15411. var lastNameField = jQuery("input[name=lastname]");
  15412. if (emailField.val() === "") {
  15413. emailField.val(data.remote_account.email);
  15414. }
  15415. if (firstNameField.val() === "") {
  15416. firstNameField.val(data.remote_account.firstname);
  15417. }
  15418. if (lastNameField.val() === "") {
  15419. lastNameField.val(data.remote_account.lastname);
  15420. }
  15421. if (htmlTarget === targetRegister) {
  15422. if (typeof WHMCS.client.registration === 'object') {
  15423. WHMCS.client.registration.prefillPassword();
  15424. }
  15425. feedbackMsg = this.feedbackMessage('login_to_link-registration-required');
  15426. this.feedbackContainer().fadeOut('slow', function () {
  15427. $(this).removeClass('alert-danger alert-success alert-info')
  15428. .addClass('alert alert-warning')
  15429. .html(icon + feedbackMsg).fadeIn('fast');
  15430. });
  15431. } else {
  15432. // this is checkout
  15433. if (typeof WHMCS.client.registration === 'object') {
  15434. WHMCS.client.registration.prefillPassword();
  15435. }
  15436. var self = this;
  15437. this.feedbackContainer().each(function (i, el) {
  15438. var container = $(el);
  15439. var linkContext = container.siblings('div .providerPreLinking').data('linkContext');
  15440. container.fadeOut('slow', function () {
  15441. if (linkContext === 'checkout-new') {
  15442. feedbackMsg = self.feedbackMessage('checkout-new');
  15443. } else {
  15444. feedbackMsg = self.feedbackMessage('login_to_link-signin-required');
  15445. }
  15446. container.removeClass('alert-danger alert-success alert-info')
  15447. .addClass('alert alert-warning')
  15448. .html(icon + feedbackMsg).fadeIn('fast');
  15449. });
  15450. });
  15451. }
  15452. }
  15453. break;
  15454. case "other_user_exists":
  15455. feedbackMsg = this.feedbackMessage('other_user_exists');
  15456. this.feedbackContainer().removeClass('alert-info alert-success')
  15457. .addClass('alert alert-danger')
  15458. .html(icon + feedbackMsg).slideDown();
  15459. break;
  15460. case "already_linked":
  15461. feedbackMsg = this.feedbackMessage('already_linked');
  15462. this.feedbackContainer().removeClass('alert-info alert-success')
  15463. .addClass('alert alert-danger')
  15464. .html(icon + feedbackMsg).slideDown();
  15465. break;
  15466. default:
  15467. feedbackMsg = this.feedbackMessage('default');
  15468. this.feedbackContainer().removeClass('alert-info alert-success')
  15469. .addClass('alert alert-danger')
  15470. .html(icon + feedbackMsg).slideDown();
  15471. break;
  15472. }
  15473. };
  15474. this.signIn = function (config, context, provider, providerDone, providerError) {
  15475. jQuery.ajax(config).done(function(data) {
  15476. providerDone();
  15477. WHMCS.authn.provider.displaySuccess(data, context, provider);
  15478. var table = jQuery('#tableLinkedAccounts');
  15479. if (table.length) {
  15480. WHMCS.ui.dataTable.getTableById('tableLinkedAccounts').ajax.reload();
  15481. }
  15482. }).error(function() {
  15483. providerError();
  15484. WHMCS.authn.provider.displayError();
  15485. });
  15486. };
  15487. return this;
  15488. }});
  15489. /**
  15490. * WHMCS client module
  15491. *
  15492. * @copyright Copyright (c) WHMCS Limited 2005-2017
  15493. * @license http://www.whmcs.com/license/ WHMCS Eula
  15494. */
  15495. (function(module) {
  15496. if (!WHMCS.hasModule('client')) {
  15497. WHMCS.loadModule('client', module);
  15498. }
  15499. })({
  15500. registration: function () {
  15501. this.prefillPassword = function (params) {
  15502. params = params || {};
  15503. if (typeof params.hideContainer === 'undefined') {
  15504. var id = (jQuery('#inputSecurityQId').attr('id')) ? '#containerPassword' : '#containerNewUserSecurity';
  15505. params.hideContainer = jQuery(id);
  15506. params.hideInputs = true;
  15507. } else if (typeof params.hideContainer === 'string' && params.hideContainer.length) {
  15508. params.hideContainer = jQuery(params.hideContainer);
  15509. }
  15510. if (typeof params.form === 'undefined') {
  15511. params.form = {
  15512. password: [
  15513. {id: 'inputNewPassword1'},
  15514. {id: 'inputNewPassword2'}
  15515. ]
  15516. };
  15517. }
  15518. var prefillFunc = function () {
  15519. var $randomPasswd = WHMCS.utils.simpleRNG();
  15520. for (var i = 0, len = params.form.password.length; i < len; i++) {
  15521. jQuery('#' + params.form.password[i].id)
  15522. .val($randomPasswd).trigger('keyup');
  15523. }
  15524. };
  15525. if (params.hideInputs) {
  15526. params.hideContainer.slideUp('fast', prefillFunc);
  15527. } else {
  15528. prefillFunc();
  15529. }
  15530. };
  15531. return this;
  15532. }});
  15533. /**
  15534. * WHMCS HTTP module
  15535. *
  15536. * @copyright Copyright (c) WHMCS Limited 2005-2018
  15537. * @license http://www.whmcs.com/license/ WHMCS Eula
  15538. */
  15539. (function(module) {
  15540. if (!WHMCS.hasModule('http')) {
  15541. WHMCS.loadModule('http', module);
  15542. }
  15543. })({
  15544. jqClient: function () {
  15545. _getSettings = function (url, data, success, dataType)
  15546. {
  15547. if (typeof url === 'object') {
  15548. /*
  15549. Settings may be the only argument
  15550. */
  15551. return url;
  15552. }
  15553. if (typeof data === 'function') {
  15554. /*
  15555. If 'data' is omitted, 'success' will come in its place
  15556. */
  15557. success = data;
  15558. data = null;
  15559. }
  15560. return {
  15561. url: url,
  15562. data: data,
  15563. success: success,
  15564. dataType: dataType
  15565. };
  15566. };
  15567. /**
  15568. * @param url
  15569. * @param data
  15570. * @param success
  15571. * @param dataType
  15572. * @returns {*}
  15573. */
  15574. this.get = function (url, data, success, dataType)
  15575. {
  15576. return WHMCS.http.client.request(
  15577. jQuery.extend(
  15578. _getSettings(url, data, success, dataType),
  15579. {
  15580. type: 'GET'
  15581. }
  15582. )
  15583. );
  15584. };
  15585. /**
  15586. * @param url
  15587. * @param data
  15588. * @param success
  15589. * @param dataType
  15590. * @returns {*}
  15591. */
  15592. this.post = function (url, data, success, dataType)
  15593. {
  15594. return WHMCS.http.client.request(
  15595. jQuery.extend(
  15596. _getSettings(url, data, success, dataType),
  15597. {
  15598. type: 'POST'
  15599. }
  15600. )
  15601. );
  15602. };
  15603. /**
  15604. * @param options
  15605. * @returns {*}
  15606. */
  15607. this.jsonGet = function (options) {
  15608. options = options || {};
  15609. this.get(options.url, options.data, function(response) {
  15610. if (response.warning) {
  15611. console.log('[WHMCS] Warning: ' + response.warning);
  15612. if (typeof options.warning === 'function') {
  15613. options.warning(response.warning);
  15614. }
  15615. } else if (response.error) {
  15616. console.log('[WHMCS] Error: ' + response.error);
  15617. if (typeof options.error === 'function') {
  15618. options.error(response.error);
  15619. }
  15620. } else {
  15621. if (typeof options.success === 'function') {
  15622. options.success(response);
  15623. }
  15624. }
  15625. }, 'json').error(function(xhr, errorMsg){
  15626. console.log('[WHMCS] Error: ' + errorMsg);
  15627. if (typeof options.fail === 'function') {
  15628. options.fail(errorMsg);
  15629. }
  15630. }).always(function() {
  15631. if (typeof options.always === 'function') {
  15632. options.always();
  15633. }
  15634. });
  15635. };
  15636. /**
  15637. * @param options
  15638. * @returns {*}
  15639. */
  15640. this.jsonPost = function (options) {
  15641. options = options || {};
  15642. this.post(options.url, options.data, function(response) {
  15643. if (response.warning) {
  15644. console.log('[WHMCS] Warning: ' + response.warning);
  15645. if (typeof options.warning === 'function') {
  15646. options.warning(response.warning);
  15647. }
  15648. } else if (response.error) {
  15649. console.log('[WHMCS] Error: ' + response.error);
  15650. if (typeof options.error === 'function') {
  15651. options.error(response.error);
  15652. }
  15653. } else {
  15654. if (typeof options.success === 'function') {
  15655. options.success(response);
  15656. }
  15657. }
  15658. }, 'json').fail(function(xhr, errorMsg){
  15659. console.log('[WHMCS] Fail: ' + errorMsg);
  15660. if (typeof options.fail === 'function') {
  15661. options.fail(errorMsg, xhr);
  15662. }
  15663. }).always(function() {
  15664. if (typeof options.always === 'function') {
  15665. options.always();
  15666. }
  15667. });
  15668. };
  15669. return this;
  15670. },
  15671. client: function () {
  15672. var methods = ['get', 'post', 'put', 'delete'];
  15673. var client = this;
  15674. _beforeRequest = function (settings)
  15675. {
  15676. /*
  15677. Enforcing dataType was found to break many invocations expecting HTML back.
  15678. If/when those are refactored, this may be uncommented to enforce a safer
  15679. data transit.
  15680. */
  15681. /*if (typeof settings.dataType === 'undefined') {
  15682. settings.dataType = 'json';
  15683. }*/
  15684. if (typeof settings.type === 'undefined') {
  15685. // default request type is GET
  15686. settings.type = 'GET';
  15687. }
  15688. /*
  15689. Add other preprocessing here if required
  15690. */
  15691. return settings;
  15692. };
  15693. this.request = function (settings)
  15694. {
  15695. settings = _beforeRequest(settings || {});
  15696. return jQuery.ajax(settings);
  15697. };
  15698. /*
  15699. Create shortcut methods for methods[] array above
  15700. */
  15701. jQuery.each(methods, function(index, method) {
  15702. client[method] = (function(method, client) {
  15703. return function (settings)
  15704. {
  15705. settings = settings || {};
  15706. settings.type = method.toUpperCase();
  15707. return client.request(settings);
  15708. }
  15709. })(method, client);
  15710. });
  15711. return this;
  15712. }
  15713. });
  15714. /**
  15715. * WHMCS UI module
  15716. *
  15717. * @copyright Copyright (c) WHMCS Limited 2005-2017
  15718. * @license http://www.whmcs.com/license/ WHMCS Eula
  15719. */
  15720. (function(module) {
  15721. if (!WHMCS.hasModule('ui')) {
  15722. WHMCS.loadModule('ui', module);
  15723. }
  15724. })({
  15725. /**
  15726. * Confirmation PopUp
  15727. */
  15728. confirmation: function () {
  15729. /**
  15730. * @type {Array} Registered confirmation root selectors
  15731. */
  15732. var toggles = [];
  15733. /**
  15734. * Register/Re-Register all confirmation elements with jQuery
  15735. * By default all elements of data toggle "confirmation" will be registered
  15736. *
  15737. * @param {(string|undefined)} rootSelector
  15738. * @return {Array} array of registered toggles
  15739. */
  15740. this.register = function (rootSelector) {
  15741. if (typeof rootSelector === 'undefined') {
  15742. rootSelector = '[data-toggle=confirmation]';
  15743. }
  15744. if (toggles.indexOf(rootSelector) < 0) {
  15745. toggles.push(rootSelector);
  15746. }
  15747. jQuery(rootSelector).confirmation({
  15748. rootSelector: rootSelector
  15749. });
  15750. return toggles;
  15751. };
  15752. return this;
  15753. },
  15754. /**
  15755. * Data Driven Table
  15756. */
  15757. dataTable: function () {
  15758. /**
  15759. * @type {{}}
  15760. */
  15761. this.tables = {};
  15762. /**
  15763. * Register all tables on page with the class "data-driven"
  15764. */
  15765. this.register = function () {
  15766. var self = this;
  15767. jQuery('table.data-driven').each(function (i, table) {
  15768. self.getTableById(table.id, undefined);
  15769. });
  15770. };
  15771. /**
  15772. * Get a table by id; create table object on fly as necessary
  15773. *
  15774. * @param {string} id
  15775. * @param {({}|undefined)} options
  15776. * @returns {DataTable}
  15777. */
  15778. this.getTableById = function (id, options) {
  15779. var self = this;
  15780. var el = jQuery('#' + id);
  15781. if (typeof self.tables[id] === 'undefined') {
  15782. if (typeof options === 'undefined') {
  15783. options = {
  15784. dom: '<"listtable"ift>pl',
  15785. paging: false,
  15786. lengthChange: false,
  15787. searching: false,
  15788. ordering: true,
  15789. info: false,
  15790. autoWidth: true,
  15791. columns: [],
  15792. lengthMenu: [10, 25, 50, 100, 500, 1000],
  15793. language: {
  15794. emptyTable: (el.data('langEmptyTable')) ? el.data('langEmptyTable') : "No records found"
  15795. }
  15796. };
  15797. }
  15798. jQuery.each(el.data(), function (key, value) {
  15799. if (typeof value === 'undefined') {
  15800. return;
  15801. }
  15802. if (key === 'ajaxUrl') {
  15803. options.ajax = {
  15804. url: value
  15805. };
  15806. return;
  15807. }
  15808. if (key === 'lengthChange') {
  15809. options.lengthChange = value;
  15810. return;
  15811. }
  15812. if (key === 'pageLength') {
  15813. options.pageLength = value;
  15814. return;
  15815. }
  15816. if (key === 'langEmptyTable') {
  15817. if (typeof options.language === "undefined") {
  15818. options.language = {};
  15819. }
  15820. options.language.emptyTable = value;
  15821. return
  15822. }
  15823. if (key === 'langZeroRecords') {
  15824. if (typeof options.language === "undefined") {
  15825. options.language = {};
  15826. }
  15827. options.language.zeroRecords = value;
  15828. return
  15829. }
  15830. options.key = value;
  15831. });
  15832. jQuery.each(el.find('th'), function() {
  15833. if (typeof options.columns === "undefined") {
  15834. options.columns = [];
  15835. }
  15836. options.columns.push({data:jQuery(this).data('name')});
  15837. });
  15838. self.tables[id] = self.initTable(el, options);
  15839. } else if (typeof options !== 'undefined') {
  15840. var oldTable = self.tables[id];
  15841. var initOpts = oldTable.init();
  15842. var newOpts = jQuery.extend( initOpts, options);
  15843. oldTable.destroy();
  15844. self.tables[id] = self.initTable(el, newOpts);
  15845. }
  15846. return self.tables[id];
  15847. };
  15848. this.initTable = function (el, options) {
  15849. var table = el.DataTable(options);
  15850. var self = this;
  15851. if (el.data('on-draw')) {
  15852. table.on('draw.dt', function (e, settings) {
  15853. var namedCallback = el.data('on-draw');
  15854. if (typeof window[namedCallback] === 'function') {
  15855. window[namedCallback](e, settings);
  15856. }
  15857. });
  15858. } else if (el.data('on-draw-rebind-confirmation')) {
  15859. table.on('draw.dt', function (e) {
  15860. self.rebindConfirmation(e);
  15861. });
  15862. }
  15863. return table;
  15864. };
  15865. this.rebindConfirmation = function (e) {
  15866. var self = this;
  15867. var tableId = e.target.id;
  15868. var toggles = WHMCS.ui.confirmation.register();
  15869. for(var i = 0, len = toggles.length; i < len; i++ ) {
  15870. jQuery(toggles[i]).on(
  15871. 'confirmed.bs.confirmation',
  15872. function (e)
  15873. {
  15874. e.preventDefault();
  15875. WHMCS.http.jqClient.post(
  15876. jQuery(e.target).data('target-url'),
  15877. {
  15878. 'token': csrfToken
  15879. }
  15880. ).done(function (data)
  15881. {
  15882. if (data.status === 'success' || data.status === 'okay') {
  15883. self.getTableById(tableId, undefined).ajax.reload();
  15884. }
  15885. });
  15886. }
  15887. );
  15888. }
  15889. };
  15890. return this;
  15891. },
  15892. clipboard: function() {
  15893. this.copy = function(e) {
  15894. e.preventDefault();
  15895. var trigger = $(e.currentTarget);
  15896. var contentElement = $(trigger).data('clipboard-target');
  15897. var container = $(contentElement).parent();
  15898. try {
  15899. var tempElement = $('<textarea>')
  15900. .css('position', 'fixed')
  15901. .css('opacity', '0')
  15902. .css('width', '1px')
  15903. .css('height', '1px')
  15904. .val($(contentElement).val());
  15905. container.append(tempElement);
  15906. tempElement.focus().select();
  15907. document.execCommand('copy');
  15908. } finally {
  15909. tempElement.remove();
  15910. }
  15911. trigger.tooltip({
  15912. trigger: 'click',
  15913. placement: 'bottom'
  15914. });
  15915. WHMCS.ui.toolTip.setTip(trigger, 'Copied!');
  15916. WHMCS.ui.toolTip.hideTip(trigger);
  15917. };
  15918. return this;
  15919. },
  15920. /**
  15921. * ToolTip and Clipboard behaviors
  15922. */
  15923. toolTip: function () {
  15924. this.setTip = function (btn, message) {
  15925. var tip = btn.data('bs.tooltip');
  15926. if (tip.hoverState !== 'in') {
  15927. tip.hoverState = 'in';
  15928. }
  15929. btn.attr('data-original-title', message);
  15930. tip.show();
  15931. return tip;
  15932. };
  15933. this.hideTip = function (btn, timeout) {
  15934. if (!timeout) {
  15935. timeout = 2000;
  15936. }
  15937. return setTimeout(function() {
  15938. btn.data('bs.tooltip').hide()
  15939. }, timeout);
  15940. }
  15941. },
  15942. jsonForm: function() {
  15943. this.managedElements = 'input,textarea,select';
  15944. this.initFields = function (form) {
  15945. var self = this;
  15946. $(form).find(self.managedElements).each(function () {
  15947. var field = this;
  15948. $(field).on('keypress change', function () {
  15949. if (self.fieldHasError(field)) {
  15950. self.clearFieldError(field);
  15951. }
  15952. });
  15953. });
  15954. };
  15955. this.init = function (form) {
  15956. var self = this;
  15957. self.initFields(form);
  15958. $(form).on('submit', function(e) {
  15959. e.preventDefault();
  15960. e.stopPropagation();
  15961. self.clearErrors(form);
  15962. var formModal = $(form).parents('.modal[role="dialog"]').first();
  15963. if ($(formModal).length) {
  15964. $(formModal).on('show.bs.modal hidden.bs.modal', function() {
  15965. self.clearErrors(form);
  15966. });
  15967. /*
  15968. * Make this optional if the form is used for editing
  15969. */
  15970. $(formModal).on('show.bs.modal', function() {
  15971. $(form)[0].reset();
  15972. });
  15973. }
  15974. WHMCS.http.client.post({
  15975. url: $(form).attr('action'),
  15976. data: $(form).serializeArray(),
  15977. })
  15978. .done(function (response) {
  15979. self.onSuccess(form, response);
  15980. })
  15981. .fail(function (jqXHR) {
  15982. self.onError(form, jqXHR);
  15983. })
  15984. .always(function (data) {
  15985. self.onRequestComplete(form, data);
  15986. });
  15987. });
  15988. };
  15989. this.initAll = function () {
  15990. var self = this;
  15991. $('form[data-role="json-form"]').each(function() {
  15992. var formElement = this;
  15993. self.init(formElement);
  15994. });
  15995. };
  15996. this.markFieldErrors = function (form, fields)
  15997. {
  15998. var self = this;
  15999. var errorMessage = null;
  16000. var field, fieldLookup;
  16001. for (var fieldName in fields) {
  16002. if (fields.hasOwnProperty(fieldName)) {
  16003. errorMessage = fields[fieldName];
  16004. }
  16005. fieldLookup = self.managedElements.split(',').map(function(element) {
  16006. return element + '[name="' + fieldName + '"]';
  16007. }).join(',');
  16008. field = $(form).find(fieldLookup);
  16009. if (errorMessage) {
  16010. $(field).parents('.form-group').addClass('has-error');
  16011. $(field).attr('title', errorMessage);
  16012. $(field).tooltip();
  16013. }
  16014. }
  16015. $(form).find('.form-group.has-error input[title]').first().tooltip('show');
  16016. };
  16017. this.fieldHasError = function (field) {
  16018. return $(field).parents('.form-group').hasClass('has-error');
  16019. };
  16020. this.clearFieldError = function (field) {
  16021. /**
  16022. * Try dispose first for BS 4, which will raise error
  16023. * on BS 3 or older, then we use destroy instead
  16024. */
  16025. try {
  16026. $(field).tooltip('dispose');
  16027. } catch (err) {
  16028. $(field).tooltip('destroy');
  16029. }
  16030. $(field).parents('.form-group').removeClass('has-error');
  16031. };
  16032. this.onSuccess = function (form, response) {
  16033. var formOnSuccess = $(form).data('on-success');
  16034. if (typeof formOnSuccess === 'function') {
  16035. formOnSuccess(response.data);
  16036. }
  16037. };
  16038. this.onError = function (form, jqXHR) {
  16039. if (jqXHR.responseJSON && jqXHR.responseJSON.fields && typeof jqXHR.responseJSON.fields === 'object') {
  16040. this.markFieldErrors(form, jqXHR.responseJSON.fields);
  16041. } else {
  16042. // TODO: replace with client-accessible generic error messaging
  16043. console.log('Unknown error - please try again later.');
  16044. }
  16045. var formOnError = $(form).data('on-error');
  16046. if (typeof formOnError === 'function') {
  16047. formOnError(jqXHR);
  16048. }
  16049. };
  16050. this.clearErrors = function (form) {
  16051. var self = this;
  16052. $(form).find(self.managedElements).each(function () {
  16053. self.clearFieldError(this);
  16054. })
  16055. };
  16056. this.onRequestComplete = function (form, data) {
  16057. // implement as needed
  16058. };
  16059. return this;
  16060. },
  16061. effects: function () {
  16062. this.errorShake = function (element) {
  16063. /**
  16064. * Shake effect without jQuery UI inspired by Hiren Patel | ninty9notout:
  16065. * @see https://github.com/ninty9notout/jquery-shake/blob/51f3dcf625970c78505bcac831fd9e28fc85d374/jquery.ui.shake.js
  16066. */
  16067. options = options || {};
  16068. var options = $.extend({
  16069. direction: "left",
  16070. distance: 8,
  16071. times: 3,
  16072. speed: 90
  16073. }, options);
  16074. return element.each(function () {
  16075. var el = $(this), props = {
  16076. position: el.css("position"),
  16077. top: el.css("top"),
  16078. bottom: el.css("bottom"),
  16079. left: el.css("left"),
  16080. right: el.css("right")
  16081. };
  16082. el.css("position", "relative");
  16083. var ref = (options.direction === "up" || options.direction === "down") ? "top" : "left";
  16084. var motion = (options.direction === "up" || options.direction === "left") ? "pos" : "neg";
  16085. var animation = {}, animation1 = {}, animation2 = {};
  16086. animation[ref] = (motion === "pos" ? "-=" : "+=") + options.distance;
  16087. animation1[ref] = (motion === "pos" ? "+=" : "-=") + options.distance * 2;
  16088. animation2[ref] = (motion === "pos" ? "-=" : "+=") + options.distance * 2;
  16089. el.animate(animation, options.speed);
  16090. for (var i = 1; i < options.times; i++) {
  16091. el.animate(animation1, options.speed).animate(animation2, options.speed);
  16092. }
  16093. el.animate(animation1, options.speed).animate(animation, options.speed / 2, function () {
  16094. el.css(props);
  16095. });
  16096. });
  16097. };
  16098. }
  16099. });
  16100. /**
  16101. * Form module
  16102. *
  16103. * @copyright Copyright (c) WHMCS Limited 2005-2017
  16104. * @license http://www.whmcs.com/license/ WHMCS Eula
  16105. */
  16106. (function(module) {
  16107. if (!WHMCS.hasModule('form')) {
  16108. WHMCS.loadModule('form', module);
  16109. }
  16110. })(
  16111. function () {
  16112. this.checkAllBound = false;
  16113. this.register = function () {
  16114. if (!this.checkAllBound) {
  16115. this.bindCheckAll();
  16116. this.checkAllBound = true;
  16117. }
  16118. };
  16119. this.bindCheckAll = function ()
  16120. {
  16121. var huntSelector = '.btn-check-all';
  16122. jQuery('body').on('click', huntSelector, function (e) {
  16123. var btn = jQuery(e.target);
  16124. var targetInputs = jQuery(
  16125. '#' + btn.data('checkbox-container') + ' input[type="checkbox"]'
  16126. );
  16127. if (btn.data('btn-check-toggle')) {
  16128. // one control that changes
  16129. var textDeselect = 'Deselect All';
  16130. var textSelect = 'Select All';
  16131. if (btn.data('label-text-deselect')) {
  16132. textDeselect = btn.data('label-text-deselect');
  16133. }
  16134. if (btn.data('label-text-select')) {
  16135. textSelect = btn.data('label-text-select');
  16136. }
  16137. if (btn.hasClass('toggle-active')) {
  16138. targetInputs.prop('checked',false);
  16139. btn.text(textSelect);
  16140. btn.removeClass('toggle-active');
  16141. } else {
  16142. targetInputs.prop('checked',true);
  16143. btn.text(textDeselect);
  16144. btn.addClass('toggle-active');
  16145. }
  16146. } else {
  16147. // two controls that are static
  16148. if (btn.data('btn-toggle-on')) {
  16149. targetInputs.prop('checked',true);
  16150. } else {
  16151. targetInputs.prop('checked',false);
  16152. }
  16153. }
  16154. });
  16155. };
  16156. this.reloadCaptcha = function (element)
  16157. {
  16158. if (typeof grecaptcha !== 'undefined') {
  16159. grecaptcha.reset();
  16160. } else {
  16161. if (!element) {
  16162. element = jQuery('#inputCaptchaImage');
  16163. }
  16164. var src = jQuery(element).data('src');
  16165. jQuery(element).attr('src', src + '?nocache=' + (new Date()).getTime());
  16166. var userInput = jQuery('#inputCaptcha');
  16167. if (userInput.length) {
  16168. userInput.val('');
  16169. }
  16170. }
  16171. };
  16172. return this;
  16173. });
  16174. /**
  16175. * reCaptcha module - used for captcha apis compatible with the google recaptcha api
  16176. *
  16177. * @copyright Copyright (c) WHMCS Limited 2005-2020
  16178. * @license http://www.whmcs.com/license/ WHMCS Eula
  16179. */
  16180. var recaptchaLoadComplete = false,
  16181. recaptchaCount = 0,
  16182. recaptchaType = 'recaptcha',
  16183. recaptchaValidationComplete = false;
  16184. (function(module) {
  16185. if (!WHMCS.hasModule('recaptcha')) {
  16186. WHMCS.loadModule('recaptcha', module);
  16187. }
  16188. })(
  16189. function () {
  16190. this.register = function () {
  16191. if (recaptchaLoadComplete) {
  16192. return;
  16193. }
  16194. var postLoad = [],
  16195. recaptchaForms = jQuery(".btn-recaptcha").parents('form'),
  16196. isInvisible = false;
  16197. recaptchaForms.each(function (i, el){
  16198. if (typeof recaptcha.siteKey === 'undefined') {
  16199. console.error('Recaptcha site key not defined');
  16200. return;
  16201. }
  16202. if (typeof recaptcha.libUrl === 'undefined') {
  16203. console.error('Recaptcha client js url not defined');
  16204. return;
  16205. }
  16206. if (typeof recaptcha.apiObject === 'undefined') {
  16207. console.error('Recaptcha client js api object name not defined');
  16208. return;
  16209. }
  16210. recaptchaCount += 1;
  16211. var frm = jQuery(el),
  16212. btnRecaptcha = frm.find(".btn-recaptcha"),
  16213. required = (typeof recaptcha.requiredText !== 'undefined')
  16214. ? recaptcha.requiredText
  16215. : 'Required',
  16216. recaptchaId = 'divDynamicRecaptcha' + recaptchaCount;
  16217. isInvisible = btnRecaptcha.hasClass('btn-recaptcha-invisible')
  16218. // if no recaptcha element, make one
  16219. var recaptchaContent = frm.find('#' + recaptchaId + ' .g-recaptcha'),
  16220. recaptchaElement = frm.find('.recaptcha-container'),
  16221. appendElement = frm;
  16222. if (recaptchaElement.length) {
  16223. recaptchaElement.attr('id', recaptchaElement.attr('id') + recaptchaCount);
  16224. appendElement = recaptchaElement;
  16225. }
  16226. if (!recaptchaContent.length) {
  16227. appendElement.append('<div id="#' + recaptchaId + '" class="g-recaptcha"></div>');
  16228. recaptchaContent = appendElement.find('#' + recaptchaId);
  16229. }
  16230. // propagate invisible recaptcha if necessary
  16231. if (!isInvisible) {
  16232. recaptchaContent.data('toggle', 'tooltip')
  16233. .data('placement', 'bottom')
  16234. .data('trigger', 'manual')
  16235. .attr('title', required)
  16236. .hide();
  16237. }
  16238. // make callback for grecaptcha to invoke after
  16239. // injecting token & make it known via data-callback
  16240. var funcName = recaptchaId + 'Callback';
  16241. window[funcName] = function () {
  16242. if (isInvisible) {
  16243. frm.submit();
  16244. }
  16245. };
  16246. // setup an on form submit event to ensure that we
  16247. // are allowing required field validation to occur before
  16248. // we do the invisible recaptcha checking
  16249. if (isInvisible) {
  16250. recaptchaType = 'invisible';
  16251. frm.on('submit.recaptcha', function (event) {
  16252. var recaptchaId = frm.find('.g-recaptcha').data('recaptcha-id');
  16253. if (!window[recaptcha.apiObject].getResponse(recaptchaId).trim()) {
  16254. event.preventDefault();
  16255. window[recaptcha.apiObject].execute(recaptchaId);
  16256. recaptchaValidationComplete = false;
  16257. } else {
  16258. recaptchaValidationComplete = true;
  16259. }
  16260. });
  16261. } else {
  16262. postLoad.push(function () {
  16263. recaptchaContent.slideDown('fast', function() {
  16264. // just in case there's a delay in DOM; rare
  16265. recaptchaContent.find(':first').addClass('center-block');
  16266. });
  16267. });
  16268. postLoad.push(function() {
  16269. recaptchaContent.find(':first').addClass('center-block');
  16270. });
  16271. }
  16272. });
  16273. window.recaptchaLoadCallback = function() {
  16274. jQuery('.g-recaptcha').each(function(i, el) {
  16275. var element = jQuery(el),
  16276. frm = element.closest('form'),
  16277. btn = frm.find('.btn-recaptcha'),
  16278. idToUse = element.attr('id').substring(1);
  16279. var recaptchaId = grecaptcha.render(
  16280. el,
  16281. {
  16282. sitekey: recaptcha.siteKey,
  16283. size: (btn.hasClass('btn-recaptcha-invisible')) ? 'invisible' : 'normal',
  16284. callback: idToUse + 'Callback'
  16285. }
  16286. );
  16287. element.data('recaptcha-id', recaptchaId);
  16288. });
  16289. }
  16290. // fetch/invoke the remote library
  16291. if (recaptchaForms.length) {
  16292. jQuery.getScript(recaptcha.libUrl, function () {
  16293. for(var i = postLoad.length - 1; i >= 0 ; i--){
  16294. postLoad[i]();
  16295. }
  16296. });
  16297. }
  16298. // captcha overlay badge
  16299. let captchaOverlayBadge = jQuery('.captcha-overlay-badge'),
  16300. captchaOverlayPopup = jQuery('.captcha-overlay-popup');
  16301. if (recaptchaForms.length && captchaOverlayBadge.length) {
  16302. captchaOverlayBadge.show();
  16303. if (captchaOverlayPopup.length) {
  16304. let captchaOverlayTimer;
  16305. function captchaPopupHide() {
  16306. captchaOverlayPopup.hide();
  16307. }
  16308. function debounce(func, delay) {
  16309. return function() {
  16310. const context = this;
  16311. const args = arguments;
  16312. clearTimeout(captchaOverlayTimer);
  16313. captchaOverlayTimer = setTimeout(function() {
  16314. func.apply(context, args);
  16315. }, delay);
  16316. };
  16317. }
  16318. const debouncedCaptchaPopupHide = debounce(captchaPopupHide, 3000);
  16319. captchaOverlayBadge.bind('mouseenter', function() {
  16320. captchaOverlayPopup.show();
  16321. clearTimeout(captchaOverlayTimer);
  16322. });
  16323. captchaOverlayBadge.bind('mouseleave', debouncedCaptchaPopupHide);
  16324. captchaOverlayBadge.bind('touchstart', function() {
  16325. captchaOverlayPopup.show();
  16326. clearTimeout(captchaOverlayTimer);
  16327. captchaOverlayTimer = setTimeout(captchaPopupHide, 3000);
  16328. });
  16329. }
  16330. }
  16331. recaptchaLoadComplete = true;
  16332. };
  16333. return this;
  16334. });
  16335. /**
  16336. * WHMCS client area checkout and invoice payment UX module integration interface.
  16337. * Stability: alpha - no guarantees are made against the stability of this interface.
  16338. * @copyright Copyright (c) WHMCS Limited 2005-2023
  16339. * @license http://www.whmcs.com/license/ WHMCS Eula
  16340. */
  16341. (function(module) {
  16342. if (!WHMCS.hasModule('payment')) {
  16343. WHMCS.loadModule('payment', module);
  16344. }
  16345. })({
  16346. internal: function () {
  16347. this.isRenderSource = function (source) {
  16348. return [
  16349. 'checkout',
  16350. 'invoice-pay',
  16351. 'admin-payment-method-add',
  16352. 'admin-payment-method-edit',
  16353. 'payment-method-add',
  16354. 'payment-method-edit',
  16355. ].includes(source);
  16356. }
  16357. this.reportUnknownSource = function (source) {
  16358. if (!WHMCS.payment.internal.isRenderSource(source)) {
  16359. WHMCS.payment.internal.logError('unknown source: ' + source);
  16360. return true;
  16361. }
  16362. return false;
  16363. }
  16364. this.logError = function (error) {
  16365. console.error('[WHMCS.payment] ' + error);
  16366. }
  16367. },
  16368. handler: function () {
  16369. this.make = function (moduleName) {
  16370. function Handler(moduleName) {
  16371. this.module = moduleName;
  16372. this.onGatewayInit = function (fn, options = {}) {
  16373. var eventOptions = {...WHMCS.payment.register.defaultEventOpts(), ...options};
  16374. WHMCS.payment.register.onGatewayInit(this.module, fn, eventOptions);
  16375. return this;
  16376. }
  16377. this.onGatewayOptionInit = function (fn, options = {}) {
  16378. var eventOptions = {...WHMCS.payment.register.defaultEventOpts(), ...options};
  16379. WHMCS.payment.register.onGatewayOptionInit(this.module, fn, eventOptions);
  16380. return this;
  16381. }
  16382. this.onGatewaySelected = function (fn, options = {}) {
  16383. var eventOptions = {...WHMCS.payment.register.defaultEventOpts(), ...options};
  16384. WHMCS.payment.register.onGatewaySelected(this.module, fn, eventOptions);
  16385. return this;
  16386. }
  16387. this.onGatewayUnselected = function (fn, options = {}) {
  16388. var eventOptions = {...WHMCS.payment.register.defaultEventOpts(), ...options};
  16389. WHMCS.payment.register.onGatewayUnselected(this.module, fn, eventOptions);
  16390. return this;
  16391. }
  16392. this.onCheckoutFormSubmit = function (fn, options = {}) {
  16393. var eventOptions = {...WHMCS.payment.register.defaultEventOpts(), ...options};
  16394. WHMCS.payment.register.onCheckoutFormSubmit(this.module, fn, eventOptions);
  16395. return this;
  16396. }
  16397. this.onAddPayMethodFormSubmit = function (fn, options = {}) {
  16398. var eventOptions = {...WHMCS.payment.register.defaultEventOpts(), ...options};
  16399. WHMCS.payment.register.onAddPayMethodFormSubmit(this.module, fn, eventOptions);
  16400. return this;
  16401. }
  16402. this.manageInputsContainer = function (selector, options = {}) {
  16403. var eventOptions = {
  16404. ...WHMCS.payment.register.defaultEventOpts(),
  16405. ...{priority: 1},
  16406. ...options
  16407. };
  16408. this.onGatewayInit(function (metadata, element) {
  16409. if (metadata._source != 'invoice-pay') return;
  16410. WHMCS.payment.display.reset();
  16411. WHMCS.payment.display.show(jQuery(selector));
  16412. }, eventOptions);
  16413. this.onGatewaySelected(function (metadata, element) {
  16414. if (metadata._source == 'payment-method-add') {
  16415. WHMCS.payment.display.reset();
  16416. jQuery('div.fieldgroup-creditcard'
  16417. + ',div.fieldgroup-bankaccount'
  16418. + ',div.fieldgroup-auxfields').hide();
  16419. }
  16420. WHMCS.payment.display.show(jQuery(selector));
  16421. }, eventOptions);
  16422. this.onGatewayUnselected(function (metadata, element) {
  16423. WHMCS.payment.display.hide(jQuery(selector));
  16424. }, eventOptions);
  16425. return this;
  16426. }
  16427. }
  16428. return new Handler(moduleName);
  16429. }
  16430. },
  16431. register: function () {
  16432. this.onGatewayInit = function (module, fn, options) {
  16433. if (!this.isFunction('register.gatewayInit', fn)) return this;
  16434. this.registerForEvent(
  16435. WHMCS.payment.event.observersGatewayInit,
  16436. module,
  16437. fn,
  16438. options
  16439. )
  16440. return this;
  16441. }
  16442. this.onGatewayOptionInit = function (module, fn, options) {
  16443. if (!this.isFunction('register.gatewayOptionInit', fn)) return this;
  16444. this.registerForEvent(
  16445. WHMCS.payment.event.observersGatewayOptionInit,
  16446. module,
  16447. fn,
  16448. options
  16449. )
  16450. return this;
  16451. }
  16452. this.onGatewaySelected = function (module, fn, options) {
  16453. if (!this.isFunction('register.onGatewaySelected', fn)) return this;
  16454. this.registerForEvent(
  16455. WHMCS.payment.event.observersGatewaySelected,
  16456. module,
  16457. fn,
  16458. options
  16459. )
  16460. return this;
  16461. }
  16462. this.onGatewayUnselected = function (module, fn, options) {
  16463. if (!this.isFunction('register.onGatewayUnselected', fn)) return this;
  16464. this.registerForEvent(
  16465. WHMCS.payment.event.observersGatewayUnselected,
  16466. module,
  16467. fn,
  16468. options
  16469. )
  16470. return this;
  16471. }
  16472. this.onCheckoutFormSubmit = function (module, fn, options) {
  16473. if (!this.isFunction('register.onCheckoutFormSubmit', fn)) return this;
  16474. this.registerForEvent(
  16475. WHMCS.payment.event.observersCheckoutFormSubmit,
  16476. module,
  16477. fn,
  16478. options
  16479. )
  16480. return this;
  16481. }
  16482. this.onAddPayMethodFormSubmit = function (module, fn, options) {
  16483. if (!this.isFunction('register.onAddPayMethodFormSubmit', fn)) return this;
  16484. this.registerForEvent(
  16485. WHMCS.payment.event.observersAddPayMethodFormSubmit,
  16486. module,
  16487. fn,
  16488. options
  16489. )
  16490. return this;
  16491. }
  16492. this.defaultEventOpts = function () {
  16493. return {
  16494. priority: 100,
  16495. once: false,
  16496. };
  16497. }
  16498. this.registerForEvent = function (observerMap, module, fn, options) {
  16499. if (!observerMap.has(module)) {
  16500. observerMap.set(module, new Map);
  16501. }
  16502. observerMap.get(module).set(options.priority, {
  16503. _fn: fn,
  16504. ...options,
  16505. });
  16506. return this;
  16507. }
  16508. this.isFunction = function (label, fn) {
  16509. if (typeof fn != 'function') {
  16510. console.error('[register.' + label + '] Expecting a function, got ' + fn);
  16511. return false;
  16512. }
  16513. return true;
  16514. }
  16515. },
  16516. event: function () {
  16517. this.observersGatewayInit = new Map;
  16518. this.observersGatewayOptionInit = new Map;
  16519. this.observersGatewaySelected = new Map;
  16520. this.observersGatewayUnselected = new Map;
  16521. this.observersCheckoutFormSubmit = new Map;
  16522. this.observersAddPayMethodFormSubmit = new Map;
  16523. this.previouslySelected = null;
  16524. this.gatewayInit = function (metadata, module) {
  16525. this.notifyEvent(
  16526. 'gatewayInit',
  16527. this.observersGatewayInit,
  16528. module,
  16529. metadata
  16530. );
  16531. }
  16532. this.gatewayOptionInit = function (metadata, module, formElement) {
  16533. this.notifyEvent(
  16534. 'gatewayOptionInit',
  16535. this.observersGatewayOptionInit,
  16536. module,
  16537. metadata,
  16538. formElement
  16539. );
  16540. }
  16541. this.gatewaySelected = function (metadata, module, formElement) {
  16542. this.previouslySelected = {
  16543. formElement: formElement,
  16544. module: module,
  16545. };
  16546. this.notifyEvent(
  16547. 'gatewaySelected',
  16548. this.observersGatewaySelected,
  16549. module,
  16550. metadata,
  16551. formElement
  16552. );
  16553. }
  16554. this.gatewayUnselected = function (metadata) {
  16555. if (this.previouslySelected == null) return;
  16556. this.notifyEvent(
  16557. 'gatewayUnselected',
  16558. this.observersGatewayUnselected,
  16559. this.previouslySelected.module,
  16560. metadata,
  16561. this.previouslySelected.formElement
  16562. );
  16563. }
  16564. this.checkoutFormSubmit = function (metadata, module, formElement) {
  16565. this.notifyEvent(
  16566. 'checkoutFormSubmit',
  16567. this.observersCheckoutFormSubmit,
  16568. module,
  16569. metadata,
  16570. formElement
  16571. );
  16572. }
  16573. this.addPayMethodFormSubmit = function (metadata, module, formElement) {
  16574. this.notifyEvent(
  16575. 'addPayMethodFormSubmit',
  16576. this.observersAddPayMethodFormSubmit,
  16577. module,
  16578. metadata,
  16579. formElement
  16580. );
  16581. }
  16582. this.notifyEvent = function (eventName, observersMap, module, metadata, formElement) {
  16583. if (!observersMap.has(module)) {
  16584. return;
  16585. }
  16586. var observers = observersMap.get(module);
  16587. var destruct = [];
  16588. this.notifyOrdered(observers, function (observer, priority) {
  16589. observer._fn(metadata, formElement);
  16590. if (observer.once) {
  16591. destruct.push(priority);
  16592. }
  16593. });
  16594. destruct.forEach(function (k) {
  16595. observers.delete(k);
  16596. })
  16597. }
  16598. this.notifyOrdered = function (observersMap, fn) {
  16599. (new Map([...observersMap.entries()].sort())).forEach(fn);
  16600. }
  16601. },
  16602. query: function () {
  16603. this.isGatewaySelected = function (module) {
  16604. return (
  16605. WHMCS.payment.event.previouslySelected != null
  16606. && WHMCS.payment.event.previouslySelected.module == module
  16607. );
  16608. }
  16609. },
  16610. behavior: function () {
  16611. this.disableDefaultCardValidation = function (source) {
  16612. if (source == 'invoice-pay') {
  16613. if (typeof validateCreditCardInput === 'function') {
  16614. jQuery('#frmPayment').off('submit', validateCreditCardInput);
  16615. }
  16616. } else if (source == 'checkout') {
  16617. if (typeof validateCheckoutCreditCardInput === 'function') {
  16618. jQuery('#frmCheckout').off('submit', validateCheckoutCreditCardInput);
  16619. }
  16620. } else {
  16621. WHMCS.payment.internal.reportUnknownSource(source);
  16622. }
  16623. }
  16624. this.enableDefaultCardValidation = function (source) {
  16625. if (source == 'invoice-pay') {
  16626. if (typeof validateCreditCardInput === 'function') {
  16627. jQuery('#frmPayment').on('submit', validateCreditCardInput);
  16628. }
  16629. } else if (source == 'checkout') {
  16630. if (typeof validateCheckoutCreditCardInput === 'function') {
  16631. jQuery('#frmCheckout').on('submit', validateCheckoutCreditCardInput);
  16632. }
  16633. } else {
  16634. WHMCS.payment.internal.reportUnknownSource(source);
  16635. }
  16636. }
  16637. },
  16638. display: function () {
  16639. this.reset = function () {
  16640. var container = jQuery('#paymentGatewayInput');
  16641. if (container.length == 0) return;
  16642. var existing = container.children();
  16643. existing.hide();
  16644. jQuery('body').append(existing);
  16645. return this;
  16646. }
  16647. this.show = function (inputContainer) {
  16648. var container = jQuery('#paymentGatewayInput');
  16649. if (container.length == 0) return;
  16650. container.append(inputContainer);
  16651. inputContainer.slideDown();
  16652. return this;
  16653. }
  16654. this.hide = function (inputContainer) {
  16655. inputContainer.slideUp({
  16656. complete: function () {
  16657. jQuery('body').append(inputContainer);
  16658. },
  16659. });
  16660. return this;
  16661. }
  16662. this.error = function (errorMessage) {
  16663. jQuery('.gateway-errors').html(errorMessage);
  16664. return this;
  16665. }
  16666. this.errorClear = function () {
  16667. let gatewayErrorsContainer = jQuery('.gateway-errors');
  16668. if (gatewayErrorsContainer.length == 0) return;
  16669. this.error('');
  16670. gatewayErrorsContainer.slideUp();
  16671. return this;
  16672. }
  16673. this.errorShow = function (errorMessage) {
  16674. let gatewayErrorsContainer = jQuery('.gateway-errors');
  16675. if (gatewayErrorsContainer.length == 0) return;
  16676. this.error(errorMessage);
  16677. gatewayErrorsContainer.slideDown()
  16678. return this;
  16679. }
  16680. this.submitReset = function (source) {
  16681. if (source == 'invoice-pay') {
  16682. this.invoiceSubmitReset();
  16683. } else if (source == 'checkout') {
  16684. this.checkoutSubmitReset();
  16685. } else {
  16686. WHMCS.payment.internal.reportUnknownSource(source);
  16687. }
  16688. };
  16689. this.invoiceSubmitReset = function () {
  16690. let btnSubmit = jQuery('#btnSubmit').prop('disabled', false)
  16691. .removeClass('disabled');
  16692. btnSubmit.find('.click-text').hide();
  16693. btnSubmit.find('.pay-text').show();
  16694. }
  16695. this.checkoutSubmitReset = function () {
  16696. jQuery('#btnCompleteOrder').removeClass('disabled')
  16697. .removeClass('disable-on-click')
  16698. .removeClass('spinner-on-click')
  16699. .addClass('disable-on-click spinner-on-click')
  16700. .prop('disabled', false)
  16701. .find('i.fas')
  16702. .removeAttr('class')
  16703. .addClass('fas fa-arrow-circle-right');
  16704. }
  16705. this.submitDisable = function (source) {
  16706. if (source == 'invoice-pay') {
  16707. this.invoiceSubmitDisable();
  16708. } else if (source == 'checkout') {
  16709. this.checkoutSubmitDisable();
  16710. } else {
  16711. WHMCS.payment.internal.reportUnknownSource(source);
  16712. }
  16713. };
  16714. this.invoiceSubmitDisable = function () {
  16715. jQuery('#btnSubmit').addClass('disabled')
  16716. .prop('disabled', true);
  16717. }
  16718. this.checkoutSubmitDisable = function () {
  16719. jQuery('#btnCompleteOrder').addClass('disabled')
  16720. .prop('disabled', true);
  16721. }
  16722. },
  16723. });
  16724. /**
  16725. * microplugin.js
  16726. * Copyright (c) 2013 Brian Reavis & contributors
  16727. *
  16728. * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
  16729. * file except in compliance with the License. You may obtain a copy of the License at:
  16730. * http://www.apache.org/licenses/LICENSE-2.0
  16731. *
  16732. * Unless required by applicable law or agreed to in writing, software distributed under
  16733. * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
  16734. * ANY KIND, either express or implied. See the License for the specific language
  16735. * governing permissions and limitations under the License.
  16736. *
  16737. * @author Brian Reavis <brian@thirdroute.com>
  16738. */
  16739. (function(root, factory) {
  16740. if (typeof define === 'function' && define.amd) {
  16741. define(factory);
  16742. } else if (typeof exports === 'object') {
  16743. module.exports = factory();
  16744. } else {
  16745. root.MicroPlugin = factory();
  16746. }
  16747. }(this, function() {
  16748. var MicroPlugin = {};
  16749. MicroPlugin.mixin = function(Interface) {
  16750. Interface.plugins = {};
  16751. /**
  16752. * Initializes the listed plugins (with options).
  16753. * Acceptable formats:
  16754. *
  16755. * List (without options):
  16756. * ['a', 'b', 'c']
  16757. *
  16758. * List (with options):
  16759. * [{'name': 'a', options: {}}, {'name': 'b', options: {}}]
  16760. *
  16761. * Hash (with options):
  16762. * {'a': { ... }, 'b': { ... }, 'c': { ... }}
  16763. *
  16764. * @param {mixed} plugins
  16765. */
  16766. Interface.prototype.initializePlugins = function(plugins) {
  16767. var i, n, key;
  16768. var self = this;
  16769. var queue = [];
  16770. self.plugins = {
  16771. names : [],
  16772. settings : {},
  16773. requested : {},
  16774. loaded : {}
  16775. };
  16776. if (utils.isArray(plugins)) {
  16777. for (i = 0, n = plugins.length; i < n; i++) {
  16778. if (typeof plugins[i] === 'string') {
  16779. queue.push(plugins[i]);
  16780. } else {
  16781. self.plugins.settings[plugins[i].name] = plugins[i].options;
  16782. queue.push(plugins[i].name);
  16783. }
  16784. }
  16785. } else if (plugins) {
  16786. for (key in plugins) {
  16787. if (plugins.hasOwnProperty(key)) {
  16788. self.plugins.settings[key] = plugins[key];
  16789. queue.push(key);
  16790. }
  16791. }
  16792. }
  16793. while (queue.length) {
  16794. self.require(queue.shift());
  16795. }
  16796. };
  16797. Interface.prototype.loadPlugin = function(name) {
  16798. var self = this;
  16799. var plugins = self.plugins;
  16800. var plugin = Interface.plugins[name];
  16801. if (!Interface.plugins.hasOwnProperty(name)) {
  16802. throw new Error('Unable to find "' + name + '" plugin');
  16803. }
  16804. plugins.requested[name] = true;
  16805. plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]);
  16806. plugins.names.push(name);
  16807. };
  16808. /**
  16809. * Initializes a plugin.
  16810. *
  16811. * @param {string} name
  16812. */
  16813. Interface.prototype.require = function(name) {
  16814. var self = this;
  16815. var plugins = self.plugins;
  16816. if (!self.plugins.loaded.hasOwnProperty(name)) {
  16817. if (plugins.requested[name]) {
  16818. throw new Error('Plugin has circular dependency ("' + name + '")');
  16819. }
  16820. self.loadPlugin(name);
  16821. }
  16822. return plugins.loaded[name];
  16823. };
  16824. /**
  16825. * Registers a plugin.
  16826. *
  16827. * @param {string} name
  16828. * @param {function} fn
  16829. */
  16830. Interface.define = function(name, fn) {
  16831. Interface.plugins[name] = {
  16832. 'name' : name,
  16833. 'fn' : fn
  16834. };
  16835. };
  16836. };
  16837. var utils = {
  16838. isArray: Array.isArray || function(vArg) {
  16839. return Object.prototype.toString.call(vArg) === '[object Array]';
  16840. }
  16841. };
  16842. return MicroPlugin;
  16843. }));
  16844. /**
  16845. * sifter.js
  16846. * Copyright (c) 2013 Brian Reavis & contributors
  16847. *
  16848. * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
  16849. * file except in compliance with the License. You may obtain a copy of the License at:
  16850. * http://www.apache.org/licenses/LICENSE-2.0
  16851. *
  16852. * Unless required by applicable law or agreed to in writing, software distributed under
  16853. * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
  16854. * ANY KIND, either express or implied. See the License for the specific language
  16855. * governing permissions and limitations under the License.
  16856. *
  16857. * @author Brian Reavis <brian@thirdroute.com>
  16858. */
  16859. (function(root, factory) {
  16860. if (typeof define === 'function' && define.amd) {
  16861. define(factory);
  16862. } else if (typeof exports === 'object') {
  16863. module.exports = factory();
  16864. } else {
  16865. root.Sifter = factory();
  16866. }
  16867. }(this, function() {
  16868. /**
  16869. * Textually searches arrays and hashes of objects
  16870. * by property (or multiple properties). Designed
  16871. * specifically for autocomplete.
  16872. *
  16873. * @constructor
  16874. * @param {array|object} items
  16875. * @param {object} items
  16876. */
  16877. var Sifter = function(items, settings) {
  16878. this.items = items;
  16879. this.settings = settings || {diacritics: true};
  16880. };
  16881. /**
  16882. * Splits a search string into an array of individual
  16883. * regexps to be used to match results.
  16884. *
  16885. * @param {string} query
  16886. * @returns {array}
  16887. */
  16888. Sifter.prototype.tokenize = function(query) {
  16889. query = trim(String(query || '').toLowerCase());
  16890. if (!query || !query.length) return [];
  16891. var i, n, regex, letter;
  16892. var tokens = [];
  16893. var words = query.split(/ +/);
  16894. for (i = 0, n = words.length; i < n; i++) {
  16895. regex = escape_regex(words[i]);
  16896. if (this.settings.diacritics) {
  16897. for (letter in DIACRITICS) {
  16898. if (DIACRITICS.hasOwnProperty(letter)) {
  16899. regex = regex.replace(new RegExp(letter, 'g'), DIACRITICS[letter]);
  16900. }
  16901. }
  16902. }
  16903. tokens.push({
  16904. string : words[i],
  16905. regex : new RegExp(regex, 'i')
  16906. });
  16907. }
  16908. return tokens;
  16909. };
  16910. /**
  16911. * Iterates over arrays and hashes.
  16912. *
  16913. * ```
  16914. * this.iterator(this.items, function(item, id) {
  16915. * // invoked for each item
  16916. * });
  16917. * ```
  16918. *
  16919. * @param {array|object} object
  16920. */
  16921. Sifter.prototype.iterator = function(object, callback) {
  16922. var iterator;
  16923. if (is_array(object)) {
  16924. iterator = Array.prototype.forEach || function(callback) {
  16925. for (var i = 0, n = this.length; i < n; i++) {
  16926. callback(this[i], i, this);
  16927. }
  16928. };
  16929. } else {
  16930. iterator = function(callback) {
  16931. for (var key in this) {
  16932. if (this.hasOwnProperty(key)) {
  16933. callback(this[key], key, this);
  16934. }
  16935. }
  16936. };
  16937. }
  16938. iterator.apply(object, [callback]);
  16939. };
  16940. /**
  16941. * Returns a function to be used to score individual results.
  16942. *
  16943. * Good matches will have a higher score than poor matches.
  16944. * If an item is not a match, 0 will be returned by the function.
  16945. *
  16946. * @param {object|string} search
  16947. * @param {object} options (optional)
  16948. * @returns {function}
  16949. */
  16950. Sifter.prototype.getScoreFunction = function(search, options) {
  16951. var self, fields, tokens, token_count, nesting;
  16952. self = this;
  16953. search = self.prepareSearch(search, options);
  16954. tokens = search.tokens;
  16955. fields = search.options.fields;
  16956. token_count = tokens.length;
  16957. nesting = search.options.nesting;
  16958. /**
  16959. * Calculates how close of a match the
  16960. * given value is against a search token.
  16961. *
  16962. * @param {mixed} value
  16963. * @param {object} token
  16964. * @return {number}
  16965. */
  16966. var scoreValue = function(value, token) {
  16967. var score, pos;
  16968. if (!value) return 0;
  16969. value = String(value || '');
  16970. pos = value.search(token.regex);
  16971. if (pos === -1) return 0;
  16972. score = token.string.length / value.length;
  16973. if (pos === 0) score += 0.5;
  16974. return score;
  16975. };
  16976. /**
  16977. * Calculates the score of an object
  16978. * against the search query.
  16979. *
  16980. * @param {object} token
  16981. * @param {object} data
  16982. * @return {number}
  16983. */
  16984. var scoreObject = (function() {
  16985. var field_count = fields.length;
  16986. if (!field_count) {
  16987. return function() { return 0; };
  16988. }
  16989. if (field_count === 1) {
  16990. return function(token, data) {
  16991. return scoreValue(getattr(data, fields[0], nesting), token);
  16992. };
  16993. }
  16994. return function(token, data) {
  16995. for (var i = 0, sum = 0; i < field_count; i++) {
  16996. sum += scoreValue(getattr(data, fields[i], nesting), token);
  16997. }
  16998. return sum / field_count;
  16999. };
  17000. })();
  17001. if (!token_count) {
  17002. return function() { return 0; };
  17003. }
  17004. if (token_count === 1) {
  17005. return function(data) {
  17006. return scoreObject(tokens[0], data);
  17007. };
  17008. }
  17009. if (search.options.conjunction === 'and') {
  17010. return function(data) {
  17011. var score;
  17012. for (var i = 0, sum = 0; i < token_count; i++) {
  17013. score = scoreObject(tokens[i], data);
  17014. if (score <= 0) return 0;
  17015. sum += score;
  17016. }
  17017. return sum / token_count;
  17018. };
  17019. } else {
  17020. return function(data) {
  17021. for (var i = 0, sum = 0; i < token_count; i++) {
  17022. sum += scoreObject(tokens[i], data);
  17023. }
  17024. return sum / token_count;
  17025. };
  17026. }
  17027. };
  17028. /**
  17029. * Returns a function that can be used to compare two
  17030. * results, for sorting purposes. If no sorting should
  17031. * be performed, `null` will be returned.
  17032. *
  17033. * @param {string|object} search
  17034. * @param {object} options
  17035. * @return function(a,b)
  17036. */
  17037. Sifter.prototype.getSortFunction = function(search, options) {
  17038. var i, n, self, field, fields, fields_count, multiplier, multipliers, get_field, implicit_score, sort;
  17039. self = this;
  17040. search = self.prepareSearch(search, options);
  17041. sort = (!search.query && options.sort_empty) || options.sort;
  17042. /**
  17043. * Fetches the specified sort field value
  17044. * from a search result item.
  17045. *
  17046. * @param {string} name
  17047. * @param {object} result
  17048. * @return {mixed}
  17049. */
  17050. get_field = function(name, result) {
  17051. if (name === '$score') return result.score;
  17052. return getattr(self.items[result.id], name, options.nesting);
  17053. };
  17054. // parse options
  17055. fields = [];
  17056. if (sort) {
  17057. for (i = 0, n = sort.length; i < n; i++) {
  17058. if (search.query || sort[i].field !== '$score') {
  17059. fields.push(sort[i]);
  17060. }
  17061. }
  17062. }
  17063. // the "$score" field is implied to be the primary
  17064. // sort field, unless it's manually specified
  17065. if (search.query) {
  17066. implicit_score = true;
  17067. for (i = 0, n = fields.length; i < n; i++) {
  17068. if (fields[i].field === '$score') {
  17069. implicit_score = false;
  17070. break;
  17071. }
  17072. }
  17073. if (implicit_score) {
  17074. fields.unshift({field: '$score', direction: 'desc'});
  17075. }
  17076. } else {
  17077. for (i = 0, n = fields.length; i < n; i++) {
  17078. if (fields[i].field === '$score') {
  17079. fields.splice(i, 1);
  17080. break;
  17081. }
  17082. }
  17083. }
  17084. multipliers = [];
  17085. for (i = 0, n = fields.length; i < n; i++) {
  17086. multipliers.push(fields[i].direction === 'desc' ? -1 : 1);
  17087. }
  17088. // build function
  17089. fields_count = fields.length;
  17090. if (!fields_count) {
  17091. return null;
  17092. } else if (fields_count === 1) {
  17093. field = fields[0].field;
  17094. multiplier = multipliers[0];
  17095. return function(a, b) {
  17096. return multiplier * cmp(
  17097. get_field(field, a),
  17098. get_field(field, b)
  17099. );
  17100. };
  17101. } else {
  17102. return function(a, b) {
  17103. var i, result, a_value, b_value, field;
  17104. for (i = 0; i < fields_count; i++) {
  17105. field = fields[i].field;
  17106. result = multipliers[i] * cmp(
  17107. get_field(field, a),
  17108. get_field(field, b)
  17109. );
  17110. if (result) return result;
  17111. }
  17112. return 0;
  17113. };
  17114. }
  17115. };
  17116. /**
  17117. * Parses a search query and returns an object
  17118. * with tokens and fields ready to be populated
  17119. * with results.
  17120. *
  17121. * @param {string} query
  17122. * @param {object} options
  17123. * @returns {object}
  17124. */
  17125. Sifter.prototype.prepareSearch = function(query, options) {
  17126. if (typeof query === 'object') return query;
  17127. options = extend({}, options);
  17128. var option_fields = options.fields;
  17129. var option_sort = options.sort;
  17130. var option_sort_empty = options.sort_empty;
  17131. if (option_fields && !is_array(option_fields)) options.fields = [option_fields];
  17132. if (option_sort && !is_array(option_sort)) options.sort = [option_sort];
  17133. if (option_sort_empty && !is_array(option_sort_empty)) options.sort_empty = [option_sort_empty];
  17134. return {
  17135. options : options,
  17136. query : String(query || '').toLowerCase(),
  17137. tokens : this.tokenize(query),
  17138. total : 0,
  17139. items : []
  17140. };
  17141. };
  17142. /**
  17143. * Searches through all items and returns a sorted array of matches.
  17144. *
  17145. * The `options` parameter can contain:
  17146. *
  17147. * - fields {string|array}
  17148. * - sort {array}
  17149. * - score {function}
  17150. * - filter {bool}
  17151. * - limit {integer}
  17152. *
  17153. * Returns an object containing:
  17154. *
  17155. * - options {object}
  17156. * - query {string}
  17157. * - tokens {array}
  17158. * - total {int}
  17159. * - items {array}
  17160. *
  17161. * @param {string} query
  17162. * @param {object} options
  17163. * @returns {object}
  17164. */
  17165. Sifter.prototype.search = function(query, options) {
  17166. var self = this, value, score, search, calculateScore;
  17167. var fn_sort;
  17168. var fn_score;
  17169. search = this.prepareSearch(query, options);
  17170. options = search.options;
  17171. query = search.query;
  17172. // generate result scoring function
  17173. fn_score = options.score || self.getScoreFunction(search);
  17174. // perform search and sort
  17175. if (query.length) {
  17176. self.iterator(self.items, function(item, id) {
  17177. score = fn_score(item);
  17178. if (options.filter === false || score > 0) {
  17179. search.items.push({'score': score, 'id': id});
  17180. }
  17181. });
  17182. } else {
  17183. self.iterator(self.items, function(item, id) {
  17184. search.items.push({'score': 1, 'id': id});
  17185. });
  17186. }
  17187. fn_sort = self.getSortFunction(search, options);
  17188. if (fn_sort) search.items.sort(fn_sort);
  17189. // apply limits
  17190. search.total = search.items.length;
  17191. if (typeof options.limit === 'number') {
  17192. search.items = search.items.slice(0, options.limit);
  17193. }
  17194. return search;
  17195. };
  17196. // utilities
  17197. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  17198. var cmp = function(a, b) {
  17199. if (typeof a === 'number' && typeof b === 'number') {
  17200. return a > b ? 1 : (a < b ? -1 : 0);
  17201. }
  17202. a = asciifold(String(a || ''));
  17203. b = asciifold(String(b || ''));
  17204. if (a > b) return 1;
  17205. if (b > a) return -1;
  17206. return 0;
  17207. };
  17208. var extend = function(a, b) {
  17209. var i, n, k, object;
  17210. for (i = 1, n = arguments.length; i < n; i++) {
  17211. object = arguments[i];
  17212. if (!object) continue;
  17213. for (k in object) {
  17214. if (object.hasOwnProperty(k)) {
  17215. a[k] = object[k];
  17216. }
  17217. }
  17218. }
  17219. return a;
  17220. };
  17221. /**
  17222. * A property getter resolving dot-notation
  17223. * @param {Object} obj The root object to fetch property on
  17224. * @param {String} name The optionally dotted property name to fetch
  17225. * @param {Boolean} nesting Handle nesting or not
  17226. * @return {Object} The resolved property value
  17227. */
  17228. var getattr = function(obj, name, nesting) {
  17229. if (!obj || !name) return;
  17230. if (!nesting) return obj[name];
  17231. var names = name.split(".");
  17232. while(names.length && (obj = obj[names.shift()]));
  17233. return obj;
  17234. };
  17235. var trim = function(str) {
  17236. return (str + '').replace(/^\s+|\s+$|/g, '');
  17237. };
  17238. var escape_regex = function(str) {
  17239. return (str + '').replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
  17240. };
  17241. var is_array = Array.isArray || (typeof $ !== 'undefined' && $.isArray) || function(object) {
  17242. return Object.prototype.toString.call(object) === '[object Array]';
  17243. };
  17244. var DIACRITICS = {
  17245. 'a': '[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]',
  17246. 'b': '[b␢βΒB฿𐌁ᛒ]',
  17247. 'c': '[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄCc]',
  17248. 'd': '[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅDdð]',
  17249. 'e': '[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇEeɘǝƏƐε]',
  17250. 'f': '[fƑƒḞḟ]',
  17251. 'g': '[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]',
  17252. 'h': '[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]',
  17253. 'i': '[iÍíÌìĬĭÎîǏǐÏïḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ̆ᵻᶖİiIıɪIi]',
  17254. 'j': '[jȷĴĵɈɉʝɟʲ]',
  17255. 'k': '[kƘƙꝀꝁḰḱǨǩḲḳḴḵκϰ₭]',
  17256. 'l': '[lŁłĽľĻļĹĺḶḷḸḹḼḽḺḻĿŀȽƚⱠⱡⱢɫɬᶅɭȴʟLl]',
  17257. 'n': '[nŃńǸǹŇňÑñṄṅŅņṆṇṊṋṈṉN̈n̈ƝɲȠƞᵰᶇɳȵɴNnŊŋ]',
  17258. 'o': '[oØøÖöÓóÒòÔôǑǒŐőŎŏȮȯỌọƟɵƠơỎỏŌōÕõǪǫȌȍՕօ]',
  17259. 'p': '[pṔṕṖṗⱣᵽƤƥᵱ]',
  17260. 'q': '[qꝖꝗʠɊɋꝘꝙq̃]',
  17261. 'r': '[rŔŕɌɍŘřŖŗṘṙȐȑȒȓṚṛⱤɽ]',
  17262. 's': '[sŚśṠṡṢṣꞨꞩŜŝŠšŞşȘșS̈s̈]',
  17263. 't': '[tŤťṪṫŢţṬṭƮʈȚțṰṱṮṯƬƭ]',
  17264. 'u': '[uŬŭɄʉỤụÜüÚúÙùÛûǓǔŰűŬŭƯưỦủŪūŨũŲųȔȕ∪]',
  17265. 'v': '[vṼṽṾṿƲʋꝞꝟⱱʋ]',
  17266. 'w': '[wẂẃẀẁŴŵẄẅẆẇẈẉ]',
  17267. 'x': '[xẌẍẊẋχ]',
  17268. 'y': '[yÝýỲỳŶŷŸÿỸỹẎẏỴỵɎɏƳƴ]',
  17269. 'z': '[zŹźẐẑŽžŻżẒẓẔẕƵƶ]'
  17270. };
  17271. var asciifold = (function() {
  17272. var i, n, k, chunk;
  17273. var foreignletters = '';
  17274. var lookup = {};
  17275. for (k in DIACRITICS) {
  17276. if (DIACRITICS.hasOwnProperty(k)) {
  17277. chunk = DIACRITICS[k].substring(2, DIACRITICS[k].length - 1);
  17278. foreignletters += chunk;
  17279. for (i = 0, n = chunk.length; i < n; i++) {
  17280. lookup[chunk.charAt(i)] = k;
  17281. }
  17282. }
  17283. }
  17284. var regexp = new RegExp('[' + foreignletters + ']', 'g');
  17285. return function(str) {
  17286. return str.replace(regexp, function(foreignletter) {
  17287. return lookup[foreignletter];
  17288. }).toLowerCase();
  17289. };
  17290. })();
  17291. // export
  17292. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  17293. return Sifter;
  17294. }));
  17295. /**
  17296. * General utilities module
  17297. *
  17298. * @copyright Copyright (c) WHMCS Limited 2005-2017
  17299. * @license http://www.whmcs.com/license/ WHMCS Eula
  17300. */
  17301. (function(module) {
  17302. if (!WHMCS.hasModule('utils')) {
  17303. WHMCS.loadModule('utils', module);
  17304. }
  17305. })(
  17306. function () {
  17307. /**
  17308. * Not crypto strong; server-side must discard for
  17309. * something with more entropy; the value is sufficient
  17310. * for strong client-side validation check
  17311. */
  17312. this.simpleRNG = function () {
  17313. var chars = './$_-#!,^*()|';
  17314. var r = 0;
  17315. for (var i = 0; r < 3; i++) {
  17316. r += Math.floor((Math.random() * 10) / 2);
  17317. }
  17318. r = Math.floor(r);
  17319. var s = '';
  17320. for (var x = 0; x < r; x++) {
  17321. v = (Math.random() + 1).toString(24).split('.')[1];
  17322. if ((Math.random()) > 0.5) {
  17323. s += btoa(v).substr(0,4)
  17324. } else {
  17325. s += v
  17326. }
  17327. if ((Math.random()) > 0.5) {
  17328. s += chars.substr(
  17329. Math.floor(Math.random() * 13),
  17330. 1
  17331. );
  17332. }
  17333. }
  17334. return s;
  17335. };
  17336. this.getRouteUrl = function (path) {
  17337. return whmcsBaseUrl + "/index.php?rp=" + path;
  17338. };
  17339. this.validateBaseUrl = function() {
  17340. if (typeof window.whmcsBaseUrl === 'undefined') {
  17341. console.log('Warning: The WHMCS Base URL definition is missing '
  17342. + 'from your active template. Please refer to '
  17343. + 'https://go.whmcs.com/1961/base-url '
  17344. + 'for more information and details of how to resolve this '
  17345. + 'warning.');
  17346. window.whmcsBaseUrl = this.autoDetermineBaseUrl();
  17347. window.whmcsBaseUrlAutoSet = true;
  17348. } else if (window.whmcsBaseUrl === ''
  17349. && typeof window.whmcsBaseUrlAutoSet !== 'undefined'
  17350. && window.whmcsBaseUrlAutoSet === true
  17351. ) {
  17352. window.whmcsBaseUrl = this.autoDetermineBaseUrl();
  17353. }
  17354. };
  17355. this.autoDetermineBaseUrl = function() {
  17356. var windowLocation = window.location.href;
  17357. var phpExtensionLocation = -1;
  17358. if (typeof windowLocation !== 'undefined') {
  17359. phpExtensionLocation = windowLocation.indexOf('.php');
  17360. }
  17361. if (phpExtensionLocation === -1) {
  17362. windowLocation = jQuery('#Primary_Navbar-Home a').attr('href');
  17363. if (typeof windowLocation !== 'undefined') {
  17364. phpExtensionLocation = windowLocation.indexOf('.php');
  17365. }
  17366. }
  17367. if (phpExtensionLocation !== -1) {
  17368. windowLocation = windowLocation.substring(0, phpExtensionLocation);
  17369. var lastTrailingSlash = windowLocation.lastIndexOf('/');
  17370. if (lastTrailingSlash !== false) {
  17371. return windowLocation.substring(0, lastTrailingSlash);
  17372. }
  17373. }
  17374. return '';
  17375. };
  17376. this.normaliseStringValue = function(status) {
  17377. return status ? status.toLowerCase().replace(/\s/g, '-') : '';
  17378. };
  17379. this.generatePassword = function(len) {
  17380. var charset = this.getPasswordCharacterSet();
  17381. var result = "";
  17382. for (var i = 0; len > i; i++)
  17383. result += charset[this.randomInt(charset.length)];
  17384. return result;
  17385. };
  17386. this.getPasswordCharacterSet = function() {
  17387. var rawCharset = '0123456789'
  17388. + 'abcdefghijklmnopqrstuvwxyz'
  17389. + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  17390. + '!#$%()*+,-.:;=@_|{ldelim}{rdelim}~';
  17391. // Parse UTF-16, remove duplicates, convert to array of strings
  17392. var charset = [];
  17393. for (var i = 0; rawCharset.length > i; i++) {
  17394. var c = rawCharset.charCodeAt(i);
  17395. if (0xD800 > c || c >= 0xE000) { // Regular UTF-16 character
  17396. var s = rawCharset.charAt(i);
  17397. if (charset.indexOf(s) == -1)
  17398. charset.push(s);
  17399. continue;
  17400. }
  17401. if (0xDC00 > c ? rawCharset.length > i + 1 : false) { // High surrogate
  17402. var d = rawCharset.charCodeAt(i + 1);
  17403. if (d >= 0xDC00 ? 0xE000 > d : false) { // Low surrogate
  17404. var s = rawCharset.substring(i, i + 2);
  17405. i++;
  17406. if (charset.indexOf(s) == -1)
  17407. charset.push(s);
  17408. continue;
  17409. }
  17410. }
  17411. throw "Invalid UTF-16";
  17412. }
  17413. return charset;
  17414. };
  17415. this.randomInt = function(n) {
  17416. var x = this.randomIntMathRandom(n);
  17417. x = (x + this.randomIntBrowserCrypto(n)) % n;
  17418. return x;
  17419. };
  17420. this.randomIntMathRandom = function(n) {
  17421. var x = Math.floor(Math.random() * n);
  17422. if (0 > x || x >= n)
  17423. throw "Arithmetic exception";
  17424. return x;
  17425. };
  17426. this.randomIntBrowserCrypto = function(n) {
  17427. var cryptoObject = null;
  17428. if ("crypto" in window)
  17429. cryptoObject = crypto;
  17430. else if ("msCrypto" in window)
  17431. cryptoObject = msCrypto;
  17432. else
  17433. return 0;
  17434. if (!("getRandomValues" in cryptoObject) || !("Uint32Array" in window) || typeof Uint32Array != "function")
  17435. cryptoObject = null;
  17436. if (cryptoObject == null)
  17437. return 0;
  17438. // Generate an unbiased sample
  17439. var x = new Uint32Array(1);
  17440. do cryptoObject.getRandomValues(x);
  17441. while (x[0] - x[0] % n > 4294967296 - n);
  17442. return x[0] % n;
  17443. };
  17444. return this;
  17445. });
  17446. WHMCS.utils.validateBaseUrl();
  17447. /*!
  17448. * WHMCS Twenty-One Theme
  17449. * Global Javascript
  17450. * Copyright (c) 2020 WHMCS Limited
  17451. * https://www.whmcs.com/license/
  17452. */
  17453. jQuery(document).ready(function() {
  17454. // when the page loads
  17455. autoCollapse('#nav', 30);
  17456. if (jQuery('#lightbox').length === 0) {
  17457. lightbox.init();
  17458. }
  17459. // when the window is resized
  17460. jQuery(window).on('resize', function () {
  17461. if (jQuery('button[data-target="#mainNavbar"], button[data-toggle="collapse"]').is(':visible')) {
  17462. return;
  17463. }
  17464. autoCollapse('#nav', 30);
  17465. });
  17466. // Item selector
  17467. jQuery('.item-selector .item').click(function(e) {
  17468. e.preventDefault();
  17469. jQuery(this).closest('.item-selector').find('.item').removeClass('active').end()
  17470. .find('input').val(jQuery(this).data('value'));
  17471. jQuery(this).addClass('active');
  17472. });
  17473. // Password reveal
  17474. jQuery(document).on('click', '.btn-reveal-pw', function (e) {
  17475. $targetField = jQuery(this).closest('.input-group').find('.pw-input');
  17476. if ($targetField.attr('type') == 'password') {
  17477. $targetField.attr('type', 'text');
  17478. } else {
  17479. $targetField.attr('type', 'password');
  17480. }
  17481. });
  17482. // Account notifications popover
  17483. jQuery("#accountNotifications").popover({
  17484. container: 'body',
  17485. placement: 'bottom',
  17486. template: '<div class="popover popover-user-notifications" role="tooltip"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-header"></h3><div class="popover-body"><p></p></div></div></div>',
  17487. html: true,
  17488. content: function() {
  17489. return jQuery("#accountNotificationsContent").html();
  17490. },
  17491. });
  17492. jQuery('.card-sidebar .truncate').each(function () {
  17493. jQuery(this).attr('title', jQuery(this).text())
  17494. .attr('data-toggle', 'tooltip')
  17495. .attr('data-placement', 'bottom');
  17496. });
  17497. // Default catch for all other popovers
  17498. jQuery('[data-toggle="popover"]').popover({
  17499. html: true
  17500. });
  17501. // Enable tooltips
  17502. // Attach function to body so tooltips inserted by ajax will load
  17503. jQuery(function(jQuery){
  17504. jQuery('body').tooltip({
  17505. selector: '[data-toggle="tooltip"]'
  17506. });
  17507. });
  17508. // Logic to dismiss popovers on click outside
  17509. jQuery('body').on('click', function (e) {
  17510. jQuery('[data-toggle="popover"]').each(function () {
  17511. if (!jQuery(this).is(e.target) && jQuery(this).has(e.target).length === 0 && jQuery('.popover').has(e.target).length === 0) {
  17512. jQuery(this).popover('hide');
  17513. }
  17514. });
  17515. });
  17516. // Sidebar active class toggle
  17517. jQuery(".list-group-tab-nav a").click(function() {
  17518. if (jQuery(this).hasClass('disabled')) {
  17519. return false;
  17520. }
  17521. var urlFragment = this.href.split('#')[1];
  17522. if (urlFragment) {
  17523. // set the fragment in the URL bar for bookmarking and such.
  17524. window.location.hash = '#' + urlFragment;
  17525. }
  17526. });
  17527. // Sidebar minimise/maximise
  17528. jQuery('.card-minimise').click(function(e) {
  17529. e.preventDefault();
  17530. var collapsableBody = jQuery(this).closest('.card').find('.collapsable-card-body');
  17531. if (jQuery(this).hasClass('minimised')) {
  17532. collapsableBody.slideDown();
  17533. jQuery(this).removeClass('minimised');
  17534. } else {
  17535. collapsableBody.slideUp();
  17536. jQuery(this).addClass('minimised');
  17537. }
  17538. });
  17539. // Minimise sidebar panels by default on small devices
  17540. if (jQuery('.container').width() <= 720) {
  17541. jQuery('.card-sidebar').find('.collapsable-card-body').hide().end()
  17542. .find('.card-minimise').addClass('minimised');
  17543. }
  17544. // Internal page tab selection handling via location hash
  17545. var internalSelectionDisabled = false;
  17546. if (
  17547. typeof(disableInternalTabSelection) !== 'undefined'
  17548. &&
  17549. disableInternalTabSelection
  17550. ) {
  17551. internalSelectionDisabled = true;
  17552. }
  17553. if (!internalSelectionDisabled) {
  17554. if (jQuery(location).attr('hash').substr(1) !== "") {
  17555. var activeTab = jQuery(location).attr('hash');
  17556. jQuery(".primary-content > .tab-content > .tab-pane").removeClass('active');
  17557. jQuery(activeTab).removeClass('fade').addClass('active');
  17558. jQuery(".list-group-tab-nav a").removeClass('active');
  17559. jQuery('a[href="' + activeTab + '"]').addClass('active');
  17560. setTimeout(function() {
  17561. // Browsers automatically scroll on page load with a fragment.
  17562. // This scrolls back to the top right after page complete, but
  17563. // just before render (no perceptible scroll).
  17564. window.scrollTo(0, 0);
  17565. }, 1);
  17566. }
  17567. }
  17568. // Enable Switches for Checkboxes
  17569. if (jQuery.prototype.bootstrapSwitch) {
  17570. jQuery(".toggle-switch-success").bootstrapSwitch({
  17571. onColor: 'success'
  17572. });
  17573. }
  17574. // Collapsable Panels
  17575. jQuery(".panel-collapsable .card-header").click(function(e) {
  17576. var $this = jQuery(this);
  17577. if (!$this.closest('.card').hasClass('panel-collapsed')) {
  17578. $this.closest('.card').addClass('panel-collapsed').find('.card-body').slideUp();
  17579. $this.find('.collapse-icon i').removeClass('fa-minus').addClass('fa-plus');
  17580. } else {
  17581. $this.closest('.card').removeClass('panel-collapsed').find('.card-body').slideDown();
  17582. $this.find('.collapse-icon i').removeClass('fa-plus').addClass('fa-minus');
  17583. }
  17584. });
  17585. // Two-Factor Authentication Auto Focus Rules
  17586. if (("#frmLogin").length > 0) {
  17587. jQuery("#frmLogin input:text:visible:first").focus();
  17588. }
  17589. if (("#twofaactivation").length > 0) {
  17590. jQuery("#twofaactivation input:text:visible:first,#twofaactivation input:password:visible:first").focus();
  17591. }
  17592. // Sub-Account Activation Toggle
  17593. jQuery("#inputSubaccountActivate").click(function () {
  17594. if (jQuery("#inputSubaccountActivate:checked").val() != null) {
  17595. jQuery("#subacct-container").show();
  17596. } else {
  17597. jQuery("#subacct-container").hide();
  17598. }
  17599. });
  17600. // Mass Domain Management Bulk Action Handling
  17601. jQuery(".setBulkAction").click(function(event) {
  17602. event.preventDefault();
  17603. var id = jQuery(this).attr('id').replace('Link', ''),
  17604. domainForm = jQuery('#domainForm');
  17605. if (id === 'renewDomains') {
  17606. domainForm.attr('action', WHMCS.utils.getRouteUrl('/cart/domain/renew'));
  17607. } else {
  17608. if (jQuery('#' + id).length !== 0) {
  17609. var action = domainForm.attr('action');
  17610. domainForm.attr('action', action + '#' + id);
  17611. }
  17612. jQuery('#bulkaction').val(id);
  17613. }
  17614. domainForm.submit();
  17615. });
  17616. // Stop events on objects with this class from bubbling up the dom
  17617. jQuery('.stopEventBubble').click( function(event) {
  17618. event.stopPropagation();
  17619. });
  17620. // Tab Control Link handling for tab switching via regular links
  17621. jQuery('.tabControlLink').on(
  17622. 'click',
  17623. function(event) {
  17624. event.preventDefault();
  17625. var id = jQuery(this).attr('href');
  17626. jQuery("a[href='/"+id+"']").click();
  17627. }
  17628. );
  17629. jQuery(document).on('click', '.delete-cc-email', function() {
  17630. var self = jQuery(this),
  17631. email = self.data('email'),
  17632. feedback = jQuery('#divCcEmailFeedback');
  17633. if (feedback.is(':visible')) {
  17634. feedback.slideUp('fast');
  17635. }
  17636. WHMCS.http.jqClient.jsonPost({
  17637. url: window.location.href,
  17638. data: {
  17639. action: 'delete',
  17640. email: email,
  17641. token: csrfToken
  17642. },
  17643. success: function (data) {
  17644. if (data.success) {
  17645. self.closest('.ticket-cc-email').parent('div').slideUp('fast').remove();
  17646. feedback.removeClass('alert-danger')
  17647. .addClass('alert-success')
  17648. .html(data.message)
  17649. .slideDown('fast');
  17650. }
  17651. },
  17652. error: function (error) {
  17653. if (error) {
  17654. feedback.removeClass('alert-success')
  17655. .addClass('alert-danger')
  17656. .html(error)
  17657. .slideDown('fast');
  17658. }
  17659. }
  17660. });
  17661. }).on('submit', '#frmAddCcEmail', function(e) {
  17662. e.preventDefault();
  17663. var frm = jQuery(this),
  17664. cloneRow = jQuery('#ccCloneRow').clone().removeAttr('id'),
  17665. email = jQuery('#inputAddCcEmail'),
  17666. feedback = jQuery('#divCcEmailFeedback');
  17667. if (feedback.is(':visible')) {
  17668. feedback.slideUp('fast');
  17669. }
  17670. WHMCS.http.jqClient.jsonPost({
  17671. url: frm.attr('action'),
  17672. data: frm.serialize(),
  17673. success: function (data) {
  17674. if (data.success) {
  17675. cloneRow.find('span.email')
  17676. .html(email.val())
  17677. .find('button')
  17678. .data('email', email.val())
  17679. .end();
  17680. cloneRow.show()
  17681. .appendTo(jQuery('#sidebarTicketCc').find('.list-group'));
  17682. email.val('');
  17683. feedback.slideUp('fast')
  17684. .removeClass('alert-danger hidden')
  17685. .addClass('alert-success')
  17686. .html(data.message)
  17687. .slideDown('fast');
  17688. }
  17689. },
  17690. error: function (error) {
  17691. if (error) {
  17692. feedback.slideUp('fast')
  17693. .removeClass('alert-success hidden')
  17694. .addClass('alert-danger')
  17695. .html(error)
  17696. .slideDown('fast');
  17697. }
  17698. }
  17699. });
  17700. });
  17701. // Ticket Rating Click Handler
  17702. jQuery('.ticket-reply .rating span.star').click( function(event) {
  17703. window.location = 'viewticket.php?tid='
  17704. + jQuery(this).parent('.rating').attr("ticketid")
  17705. + '&c=' + jQuery(this).parent('.rating').attr("ticketkey")
  17706. + '&rating=rate' + jQuery(this).parent('.rating').attr("ticketreplyid")
  17707. + '_' + jQuery(this).attr("rate");
  17708. });
  17709. // Prevent malicious window.opener activity from auto-linked URLs
  17710. jQuery('a.autoLinked').click(function (e) {
  17711. e.preventDefault();
  17712. if (jQuery(this).hasClass('disabled')) {
  17713. return false;
  17714. }
  17715. var child = window.open();
  17716. child.opener = null;
  17717. child.location = e.target.href;
  17718. });
  17719. // Handle Single Sign-On Toggle Setting
  17720. jQuery("#inputAllowSso").on('switchChange.bootstrapSwitch', function(event, isChecked) {
  17721. if (isChecked) {
  17722. jQuery("#ssoStatusTextEnabled").show();
  17723. jQuery("#ssoStatusTextDisabled").hide();
  17724. } else {
  17725. jQuery("#ssoStatusTextDisabled").show();
  17726. jQuery("#ssoStatusTextEnabled").hide();
  17727. }
  17728. WHMCS.http.jqClient.post("clientarea.php", jQuery("#frmSingleSignOn").serialize());
  17729. });
  17730. // Single Sign-On call for Product/Service
  17731. jQuery('.btn-service-sso').on('click', function(e) {
  17732. e.preventDefault();
  17733. var button = jQuery(this);
  17734. var form = button.closest('form');
  17735. if (form.length === 0) {
  17736. form = button.find('form');
  17737. }
  17738. if (form.hasClass('disabled') || button.hasClass('disabled')) {
  17739. return;
  17740. }
  17741. var url = form.data('href');
  17742. if (!url) {
  17743. url = window.location.href;
  17744. }
  17745. button.attr('disabled', 'disabled').addClass('disabled');
  17746. jQuery('.loading', button).show().end();
  17747. jQuery('.login-feedback', form).slideUp();
  17748. WHMCS.http.jqClient.post(
  17749. url,
  17750. form.serialize(),
  17751. function (data) {
  17752. jQuery('.loading', button).hide().end().removeAttr('disabled');
  17753. jQuery('.login-feedback', form).html('');
  17754. if (data.error) {
  17755. jQuery('.login-feedback', form).hide().html(data.error).slideDown();
  17756. }
  17757. if (data.redirect !== undefined && data.redirect.substr(0, 7) === 'window|') {
  17758. window.open(data.redirect.substr(7), '_blank');
  17759. }
  17760. },
  17761. 'json'
  17762. ).always(function() {
  17763. button.removeAttr('disabled').removeClass('disabled');
  17764. button.find('.loading').hide().end();
  17765. });
  17766. });
  17767. jQuery('.btn-sidebar-form-submit').on('click', function(e) {
  17768. e.preventDefault();
  17769. jQuery(this).find('.loading').show().end()
  17770. .attr('disabled', 'disabled');
  17771. var form = jQuery(this).closest('form');
  17772. if (form.length === 0) {
  17773. form = jQuery(this).find('form');
  17774. }
  17775. if (form.length !== 0 && form.hasClass('disabled') === false) {
  17776. form.submit();
  17777. } else {
  17778. jQuery(this).find('.loading').hide().end().removeAttr('disabled');
  17779. }
  17780. });
  17781. // Back to top animated scroll
  17782. jQuery('.back-to-top').click(function(e) {
  17783. e.preventDefault();
  17784. jQuery('body,html').animate({scrollTop: 0}, 500);
  17785. });
  17786. // Prevent page scroll on language choose click
  17787. jQuery('.choose-language').click(function(e) {
  17788. e.preventDefault();
  17789. });
  17790. // Activate copy to clipboard functionality
  17791. jQuery('.copy-to-clipboard').click(WHMCS.ui.clipboard.copy);
  17792. // Handle Language Chooser modal
  17793. jQuery('#modalChooseLanguage button[type=submit]').click(function(e) {
  17794. e.preventDefault();
  17795. var form = jQuery(this).closest('form');
  17796. var currency = form.find('input[name="currency"]');
  17797. var language = form.find('input[name="language"]');
  17798. var fields = [];
  17799. if (language.data('current') != language.val()) {
  17800. fields.push('language=' + language.val());
  17801. }
  17802. if (currency.data('current') != currency.val() && currency.val() != "") {
  17803. fields.push('currency=' + currency.val());
  17804. }
  17805. window.location.replace(form.attr('action') + fields.join('&'));
  17806. });
  17807. // Password Generator
  17808. jQuery('.generate-password').click(function(e) {
  17809. jQuery('#frmGeneratePassword').submit();
  17810. jQuery('#modalGeneratePassword')
  17811. .data('targetfields', jQuery(this).data('targetfields'))
  17812. .modal('show');
  17813. });
  17814. jQuery('#frmGeneratePassword').submit(function(e) {
  17815. e.preventDefault();
  17816. var length = parseInt(jQuery('#inputGeneratePasswordLength').val(), 10);
  17817. // Check length
  17818. if (length < 8 || length > 64) {
  17819. jQuery('#generatePwLengthError').show();
  17820. return;
  17821. }
  17822. jQuery('#inputGeneratePasswordOutput').val(WHMCS.utils.generatePassword(length));
  17823. });
  17824. jQuery('#btnGeneratePasswordInsert')
  17825. .click(WHMCS.ui.clipboard.copy)
  17826. .click(function(e) {
  17827. jQuery(this).closest('.modal').modal('hide');
  17828. var targetFields = jQuery(this).closest('.modal').data('targetfields'),
  17829. generatedPassword = jQuery('#inputGeneratePasswordOutput');
  17830. targetFields = targetFields.split(',');
  17831. for(var i = 0; i < targetFields.length; i++) {
  17832. jQuery('#' + targetFields[i]).val(generatedPassword.val())
  17833. .trigger('keyup');
  17834. }
  17835. // Remove the generated password.
  17836. generatedPassword.val('');
  17837. });
  17838. /**
  17839. * If we are logged into the admin area and can edit a category and click edit,
  17840. * we need to stop the default and click the edit instead since its nested.
  17841. */
  17842. jQuery('a.card-body').click(function(e) {
  17843. if (e.target.id.includes('btnEditCategory')) {
  17844. e.preventDefault();
  17845. var editUrl = jQuery('#btnEditCategory-' + jQuery(this).data('id')).data('url');
  17846. window.location.href = editUrl;
  17847. }
  17848. });
  17849. jQuery('.kb-article-item').click(function(e) {
  17850. if (e.target.id.includes('btnEditArticle')) {
  17851. e.preventDefault();
  17852. var editUrl = jQuery('#btnEditArticle-' + jQuery(this).data('id')).data('url');
  17853. window.location.href = editUrl;
  17854. }
  17855. });
  17856. /**
  17857. * Code will loop through each element that has the class markdown-editor and
  17858. * enable the Markdown editor.
  17859. */
  17860. var count = 0,
  17861. editorName = 'clientMDE',
  17862. counter = 0;
  17863. jQuery(".markdown-editor").each(function( index ) {
  17864. count++;
  17865. var autoSaveName = jQuery(this).data('auto-save-name'),
  17866. footerId = jQuery(this).attr('id') + '-footer';
  17867. if (typeof autoSaveName == "undefined") {
  17868. autoSaveName = 'client_area';
  17869. }
  17870. window[editorName + count.toString()] = jQuery(this).markdown(
  17871. {
  17872. footer: '<div id="' + footerId + '" class="markdown-editor-status"></div>',
  17873. autofocus: false,
  17874. savable: false,
  17875. resize: 'vertical',
  17876. iconlibrary: 'fa-5',
  17877. language: locale,
  17878. onShow: function(e){
  17879. var content = '',
  17880. save_enabled = false;
  17881. if(typeof(Storage) !== "undefined") {
  17882. // Code for localStorage/sessionStorage.
  17883. content = localStorage.getItem(autoSaveName);
  17884. save_enabled = true;
  17885. if (content && typeof(content) !== "undefined") {
  17886. e.setContent(content);
  17887. }
  17888. }
  17889. jQuery("#" + footerId).html(parseMdeFooter(content, save_enabled, saved));
  17890. },
  17891. onChange: function(e){
  17892. var content = e.getContent(),
  17893. save_enabled = false;
  17894. if(typeof(Storage) !== "undefined") {
  17895. counter = 3;
  17896. save_enabled = true;
  17897. localStorage.setItem(autoSaveName, content);
  17898. doCountdown();
  17899. }
  17900. jQuery("#" + footerId).html(parseMdeFooter(content, save_enabled));
  17901. },
  17902. onPreview: function(e){
  17903. var originalContent = e.getContent(),
  17904. parsedContent;
  17905. jQuery.ajax({
  17906. url: WHMCS.utils.getRouteUrl('/clientarea/message/preview'),
  17907. async: false,
  17908. data: {token: csrfToken, content: originalContent},
  17909. dataType: 'json',
  17910. success: function (data) {
  17911. parsedContent = data;
  17912. }
  17913. });
  17914. return parsedContent.body ? parsedContent.body : '';
  17915. },
  17916. additionalButtons: [
  17917. [{
  17918. name: "groupCustom",
  17919. data: [{
  17920. name: "cmdHelp",
  17921. title: "Help",
  17922. hotkey: "Ctrl+F1",
  17923. btnClass: "btn open-modal",
  17924. icon: {
  17925. glyph: 'fas fa-question-circle',
  17926. fa: 'fas fa-question-circle',
  17927. 'fa-3': 'icon-question-sign',
  17928. 'fa-5': 'fas fa-question-circle',
  17929. },
  17930. callback: function(e) {
  17931. e.$editor.removeClass("md-fullscreen-mode");
  17932. }
  17933. }]
  17934. }]
  17935. ],
  17936. hiddenButtons: [
  17937. 'cmdImage'
  17938. ]
  17939. });
  17940. jQuery('button[data-handler="bootstrap-markdown-cmdHelp"]')
  17941. .attr('data-modal-title', markdownGuide)
  17942. .attr('href', 'submitticket.php?action=markdown');
  17943. jQuery(this).closest("form").bind({
  17944. submit: function() {
  17945. if(typeof(Storage) !== "undefined") {
  17946. localStorage.removeItem(autoSaveName);
  17947. }
  17948. }
  17949. });
  17950. });
  17951. // Email verification
  17952. var btnResendEmail = jQuery('.btn-resend-verify-email');
  17953. jQuery(btnResendEmail).click(function() {
  17954. $(this).prop('disabled', true).find('.loader').show();
  17955. WHMCS.http.jqClient.post(
  17956. jQuery(this).data('uri'),
  17957. {
  17958. 'token': csrfToken,
  17959. }).done(function(data) {
  17960. btnResendEmail.find('.loader').hide();
  17961. if (data.success) {
  17962. btnResendEmail.text(btnResendEmail.data('email-sent'));
  17963. } else {
  17964. btnResendEmail.text(btnResendEmail.data('error-msg'));
  17965. }
  17966. });
  17967. });
  17968. jQuery('#btnEmailVerificationClose').click(function(e) {
  17969. e.preventDefault();
  17970. WHMCS.http.jqClient.post(jQuery(this).data('uri'),
  17971. {
  17972. 'token': csrfToken
  17973. });
  17974. jQuery('.verification-banner.email-verification').hide();
  17975. });
  17976. jQuery('#btnUserValidationClose').click(function(e) {
  17977. e.preventDefault();
  17978. WHMCS.http.jqClient.post(jQuery(this).data('uri'),
  17979. {
  17980. 'token': csrfToken
  17981. });
  17982. jQuery('.verification-banner.user-validation').hide();
  17983. });
  17984. var ssoDropdown = jQuery('#servicesPanel').find('.list-group');
  17985. if (parseInt(ssoDropdown.css('height'), 10) < parseInt(ssoDropdown.css('max-height'), 10)) {
  17986. ssoDropdown.css('overflow', 'unset');
  17987. }
  17988. /**
  17989. * Parse the content to populate the markdown editor footer.
  17990. *
  17991. * @param {string} content
  17992. * @param {bool} auto_save
  17993. * @param {string} [saveText]
  17994. * @returns {string}
  17995. */
  17996. function parseMdeFooter(content, auto_save, saveText)
  17997. {
  17998. saveText = saveText || saving;
  17999. var pattern = /[^\s]+/g,
  18000. m = [],
  18001. word_count = 0,
  18002. line_count = 0;
  18003. if (content) {
  18004. m = content.match(pattern);
  18005. line_count = content.split(/\\r\\n|\\r|\\n/).length;
  18006. }
  18007. if (m) {
  18008. for (var i = 0; i < m.length; i++) {
  18009. if (m[i].charCodeAt(0) >= 0x4E00) {
  18010. word_count += m[i].length;
  18011. } else {
  18012. word_count += 1;
  18013. }
  18014. }
  18015. }
  18016. return '<div class="small-font">lines: ' + line_count
  18017. + '&nbsp;&nbsp;&nbsp;words: ' + word_count + ''
  18018. + (auto_save ? '&nbsp;&nbsp;&nbsp;<span class="markdown-save">' + saveText + '</span>' : '')
  18019. + '</div>';
  18020. }
  18021. /**
  18022. * Countdown the save timeout. When zero, the span will update to show saved.
  18023. */
  18024. function doCountdown()
  18025. {
  18026. if (counter >= 0) {
  18027. if (counter === 0) {
  18028. jQuery("span.markdown-save").html(saved);
  18029. }
  18030. counter--;
  18031. setTimeout(doCountdown, 1000);
  18032. }
  18033. }
  18034. // Two-Factor Activation Process Modal Handler.
  18035. var frmTwoFactorActivation = jQuery('input[name=2fasetup]').parent('form');
  18036. frmTwoFactorActivation.submit(function(e) {
  18037. e.preventDefault();
  18038. openModal(frmTwoFactorActivation.attr('action'), frmTwoFactorActivation.serialize(), 'Loading...');
  18039. });
  18040. $.fn.setInputError = function(error) {
  18041. this.closest('.form-group').addClass('has-error').find('.field-error-msg').text(error);
  18042. return this;
  18043. };
  18044. jQuery.fn.showInputError = function () {
  18045. this.closest('.form-group').addClass('has-error').find('.field-error-msg').show();
  18046. return this;
  18047. };
  18048. jQuery('#frmPayment').on('submit', function() {
  18049. var btn = jQuery('#btnSubmit');
  18050. btn.find('span').toggle();
  18051. btn.prop('disabled', true).addClass('disabled');
  18052. });
  18053. // SSL Manage Action Button.
  18054. jQuery('.btn-resend-approver-email').click(function () {
  18055. WHMCS.http.jqClient.post(
  18056. jQuery(this).data('url'),
  18057. {
  18058. addonId: jQuery(this).data('addonid'),
  18059. serviceId: jQuery(this).data('serviceid'),
  18060. },
  18061. function(data) {
  18062. if (data.success === true) {
  18063. jQuery('.alert-table-ssl-manage').addClass('alert-success').text('Approver Email Resent').show();
  18064. } else {
  18065. jQuery('.alert-table-ssl-manage').addClass('alert-danger').text('Error: ' + data.message).show();
  18066. }
  18067. }
  18068. );
  18069. });
  18070. // Domain Pricing Table Filters
  18071. jQuery(".tld-filters a").click(function(e) {
  18072. e.preventDefault();
  18073. var noTlds = jQuery('.tld-row.no-tlds');
  18074. if (jQuery(this).hasClass('badge-success')) {
  18075. jQuery(this).removeClass('badge-success');
  18076. } else {
  18077. jQuery(this).addClass('badge-success');
  18078. }
  18079. if (noTlds.is(':visible')) {
  18080. noTlds.hide();
  18081. }
  18082. jQuery('.tld-row').removeClass('filtered-row');
  18083. jQuery('.tld-filters a.badge-success').each(function(index) {
  18084. var filterValue = jQuery(this).data('category');
  18085. jQuery('.tld-row[data-category*="' + filterValue + '"]').addClass('filtered-row');
  18086. });
  18087. jQuery(".filtered-row:even").removeClass('highlighted');
  18088. jQuery(".filtered-row:odd").addClass('highlighted');
  18089. var rowsToHide = jQuery('.tld-row:not(".filtered-row")');
  18090. rowsToHide.fadeOut('fast');
  18091. rowsToHide.promise().done(function () {
  18092. if (jQuery('.filtered-row').length === 0) {
  18093. noTlds.show();
  18094. } else {
  18095. jQuery('.tld-row.filtered-row').show();
  18096. }
  18097. });
  18098. });
  18099. jQuery(".filtered-row:even").removeClass('highlighted');
  18100. jQuery(".filtered-row:odd").addClass('highlighted');
  18101. // DataTable data-driven auto object registration
  18102. WHMCS.ui.dataTable.register();
  18103. WHMCS.ui.jsonForm.initAll();
  18104. jQuery(document).on('click', '#btnTicketAttachmentsAdd', function() {
  18105. jQuery('#fileUploadsContainer').append(jQuery('.file-upload').html());
  18106. });
  18107. jQuery(document).on('change', '.custom-file-input', function() {
  18108. var fileName = jQuery(this).val().split('\\').pop();
  18109. jQuery(this).siblings('.custom-file-label').text(fileName);
  18110. });
  18111. jQuery('#frmReply').submit(function(e) {
  18112. jQuery('#frmReply').find('input[type="submit"]').addClass('disabled').prop('disabled', true);
  18113. });
  18114. jQuery('#frmDomainContactModification').on('submit', function(){
  18115. if (!allowSubmit) {
  18116. var changed = false;
  18117. jQuery('.irtp-field').each(function() {
  18118. var value = jQuery(this).val(),
  18119. originalValue = jQuery(this).data('original-value');
  18120. if (value !== originalValue) {
  18121. changed = true;
  18122. }
  18123. });
  18124. if (changed) {
  18125. jQuery('#modalIRTPConfirmation').modal('show');
  18126. return false;
  18127. }
  18128. }
  18129. return true;
  18130. });
  18131. jQuery('.ssl-state.ssl-sync').each(function () {
  18132. var self = jQuery(this),
  18133. type = getSslAttribute(self, 'type'),
  18134. domain = getSslAttribute(self, 'domain');
  18135. WHMCS.http.jqClient.post(
  18136. WHMCS.utils.getRouteUrl('/domain/ssl-check'),
  18137. {
  18138. 'type': type,
  18139. 'domain': domain,
  18140. 'token': csrfToken
  18141. },
  18142. function (data) {
  18143. if (data.invalid) {
  18144. self.hide();
  18145. } else {
  18146. var width = '',
  18147. statusDisplayLabel = '';
  18148. if (self.attr('width')) {
  18149. width = ' width="' + self.attr('width') + '"';
  18150. }
  18151. if (self.data('showlabel')) {
  18152. statusDisplayLabel = ' ' + data.statusDisplayLabel;
  18153. }
  18154. self.replaceWith(
  18155. '<img src="' + data.image + '" data-toggle="tooltip" alt="' + data.tooltip + '" title="' + data.tooltip + '" class="' + data.class + '"' + width + '>'
  18156. );
  18157. if (data.ssl.status === 'active') {
  18158. jQuery('#ssl-startdate').text(data.ssl.startDate);
  18159. jQuery('#ssl-expirydate').text(data.ssl.expiryDate);
  18160. jQuery('#ssl-issuer').text(data.ssl.issuer);
  18161. } else {
  18162. jQuery('#ssl-startdate').parent('div').hide();
  18163. jQuery('#ssl-expirydate').parent('div').hide();
  18164. jQuery('#ssl-issuer').parent('div').hide();
  18165. }
  18166. jQuery('#statusDisplayLabel').text(statusDisplayLabel);
  18167. }
  18168. }
  18169. );
  18170. });
  18171. jQuery(document).on('click', '.ssl-state.ssl-inactive', function(e) {
  18172. e.preventDefault();
  18173. window.location.href = WHMCS.utils.getRouteUrl('/ssl-purchase');
  18174. });
  18175. WHMCS.recaptcha.register();
  18176. var dynamicRecaptchaContainer = jQuery('#divDynamicRecaptcha');
  18177. var homepageHasRecaptcha = jQuery(dynamicRecaptchaContainer).length > 0;
  18178. var homepageHasInvisibleRecaptcha = homepageHasRecaptcha && jQuery(dynamicRecaptchaContainer).data('size') === 'invisible';
  18179. var frmDomainHomepage = jQuery('#frmDomainHomepage');
  18180. jQuery(frmDomainHomepage).find('button[data-domain-action="transfer"]').click(function () {
  18181. jQuery(frmDomainHomepage).find('input[name="transfer"]').val('1');
  18182. });
  18183. if (homepageHasRecaptcha && !homepageHasInvisibleRecaptcha) {
  18184. jQuery('section#home-banner').addClass('with-recaptcha');
  18185. }
  18186. if (jQuery('.domainchecker-homepage-captcha').length && !homepageHasInvisibleRecaptcha) {
  18187. // invisible reCaptcha doesn't play well with onsubmit() handlers on all submissions following a prevented one
  18188. jQuery(frmDomainHomepage).submit(function (e) {
  18189. var inputDomain = jQuery(frmDomainHomepage).find('input[name="domain"]'),
  18190. reCaptchaContainer = jQuery('#divDynamicRecaptcha'),
  18191. reCaptcha = jQuery('#g-recaptcha-response'),
  18192. captcha = jQuery('#inputCaptcha');
  18193. if (reCaptcha.length && !reCaptcha.val()) {
  18194. reCaptchaContainer.tooltip('show');
  18195. e.preventDefault();
  18196. return;
  18197. }
  18198. if (captcha.length && !captcha.val()) {
  18199. captcha.tooltip('show');
  18200. e.preventDefault();
  18201. }
  18202. });
  18203. }
  18204. $('.icheck-button').iCheck({
  18205. inheritID: true,
  18206. checkboxClass: 'icheckbox_square-blue',
  18207. radioClass: 'iradio_square-blue',
  18208. increaseArea: '20%'
  18209. });
  18210. jQuery('#inputNoStore').on('switchChange.bootstrapSwitch', function(event, state) {
  18211. var descContainer = jQuery('#inputDescription');
  18212. if (!state) {
  18213. descContainer.prop('disabled', true).addClass('disabled');
  18214. }
  18215. if (state) {
  18216. descContainer.removeClass('disabled').prop('disabled', false);
  18217. }
  18218. });
  18219. jQuery(document).on('click', '#btnConfirmModalConfirmBtn', function () {
  18220. var confirmButton = jQuery(this),
  18221. confirmationModal = confirmButton.closest('div.modal'),
  18222. targetUrl = confirmButton.data('target-url'),
  18223. dataTable = confirmButton.closest('table.dataTable[data-on-draw-rebind-confirmation-modal="true"]');
  18224. WHMCS.http.jqClient.jsonPost(
  18225. {
  18226. url: targetUrl,
  18227. data: {
  18228. token: csrfToken
  18229. },
  18230. success: function(data) {
  18231. if (data.status === 'success' || data.status === 'okay') {
  18232. if (dataTable.length > 0) {
  18233. dataTable.DataTable().ajax.reload();
  18234. }
  18235. }
  18236. }
  18237. }
  18238. );
  18239. confirmationModal.modal('toggle');
  18240. });
  18241. hideOverlay();
  18242. jQuery('input[name="approval_method"]').on('ifChecked', function(event) {
  18243. var fileMethod = $('#containerApprovalMethodFile'),
  18244. emailMethod = $('#containerApprovalMethodEmail'),
  18245. dnsMethod = $('#containerApprovalMethodDns');
  18246. if (jQuery(this).attr('value') == 'file') {
  18247. fileMethod.show();
  18248. dnsMethod.hide();
  18249. emailMethod.hide();
  18250. } else if (jQuery(this).attr('value') == 'dns-txt-token') {
  18251. dnsMethod.show();
  18252. fileMethod.hide();
  18253. emailMethod.hide();
  18254. } else {
  18255. fileMethod.hide();
  18256. dnsMethod.hide();
  18257. emailMethod.show();
  18258. }
  18259. });
  18260. (function () {
  18261. jQuery('.div-service-status').css(
  18262. 'width',
  18263. (jQuery('.div-service-status .label-placeholder').outerWidth() + 5)
  18264. );
  18265. jQuery('div[menuitemname="Active Products/Services"] .list-group-item:visible')
  18266. .last()
  18267. .css('border-bottom', '1px solid #ddd');
  18268. }());
  18269. jQuery('div[menuitemname="Active Products/Services"] .btn-view-more').on('click', function(event) {
  18270. var hiddenItems = jQuery('div[menuitemname="Active Products/Services"] .list-group-item:hidden');
  18271. var itemAmount = 8;
  18272. event.preventDefault();
  18273. hiddenItems.slice(0,itemAmount).css('display', 'block');
  18274. if ((hiddenItems.length - itemAmount) <= 0) {
  18275. jQuery(event.target).addClass('disabled').attr("aria-disabled", true);
  18276. }
  18277. jQuery('div[menuitemname="Active Products/Services"] .list-group-item:visible')
  18278. .css('border-bottom', '')
  18279. .last()
  18280. .css('border-bottom', '1px solid #ddd');
  18281. })
  18282. jQuery('div[menuitemname="Service Details Actions"] a[data-identifier][data-serviceid][data-active="1"]').on('click', function(event) {
  18283. return customActionAjaxCall(event, jQuery(event.target).closest('a'));
  18284. });
  18285. jQuery('.div-service-item').on('click', function (event) {
  18286. var element = jQuery(event.target);
  18287. if (element.is('.dropdown-toggle, .dropdown-menu')) {
  18288. return true;
  18289. }
  18290. if (element.hasClass('btn-custom-action')) {
  18291. return customActionAjaxCall(event, element);
  18292. }
  18293. window.location.href = element.closest('.div-service-item').data('href');
  18294. return false;
  18295. });
  18296. });
  18297. /**
  18298. * Control disabled/enabled state of elements by class name.
  18299. *
  18300. * @param {string} className Common element class name.
  18301. * @param {bool} disabledState Whether the elements should be disabled or not.
  18302. */
  18303. function disableFields(className, disabledState) {
  18304. if (className[0] !== '.') {
  18305. className = '.' + className;
  18306. }
  18307. var elements = jQuery(className);
  18308. elements.prop('disabled', disabledState);
  18309. if (disabledState) {
  18310. elements.addClass('disabled');
  18311. } else {
  18312. elements.removeClass('disabled');
  18313. }
  18314. }
  18315. /**
  18316. * Check all checkboxes with a given class.
  18317. *
  18318. * @param {string} className Common class name.
  18319. * @param {Element} masterControl Parent checkbox to which the other checkboxes should mirror.
  18320. */
  18321. function checkAll(className, masterControl) {
  18322. if (className[0] !== '.') {
  18323. className = '.' + className;
  18324. }
  18325. // In jQuery, if you set the checked attribute directly, the dom
  18326. // element is changed, but browsers don't show the check box as
  18327. // checked. Using the click event will properly display.
  18328. jQuery(className).removeAttr('checked');
  18329. if(jQuery(masterControl).is(":checked")) {
  18330. jQuery(className).click();
  18331. }
  18332. }
  18333. /**
  18334. * Redirect on click if an element is not a button or link.
  18335. *
  18336. * Where table rows are clickable, we only want to redirect if the row
  18337. * itself is clicked. If a button or link within the row is clicked,
  18338. * the event tied to that object should be executed. This function
  18339. * stops the standard JS event bubbling required to make that happen.
  18340. *
  18341. * @param {object} clickEvent jQuery click event
  18342. * @param {string} target Redirect location
  18343. * @param {bool} newWindow Open link in new window
  18344. */
  18345. function clickableSafeRedirect(clickEvent, target, newWindow) {
  18346. var eventSource = clickEvent.target.tagName.toLowerCase();
  18347. var eventParent = clickEvent.target.parentNode.tagName.toLowerCase();
  18348. var eventTable = clickEvent.target.parentNode.parentNode.parentNode;
  18349. if (jQuery(eventTable).hasClass('collapsed')) {
  18350. // This is a mobile device sized display, and datatables has triggered folding
  18351. return false;
  18352. }
  18353. if (eventSource === 'i' && jQuery(clickEvent.target).hasClass('ssl-required')) {
  18354. return false;
  18355. }
  18356. if(eventSource !== 'button' && eventSource !== 'a') {
  18357. if(eventParent !== 'button' && eventParent !== 'a') {
  18358. if (newWindow) {
  18359. window.open(target);
  18360. } else {
  18361. window.location.href = target;
  18362. }
  18363. }
  18364. }
  18365. }
  18366. /**
  18367. * Open a centered popup window.
  18368. *
  18369. * @param {string} addr The URL to navigate to
  18370. * @param {string} popname The name to assign the window
  18371. * @param {number} w The width
  18372. * @param {number} h The height
  18373. * @param {string} features Any additional settings to apply
  18374. */
  18375. function popupWindow(addr, popname, w, h, features) {
  18376. var winl = (screen.width-w) / 2,
  18377. wint = (screen.height-h) / 2,
  18378. win;
  18379. if (winl < 0) {
  18380. winl = 0;
  18381. }
  18382. if (wint < 0) {
  18383. wint = 0;
  18384. }
  18385. var settings = 'height=' + h + ',';
  18386. settings += 'width=' + w + ',';
  18387. settings += 'top=' + wint + ',';
  18388. settings += 'left=' + winl + ',';
  18389. settings += features;
  18390. win = window.open(addr, popname, settings);
  18391. win.window.focus();
  18392. }
  18393. /**
  18394. * Navigate to a page on dropdown change.
  18395. *
  18396. * This is implemented onblur() for a dropdown. When the dropdown
  18397. * changes state, the value is pulled and the browser navigated to
  18398. * the selected page.
  18399. *
  18400. * @param {Element} select The dropdown triggering the event
  18401. */
  18402. function selectChangeNavigate(select) {
  18403. window.location.href = $(select).val();
  18404. }
  18405. /**
  18406. * Fetch load and uptime for a given server.
  18407. *
  18408. * @param {number} num Server Id
  18409. */
  18410. function getStats(num) {
  18411. WHMCS.http.jqClient.post('serverstatus.php', 'getstats=1&num=' + num, function(data) {
  18412. jQuery("#load"+num).html(data.load);
  18413. jQuery("#uptime"+num).html(data.uptime);
  18414. },'json');
  18415. }
  18416. /**
  18417. * Determine status of a given port for a given server.
  18418. *
  18419. * @param {number} num Server Id
  18420. * @param {number} port Port Number
  18421. */
  18422. function checkPort(num, port) {
  18423. WHMCS.http.jqClient.post('serverstatus.php', 'ping=1&num=' + num + '&port=' + port, function(data) {
  18424. jQuery("#port" + port + "_" + num).html(data);
  18425. });
  18426. }
  18427. /**
  18428. * Fetch automated knowledgebase suggestions for ticket content.
  18429. */
  18430. var currentcheckcontent,
  18431. lastcheckcontent;
  18432. function getticketsuggestions() {
  18433. currentcheckcontent = jQuery("#message").val();
  18434. if (currentcheckcontent !== lastcheckcontent && currentcheckcontent !== "") {
  18435. WHMCS.http.jqClient.post("submitticket.php", { action: "getkbarticles", text: currentcheckcontent },
  18436. function(data){
  18437. if (data) {
  18438. jQuery("#searchresults").html(data).slideDown();
  18439. }
  18440. });
  18441. lastcheckcontent = currentcheckcontent;
  18442. }
  18443. setTimeout('getticketsuggestions();', 3000);
  18444. }
  18445. /**
  18446. * Update custom fields upon department change.
  18447. *
  18448. * @param {Element} input The department selector dropdown object
  18449. */
  18450. function refreshCustomFields(input) {
  18451. jQuery("#customFieldsContainer").load(
  18452. "submitticket.php",
  18453. { action: "getcustomfields", deptid: $(input).val() }
  18454. );
  18455. }
  18456. /**
  18457. * Submit the first form that exists within a given container.
  18458. *
  18459. * @param {string} containerId The ID name of the container
  18460. */
  18461. function autoSubmitFormByContainer(containerId) {
  18462. if (typeof noAutoSubmit === "undefined" || noAutoSubmit === false) {
  18463. jQuery("#" + containerId).find("form:first").submit();
  18464. }
  18465. }
  18466. /**
  18467. * Submit default whois info and disable custom fields.
  18468. *
  18469. * @param {string} regType The contact registration type
  18470. */
  18471. function useDefaultWhois(regType) {
  18472. jQuery("." + regType.substr(0, regType.length - 1) + "customwhois").attr("disabled", true);
  18473. jQuery("." + regType.substr(0, regType.length - 1) + "defaultwhois").attr("disabled", false);
  18474. jQuery('#' + regType.substr(0, regType.length - 1) + '1').attr("checked", "checked");
  18475. }
  18476. /**
  18477. * Submit custom fields and disable default whois info.
  18478. *
  18479. * @param {string} regType The contact registration type
  18480. */
  18481. function useCustomWhois(regType) {
  18482. jQuery("." + regType.substr(0, regType.length - 1) + "customwhois").attr("disabled", false);
  18483. jQuery("." + regType.substr(0, regType.length - 1) + "defaultwhois").attr("disabled", true);
  18484. jQuery('#' + regType.substr(0, regType.length - 1) + '2').attr("checked", "checked");
  18485. }
  18486. function showNewBillingAddressFields() {
  18487. jQuery('#newBillingAddress').parent('div').slideDown();
  18488. }
  18489. function hideNewBillingAddressFields() {
  18490. jQuery('#newBillingAddress').parent('div').slideUp();
  18491. }
  18492. /**
  18493. * Show new credit card input fields.
  18494. */
  18495. function showNewCardInputFields() {
  18496. var ccDetails = jQuery('.cc-details'),
  18497. ccNumber = jQuery('#inputCardNumber'),
  18498. billAddress = jQuery('#billingAddressChoice'),
  18499. container;
  18500. container = ccDetails.parent('div');
  18501. if (container.not(':visible')) {
  18502. container.show();
  18503. }
  18504. jQuery('.cc-details').slideDown();
  18505. ccNumber.focus();
  18506. container = billAddress.parent('div');
  18507. if (container.not(':visible')) {
  18508. container.show();
  18509. }
  18510. billAddress.slideDown()
  18511. .find('input[name="billingcontact"]')
  18512. .first()
  18513. .iCheck('check');
  18514. }
  18515. /**
  18516. * Show new bank account input fields.
  18517. */
  18518. function showNewAccountInputFields() {
  18519. var bankDetails = jQuery('.bank-details').parent('div');
  18520. if (bankDetails.not(':visible')) {
  18521. bankDetails.slideDown();
  18522. }
  18523. jQuery("#billingAddressChoice")
  18524. .parent('div')
  18525. .slideDown()
  18526. .find('input[name="billingcontact"]')
  18527. .first()
  18528. .iCheck('check');
  18529. }
  18530. /**
  18531. * Hide new credit card input fields.
  18532. */
  18533. function hideNewCardInputFields() {
  18534. hideNewBillingAddressFields();
  18535. jQuery(".cc-details").slideUp();
  18536. jQuery("#billingAddressChoice").slideUp();
  18537. var contactId = jQuery('input[name="ccinfo"]:checked').data('billing-contact-id');
  18538. if (contactId != undefined) {
  18539. jQuery('#billingAddressChoice label.billing-contact-' + contactId)
  18540. .iCheck('check');
  18541. }
  18542. jQuery('#inputCardCvv').focus();
  18543. }
  18544. /**
  18545. * Hide new bank account input fields.
  18546. */
  18547. function hideNewAccountInputFields() {
  18548. hideNewBillingAddressFields();
  18549. jQuery(".bank-details").parent('div').slideUp();
  18550. jQuery("#billingAddressChoice").parent('div').slideUp();
  18551. var selectedAccount = jQuery('input[name="paymethod"]:checked'),
  18552. selectedContactId = jQuery(selectedAccount).data('billing-contact-id'),
  18553. selectedContactData = jQuery('.billing-contact-info[data-billing-contact-id="' + selectedContactId + '"]');
  18554. if (selectedContactData.length) {
  18555. jQuery('.billing-contact-info').hide();
  18556. jQuery(selectedContactData).show();
  18557. }
  18558. }
  18559. /**
  18560. * Get automatic knowledgebase suggestions for support ticket message.
  18561. */
  18562. var lastTicketMsg;
  18563. function getTicketSuggestions() {
  18564. var userMsg = jQuery("#inputMessage").val();
  18565. if (userMsg !== lastTicketMsg && userMsg !== '') {
  18566. WHMCS.http.jqClient.post("submitticket.php", { action: "getkbarticles", text: userMsg },
  18567. function (data) {
  18568. var suggestions = jQuery("#autoAnswerSuggestions");
  18569. if (data) {
  18570. suggestions.html(data);
  18571. if (suggestions.not(":visible")) {
  18572. suggestions.slideDown();
  18573. }
  18574. }
  18575. });
  18576. lastTicketMsg = userMsg;
  18577. }
  18578. setTimeout('getTicketSuggestions()', 3000);
  18579. }
  18580. /**
  18581. * Smooth scroll to named element.
  18582. */
  18583. function smoothScroll(element) {
  18584. $('html, body').animate({
  18585. scrollTop: $(element).offset().top
  18586. }, 500);
  18587. }
  18588. var allowSubmit = false;
  18589. function irtpSubmit() {
  18590. allowSubmit = true;
  18591. var optOut = 0,
  18592. optOutCheckbox = jQuery('#modalIrtpOptOut'),
  18593. optOutReason = jQuery('#modalReason'),
  18594. formOptOut = jQuery('#irtpOptOut'),
  18595. formOptOutReason = jQuery('#irtpOptOutReason');
  18596. if (optOutCheckbox.is(':checked')) {
  18597. optOut = 1;
  18598. }
  18599. formOptOut.val(optOut);
  18600. formOptOutReason.val(optOutReason.val());
  18601. jQuery('#frmDomainContactModification').submit();
  18602. }
  18603. function showOverlay(msg) {
  18604. jQuery('#fullpage-overlay .msg').html(msg);
  18605. jQuery('#fullpage-overlay').show();
  18606. }
  18607. function hideOverlay() {
  18608. jQuery('#fullpage-overlay').hide();
  18609. }
  18610. function getSslAttribute(element, attribute) {
  18611. if (element.data(attribute)) {
  18612. return element.data(attribute);
  18613. }
  18614. return element.parent('td').data(attribute);
  18615. }
  18616. function removeRetweets() {
  18617. jQuery('#twitter-widget-0')
  18618. .contents()
  18619. .find('.timeline-Tweet--isRetweet')
  18620. .parent('li')
  18621. .remove();
  18622. }
  18623. function addTwitterWidgetObserverWhenNodeAvailable() {
  18624. if (elementsWaitTimeout) {
  18625. clearTimeout(elementsWaitTimeout);
  18626. }
  18627. var targetTwitterWidget = document.getElementById('twitter-widget-0');
  18628. if (!targetTwitterWidget) {
  18629. elementsWaitTimeout = window.setTimeout(addTwitterWidgetObserverWhenNodeAvailable, 500);
  18630. return;
  18631. }
  18632. var targetTimelineTweets = targetTwitterWidget
  18633. .contentWindow
  18634. .document
  18635. .getElementsByClassName('timeline-TweetList')[0];
  18636. if (!targetTimelineTweets) {
  18637. elementsWaitTimeout = window.setTimeout(addTwitterWidgetObserverWhenNodeAvailable, 500);
  18638. return;
  18639. }
  18640. jQuery('#twitter-widget-0')
  18641. .contents()
  18642. .find('head')
  18643. .append("<style>.timeline-Tweet-text { font-size: 18px !important; line-height: 25px !important; margin-bottom: 0px !important; }</style>");
  18644. removeRetweets();
  18645. observerTwitterWidget.observe(targetTimelineTweets, observerConfig);
  18646. }
  18647. function openValidationSubmitModal(caller)
  18648. {
  18649. var validationSubmitModal = jQuery('#validationSubmitModal');
  18650. validationSubmitModal.find('.modal-body iframe').attr('src', caller.dataset.url);
  18651. validationSubmitModal.modal('show');
  18652. }
  18653. function completeValidationComClientWorkflow()
  18654. {
  18655. var submitDocsRequestBanner = jQuery('.user-validation'),
  18656. secondarySidebarStatus = jQuery('.validation-status-label'),
  18657. submitDiv = jQuery('.validation-submit-div'),
  18658. redirectUser = true;
  18659. $('#validationSubmitModal').modal('hide');
  18660. if (submitDocsRequestBanner.length !== 0) {
  18661. submitDocsRequestBanner.slideUp();
  18662. redirectUser = false;
  18663. }
  18664. if (secondarySidebarStatus.length !== 0) {
  18665. var submitString = submitDiv.find('a').data('submitted-string');
  18666. secondarySidebarStatus.text(submitString).removeClass('label-default').addClass('label-warning');
  18667. submitDiv.hide();
  18668. redirectUser = false;
  18669. }
  18670. if (redirectUser) {
  18671. window.location.href = WHMCS.utils.autoDetermineBaseUrl();
  18672. }
  18673. return false;
  18674. }
  18675. var autoCollapse = function (menu, maxHeight) {
  18676. var continueLoop = true,
  18677. nav = jQuery(menu),
  18678. navHeight = nav.innerHeight();
  18679. if (navHeight >= maxHeight) {
  18680. jQuery(menu + ' .collapsable-dropdown').removeClass('d-none');
  18681. jQuery(".navbar-nav").removeClass('w-auto').addClass("w-100");
  18682. while (navHeight > maxHeight && continueLoop) {
  18683. // add child to dropdown
  18684. var children = nav.children(menu + ' li:not(:last-child):not(".no-collapse")'),
  18685. count = children.length;
  18686. if (!count) {
  18687. continueLoop = false;
  18688. } else {
  18689. children.data('original-classes', children.attr('class'));
  18690. var child = jQuery(children[count - 1]);
  18691. child.removeClass().addClass('dropdown-item');
  18692. child.prependTo(menu + ' .collapsable-dropdown-menu');
  18693. }
  18694. navHeight = nav.innerHeight();
  18695. }
  18696. jQuery(".navbar-nav").addClass("w-auto").removeClass('w-100');
  18697. } else {
  18698. var collapsed = jQuery(menu + ' .collapsable-dropdown-menu').children(menu + ' li');
  18699. if (collapsed.length === 0) {
  18700. jQuery(menu + ' .collapsable-dropdown').addClass('d-none');
  18701. }
  18702. while (navHeight < maxHeight && (nav.children(menu + ' li').length > 0) && collapsed.length > 0) {
  18703. // remove child from dropdown
  18704. collapsed = jQuery(menu + ' .collapsable-dropdown-menu').children('li');
  18705. var child = jQuery(collapsed[0]);
  18706. child.removeClass().addClass(child.data('original-classes'));
  18707. child.insertBefore(nav.children(menu + ' li:last-child'));
  18708. navHeight = nav.innerHeight();
  18709. }
  18710. if (navHeight > maxHeight) {
  18711. autoCollapse(menu, maxHeight);
  18712. }
  18713. }
  18714. }
  18715. /**
  18716. * Perform the AjaxCall for a CustomAction.
  18717. *
  18718. * @param event
  18719. * @param element
  18720. * @returns {boolean}
  18721. */
  18722. function customActionAjaxCall(event, element) {
  18723. var loadingIcon = jQuery('.loading', element);
  18724. var standardIcon = jQuery('.sidebar-menu-item-icon', element);
  18725. event.stopPropagation();
  18726. if (!element.data('active')) {
  18727. return false;
  18728. }
  18729. element.attr('disabled', 'disabled').addClass('disabled');
  18730. loadingIcon.show();
  18731. standardIcon.hide();
  18732. const redirectFn = ((jQuery(element).data('ca-target') === '_self') || (jQuery(element).attr('target') === '_self'))
  18733. ? function(url) { window.location.href = url; }
  18734. : window.open;
  18735. WHMCS.http.jqClient.jsonPost({
  18736. url: WHMCS.utils.getRouteUrl(
  18737. '/clientarea/service/' + element.data('serviceid') + '/custom-action/' + element.data('identifier')
  18738. ),
  18739. data: {
  18740. 'token': csrfToken
  18741. },
  18742. success: function(data) {
  18743. if (data.success) {
  18744. redirectFn(data.redirectTo);
  18745. } else {
  18746. redirectFn('clientarea.php?action=productdetails&id=' + element.data('serviceid') + '&customaction_error=1');
  18747. }
  18748. },
  18749. fail: function () {
  18750. redirectFn('clientarea.php?action=productdetails&id=' + element.data('serviceid') + '&customaction_ajax_error=1');
  18751. },
  18752. error: function () {
  18753. redirectFn('clientarea.php?action=productdetails&id=' + element.data('serviceid') + '&customaction_ajax_error=1');
  18754. },
  18755. always: function() {
  18756. loadingIcon.hide();
  18757. standardIcon.show();
  18758. element.removeAttr('disabled').removeClass('disabled');
  18759. if (element.hasClass('dropdown-item')) {
  18760. element.closest('.dropdown-menu').removeClass('show');
  18761. }
  18762. },
  18763. });
  18764. return true;
  18765. }
  18766. /*!
  18767. * WHMCS Ajax Driven Modal Framework
  18768. *
  18769. * @copyright Copyright (c) WHMCS Limited 2005-2021
  18770. * @license https://www.whmcs.com/license/ WHMCS Eula
  18771. */
  18772. var ajaxModalSubmitEvents = [],
  18773. ajaxModalPostSubmitEvents = [];
  18774. jQuery(document).ready(function(){
  18775. jQuery(document).on('click', '.open-modal', function(e) {
  18776. e.preventDefault();
  18777. var url = jQuery(this).attr('href'),
  18778. modalSize = jQuery(this).data('modal-size'),
  18779. modalClass = jQuery(this).data('modal-class'),
  18780. modalTitle = jQuery(this).data('modal-title'),
  18781. submitId = jQuery(this).data('btn-submit-id'),
  18782. submitLabel = jQuery(this).data('btn-submit-label'),
  18783. submitColor = jQuery(this).data('btn-submit-color'),
  18784. hideClose = jQuery(this).data('btn-close-hide'),
  18785. disabled = jQuery(this).attr('disabled'),
  18786. successDataTable = jQuery(this).data('datatable-reload-success');
  18787. var postData = '';
  18788. if (csrfToken) {
  18789. postData = {token: csrfToken};
  18790. }
  18791. if (!disabled) {
  18792. openModal(url, postData, modalTitle, modalSize, modalClass, submitLabel, submitId, submitColor, hideClose, successDataTable);
  18793. }
  18794. });
  18795. // define modal close reset action
  18796. jQuery('#modalAjax').on('hidden.bs.modal', function (e) {
  18797. if (jQuery(this).hasClass('modal-feature-highlights')) {
  18798. var dismissForVersion = jQuery('#cbFeatureHighlightsDismissForVersion').is(':checked');
  18799. WHMCS.http.jqClient.post(
  18800. 'whatsnew.php',
  18801. {
  18802. dismiss: "1",
  18803. until_next_update: dismissForVersion ? '1' : '0',
  18804. token: csrfToken
  18805. }
  18806. );
  18807. }
  18808. jQuery('#modalAjax').find('.modal-body').empty();
  18809. jQuery('#modalAjax').children('div.modal-dialog').removeClass('modal-lg');
  18810. jQuery('#modalAjax').removeClass().addClass('modal whmcs-modal fade');
  18811. jQuery('#modalAjax .modal-title').html('Title');
  18812. jQuery('#modalAjax .modal-submit').html('Submit')
  18813. .removeClass()
  18814. .addClass('btn btn-primary modal-submit')
  18815. .removeAttr('id')
  18816. .removeAttr('disabled');
  18817. jQuery('#modalAjax .loader').show();
  18818. });
  18819. });
  18820. function openModal(url, postData, modalTitle, modalSize, modalClass, submitLabel, submitId, submitColor, hideClose, successDataTable) {
  18821. //set the text of the modal title
  18822. jQuery('#modalAjax .modal-title').html(modalTitle);
  18823. // set the modal size via a class attribute
  18824. if (modalSize) {
  18825. jQuery('#modalAjax').children('div[class="modal-dialog"]').addClass(modalSize);
  18826. }
  18827. // set the modal class
  18828. if (modalClass) {
  18829. jQuery('#modalAjax').addClass(modalClass);
  18830. }
  18831. // set the text of the submit button
  18832. if(!submitLabel){
  18833. jQuery('#modalAjax .modal-submit').hide();
  18834. } else {
  18835. jQuery('#modalAjax .modal-submit').show().html(submitLabel);
  18836. // set the button id so we can target the click function of it.
  18837. if (submitId) {
  18838. jQuery('#modalAjax .modal-submit').attr('id', submitId);
  18839. }
  18840. }
  18841. if (hideClose) {
  18842. jQuery('#modalAjaxClose').hide();
  18843. }
  18844. if (submitColor) {
  18845. jQuery('#modalAjax .modal-submit').removeClass('btn-primary')
  18846. .addClass('btn-' + submitColor);
  18847. }
  18848. jQuery('#modalAjax .modal-body').html('');
  18849. jQuery('#modalSkip').hide();
  18850. disableSubmit();
  18851. // show modal
  18852. jQuery('#modalAjax').modal({
  18853. show: true,
  18854. keyboard: true,
  18855. backdrop: jQuery('#modalAjax').hasClass('static') ? 'static' : true
  18856. });
  18857. // fetch modal content
  18858. WHMCS.http.jqClient.post(url, postData, function(data) {
  18859. updateAjaxModal(data);
  18860. }, 'json').fail(function() {
  18861. jQuery('#modalAjax .modal-body').html('An error occurred while communicating with the server. Please try again.');
  18862. jQuery('#modalAjax .loader').fadeOut();
  18863. }).always(function () {
  18864. var modalForm = jQuery('#modalAjax').find('form');
  18865. // If a submitId is present, then we're working with a form and need to override the default event
  18866. if (submitId) {
  18867. modalForm.submit(function (event) {
  18868. submitIdAjaxModalClickEvent();
  18869. return false;
  18870. });
  18871. }
  18872. if (successDataTable) {
  18873. modalForm.data('successDataTable', successDataTable);
  18874. }
  18875. // Since the content is dynamically fetched, we have to check for the elements we want here too
  18876. var inputs = jQuery(modalForm).find('input:not(input[type=checkbox],input[type=radio],input[type=hidden])');
  18877. if (inputs.length > 0) {
  18878. jQuery(inputs).first().focus();
  18879. }
  18880. });
  18881. //define modal submit button click
  18882. if (submitId) {
  18883. /**
  18884. * Reloading ajax modal multiple times on the same page can add
  18885. * multiple "on" click events which submits the same form over
  18886. * and over.
  18887. * Remove the on click event with "off" to avoid multiple growl
  18888. * and save events being run.
  18889. *
  18890. * @see http://api.jquery.com/off/
  18891. */
  18892. var submitButton = jQuery('#' + submitId);
  18893. submitButton.off('click');
  18894. submitButton.on('click', submitIdAjaxModalClickEvent);
  18895. }
  18896. }
  18897. function submitIdAjaxModalClickEvent ()
  18898. {
  18899. var canContinue = true,
  18900. loader = jQuery('#modalAjax .loader');
  18901. disableSubmit();
  18902. loader.show();
  18903. if (ajaxModalSubmitEvents.length) {
  18904. jQuery.each(ajaxModalSubmitEvents, function (index, value) {
  18905. var fn = window[value];
  18906. if (canContinue && typeof fn === 'function') {
  18907. canContinue = fn();
  18908. }
  18909. });
  18910. }
  18911. if (!canContinue) {
  18912. enableSubmit();
  18913. loader.hide();
  18914. return;
  18915. }
  18916. var modalForm = jQuery('#modalAjax').find('form');
  18917. var modalBody = jQuery('#modalAjax .modal-body');
  18918. var modalErrorContainer = jQuery(modalBody).find('.admin-modal-error');
  18919. jQuery(modalErrorContainer).slideUp();
  18920. var modalPost = WHMCS.http.jqClient.post(
  18921. modalForm.attr('action'),
  18922. modalForm.serialize(),
  18923. function(data) {
  18924. if (modalForm.data('successDataTable')) {
  18925. data.successDataTable = modalForm.data('successDataTable');
  18926. }
  18927. /**
  18928. * When actions should occur before the ajax modal is updated
  18929. * that do not fall into the standard actions.
  18930. * Calling code (ie the function defined in fn) should validate
  18931. * that the ajax modal being updated is the one that the code should
  18932. * run for, as there is potential for multiple ajax modals on the
  18933. * same page.
  18934. */
  18935. if (ajaxModalPostSubmitEvents.length) {
  18936. jQuery.each(ajaxModalPostSubmitEvents, function (index, value) {
  18937. var fn = window[value];
  18938. if (typeof fn === 'function') {
  18939. fn(data, modalForm);
  18940. }
  18941. });
  18942. }
  18943. updateAjaxModal(data);
  18944. },
  18945. 'json'
  18946. ).fail(function(xhr) {
  18947. var data = xhr.responseJSON;
  18948. var genericErrorMsg = 'An error occurred while communicating with the server. Please try again.';
  18949. if (data && data.data) {
  18950. data = data.data;
  18951. if (data.errorMsg) {
  18952. if (modalErrorContainer.length > 0) {
  18953. jQuery(modalErrorContainer)
  18954. .html(data.errorMsg)
  18955. .slideDown();
  18956. } else {
  18957. jQuery.growl.warning({title: data.errorMsgTitle, message: data.errorMsg});
  18958. }
  18959. } else if (data.data.body) {
  18960. jQuery(modalBody).html(data.body);
  18961. } else {
  18962. jQuery(modalBody).html(genericErrorMsg);
  18963. }
  18964. } else {
  18965. jQuery(modalBody).html(genericErrorMsg);
  18966. }
  18967. jQuery('#modalAjax .loader').fadeOut();
  18968. enableSubmit();
  18969. });
  18970. }
  18971. function updateAjaxModal(data) {
  18972. if (data.reloadPage) {
  18973. if (typeof data.reloadPage === 'string') {
  18974. window.location = data.reloadPage;
  18975. } else {
  18976. window.location.reload();
  18977. }
  18978. return;
  18979. }
  18980. if (data.successDataTable) {
  18981. WHMCS.ui.dataTable.getTableById(data.successDataTable, undefined).ajax.reload();
  18982. }
  18983. if (data.redirect) {
  18984. window.location = data.redirect;
  18985. }
  18986. if (data.successWindow && typeof window[data.successWindow] === "function") {
  18987. window[data.successWindow]();
  18988. }
  18989. if (data.dismiss) {
  18990. dialogClose();
  18991. }
  18992. if (data.successMsg) {
  18993. jQuery.growl.notice({ title: data.successMsgTitle, message: data.successMsg });
  18994. }
  18995. if (data.errorMsg) {
  18996. var inModalErrorContainer = jQuery('#modalAjax .modal-body .admin-modal-error');
  18997. if (inModalErrorContainer.length > 0 && !data.dismiss) {
  18998. jQuery(inModalErrorContainer)
  18999. .html(data.errorMsg)
  19000. .slideDown();
  19001. } else {
  19002. jQuery.growl.warning({title: data.errorMsgTitle, message: data.errorMsg});
  19003. }
  19004. }
  19005. if (data.title) {
  19006. jQuery('#modalAjax .modal-title').html(data.title);
  19007. }
  19008. if (data.body) {
  19009. jQuery('#modalAjax .modal-body').html(data.body);
  19010. } else {
  19011. if (data.url) {
  19012. WHMCS.http.jqClient.post(data.url, '', function(data2) {
  19013. jQuery('#modalAjax').find('.modal-body').html(data2.body);
  19014. }, 'json').fail(function() {
  19015. jQuery('#modalAjax').find('.modal-body').html('An error occurred while communicating with the server. Please try again.');
  19016. jQuery('#modalAjax').find('.loader').fadeOut();
  19017. });
  19018. }
  19019. }
  19020. if (data.submitlabel) {
  19021. jQuery('#modalAjax .modal-submit').html(data.submitlabel).show();
  19022. if (data.submitId) {
  19023. jQuery('#modalAjax').find('.modal-submit').attr('id', data.submitId);
  19024. }
  19025. }
  19026. if (data.submitId) {
  19027. /**
  19028. * Reloading ajax modal multiple times on the same page can add
  19029. * multiple "on" click events which submits the same form over
  19030. * and over.
  19031. * Remove the on click event with "off" to avoid multiple growl
  19032. * and save events being run.
  19033. *
  19034. * @see http://api.jquery.com/off/
  19035. */
  19036. var submitButton = jQuery('#' + data.submitId);
  19037. submitButton.off('click');
  19038. submitButton.on('click', submitIdAjaxModalClickEvent);
  19039. }
  19040. if (data.disableSubmit) {
  19041. disableSubmit();
  19042. } else {
  19043. enableSubmit();
  19044. }
  19045. var dismissLoader = true;
  19046. if (typeof data.dismissLoader !== 'undefined') {
  19047. dismissLoader = data.dismissLoader;
  19048. }
  19049. dismissLoaderAfterRender(dismissLoader);
  19050. if (data.hideSubmit) {
  19051. ajaxModalHideSubmit();
  19052. }
  19053. }
  19054. // backwards compat for older dialog implementations
  19055. function dialogSubmit() {
  19056. disableSubmit();
  19057. jQuery('#modalAjax .loader').show();
  19058. var postUrl = jQuery('#modalAjax').find('form').attr('action');
  19059. WHMCS.http.jqClient.post(postUrl, jQuery('#modalAjax').find('form').serialize(),
  19060. function(data) {
  19061. updateAjaxModal(data);
  19062. }, 'json').fail(function() {
  19063. jQuery('#modalAjax .modal-body').html('An error occurred while communicating with the server. Please try again.');
  19064. jQuery('#modalAjax .loader').fadeOut();
  19065. });
  19066. }
  19067. function dialogClose() {
  19068. jQuery('#modalAjax').modal('hide');
  19069. }
  19070. function addAjaxModalSubmitEvents(functionName) {
  19071. if (functionName) {
  19072. ajaxModalSubmitEvents.push(functionName);
  19073. }
  19074. }
  19075. function removeAjaxModalSubmitEvents(functionName) {
  19076. if (functionName) {
  19077. var index = ajaxModalSubmitEvents.indexOf(functionName);
  19078. if (index >= 0) {
  19079. ajaxModalSubmitEvents.splice(index, 1);
  19080. }
  19081. }
  19082. }
  19083. function addAjaxModalPostSubmitEvents(functionName) {
  19084. if (functionName) {
  19085. ajaxModalPostSubmitEvents.push(functionName);
  19086. }
  19087. }
  19088. function removeAjaxModalPostSubmitEvents(functionName) {
  19089. if (functionName) {
  19090. var index = ajaxModalPostSubmitEvents.indexOf(functionName);
  19091. if (index >= 0) {
  19092. ajaxModalPostSubmitEvents.splice(index, 1);
  19093. }
  19094. }
  19095. }
  19096. function disableSubmit()
  19097. {
  19098. jQuery('#modalAjax .modal-submit').prop('disabled', true).addClass('disabled');
  19099. }
  19100. function enableSubmit()
  19101. {
  19102. jQuery('#modalAjax .modal-submit').prop('disabled', false).removeClass('disabled');
  19103. }
  19104. function ajaxModalHideSubmit()
  19105. {
  19106. jQuery('#modalAjax .modal-submit').hide();
  19107. }
  19108. function dismissLoaderAfterRender(showLoader)
  19109. {
  19110. if (showLoader === false) {
  19111. jQuery('#modalAjax .loader').show();
  19112. } else {
  19113. jQuery('#modalAjax .loader').fadeOut();
  19114. }
  19115. }
  19116. /**
  19117. * bootstrap-switch - Turn checkboxes and radio buttons into toggle switches.
  19118. *
  19119. * @version v4.0.0-alpha.1
  19120. * @homepage http://www.bootstrap-switch.org
  19121. * @author Mattia Larentis <mattia@larentis.eu> (http://larentis.eu)
  19122. * @license Apache-2.0
  19123. */
  19124. 'use strict';
  19125. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  19126. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  19127. (function ($, window) {
  19128. var BootstrapSwitch = function () {
  19129. function BootstrapSwitch(element) {
  19130. var _this = this;
  19131. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  19132. _classCallCheck(this, BootstrapSwitch);
  19133. this.$element = $(element);
  19134. this.options = $.extend({}, $.fn.bootstrapSwitch.defaults, this._getElementOptions(), options);
  19135. this.prevOptions = {};
  19136. this.$wrapper = $('<div>', {
  19137. class: function _class() {
  19138. var classes = [];
  19139. classes.push(_this.options.state ? 'on' : 'off');
  19140. if (_this.options.size) {
  19141. classes.push(_this.options.size);
  19142. }
  19143. if (_this.options.disabled) {
  19144. classes.push('disabled');
  19145. }
  19146. if (_this.options.readonly) {
  19147. classes.push('readonly');
  19148. }
  19149. if (_this.options.indeterminate) {
  19150. classes.push('indeterminate');
  19151. }
  19152. if (_this.options.inverse) {
  19153. classes.push('inverse');
  19154. }
  19155. if (_this.$element.attr('id')) {
  19156. classes.push('id-' + _this.$element.attr('id'));
  19157. }
  19158. return classes.map(_this._getClass.bind(_this)).concat([_this.options.baseClass], _this._getClasses(_this.options.wrapperClass)).join(' ');
  19159. }
  19160. });
  19161. this.$container = $('<div>', { class: this._getClass('container') });
  19162. this.$on = $('<span>', {
  19163. html: this.options.onText,
  19164. class: this._getClass('handle-on') + ' ' + this._getClass(this.options.onColor)
  19165. });
  19166. this.$off = $('<span>', {
  19167. html: this.options.offText,
  19168. class: this._getClass('handle-off') + ' ' + this._getClass(this.options.offColor)
  19169. });
  19170. this.$label = $('<span>', {
  19171. html: this.options.labelText,
  19172. class: this._getClass('label')
  19173. });
  19174. this.$element.on('init.bootstrapSwitch', this.options.onInit.bind(this, element));
  19175. this.$element.on('switchChange.bootstrapSwitch', function () {
  19176. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  19177. args[_key] = arguments[_key];
  19178. }
  19179. if (_this.options.onSwitchChange.apply(element, args) === false) {
  19180. if (_this.$element.is(':radio')) {
  19181. $('[name="' + _this.$element.attr('name') + '"]').trigger('previousState.bootstrapSwitch', true);
  19182. } else {
  19183. _this.$element.trigger('previousState.bootstrapSwitch', true);
  19184. }
  19185. }
  19186. });
  19187. this.$container = this.$element.wrap(this.$container).parent();
  19188. this.$wrapper = this.$container.wrap(this.$wrapper).parent();
  19189. this.$element.before(this.options.inverse ? this.$off : this.$on).before(this.$label).before(this.options.inverse ? this.$on : this.$off);
  19190. if (this.options.indeterminate) {
  19191. this.$element.prop('indeterminate', true);
  19192. }
  19193. this._init();
  19194. this._elementHandlers();
  19195. this._handleHandlers();
  19196. this._labelHandlers();
  19197. this._formHandler();
  19198. this._externalLabelHandler();
  19199. this.$element.trigger('init.bootstrapSwitch', this.options.state);
  19200. }
  19201. _createClass(BootstrapSwitch, [{
  19202. key: 'setPrevOptions',
  19203. value: function setPrevOptions() {
  19204. this.prevOptions = Object.assign({}, this.options);
  19205. }
  19206. }, {
  19207. key: 'state',
  19208. value: function state(value, skip) {
  19209. if (typeof value === 'undefined') {
  19210. return this.options.state;
  19211. }
  19212. if (this.options.disabled || this.options.readonly || this.options.state && !this.options.radioAllOff && this.$element.is(':radio')) {
  19213. return this.$element;
  19214. }
  19215. if (this.$element.is(':radio')) {
  19216. $('[name="' + this.$element.attr('name') + '"]').trigger('setPreviousOptions.bootstrapSwitch');
  19217. } else {
  19218. this.$element.trigger('setPreviousOptions.bootstrapSwitch');
  19219. }
  19220. if (this.options.indeterminate) {
  19221. this.indeterminate(false);
  19222. }
  19223. this.$element.prop('checked', Boolean(value)).trigger('change.bootstrapSwitch', skip);
  19224. return this.$element;
  19225. }
  19226. }, {
  19227. key: 'toggleState',
  19228. value: function toggleState(skip) {
  19229. if (this.options.disabled || this.options.readonly) {
  19230. return this.$element;
  19231. }
  19232. if (this.options.indeterminate) {
  19233. this.indeterminate(false);
  19234. return this.state(true);
  19235. } else {
  19236. return this.$element.prop('checked', !this.options.state).trigger('change.bootstrapSwitch', skip);
  19237. }
  19238. }
  19239. }, {
  19240. key: 'size',
  19241. value: function size(value) {
  19242. if (typeof value === 'undefined') {
  19243. return this.options.size;
  19244. }
  19245. if (this.options.size != null) {
  19246. this.$wrapper.removeClass(this._getClass(this.options.size));
  19247. }
  19248. if (value) {
  19249. this.$wrapper.addClass(this._getClass(value));
  19250. }
  19251. this._width();
  19252. this._containerPosition();
  19253. this.options.size = value;
  19254. return this.$element;
  19255. }
  19256. }, {
  19257. key: 'animate',
  19258. value: function animate(value) {
  19259. if (typeof value === 'undefined') {
  19260. return this.options.animate;
  19261. }
  19262. if (this.options.animate === Boolean(value)) {
  19263. return this.$element;
  19264. }
  19265. return this.toggleAnimate();
  19266. }
  19267. }, {
  19268. key: 'toggleAnimate',
  19269. value: function toggleAnimate() {
  19270. this.options.animate = !this.options.animate;
  19271. this.$wrapper.toggleClass(this._getClass('animate'));
  19272. return this.$element;
  19273. }
  19274. }, {
  19275. key: 'disabled',
  19276. value: function disabled(value) {
  19277. if (typeof value === 'undefined') {
  19278. return this.options.disabled;
  19279. }
  19280. if (this.options.disabled === Boolean(value)) {
  19281. return this.$element;
  19282. }
  19283. return this.toggleDisabled();
  19284. }
  19285. }, {
  19286. key: 'toggleDisabled',
  19287. value: function toggleDisabled() {
  19288. this.options.disabled = !this.options.disabled;
  19289. this.$element.prop('disabled', this.options.disabled);
  19290. this.$wrapper.toggleClass(this._getClass('disabled'));
  19291. return this.$element;
  19292. }
  19293. }, {
  19294. key: 'readonly',
  19295. value: function readonly(value) {
  19296. if (typeof value === 'undefined') {
  19297. return this.options.readonly;
  19298. }
  19299. if (this.options.readonly === Boolean(value)) {
  19300. return this.$element;
  19301. }
  19302. return this.toggleReadonly();
  19303. }
  19304. }, {
  19305. key: 'toggleReadonly',
  19306. value: function toggleReadonly() {
  19307. this.options.readonly = !this.options.readonly;
  19308. this.$element.prop('readonly', this.options.readonly);
  19309. this.$wrapper.toggleClass(this._getClass('readonly'));
  19310. return this.$element;
  19311. }
  19312. }, {
  19313. key: 'indeterminate',
  19314. value: function indeterminate(value) {
  19315. if (typeof value === 'undefined') {
  19316. return this.options.indeterminate;
  19317. }
  19318. if (this.options.indeterminate === Boolean(value)) {
  19319. return this.$element;
  19320. }
  19321. return this.toggleIndeterminate();
  19322. }
  19323. }, {
  19324. key: 'toggleIndeterminate',
  19325. value: function toggleIndeterminate() {
  19326. this.options.indeterminate = !this.options.indeterminate;
  19327. this.$element.prop('indeterminate', this.options.indeterminate);
  19328. this.$wrapper.toggleClass(this._getClass('indeterminate'));
  19329. this._containerPosition();
  19330. return this.$element;
  19331. }
  19332. }, {
  19333. key: 'inverse',
  19334. value: function inverse(value) {
  19335. if (typeof value === 'undefined') {
  19336. return this.options.inverse;
  19337. }
  19338. if (this.options.inverse === Boolean(value)) {
  19339. return this.$element;
  19340. }
  19341. return this.toggleInverse();
  19342. }
  19343. }, {
  19344. key: 'toggleInverse',
  19345. value: function toggleInverse() {
  19346. this.$wrapper.toggleClass(this._getClass('inverse'));
  19347. var $on = this.$on.clone(true);
  19348. var $off = this.$off.clone(true);
  19349. this.$on.replaceWith($off);
  19350. this.$off.replaceWith($on);
  19351. this.$on = $off;
  19352. this.$off = $on;
  19353. this.options.inverse = !this.options.inverse;
  19354. return this.$element;
  19355. }
  19356. }, {
  19357. key: 'onColor',
  19358. value: function onColor(value) {
  19359. if (typeof value === 'undefined') {
  19360. return this.options.onColor;
  19361. }
  19362. if (this.options.onColor) {
  19363. this.$on.removeClass(this._getClass(this.options.onColor));
  19364. }
  19365. this.$on.addClass(this._getClass(value));
  19366. this.options.onColor = value;
  19367. return this.$element;
  19368. }
  19369. }, {
  19370. key: 'offColor',
  19371. value: function offColor(value) {
  19372. if (typeof value === 'undefined') {
  19373. return this.options.offColor;
  19374. }
  19375. if (this.options.offColor) {
  19376. this.$off.removeClass(this._getClass(this.options.offColor));
  19377. }
  19378. this.$off.addClass(this._getClass(value));
  19379. this.options.offColor = value;
  19380. return this.$element;
  19381. }
  19382. }, {
  19383. key: 'onText',
  19384. value: function onText(value) {
  19385. if (typeof value === 'undefined') {
  19386. return this.options.onText;
  19387. }
  19388. this.$on.html(value);
  19389. this._width();
  19390. this._containerPosition();
  19391. this.options.onText = value;
  19392. return this.$element;
  19393. }
  19394. }, {
  19395. key: 'offText',
  19396. value: function offText(value) {
  19397. if (typeof value === 'undefined') {
  19398. return this.options.offText;
  19399. }
  19400. this.$off.html(value);
  19401. this._width();
  19402. this._containerPosition();
  19403. this.options.offText = value;
  19404. return this.$element;
  19405. }
  19406. }, {
  19407. key: 'labelText',
  19408. value: function labelText(value) {
  19409. if (typeof value === 'undefined') {
  19410. return this.options.labelText;
  19411. }
  19412. this.$label.html(value);
  19413. this._width();
  19414. this.options.labelText = value;
  19415. return this.$element;
  19416. }
  19417. }, {
  19418. key: 'handleWidth',
  19419. value: function handleWidth(value) {
  19420. if (typeof value === 'undefined') {
  19421. return this.options.handleWidth;
  19422. }
  19423. this.options.handleWidth = value;
  19424. this._width();
  19425. this._containerPosition();
  19426. return this.$element;
  19427. }
  19428. }, {
  19429. key: 'labelWidth',
  19430. value: function labelWidth(value) {
  19431. if (typeof value === 'undefined') {
  19432. return this.options.labelWidth;
  19433. }
  19434. this.options.labelWidth = value;
  19435. this._width();
  19436. this._containerPosition();
  19437. return this.$element;
  19438. }
  19439. }, {
  19440. key: 'baseClass',
  19441. value: function baseClass(value) {
  19442. return this.options.baseClass;
  19443. }
  19444. }, {
  19445. key: 'wrapperClass',
  19446. value: function wrapperClass(value) {
  19447. if (typeof value === 'undefined') {
  19448. return this.options.wrapperClass;
  19449. }
  19450. if (!value) {
  19451. value = $.fn.bootstrapSwitch.defaults.wrapperClass;
  19452. }
  19453. this.$wrapper.removeClass(this._getClasses(this.options.wrapperClass).join(' '));
  19454. this.$wrapper.addClass(this._getClasses(value).join(' '));
  19455. this.options.wrapperClass = value;
  19456. return this.$element;
  19457. }
  19458. }, {
  19459. key: 'radioAllOff',
  19460. value: function radioAllOff(value) {
  19461. if (typeof value === 'undefined') {
  19462. return this.options.radioAllOff;
  19463. }
  19464. var val = Boolean(value);
  19465. if (this.options.radioAllOff === val) {
  19466. return this.$element;
  19467. }
  19468. this.options.radioAllOff = val;
  19469. return this.$element;
  19470. }
  19471. }, {
  19472. key: 'onInit',
  19473. value: function onInit(value) {
  19474. if (typeof value === 'undefined') {
  19475. return this.options.onInit;
  19476. }
  19477. if (!value) {
  19478. value = $.fn.bootstrapSwitch.defaults.onInit;
  19479. }
  19480. this.options.onInit = value;
  19481. return this.$element;
  19482. }
  19483. }, {
  19484. key: 'onSwitchChange',
  19485. value: function onSwitchChange(value) {
  19486. if (typeof value === 'undefined') {
  19487. return this.options.onSwitchChange;
  19488. }
  19489. if (!value) {
  19490. value = $.fn.bootstrapSwitch.defaults.onSwitchChange;
  19491. }
  19492. this.options.onSwitchChange = value;
  19493. return this.$element;
  19494. }
  19495. }, {
  19496. key: 'destroy',
  19497. value: function destroy() {
  19498. var $form = this.$element.closest('form');
  19499. if ($form.length) {
  19500. $form.off('reset.bootstrapSwitch').removeData('bootstrap-switch');
  19501. }
  19502. this.$container.children().not(this.$element).remove();
  19503. this.$element.unwrap().unwrap().off('.bootstrapSwitch').removeData('bootstrap-switch');
  19504. return this.$element;
  19505. }
  19506. }, {
  19507. key: '_getElementOptions',
  19508. value: function _getElementOptions() {
  19509. return {
  19510. state: this.$element.is(':checked'),
  19511. size: this.$element.data('size'),
  19512. animate: this.$element.data('animate'),
  19513. disabled: this.$element.is(':disabled'),
  19514. readonly: this.$element.is('[readonly]'),
  19515. indeterminate: this.$element.data('indeterminate'),
  19516. inverse: this.$element.data('inverse'),
  19517. radioAllOff: this.$element.data('radio-all-off'),
  19518. onColor: this.$element.data('on-color'),
  19519. offColor: this.$element.data('off-color'),
  19520. onText: this.$element.data('on-text'),
  19521. offText: this.$element.data('off-text'),
  19522. labelText: this.$element.data('label-text'),
  19523. handleWidth: this.$element.data('handle-width'),
  19524. labelWidth: this.$element.data('label-width'),
  19525. baseClass: this.$element.data('base-class'),
  19526. wrapperClass: this.$element.data('wrapper-class')
  19527. };
  19528. }
  19529. }, {
  19530. key: '_width',
  19531. value: function _width() {
  19532. var _this2 = this;
  19533. var $handles = this.$on.add(this.$off).add(this.$label).css('width', '');
  19534. var handleWidth = void 0;
  19535. if (this.options.handleWidth === 'auto') {
  19536. handleWidth = Math.round(Math.max(this.$on.width(), this.$off.width()));
  19537. } else {
  19538. handleWidth = this.options.handleWidth;
  19539. }
  19540. $handles.width(handleWidth);
  19541. this.$label.width(function (index, width) {
  19542. if (_this2.options.labelWidth !== 'auto') {
  19543. return _this2.options.labelWidth;
  19544. }
  19545. if (width < handleWidth) {
  19546. return handleWidth;
  19547. }
  19548. return width;
  19549. });
  19550. this._handleWidth = this.$on.outerWidth();
  19551. this._labelWidth = this.$label.outerWidth();
  19552. this.$container.width(this._handleWidth * 2 + this._labelWidth);
  19553. return this.$wrapper.width(this._handleWidth + this._labelWidth);
  19554. }
  19555. }, {
  19556. key: '_containerPosition',
  19557. value: function _containerPosition() {
  19558. var _this3 = this;
  19559. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.options.state;
  19560. var callback = arguments[1];
  19561. this.$container.css('margin-left', function () {
  19562. var values = [0, '-' + _this3._handleWidth + 'px'];
  19563. if (_this3.options.indeterminate) {
  19564. return '-' + _this3._handleWidth / 2 + 'px';
  19565. }
  19566. if (state) {
  19567. if (_this3.options.inverse) {
  19568. return values[1];
  19569. } else {
  19570. return values[0];
  19571. }
  19572. } else {
  19573. if (_this3.options.inverse) {
  19574. return values[0];
  19575. } else {
  19576. return values[1];
  19577. }
  19578. }
  19579. });
  19580. }
  19581. }, {
  19582. key: '_init',
  19583. value: function _init() {
  19584. var _this4 = this;
  19585. var init = function init() {
  19586. _this4.setPrevOptions();
  19587. _this4._width();
  19588. _this4._containerPosition();
  19589. setTimeout(function () {
  19590. if (_this4.options.animate) {
  19591. return _this4.$wrapper.addClass(_this4._getClass('animate'));
  19592. }
  19593. }, 50);
  19594. };
  19595. if (this.$wrapper.is(':visible')) {
  19596. init();
  19597. return;
  19598. }
  19599. var initInterval = window.setInterval(function () {
  19600. if (_this4.$wrapper.is(':visible')) {
  19601. init();
  19602. return window.clearInterval(initInterval);
  19603. }
  19604. }, 50);
  19605. }
  19606. }, {
  19607. key: '_elementHandlers',
  19608. value: function _elementHandlers() {
  19609. var _this5 = this;
  19610. return this.$element.on({
  19611. 'setPreviousOptions.bootstrapSwitch': this.setPrevOptions.bind(this),
  19612. 'previousState.bootstrapSwitch': function previousStateBootstrapSwitch() {
  19613. _this5.options = _this5.prevOptions;
  19614. if (_this5.options.indeterminate) {
  19615. _this5.$wrapper.addClass(_this5._getClass('indeterminate'));
  19616. }
  19617. _this5.$element.prop('checked', _this5.options.state).trigger('change.bootstrapSwitch', true);
  19618. },
  19619. 'change.bootstrapSwitch': function changeBootstrapSwitch(event, skip) {
  19620. event.preventDefault();
  19621. event.stopImmediatePropagation();
  19622. var state = _this5.$element.is(':checked');
  19623. _this5._containerPosition(state);
  19624. if (state === _this5.options.state) {
  19625. return;
  19626. }
  19627. _this5.options.state = state;
  19628. _this5.$wrapper.toggleClass(_this5._getClass('off')).toggleClass(_this5._getClass('on'));
  19629. if (!skip) {
  19630. if (_this5.$element.is(':radio')) {
  19631. $('[name="' + _this5.$element.attr('name') + '"]').not(_this5.$element).prop('checked', false).trigger('change.bootstrapSwitch', true);
  19632. }
  19633. _this5.$element.trigger('switchChange.bootstrapSwitch', [state]);
  19634. }
  19635. },
  19636. 'focus.bootstrapSwitch': function focusBootstrapSwitch(event) {
  19637. event.preventDefault();
  19638. _this5.$wrapper.addClass(_this5._getClass('focused'));
  19639. },
  19640. 'blur.bootstrapSwitch': function blurBootstrapSwitch(event) {
  19641. event.preventDefault();
  19642. _this5.$wrapper.removeClass(_this5._getClass('focused'));
  19643. },
  19644. 'keydown.bootstrapSwitch': function keydownBootstrapSwitch(event) {
  19645. if (!event.which || _this5.options.disabled || _this5.options.readonly) {
  19646. return;
  19647. }
  19648. if (event.which === 37 || event.which === 39) {
  19649. event.preventDefault();
  19650. event.stopImmediatePropagation();
  19651. _this5.state(event.which === 39);
  19652. }
  19653. }
  19654. });
  19655. }
  19656. }, {
  19657. key: '_handleHandlers',
  19658. value: function _handleHandlers() {
  19659. var _this6 = this;
  19660. this.$on.on('click.bootstrapSwitch', function (event) {
  19661. event.preventDefault();
  19662. event.stopPropagation();
  19663. _this6.state(false);
  19664. return _this6.$element.trigger('focus.bootstrapSwitch');
  19665. });
  19666. return this.$off.on('click.bootstrapSwitch', function (event) {
  19667. event.preventDefault();
  19668. event.stopPropagation();
  19669. _this6.state(true);
  19670. return _this6.$element.trigger('focus.bootstrapSwitch');
  19671. });
  19672. }
  19673. }, {
  19674. key: '_labelHandlers',
  19675. value: function _labelHandlers() {
  19676. var _this7 = this;
  19677. var handlers = {
  19678. click: function click(event) {
  19679. event.stopPropagation();
  19680. },
  19681. 'mousedown.bootstrapSwitch touchstart.bootstrapSwitch': function mousedownBootstrapSwitchTouchstartBootstrapSwitch(event) {
  19682. if (_this7._dragStart || _this7.options.disabled || _this7.options.readonly) {
  19683. return;
  19684. }
  19685. event.preventDefault();
  19686. event.stopPropagation();
  19687. _this7._dragStart = (event.pageX || event.originalEvent.touches[0].pageX) - parseInt(_this7.$container.css('margin-left'), 10);
  19688. if (_this7.options.animate) {
  19689. _this7.$wrapper.removeClass(_this7._getClass('animate'));
  19690. }
  19691. _this7.$element.trigger('focus.bootstrapSwitch');
  19692. },
  19693. 'mousemove.bootstrapSwitch touchmove.bootstrapSwitch': function mousemoveBootstrapSwitchTouchmoveBootstrapSwitch(event) {
  19694. if (_this7._dragStart == null) {
  19695. return;
  19696. }
  19697. var difference = (event.pageX || event.originalEvent.touches[0].pageX) - _this7._dragStart;
  19698. event.preventDefault();
  19699. if (difference < -_this7._handleWidth || difference > 0) {
  19700. return;
  19701. }
  19702. _this7._dragEnd = difference;
  19703. _this7.$container.css('margin-left', _this7._dragEnd + 'px');
  19704. },
  19705. 'mouseup.bootstrapSwitch touchend.bootstrapSwitch': function mouseupBootstrapSwitchTouchendBootstrapSwitch(event) {
  19706. if (!_this7._dragStart) {
  19707. return;
  19708. }
  19709. event.preventDefault();
  19710. if (_this7.options.animate) {
  19711. _this7.$wrapper.addClass(_this7._getClass('animate'));
  19712. }
  19713. if (_this7._dragEnd) {
  19714. var state = _this7._dragEnd > -(_this7._handleWidth / 2);
  19715. _this7._dragEnd = false;
  19716. _this7.state(_this7.options.inverse ? !state : state);
  19717. } else {
  19718. _this7.state(!_this7.options.state);
  19719. }
  19720. _this7._dragStart = false;
  19721. },
  19722. 'mouseleave.bootstrapSwitch': function mouseleaveBootstrapSwitch() {
  19723. _this7.$label.trigger('mouseup.bootstrapSwitch');
  19724. }
  19725. };
  19726. this.$label.on(handlers);
  19727. }
  19728. }, {
  19729. key: '_externalLabelHandler',
  19730. value: function _externalLabelHandler() {
  19731. var _this8 = this;
  19732. var $externalLabel = this.$element.closest('label');
  19733. $externalLabel.on('click', function (event) {
  19734. event.preventDefault();
  19735. event.stopImmediatePropagation();
  19736. if (event.target === $externalLabel[0]) {
  19737. _this8.toggleState();
  19738. }
  19739. });
  19740. }
  19741. }, {
  19742. key: '_formHandler',
  19743. value: function _formHandler() {
  19744. var $form = this.$element.closest('form');
  19745. if ($form.data('bootstrap-switch')) {
  19746. return;
  19747. }
  19748. $form.on('reset.bootstrapSwitch', function () {
  19749. window.setTimeout(function () {
  19750. $form.find('input').filter(function () {
  19751. return $(this).data('bootstrap-switch');
  19752. }).each(function () {
  19753. return $(this).bootstrapSwitch('state', this.checked);
  19754. });
  19755. }, 1);
  19756. }).data('bootstrap-switch', true);
  19757. }
  19758. }, {
  19759. key: '_getClass',
  19760. value: function _getClass(name) {
  19761. return this.options.baseClass + '-' + name;
  19762. }
  19763. }, {
  19764. key: '_getClasses',
  19765. value: function _getClasses(classes) {
  19766. if (!$.isArray(classes)) {
  19767. return [this._getClass(classes)];
  19768. }
  19769. return classes.map(this._getClass.bind(this));
  19770. }
  19771. }]);
  19772. return BootstrapSwitch;
  19773. }();
  19774. $.fn.bootstrapSwitch = function (option) {
  19775. for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  19776. args[_key2 - 1] = arguments[_key2];
  19777. }
  19778. var ret = this;
  19779. this.each(function () {
  19780. var $this = $(this);
  19781. var data = $this.data('bootstrap-switch');
  19782. if (!data) {
  19783. data = new BootstrapSwitch(this, option);
  19784. $this.data('bootstrap-switch', data);
  19785. }
  19786. if (typeof option === 'string') {
  19787. ret = data[option].apply(data, args);
  19788. }
  19789. });
  19790. return ret;
  19791. };
  19792. $.fn.bootstrapSwitch.Constructor = BootstrapSwitch;
  19793. $.fn.bootstrapSwitch.defaults = {
  19794. state: true,
  19795. size: null,
  19796. animate: true,
  19797. disabled: false,
  19798. readonly: false,
  19799. indeterminate: false,
  19800. inverse: false,
  19801. radioAllOff: false,
  19802. onColor: 'primary',
  19803. offColor: 'secondary',
  19804. onText: 'ON',
  19805. offText: 'OFF',
  19806. labelText: '&nbsp',
  19807. handleWidth: 'auto',
  19808. labelWidth: 'auto',
  19809. baseClass: 'bootstrap-switch',
  19810. wrapperClass: 'wrapper',
  19811. onInit: function onInit() {},
  19812. onSwitchChange: function onSwitchChange() {}
  19813. };
  19814. })(window.jQuery, window);
  19815. /* ===================================================
  19816. * bootstrap-markdown.js v2.10.0
  19817. * http://github.com/toopay/bootstrap-markdown
  19818. * ===================================================
  19819. * Copyright 2013-2016 Taufan Aditya
  19820. *
  19821. * Licensed under the Apache License, Version 2.0 (the "License");
  19822. * you may not use this file except in compliance with the License.
  19823. * You may obtain a copy of the License at
  19824. *
  19825. * http://www.apache.org/licenses/LICENSE-2.0
  19826. *
  19827. * Unless required by applicable law or agreed to in writing, software
  19828. * distributed under the License is distributed on an "AS IS" BASIS,
  19829. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19830. * See the License for the specific language governing permissions and
  19831. * limitations under the License.
  19832. * ========================================================== */
  19833. (function(factory) {
  19834. if (typeof define === "function" && define.amd) {
  19835. // RequireJS
  19836. define(["jquery"], factory);
  19837. } else if (typeof exports === 'object') {
  19838. // Backbone.js
  19839. factory(require('jquery'));
  19840. } else {
  19841. // jQuery plugin
  19842. factory(jQuery);
  19843. }
  19844. }(function($) {
  19845. "use strict";
  19846. /* MARKDOWN CLASS DEFINITION
  19847. * ========================== */
  19848. var Markdown = function(element, options) {
  19849. // @TODO : remove this BC on next major release
  19850. // @see : https://github.com/toopay/bootstrap-markdown/issues/109
  19851. var opts = ['autofocus', 'savable', 'hideable', 'width',
  19852. 'height', 'resize', 'iconlibrary', 'language',
  19853. 'footer', 'fullscreen', 'hiddenButtons', 'disabledButtons'
  19854. ];
  19855. $.each(opts, function(_, opt) {
  19856. if (typeof $(element).data(opt) !== 'undefined') {
  19857. options = typeof options == 'object' ? options : {};
  19858. options[opt] = $(element).data(opt);
  19859. }
  19860. });
  19861. // End BC
  19862. // Class Properties
  19863. this.$ns = 'bootstrap-markdown';
  19864. this.$element = $(element);
  19865. this.$editable = {
  19866. el: null,
  19867. type: null,
  19868. attrKeys: [],
  19869. attrValues: [],
  19870. content: null
  19871. };
  19872. this.$options = $.extend(true, {}, $.fn.markdown.defaults, options, this.$element.data('options'));
  19873. this.$oldContent = null;
  19874. this.$isPreview = false;
  19875. this.$isFullscreen = false;
  19876. this.$editor = null;
  19877. this.$textarea = null;
  19878. this.$handler = [];
  19879. this.$callback = [];
  19880. this.$nextTab = [];
  19881. this.showEditor();
  19882. };
  19883. Markdown.prototype = {
  19884. constructor: Markdown,
  19885. __alterButtons: function(name, alter) {
  19886. var handler = this.$handler,
  19887. isAll = (name == 'all'),
  19888. that = this;
  19889. $.each(handler, function(k, v) {
  19890. var halt = true;
  19891. if (isAll) {
  19892. halt = false;
  19893. } else {
  19894. halt = v.indexOf(name) < 0;
  19895. }
  19896. if (halt === false) {
  19897. alter(that.$editor.find('button[data-handler="' + v + '"]'));
  19898. }
  19899. });
  19900. },
  19901. __buildButtons: function(buttonsArray, container) {
  19902. var i,
  19903. ns = this.$ns,
  19904. handler = this.$handler,
  19905. callback = this.$callback;
  19906. for (i = 0; i < buttonsArray.length; i++) {
  19907. // Build each group container
  19908. var y, btnGroups = buttonsArray[i];
  19909. for (y = 0; y < btnGroups.length; y++) {
  19910. // Build each button group
  19911. var z,
  19912. buttons = btnGroups[y].data,
  19913. btnGroupContainer = $('<div/>', {
  19914. 'class': 'btn-group'
  19915. });
  19916. for (z = 0; z < buttons.length; z++) {
  19917. var button = buttons[z],
  19918. buttonContainer, buttonIconContainer,
  19919. buttonHandler = ns + '-' + button.name,
  19920. buttonIcon = this.__getIcon(button),
  19921. btnText = button.btnText ? button.btnText : '',
  19922. btnClass = button.btnClass ? button.btnClass : 'btn',
  19923. tabIndex = button.tabIndex ? button.tabIndex : '-1',
  19924. hotkey = typeof button.hotkey !== 'undefined' ? button.hotkey : '',
  19925. hotkeyCaption = typeof jQuery.hotkeys !== 'undefined' && hotkey !== '' ? ' (' + hotkey + ')' : '';
  19926. // Construct the button object
  19927. buttonContainer = $('<button></button>');
  19928. buttonContainer.text(' ' + this.__localize(btnText)).addClass('btn-default btn-sm').addClass(btnClass);
  19929. if (btnClass.match(/btn\-(primary|success|info|warning|danger|link)/)) {
  19930. buttonContainer.removeClass('btn-default');
  19931. }
  19932. buttonContainer.attr({
  19933. 'type': 'button',
  19934. 'title': this.__localize(button.title) + hotkeyCaption,
  19935. 'tabindex': tabIndex,
  19936. 'data-provider': ns,
  19937. 'data-handler': buttonHandler,
  19938. 'data-hotkey': hotkey
  19939. });
  19940. if (button.toggle === true) {
  19941. buttonContainer.attr('data-toggle', 'button');
  19942. }
  19943. buttonIconContainer = $('<span/>');
  19944. buttonIconContainer.addClass(buttonIcon);
  19945. buttonIconContainer.prependTo(buttonContainer);
  19946. // Attach the button object
  19947. btnGroupContainer.append(buttonContainer);
  19948. // Register handler and callback
  19949. handler.push(buttonHandler);
  19950. callback.push(button.callback);
  19951. }
  19952. // Attach the button group into container DOM
  19953. container.append(btnGroupContainer);
  19954. }
  19955. }
  19956. return container;
  19957. },
  19958. __setListener: function() {
  19959. // Set size and resizable Properties
  19960. var hasRows = typeof this.$textarea.attr('rows') !== 'undefined',
  19961. maxRows = this.$textarea.val().split("\n").length > 5 ? this.$textarea.val().split("\n").length : '5',
  19962. rowsVal = hasRows ? this.$textarea.attr('rows') : maxRows;
  19963. this.$textarea.attr('rows', rowsVal);
  19964. if (this.$options.resize) {
  19965. this.$textarea.css('resize', this.$options.resize);
  19966. }
  19967. // Re-attach markdown data
  19968. this.$textarea.data('markdown', this);
  19969. },
  19970. __setEventListeners: function() {
  19971. this.$textarea.on({
  19972. 'focus': $.proxy(this.focus, this),
  19973. 'keyup': $.proxy(this.keyup, this),
  19974. 'change': $.proxy(this.change, this),
  19975. 'select': $.proxy(this.select, this)
  19976. });
  19977. if (this.eventSupported('keydown')) {
  19978. this.$textarea.on('keydown', $.proxy(this.keydown, this));
  19979. }
  19980. if (this.eventSupported('keypress')) {
  19981. this.$textarea.on('keypress', $.proxy(this.keypress, this));
  19982. }
  19983. },
  19984. __handle: function(e) {
  19985. var target = $(e.currentTarget),
  19986. handler = this.$handler,
  19987. callback = this.$callback,
  19988. handlerName = target.attr('data-handler'),
  19989. callbackIndex = handler.indexOf(handlerName),
  19990. callbackHandler = callback[callbackIndex];
  19991. // Trigger the focusin
  19992. $(e.currentTarget).focus();
  19993. callbackHandler(this);
  19994. // Trigger onChange for each button handle
  19995. this.change(this);
  19996. // Unless it was the save handler,
  19997. // focusin the textarea
  19998. if (handlerName.indexOf('cmdSave') < 0) {
  19999. this.$textarea.focus();
  20000. }
  20001. e.preventDefault();
  20002. },
  20003. __localize: function(string) {
  20004. var messages = $.fn.markdown.messages,
  20005. language = this.$options.language;
  20006. if (
  20007. typeof messages !== 'undefined' &&
  20008. typeof messages[language] !== 'undefined' &&
  20009. typeof messages[language][string] !== 'undefined'
  20010. ) {
  20011. return messages[language][string];
  20012. }
  20013. return string;
  20014. },
  20015. __getIcon: function(src) {
  20016. if(typeof src == 'object'){
  20017. var customIcon = this.$options.customIcons[src.name];
  20018. return typeof customIcon == 'undefined' ? src.icon[this.$options.iconlibrary] : customIcon;
  20019. } else {
  20020. return src;
  20021. }
  20022. },
  20023. setFullscreen: function(mode) {
  20024. var $editor = this.$editor,
  20025. $textarea = this.$textarea;
  20026. if (mode === true) {
  20027. $editor.addClass('md-fullscreen-mode');
  20028. $('body').addClass('md-nooverflow');
  20029. this.$options.onFullscreen(this);
  20030. } else {
  20031. $editor.removeClass('md-fullscreen-mode');
  20032. $('body').removeClass('md-nooverflow');
  20033. this.$options.onFullscreenExit(this);
  20034. if (this.$isPreview === true)
  20035. this.hidePreview().showPreview();
  20036. }
  20037. this.$isFullscreen = mode;
  20038. $textarea.focus();
  20039. },
  20040. showEditor: function() {
  20041. var instance = this,
  20042. textarea,
  20043. ns = this.$ns,
  20044. container = this.$element,
  20045. originalHeigth = container.css('height'),
  20046. originalWidth = container.css('width'),
  20047. editable = this.$editable,
  20048. handler = this.$handler,
  20049. callback = this.$callback,
  20050. options = this.$options,
  20051. editor = $('<div/>', {
  20052. 'class': 'md-editor',
  20053. click: function() {
  20054. instance.focus();
  20055. }
  20056. });
  20057. // Prepare the editor
  20058. if (this.$editor === null) {
  20059. // Create the panel
  20060. var editorHeader = $('<div/>', {
  20061. 'class': 'md-header btn-toolbar'
  20062. });
  20063. // Merge the main & additional button groups together
  20064. var allBtnGroups = [];
  20065. if (options.buttons.length > 0) allBtnGroups = allBtnGroups.concat(options.buttons[0]);
  20066. if (options.additionalButtons.length > 0) {
  20067. // iterate the additional button groups
  20068. $.each(options.additionalButtons[0], function(idx, buttonGroup) {
  20069. // see if the group name of the additional group matches an existing group
  20070. var matchingGroups = $.grep(allBtnGroups, function(allButtonGroup, allIdx) {
  20071. return allButtonGroup.name === buttonGroup.name;
  20072. });
  20073. // if it matches add the additional buttons to that group, if not just add it to the all buttons group
  20074. if (matchingGroups.length > 0) {
  20075. matchingGroups[0].data = matchingGroups[0].data.concat(buttonGroup.data);
  20076. } else {
  20077. allBtnGroups.push(options.additionalButtons[0][idx]);
  20078. }
  20079. });
  20080. }
  20081. // Reduce and/or reorder the button groups
  20082. if (options.reorderButtonGroups.length > 0) {
  20083. allBtnGroups = allBtnGroups
  20084. .filter(function(btnGroup) {
  20085. return options.reorderButtonGroups.indexOf(btnGroup.name) > -1;
  20086. })
  20087. .sort(function(a, b) {
  20088. if (options.reorderButtonGroups.indexOf(a.name) < options.reorderButtonGroups.indexOf(b.name)) return -1;
  20089. if (options.reorderButtonGroups.indexOf(a.name) > options.reorderButtonGroups.indexOf(b.name)) return 1;
  20090. return 0;
  20091. });
  20092. }
  20093. // Build the buttons
  20094. if (allBtnGroups.length > 0) {
  20095. editorHeader = this.__buildButtons([allBtnGroups], editorHeader);
  20096. }
  20097. if (options.fullscreen.enable) {
  20098. editorHeader.append('<div class="md-controls"><a class="md-control md-control-fullscreen" href="#"><span class="' + this.__getIcon(options.fullscreen.icons.fullscreenOn) + '"></span></a></div>').on('click', '.md-control-fullscreen', function(e) {
  20099. e.preventDefault();
  20100. instance.setFullscreen(true);
  20101. });
  20102. }
  20103. editor.append(editorHeader);
  20104. // Wrap the textarea
  20105. if (container.is('textarea')) {
  20106. container.before(editor);
  20107. textarea = container;
  20108. textarea.addClass('md-input');
  20109. editor.append(textarea);
  20110. } else {
  20111. var rawContent = (typeof toMarkdown == 'function') ? toMarkdown(container.html()) : container.html(),
  20112. currentContent = $.trim(rawContent);
  20113. // This is some arbitrary content that could be edited
  20114. textarea = $('<textarea/>', {
  20115. 'class': 'md-input',
  20116. 'val': currentContent
  20117. });
  20118. editor.append(textarea);
  20119. // Save the editable
  20120. editable.el = container;
  20121. editable.type = container.prop('tagName').toLowerCase();
  20122. editable.content = container.html();
  20123. $(container[0].attributes).each(function() {
  20124. editable.attrKeys.push(this.nodeName);
  20125. editable.attrValues.push(this.nodeValue);
  20126. });
  20127. // Set editor to block the original container
  20128. container.replaceWith(editor);
  20129. }
  20130. var editorFooter = $('<div/>', {
  20131. 'class': 'md-footer'
  20132. }),
  20133. createFooter = false,
  20134. footer = '';
  20135. // Create the footer if savable
  20136. if (options.savable) {
  20137. createFooter = true;
  20138. var saveHandler = 'cmdSave';
  20139. // Register handler and callback
  20140. handler.push(saveHandler);
  20141. callback.push(options.onSave);
  20142. editorFooter.append('<button class="btn btn-success" data-provider="' +
  20143. ns +
  20144. '" data-handler="' +
  20145. saveHandler +
  20146. '"><i class="icon icon-white icon-ok"></i> ' +
  20147. this.__localize('Save') +
  20148. '</button>');
  20149. }
  20150. footer = typeof options.footer === 'function' ? options.footer(this) : options.footer;
  20151. if ($.trim(footer) !== '') {
  20152. createFooter = true;
  20153. editorFooter.append(footer);
  20154. }
  20155. if (createFooter) editor.append(editorFooter);
  20156. // Set width
  20157. if (options.width && options.width !== 'inherit') {
  20158. if (jQuery.isNumeric(options.width)) {
  20159. editor.css('display', 'table');
  20160. textarea.css('width', options.width + 'px');
  20161. } else {
  20162. editor.addClass(options.width);
  20163. }
  20164. }
  20165. // Set height
  20166. if (options.height && options.height !== 'inherit') {
  20167. if (jQuery.isNumeric(options.height)) {
  20168. var height = options.height;
  20169. if (editorHeader) height = Math.max(0, height - editorHeader.outerHeight());
  20170. if (editorFooter) height = Math.max(0, height - editorFooter.outerHeight());
  20171. textarea.css('height', height + 'px');
  20172. } else {
  20173. editor.addClass(options.height);
  20174. }
  20175. }
  20176. // Reference
  20177. this.$editor = editor;
  20178. this.$textarea = textarea;
  20179. this.$editable = editable;
  20180. this.$oldContent = this.getContent();
  20181. this.__setListener();
  20182. this.__setEventListeners();
  20183. // Set editor attributes, data short-hand API and listener
  20184. this.$editor.attr('id', (new Date()).getTime());
  20185. this.$editor.on('click', '[data-provider="bootstrap-markdown"]', $.proxy(this.__handle, this));
  20186. if (this.$element.is(':disabled') || this.$element.is('[readonly]')) {
  20187. this.$editor.addClass('md-editor-disabled');
  20188. this.disableButtons('all');
  20189. }
  20190. if (this.eventSupported('keydown') && typeof jQuery.hotkeys === 'object') {
  20191. editorHeader.find('[data-provider="bootstrap-markdown"]').each(function() {
  20192. var $button = $(this),
  20193. hotkey = $button.attr('data-hotkey');
  20194. if (hotkey.toLowerCase() !== '') {
  20195. textarea.bind('keydown', hotkey, function() {
  20196. $button.trigger('click');
  20197. return false;
  20198. });
  20199. }
  20200. });
  20201. }
  20202. if (options.initialstate === 'preview') {
  20203. this.showPreview();
  20204. } else if (options.initialstate === 'fullscreen' && options.fullscreen.enable) {
  20205. this.setFullscreen(true);
  20206. }
  20207. } else {
  20208. this.$editor.show();
  20209. }
  20210. if (options.autofocus) {
  20211. this.$textarea.focus();
  20212. this.$editor.addClass('active');
  20213. }
  20214. if (options.fullscreen.enable && options.fullscreen !== false) {
  20215. this.$editor.append('<div class="md-fullscreen-controls">' +
  20216. '<a href="#" class="exit-fullscreen" title="Exit fullscreen"><span class="' + this.__getIcon(options.fullscreen.icons.fullscreenOff) + '">' +
  20217. '</span></a>' +
  20218. '</div>');
  20219. this.$editor.on('click', '.exit-fullscreen', function(e) {
  20220. e.preventDefault();
  20221. instance.setFullscreen(false);
  20222. });
  20223. }
  20224. // hide hidden buttons from options
  20225. this.hideButtons(options.hiddenButtons);
  20226. // disable disabled buttons from options
  20227. this.disableButtons(options.disabledButtons);
  20228. // enable dropZone if available and configured
  20229. if (options.dropZoneOptions) {
  20230. if (this.$editor.dropzone) {
  20231. if(!options.dropZoneOptions.init) {
  20232. options.dropZoneOptions.init = function() {
  20233. var caretPos = 0;
  20234. this.on('drop', function(e) {
  20235. caretPos = textarea.prop('selectionStart');
  20236. });
  20237. this.on('success', function(file, path) {
  20238. var text = textarea.val();
  20239. textarea.val(text.substring(0, caretPos) + '\n![description](' + path + ')\n' + text.substring(caretPos));
  20240. });
  20241. this.on('error', function(file, error, xhr) {
  20242. console.log('Error:', error);
  20243. });
  20244. };
  20245. }
  20246. this.$editor.addClass('dropzone');
  20247. this.$editor.dropzone(options.dropZoneOptions);
  20248. } else {
  20249. console.log('dropZoneOptions was configured, but DropZone was not detected.');
  20250. }
  20251. }
  20252. // enable data-uris via drag and drop
  20253. if (options.enableDropDataUri === true) {
  20254. this.$editor.on('drop', function(e) {
  20255. var caretPos = textarea.prop('selectionStart');
  20256. e.stopPropagation();
  20257. e.preventDefault();
  20258. $.each(e.originalEvent.dataTransfer.files, function(index, file){
  20259. var fileReader = new FileReader();
  20260. fileReader.onload = (function(file) {
  20261. var type = file.type.split('/')[0];
  20262. return function(e) {
  20263. var text = textarea.val();
  20264. if (type === 'image')
  20265. textarea.val(text.substring(0, caretPos) + '\n<img src="'+ e.target.result +'" />\n' + text.substring(caretPos) );
  20266. else
  20267. textarea.val(text.substring(0, caretPos) + '\n<a href="'+ e.target.result +'">Download ' + file.name + '</a>\n' + text.substring(caretPos) );
  20268. };
  20269. })(file);
  20270. fileReader.readAsDataURL(file);
  20271. });
  20272. });
  20273. }
  20274. // Trigger the onShow hook
  20275. options.onShow(this);
  20276. return this;
  20277. },
  20278. parseContent: function(val) {
  20279. var content;
  20280. // parse with supported markdown parser
  20281. val = val || this.$textarea.val();
  20282. if (this.$options.parser) {
  20283. content = this.$options.parser(val);
  20284. } else if (typeof markdown == 'object') {
  20285. content = markdown.toHTML(val);
  20286. } else if (typeof marked == 'function') {
  20287. content = marked(val);
  20288. } else {
  20289. content = val;
  20290. }
  20291. return content;
  20292. },
  20293. showPreview: function() {
  20294. var options = this.$options,
  20295. container = this.$textarea,
  20296. afterContainer = container.next(),
  20297. replacementContainer = $('<div/>', {
  20298. 'class': 'md-preview',
  20299. 'data-provider': 'markdown-preview'
  20300. }),
  20301. content,
  20302. callbackContent;
  20303. if (this.$isPreview === true) {
  20304. // Avoid sequenced element creation on misused scenario
  20305. // @see https://github.com/toopay/bootstrap-markdown/issues/170
  20306. return this;
  20307. }
  20308. // Give flag that tells the editor to enter preview mode
  20309. this.$isPreview = true;
  20310. // Disable all buttons
  20311. this.disableButtons('all').enableButtons('cmdPreview');
  20312. // Try to get the content from callback
  20313. callbackContent = options.onPreview(this, replacementContainer);
  20314. // Set the content based on the callback content if string, otherwise parse value from textarea
  20315. content = typeof callbackContent == 'string' ? callbackContent : this.parseContent();
  20316. // Build preview element
  20317. replacementContainer.html(content);
  20318. if (afterContainer && afterContainer.attr('class') == 'md-footer') {
  20319. // If there is footer element, insert the preview container before it
  20320. replacementContainer.insertBefore(afterContainer);
  20321. } else {
  20322. // Otherwise, just append it after textarea
  20323. container.parent().append(replacementContainer);
  20324. }
  20325. // Set the preview element dimensions
  20326. replacementContainer.css({
  20327. "width": container.outerWidth() + 'px',
  20328. "min-height": container.outerHeight() + 'px',
  20329. "height": "auto"
  20330. });
  20331. if (this.$options.resize) {
  20332. replacementContainer.css('resize', this.$options.resize);
  20333. }
  20334. // Hide the last-active textarea
  20335. container.hide();
  20336. // Attach the editor instances
  20337. replacementContainer.data('markdown', this);
  20338. if (this.$element.is(':disabled') || this.$element.is('[readonly]')) {
  20339. this.$editor.addClass('md-editor-disabled');
  20340. this.disableButtons('all');
  20341. }
  20342. return this;
  20343. },
  20344. hidePreview: function() {
  20345. // Give flag that tells the editor to quit preview mode
  20346. this.$isPreview = false;
  20347. // Obtain the preview container
  20348. var container = this.$editor.find('div[data-provider="markdown-preview"]');
  20349. // Remove the preview container
  20350. container.remove();
  20351. // Enable all buttons
  20352. this.enableButtons('all');
  20353. // Disable configured disabled buttons
  20354. this.disableButtons(this.$options.disabledButtons);
  20355. // Perform any callbacks
  20356. this.$options.onPreviewEnd(this);
  20357. // Back to the editor
  20358. this.$textarea.show();
  20359. this.__setListener();
  20360. return this;
  20361. },
  20362. isDirty: function() {
  20363. return this.$oldContent != this.getContent();
  20364. },
  20365. getContent: function() {
  20366. return this.$textarea.val();
  20367. },
  20368. setContent: function(content) {
  20369. this.$textarea.val(content);
  20370. return this;
  20371. },
  20372. findSelection: function(chunk) {
  20373. var content = this.getContent(),
  20374. startChunkPosition;
  20375. if (startChunkPosition = content.indexOf(chunk), startChunkPosition >= 0 && chunk.length > 0) {
  20376. var oldSelection = this.getSelection(),
  20377. selection;
  20378. this.setSelection(startChunkPosition, startChunkPosition + chunk.length);
  20379. selection = this.getSelection();
  20380. this.setSelection(oldSelection.start, oldSelection.end);
  20381. return selection;
  20382. } else {
  20383. return null;
  20384. }
  20385. },
  20386. getSelection: function() {
  20387. var e = this.$textarea[0];
  20388. return (
  20389. ('selectionStart' in e && function() {
  20390. var l = e.selectionEnd - e.selectionStart;
  20391. return {
  20392. start: e.selectionStart,
  20393. end: e.selectionEnd,
  20394. length: l,
  20395. text: e.value.substr(e.selectionStart, l)
  20396. };
  20397. }) ||
  20398. /* browser not supported */
  20399. function() {
  20400. return null;
  20401. }
  20402. )();
  20403. },
  20404. setSelection: function(start, end) {
  20405. var e = this.$textarea[0];
  20406. return (
  20407. ('selectionStart' in e && function() {
  20408. e.selectionStart = start;
  20409. e.selectionEnd = end;
  20410. return;
  20411. }) ||
  20412. /* browser not supported */
  20413. function() {
  20414. return null;
  20415. }
  20416. )();
  20417. },
  20418. replaceSelection: function(text) {
  20419. var e = this.$textarea[0];
  20420. return (
  20421. ('selectionStart' in e && function() {
  20422. e.value = e.value.substr(0, e.selectionStart) + text + e.value.substr(e.selectionEnd, e.value.length);
  20423. // Set cursor to the last replacement end
  20424. e.selectionStart = e.value.length;
  20425. return this;
  20426. }) ||
  20427. /* browser not supported */
  20428. function() {
  20429. e.value += text;
  20430. return jQuery(e);
  20431. }
  20432. )();
  20433. },
  20434. getNextTab: function() {
  20435. // Shift the nextTab
  20436. if (this.$nextTab.length === 0) {
  20437. return null;
  20438. } else {
  20439. var nextTab, tab = this.$nextTab.shift();
  20440. if (typeof tab == 'function') {
  20441. nextTab = tab();
  20442. } else if (typeof tab == 'object' && tab.length > 0) {
  20443. nextTab = tab;
  20444. }
  20445. return nextTab;
  20446. }
  20447. },
  20448. setNextTab: function(start, end) {
  20449. // Push new selection into nextTab collections
  20450. if (typeof start == 'string') {
  20451. var that = this;
  20452. this.$nextTab.push(function() {
  20453. return that.findSelection(start);
  20454. });
  20455. } else if (typeof start == 'number' && typeof end == 'number') {
  20456. var oldSelection = this.getSelection();
  20457. this.setSelection(start, end);
  20458. this.$nextTab.push(this.getSelection());
  20459. this.setSelection(oldSelection.start, oldSelection.end);
  20460. }
  20461. return;
  20462. },
  20463. __parseButtonNameParam: function(names) {
  20464. return typeof names == 'string' ?
  20465. names.split(' ') :
  20466. names;
  20467. },
  20468. enableButtons: function(name) {
  20469. var buttons = this.__parseButtonNameParam(name),
  20470. that = this;
  20471. $.each(buttons, function(i, v) {
  20472. that.__alterButtons(buttons[i], function(el) {
  20473. el.removeAttr('disabled');
  20474. });
  20475. });
  20476. return this;
  20477. },
  20478. disableButtons: function(name) {
  20479. var buttons = this.__parseButtonNameParam(name),
  20480. that = this;
  20481. $.each(buttons, function(i, v) {
  20482. that.__alterButtons(buttons[i], function(el) {
  20483. el.attr('disabled', 'disabled');
  20484. });
  20485. });
  20486. return this;
  20487. },
  20488. hideButtons: function(name) {
  20489. var buttons = this.__parseButtonNameParam(name),
  20490. that = this;
  20491. $.each(buttons, function(i, v) {
  20492. that.__alterButtons(buttons[i], function(el) {
  20493. el.addClass('hidden');
  20494. });
  20495. });
  20496. return this;
  20497. },
  20498. showButtons: function(name) {
  20499. var buttons = this.__parseButtonNameParam(name),
  20500. that = this;
  20501. $.each(buttons, function(i, v) {
  20502. that.__alterButtons(buttons[i], function(el) {
  20503. el.removeClass('hidden');
  20504. });
  20505. });
  20506. return this;
  20507. },
  20508. eventSupported: function(eventName) {
  20509. var isSupported = eventName in this.$element;
  20510. if (!isSupported) {
  20511. this.$element.setAttribute(eventName, 'return;');
  20512. isSupported = typeof this.$element[eventName] === 'function';
  20513. }
  20514. return isSupported;
  20515. },
  20516. keyup: function(e) {
  20517. var blocked = false;
  20518. switch (e.keyCode) {
  20519. case 40: // down arrow
  20520. case 38: // up arrow
  20521. case 16: // shift
  20522. case 17: // ctrl
  20523. case 18: // alt
  20524. break;
  20525. case 9: // tab
  20526. var nextTab;
  20527. if (nextTab = this.getNextTab(), nextTab !== null) {
  20528. // Get the nextTab if exists
  20529. var that = this;
  20530. setTimeout(function() {
  20531. that.setSelection(nextTab.start, nextTab.end);
  20532. }, 500);
  20533. blocked = true;
  20534. } else {
  20535. // The next tab's memory contains nothing...
  20536. // check the cursor position to determine tab action
  20537. var cursor = this.getSelection();
  20538. if (cursor.start == cursor.end && cursor.end == this.getContent().length) {
  20539. // The cursor has reached the end of the content
  20540. blocked = false;
  20541. } else {
  20542. // Put the cursor to the end
  20543. this.setSelection(this.getContent().length, this.getContent().length);
  20544. blocked = true;
  20545. }
  20546. }
  20547. break;
  20548. case 13: // enter
  20549. blocked = false;
  20550. var chars = this.getContent().split('');
  20551. var enterIndex = this.getSelection().start;
  20552. var priorNewlineIndex = -1; // initial line break at before index 0
  20553. // traverse backwards through chars to check if last line break was num/bullet item
  20554. for (var i = enterIndex - 2; i >= 0; i--) {
  20555. if (chars[i] === '\n') {
  20556. priorNewlineIndex = i;
  20557. break;
  20558. }
  20559. }
  20560. if (chars.slice(priorNewlineIndex + 1, priorNewlineIndex + 4).join('') == '---') {
  20561. break;
  20562. }
  20563. var charFollowingLastLineBreak = chars[priorNewlineIndex + 1];
  20564. if (charFollowingLastLineBreak === '-') {
  20565. this.addBullet(enterIndex);
  20566. } else if ($.isNumeric(charFollowingLastLineBreak)) {
  20567. var numBullet = this.getBulletNumber(priorNewlineIndex + 1);
  20568. if (numBullet) {
  20569. this.addNumberedBullet(enterIndex, numBullet);
  20570. }
  20571. }
  20572. break;
  20573. case 27: // escape
  20574. if (this.$isFullscreen) this.setFullscreen(false);
  20575. blocked = false;
  20576. break;
  20577. default:
  20578. blocked = false;
  20579. }
  20580. if (blocked) {
  20581. e.stopPropagation();
  20582. e.preventDefault();
  20583. }
  20584. this.$options.onChange(this);
  20585. },
  20586. insertContent: function(index, content) {
  20587. var firstHalf = this.getContent().slice(0, index);
  20588. var secondHalf = this.getContent().slice(index + 1);
  20589. this.setContent(firstHalf.concat(content).concat(secondHalf));
  20590. },
  20591. addBullet: function(index) {
  20592. this.insertContent(index, '- \n');
  20593. this.setSelection(index + 2, index + 2); // Put the cursor after the bullet
  20594. },
  20595. addNumberedBullet: function(index, num) {
  20596. var numBullet = (num + 1) + '. \n';
  20597. this.insertContent(index, numBullet);
  20598. var prefixLength = num.toString().length + 2;
  20599. this.setSelection(index + prefixLength, index + prefixLength); // Put the cursor after the number
  20600. },
  20601. getBulletNumber: function(startIndex) {
  20602. var bulletNum = this.getContent().slice(startIndex).split('.')[0];
  20603. return $.isNumeric(bulletNum) ? parseInt(bulletNum) : null;
  20604. },
  20605. change: function(e) {
  20606. this.$options.onChange(this);
  20607. return this;
  20608. },
  20609. select: function(e) {
  20610. this.$options.onSelect(this);
  20611. return this;
  20612. },
  20613. focus: function(e) {
  20614. var options = this.$options,
  20615. isHideable = options.hideable,
  20616. editor = this.$editor;
  20617. editor.addClass('active');
  20618. // Blur other markdown(s)
  20619. $(document).find('.md-editor').each(function() {
  20620. if ($(this).attr('id') !== editor.attr('id')) {
  20621. var attachedMarkdown;
  20622. if (attachedMarkdown = $(this).find('textarea').data('markdown'),
  20623. attachedMarkdown === null) {
  20624. attachedMarkdown = $(this).find('div[data-provider="markdown-preview"]').data('markdown');
  20625. }
  20626. if (attachedMarkdown) {
  20627. attachedMarkdown.blur();
  20628. }
  20629. }
  20630. });
  20631. // Trigger the onFocus hook
  20632. options.onFocus(this);
  20633. return this;
  20634. },
  20635. blur: function(e) {
  20636. var options = this.$options,
  20637. isHideable = options.hideable,
  20638. editor = this.$editor,
  20639. editable = this.$editable;
  20640. if (editor.hasClass('active') || this.$element.parent().length === 0) {
  20641. editor.removeClass('active');
  20642. if (isHideable) {
  20643. // Check for editable elements
  20644. if (editable.el !== null) {
  20645. // Build the original element
  20646. var oldElement = $('<' + editable.type + '/>'),
  20647. content = this.getContent(),
  20648. currentContent = this.parseContent(content);
  20649. $(editable.attrKeys).each(function(k, v) {
  20650. oldElement.attr(editable.attrKeys[k], editable.attrValues[k]);
  20651. });
  20652. // Get the editor content
  20653. oldElement.html(currentContent);
  20654. editor.replaceWith(oldElement);
  20655. } else {
  20656. editor.hide();
  20657. }
  20658. }
  20659. // Trigger the onBlur hook
  20660. options.onBlur(this);
  20661. }
  20662. return this;
  20663. }
  20664. };
  20665. /* MARKDOWN PLUGIN DEFINITION
  20666. * ========================== */
  20667. var old = $.fn.markdown;
  20668. $.fn.markdown = function(option) {
  20669. return this.each(function() {
  20670. var $this = $(this),
  20671. data = $this.data('markdown'),
  20672. options = typeof option == 'object' && option;
  20673. if (!data)
  20674. $this.data('markdown', (data = new Markdown(this, options)));
  20675. });
  20676. };
  20677. $.fn.markdown.messages = {};
  20678. $.fn.markdown.defaults = {
  20679. /* Editor Properties */
  20680. autofocus: false,
  20681. hideable: false,
  20682. savable: false,
  20683. width: 'inherit',
  20684. height: 'inherit',
  20685. resize: 'none',
  20686. iconlibrary: 'glyph',
  20687. language: 'en',
  20688. initialstate: 'editor',
  20689. parser: null,
  20690. dropZoneOptions: null,
  20691. enableDropDataUri: false,
  20692. /* Buttons Properties */
  20693. buttons: [
  20694. [{
  20695. name: 'groupFont',
  20696. data: [{
  20697. name: 'cmdBold',
  20698. hotkey: 'Ctrl+B',
  20699. title: 'Bold',
  20700. icon: {
  20701. glyph: 'glyphicon glyphicon-bold',
  20702. fa: 'fa fa-bold',
  20703. 'fa-3': 'icon-bold',
  20704. 'fa-5': 'fas fa-bold',
  20705. octicons: 'octicon octicon-bold'
  20706. },
  20707. callback: function(e) {
  20708. // Give/remove ** surround the selection
  20709. var chunk, cursor, selected = e.getSelection(),
  20710. content = e.getContent();
  20711. if (selected.length === 0) {
  20712. // Give extra word
  20713. chunk = e.__localize('strong text');
  20714. } else {
  20715. chunk = selected.text;
  20716. }
  20717. // transform selection and set the cursor into chunked text
  20718. if (content.substr(selected.start - 2, 2) === '**' &&
  20719. content.substr(selected.end, 2) === '**') {
  20720. e.setSelection(selected.start - 2, selected.end + 2);
  20721. e.replaceSelection(chunk);
  20722. cursor = selected.start - 2;
  20723. } else {
  20724. e.replaceSelection('**' + chunk + '**');
  20725. cursor = selected.start + 2;
  20726. }
  20727. // Set the cursor
  20728. e.setSelection(cursor, cursor + chunk.length);
  20729. }
  20730. }, {
  20731. name: 'cmdItalic',
  20732. title: 'Italic',
  20733. hotkey: 'Ctrl+I',
  20734. icon: {
  20735. glyph: 'glyphicon glyphicon-italic',
  20736. fa: 'fa fa-italic',
  20737. 'fa-3': 'icon-italic',
  20738. 'fa-5': 'fas fa-italic',
  20739. octicons: 'octicon octicon-italic'
  20740. },
  20741. callback: function(e) {
  20742. // Give/remove * surround the selection
  20743. var chunk, cursor, selected = e.getSelection(),
  20744. content = e.getContent();
  20745. if (selected.length === 0) {
  20746. // Give extra word
  20747. chunk = e.__localize('emphasized text');
  20748. } else {
  20749. chunk = selected.text;
  20750. }
  20751. // transform selection and set the cursor into chunked text
  20752. if (content.substr(selected.start - 1, 1) === '_' &&
  20753. content.substr(selected.end, 1) === '_') {
  20754. e.setSelection(selected.start - 1, selected.end + 1);
  20755. e.replaceSelection(chunk);
  20756. cursor = selected.start - 1;
  20757. } else {
  20758. e.replaceSelection('_' + chunk + '_');
  20759. cursor = selected.start + 1;
  20760. }
  20761. // Set the cursor
  20762. e.setSelection(cursor, cursor + chunk.length);
  20763. }
  20764. }, {
  20765. name: 'cmdHeading',
  20766. title: 'Heading',
  20767. hotkey: 'Ctrl+H',
  20768. icon: {
  20769. glyph: 'glyphicon glyphicon-header',
  20770. fa: 'fa fa-header',
  20771. 'fa-3': 'icon-font',
  20772. 'fa-5': 'fas fa-heading',
  20773. octicons: 'octicon octicon-text-size'
  20774. },
  20775. callback: function(e) {
  20776. // Append/remove ### surround the selection
  20777. var chunk, cursor, selected = e.getSelection(),
  20778. content = e.getContent(),
  20779. pointer, prevChar;
  20780. if (selected.length === 0) {
  20781. // Give extra word
  20782. chunk = e.__localize('heading text');
  20783. } else {
  20784. chunk = selected.text + '\n';
  20785. }
  20786. // transform selection and set the cursor into chunked text
  20787. if ((pointer = 4, content.substr(selected.start - pointer, pointer) === '### ') ||
  20788. (pointer = 3, content.substr(selected.start - pointer, pointer) === '###')) {
  20789. e.setSelection(selected.start - pointer, selected.end);
  20790. e.replaceSelection(chunk);
  20791. cursor = selected.start - pointer;
  20792. } else if (selected.start > 0 && (prevChar = content.substr(selected.start - 1, 1), !!prevChar && prevChar != '\n')) {
  20793. e.replaceSelection('\n\n### ' + chunk);
  20794. cursor = selected.start + 6;
  20795. } else {
  20796. // Empty string before element
  20797. e.replaceSelection('### ' + chunk);
  20798. cursor = selected.start + 4;
  20799. }
  20800. // Set the cursor
  20801. e.setSelection(cursor, cursor + chunk.length);
  20802. }
  20803. }]
  20804. }, {
  20805. name: 'groupLink',
  20806. data: [{
  20807. name: 'cmdUrl',
  20808. title: 'URL/Link',
  20809. hotkey: 'Ctrl+L',
  20810. icon: {
  20811. glyph: 'glyphicon glyphicon-link',
  20812. fa: 'fa fa-link',
  20813. 'fa-3': 'icon-link',
  20814. 'fa-5': 'fas fa-link',
  20815. octicons: 'octicon octicon-link'
  20816. },
  20817. callback: function(e) {
  20818. // Give [] surround the selection and prepend the link
  20819. var chunk, cursor, selected = e.getSelection(),
  20820. content = e.getContent(),
  20821. link;
  20822. if (selected.length === 0) {
  20823. // Give extra word
  20824. chunk = e.__localize('enter link description here');
  20825. } else {
  20826. chunk = selected.text;
  20827. }
  20828. link = prompt(e.__localize('Insert Hyperlink'), 'http://');
  20829. var urlRegex = new RegExp('^((http|https)://|(mailto:)|(//))[a-z0-9]', 'i');
  20830. if (link !== null && link !== '' && link !== 'http://' && urlRegex.test(link)) {
  20831. // transform selection and set the cursor into chunked text
  20832. e.replaceSelection('[' + chunk + '](' + link + ')');
  20833. cursor = selected.start + 1;
  20834. // Set the cursor
  20835. e.setSelection(cursor, cursor + chunk.length);
  20836. }
  20837. }
  20838. }, {
  20839. name: 'cmdImage',
  20840. title: 'Image',
  20841. hotkey: 'Ctrl+G',
  20842. icon: {
  20843. glyph: 'glyphicon glyphicon-picture',
  20844. fa: 'fa fa-picture-o',
  20845. 'fa-3': 'icon-picture',
  20846. 'fa-5': 'far fa-image',
  20847. octicons: 'octicon octicon-file-media'
  20848. },
  20849. callback: function(e) {
  20850. // Give ![] surround the selection and prepend the image link
  20851. var chunk, cursor, selected = e.getSelection(),
  20852. content = e.getContent(),
  20853. link;
  20854. if (selected.length === 0) {
  20855. // Give extra word
  20856. chunk = e.__localize('enter image description here');
  20857. } else {
  20858. chunk = selected.text;
  20859. }
  20860. link = prompt(e.__localize('Insert Image Hyperlink'), 'http://');
  20861. var urlRegex = new RegExp('^((http|https)://|(//))[a-z0-9]', 'i');
  20862. if (link !== null && link !== '' && link !== 'http://' && urlRegex.test(link)) {
  20863. var sanitizedLink = $('<div>' + link + '</div>').text();
  20864. // transform selection and set the cursor into chunked text
  20865. e.replaceSelection('![' + chunk + '](' + sanitizedLink + ' "' + e.__localize('enter image title here') + '")');
  20866. cursor = selected.start + 2;
  20867. // Set the next tab
  20868. e.setNextTab(e.__localize('enter image title here'));
  20869. // Set the cursor
  20870. e.setSelection(cursor, cursor + chunk.length);
  20871. }
  20872. }
  20873. }]
  20874. }, {
  20875. name: 'groupMisc',
  20876. data: [{
  20877. name: 'cmdList',
  20878. hotkey: 'Ctrl+U',
  20879. title: 'Unordered List',
  20880. icon: {
  20881. glyph: 'glyphicon glyphicon-list',
  20882. fa: 'fa fa-list',
  20883. 'fa-3': 'icon-list-ul',
  20884. 'fa-5': 'fas fa-list-ul',
  20885. octicons: 'octicon octicon-list-unordered'
  20886. },
  20887. callback: function(e) {
  20888. // Prepend/Give - surround the selection
  20889. var chunk, cursor, selected = e.getSelection(),
  20890. content = e.getContent();
  20891. // transform selection and set the cursor into chunked text
  20892. if (selected.length === 0) {
  20893. // Give extra word
  20894. chunk = e.__localize('list text here');
  20895. e.replaceSelection('- ' + chunk);
  20896. // Set the cursor
  20897. cursor = selected.start + 2;
  20898. } else {
  20899. if (selected.text.indexOf('\n') < 0) {
  20900. chunk = selected.text;
  20901. e.replaceSelection('- ' + chunk);
  20902. // Set the cursor
  20903. cursor = selected.start + 2;
  20904. } else {
  20905. var list = [];
  20906. list = selected.text.split('\n');
  20907. chunk = list[0];
  20908. $.each(list, function(k, v) {
  20909. list[k] = '- ' + v;
  20910. });
  20911. e.replaceSelection('\n\n' + list.join('\n'));
  20912. // Set the cursor
  20913. cursor = selected.start + 4;
  20914. }
  20915. }
  20916. // Set the cursor
  20917. e.setSelection(cursor, cursor + chunk.length);
  20918. }
  20919. }, {
  20920. name: 'cmdListO',
  20921. hotkey: 'Ctrl+O',
  20922. title: 'Ordered List',
  20923. icon: {
  20924. glyph: 'glyphicon glyphicon-th-list',
  20925. fa: 'fa fa-list-ol',
  20926. 'fa-3': 'icon-list-ol',
  20927. 'fa-5': 'fas fa-list-ol',
  20928. octicons: 'octicon octicon-list-ordered'
  20929. },
  20930. callback: function(e) {
  20931. // Prepend/Give - surround the selection
  20932. var chunk, cursor, selected = e.getSelection(),
  20933. content = e.getContent();
  20934. // transform selection and set the cursor into chunked text
  20935. if (selected.length === 0) {
  20936. // Give extra word
  20937. chunk = e.__localize('list text here');
  20938. e.replaceSelection('1. ' + chunk);
  20939. // Set the cursor
  20940. cursor = selected.start + 3;
  20941. } else {
  20942. if (selected.text.indexOf('\n') < 0) {
  20943. chunk = selected.text;
  20944. e.replaceSelection('1. ' + chunk);
  20945. // Set the cursor
  20946. cursor = selected.start + 3;
  20947. } else {
  20948. var i = 1;
  20949. var list = [];
  20950. list = selected.text.split('\n');
  20951. chunk = list[0];
  20952. $.each(list, function(k, v) {
  20953. list[k] = i + '. ' + v;
  20954. i++;
  20955. });
  20956. e.replaceSelection('\n\n' + list.join('\n'));
  20957. // Set the cursor
  20958. cursor = selected.start + 5;
  20959. }
  20960. }
  20961. // Set the cursor
  20962. e.setSelection(cursor, cursor + chunk.length);
  20963. }
  20964. }, {
  20965. name: 'cmdCode',
  20966. hotkey: 'Ctrl+K',
  20967. title: 'Code',
  20968. icon: {
  20969. glyph: 'glyphicon glyphicon-console',
  20970. fa: 'fa fa-code',
  20971. 'fa-3': 'icon-code',
  20972. 'fa-5': 'fas fa-code',
  20973. octicons: 'octicon octicon-code'
  20974. },
  20975. callback: function(e) {
  20976. // Give/remove ** surround the selection
  20977. var chunk, cursor, selected = e.getSelection(),
  20978. content = e.getContent();
  20979. if (selected.length === 0) {
  20980. // Give extra word
  20981. chunk = e.__localize('code text here');
  20982. } else {
  20983. chunk = selected.text;
  20984. }
  20985. // transform selection and set the cursor into chunked text
  20986. if (content.substr(selected.start - 4, 4) === '```\n' &&
  20987. content.substr(selected.end, 4) === '\n```') {
  20988. e.setSelection(selected.start - 4, selected.end + 4);
  20989. e.replaceSelection(chunk);
  20990. cursor = selected.start - 4;
  20991. } else if (content.substr(selected.start - 1, 1) === '`' &&
  20992. content.substr(selected.end, 1) === '`') {
  20993. e.setSelection(selected.start - 1, selected.end + 1);
  20994. e.replaceSelection(chunk);
  20995. cursor = selected.start - 1;
  20996. } else if (content.indexOf('\n') > -1) {
  20997. e.replaceSelection('```\n' + chunk + '\n```');
  20998. cursor = selected.start + 4;
  20999. } else {
  21000. e.replaceSelection('`' + chunk + '`');
  21001. cursor = selected.start + 1;
  21002. }
  21003. // Set the cursor
  21004. e.setSelection(cursor, cursor + chunk.length);
  21005. }
  21006. }, {
  21007. name: 'cmdQuote',
  21008. hotkey: 'Ctrl+Q',
  21009. title: 'Quote',
  21010. icon: {
  21011. glyph: 'glyphicon glyphicon-comment',
  21012. fa: 'fa fa-quote-left',
  21013. 'fa-3': 'icon-quote-left',
  21014. 'fa-5': 'fas fa-quote-left',
  21015. octicons: 'octicon octicon-quote'
  21016. },
  21017. callback: function(e) {
  21018. // Prepend/Give - surround the selection
  21019. var chunk, cursor, selected = e.getSelection(),
  21020. content = e.getContent();
  21021. // transform selection and set the cursor into chunked text
  21022. if (selected.length === 0) {
  21023. // Give extra word
  21024. chunk = e.__localize('quote here');
  21025. e.replaceSelection('> ' + chunk);
  21026. // Set the cursor
  21027. cursor = selected.start + 2;
  21028. } else {
  21029. if (selected.text.indexOf('\n') < 0) {
  21030. chunk = selected.text;
  21031. e.replaceSelection('> ' + chunk);
  21032. // Set the cursor
  21033. cursor = selected.start + 2;
  21034. } else {
  21035. var list = [];
  21036. list = selected.text.split('\n');
  21037. chunk = list[0];
  21038. $.each(list, function(k, v) {
  21039. list[k] = '> ' + v;
  21040. });
  21041. e.replaceSelection('\n\n' + list.join('\n'));
  21042. // Set the cursor
  21043. cursor = selected.start + 4;
  21044. }
  21045. }
  21046. // Set the cursor
  21047. e.setSelection(cursor, cursor + chunk.length);
  21048. }
  21049. }]
  21050. }, {
  21051. name: 'groupUtil',
  21052. data: [{
  21053. name: 'cmdPreview',
  21054. toggle: true,
  21055. hotkey: 'Ctrl+P',
  21056. title: 'Preview',
  21057. btnText: 'Preview',
  21058. btnClass: 'btn btn-primary btn-sm',
  21059. icon: {
  21060. glyph: 'glyphicon glyphicon-search',
  21061. fa: 'fa fa-search',
  21062. 'fa-3': 'icon-search',
  21063. 'fa-5': 'fas fa-search',
  21064. octicons: 'octicon octicon-search'
  21065. },
  21066. callback: function(e) {
  21067. // Check the preview mode and toggle based on this flag
  21068. var isPreview = e.$isPreview,
  21069. content;
  21070. if (isPreview === false) {
  21071. // Give flag that tells the editor to enter preview mode
  21072. e.showPreview();
  21073. } else {
  21074. e.hidePreview();
  21075. }
  21076. }
  21077. }]
  21078. }]
  21079. ],
  21080. customIcons: {},
  21081. additionalButtons: [], // Place to hook more buttons by code
  21082. reorderButtonGroups: [],
  21083. hiddenButtons: [], // Default hidden buttons
  21084. disabledButtons: [], // Default disabled buttons
  21085. footer: '',
  21086. fullscreen: {
  21087. enable: true,
  21088. icons: {
  21089. fullscreenOn: {
  21090. name: "fullscreenOn",
  21091. icon: {
  21092. fa: 'fa fa-expand',
  21093. glyph: 'glyphicon glyphicon-fullscreen',
  21094. 'fa-3': 'icon-resize-full',
  21095. 'fa-5': 'fas fa-expand-arrows-alt',
  21096. octicons: 'octicon octicon-link-external'
  21097. }
  21098. },
  21099. fullscreenOff: {
  21100. name: "fullscreenOff",
  21101. icon: {
  21102. fa: 'fa fa-compress',
  21103. glyph: 'glyphicon glyphicon-fullscreen',
  21104. 'fa-3': 'icon-resize-small',
  21105. 'fa-5': 'fas fa-compress',
  21106. octicons: 'octicon octicon-browser'
  21107. }
  21108. }
  21109. }
  21110. },
  21111. /* Events hook */
  21112. onShow: function(e) {},
  21113. onPreview: function(e) {},
  21114. onPreviewEnd: function(e) {},
  21115. onSave: function(e) {},
  21116. onBlur: function(e) {},
  21117. onFocus: function(e) {},
  21118. onChange: function(e) {},
  21119. onFullscreen: function(e) {},
  21120. onFullscreenExit: function(e) {},
  21121. onSelect: function(e) {}
  21122. };
  21123. $.fn.markdown.Constructor = Markdown;
  21124. /* MARKDOWN NO CONFLICT
  21125. * ==================== */
  21126. $.fn.markdown.noConflict = function() {
  21127. $.fn.markdown = old;
  21128. return this;
  21129. };
  21130. /* MARKDOWN GLOBAL FUNCTION & DATA-API
  21131. * ==================================== */
  21132. var initMarkdown = function(el) {
  21133. var $this = el;
  21134. if ($this.data('markdown')) {
  21135. $this.data('markdown').showEditor();
  21136. return;
  21137. }
  21138. $this.markdown();
  21139. };
  21140. var blurNonFocused = function(e) {
  21141. var $activeElement = $(document.activeElement);
  21142. // Blur event
  21143. $(document).find('.md-editor').each(function() {
  21144. var $this = $(this),
  21145. focused = $activeElement.closest('.md-editor')[0] === this,
  21146. attachedMarkdown = $this.find('textarea').data('markdown') ||
  21147. $this.find('div[data-provider="markdown-preview"]').data('markdown');
  21148. if (attachedMarkdown && !focused) {
  21149. attachedMarkdown.blur();
  21150. }
  21151. });
  21152. };
  21153. $(document)
  21154. .on('click.markdown.data-api', '[data-provide="markdown-editable"]', function(e) {
  21155. initMarkdown($(this));
  21156. e.preventDefault();
  21157. })
  21158. .on('click focusin', function(e) {
  21159. blurNonFocused(e);
  21160. })
  21161. .ready(function() {
  21162. $('textarea[data-provide="markdown"]').each(function() {
  21163. initMarkdown($(this));
  21164. });
  21165. });
  21166. }));
  21167. /*
  21168. * Arabic translation for bootstrap-markdown
  21169. * George Ajam <george.ejaam@gmail.com>
  21170. */
  21171. (function ($) {
  21172. $.fn.markdown.messages.nl = {
  21173. 'Bold': "غامق",
  21174. 'Italic': "مائل",
  21175. 'Heading': "عنوان",
  21176. 'URL/Link': "URL/رابط",
  21177. 'Image': "صورة",
  21178. 'List': "قائمة",
  21179. 'Preview': "استعراض",
  21180. 'strong text': "نص غامق",
  21181. 'emphasized text': "نص هام",
  21182. 'heading text': "العنوان",
  21183. 'enter link description here': "ادخل وصف الرابط هنا",
  21184. 'Insert Hyperlink': "ادخل الرابط هنا",
  21185. 'enter image description here': "ادخل وصف الصورة هنا",
  21186. 'Insert Image Hyperlink': "ادخل رابط الصورة هنا",
  21187. 'enter image title here': "ادخل عنوان الصورة هنا",
  21188. 'list text here': "اكتب النص هنا"
  21189. };
  21190. }(jQuery));
  21191. /**
  21192. * Czech translation for bootstrap-markdown
  21193. * Vít Kabele <vit@kabele.me>
  21194. */
  21195. (function ($) {
  21196. $.fn.markdown.messages.cs = {
  21197. 'Bold': "Tučně",
  21198. 'Italic': "Kurzíva",
  21199. 'Heading': "Nadpis",
  21200. 'URL/Link': "URL/Odkaz",
  21201. 'Image': "Obrázek",
  21202. 'Unordered List': "Seznam",
  21203. 'Ordered List': "Seřazený seznam",
  21204. 'Code': "Úsek kódu",
  21205. 'Quote': "Citace",
  21206. 'Preview': "Náhled",
  21207. 'strong text': "tučný text",
  21208. 'emphasized text': "zdůrazněný text",
  21209. 'heading text': "text nadpisu",
  21210. 'enter link description here': "sem vlož popis odkazu",
  21211. 'Insert Hyperlink': "Vložit Hyperlink",
  21212. 'enter image description here': "sem vlož popis obrázku",
  21213. 'Insert Image Hyperlink': "Vlož adresu obrázku",
  21214. 'enter image title here': "sem vlož popis obrázku",
  21215. 'list text here': "položka seznamu"
  21216. };
  21217. }(jQuery));
  21218. /**
  21219. * Danish translation for bootstrap-markdown
  21220. * Dan Storm <storm@catalystcode.net>
  21221. */
  21222. (function ($) {
  21223. $.fn.markdown.messages.da = {
  21224. 'Bold': 'Fed',
  21225. 'Italic': 'Kursiv',
  21226. 'Heading': 'Overskrift',
  21227. 'URL/Link': 'URL/Link',
  21228. 'Image': 'Billede',
  21229. 'List': 'Liste',
  21230. 'Preview': 'Forhåndsvisning',
  21231. 'strong text': 'stærk tekst',
  21232. 'emphasized text': 'fremhævet tekst',
  21233. 'heading text': 'overskrift tekst',
  21234. 'enter link description here': 'Skriv link beskrivelse her',
  21235. 'Insert Hyperlink': 'Indsæt link',
  21236. 'enter image description here': 'Indsæt billede beskrivelse her',
  21237. 'Insert Image Hyperlink': 'Indsæt billede link',
  21238. 'enter image title here': 'Indsæt billede titel',
  21239. 'list text here': 'Indsæt liste tekst her',
  21240. 'quote here': 'Indsæt citat her',
  21241. 'code text here': 'Indsæt kode her'
  21242. };
  21243. }(jQuery));
  21244. /**
  21245. * German translation for bootstrap-markdown
  21246. * Tobias Nitsche <tobias-nitsche@gmx.net>
  21247. */
  21248. (function ($) {
  21249. $.fn.markdown.messages.de = {
  21250. 'Bold': "Fett",
  21251. 'Italic': "Kursiv",
  21252. 'Heading': "Überschrift",
  21253. 'URL/Link': "Link hinzufügen",
  21254. 'Image': "Bild hinzufügen",
  21255. 'Unordered List': "Unnummerierte Liste",
  21256. 'Ordered List': "Nummerierte Liste",
  21257. 'Code': "Quelltext",
  21258. 'code text here': "Quelltext hier einfügen",
  21259. 'Quote': "Zitat",
  21260. 'quote here': "Zitat hier einfügen",
  21261. 'Preview': "Vorschau",
  21262. 'Save': "Speichern",
  21263. 'strong text': "Sehr betonter Text",
  21264. 'emphasized text': "Betonter Text",
  21265. 'heading text': "Überschrift Text",
  21266. 'enter link description here': "Linkbeschreibung",
  21267. 'Insert Hyperlink': "URL",
  21268. 'enter image description here': "Bildbeschreibung",
  21269. 'Insert Image Hyperlink': "Bild-URL",
  21270. 'enter image title here': "Titel des Bildes",
  21271. 'list text here': "Aufzählungs-Text"
  21272. };
  21273. }(jQuery));
  21274. /**
  21275. * Spanish translation for bootstrap-markdown
  21276. * by Leandro Poblet <leandrodrhouse@gmail.com>
  21277. */
  21278. (function ($) {
  21279. $.fn.markdown.messages.es = {
  21280. 'Bold': "Negrita",
  21281. 'Italic': "Itálica",
  21282. 'Heading': "Título",
  21283. 'URL/Link': "Inserte un link",
  21284. 'Image': "Inserte una imagen",
  21285. 'List': "Lista de items",
  21286. 'Unordered List': "Lista desordenada",
  21287. 'Ordered List': "Lista ordenada",
  21288. 'Code': "Código",
  21289. 'Quote': "Cita",
  21290. 'Preview': "Previsualizar",
  21291. 'strong text': "Texto importante",
  21292. 'emphasized text': "Texto con énfasis",
  21293. 'heading text': "Texto de título",
  21294. 'enter link description here': "Descripción del link",
  21295. 'Insert Hyperlink': "Inserte un hipervínculo",
  21296. 'enter image description here': "Descripción de la imagen",
  21297. 'Insert Image Hyperlink': "Inserte una imagen con un hipervínculo",
  21298. 'enter image title here': "Inserte una imagen con título",
  21299. 'list text here': "Texto de lista aquí",
  21300. 'code text here': "Código aquí",
  21301. 'quote here': "Cita aquí",
  21302. 'Save': "Guardar"
  21303. };
  21304. }(jQuery));
  21305. /**
  21306. * Persian(Farsi) translation for bootstrap-markdown
  21307. * Sajad Dehshiri <Pelakweb.ir>
  21308. */
  21309. (function ($) {
  21310. $.fn.markdown.messages.fa = {
  21311. 'Bold': "توپر",
  21312. 'Italic': "مورب",
  21313. 'Heading': "عنوان",
  21314. 'URL/Link': "پیوند",
  21315. 'Image': "تصویر",
  21316. 'List': "فهرست",
  21317. 'Preview': "پیش نمایش",
  21318. 'strong text': "متن ضخیم",
  21319. 'emphasized text': "نوشته تاکیدی",
  21320. 'heading text': "عنوان",
  21321. 'enter link description here': "توضیحات پیوند را بنویسید.",
  21322. 'Insert Hyperlink': "پیوند را درج نمایید:",
  21323. 'enter image description here': "توضیحی برای تصوی بنویسید.",
  21324. 'Insert Image Hyperlink': "آدرس تصویر را بنویسید.",
  21325. 'enter image title here': "عنوان تصویر را اینجا بنویسید",
  21326. 'list text here': "محل متن فهرست"
  21327. };
  21328. }(jQuery));
  21329. /**
  21330. * French translation for bootstrap-markdown
  21331. * Benoît Bourgeois <bierdok@gmail.com>
  21332. */
  21333. (function ($) {
  21334. $.fn.markdown.messages.fr = {
  21335. 'Bold': "Gras",
  21336. 'Italic': "Italique",
  21337. 'Heading': "Titre",
  21338. 'URL/Link': "Insérer un lien HTTP",
  21339. 'Image': "Insérer une image",
  21340. 'List': "Liste à puces",
  21341. 'Preview': "Prévisualiser",
  21342. 'strong text': "texte important",
  21343. 'emphasized text': "texte en italique",
  21344. 'heading text': "texte d'entête",
  21345. 'enter link description here': "entrez la description du lien ici",
  21346. 'Insert Hyperlink': "Insérez le lien hypertexte",
  21347. 'enter image description here': "entrez la description de l'image ici",
  21348. 'Insert Image Hyperlink': "Insérez le lien hypertexte de l'image",
  21349. 'enter image title here': "entrez le titre de l'image ici",
  21350. 'list text here': "texte à puce ici",
  21351. 'Save': "Sauvegarder",
  21352. 'Ordered List': "Liste ordonnée",
  21353. 'Unordered List': "Liste désordonnée",
  21354. 'Quote': "Citation",
  21355. 'quote here': "Votre citation",
  21356. 'Code': "Code",
  21357. 'code text here': "écrire du code ici"
  21358. };
  21359. }(jQuery));
  21360. /**
  21361. * Japanese translation for bootstrap-markdown
  21362. * Kenta Murakami <kntmrkm@gmail.com>
  21363. */
  21364. (function ($) {
  21365. $.fn.markdown.messages.ja = {
  21366. 'Bold': "太字",
  21367. 'Italic': "斜体",
  21368. 'Heading': "見出し",
  21369. 'URL/Link': "リンク",
  21370. 'Image': "画像",
  21371. 'Unordered List': "リスト",
  21372. 'Ordered List': "数字リスト",
  21373. 'Code': "コード",
  21374. 'Quote': "引用",
  21375. 'Preview': "プレビュー",
  21376. 'strong text': "太字",
  21377. 'emphasized text': "強調",
  21378. 'heading text': "見出し",
  21379. 'enter link description here': "リンク説明",
  21380. 'Insert Hyperlink': "リンク挿入",
  21381. 'enter image description here': "画像説明",
  21382. 'Insert Image Hyperlink': "画像挿入",
  21383. 'enter image title here': "画像タイトル",
  21384. 'list text here': "リスト挿入",
  21385. 'code text here': "コード",
  21386. 'quote here': "引用挿入"
  21387. };
  21388. }(jQuery));
  21389. /**
  21390. + * Korean translation for bootstrap-markdown
  21391. + * WoongBi Kim <ssinss@gmail.com>
  21392. + */
  21393. (function ($) {
  21394. $.fn.markdown.messages.kr = {
  21395. 'Bold': "진하게",
  21396. 'Italic': "이탤릭체",
  21397. 'Heading': "머리글",
  21398. 'URL/Link': "링크주소",
  21399. 'Image': "이미지",
  21400. 'List': "리스트",
  21401. 'Preview': "미리보기",
  21402. 'strong text': "강한 강조 텍스트",
  21403. 'emphasized text': "강조 텍스트",
  21404. 'heading text': "머리글 텍스트",
  21405. 'enter link description here': "여기에 링크의 설명을 적으세요",
  21406. 'Insert Hyperlink': "하이퍼링크 삽입",
  21407. 'enter image description here': "여기세 이미지 설명을 적으세요",
  21408. 'Insert Image Hyperlink': "이미지 링크 삽입",
  21409. 'enter image title here': "여기에 이미지 제목을 적으세요",
  21410. 'list text here': "리스트 텍스트"
  21411. };
  21412. }(jQuery));
  21413. /**
  21414. * Norwegian bokmål translation for bootstrap-markdown
  21415. * Tobias Bohwalli <hi@futhr.io>
  21416. */
  21417. (function ($) {
  21418. $.fn.markdown.messages.nb = {
  21419. 'Bold': 'Fet',
  21420. 'Italic': 'Kursiv',
  21421. 'Heading': 'Overskrift',
  21422. 'URL/Link': 'URL/Lenke',
  21423. 'Image': 'Bilde',
  21424. 'List': 'Liste',
  21425. 'Preview': 'Forhåndsvisning',
  21426. 'strong text': 'sterk tekst',
  21427. 'emphasized text': 'streket tekst',
  21428. 'heading text': 'overskriften tekst',
  21429. 'enter link description here': 'Skriv linken beskrivelse her',
  21430. 'Insert Hyperlink': 'Sett inn lenke',
  21431. 'enter image description here': 'Angi bildebeskrivelse her',
  21432. 'Insert Image Hyperlink': 'Sett inn lenke for bilde',
  21433. 'enter image title here': 'Angi bildetittel her',
  21434. 'list text here': 'liste tekst her'
  21435. };
  21436. }(jQuery));
  21437. /**
  21438. * Dutch translation for bootstrap-markdown
  21439. * Jeroen Thora <jeroenthora@gmail.com>
  21440. */
  21441. (function ($) {
  21442. $.fn.markdown.messages.nl = {
  21443. 'Bold': "Vet",
  21444. 'Italic': "Cursief",
  21445. 'Heading': "Titel",
  21446. 'URL/Link': "URL/Link",
  21447. 'Image': "Afbeelding",
  21448. 'List': "Lijst",
  21449. 'Preview': "Voorbeeld",
  21450. 'strong text': "vet gedrukte tekst",
  21451. 'emphasized text': "schuin gedrukte tekst",
  21452. 'heading text': "Titel",
  21453. 'enter link description here': "Voer een link beschrijving in",
  21454. 'Insert Hyperlink': "Voer een http link in",
  21455. 'enter image description here': "Voer een afbeelding beschrijving in",
  21456. 'Insert Image Hyperlink': "Voer een afbeelding link in",
  21457. 'enter image title here': "Voer de afbeelding titel in",
  21458. 'list text here': "lijst item"
  21459. };
  21460. }(jQuery));
  21461. /**
  21462. * Polish translation for bootstrap-markdown
  21463. * Marek Kaput
  21464. */
  21465. (function ($) {
  21466. $.fn.markdown.messages.pl = {
  21467. 'Bold': "Pogrubienie",
  21468. 'Italic': "Kursywa",
  21469. 'Heading': "Nagłówek",
  21470. 'URL/Link': "Wstaw link",
  21471. 'Image': "Wstaw obrazek",
  21472. 'Unordered List': "Lista punktowana",
  21473. 'Ordered List': "Lista numerowana",
  21474. 'Code': "Kod źródłowy",
  21475. 'Quote': "Cytat",
  21476. 'Preview': "Podgląd",
  21477. 'strong text': "pogrubiony tekst",
  21478. 'emphasized text': "pochylony tekst",
  21479. 'heading text': "nagłówek",
  21480. 'enter link description here': "opis linka",
  21481. 'Insert Hyperlink': "Wstaw link",
  21482. 'enter image description here': "opis obrazka",
  21483. 'Insert Image Hyperlink': "Wstaw obrazek",
  21484. 'enter image title here': "tytuł obrazka",
  21485. 'list text here': "lista"
  21486. };
  21487. }(jQuery));
  21488. /**
  21489. * Slovenian translation for bootstrap-markdown
  21490. * Davor Padovan <davor.padovan@gmail.com>
  21491. */
  21492. (function ($) {
  21493. $.fn.markdown.messages.sl = {
  21494. 'Bold': "Odebeljeno",
  21495. 'Italic': "Poševno",
  21496. 'Heading': "Naslov",
  21497. 'URL/Link': "Povezava",
  21498. 'Image': "Slika",
  21499. 'Unordered List': "Neurejen seznam",
  21500. 'Ordered List': "Urejen seznam",
  21501. 'Code': "Koda",
  21502. 'Quote': "Citat",
  21503. 'Preview': "Predogled",
  21504. 'strong text': "odebeljeno besedilo",
  21505. 'emphasized text': "poševno besedilo",
  21506. 'heading text': "naslov",
  21507. 'enter link description here': "opis povezave",
  21508. 'Insert Hyperlink': "Vstavi povezavo",
  21509. 'enter image description here': "opis slike",
  21510. 'Insert Image Hyperlink': "Vstavi povezavo do slike",
  21511. 'enter image title here': "naslov slike",
  21512. 'list text here': "seznam"
  21513. };
  21514. }(jQuery));
  21515. /**
  21516. * Swedish translation for bootstrap-markdown
  21517. * Tobias Bohwalli <hi@futhr.io>
  21518. */
  21519. (function ($) {
  21520. $.fn.markdown.messages.sv = {
  21521. 'Bold': 'Fet',
  21522. 'Italic': 'Kursiv',
  21523. 'Heading': 'Rubrik',
  21524. 'URL/Link': 'URL/Länk',
  21525. 'Image': 'Bild',
  21526. 'List': 'Lista',
  21527. 'Preview': 'Förhandsgranska',
  21528. 'strong text': 'fet text',
  21529. 'emphasized text': 'överstruken text',
  21530. 'heading text': 'Rubrik',
  21531. 'enter link description here': 'Ange länk beskrivning här',
  21532. 'Insert Hyperlink': 'Sätt in länk',
  21533. 'enter image description here': 'Ange bild beskrivning här',
  21534. 'Insert Image Hyperlink': 'Sätt in länk för bild',
  21535. 'enter image title here': 'Ange bild rubrik här',
  21536. 'list text here': 'list text'
  21537. };
  21538. }(jQuery));
  21539. /**
  21540. * Turkish translation for bootstrap-markdown
  21541. * Serkan Algur <info@wpadami.com>
  21542. */
  21543. (function ($) {
  21544. $.fn.markdown.messages.tr = {
  21545. 'Bold': "Kalın",
  21546. 'Italic': "İtalik",
  21547. 'Heading': "Başlık",
  21548. 'URL/Link': "Link ekle",
  21549. 'Image': "Resim ekle",
  21550. 'List': "Liste Oluşturun",
  21551. 'Preview': "Önizleme",
  21552. 'strong text': "kalın yazı",
  21553. 'emphasized text': "italik yazı",
  21554. 'heading text': "Başlık Yazısı",
  21555. 'enter link description here': "Link açıklamasını buraya girin",
  21556. 'Insert Hyperlink': "İnternet adresi girin",
  21557. 'enter image description here': "resim açıklamasını buraya ekleyin",
  21558. 'Insert Image Hyperlink': "Resim linkini ekleyin",
  21559. 'enter image title here': "resim başlığını buraya ekleyin",
  21560. 'list text here': "liste yazısı",
  21561. 'Save' : "Kaydet",
  21562. 'Ordered List' : "Numaralı Liste",
  21563. 'Unordered List' : "Madde imli liste",
  21564. 'Quote' : "Alıntı",
  21565. 'quote here' : "alıntıyı buraya ekleyin",
  21566. 'Code' : "Kod",
  21567. 'code text here' : "kodu buraya ekleyin"
  21568. };
  21569. }(jQuery));
  21570. /**
  21571. * Chinese translation for bootstrap-markdown
  21572. * benhaile <denghaier@163.com>
  21573. */
  21574. (function ($) {
  21575. $.fn.markdown.messages.zh = {
  21576. 'Bold': "粗体",
  21577. 'Italic': "斜体",
  21578. 'Heading': "标题",
  21579. 'URL/Link': "链接",
  21580. 'Image': "图片",
  21581. 'List': "列表",
  21582. 'Unordered List': "无序列表",
  21583. 'Ordered List': "有序列表",
  21584. 'Code': "代码",
  21585. 'Quote': "引用",
  21586. 'Preview': "预览",
  21587. 'strong text': "粗体",
  21588. 'emphasized text': "强调",
  21589. 'heading text': "标题",
  21590. 'enter link description here': "输入链接说明",
  21591. 'Insert Hyperlink': "URL地址",
  21592. 'enter image description here': "输入图片说明",
  21593. 'Insert Image Hyperlink': "图片URL地址",
  21594. 'enter image title here': "在这里输入图片标题",
  21595. 'list text here': "这里是列表文本",
  21596. 'code text here': "这里输入代码",
  21597. 'quote here': "这里输入引用文本"
  21598. };
  21599. }(jQuery));
  21600. /*! DataTables 1.10.12
  21601. * ©2008-2015 SpryMedia Ltd - datatables.net/license
  21602. */
  21603. /**
  21604. * @summary DataTables
  21605. * @description Paginate, search and order HTML tables
  21606. * @version 1.10.12
  21607. * @file jquery.dataTables.js
  21608. * @author SpryMedia Ltd (www.sprymedia.co.uk)
  21609. * @contact www.sprymedia.co.uk/contact
  21610. * @copyright Copyright 2008-2015 SpryMedia Ltd.
  21611. *
  21612. * This source file is free software, available under the following license:
  21613. * MIT license - http://datatables.net/license
  21614. *
  21615. * This source file is distributed in the hope that it will be useful, but
  21616. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  21617. * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
  21618. *
  21619. * For details please refer to: http://www.datatables.net
  21620. */
  21621. /*jslint evil: true, undef: true, browser: true */
  21622. /*globals $,require,jQuery,define,_selector_run,_selector_opts,_selector_first,_selector_row_indexes,_ext,_Api,_api_register,_api_registerPlural,_re_new_lines,_re_html,_re_formatted_numeric,_re_escape_regex,_empty,_intVal,_numToDecimal,_isNumber,_isHtml,_htmlNumeric,_pluck,_pluck_order,_range,_stripHtml,_unique,_fnBuildAjax,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnAjaxDataSrc,_fnAddColumn,_fnColumnOptions,_fnAdjustColumnSizing,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnVisbleColumns,_fnGetColumns,_fnColumnTypes,_fnApplyColumnDefs,_fnHungarianMap,_fnCamelToHungarian,_fnLanguageCompat,_fnBrowserDetect,_fnAddData,_fnAddTr,_fnNodeToDataIndex,_fnNodeToColumnIndex,_fnGetCellData,_fnSetCellData,_fnSplitObjNotation,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnGetDataMaster,_fnClearTable,_fnDeleteIndex,_fnInvalidate,_fnGetRowElements,_fnCreateTr,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAddOptionsHtml,_fnDetectHeader,_fnGetUniqueThs,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnFilterCreateSearch,_fnEscapeRegex,_fnFilterData,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnInfoMacros,_fnInitialise,_fnInitComplete,_fnLengthChange,_fnFeatureHtmlLength,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnFeatureHtmlTable,_fnScrollDraw,_fnApplyToChildren,_fnCalculateColumnWidths,_fnThrottle,_fnConvertToWidth,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnSortFlatten,_fnSort,_fnSortAria,_fnSortListener,_fnSortAttachListener,_fnSortingClasses,_fnSortData,_fnSaveState,_fnLoadState,_fnSettingsFromNode,_fnLog,_fnMap,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnLengthOverflow,_fnRenderer,_fnDataSource,_fnRowAttributes*/
  21623. (function( factory ) {
  21624. "use strict";
  21625. if ( typeof define === 'function' && define.amd ) {
  21626. // AMD
  21627. define( ['jquery'], function ( $ ) {
  21628. return factory( $, window, document );
  21629. } );
  21630. }
  21631. else if ( typeof exports === 'object' ) {
  21632. // CommonJS
  21633. module.exports = function (root, $) {
  21634. if ( ! root ) {
  21635. // CommonJS environments without a window global must pass a
  21636. // root. This will give an error otherwise
  21637. root = window;
  21638. }
  21639. if ( ! $ ) {
  21640. $ = typeof window !== 'undefined' ? // jQuery's factory checks for a global window
  21641. require('jquery') :
  21642. require('jquery')( root );
  21643. }
  21644. return factory( $, root, root.document );
  21645. };
  21646. }
  21647. else {
  21648. // Browser
  21649. factory( jQuery, window, document );
  21650. }
  21651. }
  21652. (function( $, window, document, undefined ) {
  21653. "use strict";
  21654. /**
  21655. * DataTables is a plug-in for the jQuery Javascript library. It is a highly
  21656. * flexible tool, based upon the foundations of progressive enhancement,
  21657. * which will add advanced interaction controls to any HTML table. For a
  21658. * full list of features please refer to
  21659. * [DataTables.net](href="http://datatables.net).
  21660. *
  21661. * Note that the `DataTable` object is not a global variable but is aliased
  21662. * to `jQuery.fn.DataTable` and `jQuery.fn.dataTable` through which it may
  21663. * be accessed.
  21664. *
  21665. * @class
  21666. * @param {object} [init={}] Configuration object for DataTables. Options
  21667. * are defined by {@link DataTable.defaults}
  21668. * @requires jQuery 1.7+
  21669. *
  21670. * @example
  21671. * // Basic initialisation
  21672. * $(document).ready( function {
  21673. * $('#example').dataTable();
  21674. * } );
  21675. *
  21676. * @example
  21677. * // Initialisation with configuration options - in this case, disable
  21678. * // pagination and sorting.
  21679. * $(document).ready( function {
  21680. * $('#example').dataTable( {
  21681. * "paginate": false,
  21682. * "sort": false
  21683. * } );
  21684. * } );
  21685. */
  21686. var DataTable = function ( options )
  21687. {
  21688. /**
  21689. * Perform a jQuery selector action on the table's TR elements (from the tbody) and
  21690. * return the resulting jQuery object.
  21691. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  21692. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  21693. * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
  21694. * criterion ("applied") or all TR elements (i.e. no filter).
  21695. * @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
  21696. * Can be either 'current', whereby the current sorting of the table is used, or
  21697. * 'original' whereby the original order the data was read into the table is used.
  21698. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  21699. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  21700. * 'current' and filter is 'applied', regardless of what they might be given as.
  21701. * @returns {object} jQuery object, filtered by the given selector.
  21702. * @dtopt API
  21703. * @deprecated Since v1.10
  21704. *
  21705. * @example
  21706. * $(document).ready(function() {
  21707. * var oTable = $('#example').dataTable();
  21708. *
  21709. * // Highlight every second row
  21710. * oTable.$('tr:odd').css('backgroundColor', 'blue');
  21711. * } );
  21712. *
  21713. * @example
  21714. * $(document).ready(function() {
  21715. * var oTable = $('#example').dataTable();
  21716. *
  21717. * // Filter to rows with 'Webkit' in them, add a background colour and then
  21718. * // remove the filter, thus highlighting the 'Webkit' rows only.
  21719. * oTable.fnFilter('Webkit');
  21720. * oTable.$('tr', {"search": "applied"}).css('backgroundColor', 'blue');
  21721. * oTable.fnFilter('');
  21722. * } );
  21723. */
  21724. this.$ = function ( sSelector, oOpts )
  21725. {
  21726. return this.api(true).$( sSelector, oOpts );
  21727. };
  21728. /**
  21729. * Almost identical to $ in operation, but in this case returns the data for the matched
  21730. * rows - as such, the jQuery selector used should match TR row nodes or TD/TH cell nodes
  21731. * rather than any descendants, so the data can be obtained for the row/cell. If matching
  21732. * rows are found, the data returned is the original data array/object that was used to
  21733. * create the row (or a generated array if from a DOM source).
  21734. *
  21735. * This method is often useful in-combination with $ where both functions are given the
  21736. * same parameters and the array indexes will match identically.
  21737. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  21738. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  21739. * @param {string} [oOpts.filter=none] Select elements that meet the current filter
  21740. * criterion ("applied") or all elements (i.e. no filter).
  21741. * @param {string} [oOpts.order=current] Order of the data in the processed array.
  21742. * Can be either 'current', whereby the current sorting of the table is used, or
  21743. * 'original' whereby the original order the data was read into the table is used.
  21744. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  21745. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  21746. * 'current' and filter is 'applied', regardless of what they might be given as.
  21747. * @returns {array} Data for the matched elements. If any elements, as a result of the
  21748. * selector, were not TR, TD or TH elements in the DataTable, they will have a null
  21749. * entry in the array.
  21750. * @dtopt API
  21751. * @deprecated Since v1.10
  21752. *
  21753. * @example
  21754. * $(document).ready(function() {
  21755. * var oTable = $('#example').dataTable();
  21756. *
  21757. * // Get the data from the first row in the table
  21758. * var data = oTable._('tr:first');
  21759. *
  21760. * // Do something useful with the data
  21761. * alert( "First cell is: "+data[0] );
  21762. * } );
  21763. *
  21764. * @example
  21765. * $(document).ready(function() {
  21766. * var oTable = $('#example').dataTable();
  21767. *
  21768. * // Filter to 'Webkit' and get all data for
  21769. * oTable.fnFilter('Webkit');
  21770. * var data = oTable._('tr', {"search": "applied"});
  21771. *
  21772. * // Do something with the data
  21773. * alert( data.length+" rows matched the search" );
  21774. * } );
  21775. */
  21776. this._ = function ( sSelector, oOpts )
  21777. {
  21778. return this.api(true).rows( sSelector, oOpts ).data();
  21779. };
  21780. /**
  21781. * Create a DataTables Api instance, with the currently selected tables for
  21782. * the Api's context.
  21783. * @param {boolean} [traditional=false] Set the API instance's context to be
  21784. * only the table referred to by the `DataTable.ext.iApiIndex` option, as was
  21785. * used in the API presented by DataTables 1.9- (i.e. the traditional mode),
  21786. * or if all tables captured in the jQuery object should be used.
  21787. * @return {DataTables.Api}
  21788. */
  21789. this.api = function ( traditional )
  21790. {
  21791. return traditional ?
  21792. new _Api(
  21793. _fnSettingsFromNode( this[ _ext.iApiIndex ] )
  21794. ) :
  21795. new _Api( this );
  21796. };
  21797. /**
  21798. * Add a single new row or multiple rows of data to the table. Please note
  21799. * that this is suitable for client-side processing only - if you are using
  21800. * server-side processing (i.e. "bServerSide": true), then to add data, you
  21801. * must add it to the data source, i.e. the server-side, through an Ajax call.
  21802. * @param {array|object} data The data to be added to the table. This can be:
  21803. * <ul>
  21804. * <li>1D array of data - add a single row with the data provided</li>
  21805. * <li>2D array of arrays - add multiple rows in a single call</li>
  21806. * <li>object - data object when using <i>mData</i></li>
  21807. * <li>array of objects - multiple data objects when using <i>mData</i></li>
  21808. * </ul>
  21809. * @param {bool} [redraw=true] redraw the table or not
  21810. * @returns {array} An array of integers, representing the list of indexes in
  21811. * <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
  21812. * the table.
  21813. * @dtopt API
  21814. * @deprecated Since v1.10
  21815. *
  21816. * @example
  21817. * // Global var for counter
  21818. * var giCount = 2;
  21819. *
  21820. * $(document).ready(function() {
  21821. * $('#example').dataTable();
  21822. * } );
  21823. *
  21824. * function fnClickAddRow() {
  21825. * $('#example').dataTable().fnAddData( [
  21826. * giCount+".1",
  21827. * giCount+".2",
  21828. * giCount+".3",
  21829. * giCount+".4" ]
  21830. * );
  21831. *
  21832. * giCount++;
  21833. * }
  21834. */
  21835. this.fnAddData = function( data, redraw )
  21836. {
  21837. var api = this.api( true );
  21838. /* Check if we want to add multiple rows or not */
  21839. var rows = $.isArray(data) && ( $.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
  21840. api.rows.add( data ) :
  21841. api.row.add( data );
  21842. if ( redraw === undefined || redraw ) {
  21843. api.draw();
  21844. }
  21845. return rows.flatten().toArray();
  21846. };
  21847. /**
  21848. * This function will make DataTables recalculate the column sizes, based on the data
  21849. * contained in the table and the sizes applied to the columns (in the DOM, CSS or
  21850. * through the sWidth parameter). This can be useful when the width of the table's
  21851. * parent element changes (for example a window resize).
  21852. * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
  21853. * @dtopt API
  21854. * @deprecated Since v1.10
  21855. *
  21856. * @example
  21857. * $(document).ready(function() {
  21858. * var oTable = $('#example').dataTable( {
  21859. * "sScrollY": "200px",
  21860. * "bPaginate": false
  21861. * } );
  21862. *
  21863. * $(window).bind('resize', function () {
  21864. * oTable.fnAdjustColumnSizing();
  21865. * } );
  21866. * } );
  21867. */
  21868. this.fnAdjustColumnSizing = function ( bRedraw )
  21869. {
  21870. var api = this.api( true ).columns.adjust();
  21871. var settings = api.settings()[0];
  21872. var scroll = settings.oScroll;
  21873. if ( bRedraw === undefined || bRedraw ) {
  21874. api.draw( false );
  21875. }
  21876. else if ( scroll.sX !== "" || scroll.sY !== "" ) {
  21877. /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
  21878. _fnScrollDraw( settings );
  21879. }
  21880. };
  21881. /**
  21882. * Quickly and simply clear a table
  21883. * @param {bool} [bRedraw=true] redraw the table or not
  21884. * @dtopt API
  21885. * @deprecated Since v1.10
  21886. *
  21887. * @example
  21888. * $(document).ready(function() {
  21889. * var oTable = $('#example').dataTable();
  21890. *
  21891. * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
  21892. * oTable.fnClearTable();
  21893. * } );
  21894. */
  21895. this.fnClearTable = function( bRedraw )
  21896. {
  21897. var api = this.api( true ).clear();
  21898. if ( bRedraw === undefined || bRedraw ) {
  21899. api.draw();
  21900. }
  21901. };
  21902. /**
  21903. * The exact opposite of 'opening' a row, this function will close any rows which
  21904. * are currently 'open'.
  21905. * @param {node} nTr the table row to 'close'
  21906. * @returns {int} 0 on success, or 1 if failed (can't find the row)
  21907. * @dtopt API
  21908. * @deprecated Since v1.10
  21909. *
  21910. * @example
  21911. * $(document).ready(function() {
  21912. * var oTable;
  21913. *
  21914. * // 'open' an information row when a row is clicked on
  21915. * $('#example tbody tr').click( function () {
  21916. * if ( oTable.fnIsOpen(this) ) {
  21917. * oTable.fnClose( this );
  21918. * } else {
  21919. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  21920. * }
  21921. * } );
  21922. *
  21923. * oTable = $('#example').dataTable();
  21924. * } );
  21925. */
  21926. this.fnClose = function( nTr )
  21927. {
  21928. this.api( true ).row( nTr ).child.hide();
  21929. };
  21930. /**
  21931. * Remove a row for the table
  21932. * @param {mixed} target The index of the row from aoData to be deleted, or
  21933. * the TR element you want to delete
  21934. * @param {function|null} [callBack] Callback function
  21935. * @param {bool} [redraw=true] Redraw the table or not
  21936. * @returns {array} The row that was deleted
  21937. * @dtopt API
  21938. * @deprecated Since v1.10
  21939. *
  21940. * @example
  21941. * $(document).ready(function() {
  21942. * var oTable = $('#example').dataTable();
  21943. *
  21944. * // Immediately remove the first row
  21945. * oTable.fnDeleteRow( 0 );
  21946. * } );
  21947. */
  21948. this.fnDeleteRow = function( target, callback, redraw )
  21949. {
  21950. var api = this.api( true );
  21951. var rows = api.rows( target );
  21952. var settings = rows.settings()[0];
  21953. var data = settings.aoData[ rows[0][0] ];
  21954. rows.remove();
  21955. if ( callback ) {
  21956. callback.call( this, settings, data );
  21957. }
  21958. if ( redraw === undefined || redraw ) {
  21959. api.draw();
  21960. }
  21961. return data;
  21962. };
  21963. /**
  21964. * Restore the table to it's original state in the DOM by removing all of DataTables
  21965. * enhancements, alterations to the DOM structure of the table and event listeners.
  21966. * @param {boolean} [remove=false] Completely remove the table from the DOM
  21967. * @dtopt API
  21968. * @deprecated Since v1.10
  21969. *
  21970. * @example
  21971. * $(document).ready(function() {
  21972. * // This example is fairly pointless in reality, but shows how fnDestroy can be used
  21973. * var oTable = $('#example').dataTable();
  21974. * oTable.fnDestroy();
  21975. * } );
  21976. */
  21977. this.fnDestroy = function ( remove )
  21978. {
  21979. this.api( true ).destroy( remove );
  21980. };
  21981. /**
  21982. * Redraw the table
  21983. * @param {bool} [complete=true] Re-filter and resort (if enabled) the table before the draw.
  21984. * @dtopt API
  21985. * @deprecated Since v1.10
  21986. *
  21987. * @example
  21988. * $(document).ready(function() {
  21989. * var oTable = $('#example').dataTable();
  21990. *
  21991. * // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
  21992. * oTable.fnDraw();
  21993. * } );
  21994. */
  21995. this.fnDraw = function( complete )
  21996. {
  21997. // Note that this isn't an exact match to the old call to _fnDraw - it takes
  21998. // into account the new data, but can hold position.
  21999. this.api( true ).draw( complete );
  22000. };
  22001. /**
  22002. * Filter the input based on data
  22003. * @param {string} sInput String to filter the table on
  22004. * @param {int|null} [iColumn] Column to limit filtering to
  22005. * @param {bool} [bRegex=false] Treat as regular expression or not
  22006. * @param {bool} [bSmart=true] Perform smart filtering or not
  22007. * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es)
  22008. * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false)
  22009. * @dtopt API
  22010. * @deprecated Since v1.10
  22011. *
  22012. * @example
  22013. * $(document).ready(function() {
  22014. * var oTable = $('#example').dataTable();
  22015. *
  22016. * // Sometime later - filter...
  22017. * oTable.fnFilter( 'test string' );
  22018. * } );
  22019. */
  22020. this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive )
  22021. {
  22022. var api = this.api( true );
  22023. if ( iColumn === null || iColumn === undefined ) {
  22024. api.search( sInput, bRegex, bSmart, bCaseInsensitive );
  22025. }
  22026. else {
  22027. api.column( iColumn ).search( sInput, bRegex, bSmart, bCaseInsensitive );
  22028. }
  22029. api.draw();
  22030. };
  22031. /**
  22032. * Get the data for the whole table, an individual row or an individual cell based on the
  22033. * provided parameters.
  22034. * @param {int|node} [src] A TR row node, TD/TH cell node or an integer. If given as
  22035. * a TR node then the data source for the whole row will be returned. If given as a
  22036. * TD/TH cell node then iCol will be automatically calculated and the data for the
  22037. * cell returned. If given as an integer, then this is treated as the aoData internal
  22038. * data index for the row (see fnGetPosition) and the data for that row used.
  22039. * @param {int} [col] Optional column index that you want the data of.
  22040. * @returns {array|object|string} If mRow is undefined, then the data for all rows is
  22041. * returned. If mRow is defined, just data for that row, and is iCol is
  22042. * defined, only data for the designated cell is returned.
  22043. * @dtopt API
  22044. * @deprecated Since v1.10
  22045. *
  22046. * @example
  22047. * // Row data
  22048. * $(document).ready(function() {
  22049. * oTable = $('#example').dataTable();
  22050. *
  22051. * oTable.$('tr').click( function () {
  22052. * var data = oTable.fnGetData( this );
  22053. * // ... do something with the array / object of data for the row
  22054. * } );
  22055. * } );
  22056. *
  22057. * @example
  22058. * // Individual cell data
  22059. * $(document).ready(function() {
  22060. * oTable = $('#example').dataTable();
  22061. *
  22062. * oTable.$('td').click( function () {
  22063. * var sData = oTable.fnGetData( this );
  22064. * alert( 'The cell clicked on had the value of '+sData );
  22065. * } );
  22066. * } );
  22067. */
  22068. this.fnGetData = function( src, col )
  22069. {
  22070. var api = this.api( true );
  22071. if ( src !== undefined ) {
  22072. var type = src.nodeName ? src.nodeName.toLowerCase() : '';
  22073. return col !== undefined || type == 'td' || type == 'th' ?
  22074. api.cell( src, col ).data() :
  22075. api.row( src ).data() || null;
  22076. }
  22077. return api.data().toArray();
  22078. };
  22079. /**
  22080. * Get an array of the TR nodes that are used in the table's body. Note that you will
  22081. * typically want to use the '$' API method in preference to this as it is more
  22082. * flexible.
  22083. * @param {int} [iRow] Optional row index for the TR element you want
  22084. * @returns {array|node} If iRow is undefined, returns an array of all TR elements
  22085. * in the table's body, or iRow is defined, just the TR element requested.
  22086. * @dtopt API
  22087. * @deprecated Since v1.10
  22088. *
  22089. * @example
  22090. * $(document).ready(function() {
  22091. * var oTable = $('#example').dataTable();
  22092. *
  22093. * // Get the nodes from the table
  22094. * var nNodes = oTable.fnGetNodes( );
  22095. * } );
  22096. */
  22097. this.fnGetNodes = function( iRow )
  22098. {
  22099. var api = this.api( true );
  22100. return iRow !== undefined ?
  22101. api.row( iRow ).node() :
  22102. api.rows().nodes().flatten().toArray();
  22103. };
  22104. /**
  22105. * Get the array indexes of a particular cell from it's DOM element
  22106. * and column index including hidden columns
  22107. * @param {node} node this can either be a TR, TD or TH in the table's body
  22108. * @returns {int} If nNode is given as a TR, then a single index is returned, or
  22109. * if given as a cell, an array of [row index, column index (visible),
  22110. * column index (all)] is given.
  22111. * @dtopt API
  22112. * @deprecated Since v1.10
  22113. *
  22114. * @example
  22115. * $(document).ready(function() {
  22116. * $('#example tbody td').click( function () {
  22117. * // Get the position of the current data from the node
  22118. * var aPos = oTable.fnGetPosition( this );
  22119. *
  22120. * // Get the data array for this row
  22121. * var aData = oTable.fnGetData( aPos[0] );
  22122. *
  22123. * // Update the data array and return the value
  22124. * aData[ aPos[1] ] = 'clicked';
  22125. * this.innerHTML = 'clicked';
  22126. * } );
  22127. *
  22128. * // Init DataTables
  22129. * oTable = $('#example').dataTable();
  22130. * } );
  22131. */
  22132. this.fnGetPosition = function( node )
  22133. {
  22134. var api = this.api( true );
  22135. var nodeName = node.nodeName.toUpperCase();
  22136. if ( nodeName == 'TR' ) {
  22137. return api.row( node ).index();
  22138. }
  22139. else if ( nodeName == 'TD' || nodeName == 'TH' ) {
  22140. var cell = api.cell( node ).index();
  22141. return [
  22142. cell.row,
  22143. cell.columnVisible,
  22144. cell.column
  22145. ];
  22146. }
  22147. return null;
  22148. };
  22149. /**
  22150. * Check to see if a row is 'open' or not.
  22151. * @param {node} nTr the table row to check
  22152. * @returns {boolean} true if the row is currently open, false otherwise
  22153. * @dtopt API
  22154. * @deprecated Since v1.10
  22155. *
  22156. * @example
  22157. * $(document).ready(function() {
  22158. * var oTable;
  22159. *
  22160. * // 'open' an information row when a row is clicked on
  22161. * $('#example tbody tr').click( function () {
  22162. * if ( oTable.fnIsOpen(this) ) {
  22163. * oTable.fnClose( this );
  22164. * } else {
  22165. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  22166. * }
  22167. * } );
  22168. *
  22169. * oTable = $('#example').dataTable();
  22170. * } );
  22171. */
  22172. this.fnIsOpen = function( nTr )
  22173. {
  22174. return this.api( true ).row( nTr ).child.isShown();
  22175. };
  22176. /**
  22177. * This function will place a new row directly after a row which is currently
  22178. * on display on the page, with the HTML contents that is passed into the
  22179. * function. This can be used, for example, to ask for confirmation that a
  22180. * particular record should be deleted.
  22181. * @param {node} nTr The table row to 'open'
  22182. * @param {string|node|jQuery} mHtml The HTML to put into the row
  22183. * @param {string} sClass Class to give the new TD cell
  22184. * @returns {node} The row opened. Note that if the table row passed in as the
  22185. * first parameter, is not found in the table, this method will silently
  22186. * return.
  22187. * @dtopt API
  22188. * @deprecated Since v1.10
  22189. *
  22190. * @example
  22191. * $(document).ready(function() {
  22192. * var oTable;
  22193. *
  22194. * // 'open' an information row when a row is clicked on
  22195. * $('#example tbody tr').click( function () {
  22196. * if ( oTable.fnIsOpen(this) ) {
  22197. * oTable.fnClose( this );
  22198. * } else {
  22199. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  22200. * }
  22201. * } );
  22202. *
  22203. * oTable = $('#example').dataTable();
  22204. * } );
  22205. */
  22206. this.fnOpen = function( nTr, mHtml, sClass )
  22207. {
  22208. return this.api( true )
  22209. .row( nTr )
  22210. .child( mHtml, sClass )
  22211. .show()
  22212. .child()[0];
  22213. };
  22214. /**
  22215. * Change the pagination - provides the internal logic for pagination in a simple API
  22216. * function. With this function you can have a DataTables table go to the next,
  22217. * previous, first or last pages.
  22218. * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
  22219. * or page number to jump to (integer), note that page 0 is the first page.
  22220. * @param {bool} [bRedraw=true] Redraw the table or not
  22221. * @dtopt API
  22222. * @deprecated Since v1.10
  22223. *
  22224. * @example
  22225. * $(document).ready(function() {
  22226. * var oTable = $('#example').dataTable();
  22227. * oTable.fnPageChange( 'next' );
  22228. * } );
  22229. */
  22230. this.fnPageChange = function ( mAction, bRedraw )
  22231. {
  22232. var api = this.api( true ).page( mAction );
  22233. if ( bRedraw === undefined || bRedraw ) {
  22234. api.draw(false);
  22235. }
  22236. };
  22237. /**
  22238. * Show a particular column
  22239. * @param {int} iCol The column whose display should be changed
  22240. * @param {bool} bShow Show (true) or hide (false) the column
  22241. * @param {bool} [bRedraw=true] Redraw the table or not
  22242. * @dtopt API
  22243. * @deprecated Since v1.10
  22244. *
  22245. * @example
  22246. * $(document).ready(function() {
  22247. * var oTable = $('#example').dataTable();
  22248. *
  22249. * // Hide the second column after initialisation
  22250. * oTable.fnSetColumnVis( 1, false );
  22251. * } );
  22252. */
  22253. this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
  22254. {
  22255. var api = this.api( true ).column( iCol ).visible( bShow );
  22256. if ( bRedraw === undefined || bRedraw ) {
  22257. api.columns.adjust().draw();
  22258. }
  22259. };
  22260. /**
  22261. * Get the settings for a particular table for external manipulation
  22262. * @returns {object} DataTables settings object. See
  22263. * {@link DataTable.models.oSettings}
  22264. * @dtopt API
  22265. * @deprecated Since v1.10
  22266. *
  22267. * @example
  22268. * $(document).ready(function() {
  22269. * var oTable = $('#example').dataTable();
  22270. * var oSettings = oTable.fnSettings();
  22271. *
  22272. * // Show an example parameter from the settings
  22273. * alert( oSettings._iDisplayStart );
  22274. * } );
  22275. */
  22276. this.fnSettings = function()
  22277. {
  22278. return _fnSettingsFromNode( this[_ext.iApiIndex] );
  22279. };
  22280. /**
  22281. * Sort the table by a particular column
  22282. * @param {int} iCol the data index to sort on. Note that this will not match the
  22283. * 'display index' if you have hidden data entries
  22284. * @dtopt API
  22285. * @deprecated Since v1.10
  22286. *
  22287. * @example
  22288. * $(document).ready(function() {
  22289. * var oTable = $('#example').dataTable();
  22290. *
  22291. * // Sort immediately with columns 0 and 1
  22292. * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
  22293. * } );
  22294. */
  22295. this.fnSort = function( aaSort )
  22296. {
  22297. this.api( true ).order( aaSort ).draw();
  22298. };
  22299. /**
  22300. * Attach a sort listener to an element for a given column
  22301. * @param {node} nNode the element to attach the sort listener to
  22302. * @param {int} iColumn the column that a click on this node will sort on
  22303. * @param {function} [fnCallback] callback function when sort is run
  22304. * @dtopt API
  22305. * @deprecated Since v1.10
  22306. *
  22307. * @example
  22308. * $(document).ready(function() {
  22309. * var oTable = $('#example').dataTable();
  22310. *
  22311. * // Sort on column 1, when 'sorter' is clicked on
  22312. * oTable.fnSortListener( document.getElementById('sorter'), 1 );
  22313. * } );
  22314. */
  22315. this.fnSortListener = function( nNode, iColumn, fnCallback )
  22316. {
  22317. this.api( true ).order.listener( nNode, iColumn, fnCallback );
  22318. };
  22319. /**
  22320. * Update a table cell or row - this method will accept either a single value to
  22321. * update the cell with, an array of values with one element for each column or
  22322. * an object in the same format as the original data source. The function is
  22323. * self-referencing in order to make the multi column updates easier.
  22324. * @param {object|array|string} mData Data to update the cell/row with
  22325. * @param {node|int} mRow TR element you want to update or the aoData index
  22326. * @param {int} [iColumn] The column to update, give as null or undefined to
  22327. * update a whole row.
  22328. * @param {bool} [bRedraw=true] Redraw the table or not
  22329. * @param {bool} [bAction=true] Perform pre-draw actions or not
  22330. * @returns {int} 0 on success, 1 on error
  22331. * @dtopt API
  22332. * @deprecated Since v1.10
  22333. *
  22334. * @example
  22335. * $(document).ready(function() {
  22336. * var oTable = $('#example').dataTable();
  22337. * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
  22338. * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], $('tbody tr')[0] ); // Row
  22339. * } );
  22340. */
  22341. this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
  22342. {
  22343. var api = this.api( true );
  22344. if ( iColumn === undefined || iColumn === null ) {
  22345. api.row( mRow ).data( mData );
  22346. }
  22347. else {
  22348. api.cell( mRow, iColumn ).data( mData );
  22349. }
  22350. if ( bAction === undefined || bAction ) {
  22351. api.columns.adjust();
  22352. }
  22353. if ( bRedraw === undefined || bRedraw ) {
  22354. api.draw();
  22355. }
  22356. return 0;
  22357. };
  22358. /**
  22359. * Provide a common method for plug-ins to check the version of DataTables being used, in order
  22360. * to ensure compatibility.
  22361. * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
  22362. * formats "X" and "X.Y" are also acceptable.
  22363. * @returns {boolean} true if this version of DataTables is greater or equal to the required
  22364. * version, or false if this version of DataTales is not suitable
  22365. * @method
  22366. * @dtopt API
  22367. * @deprecated Since v1.10
  22368. *
  22369. * @example
  22370. * $(document).ready(function() {
  22371. * var oTable = $('#example').dataTable();
  22372. * alert( oTable.fnVersionCheck( '1.9.0' ) );
  22373. * } );
  22374. */
  22375. this.fnVersionCheck = _ext.fnVersionCheck;
  22376. var _that = this;
  22377. var emptyInit = options === undefined;
  22378. var len = this.length;
  22379. if ( emptyInit ) {
  22380. options = {};
  22381. }
  22382. this.oApi = this.internal = _ext.internal;
  22383. // Extend with old style plug-in API methods
  22384. for ( var fn in DataTable.ext.internal ) {
  22385. if ( fn ) {
  22386. this[fn] = _fnExternApiFunc(fn);
  22387. }
  22388. }
  22389. this.each(function() {
  22390. // For each initialisation we want to give it a clean initialisation
  22391. // object that can be bashed around
  22392. var o = {};
  22393. var oInit = len > 1 ? // optimisation for single table case
  22394. _fnExtend( o, options, true ) :
  22395. options;
  22396. /*global oInit,_that,emptyInit*/
  22397. var i=0, iLen, j, jLen, k, kLen;
  22398. var sId = this.getAttribute( 'id' );
  22399. var bInitHandedOff = false;
  22400. var defaults = DataTable.defaults;
  22401. var $this = $(this);
  22402. /* Sanity check */
  22403. if ( this.nodeName.toLowerCase() != 'table' )
  22404. {
  22405. _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
  22406. return;
  22407. }
  22408. /* Backwards compatibility for the defaults */
  22409. _fnCompatOpts( defaults );
  22410. _fnCompatCols( defaults.column );
  22411. /* Convert the camel-case defaults to Hungarian */
  22412. _fnCamelToHungarian( defaults, defaults, true );
  22413. _fnCamelToHungarian( defaults.column, defaults.column, true );
  22414. /* Setting up the initialisation object */
  22415. _fnCamelToHungarian( defaults, $.extend( oInit, $this.data() ) );
  22416. /* Check to see if we are re-initialising a table */
  22417. var allSettings = DataTable.settings;
  22418. for ( i=0, iLen=allSettings.length ; i<iLen ; i++ )
  22419. {
  22420. var s = allSettings[i];
  22421. /* Base check on table node */
  22422. if ( s.nTable == this || s.nTHead.parentNode == this || (s.nTFoot && s.nTFoot.parentNode == this) )
  22423. {
  22424. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  22425. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  22426. if ( emptyInit || bRetrieve )
  22427. {
  22428. return s.oInstance;
  22429. }
  22430. else if ( bDestroy )
  22431. {
  22432. s.oInstance.fnDestroy();
  22433. break;
  22434. }
  22435. else
  22436. {
  22437. _fnLog( s, 0, 'Cannot reinitialise DataTable', 3 );
  22438. return;
  22439. }
  22440. }
  22441. /* If the element we are initialising has the same ID as a table which was previously
  22442. * initialised, but the table nodes don't match (from before) then we destroy the old
  22443. * instance by simply deleting it. This is under the assumption that the table has been
  22444. * destroyed by other methods. Anyone using non-id selectors will need to do this manually
  22445. */
  22446. if ( s.sTableId == this.id )
  22447. {
  22448. allSettings.splice( i, 1 );
  22449. break;
  22450. }
  22451. }
  22452. /* Ensure the table has an ID - required for accessibility */
  22453. if ( sId === null || sId === "" )
  22454. {
  22455. sId = "DataTables_Table_"+(DataTable.ext._unique++);
  22456. this.id = sId;
  22457. }
  22458. /* Create the settings object for this table and set some of the default parameters */
  22459. var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
  22460. "sDestroyWidth": $this[0].style.width,
  22461. "sInstance": sId,
  22462. "sTableId": sId
  22463. } );
  22464. oSettings.nTable = this;
  22465. oSettings.oApi = _that.internal;
  22466. oSettings.oInit = oInit;
  22467. allSettings.push( oSettings );
  22468. // Need to add the instance after the instance after the settings object has been added
  22469. // to the settings array, so we can self reference the table instance if more than one
  22470. oSettings.oInstance = (_that.length===1) ? _that : $this.dataTable();
  22471. // Backwards compatibility, before we apply all the defaults
  22472. _fnCompatOpts( oInit );
  22473. if ( oInit.oLanguage )
  22474. {
  22475. _fnLanguageCompat( oInit.oLanguage );
  22476. }
  22477. // If the length menu is given, but the init display length is not, use the length menu
  22478. if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
  22479. {
  22480. oInit.iDisplayLength = $.isArray( oInit.aLengthMenu[0] ) ?
  22481. oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
  22482. }
  22483. // Apply the defaults and init options to make a single init object will all
  22484. // options defined from defaults and instance options.
  22485. oInit = _fnExtend( $.extend( true, {}, defaults ), oInit );
  22486. // Map the initialisation options onto the settings object
  22487. _fnMap( oSettings.oFeatures, oInit, [
  22488. "bPaginate",
  22489. "bLengthChange",
  22490. "bFilter",
  22491. "bSort",
  22492. "bSortMulti",
  22493. "bInfo",
  22494. "bProcessing",
  22495. "bAutoWidth",
  22496. "bSortClasses",
  22497. "bServerSide",
  22498. "bDeferRender"
  22499. ] );
  22500. _fnMap( oSettings, oInit, [
  22501. "asStripeClasses",
  22502. "ajax",
  22503. "fnServerData",
  22504. "fnFormatNumber",
  22505. "sServerMethod",
  22506. "aaSorting",
  22507. "aaSortingFixed",
  22508. "aLengthMenu",
  22509. "sPaginationType",
  22510. "sAjaxSource",
  22511. "sAjaxDataProp",
  22512. "iStateDuration",
  22513. "sDom",
  22514. "bSortCellsTop",
  22515. "iTabIndex",
  22516. "fnStateLoadCallback",
  22517. "fnStateSaveCallback",
  22518. "renderer",
  22519. "searchDelay",
  22520. "rowId",
  22521. [ "iCookieDuration", "iStateDuration" ], // backwards compat
  22522. [ "oSearch", "oPreviousSearch" ],
  22523. [ "aoSearchCols", "aoPreSearchCols" ],
  22524. [ "iDisplayLength", "_iDisplayLength" ],
  22525. [ "bJQueryUI", "bJUI" ]
  22526. ] );
  22527. _fnMap( oSettings.oScroll, oInit, [
  22528. [ "sScrollX", "sX" ],
  22529. [ "sScrollXInner", "sXInner" ],
  22530. [ "sScrollY", "sY" ],
  22531. [ "bScrollCollapse", "bCollapse" ]
  22532. ] );
  22533. _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
  22534. /* Callback functions which are array driven */
  22535. _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
  22536. _fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
  22537. _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user' );
  22538. _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user' );
  22539. _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user' );
  22540. _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
  22541. _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
  22542. _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
  22543. _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
  22544. _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
  22545. _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
  22546. oSettings.rowIdFn = _fnGetObjectDataFn( oInit.rowId );
  22547. /* Browser support detection */
  22548. _fnBrowserDetect( oSettings );
  22549. var oClasses = oSettings.oClasses;
  22550. // @todo Remove in 1.11
  22551. if ( oInit.bJQueryUI )
  22552. {
  22553. /* Use the JUI classes object for display. You could clone the oStdClasses object if
  22554. * you want to have multiple tables with multiple independent classes
  22555. */
  22556. $.extend( oClasses, DataTable.ext.oJUIClasses, oInit.oClasses );
  22557. if ( oInit.sDom === defaults.sDom && defaults.sDom === "lfrtip" )
  22558. {
  22559. /* Set the DOM to use a layout suitable for jQuery UI's theming */
  22560. oSettings.sDom = '<"H"lfr>t<"F"ip>';
  22561. }
  22562. if ( ! oSettings.renderer ) {
  22563. oSettings.renderer = 'jqueryui';
  22564. }
  22565. else if ( $.isPlainObject( oSettings.renderer ) && ! oSettings.renderer.header ) {
  22566. oSettings.renderer.header = 'jqueryui';
  22567. }
  22568. }
  22569. else
  22570. {
  22571. $.extend( oClasses, DataTable.ext.classes, oInit.oClasses );
  22572. }
  22573. $this.addClass( oClasses.sTable );
  22574. if ( oSettings.iInitDisplayStart === undefined )
  22575. {
  22576. /* Display start point, taking into account the save saving */
  22577. oSettings.iInitDisplayStart = oInit.iDisplayStart;
  22578. oSettings._iDisplayStart = oInit.iDisplayStart;
  22579. }
  22580. if ( oInit.iDeferLoading !== null )
  22581. {
  22582. oSettings.bDeferLoading = true;
  22583. var tmp = $.isArray( oInit.iDeferLoading );
  22584. oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
  22585. oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
  22586. }
  22587. /* Language definitions */
  22588. var oLanguage = oSettings.oLanguage;
  22589. $.extend( true, oLanguage, oInit.oLanguage );
  22590. if ( oLanguage.sUrl !== "" )
  22591. {
  22592. /* Get the language definitions from a file - because this Ajax call makes the language
  22593. * get async to the remainder of this function we use bInitHandedOff to indicate that
  22594. * _fnInitialise will be fired by the returned Ajax handler, rather than the constructor
  22595. */
  22596. $.ajax( {
  22597. dataType: 'json',
  22598. url: oLanguage.sUrl,
  22599. success: function ( json ) {
  22600. _fnLanguageCompat( json );
  22601. _fnCamelToHungarian( defaults.oLanguage, json );
  22602. $.extend( true, oLanguage, json );
  22603. _fnInitialise( oSettings );
  22604. },
  22605. error: function () {
  22606. // Error occurred loading language file, continue on as best we can
  22607. _fnInitialise( oSettings );
  22608. }
  22609. } );
  22610. bInitHandedOff = true;
  22611. }
  22612. /*
  22613. * Stripes
  22614. */
  22615. if ( oInit.asStripeClasses === null )
  22616. {
  22617. oSettings.asStripeClasses =[
  22618. oClasses.sStripeOdd,
  22619. oClasses.sStripeEven
  22620. ];
  22621. }
  22622. /* Remove row stripe classes if they are already on the table row */
  22623. var stripeClasses = oSettings.asStripeClasses;
  22624. var rowOne = $this.children('tbody').find('tr').eq(0);
  22625. if ( $.inArray( true, $.map( stripeClasses, function(el, i) {
  22626. return rowOne.hasClass(el);
  22627. } ) ) !== -1 ) {
  22628. $('tbody tr', this).removeClass( stripeClasses.join(' ') );
  22629. oSettings.asDestroyStripes = stripeClasses.slice();
  22630. }
  22631. /*
  22632. * Columns
  22633. * See if we should load columns automatically or use defined ones
  22634. */
  22635. var anThs = [];
  22636. var aoColumnsInit;
  22637. var nThead = this.getElementsByTagName('thead');
  22638. if ( nThead.length !== 0 )
  22639. {
  22640. _fnDetectHeader( oSettings.aoHeader, nThead[0] );
  22641. anThs = _fnGetUniqueThs( oSettings );
  22642. }
  22643. /* If not given a column array, generate one with nulls */
  22644. if ( oInit.aoColumns === null )
  22645. {
  22646. aoColumnsInit = [];
  22647. for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
  22648. {
  22649. aoColumnsInit.push( null );
  22650. }
  22651. }
  22652. else
  22653. {
  22654. aoColumnsInit = oInit.aoColumns;
  22655. }
  22656. /* Add the columns */
  22657. for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
  22658. {
  22659. _fnAddColumn( oSettings, anThs ? anThs[i] : null );
  22660. }
  22661. /* Apply the column definitions */
  22662. _fnApplyColumnDefs( oSettings, oInit.aoColumnDefs, aoColumnsInit, function (iCol, oDef) {
  22663. _fnColumnOptions( oSettings, iCol, oDef );
  22664. } );
  22665. /* HTML5 attribute detection - build an mData object automatically if the
  22666. * attributes are found
  22667. */
  22668. if ( rowOne.length ) {
  22669. var a = function ( cell, name ) {
  22670. return cell.getAttribute( 'data-'+name ) !== null ? name : null;
  22671. };
  22672. $( rowOne[0] ).children('th, td').each( function (i, cell) {
  22673. var col = oSettings.aoColumns[i];
  22674. if ( col.mData === i ) {
  22675. var sort = a( cell, 'sort' ) || a( cell, 'order' );
  22676. var filter = a( cell, 'filter' ) || a( cell, 'search' );
  22677. if ( sort !== null || filter !== null ) {
  22678. col.mData = {
  22679. _: i+'.display',
  22680. sort: sort !== null ? i+'.@data-'+sort : undefined,
  22681. type: sort !== null ? i+'.@data-'+sort : undefined,
  22682. filter: filter !== null ? i+'.@data-'+filter : undefined
  22683. };
  22684. _fnColumnOptions( oSettings, i );
  22685. }
  22686. }
  22687. } );
  22688. }
  22689. var features = oSettings.oFeatures;
  22690. /* Must be done after everything which can be overridden by the state saving! */
  22691. if ( oInit.bStateSave )
  22692. {
  22693. features.bStateSave = true;
  22694. _fnLoadState( oSettings, oInit );
  22695. _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
  22696. }
  22697. /*
  22698. * Sorting
  22699. * @todo For modularisation (1.11) this needs to do into a sort start up handler
  22700. */
  22701. // If aaSorting is not defined, then we use the first indicator in asSorting
  22702. // in case that has been altered, so the default sort reflects that option
  22703. if ( oInit.aaSorting === undefined )
  22704. {
  22705. var sorting = oSettings.aaSorting;
  22706. for ( i=0, iLen=sorting.length ; i<iLen ; i++ )
  22707. {
  22708. sorting[i][1] = oSettings.aoColumns[ i ].asSorting[0];
  22709. }
  22710. }
  22711. /* Do a first pass on the sorting classes (allows any size changes to be taken into
  22712. * account, and also will apply sorting disabled classes if disabled
  22713. */
  22714. _fnSortingClasses( oSettings );
  22715. if ( features.bSort )
  22716. {
  22717. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  22718. if ( oSettings.bSorted ) {
  22719. var aSort = _fnSortFlatten( oSettings );
  22720. var sortedColumns = {};
  22721. $.each( aSort, function (i, val) {
  22722. sortedColumns[ val.src ] = val.dir;
  22723. } );
  22724. _fnCallbackFire( oSettings, null, 'order', [oSettings, aSort, sortedColumns] );
  22725. _fnSortAria( oSettings );
  22726. }
  22727. } );
  22728. }
  22729. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  22730. if ( oSettings.bSorted || _fnDataSource( oSettings ) === 'ssp' || features.bDeferRender ) {
  22731. _fnSortingClasses( oSettings );
  22732. }
  22733. }, 'sc' );
  22734. /*
  22735. * Final init
  22736. * Cache the header, body and footer as required, creating them if needed
  22737. */
  22738. // Work around for Webkit bug 83867 - store the caption-side before removing from doc
  22739. var captions = $this.children('caption').each( function () {
  22740. this._captionSide = $this.css('caption-side');
  22741. } );
  22742. var thead = $this.children('thead');
  22743. if ( thead.length === 0 )
  22744. {
  22745. thead = $('<thead/>').appendTo(this);
  22746. }
  22747. oSettings.nTHead = thead[0];
  22748. var tbody = $this.children('tbody');
  22749. if ( tbody.length === 0 )
  22750. {
  22751. tbody = $('<tbody/>').appendTo(this);
  22752. }
  22753. oSettings.nTBody = tbody[0];
  22754. var tfoot = $this.children('tfoot');
  22755. if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") )
  22756. {
  22757. // If we are a scrolling table, and no footer has been given, then we need to create
  22758. // a tfoot element for the caption element to be appended to
  22759. tfoot = $('<tfoot/>').appendTo(this);
  22760. }
  22761. if ( tfoot.length === 0 || tfoot.children().length === 0 ) {
  22762. $this.addClass( oClasses.sNoFooter );
  22763. }
  22764. else if ( tfoot.length > 0 ) {
  22765. oSettings.nTFoot = tfoot[0];
  22766. _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
  22767. }
  22768. /* Check if there is data passing into the constructor */
  22769. if ( oInit.aaData )
  22770. {
  22771. for ( i=0 ; i<oInit.aaData.length ; i++ )
  22772. {
  22773. _fnAddData( oSettings, oInit.aaData[ i ] );
  22774. }
  22775. }
  22776. else if ( oSettings.bDeferLoading || _fnDataSource( oSettings ) == 'dom' )
  22777. {
  22778. /* Grab the data from the page - only do this when deferred loading or no Ajax
  22779. * source since there is no point in reading the DOM data if we are then going
  22780. * to replace it with Ajax data
  22781. */
  22782. _fnAddTr( oSettings, $(oSettings.nTBody).children('tr') );
  22783. }
  22784. /* Copy the data index array */
  22785. oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
  22786. /* Initialisation complete - table can be drawn */
  22787. oSettings.bInitialised = true;
  22788. /* Check if we need to initialise the table (it might not have been handed off to the
  22789. * language processor)
  22790. */
  22791. if ( bInitHandedOff === false )
  22792. {
  22793. _fnInitialise( oSettings );
  22794. }
  22795. } );
  22796. _that = null;
  22797. return this;
  22798. };
  22799. /*
  22800. * It is useful to have variables which are scoped locally so only the
  22801. * DataTables functions can access them and they don't leak into global space.
  22802. * At the same time these functions are often useful over multiple files in the
  22803. * core and API, so we list, or at least document, all variables which are used
  22804. * by DataTables as private variables here. This also ensures that there is no
  22805. * clashing of variable names and that they can easily referenced for reuse.
  22806. */
  22807. // Defined else where
  22808. // _selector_run
  22809. // _selector_opts
  22810. // _selector_first
  22811. // _selector_row_indexes
  22812. var _ext; // DataTable.ext
  22813. var _Api; // DataTable.Api
  22814. var _api_register; // DataTable.Api.register
  22815. var _api_registerPlural; // DataTable.Api.registerPlural
  22816. var _re_dic = {};
  22817. var _re_new_lines = /[\r\n]/g;
  22818. var _re_html = /<.*?>/g;
  22819. var _re_date_start = /^[\w\+\-]/;
  22820. var _re_date_end = /[\w\+\-]$/;
  22821. // Escape regular expression special characters
  22822. var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' );
  22823. // http://en.wikipedia.org/wiki/Foreign_exchange_market
  22824. // - \u20BD - Russian ruble.
  22825. // - \u20a9 - South Korean Won
  22826. // - \u20BA - Turkish Lira
  22827. // - \u20B9 - Indian Rupee
  22828. // - R - Brazil (R$) and South Africa
  22829. // - fr - Swiss Franc
  22830. // - kr - Swedish krona, Norwegian krone and Danish krone
  22831. // - \u2009 is thin space and \u202F is narrow no-break space, both used in many
  22832. // standards as thousands separators.
  22833. var _re_formatted_numeric = /[',$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfk]/gi;
  22834. var _empty = function ( d ) {
  22835. return !d || d === true || d === '-' ? true : false;
  22836. };
  22837. var _intVal = function ( s ) {
  22838. var integer = parseInt( s, 10 );
  22839. return !isNaN(integer) && isFinite(s) ? integer : null;
  22840. };
  22841. // Convert from a formatted number with characters other than `.` as the
  22842. // decimal place, to a Javascript number
  22843. var _numToDecimal = function ( num, decimalPoint ) {
  22844. // Cache created regular expressions for speed as this function is called often
  22845. if ( ! _re_dic[ decimalPoint ] ) {
  22846. _re_dic[ decimalPoint ] = new RegExp( _fnEscapeRegex( decimalPoint ), 'g' );
  22847. }
  22848. return typeof num === 'string' && decimalPoint !== '.' ?
  22849. num.replace( /\./g, '' ).replace( _re_dic[ decimalPoint ], '.' ) :
  22850. num;
  22851. };
  22852. var _isNumber = function ( d, decimalPoint, formatted ) {
  22853. var strType = typeof d === 'string';
  22854. // If empty return immediately so there must be a number if it is a
  22855. // formatted string (this stops the string "k", or "kr", etc being detected
  22856. // as a formatted number for currency
  22857. if ( _empty( d ) ) {
  22858. return true;
  22859. }
  22860. if ( decimalPoint && strType ) {
  22861. d = _numToDecimal( d, decimalPoint );
  22862. }
  22863. if ( formatted && strType ) {
  22864. d = d.replace( _re_formatted_numeric, '' );
  22865. }
  22866. return !isNaN( parseFloat(d) ) && isFinite( d );
  22867. };
  22868. // A string without HTML in it can be considered to be HTML still
  22869. var _isHtml = function ( d ) {
  22870. return _empty( d ) || typeof d === 'string';
  22871. };
  22872. var _htmlNumeric = function ( d, decimalPoint, formatted ) {
  22873. if ( _empty( d ) ) {
  22874. return true;
  22875. }
  22876. var html = _isHtml( d );
  22877. return ! html ?
  22878. null :
  22879. _isNumber( _stripHtml( d ), decimalPoint, formatted ) ?
  22880. true :
  22881. null;
  22882. };
  22883. var _pluck = function ( a, prop, prop2 ) {
  22884. var out = [];
  22885. var i=0, ien=a.length;
  22886. // Could have the test in the loop for slightly smaller code, but speed
  22887. // is essential here
  22888. if ( prop2 !== undefined ) {
  22889. for ( ; i<ien ; i++ ) {
  22890. if ( a[i] && a[i][ prop ] ) {
  22891. out.push( a[i][ prop ][ prop2 ] );
  22892. }
  22893. }
  22894. }
  22895. else {
  22896. for ( ; i<ien ; i++ ) {
  22897. if ( a[i] ) {
  22898. out.push( a[i][ prop ] );
  22899. }
  22900. }
  22901. }
  22902. return out;
  22903. };
  22904. // Basically the same as _pluck, but rather than looping over `a` we use `order`
  22905. // as the indexes to pick from `a`
  22906. var _pluck_order = function ( a, order, prop, prop2 )
  22907. {
  22908. var out = [];
  22909. var i=0, ien=order.length;
  22910. // Could have the test in the loop for slightly smaller code, but speed
  22911. // is essential here
  22912. if ( prop2 !== undefined ) {
  22913. for ( ; i<ien ; i++ ) {
  22914. if ( a[ order[i] ][ prop ] ) {
  22915. out.push( a[ order[i] ][ prop ][ prop2 ] );
  22916. }
  22917. }
  22918. }
  22919. else {
  22920. for ( ; i<ien ; i++ ) {
  22921. out.push( a[ order[i] ][ prop ] );
  22922. }
  22923. }
  22924. return out;
  22925. };
  22926. var _range = function ( len, start )
  22927. {
  22928. var out = [];
  22929. var end;
  22930. if ( start === undefined ) {
  22931. start = 0;
  22932. end = len;
  22933. }
  22934. else {
  22935. end = start;
  22936. start = len;
  22937. }
  22938. for ( var i=start ; i<end ; i++ ) {
  22939. out.push( i );
  22940. }
  22941. return out;
  22942. };
  22943. var _removeEmpty = function ( a )
  22944. {
  22945. var out = [];
  22946. for ( var i=0, ien=a.length ; i<ien ; i++ ) {
  22947. if ( a[i] ) { // careful - will remove all falsy values!
  22948. out.push( a[i] );
  22949. }
  22950. }
  22951. return out;
  22952. };
  22953. var _stripHtml = function ( d ) {
  22954. return d.replace( _re_html, '' );
  22955. };
  22956. /**
  22957. * Find the unique elements in a source array.
  22958. *
  22959. * @param {array} src Source array
  22960. * @return {array} Array of unique items
  22961. * @ignore
  22962. */
  22963. var _unique = function ( src )
  22964. {
  22965. // A faster unique method is to use object keys to identify used values,
  22966. // but this doesn't work with arrays or objects, which we must also
  22967. // consider. See jsperf.com/compare-array-unique-versions/4 for more
  22968. // information.
  22969. var
  22970. out = [],
  22971. val,
  22972. i, ien=src.length,
  22973. j, k=0;
  22974. again: for ( i=0 ; i<ien ; i++ ) {
  22975. val = src[i];
  22976. for ( j=0 ; j<k ; j++ ) {
  22977. if ( out[j] === val ) {
  22978. continue again;
  22979. }
  22980. }
  22981. out.push( val );
  22982. k++;
  22983. }
  22984. return out;
  22985. };
  22986. /**
  22987. * DataTables utility methods
  22988. *
  22989. * This namespace provides helper methods that DataTables uses internally to
  22990. * create a DataTable, but which are not exclusively used only for DataTables.
  22991. * These methods can be used by extension authors to save the duplication of
  22992. * code.
  22993. *
  22994. * @namespace
  22995. */
  22996. DataTable.util = {
  22997. /**
  22998. * Throttle the calls to a function. Arguments and context are maintained
  22999. * for the throttled function.
  23000. *
  23001. * @param {function} fn Function to be called
  23002. * @param {integer} freq Call frequency in mS
  23003. * @return {function} Wrapped function
  23004. */
  23005. throttle: function ( fn, freq ) {
  23006. var
  23007. frequency = freq !== undefined ? freq : 200,
  23008. last,
  23009. timer;
  23010. return function () {
  23011. var
  23012. that = this,
  23013. now = +new Date(),
  23014. args = arguments;
  23015. if ( last && now < last + frequency ) {
  23016. clearTimeout( timer );
  23017. timer = setTimeout( function () {
  23018. last = undefined;
  23019. fn.apply( that, args );
  23020. }, frequency );
  23021. }
  23022. else {
  23023. last = now;
  23024. fn.apply( that, args );
  23025. }
  23026. };
  23027. },
  23028. /**
  23029. * Escape a string such that it can be used in a regular expression
  23030. *
  23031. * @param {string} val string to escape
  23032. * @returns {string} escaped string
  23033. */
  23034. escapeRegex: function ( val ) {
  23035. return val.replace( _re_escape_regex, '\\$1' );
  23036. }
  23037. };
  23038. /**
  23039. * Create a mapping object that allows camel case parameters to be looked up
  23040. * for their Hungarian counterparts. The mapping is stored in a private
  23041. * parameter called `_hungarianMap` which can be accessed on the source object.
  23042. * @param {object} o
  23043. * @memberof DataTable#oApi
  23044. */
  23045. function _fnHungarianMap ( o )
  23046. {
  23047. var
  23048. hungarian = 'a aa ai ao as b fn i m o s ',
  23049. match,
  23050. newKey,
  23051. map = {};
  23052. $.each( o, function (key, val) {
  23053. match = key.match(/^([^A-Z]+?)([A-Z])/);
  23054. if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
  23055. {
  23056. newKey = key.replace( match[0], match[2].toLowerCase() );
  23057. map[ newKey ] = key;
  23058. if ( match[1] === 'o' )
  23059. {
  23060. _fnHungarianMap( o[key] );
  23061. }
  23062. }
  23063. } );
  23064. o._hungarianMap = map;
  23065. }
  23066. /**
  23067. * Convert from camel case parameters to Hungarian, based on a Hungarian map
  23068. * created by _fnHungarianMap.
  23069. * @param {object} src The model object which holds all parameters that can be
  23070. * mapped.
  23071. * @param {object} user The object to convert from camel case to Hungarian.
  23072. * @param {boolean} force When set to `true`, properties which already have a
  23073. * Hungarian value in the `user` object will be overwritten. Otherwise they
  23074. * won't be.
  23075. * @memberof DataTable#oApi
  23076. */
  23077. function _fnCamelToHungarian ( src, user, force )
  23078. {
  23079. if ( ! src._hungarianMap ) {
  23080. _fnHungarianMap( src );
  23081. }
  23082. var hungarianKey;
  23083. $.each( user, function (key, val) {
  23084. hungarianKey = src._hungarianMap[ key ];
  23085. if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
  23086. {
  23087. // For objects, we need to buzz down into the object to copy parameters
  23088. if ( hungarianKey.charAt(0) === 'o' )
  23089. {
  23090. // Copy the camelCase options over to the hungarian
  23091. if ( ! user[ hungarianKey ] ) {
  23092. user[ hungarianKey ] = {};
  23093. }
  23094. $.extend( true, user[hungarianKey], user[key] );
  23095. _fnCamelToHungarian( src[hungarianKey], user[hungarianKey], force );
  23096. }
  23097. else {
  23098. user[hungarianKey] = user[ key ];
  23099. }
  23100. }
  23101. } );
  23102. }
  23103. /**
  23104. * Language compatibility - when certain options are given, and others aren't, we
  23105. * need to duplicate the values over, in order to provide backwards compatibility
  23106. * with older language files.
  23107. * @param {object} oSettings dataTables settings object
  23108. * @memberof DataTable#oApi
  23109. */
  23110. function _fnLanguageCompat( lang )
  23111. {
  23112. var defaults = DataTable.defaults.oLanguage;
  23113. var zeroRecords = lang.sZeroRecords;
  23114. /* Backwards compatibility - if there is no sEmptyTable given, then use the same as
  23115. * sZeroRecords - assuming that is given.
  23116. */
  23117. if ( ! lang.sEmptyTable && zeroRecords &&
  23118. defaults.sEmptyTable === "No data available in table" )
  23119. {
  23120. _fnMap( lang, lang, 'sZeroRecords', 'sEmptyTable' );
  23121. }
  23122. /* Likewise with loading records */
  23123. if ( ! lang.sLoadingRecords && zeroRecords &&
  23124. defaults.sLoadingRecords === "Loading..." )
  23125. {
  23126. _fnMap( lang, lang, 'sZeroRecords', 'sLoadingRecords' );
  23127. }
  23128. // Old parameter name of the thousands separator mapped onto the new
  23129. if ( lang.sInfoThousands ) {
  23130. lang.sThousands = lang.sInfoThousands;
  23131. }
  23132. var decimal = lang.sDecimal;
  23133. if ( decimal ) {
  23134. _addNumericSort( decimal );
  23135. }
  23136. }
  23137. /**
  23138. * Map one parameter onto another
  23139. * @param {object} o Object to map
  23140. * @param {*} knew The new parameter name
  23141. * @param {*} old The old parameter name
  23142. */
  23143. var _fnCompatMap = function ( o, knew, old ) {
  23144. if ( o[ knew ] !== undefined ) {
  23145. o[ old ] = o[ knew ];
  23146. }
  23147. };
  23148. /**
  23149. * Provide backwards compatibility for the main DT options. Note that the new
  23150. * options are mapped onto the old parameters, so this is an external interface
  23151. * change only.
  23152. * @param {object} init Object to map
  23153. */
  23154. function _fnCompatOpts ( init )
  23155. {
  23156. _fnCompatMap( init, 'ordering', 'bSort' );
  23157. _fnCompatMap( init, 'orderMulti', 'bSortMulti' );
  23158. _fnCompatMap( init, 'orderClasses', 'bSortClasses' );
  23159. _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' );
  23160. _fnCompatMap( init, 'order', 'aaSorting' );
  23161. _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' );
  23162. _fnCompatMap( init, 'paging', 'bPaginate' );
  23163. _fnCompatMap( init, 'pagingType', 'sPaginationType' );
  23164. _fnCompatMap( init, 'pageLength', 'iDisplayLength' );
  23165. _fnCompatMap( init, 'searching', 'bFilter' );
  23166. // Boolean initialisation of x-scrolling
  23167. if ( typeof init.sScrollX === 'boolean' ) {
  23168. init.sScrollX = init.sScrollX ? '100%' : '';
  23169. }
  23170. if ( typeof init.scrollX === 'boolean' ) {
  23171. init.scrollX = init.scrollX ? '100%' : '';
  23172. }
  23173. // Column search objects are in an array, so it needs to be converted
  23174. // element by element
  23175. var searchCols = init.aoSearchCols;
  23176. if ( searchCols ) {
  23177. for ( var i=0, ien=searchCols.length ; i<ien ; i++ ) {
  23178. if ( searchCols[i] ) {
  23179. _fnCamelToHungarian( DataTable.models.oSearch, searchCols[i] );
  23180. }
  23181. }
  23182. }
  23183. }
  23184. /**
  23185. * Provide backwards compatibility for column options. Note that the new options
  23186. * are mapped onto the old parameters, so this is an external interface change
  23187. * only.
  23188. * @param {object} init Object to map
  23189. */
  23190. function _fnCompatCols ( init )
  23191. {
  23192. _fnCompatMap( init, 'orderable', 'bSortable' );
  23193. _fnCompatMap( init, 'orderData', 'aDataSort' );
  23194. _fnCompatMap( init, 'orderSequence', 'asSorting' );
  23195. _fnCompatMap( init, 'orderDataType', 'sortDataType' );
  23196. // orderData can be given as an integer
  23197. var dataSort = init.aDataSort;
  23198. if ( dataSort && ! $.isArray( dataSort ) ) {
  23199. init.aDataSort = [ dataSort ];
  23200. }
  23201. }
  23202. /**
  23203. * Browser feature detection for capabilities, quirks
  23204. * @param {object} settings dataTables settings object
  23205. * @memberof DataTable#oApi
  23206. */
  23207. function _fnBrowserDetect( settings )
  23208. {
  23209. // We don't need to do this every time DataTables is constructed, the values
  23210. // calculated are specific to the browser and OS configuration which we
  23211. // don't expect to change between initialisations
  23212. if ( ! DataTable.__browser ) {
  23213. var browser = {};
  23214. DataTable.__browser = browser;
  23215. // Scrolling feature / quirks detection
  23216. var n = $('<div/>')
  23217. .css( {
  23218. position: 'fixed',
  23219. top: 0,
  23220. left: 0,
  23221. height: 1,
  23222. width: 1,
  23223. overflow: 'hidden'
  23224. } )
  23225. .append(
  23226. $('<div/>')
  23227. .css( {
  23228. position: 'absolute',
  23229. top: 1,
  23230. left: 1,
  23231. width: 100,
  23232. overflow: 'scroll'
  23233. } )
  23234. .append(
  23235. $('<div/>')
  23236. .css( {
  23237. width: '100%',
  23238. height: 10
  23239. } )
  23240. )
  23241. )
  23242. .appendTo( 'body' );
  23243. var outer = n.children();
  23244. var inner = outer.children();
  23245. // Numbers below, in order, are:
  23246. // inner.offsetWidth, inner.clientWidth, outer.offsetWidth, outer.clientWidth
  23247. //
  23248. // IE6 XP: 100 100 100 83
  23249. // IE7 Vista: 100 100 100 83
  23250. // IE 8+ Windows: 83 83 100 83
  23251. // Evergreen Windows: 83 83 100 83
  23252. // Evergreen Mac with scrollbars: 85 85 100 85
  23253. // Evergreen Mac without scrollbars: 100 100 100 100
  23254. // Get scrollbar width
  23255. browser.barWidth = outer[0].offsetWidth - outer[0].clientWidth;
  23256. // IE6/7 will oversize a width 100% element inside a scrolling element, to
  23257. // include the width of the scrollbar, while other browsers ensure the inner
  23258. // element is contained without forcing scrolling
  23259. browser.bScrollOversize = inner[0].offsetWidth === 100 && outer[0].clientWidth !== 100;
  23260. // In rtl text layout, some browsers (most, but not all) will place the
  23261. // scrollbar on the left, rather than the right.
  23262. browser.bScrollbarLeft = Math.round( inner.offset().left ) !== 1;
  23263. // IE8- don't provide height and width for getBoundingClientRect
  23264. browser.bBounding = n[0].getBoundingClientRect().width ? true : false;
  23265. n.remove();
  23266. }
  23267. $.extend( settings.oBrowser, DataTable.__browser );
  23268. settings.oScroll.iBarWidth = DataTable.__browser.barWidth;
  23269. }
  23270. /**
  23271. * Array.prototype reduce[Right] method, used for browsers which don't support
  23272. * JS 1.6. Done this way to reduce code size, since we iterate either way
  23273. * @param {object} settings dataTables settings object
  23274. * @memberof DataTable#oApi
  23275. */
  23276. function _fnReduce ( that, fn, init, start, end, inc )
  23277. {
  23278. var
  23279. i = start,
  23280. value,
  23281. isSet = false;
  23282. if ( init !== undefined ) {
  23283. value = init;
  23284. isSet = true;
  23285. }
  23286. while ( i !== end ) {
  23287. if ( ! that.hasOwnProperty(i) ) {
  23288. continue;
  23289. }
  23290. value = isSet ?
  23291. fn( value, that[i], i, that ) :
  23292. that[i];
  23293. isSet = true;
  23294. i += inc;
  23295. }
  23296. return value;
  23297. }
  23298. /**
  23299. * Add a column to the list used for the table with default values
  23300. * @param {object} oSettings dataTables settings object
  23301. * @param {node} nTh The th element for this column
  23302. * @memberof DataTable#oApi
  23303. */
  23304. function _fnAddColumn( oSettings, nTh )
  23305. {
  23306. // Add column to aoColumns array
  23307. var oDefaults = DataTable.defaults.column;
  23308. var iCol = oSettings.aoColumns.length;
  23309. var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
  23310. "nTh": nTh ? nTh : document.createElement('th'),
  23311. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  23312. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  23313. "mData": oDefaults.mData ? oDefaults.mData : iCol,
  23314. idx: iCol
  23315. } );
  23316. oSettings.aoColumns.push( oCol );
  23317. // Add search object for column specific search. Note that the `searchCols[ iCol ]`
  23318. // passed into extend can be undefined. This allows the user to give a default
  23319. // with only some of the parameters defined, and also not give a default
  23320. var searchCols = oSettings.aoPreSearchCols;
  23321. searchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch, searchCols[ iCol ] );
  23322. // Use the default column options function to initialise classes etc
  23323. _fnColumnOptions( oSettings, iCol, $(nTh).data() );
  23324. }
  23325. /**
  23326. * Apply options for a column
  23327. * @param {object} oSettings dataTables settings object
  23328. * @param {int} iCol column index to consider
  23329. * @param {object} oOptions object with sType, bVisible and bSearchable etc
  23330. * @memberof DataTable#oApi
  23331. */
  23332. function _fnColumnOptions( oSettings, iCol, oOptions )
  23333. {
  23334. var oCol = oSettings.aoColumns[ iCol ];
  23335. var oClasses = oSettings.oClasses;
  23336. var th = $(oCol.nTh);
  23337. // Try to get width information from the DOM. We can't get it from CSS
  23338. // as we'd need to parse the CSS stylesheet. `width` option can override
  23339. if ( ! oCol.sWidthOrig ) {
  23340. // Width attribute
  23341. oCol.sWidthOrig = th.attr('width') || null;
  23342. // Style attribute
  23343. var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
  23344. if ( t ) {
  23345. oCol.sWidthOrig = t[1];
  23346. }
  23347. }
  23348. /* User specified column options */
  23349. if ( oOptions !== undefined && oOptions !== null )
  23350. {
  23351. // Backwards compatibility
  23352. _fnCompatCols( oOptions );
  23353. // Map camel case parameters to their Hungarian counterparts
  23354. _fnCamelToHungarian( DataTable.defaults.column, oOptions );
  23355. /* Backwards compatibility for mDataProp */
  23356. if ( oOptions.mDataProp !== undefined && !oOptions.mData )
  23357. {
  23358. oOptions.mData = oOptions.mDataProp;
  23359. }
  23360. if ( oOptions.sType )
  23361. {
  23362. oCol._sManualType = oOptions.sType;
  23363. }
  23364. // `class` is a reserved word in Javascript, so we need to provide
  23365. // the ability to use a valid name for the camel case input
  23366. if ( oOptions.className && ! oOptions.sClass )
  23367. {
  23368. oOptions.sClass = oOptions.className;
  23369. }
  23370. $.extend( oCol, oOptions );
  23371. _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
  23372. /* iDataSort to be applied (backwards compatibility), but aDataSort will take
  23373. * priority if defined
  23374. */
  23375. if ( oOptions.iDataSort !== undefined )
  23376. {
  23377. oCol.aDataSort = [ oOptions.iDataSort ];
  23378. }
  23379. _fnMap( oCol, oOptions, "aDataSort" );
  23380. }
  23381. /* Cache the data get and set functions for speed */
  23382. var mDataSrc = oCol.mData;
  23383. var mData = _fnGetObjectDataFn( mDataSrc );
  23384. var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
  23385. var attrTest = function( src ) {
  23386. return typeof src === 'string' && src.indexOf('@') !== -1;
  23387. };
  23388. oCol._bAttrSrc = $.isPlainObject( mDataSrc ) && (
  23389. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  23390. );
  23391. oCol._setter = null;
  23392. oCol.fnGetData = function (rowData, type, meta) {
  23393. var innerData = mData( rowData, type, undefined, meta );
  23394. return mRender && type ?
  23395. mRender( innerData, type, rowData, meta ) :
  23396. innerData;
  23397. };
  23398. oCol.fnSetData = function ( rowData, val, meta ) {
  23399. return _fnSetObjectDataFn( mDataSrc )( rowData, val, meta );
  23400. };
  23401. // Indicate if DataTables should read DOM data as an object or array
  23402. // Used in _fnGetRowElements
  23403. if ( typeof mDataSrc !== 'number' ) {
  23404. oSettings._rowReadObject = true;
  23405. }
  23406. /* Feature sorting overrides column specific when off */
  23407. if ( !oSettings.oFeatures.bSort )
  23408. {
  23409. oCol.bSortable = false;
  23410. th.addClass( oClasses.sSortableNone ); // Have to add class here as order event isn't called
  23411. }
  23412. /* Check that the class assignment is correct for sorting */
  23413. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  23414. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  23415. if ( !oCol.bSortable || (!bAsc && !bDesc) )
  23416. {
  23417. oCol.sSortingClass = oClasses.sSortableNone;
  23418. oCol.sSortingClassJUI = "";
  23419. }
  23420. else if ( bAsc && !bDesc )
  23421. {
  23422. oCol.sSortingClass = oClasses.sSortableAsc;
  23423. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  23424. }
  23425. else if ( !bAsc && bDesc )
  23426. {
  23427. oCol.sSortingClass = oClasses.sSortableDesc;
  23428. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  23429. }
  23430. else
  23431. {
  23432. oCol.sSortingClass = oClasses.sSortable;
  23433. oCol.sSortingClassJUI = oClasses.sSortJUI;
  23434. }
  23435. }
  23436. /**
  23437. * Adjust the table column widths for new data. Note: you would probably want to
  23438. * do a redraw after calling this function!
  23439. * @param {object} settings dataTables settings object
  23440. * @memberof DataTable#oApi
  23441. */
  23442. function _fnAdjustColumnSizing ( settings )
  23443. {
  23444. /* Not interested in doing column width calculation if auto-width is disabled */
  23445. if ( settings.oFeatures.bAutoWidth !== false )
  23446. {
  23447. var columns = settings.aoColumns;
  23448. _fnCalculateColumnWidths( settings );
  23449. for ( var i=0 , iLen=columns.length ; i<iLen ; i++ )
  23450. {
  23451. columns[i].nTh.style.width = columns[i].sWidth;
  23452. }
  23453. }
  23454. var scroll = settings.oScroll;
  23455. if ( scroll.sY !== '' || scroll.sX !== '')
  23456. {
  23457. _fnScrollDraw( settings );
  23458. }
  23459. _fnCallbackFire( settings, null, 'column-sizing', [settings] );
  23460. }
  23461. /**
  23462. * Covert the index of a visible column to the index in the data array (take account
  23463. * of hidden columns)
  23464. * @param {object} oSettings dataTables settings object
  23465. * @param {int} iMatch Visible column index to lookup
  23466. * @returns {int} i the data index
  23467. * @memberof DataTable#oApi
  23468. */
  23469. function _fnVisibleToColumnIndex( oSettings, iMatch )
  23470. {
  23471. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  23472. return typeof aiVis[iMatch] === 'number' ?
  23473. aiVis[iMatch] :
  23474. null;
  23475. }
  23476. /**
  23477. * Covert the index of an index in the data array and convert it to the visible
  23478. * column index (take account of hidden columns)
  23479. * @param {int} iMatch Column index to lookup
  23480. * @param {object} oSettings dataTables settings object
  23481. * @returns {int} i the data index
  23482. * @memberof DataTable#oApi
  23483. */
  23484. function _fnColumnIndexToVisible( oSettings, iMatch )
  23485. {
  23486. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  23487. var iPos = $.inArray( iMatch, aiVis );
  23488. return iPos !== -1 ? iPos : null;
  23489. }
  23490. /**
  23491. * Get the number of visible columns
  23492. * @param {object} oSettings dataTables settings object
  23493. * @returns {int} i the number of visible columns
  23494. * @memberof DataTable#oApi
  23495. */
  23496. function _fnVisbleColumns( oSettings )
  23497. {
  23498. var vis = 0;
  23499. // No reduce in IE8, use a loop for now
  23500. $.each( oSettings.aoColumns, function ( i, col ) {
  23501. if ( col.bVisible && $(col.nTh).css('display') !== 'none' ) {
  23502. vis++;
  23503. }
  23504. } );
  23505. return vis;
  23506. }
  23507. /**
  23508. * Get an array of column indexes that match a given property
  23509. * @param {object} oSettings dataTables settings object
  23510. * @param {string} sParam Parameter in aoColumns to look for - typically
  23511. * bVisible or bSearchable
  23512. * @returns {array} Array of indexes with matched properties
  23513. * @memberof DataTable#oApi
  23514. */
  23515. function _fnGetColumns( oSettings, sParam )
  23516. {
  23517. var a = [];
  23518. $.map( oSettings.aoColumns, function(val, i) {
  23519. if ( val[sParam] ) {
  23520. a.push( i );
  23521. }
  23522. } );
  23523. return a;
  23524. }
  23525. /**
  23526. * Calculate the 'type' of a column
  23527. * @param {object} settings dataTables settings object
  23528. * @memberof DataTable#oApi
  23529. */
  23530. function _fnColumnTypes ( settings )
  23531. {
  23532. var columns = settings.aoColumns;
  23533. var data = settings.aoData;
  23534. var types = DataTable.ext.type.detect;
  23535. var i, ien, j, jen, k, ken;
  23536. var col, cell, detectedType, cache;
  23537. // For each column, spin over the
  23538. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  23539. col = columns[i];
  23540. cache = [];
  23541. if ( ! col.sType && col._sManualType ) {
  23542. col.sType = col._sManualType;
  23543. }
  23544. else if ( ! col.sType ) {
  23545. for ( j=0, jen=types.length ; j<jen ; j++ ) {
  23546. for ( k=0, ken=data.length ; k<ken ; k++ ) {
  23547. // Use a cache array so we only need to get the type data
  23548. // from the formatter once (when using multiple detectors)
  23549. if ( cache[k] === undefined ) {
  23550. cache[k] = _fnGetCellData( settings, k, i, 'type' );
  23551. }
  23552. detectedType = types[j]( cache[k], settings );
  23553. // If null, then this type can't apply to this column, so
  23554. // rather than testing all cells, break out. There is an
  23555. // exception for the last type which is `html`. We need to
  23556. // scan all rows since it is possible to mix string and HTML
  23557. // types
  23558. if ( ! detectedType && j !== types.length-1 ) {
  23559. break;
  23560. }
  23561. // Only a single match is needed for html type since it is
  23562. // bottom of the pile and very similar to string
  23563. if ( detectedType === 'html' ) {
  23564. break;
  23565. }
  23566. }
  23567. // Type is valid for all data points in the column - use this
  23568. // type
  23569. if ( detectedType ) {
  23570. col.sType = detectedType;
  23571. break;
  23572. }
  23573. }
  23574. // Fall back - if no type was detected, always use string
  23575. if ( ! col.sType ) {
  23576. col.sType = 'string';
  23577. }
  23578. }
  23579. }
  23580. }
  23581. /**
  23582. * Take the column definitions and static columns arrays and calculate how
  23583. * they relate to column indexes. The callback function will then apply the
  23584. * definition found for a column to a suitable configuration object.
  23585. * @param {object} oSettings dataTables settings object
  23586. * @param {array} aoColDefs The aoColumnDefs array that is to be applied
  23587. * @param {array} aoCols The aoColumns array that defines columns individually
  23588. * @param {function} fn Callback function - takes two parameters, the calculated
  23589. * column index and the definition for that column.
  23590. * @memberof DataTable#oApi
  23591. */
  23592. function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
  23593. {
  23594. var i, iLen, j, jLen, k, kLen, def;
  23595. var columns = oSettings.aoColumns;
  23596. // Column definitions with aTargets
  23597. if ( aoColDefs )
  23598. {
  23599. /* Loop over the definitions array - loop in reverse so first instance has priority */
  23600. for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
  23601. {
  23602. def = aoColDefs[i];
  23603. /* Each definition can target multiple columns, as it is an array */
  23604. var aTargets = def.targets !== undefined ?
  23605. def.targets :
  23606. def.aTargets;
  23607. if ( ! $.isArray( aTargets ) )
  23608. {
  23609. aTargets = [ aTargets ];
  23610. }
  23611. for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
  23612. {
  23613. if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
  23614. {
  23615. /* Add columns that we don't yet know about */
  23616. while( columns.length <= aTargets[j] )
  23617. {
  23618. _fnAddColumn( oSettings );
  23619. }
  23620. /* Integer, basic index */
  23621. fn( aTargets[j], def );
  23622. }
  23623. else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
  23624. {
  23625. /* Negative integer, right to left column counting */
  23626. fn( columns.length+aTargets[j], def );
  23627. }
  23628. else if ( typeof aTargets[j] === 'string' )
  23629. {
  23630. /* Class name matching on TH element */
  23631. for ( k=0, kLen=columns.length ; k<kLen ; k++ )
  23632. {
  23633. if ( aTargets[j] == "_all" ||
  23634. $(columns[k].nTh).hasClass( aTargets[j] ) )
  23635. {
  23636. fn( k, def );
  23637. }
  23638. }
  23639. }
  23640. }
  23641. }
  23642. }
  23643. // Statically defined columns array
  23644. if ( aoCols )
  23645. {
  23646. for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
  23647. {
  23648. fn( i, aoCols[i] );
  23649. }
  23650. }
  23651. }
  23652. /**
  23653. * Add a data array to the table, creating DOM node etc. This is the parallel to
  23654. * _fnGatherData, but for adding rows from a Javascript source, rather than a
  23655. * DOM source.
  23656. * @param {object} oSettings dataTables settings object
  23657. * @param {array} aData data array to be added
  23658. * @param {node} [nTr] TR element to add to the table - optional. If not given,
  23659. * DataTables will create a row automatically
  23660. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  23661. * if nTr is.
  23662. * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
  23663. * @memberof DataTable#oApi
  23664. */
  23665. function _fnAddData ( oSettings, aDataIn, nTr, anTds )
  23666. {
  23667. /* Create the object for storing information about this new row */
  23668. var iRow = oSettings.aoData.length;
  23669. var oData = $.extend( true, {}, DataTable.models.oRow, {
  23670. src: nTr ? 'dom' : 'data',
  23671. idx: iRow
  23672. } );
  23673. oData._aData = aDataIn;
  23674. oSettings.aoData.push( oData );
  23675. /* Create the cells */
  23676. var nTd, sThisType;
  23677. var columns = oSettings.aoColumns;
  23678. // Invalidate the column types as the new data needs to be revalidated
  23679. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  23680. {
  23681. columns[i].sType = null;
  23682. }
  23683. /* Add to the display array */
  23684. oSettings.aiDisplayMaster.push( iRow );
  23685. var id = oSettings.rowIdFn( aDataIn );
  23686. if ( id !== undefined ) {
  23687. oSettings.aIds[ id ] = oData;
  23688. }
  23689. /* Create the DOM information, or register it if already present */
  23690. if ( nTr || ! oSettings.oFeatures.bDeferRender )
  23691. {
  23692. _fnCreateTr( oSettings, iRow, nTr, anTds );
  23693. }
  23694. return iRow;
  23695. }
  23696. /**
  23697. * Add one or more TR elements to the table. Generally we'd expect to
  23698. * use this for reading data from a DOM sourced table, but it could be
  23699. * used for an TR element. Note that if a TR is given, it is used (i.e.
  23700. * it is not cloned).
  23701. * @param {object} settings dataTables settings object
  23702. * @param {array|node|jQuery} trs The TR element(s) to add to the table
  23703. * @returns {array} Array of indexes for the added rows
  23704. * @memberof DataTable#oApi
  23705. */
  23706. function _fnAddTr( settings, trs )
  23707. {
  23708. var row;
  23709. // Allow an individual node to be passed in
  23710. if ( ! (trs instanceof $) ) {
  23711. trs = $(trs);
  23712. }
  23713. return trs.map( function (i, el) {
  23714. row = _fnGetRowElements( settings, el );
  23715. return _fnAddData( settings, row.data, el, row.cells );
  23716. } );
  23717. }
  23718. /**
  23719. * Take a TR element and convert it to an index in aoData
  23720. * @param {object} oSettings dataTables settings object
  23721. * @param {node} n the TR element to find
  23722. * @returns {int} index if the node is found, null if not
  23723. * @memberof DataTable#oApi
  23724. */
  23725. function _fnNodeToDataIndex( oSettings, n )
  23726. {
  23727. return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
  23728. }
  23729. /**
  23730. * Take a TD element and convert it into a column data index (not the visible index)
  23731. * @param {object} oSettings dataTables settings object
  23732. * @param {int} iRow The row number the TD/TH can be found in
  23733. * @param {node} n The TD/TH element to find
  23734. * @returns {int} index if the node is found, -1 if not
  23735. * @memberof DataTable#oApi
  23736. */
  23737. function _fnNodeToColumnIndex( oSettings, iRow, n )
  23738. {
  23739. return $.inArray( n, oSettings.aoData[ iRow ].anCells );
  23740. }
  23741. /**
  23742. * Get the data for a given cell from the internal cache, taking into account data mapping
  23743. * @param {object} settings dataTables settings object
  23744. * @param {int} rowIdx aoData row id
  23745. * @param {int} colIdx Column index
  23746. * @param {string} type data get type ('display', 'type' 'filter' 'sort')
  23747. * @returns {*} Cell data
  23748. * @memberof DataTable#oApi
  23749. */
  23750. function _fnGetCellData( settings, rowIdx, colIdx, type )
  23751. {
  23752. var draw = settings.iDraw;
  23753. var col = settings.aoColumns[colIdx];
  23754. var rowData = settings.aoData[rowIdx]._aData;
  23755. var defaultContent = col.sDefaultContent;
  23756. var cellData = col.fnGetData( rowData, type, {
  23757. settings: settings,
  23758. row: rowIdx,
  23759. col: colIdx
  23760. } );
  23761. if ( cellData === undefined ) {
  23762. if ( settings.iDrawError != draw && defaultContent === null ) {
  23763. _fnLog( settings, 0, "Requested unknown parameter "+
  23764. (typeof col.mData=='function' ? '{function}' : "'"+col.mData+"'")+
  23765. " for row "+rowIdx+", column "+colIdx, 4 );
  23766. settings.iDrawError = draw;
  23767. }
  23768. return defaultContent;
  23769. }
  23770. // When the data source is null and a specific data type is requested (i.e.
  23771. // not the original data), we can use default column data
  23772. if ( (cellData === rowData || cellData === null) && defaultContent !== null && type !== undefined ) {
  23773. cellData = defaultContent;
  23774. }
  23775. else if ( typeof cellData === 'function' ) {
  23776. // If the data source is a function, then we run it and use the return,
  23777. // executing in the scope of the data object (for instances)
  23778. return cellData.call( rowData );
  23779. }
  23780. if ( cellData === null && type == 'display' ) {
  23781. return '';
  23782. }
  23783. return cellData;
  23784. }
  23785. /**
  23786. * Set the value for a specific cell, into the internal data cache
  23787. * @param {object} settings dataTables settings object
  23788. * @param {int} rowIdx aoData row id
  23789. * @param {int} colIdx Column index
  23790. * @param {*} val Value to set
  23791. * @memberof DataTable#oApi
  23792. */
  23793. function _fnSetCellData( settings, rowIdx, colIdx, val )
  23794. {
  23795. var col = settings.aoColumns[colIdx];
  23796. var rowData = settings.aoData[rowIdx]._aData;
  23797. col.fnSetData( rowData, val, {
  23798. settings: settings,
  23799. row: rowIdx,
  23800. col: colIdx
  23801. } );
  23802. }
  23803. // Private variable that is used to match action syntax in the data property object
  23804. var __reArray = /\[.*?\]$/;
  23805. var __reFn = /\(\)$/;
  23806. /**
  23807. * Split string on periods, taking into account escaped periods
  23808. * @param {string} str String to split
  23809. * @return {array} Split string
  23810. */
  23811. function _fnSplitObjNotation( str )
  23812. {
  23813. return $.map( str.match(/(\\.|[^\.])+/g) || [''], function ( s ) {
  23814. return s.replace(/\\./g, '.');
  23815. } );
  23816. }
  23817. /**
  23818. * Return a function that can be used to get data from a source object, taking
  23819. * into account the ability to use nested objects as a source
  23820. * @param {string|int|function} mSource The data source for the object
  23821. * @returns {function} Data get function
  23822. * @memberof DataTable#oApi
  23823. */
  23824. function _fnGetObjectDataFn( mSource )
  23825. {
  23826. if ( $.isPlainObject( mSource ) )
  23827. {
  23828. /* Build an object of get functions, and wrap them in a single call */
  23829. var o = {};
  23830. $.each( mSource, function (key, val) {
  23831. if ( val ) {
  23832. o[key] = _fnGetObjectDataFn( val );
  23833. }
  23834. } );
  23835. return function (data, type, row, meta) {
  23836. var t = o[type] || o._;
  23837. return t !== undefined ?
  23838. t(data, type, row, meta) :
  23839. data;
  23840. };
  23841. }
  23842. else if ( mSource === null )
  23843. {
  23844. /* Give an empty string for rendering / sorting etc */
  23845. return function (data) { // type, row and meta also passed, but not used
  23846. return data;
  23847. };
  23848. }
  23849. else if ( typeof mSource === 'function' )
  23850. {
  23851. return function (data, type, row, meta) {
  23852. return mSource( data, type, row, meta );
  23853. };
  23854. }
  23855. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  23856. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  23857. {
  23858. /* If there is a . in the source string then the data source is in a
  23859. * nested object so we loop over the data for each level to get the next
  23860. * level down. On each loop we test for undefined, and if found immediately
  23861. * return. This allows entire objects to be missing and sDefaultContent to
  23862. * be used if defined, rather than throwing an error
  23863. */
  23864. var fetchData = function (data, type, src) {
  23865. var arrayNotation, funcNotation, out, innerSrc;
  23866. if ( src !== "" )
  23867. {
  23868. var a = _fnSplitObjNotation( src );
  23869. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  23870. {
  23871. // Check if we are dealing with special notation
  23872. arrayNotation = a[i].match(__reArray);
  23873. funcNotation = a[i].match(__reFn);
  23874. if ( arrayNotation )
  23875. {
  23876. // Array notation
  23877. a[i] = a[i].replace(__reArray, '');
  23878. // Condition allows simply [] to be passed in
  23879. if ( a[i] !== "" ) {
  23880. data = data[ a[i] ];
  23881. }
  23882. out = [];
  23883. // Get the remainder of the nested object to get
  23884. a.splice( 0, i+1 );
  23885. innerSrc = a.join('.');
  23886. // Traverse each entry in the array getting the properties requested
  23887. if ( $.isArray( data ) ) {
  23888. for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
  23889. out.push( fetchData( data[j], type, innerSrc ) );
  23890. }
  23891. }
  23892. // If a string is given in between the array notation indicators, that
  23893. // is used to join the strings together, otherwise an array is returned
  23894. var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
  23895. data = (join==="") ? out : out.join(join);
  23896. // The inner call to fetchData has already traversed through the remainder
  23897. // of the source requested, so we exit from the loop
  23898. break;
  23899. }
  23900. else if ( funcNotation )
  23901. {
  23902. // Function call
  23903. a[i] = a[i].replace(__reFn, '');
  23904. data = data[ a[i] ]();
  23905. continue;
  23906. }
  23907. if ( data === null || data[ a[i] ] === undefined )
  23908. {
  23909. return undefined;
  23910. }
  23911. data = data[ a[i] ];
  23912. }
  23913. }
  23914. return data;
  23915. };
  23916. return function (data, type) { // row and meta also passed, but not used
  23917. return fetchData( data, type, mSource );
  23918. };
  23919. }
  23920. else
  23921. {
  23922. /* Array or flat object mapping */
  23923. return function (data, type) { // row and meta also passed, but not used
  23924. return data[mSource];
  23925. };
  23926. }
  23927. }
  23928. /**
  23929. * Return a function that can be used to set data from a source object, taking
  23930. * into account the ability to use nested objects as a source
  23931. * @param {string|int|function} mSource The data source for the object
  23932. * @returns {function} Data set function
  23933. * @memberof DataTable#oApi
  23934. */
  23935. function _fnSetObjectDataFn( mSource )
  23936. {
  23937. if ( $.isPlainObject( mSource ) )
  23938. {
  23939. /* Unlike get, only the underscore (global) option is used for for
  23940. * setting data since we don't know the type here. This is why an object
  23941. * option is not documented for `mData` (which is read/write), but it is
  23942. * for `mRender` which is read only.
  23943. */
  23944. return _fnSetObjectDataFn( mSource._ );
  23945. }
  23946. else if ( mSource === null )
  23947. {
  23948. /* Nothing to do when the data source is null */
  23949. return function () {};
  23950. }
  23951. else if ( typeof mSource === 'function' )
  23952. {
  23953. return function (data, val, meta) {
  23954. mSource( data, 'set', val, meta );
  23955. };
  23956. }
  23957. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  23958. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  23959. {
  23960. /* Like the get, we need to get data from a nested object */
  23961. var setData = function (data, val, src) {
  23962. var a = _fnSplitObjNotation( src ), b;
  23963. var aLast = a[a.length-1];
  23964. var arrayNotation, funcNotation, o, innerSrc;
  23965. for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
  23966. {
  23967. // Check if we are dealing with an array notation request
  23968. arrayNotation = a[i].match(__reArray);
  23969. funcNotation = a[i].match(__reFn);
  23970. if ( arrayNotation )
  23971. {
  23972. a[i] = a[i].replace(__reArray, '');
  23973. data[ a[i] ] = [];
  23974. // Get the remainder of the nested object to set so we can recurse
  23975. b = a.slice();
  23976. b.splice( 0, i+1 );
  23977. innerSrc = b.join('.');
  23978. // Traverse each entry in the array setting the properties requested
  23979. if ( $.isArray( val ) )
  23980. {
  23981. for ( var j=0, jLen=val.length ; j<jLen ; j++ )
  23982. {
  23983. o = {};
  23984. setData( o, val[j], innerSrc );
  23985. data[ a[i] ].push( o );
  23986. }
  23987. }
  23988. else
  23989. {
  23990. // We've been asked to save data to an array, but it
  23991. // isn't array data to be saved. Best that can be done
  23992. // is to just save the value.
  23993. data[ a[i] ] = val;
  23994. }
  23995. // The inner call to setData has already traversed through the remainder
  23996. // of the source and has set the data, thus we can exit here
  23997. return;
  23998. }
  23999. else if ( funcNotation )
  24000. {
  24001. // Function call
  24002. a[i] = a[i].replace(__reFn, '');
  24003. data = data[ a[i] ]( val );
  24004. }
  24005. // If the nested object doesn't currently exist - since we are
  24006. // trying to set the value - create it
  24007. if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
  24008. {
  24009. data[ a[i] ] = {};
  24010. }
  24011. data = data[ a[i] ];
  24012. }
  24013. // Last item in the input - i.e, the actual set
  24014. if ( aLast.match(__reFn ) )
  24015. {
  24016. // Function call
  24017. data = data[ aLast.replace(__reFn, '') ]( val );
  24018. }
  24019. else
  24020. {
  24021. // If array notation is used, we just want to strip it and use the property name
  24022. // and assign the value. If it isn't used, then we get the result we want anyway
  24023. data[ aLast.replace(__reArray, '') ] = val;
  24024. }
  24025. };
  24026. return function (data, val) { // meta is also passed in, but not used
  24027. return setData( data, val, mSource );
  24028. };
  24029. }
  24030. else
  24031. {
  24032. /* Array or flat object mapping */
  24033. return function (data, val) { // meta is also passed in, but not used
  24034. data[mSource] = val;
  24035. };
  24036. }
  24037. }
  24038. /**
  24039. * Return an array with the full table data
  24040. * @param {object} oSettings dataTables settings object
  24041. * @returns array {array} aData Master data array
  24042. * @memberof DataTable#oApi
  24043. */
  24044. function _fnGetDataMaster ( settings )
  24045. {
  24046. return _pluck( settings.aoData, '_aData' );
  24047. }
  24048. /**
  24049. * Nuke the table
  24050. * @param {object} oSettings dataTables settings object
  24051. * @memberof DataTable#oApi
  24052. */
  24053. function _fnClearTable( settings )
  24054. {
  24055. settings.aoData.length = 0;
  24056. settings.aiDisplayMaster.length = 0;
  24057. settings.aiDisplay.length = 0;
  24058. settings.aIds = {};
  24059. }
  24060. /**
  24061. * Take an array of integers (index array) and remove a target integer (value - not
  24062. * the key!)
  24063. * @param {array} a Index array to target
  24064. * @param {int} iTarget value to find
  24065. * @memberof DataTable#oApi
  24066. */
  24067. function _fnDeleteIndex( a, iTarget, splice )
  24068. {
  24069. var iTargetIndex = -1;
  24070. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  24071. {
  24072. if ( a[i] == iTarget )
  24073. {
  24074. iTargetIndex = i;
  24075. }
  24076. else if ( a[i] > iTarget )
  24077. {
  24078. a[i]--;
  24079. }
  24080. }
  24081. if ( iTargetIndex != -1 && splice === undefined )
  24082. {
  24083. a.splice( iTargetIndex, 1 );
  24084. }
  24085. }
  24086. /**
  24087. * Mark cached data as invalid such that a re-read of the data will occur when
  24088. * the cached data is next requested. Also update from the data source object.
  24089. *
  24090. * @param {object} settings DataTables settings object
  24091. * @param {int} rowIdx Row index to invalidate
  24092. * @param {string} [src] Source to invalidate from: undefined, 'auto', 'dom'
  24093. * or 'data'
  24094. * @param {int} [colIdx] Column index to invalidate. If undefined the whole
  24095. * row will be invalidated
  24096. * @memberof DataTable#oApi
  24097. *
  24098. * @todo For the modularisation of v1.11 this will need to become a callback, so
  24099. * the sort and filter methods can subscribe to it. That will required
  24100. * initialisation options for sorting, which is why it is not already baked in
  24101. */
  24102. function _fnInvalidate( settings, rowIdx, src, colIdx )
  24103. {
  24104. var row = settings.aoData[ rowIdx ];
  24105. var i, ien;
  24106. var cellWrite = function ( cell, col ) {
  24107. // This is very frustrating, but in IE if you just write directly
  24108. // to innerHTML, and elements that are overwritten are GC'ed,
  24109. // even if there is a reference to them elsewhere
  24110. while ( cell.childNodes.length ) {
  24111. cell.removeChild( cell.firstChild );
  24112. }
  24113. cell.innerHTML = _fnGetCellData( settings, rowIdx, col, 'display' );
  24114. };
  24115. // Are we reading last data from DOM or the data object?
  24116. if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
  24117. // Read the data from the DOM
  24118. row._aData = _fnGetRowElements(
  24119. settings, row, colIdx, colIdx === undefined ? undefined : row._aData
  24120. )
  24121. .data;
  24122. }
  24123. else {
  24124. // Reading from data object, update the DOM
  24125. var cells = row.anCells;
  24126. if ( cells ) {
  24127. if ( colIdx !== undefined ) {
  24128. cellWrite( cells[colIdx], colIdx );
  24129. }
  24130. else {
  24131. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  24132. cellWrite( cells[i], i );
  24133. }
  24134. }
  24135. }
  24136. }
  24137. // For both row and cell invalidation, the cached data for sorting and
  24138. // filtering is nulled out
  24139. row._aSortData = null;
  24140. row._aFilterData = null;
  24141. // Invalidate the type for a specific column (if given) or all columns since
  24142. // the data might have changed
  24143. var cols = settings.aoColumns;
  24144. if ( colIdx !== undefined ) {
  24145. cols[ colIdx ].sType = null;
  24146. }
  24147. else {
  24148. for ( i=0, ien=cols.length ; i<ien ; i++ ) {
  24149. cols[i].sType = null;
  24150. }
  24151. // Update DataTables special `DT_*` attributes for the row
  24152. _fnRowAttributes( settings, row );
  24153. }
  24154. }
  24155. /**
  24156. * Build a data source object from an HTML row, reading the contents of the
  24157. * cells that are in the row.
  24158. *
  24159. * @param {object} settings DataTables settings object
  24160. * @param {node|object} TR element from which to read data or existing row
  24161. * object from which to re-read the data from the cells
  24162. * @param {int} [colIdx] Optional column index
  24163. * @param {array|object} [d] Data source object. If `colIdx` is given then this
  24164. * parameter should also be given and will be used to write the data into.
  24165. * Only the column in question will be written
  24166. * @returns {object} Object with two parameters: `data` the data read, in
  24167. * document order, and `cells` and array of nodes (they can be useful to the
  24168. * caller, so rather than needing a second traversal to get them, just return
  24169. * them from here).
  24170. * @memberof DataTable#oApi
  24171. */
  24172. function _fnGetRowElements( settings, row, colIdx, d )
  24173. {
  24174. var
  24175. tds = [],
  24176. td = row.firstChild,
  24177. name, col, o, i=0, contents,
  24178. columns = settings.aoColumns,
  24179. objectRead = settings._rowReadObject;
  24180. // Allow the data object to be passed in, or construct
  24181. d = d !== undefined ?
  24182. d :
  24183. objectRead ?
  24184. {} :
  24185. [];
  24186. var attr = function ( str, td ) {
  24187. if ( typeof str === 'string' ) {
  24188. var idx = str.indexOf('@');
  24189. if ( idx !== -1 ) {
  24190. var attr = str.substring( idx+1 );
  24191. var setter = _fnSetObjectDataFn( str );
  24192. setter( d, td.getAttribute( attr ) );
  24193. }
  24194. }
  24195. };
  24196. // Read data from a cell and store into the data object
  24197. var cellProcess = function ( cell ) {
  24198. if ( colIdx === undefined || colIdx === i ) {
  24199. col = columns[i];
  24200. contents = $.trim(cell.innerHTML);
  24201. if ( col && col._bAttrSrc ) {
  24202. var setter = _fnSetObjectDataFn( col.mData._ );
  24203. setter( d, contents );
  24204. attr( col.mData.sort, cell );
  24205. attr( col.mData.type, cell );
  24206. attr( col.mData.filter, cell );
  24207. }
  24208. else {
  24209. // Depending on the `data` option for the columns the data can
  24210. // be read to either an object or an array.
  24211. if ( objectRead ) {
  24212. if ( ! col._setter ) {
  24213. // Cache the setter function
  24214. col._setter = _fnSetObjectDataFn( col.mData );
  24215. }
  24216. col._setter( d, contents );
  24217. }
  24218. else {
  24219. d[i] = contents;
  24220. }
  24221. }
  24222. }
  24223. i++;
  24224. };
  24225. if ( td ) {
  24226. // `tr` element was passed in
  24227. while ( td ) {
  24228. name = td.nodeName.toUpperCase();
  24229. if ( name == "TD" || name == "TH" ) {
  24230. cellProcess( td );
  24231. tds.push( td );
  24232. }
  24233. td = td.nextSibling;
  24234. }
  24235. }
  24236. else {
  24237. // Existing row object passed in
  24238. tds = row.anCells;
  24239. for ( var j=0, jen=tds.length ; j<jen ; j++ ) {
  24240. cellProcess( tds[j] );
  24241. }
  24242. }
  24243. // Read the ID from the DOM if present
  24244. var rowNode = row.firstChild ? row : row.nTr;
  24245. if ( rowNode ) {
  24246. var id = rowNode.getAttribute( 'id' );
  24247. if ( id ) {
  24248. _fnSetObjectDataFn( settings.rowId )( d, id );
  24249. }
  24250. }
  24251. return {
  24252. data: d,
  24253. cells: tds
  24254. };
  24255. }
  24256. /**
  24257. * Create a new TR element (and it's TD children) for a row
  24258. * @param {object} oSettings dataTables settings object
  24259. * @param {int} iRow Row to consider
  24260. * @param {node} [nTrIn] TR element to add to the table - optional. If not given,
  24261. * DataTables will create a row automatically
  24262. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  24263. * if nTr is.
  24264. * @memberof DataTable#oApi
  24265. */
  24266. function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
  24267. {
  24268. var
  24269. row = oSettings.aoData[iRow],
  24270. rowData = row._aData,
  24271. cells = [],
  24272. nTr, nTd, oCol,
  24273. i, iLen;
  24274. if ( row.nTr === null )
  24275. {
  24276. nTr = nTrIn || document.createElement('tr');
  24277. row.nTr = nTr;
  24278. row.anCells = cells;
  24279. /* Use a private property on the node to allow reserve mapping from the node
  24280. * to the aoData array for fast look up
  24281. */
  24282. nTr._DT_RowIndex = iRow;
  24283. /* Special parameters can be given by the data source to be used on the row */
  24284. _fnRowAttributes( oSettings, row );
  24285. /* Process each column */
  24286. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  24287. {
  24288. oCol = oSettings.aoColumns[i];
  24289. nTd = nTrIn ? anTds[i] : document.createElement( oCol.sCellType );
  24290. nTd._DT_CellIndex = {
  24291. row: iRow,
  24292. column: i
  24293. };
  24294. cells.push( nTd );
  24295. // Need to create the HTML if new, or if a rendering function is defined
  24296. if ( (!nTrIn || oCol.mRender || oCol.mData !== i) &&
  24297. (!$.isPlainObject(oCol.mData) || oCol.mData._ !== i+'.display')
  24298. ) {
  24299. nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
  24300. }
  24301. /* Add user defined class */
  24302. if ( oCol.sClass )
  24303. {
  24304. nTd.className += ' '+oCol.sClass;
  24305. }
  24306. // Visibility - add or remove as required
  24307. if ( oCol.bVisible && ! nTrIn )
  24308. {
  24309. nTr.appendChild( nTd );
  24310. }
  24311. else if ( ! oCol.bVisible && nTrIn )
  24312. {
  24313. nTd.parentNode.removeChild( nTd );
  24314. }
  24315. if ( oCol.fnCreatedCell )
  24316. {
  24317. oCol.fnCreatedCell.call( oSettings.oInstance,
  24318. nTd, _fnGetCellData( oSettings, iRow, i ), rowData, iRow, i
  24319. );
  24320. }
  24321. }
  24322. _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow] );
  24323. }
  24324. // Remove once webkit bug 131819 and Chromium bug 365619 have been resolved
  24325. // and deployed
  24326. row.nTr.setAttribute( 'role', 'row' );
  24327. }
  24328. /**
  24329. * Add attributes to a row based on the special `DT_*` parameters in a data
  24330. * source object.
  24331. * @param {object} settings DataTables settings object
  24332. * @param {object} DataTables row object for the row to be modified
  24333. * @memberof DataTable#oApi
  24334. */
  24335. function _fnRowAttributes( settings, row )
  24336. {
  24337. var tr = row.nTr;
  24338. var data = row._aData;
  24339. if ( tr ) {
  24340. var id = settings.rowIdFn( data );
  24341. if ( id ) {
  24342. tr.id = id;
  24343. }
  24344. if ( data.DT_RowClass ) {
  24345. // Remove any classes added by DT_RowClass before
  24346. var a = data.DT_RowClass.split(' ');
  24347. row.__rowc = row.__rowc ?
  24348. _unique( row.__rowc.concat( a ) ) :
  24349. a;
  24350. $(tr)
  24351. .removeClass( row.__rowc.join(' ') )
  24352. .addClass( data.DT_RowClass );
  24353. }
  24354. if ( data.DT_RowAttr ) {
  24355. $(tr).attr( data.DT_RowAttr );
  24356. }
  24357. if ( data.DT_RowData ) {
  24358. $(tr).data( data.DT_RowData );
  24359. }
  24360. }
  24361. }
  24362. /**
  24363. * Create the HTML header for the table
  24364. * @param {object} oSettings dataTables settings object
  24365. * @memberof DataTable#oApi
  24366. */
  24367. function _fnBuildHead( oSettings )
  24368. {
  24369. var i, ien, cell, row, column;
  24370. var thead = oSettings.nTHead;
  24371. var tfoot = oSettings.nTFoot;
  24372. var createHeader = $('th, td', thead).length === 0;
  24373. var classes = oSettings.oClasses;
  24374. var columns = oSettings.aoColumns;
  24375. if ( createHeader ) {
  24376. row = $('<tr/>').appendTo( thead );
  24377. }
  24378. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  24379. column = columns[i];
  24380. cell = $( column.nTh ).addClass( column.sClass );
  24381. if ( createHeader ) {
  24382. cell.appendTo( row );
  24383. }
  24384. // 1.11 move into sorting
  24385. if ( oSettings.oFeatures.bSort ) {
  24386. cell.addClass( column.sSortingClass );
  24387. if ( column.bSortable !== false ) {
  24388. cell
  24389. .attr( 'tabindex', oSettings.iTabIndex )
  24390. .attr( 'aria-controls', oSettings.sTableId );
  24391. _fnSortAttachListener( oSettings, column.nTh, i );
  24392. }
  24393. }
  24394. if ( column.sTitle != cell[0].innerHTML ) {
  24395. cell.html( column.sTitle );
  24396. }
  24397. _fnRenderer( oSettings, 'header' )(
  24398. oSettings, cell, column, classes
  24399. );
  24400. }
  24401. if ( createHeader ) {
  24402. _fnDetectHeader( oSettings.aoHeader, thead );
  24403. }
  24404. /* ARIA role for the rows */
  24405. $(thead).find('>tr').attr('role', 'row');
  24406. /* Deal with the footer - add classes if required */
  24407. $(thead).find('>tr>th, >tr>td').addClass( classes.sHeaderTH );
  24408. $(tfoot).find('>tr>th, >tr>td').addClass( classes.sFooterTH );
  24409. // Cache the footer cells. Note that we only take the cells from the first
  24410. // row in the footer. If there is more than one row the user wants to
  24411. // interact with, they need to use the table().foot() method. Note also this
  24412. // allows cells to be used for multiple columns using colspan
  24413. if ( tfoot !== null ) {
  24414. var cells = oSettings.aoFooter[0];
  24415. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  24416. column = columns[i];
  24417. column.nTf = cells[i].cell;
  24418. if ( column.sClass ) {
  24419. $(column.nTf).addClass( column.sClass );
  24420. }
  24421. }
  24422. }
  24423. }
  24424. /**
  24425. * Draw the header (or footer) element based on the column visibility states. The
  24426. * methodology here is to use the layout array from _fnDetectHeader, modified for
  24427. * the instantaneous column visibility, to construct the new layout. The grid is
  24428. * traversed over cell at a time in a rows x columns grid fashion, although each
  24429. * cell insert can cover multiple elements in the grid - which is tracks using the
  24430. * aApplied array. Cell inserts in the grid will only occur where there isn't
  24431. * already a cell in that position.
  24432. * @param {object} oSettings dataTables settings object
  24433. * @param array {objects} aoSource Layout array from _fnDetectHeader
  24434. * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
  24435. * @memberof DataTable#oApi
  24436. */
  24437. function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
  24438. {
  24439. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  24440. var aoLocal = [];
  24441. var aApplied = [];
  24442. var iColumns = oSettings.aoColumns.length;
  24443. var iRowspan, iColspan;
  24444. if ( ! aoSource )
  24445. {
  24446. return;
  24447. }
  24448. if ( bIncludeHidden === undefined )
  24449. {
  24450. bIncludeHidden = false;
  24451. }
  24452. /* Make a copy of the master layout array, but without the visible columns in it */
  24453. for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
  24454. {
  24455. aoLocal[i] = aoSource[i].slice();
  24456. aoLocal[i].nTr = aoSource[i].nTr;
  24457. /* Remove any columns which are currently hidden */
  24458. for ( j=iColumns-1 ; j>=0 ; j-- )
  24459. {
  24460. if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
  24461. {
  24462. aoLocal[i].splice( j, 1 );
  24463. }
  24464. }
  24465. /* Prep the applied array - it needs an element for each row */
  24466. aApplied.push( [] );
  24467. }
  24468. for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
  24469. {
  24470. nLocalTr = aoLocal[i].nTr;
  24471. /* All cells are going to be replaced, so empty out the row */
  24472. if ( nLocalTr )
  24473. {
  24474. while( (n = nLocalTr.firstChild) )
  24475. {
  24476. nLocalTr.removeChild( n );
  24477. }
  24478. }
  24479. for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
  24480. {
  24481. iRowspan = 1;
  24482. iColspan = 1;
  24483. /* Check to see if there is already a cell (row/colspan) covering our target
  24484. * insert point. If there is, then there is nothing to do.
  24485. */
  24486. if ( aApplied[i][j] === undefined )
  24487. {
  24488. nLocalTr.appendChild( aoLocal[i][j].cell );
  24489. aApplied[i][j] = 1;
  24490. /* Expand the cell to cover as many rows as needed */
  24491. while ( aoLocal[i+iRowspan] !== undefined &&
  24492. aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
  24493. {
  24494. aApplied[i+iRowspan][j] = 1;
  24495. iRowspan++;
  24496. }
  24497. /* Expand the cell to cover as many columns as needed */
  24498. while ( aoLocal[i][j+iColspan] !== undefined &&
  24499. aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
  24500. {
  24501. /* Must update the applied array over the rows for the columns */
  24502. for ( k=0 ; k<iRowspan ; k++ )
  24503. {
  24504. aApplied[i+k][j+iColspan] = 1;
  24505. }
  24506. iColspan++;
  24507. }
  24508. /* Do the actual expansion in the DOM */
  24509. $(aoLocal[i][j].cell)
  24510. .attr('rowspan', iRowspan)
  24511. .attr('colspan', iColspan);
  24512. }
  24513. }
  24514. }
  24515. }
  24516. /**
  24517. * Insert the required TR nodes into the table for display
  24518. * @param {object} oSettings dataTables settings object
  24519. * @memberof DataTable#oApi
  24520. */
  24521. function _fnDraw( oSettings )
  24522. {
  24523. /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
  24524. var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
  24525. if ( $.inArray( false, aPreDraw ) !== -1 )
  24526. {
  24527. _fnProcessingDisplay( oSettings, false );
  24528. return;
  24529. }
  24530. var i, iLen, n;
  24531. var anRows = [];
  24532. var iRowCount = 0;
  24533. var asStripeClasses = oSettings.asStripeClasses;
  24534. var iStripes = asStripeClasses.length;
  24535. var iOpenRows = oSettings.aoOpenRows.length;
  24536. var oLang = oSettings.oLanguage;
  24537. var iInitDisplayStart = oSettings.iInitDisplayStart;
  24538. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  24539. var aiDisplay = oSettings.aiDisplay;
  24540. oSettings.bDrawing = true;
  24541. /* Check and see if we have an initial draw position from state saving */
  24542. if ( iInitDisplayStart !== undefined && iInitDisplayStart !== -1 )
  24543. {
  24544. oSettings._iDisplayStart = bServerSide ?
  24545. iInitDisplayStart :
  24546. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  24547. 0 :
  24548. iInitDisplayStart;
  24549. oSettings.iInitDisplayStart = -1;
  24550. }
  24551. var iDisplayStart = oSettings._iDisplayStart;
  24552. var iDisplayEnd = oSettings.fnDisplayEnd();
  24553. /* Server-side processing draw intercept */
  24554. if ( oSettings.bDeferLoading )
  24555. {
  24556. oSettings.bDeferLoading = false;
  24557. oSettings.iDraw++;
  24558. _fnProcessingDisplay( oSettings, false );
  24559. }
  24560. else if ( !bServerSide )
  24561. {
  24562. oSettings.iDraw++;
  24563. }
  24564. else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
  24565. {
  24566. return;
  24567. }
  24568. if ( aiDisplay.length !== 0 )
  24569. {
  24570. var iStart = bServerSide ? 0 : iDisplayStart;
  24571. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  24572. for ( var j=iStart ; j<iEnd ; j++ )
  24573. {
  24574. var iDataIndex = aiDisplay[j];
  24575. var aoData = oSettings.aoData[ iDataIndex ];
  24576. if ( aoData.nTr === null )
  24577. {
  24578. _fnCreateTr( oSettings, iDataIndex );
  24579. }
  24580. var nRow = aoData.nTr;
  24581. /* Remove the old striping classes and then add the new one */
  24582. if ( iStripes !== 0 )
  24583. {
  24584. var sStripe = asStripeClasses[ iRowCount % iStripes ];
  24585. if ( aoData._sRowStripe != sStripe )
  24586. {
  24587. $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
  24588. aoData._sRowStripe = sStripe;
  24589. }
  24590. }
  24591. // Row callback functions - might want to manipulate the row
  24592. // iRowCount and j are not currently documented. Are they at all
  24593. // useful?
  24594. _fnCallbackFire( oSettings, 'aoRowCallback', null,
  24595. [nRow, aoData._aData, iRowCount, j] );
  24596. anRows.push( nRow );
  24597. iRowCount++;
  24598. }
  24599. }
  24600. else
  24601. {
  24602. /* Table is empty - create a row with an empty message in it */
  24603. var sZero = oLang.sZeroRecords;
  24604. if ( oSettings.iDraw == 1 && _fnDataSource( oSettings ) == 'ajax' )
  24605. {
  24606. sZero = oLang.sLoadingRecords;
  24607. }
  24608. else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
  24609. {
  24610. sZero = oLang.sEmptyTable;
  24611. }
  24612. anRows[ 0 ] = $( '<tr/>', { 'class': iStripes ? asStripeClasses[0] : '' } )
  24613. .append( $('<td />', {
  24614. 'valign': 'top',
  24615. 'colSpan': _fnVisbleColumns( oSettings ),
  24616. 'class': oSettings.oClasses.sRowEmpty
  24617. } ).html( sZero ) )[0];
  24618. }
  24619. /* Header and footer callbacks */
  24620. _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
  24621. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  24622. _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
  24623. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  24624. var body = $(oSettings.nTBody);
  24625. body.children().detach();
  24626. body.append( $(anRows) );
  24627. /* Call all required callback functions for the end of a draw */
  24628. _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
  24629. /* Draw is complete, sorting and filtering must be as well */
  24630. oSettings.bSorted = false;
  24631. oSettings.bFiltered = false;
  24632. oSettings.bDrawing = false;
  24633. }
  24634. /**
  24635. * Redraw the table - taking account of the various features which are enabled
  24636. * @param {object} oSettings dataTables settings object
  24637. * @param {boolean} [holdPosition] Keep the current paging position. By default
  24638. * the paging is reset to the first page
  24639. * @memberof DataTable#oApi
  24640. */
  24641. function _fnReDraw( settings, holdPosition )
  24642. {
  24643. var
  24644. features = settings.oFeatures,
  24645. sort = features.bSort,
  24646. filter = features.bFilter;
  24647. if ( sort ) {
  24648. _fnSort( settings );
  24649. }
  24650. if ( filter ) {
  24651. _fnFilterComplete( settings, settings.oPreviousSearch );
  24652. }
  24653. else {
  24654. // No filtering, so we want to just use the display master
  24655. settings.aiDisplay = settings.aiDisplayMaster.slice();
  24656. }
  24657. if ( holdPosition !== true ) {
  24658. settings._iDisplayStart = 0;
  24659. }
  24660. // Let any modules know about the draw hold position state (used by
  24661. // scrolling internally)
  24662. settings._drawHold = holdPosition;
  24663. _fnDraw( settings );
  24664. settings._drawHold = false;
  24665. }
  24666. /**
  24667. * Add the options to the page HTML for the table
  24668. * @param {object} oSettings dataTables settings object
  24669. * @memberof DataTable#oApi
  24670. */
  24671. function _fnAddOptionsHtml ( oSettings )
  24672. {
  24673. var classes = oSettings.oClasses;
  24674. var table = $(oSettings.nTable);
  24675. var holding = $('<div/>').insertBefore( table ); // Holding element for speed
  24676. var features = oSettings.oFeatures;
  24677. // All DataTables are wrapped in a div
  24678. var insert = $('<div/>', {
  24679. id: oSettings.sTableId+'_wrapper',
  24680. 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
  24681. } );
  24682. oSettings.nHolding = holding[0];
  24683. oSettings.nTableWrapper = insert[0];
  24684. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  24685. /* Loop over the user set positioning and place the elements as needed */
  24686. var aDom = oSettings.sDom.split('');
  24687. var featureNode, cOption, nNewNode, cNext, sAttr, j;
  24688. for ( var i=0 ; i<aDom.length ; i++ )
  24689. {
  24690. featureNode = null;
  24691. cOption = aDom[i];
  24692. if ( cOption == '<' )
  24693. {
  24694. /* New container div */
  24695. nNewNode = $('<div/>')[0];
  24696. /* Check to see if we should append an id and/or a class name to the container */
  24697. cNext = aDom[i+1];
  24698. if ( cNext == "'" || cNext == '"' )
  24699. {
  24700. sAttr = "";
  24701. j = 2;
  24702. while ( aDom[i+j] != cNext )
  24703. {
  24704. sAttr += aDom[i+j];
  24705. j++;
  24706. }
  24707. /* Replace jQuery UI constants @todo depreciated */
  24708. if ( sAttr == "H" )
  24709. {
  24710. sAttr = classes.sJUIHeader;
  24711. }
  24712. else if ( sAttr == "F" )
  24713. {
  24714. sAttr = classes.sJUIFooter;
  24715. }
  24716. /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
  24717. * breaks the string into parts and applies them as needed
  24718. */
  24719. if ( sAttr.indexOf('.') != -1 )
  24720. {
  24721. var aSplit = sAttr.split('.');
  24722. nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
  24723. nNewNode.className = aSplit[1];
  24724. }
  24725. else if ( sAttr.charAt(0) == "#" )
  24726. {
  24727. nNewNode.id = sAttr.substr(1, sAttr.length-1);
  24728. }
  24729. else
  24730. {
  24731. nNewNode.className = sAttr;
  24732. }
  24733. i += j; /* Move along the position array */
  24734. }
  24735. insert.append( nNewNode );
  24736. insert = $(nNewNode);
  24737. }
  24738. else if ( cOption == '>' )
  24739. {
  24740. /* End container div */
  24741. insert = insert.parent();
  24742. }
  24743. // @todo Move options into their own plugins?
  24744. else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
  24745. {
  24746. /* Length */
  24747. featureNode = _fnFeatureHtmlLength( oSettings );
  24748. }
  24749. else if ( cOption == 'f' && features.bFilter )
  24750. {
  24751. /* Filter */
  24752. featureNode = _fnFeatureHtmlFilter( oSettings );
  24753. }
  24754. else if ( cOption == 'r' && features.bProcessing )
  24755. {
  24756. /* pRocessing */
  24757. featureNode = _fnFeatureHtmlProcessing( oSettings );
  24758. }
  24759. else if ( cOption == 't' )
  24760. {
  24761. /* Table */
  24762. featureNode = _fnFeatureHtmlTable( oSettings );
  24763. }
  24764. else if ( cOption == 'i' && features.bInfo )
  24765. {
  24766. /* Info */
  24767. featureNode = _fnFeatureHtmlInfo( oSettings );
  24768. }
  24769. else if ( cOption == 'p' && features.bPaginate )
  24770. {
  24771. /* Pagination */
  24772. featureNode = _fnFeatureHtmlPaginate( oSettings );
  24773. }
  24774. else if ( DataTable.ext.feature.length !== 0 )
  24775. {
  24776. /* Plug-in features */
  24777. var aoFeatures = DataTable.ext.feature;
  24778. for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
  24779. {
  24780. if ( cOption == aoFeatures[k].cFeature )
  24781. {
  24782. featureNode = aoFeatures[k].fnInit( oSettings );
  24783. break;
  24784. }
  24785. }
  24786. }
  24787. /* Add to the 2D features array */
  24788. if ( featureNode )
  24789. {
  24790. var aanFeatures = oSettings.aanFeatures;
  24791. if ( ! aanFeatures[cOption] )
  24792. {
  24793. aanFeatures[cOption] = [];
  24794. }
  24795. aanFeatures[cOption].push( featureNode );
  24796. insert.append( featureNode );
  24797. }
  24798. }
  24799. /* Built our DOM structure - replace the holding div with what we want */
  24800. holding.replaceWith( insert );
  24801. oSettings.nHolding = null;
  24802. }
  24803. /**
  24804. * Use the DOM source to create up an array of header cells. The idea here is to
  24805. * create a layout grid (array) of rows x columns, which contains a reference
  24806. * to the cell that that point in the grid (regardless of col/rowspan), such that
  24807. * any column / row could be removed and the new grid constructed
  24808. * @param array {object} aLayout Array to store the calculated layout in
  24809. * @param {node} nThead The header/footer element for the table
  24810. * @memberof DataTable#oApi
  24811. */
  24812. function _fnDetectHeader ( aLayout, nThead )
  24813. {
  24814. var nTrs = $(nThead).children('tr');
  24815. var nTr, nCell;
  24816. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  24817. var bUnique;
  24818. var fnShiftCol = function ( a, i, j ) {
  24819. var k = a[i];
  24820. while ( k[j] ) {
  24821. j++;
  24822. }
  24823. return j;
  24824. };
  24825. aLayout.splice( 0, aLayout.length );
  24826. /* We know how many rows there are in the layout - so prep it */
  24827. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  24828. {
  24829. aLayout.push( [] );
  24830. }
  24831. /* Calculate a layout array */
  24832. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  24833. {
  24834. nTr = nTrs[i];
  24835. iColumn = 0;
  24836. /* For every cell in the row... */
  24837. nCell = nTr.firstChild;
  24838. while ( nCell ) {
  24839. if ( nCell.nodeName.toUpperCase() == "TD" ||
  24840. nCell.nodeName.toUpperCase() == "TH" )
  24841. {
  24842. /* Get the col and rowspan attributes from the DOM and sanitise them */
  24843. iColspan = nCell.getAttribute('colspan') * 1;
  24844. iRowspan = nCell.getAttribute('rowspan') * 1;
  24845. iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
  24846. iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
  24847. /* There might be colspan cells already in this row, so shift our target
  24848. * accordingly
  24849. */
  24850. iColShifted = fnShiftCol( aLayout, i, iColumn );
  24851. /* Cache calculation for unique columns */
  24852. bUnique = iColspan === 1 ? true : false;
  24853. /* If there is col / rowspan, copy the information into the layout grid */
  24854. for ( l=0 ; l<iColspan ; l++ )
  24855. {
  24856. for ( k=0 ; k<iRowspan ; k++ )
  24857. {
  24858. aLayout[i+k][iColShifted+l] = {
  24859. "cell": nCell,
  24860. "unique": bUnique
  24861. };
  24862. aLayout[i+k].nTr = nTr;
  24863. }
  24864. }
  24865. }
  24866. nCell = nCell.nextSibling;
  24867. }
  24868. }
  24869. }
  24870. /**
  24871. * Get an array of unique th elements, one for each column
  24872. * @param {object} oSettings dataTables settings object
  24873. * @param {node} nHeader automatically detect the layout from this node - optional
  24874. * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
  24875. * @returns array {node} aReturn list of unique th's
  24876. * @memberof DataTable#oApi
  24877. */
  24878. function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
  24879. {
  24880. var aReturn = [];
  24881. if ( !aLayout )
  24882. {
  24883. aLayout = oSettings.aoHeader;
  24884. if ( nHeader )
  24885. {
  24886. aLayout = [];
  24887. _fnDetectHeader( aLayout, nHeader );
  24888. }
  24889. }
  24890. for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
  24891. {
  24892. for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
  24893. {
  24894. if ( aLayout[i][j].unique &&
  24895. (!aReturn[j] || !oSettings.bSortCellsTop) )
  24896. {
  24897. aReturn[j] = aLayout[i][j].cell;
  24898. }
  24899. }
  24900. }
  24901. return aReturn;
  24902. }
  24903. /**
  24904. * Create an Ajax call based on the table's settings, taking into account that
  24905. * parameters can have multiple forms, and backwards compatibility.
  24906. *
  24907. * @param {object} oSettings dataTables settings object
  24908. * @param {array} data Data to send to the server, required by
  24909. * DataTables - may be augmented by developer callbacks
  24910. * @param {function} fn Callback function to run when data is obtained
  24911. */
  24912. function _fnBuildAjax( oSettings, data, fn )
  24913. {
  24914. // Compatibility with 1.9-, allow fnServerData and event to manipulate
  24915. _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] );
  24916. // Convert to object based for 1.10+ if using the old array scheme which can
  24917. // come from server-side processing or serverParams
  24918. if ( data && $.isArray(data) ) {
  24919. var tmp = {};
  24920. var rbracket = /(.*?)\[\]$/;
  24921. $.each( data, function (key, val) {
  24922. var match = val.name.match(rbracket);
  24923. if ( match ) {
  24924. // Support for arrays
  24925. var name = match[0];
  24926. if ( ! tmp[ name ] ) {
  24927. tmp[ name ] = [];
  24928. }
  24929. tmp[ name ].push( val.value );
  24930. }
  24931. else {
  24932. tmp[val.name] = val.value;
  24933. }
  24934. } );
  24935. data = tmp;
  24936. }
  24937. var ajaxData;
  24938. var ajax = oSettings.ajax;
  24939. var instance = oSettings.oInstance;
  24940. var callback = function ( json ) {
  24941. _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json, oSettings.jqXHR] );
  24942. fn( json );
  24943. };
  24944. if ( $.isPlainObject( ajax ) && ajax.data )
  24945. {
  24946. ajaxData = ajax.data;
  24947. var newData = $.isFunction( ajaxData ) ?
  24948. ajaxData( data, oSettings ) : // fn can manipulate data or return
  24949. ajaxData; // an object object or array to merge
  24950. // If the function returned something, use that alone
  24951. data = $.isFunction( ajaxData ) && newData ?
  24952. newData :
  24953. $.extend( true, data, newData );
  24954. // Remove the data property as we've resolved it already and don't want
  24955. // jQuery to do it again (it is restored at the end of the function)
  24956. delete ajax.data;
  24957. }
  24958. var baseAjax = {
  24959. "data": data,
  24960. "success": function (json) {
  24961. var error = json.error || json.sError;
  24962. if ( error ) {
  24963. _fnLog( oSettings, 0, error );
  24964. }
  24965. oSettings.json = json;
  24966. callback( json );
  24967. },
  24968. "dataType": "json",
  24969. "cache": false,
  24970. "type": oSettings.sServerMethod,
  24971. "error": function (xhr, error, thrown) {
  24972. var ret = _fnCallbackFire( oSettings, null, 'xhr', [oSettings, null, oSettings.jqXHR] );
  24973. if ( $.inArray( true, ret ) === -1 ) {
  24974. if ( error == "parsererror" ) {
  24975. _fnLog( oSettings, 0, 'Invalid JSON response', 1 );
  24976. }
  24977. else if ( xhr.readyState === 4 ) {
  24978. _fnLog( oSettings, 0, 'Ajax error', 7 );
  24979. }
  24980. }
  24981. _fnProcessingDisplay( oSettings, false );
  24982. }
  24983. };
  24984. // Store the data submitted for the API
  24985. oSettings.oAjaxData = data;
  24986. // Allow plug-ins and external processes to modify the data
  24987. _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data] );
  24988. if ( oSettings.fnServerData )
  24989. {
  24990. // DataTables 1.9- compatibility
  24991. oSettings.fnServerData.call( instance,
  24992. oSettings.sAjaxSource,
  24993. $.map( data, function (val, key) { // Need to convert back to 1.9 trad format
  24994. return { name: key, value: val };
  24995. } ),
  24996. callback,
  24997. oSettings
  24998. );
  24999. }
  25000. else if ( oSettings.sAjaxSource || typeof ajax === 'string' )
  25001. {
  25002. // DataTables 1.9- compatibility
  25003. oSettings.jqXHR = $.ajax( $.extend( baseAjax, {
  25004. url: ajax || oSettings.sAjaxSource
  25005. } ) );
  25006. }
  25007. else if ( $.isFunction( ajax ) )
  25008. {
  25009. // Is a function - let the caller define what needs to be done
  25010. oSettings.jqXHR = ajax.call( instance, data, callback, oSettings );
  25011. }
  25012. else
  25013. {
  25014. // Object to extend the base settings
  25015. oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
  25016. // Restore for next time around
  25017. ajax.data = ajaxData;
  25018. }
  25019. }
  25020. /**
  25021. * Update the table using an Ajax call
  25022. * @param {object} settings dataTables settings object
  25023. * @returns {boolean} Block the table drawing or not
  25024. * @memberof DataTable#oApi
  25025. */
  25026. function _fnAjaxUpdate( settings )
  25027. {
  25028. if ( settings.bAjaxDataGet ) {
  25029. settings.iDraw++;
  25030. _fnProcessingDisplay( settings, true );
  25031. _fnBuildAjax(
  25032. settings,
  25033. _fnAjaxParameters( settings ),
  25034. function(json) {
  25035. _fnAjaxUpdateDraw( settings, json );
  25036. }
  25037. );
  25038. return false;
  25039. }
  25040. return true;
  25041. }
  25042. /**
  25043. * Build up the parameters in an object needed for a server-side processing
  25044. * request. Note that this is basically done twice, is different ways - a modern
  25045. * method which is used by default in DataTables 1.10 which uses objects and
  25046. * arrays, or the 1.9- method with is name / value pairs. 1.9 method is used if
  25047. * the sAjaxSource option is used in the initialisation, or the legacyAjax
  25048. * option is set.
  25049. * @param {object} oSettings dataTables settings object
  25050. * @returns {bool} block the table drawing or not
  25051. * @memberof DataTable#oApi
  25052. */
  25053. function _fnAjaxParameters( settings )
  25054. {
  25055. var
  25056. columns = settings.aoColumns,
  25057. columnCount = columns.length,
  25058. features = settings.oFeatures,
  25059. preSearch = settings.oPreviousSearch,
  25060. preColSearch = settings.aoPreSearchCols,
  25061. i, data = [], dataProp, column, columnSearch,
  25062. sort = _fnSortFlatten( settings ),
  25063. displayStart = settings._iDisplayStart,
  25064. displayLength = features.bPaginate !== false ?
  25065. settings._iDisplayLength :
  25066. -1;
  25067. var param = function ( name, value ) {
  25068. data.push( { 'name': name, 'value': value } );
  25069. };
  25070. // DataTables 1.9- compatible method
  25071. param( 'sEcho', settings.iDraw );
  25072. param( 'iColumns', columnCount );
  25073. param( 'sColumns', _pluck( columns, 'sName' ).join(',') );
  25074. param( 'iDisplayStart', displayStart );
  25075. param( 'iDisplayLength', displayLength );
  25076. // DataTables 1.10+ method
  25077. var d = {
  25078. draw: settings.iDraw,
  25079. columns: [],
  25080. order: [],
  25081. start: displayStart,
  25082. length: displayLength,
  25083. search: {
  25084. value: preSearch.sSearch,
  25085. regex: preSearch.bRegex
  25086. }
  25087. };
  25088. for ( i=0 ; i<columnCount ; i++ ) {
  25089. column = columns[i];
  25090. columnSearch = preColSearch[i];
  25091. dataProp = typeof column.mData=="function" ? 'function' : column.mData ;
  25092. d.columns.push( {
  25093. data: dataProp,
  25094. name: column.sName,
  25095. searchable: column.bSearchable,
  25096. orderable: column.bSortable,
  25097. search: {
  25098. value: columnSearch.sSearch,
  25099. regex: columnSearch.bRegex
  25100. }
  25101. } );
  25102. param( "mDataProp_"+i, dataProp );
  25103. if ( features.bFilter ) {
  25104. param( 'sSearch_'+i, columnSearch.sSearch );
  25105. param( 'bRegex_'+i, columnSearch.bRegex );
  25106. param( 'bSearchable_'+i, column.bSearchable );
  25107. }
  25108. if ( features.bSort ) {
  25109. param( 'bSortable_'+i, column.bSortable );
  25110. }
  25111. }
  25112. if ( features.bFilter ) {
  25113. param( 'sSearch', preSearch.sSearch );
  25114. param( 'bRegex', preSearch.bRegex );
  25115. }
  25116. if ( features.bSort ) {
  25117. $.each( sort, function ( i, val ) {
  25118. d.order.push( { column: val.col, dir: val.dir } );
  25119. param( 'iSortCol_'+i, val.col );
  25120. param( 'sSortDir_'+i, val.dir );
  25121. } );
  25122. param( 'iSortingCols', sort.length );
  25123. }
  25124. // If the legacy.ajax parameter is null, then we automatically decide which
  25125. // form to use, based on sAjaxSource
  25126. var legacy = DataTable.ext.legacy.ajax;
  25127. if ( legacy === null ) {
  25128. return settings.sAjaxSource ? data : d;
  25129. }
  25130. // Otherwise, if legacy has been specified then we use that to decide on the
  25131. // form
  25132. return legacy ? data : d;
  25133. }
  25134. /**
  25135. * Data the data from the server (nuking the old) and redraw the table
  25136. * @param {object} oSettings dataTables settings object
  25137. * @param {object} json json data return from the server.
  25138. * @param {string} json.sEcho Tracking flag for DataTables to match requests
  25139. * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
  25140. * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
  25141. * @param {array} json.aaData The data to display on this page
  25142. * @param {string} [json.sColumns] Column ordering (sName, comma separated)
  25143. * @memberof DataTable#oApi
  25144. */
  25145. function _fnAjaxUpdateDraw ( settings, json )
  25146. {
  25147. // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
  25148. // Support both
  25149. var compat = function ( old, modern ) {
  25150. return json[old] !== undefined ? json[old] : json[modern];
  25151. };
  25152. var data = _fnAjaxDataSrc( settings, json );
  25153. var draw = compat( 'sEcho', 'draw' );
  25154. var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
  25155. var recordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
  25156. if ( draw ) {
  25157. // Protect against out of sequence returns
  25158. if ( draw*1 < settings.iDraw ) {
  25159. return;
  25160. }
  25161. settings.iDraw = draw * 1;
  25162. }
  25163. _fnClearTable( settings );
  25164. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  25165. settings._iRecordsDisplay = parseInt(recordsFiltered, 10);
  25166. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  25167. _fnAddData( settings, data[i] );
  25168. }
  25169. settings.aiDisplay = settings.aiDisplayMaster.slice();
  25170. settings.bAjaxDataGet = false;
  25171. _fnDraw( settings );
  25172. if ( ! settings._bInitComplete ) {
  25173. _fnInitComplete( settings, json );
  25174. }
  25175. settings.bAjaxDataGet = true;
  25176. _fnProcessingDisplay( settings, false );
  25177. }
  25178. /**
  25179. * Get the data from the JSON data source to use for drawing a table. Using
  25180. * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
  25181. * source object, or from a processing function.
  25182. * @param {object} oSettings dataTables settings object
  25183. * @param {object} json Data source object / array from the server
  25184. * @return {array} Array of data to use
  25185. */
  25186. function _fnAjaxDataSrc ( oSettings, json )
  25187. {
  25188. var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
  25189. oSettings.ajax.dataSrc :
  25190. oSettings.sAjaxDataProp; // Compatibility with 1.9-.
  25191. // Compatibility with 1.9-. In order to read from aaData, check if the
  25192. // default has been changed, if not, check for aaData
  25193. if ( dataSrc === 'data' ) {
  25194. return json.aaData || json[dataSrc];
  25195. }
  25196. return dataSrc !== "" ?
  25197. _fnGetObjectDataFn( dataSrc )( json ) :
  25198. json;
  25199. }
  25200. /**
  25201. * Generate the node required for filtering text
  25202. * @returns {node} Filter control element
  25203. * @param {object} oSettings dataTables settings object
  25204. * @memberof DataTable#oApi
  25205. */
  25206. function _fnFeatureHtmlFilter ( settings )
  25207. {
  25208. var classes = settings.oClasses;
  25209. var tableId = settings.sTableId;
  25210. var language = settings.oLanguage;
  25211. var previousSearch = settings.oPreviousSearch;
  25212. var features = settings.aanFeatures;
  25213. var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
  25214. var str = language.sSearch;
  25215. str = str.match(/_INPUT_/) ?
  25216. str.replace('_INPUT_', input) :
  25217. str+input;
  25218. var filter = $('<div/>', {
  25219. 'id': ! features.f ? tableId+'_filter' : null,
  25220. 'class': classes.sFilter
  25221. } )
  25222. .append( $('<label/>' ).append( str ) );
  25223. var searchFn = function() {
  25224. /* Update all other filter input elements for the new display */
  25225. var n = features.f;
  25226. var val = !this.value ? "" : this.value; // mental IE8 fix :-(
  25227. /* Now do the filter */
  25228. if ( val != previousSearch.sSearch ) {
  25229. _fnFilterComplete( settings, {
  25230. "sSearch": val,
  25231. "bRegex": previousSearch.bRegex,
  25232. "bSmart": previousSearch.bSmart ,
  25233. "bCaseInsensitive": previousSearch.bCaseInsensitive
  25234. } );
  25235. // Need to redraw, without resorting
  25236. settings._iDisplayStart = 0;
  25237. _fnDraw( settings );
  25238. }
  25239. };
  25240. var searchDelay = settings.searchDelay !== null ?
  25241. settings.searchDelay :
  25242. _fnDataSource( settings ) === 'ssp' ?
  25243. 400 :
  25244. 0;
  25245. var jqFilter = $('input', filter)
  25246. .val( previousSearch.sSearch )
  25247. .attr( 'placeholder', language.sSearchPlaceholder )
  25248. .bind(
  25249. 'keyup.DT search.DT input.DT paste.DT cut.DT',
  25250. searchDelay ?
  25251. _fnThrottle( searchFn, searchDelay ) :
  25252. searchFn
  25253. )
  25254. .bind( 'keypress.DT', function(e) {
  25255. /* Prevent form submission */
  25256. if ( e.keyCode == 13 ) {
  25257. return false;
  25258. }
  25259. } )
  25260. .attr('aria-controls', tableId);
  25261. // Update the input elements whenever the table is filtered
  25262. $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
  25263. if ( settings === s ) {
  25264. // IE9 throws an 'unknown error' if document.activeElement is used
  25265. // inside an iframe or frame...
  25266. try {
  25267. if ( jqFilter[0] !== document.activeElement ) {
  25268. jqFilter.val( previousSearch.sSearch );
  25269. }
  25270. }
  25271. catch ( e ) {}
  25272. }
  25273. } );
  25274. return filter[0];
  25275. }
  25276. /**
  25277. * Filter the table using both the global filter and column based filtering
  25278. * @param {object} oSettings dataTables settings object
  25279. * @param {object} oSearch search information
  25280. * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
  25281. * @memberof DataTable#oApi
  25282. */
  25283. function _fnFilterComplete ( oSettings, oInput, iForce )
  25284. {
  25285. var oPrevSearch = oSettings.oPreviousSearch;
  25286. var aoPrevSearch = oSettings.aoPreSearchCols;
  25287. var fnSaveFilter = function ( oFilter ) {
  25288. /* Save the filtering values */
  25289. oPrevSearch.sSearch = oFilter.sSearch;
  25290. oPrevSearch.bRegex = oFilter.bRegex;
  25291. oPrevSearch.bSmart = oFilter.bSmart;
  25292. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  25293. };
  25294. var fnRegex = function ( o ) {
  25295. // Backwards compatibility with the bEscapeRegex option
  25296. return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
  25297. };
  25298. // Resolve any column types that are unknown due to addition or invalidation
  25299. // @todo As per sort - can this be moved into an event handler?
  25300. _fnColumnTypes( oSettings );
  25301. /* In server-side processing all filtering is done by the server, so no point hanging around here */
  25302. if ( _fnDataSource( oSettings ) != 'ssp' )
  25303. {
  25304. /* Global filter */
  25305. _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive );
  25306. fnSaveFilter( oInput );
  25307. /* Now do the individual column filter */
  25308. for ( var i=0 ; i<aoPrevSearch.length ; i++ )
  25309. {
  25310. _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, fnRegex(aoPrevSearch[i]),
  25311. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
  25312. }
  25313. /* Custom filtering */
  25314. _fnFilterCustom( oSettings );
  25315. }
  25316. else
  25317. {
  25318. fnSaveFilter( oInput );
  25319. }
  25320. /* Tell the draw function we have been filtering */
  25321. oSettings.bFiltered = true;
  25322. _fnCallbackFire( oSettings, null, 'search', [oSettings] );
  25323. }
  25324. /**
  25325. * Apply custom filtering functions
  25326. * @param {object} oSettings dataTables settings object
  25327. * @memberof DataTable#oApi
  25328. */
  25329. function _fnFilterCustom( settings )
  25330. {
  25331. var filters = DataTable.ext.search;
  25332. var displayRows = settings.aiDisplay;
  25333. var row, rowIdx;
  25334. for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
  25335. var rows = [];
  25336. // Loop over each row and see if it should be included
  25337. for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
  25338. rowIdx = displayRows[ j ];
  25339. row = settings.aoData[ rowIdx ];
  25340. if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
  25341. rows.push( rowIdx );
  25342. }
  25343. }
  25344. // So the array reference doesn't break set the results into the
  25345. // existing array
  25346. displayRows.length = 0;
  25347. $.merge( displayRows, rows );
  25348. }
  25349. }
  25350. /**
  25351. * Filter the table on a per-column basis
  25352. * @param {object} oSettings dataTables settings object
  25353. * @param {string} sInput string to filter on
  25354. * @param {int} iColumn column to filter
  25355. * @param {bool} bRegex treat search string as a regular expression or not
  25356. * @param {bool} bSmart use smart filtering or not
  25357. * @param {bool} bCaseInsensitive Do case insenstive matching or not
  25358. * @memberof DataTable#oApi
  25359. */
  25360. function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
  25361. {
  25362. if ( searchStr === '' ) {
  25363. return;
  25364. }
  25365. var data;
  25366. var display = settings.aiDisplay;
  25367. var rpSearch = _fnFilterCreateSearch( searchStr, regex, smart, caseInsensitive );
  25368. for ( var i=display.length-1 ; i>=0 ; i-- ) {
  25369. data = settings.aoData[ display[i] ]._aFilterData[ colIdx ];
  25370. if ( ! rpSearch.test( data ) ) {
  25371. display.splice( i, 1 );
  25372. }
  25373. }
  25374. }
  25375. /**
  25376. * Filter the data table based on user input and draw the table
  25377. * @param {object} settings dataTables settings object
  25378. * @param {string} input string to filter on
  25379. * @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
  25380. * @param {bool} regex treat as a regular expression or not
  25381. * @param {bool} smart perform smart filtering or not
  25382. * @param {bool} caseInsensitive Do case insenstive matching or not
  25383. * @memberof DataTable#oApi
  25384. */
  25385. function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
  25386. {
  25387. var rpSearch = _fnFilterCreateSearch( input, regex, smart, caseInsensitive );
  25388. var prevSearch = settings.oPreviousSearch.sSearch;
  25389. var displayMaster = settings.aiDisplayMaster;
  25390. var display, invalidated, i;
  25391. // Need to take account of custom filtering functions - always filter
  25392. if ( DataTable.ext.search.length !== 0 ) {
  25393. force = true;
  25394. }
  25395. // Check if any of the rows were invalidated
  25396. invalidated = _fnFilterData( settings );
  25397. // If the input is blank - we just want the full data set
  25398. if ( input.length <= 0 ) {
  25399. settings.aiDisplay = displayMaster.slice();
  25400. }
  25401. else {
  25402. // New search - start from the master array
  25403. if ( invalidated ||
  25404. force ||
  25405. prevSearch.length > input.length ||
  25406. input.indexOf(prevSearch) !== 0 ||
  25407. settings.bSorted // On resort, the display master needs to be
  25408. // re-filtered since indexes will have changed
  25409. ) {
  25410. settings.aiDisplay = displayMaster.slice();
  25411. }
  25412. // Search the display array
  25413. display = settings.aiDisplay;
  25414. for ( i=display.length-1 ; i>=0 ; i-- ) {
  25415. if ( ! rpSearch.test( settings.aoData[ display[i] ]._sFilterRow ) ) {
  25416. display.splice( i, 1 );
  25417. }
  25418. }
  25419. }
  25420. }
  25421. /**
  25422. * Build a regular expression object suitable for searching a table
  25423. * @param {string} sSearch string to search for
  25424. * @param {bool} bRegex treat as a regular expression or not
  25425. * @param {bool} bSmart perform smart filtering or not
  25426. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  25427. * @returns {RegExp} constructed object
  25428. * @memberof DataTable#oApi
  25429. */
  25430. function _fnFilterCreateSearch( search, regex, smart, caseInsensitive )
  25431. {
  25432. search = regex ?
  25433. search :
  25434. _fnEscapeRegex( search );
  25435. if ( smart ) {
  25436. /* For smart filtering we want to allow the search to work regardless of
  25437. * word order. We also want double quoted text to be preserved, so word
  25438. * order is important - a la google. So this is what we want to
  25439. * generate:
  25440. *
  25441. * ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
  25442. */
  25443. var a = $.map( search.match( /"[^"]+"|[^ ]+/g ) || [''], function ( word ) {
  25444. if ( word.charAt(0) === '"' ) {
  25445. var m = word.match( /^"(.*)"$/ );
  25446. word = m ? m[1] : word;
  25447. }
  25448. return word.replace('"', '');
  25449. } );
  25450. search = '^(?=.*?'+a.join( ')(?=.*?' )+').*$';
  25451. }
  25452. return new RegExp( search, caseInsensitive ? 'i' : '' );
  25453. }
  25454. /**
  25455. * Escape a string such that it can be used in a regular expression
  25456. * @param {string} sVal string to escape
  25457. * @returns {string} escaped string
  25458. * @memberof DataTable#oApi
  25459. */
  25460. var _fnEscapeRegex = DataTable.util.escapeRegex;
  25461. var __filter_div = $('<div>')[0];
  25462. var __filter_div_textContent = __filter_div.textContent !== undefined;
  25463. // Update the filtering data for each row if needed (by invalidation or first run)
  25464. function _fnFilterData ( settings )
  25465. {
  25466. var columns = settings.aoColumns;
  25467. var column;
  25468. var i, j, ien, jen, filterData, cellData, row;
  25469. var fomatters = DataTable.ext.type.search;
  25470. var wasInvalidated = false;
  25471. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  25472. row = settings.aoData[i];
  25473. if ( ! row._aFilterData ) {
  25474. filterData = [];
  25475. for ( j=0, jen=columns.length ; j<jen ; j++ ) {
  25476. column = columns[j];
  25477. if ( column.bSearchable ) {
  25478. cellData = _fnGetCellData( settings, i, j, 'filter' );
  25479. if ( fomatters[ column.sType ] ) {
  25480. cellData = fomatters[ column.sType ]( cellData );
  25481. }
  25482. // Search in DataTables 1.10 is string based. In 1.11 this
  25483. // should be altered to also allow strict type checking.
  25484. if ( cellData === null ) {
  25485. cellData = '';
  25486. }
  25487. if ( typeof cellData !== 'string' && cellData.toString ) {
  25488. cellData = cellData.toString();
  25489. }
  25490. }
  25491. else {
  25492. cellData = '';
  25493. }
  25494. // If it looks like there is an HTML entity in the string,
  25495. // attempt to decode it so sorting works as expected. Note that
  25496. // we could use a single line of jQuery to do this, but the DOM
  25497. // method used here is much faster http://jsperf.com/html-decode
  25498. if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
  25499. __filter_div.innerHTML = cellData;
  25500. cellData = __filter_div_textContent ?
  25501. __filter_div.textContent :
  25502. __filter_div.innerText;
  25503. }
  25504. if ( cellData.replace ) {
  25505. cellData = cellData.replace(/[\r\n]/g, '');
  25506. }
  25507. filterData.push( cellData );
  25508. }
  25509. row._aFilterData = filterData;
  25510. row._sFilterRow = filterData.join(' ');
  25511. wasInvalidated = true;
  25512. }
  25513. }
  25514. return wasInvalidated;
  25515. }
  25516. /**
  25517. * Convert from the internal Hungarian notation to camelCase for external
  25518. * interaction
  25519. * @param {object} obj Object to convert
  25520. * @returns {object} Inverted object
  25521. * @memberof DataTable#oApi
  25522. */
  25523. function _fnSearchToCamel ( obj )
  25524. {
  25525. return {
  25526. search: obj.sSearch,
  25527. smart: obj.bSmart,
  25528. regex: obj.bRegex,
  25529. caseInsensitive: obj.bCaseInsensitive
  25530. };
  25531. }
  25532. /**
  25533. * Convert from camelCase notation to the internal Hungarian. We could use the
  25534. * Hungarian convert function here, but this is cleaner
  25535. * @param {object} obj Object to convert
  25536. * @returns {object} Inverted object
  25537. * @memberof DataTable#oApi
  25538. */
  25539. function _fnSearchToHung ( obj )
  25540. {
  25541. return {
  25542. sSearch: obj.search,
  25543. bSmart: obj.smart,
  25544. bRegex: obj.regex,
  25545. bCaseInsensitive: obj.caseInsensitive
  25546. };
  25547. }
  25548. /**
  25549. * Generate the node required for the info display
  25550. * @param {object} oSettings dataTables settings object
  25551. * @returns {node} Information element
  25552. * @memberof DataTable#oApi
  25553. */
  25554. function _fnFeatureHtmlInfo ( settings )
  25555. {
  25556. var
  25557. tid = settings.sTableId,
  25558. nodes = settings.aanFeatures.i,
  25559. n = $('<div/>', {
  25560. 'class': settings.oClasses.sInfo,
  25561. 'id': ! nodes ? tid+'_info' : null
  25562. } );
  25563. if ( ! nodes ) {
  25564. // Update display on each draw
  25565. settings.aoDrawCallback.push( {
  25566. "fn": _fnUpdateInfo,
  25567. "sName": "information"
  25568. } );
  25569. n
  25570. .attr( 'role', 'status' )
  25571. .attr( 'aria-live', 'polite' );
  25572. // Table is described by our info div
  25573. $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
  25574. }
  25575. return n[0];
  25576. }
  25577. /**
  25578. * Update the information elements in the display
  25579. * @param {object} settings dataTables settings object
  25580. * @memberof DataTable#oApi
  25581. */
  25582. function _fnUpdateInfo ( settings )
  25583. {
  25584. /* Show information about the table */
  25585. var nodes = settings.aanFeatures.i;
  25586. if ( nodes.length === 0 ) {
  25587. return;
  25588. }
  25589. var
  25590. lang = settings.oLanguage,
  25591. start = settings._iDisplayStart+1,
  25592. end = settings.fnDisplayEnd(),
  25593. max = settings.fnRecordsTotal(),
  25594. total = settings.fnRecordsDisplay(),
  25595. out = total ?
  25596. lang.sInfo :
  25597. lang.sInfoEmpty;
  25598. if ( total !== max ) {
  25599. /* Record set after filtering */
  25600. out += ' ' + lang.sInfoFiltered;
  25601. }
  25602. // Convert the macros
  25603. out += lang.sInfoPostFix;
  25604. out = _fnInfoMacros( settings, out );
  25605. var callback = lang.fnInfoCallback;
  25606. if ( callback !== null ) {
  25607. out = callback.call( settings.oInstance,
  25608. settings, start, end, max, total, out
  25609. );
  25610. }
  25611. $(nodes).html( out );
  25612. }
  25613. function _fnInfoMacros ( settings, str )
  25614. {
  25615. // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
  25616. // internally
  25617. var
  25618. formatter = settings.fnFormatNumber,
  25619. start = settings._iDisplayStart+1,
  25620. len = settings._iDisplayLength,
  25621. vis = settings.fnRecordsDisplay(),
  25622. all = len === -1;
  25623. return str.
  25624. replace(/_START_/g, formatter.call( settings, start ) ).
  25625. replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
  25626. replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
  25627. replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
  25628. replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
  25629. replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
  25630. }
  25631. /**
  25632. * Draw the table for the first time, adding all required features
  25633. * @param {object} settings dataTables settings object
  25634. * @memberof DataTable#oApi
  25635. */
  25636. function _fnInitialise ( settings )
  25637. {
  25638. var i, iLen, iAjaxStart=settings.iInitDisplayStart;
  25639. var columns = settings.aoColumns, column;
  25640. var features = settings.oFeatures;
  25641. var deferLoading = settings.bDeferLoading; // value modified by the draw
  25642. /* Ensure that the table data is fully initialised */
  25643. if ( ! settings.bInitialised ) {
  25644. setTimeout( function(){ _fnInitialise( settings ); }, 200 );
  25645. return;
  25646. }
  25647. /* Show the display HTML options */
  25648. _fnAddOptionsHtml( settings );
  25649. /* Build and draw the header / footer for the table */
  25650. _fnBuildHead( settings );
  25651. _fnDrawHead( settings, settings.aoHeader );
  25652. _fnDrawHead( settings, settings.aoFooter );
  25653. /* Okay to show that something is going on now */
  25654. _fnProcessingDisplay( settings, true );
  25655. /* Calculate sizes for columns */
  25656. if ( features.bAutoWidth ) {
  25657. _fnCalculateColumnWidths( settings );
  25658. }
  25659. for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
  25660. column = columns[i];
  25661. if ( column.sWidth ) {
  25662. column.nTh.style.width = _fnStringToCss( column.sWidth );
  25663. }
  25664. }
  25665. _fnCallbackFire( settings, null, 'preInit', [settings] );
  25666. // If there is default sorting required - let's do it. The sort function
  25667. // will do the drawing for us. Otherwise we draw the table regardless of the
  25668. // Ajax source - this allows the table to look initialised for Ajax sourcing
  25669. // data (show 'loading' message possibly)
  25670. _fnReDraw( settings );
  25671. // Server-side processing init complete is done by _fnAjaxUpdateDraw
  25672. var dataSrc = _fnDataSource( settings );
  25673. if ( dataSrc != 'ssp' || deferLoading ) {
  25674. // if there is an ajax source load the data
  25675. if ( dataSrc == 'ajax' ) {
  25676. _fnBuildAjax( settings, [], function(json) {
  25677. var aData = _fnAjaxDataSrc( settings, json );
  25678. // Got the data - add it to the table
  25679. for ( i=0 ; i<aData.length ; i++ ) {
  25680. _fnAddData( settings, aData[i] );
  25681. }
  25682. // Reset the init display for cookie saving. We've already done
  25683. // a filter, and therefore cleared it before. So we need to make
  25684. // it appear 'fresh'
  25685. settings.iInitDisplayStart = iAjaxStart;
  25686. _fnReDraw( settings );
  25687. _fnProcessingDisplay( settings, false );
  25688. _fnInitComplete( settings, json );
  25689. }, settings );
  25690. }
  25691. else {
  25692. _fnProcessingDisplay( settings, false );
  25693. _fnInitComplete( settings );
  25694. }
  25695. }
  25696. }
  25697. /**
  25698. * Draw the table for the first time, adding all required features
  25699. * @param {object} oSettings dataTables settings object
  25700. * @param {object} [json] JSON from the server that completed the table, if using Ajax source
  25701. * with client-side processing (optional)
  25702. * @memberof DataTable#oApi
  25703. */
  25704. function _fnInitComplete ( settings, json )
  25705. {
  25706. settings._bInitComplete = true;
  25707. // When data was added after the initialisation (data or Ajax) we need to
  25708. // calculate the column sizing
  25709. if ( json || settings.oInit.aaData ) {
  25710. _fnAdjustColumnSizing( settings );
  25711. }
  25712. _fnCallbackFire( settings, null, 'plugin-init', [settings, json] );
  25713. _fnCallbackFire( settings, 'aoInitComplete', 'init', [settings, json] );
  25714. }
  25715. function _fnLengthChange ( settings, val )
  25716. {
  25717. var len = parseInt( val, 10 );
  25718. settings._iDisplayLength = len;
  25719. _fnLengthOverflow( settings );
  25720. // Fire length change event
  25721. _fnCallbackFire( settings, null, 'length', [settings, len] );
  25722. }
  25723. /**
  25724. * Generate the node required for user display length changing
  25725. * @param {object} settings dataTables settings object
  25726. * @returns {node} Display length feature node
  25727. * @memberof DataTable#oApi
  25728. */
  25729. function _fnFeatureHtmlLength ( settings )
  25730. {
  25731. var
  25732. classes = settings.oClasses,
  25733. tableId = settings.sTableId,
  25734. menu = settings.aLengthMenu,
  25735. d2 = $.isArray( menu[0] ),
  25736. lengths = d2 ? menu[0] : menu,
  25737. language = d2 ? menu[1] : menu;
  25738. var select = $('<select/>', {
  25739. 'name': tableId+'_length',
  25740. 'aria-controls': tableId,
  25741. 'class': classes.sLengthSelect
  25742. } );
  25743. for ( var i=0, ien=lengths.length ; i<ien ; i++ ) {
  25744. select[0][ i ] = new Option( language[i], lengths[i] );
  25745. }
  25746. var div = $('<div><label/></div>').addClass( classes.sLength );
  25747. if ( ! settings.aanFeatures.l ) {
  25748. div[0].id = tableId+'_length';
  25749. }
  25750. div.children().append(
  25751. settings.oLanguage.sLengthMenu.replace( '_MENU_', select[0].outerHTML )
  25752. );
  25753. // Can't use `select` variable as user might provide their own and the
  25754. // reference is broken by the use of outerHTML
  25755. $('select', div)
  25756. .val( settings._iDisplayLength )
  25757. .bind( 'change.DT', function(e) {
  25758. _fnLengthChange( settings, $(this).val() );
  25759. _fnDraw( settings );
  25760. } );
  25761. // Update node value whenever anything changes the table's length
  25762. $(settings.nTable).bind( 'length.dt.DT', function (e, s, len) {
  25763. if ( settings === s ) {
  25764. $('select', div).val( len );
  25765. }
  25766. } );
  25767. return div[0];
  25768. }
  25769. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  25770. * Note that most of the paging logic is done in
  25771. * DataTable.ext.pager
  25772. */
  25773. /**
  25774. * Generate the node required for default pagination
  25775. * @param {object} oSettings dataTables settings object
  25776. * @returns {node} Pagination feature node
  25777. * @memberof DataTable#oApi
  25778. */
  25779. function _fnFeatureHtmlPaginate ( settings )
  25780. {
  25781. var
  25782. type = settings.sPaginationType,
  25783. plugin = DataTable.ext.pager[ type ],
  25784. modern = typeof plugin === 'function',
  25785. redraw = function( settings ) {
  25786. _fnDraw( settings );
  25787. },
  25788. node = $('<div/>').addClass( settings.oClasses.sPaging + type )[0],
  25789. features = settings.aanFeatures;
  25790. if ( ! modern ) {
  25791. plugin.fnInit( settings, node, redraw );
  25792. }
  25793. /* Add a draw callback for the pagination on first instance, to update the paging display */
  25794. if ( ! features.p )
  25795. {
  25796. node.id = settings.sTableId+'_paginate';
  25797. settings.aoDrawCallback.push( {
  25798. "fn": function( settings ) {
  25799. if ( modern ) {
  25800. var
  25801. start = settings._iDisplayStart,
  25802. len = settings._iDisplayLength,
  25803. visRecords = settings.fnRecordsDisplay(),
  25804. all = len === -1,
  25805. page = all ? 0 : Math.ceil( start / len ),
  25806. pages = all ? 1 : Math.ceil( visRecords / len ),
  25807. buttons = plugin(page, pages),
  25808. i, ien;
  25809. for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
  25810. _fnRenderer( settings, 'pageButton' )(
  25811. settings, features.p[i], i, buttons, page, pages
  25812. );
  25813. }
  25814. }
  25815. else {
  25816. plugin.fnUpdate( settings, redraw );
  25817. }
  25818. },
  25819. "sName": "pagination"
  25820. } );
  25821. }
  25822. return node;
  25823. }
  25824. /**
  25825. * Alter the display settings to change the page
  25826. * @param {object} settings DataTables settings object
  25827. * @param {string|int} action Paging action to take: "first", "previous",
  25828. * "next" or "last" or page number to jump to (integer)
  25829. * @param [bool] redraw Automatically draw the update or not
  25830. * @returns {bool} true page has changed, false - no change
  25831. * @memberof DataTable#oApi
  25832. */
  25833. function _fnPageChange ( settings, action, redraw )
  25834. {
  25835. var
  25836. start = settings._iDisplayStart,
  25837. len = settings._iDisplayLength,
  25838. records = settings.fnRecordsDisplay();
  25839. if ( records === 0 || len === -1 )
  25840. {
  25841. start = 0;
  25842. }
  25843. else if ( typeof action === "number" )
  25844. {
  25845. start = action * len;
  25846. if ( start > records )
  25847. {
  25848. start = 0;
  25849. }
  25850. }
  25851. else if ( action == "first" )
  25852. {
  25853. start = 0;
  25854. }
  25855. else if ( action == "previous" )
  25856. {
  25857. start = len >= 0 ?
  25858. start - len :
  25859. 0;
  25860. if ( start < 0 )
  25861. {
  25862. start = 0;
  25863. }
  25864. }
  25865. else if ( action == "next" )
  25866. {
  25867. if ( start + len < records )
  25868. {
  25869. start += len;
  25870. }
  25871. }
  25872. else if ( action == "last" )
  25873. {
  25874. start = Math.floor( (records-1) / len) * len;
  25875. }
  25876. else
  25877. {
  25878. _fnLog( settings, 0, "Unknown paging action: "+action, 5 );
  25879. }
  25880. var changed = settings._iDisplayStart !== start;
  25881. settings._iDisplayStart = start;
  25882. if ( changed ) {
  25883. _fnCallbackFire( settings, null, 'page', [settings] );
  25884. if ( redraw ) {
  25885. _fnDraw( settings );
  25886. }
  25887. }
  25888. return changed;
  25889. }
  25890. /**
  25891. * Generate the node required for the processing node
  25892. * @param {object} settings dataTables settings object
  25893. * @returns {node} Processing element
  25894. * @memberof DataTable#oApi
  25895. */
  25896. function _fnFeatureHtmlProcessing ( settings )
  25897. {
  25898. return $('<div/>', {
  25899. 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
  25900. 'class': settings.oClasses.sProcessing
  25901. } )
  25902. .html( settings.oLanguage.sProcessing )
  25903. .insertBefore( settings.nTable )[0];
  25904. }
  25905. /**
  25906. * Display or hide the processing indicator
  25907. * @param {object} settings dataTables settings object
  25908. * @param {bool} show Show the processing indicator (true) or not (false)
  25909. * @memberof DataTable#oApi
  25910. */
  25911. function _fnProcessingDisplay ( settings, show )
  25912. {
  25913. if ( settings.oFeatures.bProcessing ) {
  25914. $(settings.aanFeatures.r).css( 'display', show ? 'block' : 'none' );
  25915. }
  25916. _fnCallbackFire( settings, null, 'processing', [settings, show] );
  25917. }
  25918. /**
  25919. * Add any control elements for the table - specifically scrolling
  25920. * @param {object} settings dataTables settings object
  25921. * @returns {node} Node to add to the DOM
  25922. * @memberof DataTable#oApi
  25923. */
  25924. function _fnFeatureHtmlTable ( settings )
  25925. {
  25926. var table = $(settings.nTable);
  25927. // Add the ARIA grid role to the table
  25928. table.attr( 'role', 'grid' );
  25929. // Scrolling from here on in
  25930. var scroll = settings.oScroll;
  25931. if ( scroll.sX === '' && scroll.sY === '' ) {
  25932. return settings.nTable;
  25933. }
  25934. var scrollX = scroll.sX;
  25935. var scrollY = scroll.sY;
  25936. var classes = settings.oClasses;
  25937. var caption = table.children('caption');
  25938. var captionSide = caption.length ? caption[0]._captionSide : null;
  25939. var headerClone = $( table[0].cloneNode(false) );
  25940. var footerClone = $( table[0].cloneNode(false) );
  25941. var footer = table.children('tfoot');
  25942. var _div = '<div/>';
  25943. var size = function ( s ) {
  25944. return !s ? null : _fnStringToCss( s );
  25945. };
  25946. if ( ! footer.length ) {
  25947. footer = null;
  25948. }
  25949. /*
  25950. * The HTML structure that we want to generate in this function is:
  25951. * div - scroller
  25952. * div - scroll head
  25953. * div - scroll head inner
  25954. * table - scroll head table
  25955. * thead - thead
  25956. * div - scroll body
  25957. * table - table (master table)
  25958. * thead - thead clone for sizing
  25959. * tbody - tbody
  25960. * div - scroll foot
  25961. * div - scroll foot inner
  25962. * table - scroll foot table
  25963. * tfoot - tfoot
  25964. */
  25965. var scroller = $( _div, { 'class': classes.sScrollWrapper } )
  25966. .append(
  25967. $(_div, { 'class': classes.sScrollHead } )
  25968. .css( {
  25969. overflow: 'hidden',
  25970. position: 'relative',
  25971. border: 0,
  25972. width: scrollX ? size(scrollX) : '100%'
  25973. } )
  25974. .append(
  25975. $(_div, { 'class': classes.sScrollHeadInner } )
  25976. .css( {
  25977. 'box-sizing': 'content-box',
  25978. width: scroll.sXInner || '100%'
  25979. } )
  25980. .append(
  25981. headerClone
  25982. .removeAttr('id')
  25983. .css( 'margin-left', 0 )
  25984. .append( captionSide === 'top' ? caption : null )
  25985. .append(
  25986. table.children('thead')
  25987. )
  25988. )
  25989. )
  25990. )
  25991. .append(
  25992. $(_div, { 'class': classes.sScrollBody } )
  25993. .css( {
  25994. position: 'relative',
  25995. overflow: 'auto',
  25996. width: size( scrollX )
  25997. } )
  25998. .append( table )
  25999. );
  26000. if ( footer ) {
  26001. scroller.append(
  26002. $(_div, { 'class': classes.sScrollFoot } )
  26003. .css( {
  26004. overflow: 'hidden',
  26005. border: 0,
  26006. width: scrollX ? size(scrollX) : '100%'
  26007. } )
  26008. .append(
  26009. $(_div, { 'class': classes.sScrollFootInner } )
  26010. .append(
  26011. footerClone
  26012. .removeAttr('id')
  26013. .css( 'margin-left', 0 )
  26014. .append( captionSide === 'bottom' ? caption : null )
  26015. .append(
  26016. table.children('tfoot')
  26017. )
  26018. )
  26019. )
  26020. );
  26021. }
  26022. var children = scroller.children();
  26023. var scrollHead = children[0];
  26024. var scrollBody = children[1];
  26025. var scrollFoot = footer ? children[2] : null;
  26026. // When the body is scrolled, then we also want to scroll the headers
  26027. if ( scrollX ) {
  26028. $(scrollBody).on( 'scroll.DT', function (e) {
  26029. var scrollLeft = this.scrollLeft;
  26030. scrollHead.scrollLeft = scrollLeft;
  26031. if ( footer ) {
  26032. scrollFoot.scrollLeft = scrollLeft;
  26033. }
  26034. } );
  26035. }
  26036. $(scrollBody).css(
  26037. scrollY && scroll.bCollapse ? 'max-height' : 'height',
  26038. scrollY
  26039. );
  26040. settings.nScrollHead = scrollHead;
  26041. settings.nScrollBody = scrollBody;
  26042. settings.nScrollFoot = scrollFoot;
  26043. // On redraw - align columns
  26044. settings.aoDrawCallback.push( {
  26045. "fn": _fnScrollDraw,
  26046. "sName": "scrolling"
  26047. } );
  26048. return scroller[0];
  26049. }
  26050. /**
  26051. * Update the header, footer and body tables for resizing - i.e. column
  26052. * alignment.
  26053. *
  26054. * Welcome to the most horrible function DataTables. The process that this
  26055. * function follows is basically:
  26056. * 1. Re-create the table inside the scrolling div
  26057. * 2. Take live measurements from the DOM
  26058. * 3. Apply the measurements to align the columns
  26059. * 4. Clean up
  26060. *
  26061. * @param {object} settings dataTables settings object
  26062. * @memberof DataTable#oApi
  26063. */
  26064. function _fnScrollDraw ( settings )
  26065. {
  26066. // Given that this is such a monster function, a lot of variables are use
  26067. // to try and keep the minimised size as small as possible
  26068. var
  26069. scroll = settings.oScroll,
  26070. scrollX = scroll.sX,
  26071. scrollXInner = scroll.sXInner,
  26072. scrollY = scroll.sY,
  26073. barWidth = scroll.iBarWidth,
  26074. divHeader = $(settings.nScrollHead),
  26075. divHeaderStyle = divHeader[0].style,
  26076. divHeaderInner = divHeader.children('div'),
  26077. divHeaderInnerStyle = divHeaderInner[0].style,
  26078. divHeaderTable = divHeaderInner.children('table'),
  26079. divBodyEl = settings.nScrollBody,
  26080. divBody = $(divBodyEl),
  26081. divBodyStyle = divBodyEl.style,
  26082. divFooter = $(settings.nScrollFoot),
  26083. divFooterInner = divFooter.children('div'),
  26084. divFooterTable = divFooterInner.children('table'),
  26085. header = $(settings.nTHead),
  26086. table = $(settings.nTable),
  26087. tableEl = table[0],
  26088. tableStyle = tableEl.style,
  26089. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  26090. browser = settings.oBrowser,
  26091. ie67 = browser.bScrollOversize,
  26092. dtHeaderCells = _pluck( settings.aoColumns, 'nTh' ),
  26093. headerTrgEls, footerTrgEls,
  26094. headerSrcEls, footerSrcEls,
  26095. headerCopy, footerCopy,
  26096. headerWidths=[], footerWidths=[],
  26097. headerContent=[], footerContent=[],
  26098. idx, correction, sanityWidth,
  26099. zeroOut = function(nSizer) {
  26100. var style = nSizer.style;
  26101. style.paddingTop = "0";
  26102. style.paddingBottom = "0";
  26103. style.borderTopWidth = "0";
  26104. style.borderBottomWidth = "0";
  26105. style.height = 0;
  26106. };
  26107. // If the scrollbar visibility has changed from the last draw, we need to
  26108. // adjust the column sizes as the table width will have changed to account
  26109. // for the scrollbar
  26110. var scrollBarVis = divBodyEl.scrollHeight > divBodyEl.clientHeight;
  26111. if ( settings.scrollBarVis !== scrollBarVis && settings.scrollBarVis !== undefined ) {
  26112. settings.scrollBarVis = scrollBarVis;
  26113. _fnAdjustColumnSizing( settings );
  26114. return; // adjust column sizing will call this function again
  26115. }
  26116. else {
  26117. settings.scrollBarVis = scrollBarVis;
  26118. }
  26119. /*
  26120. * 1. Re-create the table inside the scrolling div
  26121. */
  26122. // Remove the old minimised thead and tfoot elements in the inner table
  26123. table.children('thead, tfoot').remove();
  26124. if ( footer ) {
  26125. footerCopy = footer.clone().prependTo( table );
  26126. footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
  26127. footerSrcEls = footerCopy.find('tr');
  26128. }
  26129. // Clone the current header and footer elements and then place it into the inner table
  26130. headerCopy = header.clone().prependTo( table );
  26131. headerTrgEls = header.find('tr'); // original header is in its own table
  26132. headerSrcEls = headerCopy.find('tr');
  26133. headerCopy.find('th, td').removeAttr('tabindex');
  26134. /*
  26135. * 2. Take live measurements from the DOM - do not alter the DOM itself!
  26136. */
  26137. // Remove old sizing and apply the calculated column widths
  26138. // Get the unique column headers in the newly created (cloned) header. We want to apply the
  26139. // calculated sizes to this header
  26140. if ( ! scrollX )
  26141. {
  26142. divBodyStyle.width = '100%';
  26143. divHeader[0].style.width = '100%';
  26144. }
  26145. $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
  26146. idx = _fnVisibleToColumnIndex( settings, i );
  26147. el.style.width = settings.aoColumns[idx].sWidth;
  26148. } );
  26149. if ( footer ) {
  26150. _fnApplyToChildren( function(n) {
  26151. n.style.width = "";
  26152. }, footerSrcEls );
  26153. }
  26154. // Size the table as a whole
  26155. sanityWidth = table.outerWidth();
  26156. if ( scrollX === "" ) {
  26157. // No x scrolling
  26158. tableStyle.width = "100%";
  26159. // IE7 will make the width of the table when 100% include the scrollbar
  26160. // - which is shouldn't. When there is a scrollbar we need to take this
  26161. // into account.
  26162. if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  26163. divBody.css('overflow-y') == "scroll")
  26164. ) {
  26165. tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
  26166. }
  26167. // Recalculate the sanity width
  26168. sanityWidth = table.outerWidth();
  26169. }
  26170. else if ( scrollXInner !== "" ) {
  26171. // legacy x scroll inner has been given - use it
  26172. tableStyle.width = _fnStringToCss(scrollXInner);
  26173. // Recalculate the sanity width
  26174. sanityWidth = table.outerWidth();
  26175. }
  26176. // Hidden header should have zero height, so remove padding and borders. Then
  26177. // set the width based on the real headers
  26178. // Apply all styles in one pass
  26179. _fnApplyToChildren( zeroOut, headerSrcEls );
  26180. // Read all widths in next pass
  26181. _fnApplyToChildren( function(nSizer) {
  26182. headerContent.push( nSizer.innerHTML );
  26183. headerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  26184. }, headerSrcEls );
  26185. // Apply all widths in final pass
  26186. _fnApplyToChildren( function(nToSize, i) {
  26187. // Only apply widths to the DataTables detected header cells - this
  26188. // prevents complex headers from having contradictory sizes applied
  26189. if ( $.inArray( nToSize, dtHeaderCells ) !== -1 ) {
  26190. nToSize.style.width = headerWidths[i];
  26191. }
  26192. }, headerTrgEls );
  26193. $(headerSrcEls).height(0);
  26194. /* Same again with the footer if we have one */
  26195. if ( footer )
  26196. {
  26197. _fnApplyToChildren( zeroOut, footerSrcEls );
  26198. _fnApplyToChildren( function(nSizer) {
  26199. footerContent.push( nSizer.innerHTML );
  26200. footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  26201. }, footerSrcEls );
  26202. _fnApplyToChildren( function(nToSize, i) {
  26203. nToSize.style.width = footerWidths[i];
  26204. }, footerTrgEls );
  26205. $(footerSrcEls).height(0);
  26206. }
  26207. /*
  26208. * 3. Apply the measurements
  26209. */
  26210. // "Hide" the header and footer that we used for the sizing. We need to keep
  26211. // the content of the cell so that the width applied to the header and body
  26212. // both match, but we want to hide it completely. We want to also fix their
  26213. // width to what they currently are
  26214. _fnApplyToChildren( function(nSizer, i) {
  26215. nSizer.innerHTML = '<div class="dataTables_sizing" style="height:0;overflow:hidden;">'+headerContent[i]+'</div>';
  26216. nSizer.style.width = headerWidths[i];
  26217. }, headerSrcEls );
  26218. if ( footer )
  26219. {
  26220. _fnApplyToChildren( function(nSizer, i) {
  26221. nSizer.innerHTML = '<div class="dataTables_sizing" style="height:0;overflow:hidden;">'+footerContent[i]+'</div>';
  26222. nSizer.style.width = footerWidths[i];
  26223. }, footerSrcEls );
  26224. }
  26225. // Sanity check that the table is of a sensible width. If not then we are going to get
  26226. // misalignment - try to prevent this by not allowing the table to shrink below its min width
  26227. if ( table.outerWidth() < sanityWidth )
  26228. {
  26229. // The min width depends upon if we have a vertical scrollbar visible or not */
  26230. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  26231. divBody.css('overflow-y') == "scroll")) ?
  26232. sanityWidth+barWidth :
  26233. sanityWidth;
  26234. // IE6/7 are a law unto themselves...
  26235. if ( ie67 && (divBodyEl.scrollHeight >
  26236. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
  26237. ) {
  26238. tableStyle.width = _fnStringToCss( correction-barWidth );
  26239. }
  26240. // And give the user a warning that we've stopped the table getting too small
  26241. if ( scrollX === "" || scrollXInner !== "" ) {
  26242. _fnLog( settings, 1, 'Possible column misalignment', 6 );
  26243. }
  26244. }
  26245. else
  26246. {
  26247. correction = '100%';
  26248. }
  26249. // Apply to the container elements
  26250. divBodyStyle.width = _fnStringToCss( correction );
  26251. divHeaderStyle.width = _fnStringToCss( correction );
  26252. if ( footer ) {
  26253. settings.nScrollFoot.style.width = _fnStringToCss( correction );
  26254. }
  26255. /*
  26256. * 4. Clean up
  26257. */
  26258. if ( ! scrollY ) {
  26259. /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
  26260. * the scrollbar height from the visible display, rather than adding it on. We need to
  26261. * set the height in order to sort this. Don't want to do it in any other browsers.
  26262. */
  26263. if ( ie67 ) {
  26264. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
  26265. }
  26266. }
  26267. /* Finally set the width's of the header and footer tables */
  26268. var iOuterWidth = table.outerWidth();
  26269. divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
  26270. divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
  26271. // Figure out if there are scrollbar present - if so then we need a the header and footer to
  26272. // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
  26273. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  26274. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
  26275. divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
  26276. if ( footer ) {
  26277. divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
  26278. divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
  26279. divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
  26280. }
  26281. // Correct DOM ordering for colgroup - comes before the thead
  26282. table.children('colgroup').insertBefore( table.children('thead') );
  26283. /* Adjust the position of the header in case we loose the y-scrollbar */
  26284. divBody.scroll();
  26285. // If sorting or filtering has occurred, jump the scrolling back to the top
  26286. // only if we aren't holding the position
  26287. if ( (settings.bSorted || settings.bFiltered) && ! settings._drawHold ) {
  26288. divBodyEl.scrollTop = 0;
  26289. }
  26290. }
  26291. /**
  26292. * Apply a given function to the display child nodes of an element array (typically
  26293. * TD children of TR rows
  26294. * @param {function} fn Method to apply to the objects
  26295. * @param array {nodes} an1 List of elements to look through for display children
  26296. * @param array {nodes} an2 Another list (identical structure to the first) - optional
  26297. * @memberof DataTable#oApi
  26298. */
  26299. function _fnApplyToChildren( fn, an1, an2 )
  26300. {
  26301. var index=0, i=0, iLen=an1.length;
  26302. var nNode1, nNode2;
  26303. while ( i < iLen ) {
  26304. nNode1 = an1[i].firstChild;
  26305. nNode2 = an2 ? an2[i].firstChild : null;
  26306. while ( nNode1 ) {
  26307. if ( nNode1.nodeType === 1 ) {
  26308. if ( an2 ) {
  26309. fn( nNode1, nNode2, index );
  26310. }
  26311. else {
  26312. fn( nNode1, index );
  26313. }
  26314. index++;
  26315. }
  26316. nNode1 = nNode1.nextSibling;
  26317. nNode2 = an2 ? nNode2.nextSibling : null;
  26318. }
  26319. i++;
  26320. }
  26321. }
  26322. var __re_html_remove = /<.*?>/g;
  26323. /**
  26324. * Calculate the width of columns for the table
  26325. * @param {object} oSettings dataTables settings object
  26326. * @memberof DataTable#oApi
  26327. */
  26328. function _fnCalculateColumnWidths ( oSettings )
  26329. {
  26330. var
  26331. table = oSettings.nTable,
  26332. columns = oSettings.aoColumns,
  26333. scroll = oSettings.oScroll,
  26334. scrollY = scroll.sY,
  26335. scrollX = scroll.sX,
  26336. scrollXInner = scroll.sXInner,
  26337. columnCount = columns.length,
  26338. visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
  26339. headerCells = $('th', oSettings.nTHead),
  26340. tableWidthAttr = table.getAttribute('width'), // from DOM element
  26341. tableContainer = table.parentNode,
  26342. userInputs = false,
  26343. i, column, columnIdx, width, outerWidth,
  26344. browser = oSettings.oBrowser,
  26345. ie67 = browser.bScrollOversize;
  26346. var styleWidth = table.style.width;
  26347. if ( styleWidth && styleWidth.indexOf('%') !== -1 ) {
  26348. tableWidthAttr = styleWidth;
  26349. }
  26350. /* Convert any user input sizes into pixel sizes */
  26351. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  26352. column = columns[ visibleColumns[i] ];
  26353. if ( column.sWidth !== null ) {
  26354. column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
  26355. userInputs = true;
  26356. }
  26357. }
  26358. /* If the number of columns in the DOM equals the number that we have to
  26359. * process in DataTables, then we can use the offsets that are created by
  26360. * the web- browser. No custom sizes can be set in order for this to happen,
  26361. * nor scrolling used
  26362. */
  26363. if ( ie67 || ! userInputs && ! scrollX && ! scrollY &&
  26364. columnCount == _fnVisbleColumns( oSettings ) &&
  26365. columnCount == headerCells.length
  26366. ) {
  26367. for ( i=0 ; i<columnCount ; i++ ) {
  26368. var colIdx = _fnVisibleToColumnIndex( oSettings, i );
  26369. if ( colIdx !== null ) {
  26370. columns[ colIdx ].sWidth = _fnStringToCss( headerCells.eq(i).width() );
  26371. }
  26372. }
  26373. }
  26374. else
  26375. {
  26376. // Otherwise construct a single row, worst case, table with the widest
  26377. // node in the data, assign any user defined widths, then insert it into
  26378. // the DOM and allow the browser to do all the hard work of calculating
  26379. // table widths
  26380. var tmpTable = $(table).clone() // don't use cloneNode - IE8 will remove events on the main table
  26381. .css( 'visibility', 'hidden' )
  26382. .removeAttr( 'id' );
  26383. // Clean up the table body
  26384. tmpTable.find('tbody tr').remove();
  26385. var tr = $('<tr/>').appendTo( tmpTable.find('tbody') );
  26386. // Clone the table header and footer - we can't use the header / footer
  26387. // from the cloned table, since if scrolling is active, the table's
  26388. // real header and footer are contained in different table tags
  26389. tmpTable.find('thead, tfoot').remove();
  26390. tmpTable
  26391. .append( $(oSettings.nTHead).clone() )
  26392. .append( $(oSettings.nTFoot).clone() );
  26393. // Remove any assigned widths from the footer (from scrolling)
  26394. tmpTable.find('tfoot th, tfoot td').css('width', '');
  26395. // Apply custom sizing to the cloned header
  26396. headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
  26397. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  26398. column = columns[ visibleColumns[i] ];
  26399. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  26400. _fnStringToCss( column.sWidthOrig ) :
  26401. '';
  26402. // For scrollX we need to force the column width otherwise the
  26403. // browser will collapse it. If this width is smaller than the
  26404. // width the column requires, then it will have no effect
  26405. if ( column.sWidthOrig && scrollX ) {
  26406. $( headerCells[i] ).append( $('<div/>').css( {
  26407. width: column.sWidthOrig,
  26408. margin: 0,
  26409. padding: 0,
  26410. border: 0,
  26411. height: 1
  26412. } ) );
  26413. }
  26414. }
  26415. // Find the widest cell for each column and put it into the table
  26416. if ( oSettings.aoData.length ) {
  26417. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  26418. columnIdx = visibleColumns[i];
  26419. column = columns[ columnIdx ];
  26420. $( _fnGetWidestNode( oSettings, columnIdx ) )
  26421. .clone( false )
  26422. .append( column.sContentPadding )
  26423. .appendTo( tr );
  26424. }
  26425. }
  26426. // Tidy the temporary table - remove name attributes so there aren't
  26427. // duplicated in the dom (radio elements for example)
  26428. $('[name]', tmpTable).removeAttr('name');
  26429. // Table has been built, attach to the document so we can work with it.
  26430. // A holding element is used, positioned at the top of the container
  26431. // with minimal height, so it has no effect on if the container scrolls
  26432. // or not. Otherwise it might trigger scrolling when it actually isn't
  26433. // needed
  26434. var holder = $('<div/>').css( scrollX || scrollY ?
  26435. {
  26436. position: 'absolute',
  26437. top: 0,
  26438. left: 0,
  26439. height: 1,
  26440. right: 0,
  26441. overflow: 'hidden'
  26442. } :
  26443. {}
  26444. )
  26445. .append( tmpTable )
  26446. .appendTo( tableContainer );
  26447. // When scrolling (X or Y) we want to set the width of the table as
  26448. // appropriate. However, when not scrolling leave the table width as it
  26449. // is. This results in slightly different, but I think correct behaviour
  26450. if ( scrollX && scrollXInner ) {
  26451. tmpTable.width( scrollXInner );
  26452. }
  26453. else if ( scrollX ) {
  26454. tmpTable.css( 'width', 'auto' );
  26455. tmpTable.removeAttr('width');
  26456. // If there is no width attribute or style, then allow the table to
  26457. // collapse
  26458. if ( tmpTable.width() < tableContainer.clientWidth && tableWidthAttr ) {
  26459. tmpTable.width( tableContainer.clientWidth );
  26460. }
  26461. }
  26462. else if ( scrollY ) {
  26463. tmpTable.width( tableContainer.clientWidth );
  26464. }
  26465. else if ( tableWidthAttr ) {
  26466. tmpTable.width( tableWidthAttr );
  26467. }
  26468. // Get the width of each column in the constructed table - we need to
  26469. // know the inner width (so it can be assigned to the other table's
  26470. // cells) and the outer width so we can calculate the full width of the
  26471. // table. This is safe since DataTables requires a unique cell for each
  26472. // column, but if ever a header can span multiple columns, this will
  26473. // need to be modified.
  26474. var total = 0;
  26475. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  26476. var cell = $(headerCells[i]);
  26477. var border = cell.outerWidth() - cell.width();
  26478. // Use getBounding... where possible (not IE8-) because it can give
  26479. // sub-pixel accuracy, which we then want to round up!
  26480. var bounding = browser.bBounding ?
  26481. Math.ceil( headerCells[i].getBoundingClientRect().width ) :
  26482. cell.outerWidth();
  26483. // Total is tracked to remove any sub-pixel errors as the outerWidth
  26484. // of the table might not equal the total given here (IE!).
  26485. total += bounding;
  26486. // Width for each column to use
  26487. columns[ visibleColumns[i] ].sWidth = _fnStringToCss( bounding - border );
  26488. }
  26489. table.style.width = _fnStringToCss( total );
  26490. // Finished with the table - ditch it
  26491. holder.remove();
  26492. }
  26493. // If there is a width attr, we want to attach an event listener which
  26494. // allows the table sizing to automatically adjust when the window is
  26495. // resized. Use the width attr rather than CSS, since we can't know if the
  26496. // CSS is a relative value or absolute - DOM read is always px.
  26497. if ( tableWidthAttr ) {
  26498. table.style.width = _fnStringToCss( tableWidthAttr );
  26499. }
  26500. if ( (tableWidthAttr || scrollX) && ! oSettings._reszEvt ) {
  26501. var bindResize = function () {
  26502. $(window).bind('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
  26503. _fnAdjustColumnSizing( oSettings );
  26504. } ) );
  26505. };
  26506. // IE6/7 will crash if we bind a resize event handler on page load.
  26507. // To be removed in 1.11 which drops IE6/7 support
  26508. if ( ie67 ) {
  26509. setTimeout( bindResize, 1000 );
  26510. }
  26511. else {
  26512. bindResize();
  26513. }
  26514. oSettings._reszEvt = true;
  26515. }
  26516. }
  26517. /**
  26518. * Throttle the calls to a function. Arguments and context are maintained for
  26519. * the throttled function
  26520. * @param {function} fn Function to be called
  26521. * @param {int} [freq=200] call frequency in mS
  26522. * @returns {function} wrapped function
  26523. * @memberof DataTable#oApi
  26524. */
  26525. var _fnThrottle = DataTable.util.throttle;
  26526. /**
  26527. * Convert a CSS unit width to pixels (e.g. 2em)
  26528. * @param {string} width width to be converted
  26529. * @param {node} parent parent to get the with for (required for relative widths) - optional
  26530. * @returns {int} width in pixels
  26531. * @memberof DataTable#oApi
  26532. */
  26533. function _fnConvertToWidth ( width, parent )
  26534. {
  26535. if ( ! width ) {
  26536. return 0;
  26537. }
  26538. var n = $('<div/>')
  26539. .css( 'width', _fnStringToCss( width ) )
  26540. .appendTo( parent || document.body );
  26541. var val = n[0].offsetWidth;
  26542. n.remove();
  26543. return val;
  26544. }
  26545. /**
  26546. * Get the widest node
  26547. * @param {object} settings dataTables settings object
  26548. * @param {int} colIdx column of interest
  26549. * @returns {node} widest table node
  26550. * @memberof DataTable#oApi
  26551. */
  26552. function _fnGetWidestNode( settings, colIdx )
  26553. {
  26554. var idx = _fnGetMaxLenString( settings, colIdx );
  26555. if ( idx < 0 ) {
  26556. return null;
  26557. }
  26558. var data = settings.aoData[ idx ];
  26559. return ! data.nTr ? // Might not have been created when deferred rendering
  26560. $('<td/>').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
  26561. data.anCells[ colIdx ];
  26562. }
  26563. /**
  26564. * Get the maximum strlen for each data column
  26565. * @param {object} settings dataTables settings object
  26566. * @param {int} colIdx column of interest
  26567. * @returns {string} max string length for each column
  26568. * @memberof DataTable#oApi
  26569. */
  26570. function _fnGetMaxLenString( settings, colIdx )
  26571. {
  26572. var s, max=-1, maxIdx = -1;
  26573. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  26574. s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
  26575. s = s.replace( __re_html_remove, '' );
  26576. s = s.replace( /&nbsp;/g, ' ' );
  26577. if ( s.length > max ) {
  26578. max = s.length;
  26579. maxIdx = i;
  26580. }
  26581. }
  26582. return maxIdx;
  26583. }
  26584. /**
  26585. * Append a CSS unit (only if required) to a string
  26586. * @param {string} value to css-ify
  26587. * @returns {string} value with css unit
  26588. * @memberof DataTable#oApi
  26589. */
  26590. function _fnStringToCss( s )
  26591. {
  26592. if ( s === null ) {
  26593. return '0px';
  26594. }
  26595. if ( typeof s == 'number' ) {
  26596. return s < 0 ?
  26597. '0px' :
  26598. s+'px';
  26599. }
  26600. // Check it has a unit character already
  26601. return s.match(/\d$/) ?
  26602. s+'px' :
  26603. s;
  26604. }
  26605. function _fnSortFlatten ( settings )
  26606. {
  26607. var
  26608. i, iLen, k, kLen,
  26609. aSort = [],
  26610. aiOrig = [],
  26611. aoColumns = settings.aoColumns,
  26612. aDataSort, iCol, sType, srcCol,
  26613. fixed = settings.aaSortingFixed,
  26614. fixedObj = $.isPlainObject( fixed ),
  26615. nestedSort = [],
  26616. add = function ( a ) {
  26617. if ( a.length && ! $.isArray( a[0] ) ) {
  26618. // 1D array
  26619. nestedSort.push( a );
  26620. }
  26621. else {
  26622. // 2D array
  26623. $.merge( nestedSort, a );
  26624. }
  26625. };
  26626. // Build the sort array, with pre-fix and post-fix options if they have been
  26627. // specified
  26628. if ( $.isArray( fixed ) ) {
  26629. add( fixed );
  26630. }
  26631. if ( fixedObj && fixed.pre ) {
  26632. add( fixed.pre );
  26633. }
  26634. add( settings.aaSorting );
  26635. if (fixedObj && fixed.post ) {
  26636. add( fixed.post );
  26637. }
  26638. for ( i=0 ; i<nestedSort.length ; i++ )
  26639. {
  26640. srcCol = nestedSort[i][0];
  26641. aDataSort = aoColumns[ srcCol ].aDataSort;
  26642. for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
  26643. {
  26644. iCol = aDataSort[k];
  26645. sType = aoColumns[ iCol ].sType || 'string';
  26646. if ( nestedSort[i]._idx === undefined ) {
  26647. nestedSort[i]._idx = $.inArray( nestedSort[i][1], aoColumns[iCol].asSorting );
  26648. }
  26649. aSort.push( {
  26650. src: srcCol,
  26651. col: iCol,
  26652. dir: nestedSort[i][1],
  26653. index: nestedSort[i]._idx,
  26654. type: sType,
  26655. formatter: DataTable.ext.type.order[ sType+"-pre" ]
  26656. } );
  26657. }
  26658. }
  26659. return aSort;
  26660. }
  26661. /**
  26662. * Change the order of the table
  26663. * @param {object} oSettings dataTables settings object
  26664. * @memberof DataTable#oApi
  26665. * @todo This really needs split up!
  26666. */
  26667. function _fnSort ( oSettings )
  26668. {
  26669. var
  26670. i, ien, iLen, j, jLen, k, kLen,
  26671. sDataType, nTh,
  26672. aiOrig = [],
  26673. oExtSort = DataTable.ext.type.order,
  26674. aoData = oSettings.aoData,
  26675. aoColumns = oSettings.aoColumns,
  26676. aDataSort, data, iCol, sType, oSort,
  26677. formatters = 0,
  26678. sortCol,
  26679. displayMaster = oSettings.aiDisplayMaster,
  26680. aSort;
  26681. // Resolve any column types that are unknown due to addition or invalidation
  26682. // @todo Can this be moved into a 'data-ready' handler which is called when
  26683. // data is going to be used in the table?
  26684. _fnColumnTypes( oSettings );
  26685. aSort = _fnSortFlatten( oSettings );
  26686. for ( i=0, ien=aSort.length ; i<ien ; i++ ) {
  26687. sortCol = aSort[i];
  26688. // Track if we can use the fast sort algorithm
  26689. if ( sortCol.formatter ) {
  26690. formatters++;
  26691. }
  26692. // Load the data needed for the sort, for each cell
  26693. _fnSortData( oSettings, sortCol.col );
  26694. }
  26695. /* No sorting required if server-side or no sorting array */
  26696. if ( _fnDataSource( oSettings ) != 'ssp' && aSort.length !== 0 )
  26697. {
  26698. // Create a value - key array of the current row positions such that we can use their
  26699. // current position during the sort, if values match, in order to perform stable sorting
  26700. for ( i=0, iLen=displayMaster.length ; i<iLen ; i++ ) {
  26701. aiOrig[ displayMaster[i] ] = i;
  26702. }
  26703. /* Do the sort - here we want multi-column sorting based on a given data source (column)
  26704. * and sorting function (from oSort) in a certain direction. It's reasonably complex to
  26705. * follow on it's own, but this is what we want (example two column sorting):
  26706. * fnLocalSorting = function(a,b){
  26707. * var iTest;
  26708. * iTest = oSort['string-asc']('data11', 'data12');
  26709. * if (iTest !== 0)
  26710. * return iTest;
  26711. * iTest = oSort['numeric-desc']('data21', 'data22');
  26712. * if (iTest !== 0)
  26713. * return iTest;
  26714. * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
  26715. * }
  26716. * Basically we have a test for each sorting column, if the data in that column is equal,
  26717. * test the next column. If all columns match, then we use a numeric sort on the row
  26718. * positions in the original data array to provide a stable sort.
  26719. *
  26720. * Note - I know it seems excessive to have two sorting methods, but the first is around
  26721. * 15% faster, so the second is only maintained for backwards compatibility with sorting
  26722. * methods which do not have a pre-sort formatting function.
  26723. */
  26724. if ( formatters === aSort.length ) {
  26725. // All sort types have formatting functions
  26726. displayMaster.sort( function ( a, b ) {
  26727. var
  26728. x, y, k, test, sort,
  26729. len=aSort.length,
  26730. dataA = aoData[a]._aSortData,
  26731. dataB = aoData[b]._aSortData;
  26732. for ( k=0 ; k<len ; k++ ) {
  26733. sort = aSort[k];
  26734. x = dataA[ sort.col ];
  26735. y = dataB[ sort.col ];
  26736. test = x<y ? -1 : x>y ? 1 : 0;
  26737. if ( test !== 0 ) {
  26738. return sort.dir === 'asc' ? test : -test;
  26739. }
  26740. }
  26741. x = aiOrig[a];
  26742. y = aiOrig[b];
  26743. return x<y ? -1 : x>y ? 1 : 0;
  26744. } );
  26745. }
  26746. else {
  26747. // Depreciated - remove in 1.11 (providing a plug-in option)
  26748. // Not all sort types have formatting methods, so we have to call their sorting
  26749. // methods.
  26750. displayMaster.sort( function ( a, b ) {
  26751. var
  26752. x, y, k, l, test, sort, fn,
  26753. len=aSort.length,
  26754. dataA = aoData[a]._aSortData,
  26755. dataB = aoData[b]._aSortData;
  26756. for ( k=0 ; k<len ; k++ ) {
  26757. sort = aSort[k];
  26758. x = dataA[ sort.col ];
  26759. y = dataB[ sort.col ];
  26760. fn = oExtSort[ sort.type+"-"+sort.dir ] || oExtSort[ "string-"+sort.dir ];
  26761. test = fn( x, y );
  26762. if ( test !== 0 ) {
  26763. return test;
  26764. }
  26765. }
  26766. x = aiOrig[a];
  26767. y = aiOrig[b];
  26768. return x<y ? -1 : x>y ? 1 : 0;
  26769. } );
  26770. }
  26771. }
  26772. /* Tell the draw function that we have sorted the data */
  26773. oSettings.bSorted = true;
  26774. }
  26775. function _fnSortAria ( settings )
  26776. {
  26777. var label;
  26778. var nextSort;
  26779. var columns = settings.aoColumns;
  26780. var aSort = _fnSortFlatten( settings );
  26781. var oAria = settings.oLanguage.oAria;
  26782. // ARIA attributes - need to loop all columns, to update all (removing old
  26783. // attributes as needed)
  26784. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  26785. {
  26786. var col = columns[i];
  26787. var asSorting = col.asSorting;
  26788. var sTitle = col.sTitle.replace( /<.*?>/g, "" );
  26789. var th = col.nTh;
  26790. // IE7 is throwing an error when setting these properties with jQuery's
  26791. // attr() and removeAttr() methods...
  26792. th.removeAttribute('aria-sort');
  26793. /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
  26794. if ( col.bSortable ) {
  26795. if ( aSort.length > 0 && aSort[0].col == i ) {
  26796. th.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
  26797. nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
  26798. }
  26799. else {
  26800. nextSort = asSorting[0];
  26801. }
  26802. label = sTitle + ( nextSort === "asc" ?
  26803. oAria.sSortAscending :
  26804. oAria.sSortDescending
  26805. );
  26806. }
  26807. else {
  26808. label = sTitle;
  26809. }
  26810. th.setAttribute('aria-label', label);
  26811. }
  26812. }
  26813. /**
  26814. * Function to run on user sort request
  26815. * @param {object} settings dataTables settings object
  26816. * @param {node} attachTo node to attach the handler to
  26817. * @param {int} colIdx column sorting index
  26818. * @param {boolean} [append=false] Append the requested sort to the existing
  26819. * sort if true (i.e. multi-column sort)
  26820. * @param {function} [callback] callback function
  26821. * @memberof DataTable#oApi
  26822. */
  26823. function _fnSortListener ( settings, colIdx, append, callback )
  26824. {
  26825. var col = settings.aoColumns[ colIdx ];
  26826. var sorting = settings.aaSorting;
  26827. var asSorting = col.asSorting;
  26828. var nextSortIdx;
  26829. var next = function ( a, overflow ) {
  26830. var idx = a._idx;
  26831. if ( idx === undefined ) {
  26832. idx = $.inArray( a[1], asSorting );
  26833. }
  26834. return idx+1 < asSorting.length ?
  26835. idx+1 :
  26836. overflow ?
  26837. null :
  26838. 0;
  26839. };
  26840. // Convert to 2D array if needed
  26841. if ( typeof sorting[0] === 'number' ) {
  26842. sorting = settings.aaSorting = [ sorting ];
  26843. }
  26844. // If appending the sort then we are multi-column sorting
  26845. if ( append && settings.oFeatures.bSortMulti ) {
  26846. // Are we already doing some kind of sort on this column?
  26847. var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
  26848. if ( sortIdx !== -1 ) {
  26849. // Yes, modify the sort
  26850. nextSortIdx = next( sorting[sortIdx], true );
  26851. if ( nextSortIdx === null && sorting.length === 1 ) {
  26852. nextSortIdx = 0; // can't remove sorting completely
  26853. }
  26854. if ( nextSortIdx === null ) {
  26855. sorting.splice( sortIdx, 1 );
  26856. }
  26857. else {
  26858. sorting[sortIdx][1] = asSorting[ nextSortIdx ];
  26859. sorting[sortIdx]._idx = nextSortIdx;
  26860. }
  26861. }
  26862. else {
  26863. // No sort on this column yet
  26864. sorting.push( [ colIdx, asSorting[0], 0 ] );
  26865. sorting[sorting.length-1]._idx = 0;
  26866. }
  26867. }
  26868. else if ( sorting.length && sorting[0][0] == colIdx ) {
  26869. // Single column - already sorting on this column, modify the sort
  26870. nextSortIdx = next( sorting[0] );
  26871. sorting.length = 1;
  26872. sorting[0][1] = asSorting[ nextSortIdx ];
  26873. sorting[0]._idx = nextSortIdx;
  26874. }
  26875. else {
  26876. // Single column - sort only on this column
  26877. sorting.length = 0;
  26878. sorting.push( [ colIdx, asSorting[0] ] );
  26879. sorting[0]._idx = 0;
  26880. }
  26881. // Run the sort by calling a full redraw
  26882. _fnReDraw( settings );
  26883. // callback used for async user interaction
  26884. if ( typeof callback == 'function' ) {
  26885. callback( settings );
  26886. }
  26887. }
  26888. /**
  26889. * Attach a sort handler (click) to a node
  26890. * @param {object} settings dataTables settings object
  26891. * @param {node} attachTo node to attach the handler to
  26892. * @param {int} colIdx column sorting index
  26893. * @param {function} [callback] callback function
  26894. * @memberof DataTable#oApi
  26895. */
  26896. function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
  26897. {
  26898. var col = settings.aoColumns[ colIdx ];
  26899. _fnBindAction( attachTo, {}, function (e) {
  26900. /* If the column is not sortable - don't to anything */
  26901. if ( col.bSortable === false ) {
  26902. return;
  26903. }
  26904. // If processing is enabled use a timeout to allow the processing
  26905. // display to be shown - otherwise to it synchronously
  26906. if ( settings.oFeatures.bProcessing ) {
  26907. _fnProcessingDisplay( settings, true );
  26908. setTimeout( function() {
  26909. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  26910. // In server-side processing, the draw callback will remove the
  26911. // processing display
  26912. if ( _fnDataSource( settings ) !== 'ssp' ) {
  26913. _fnProcessingDisplay( settings, false );
  26914. }
  26915. }, 0 );
  26916. }
  26917. else {
  26918. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  26919. }
  26920. } );
  26921. }
  26922. /**
  26923. * Set the sorting classes on table's body, Note: it is safe to call this function
  26924. * when bSort and bSortClasses are false
  26925. * @param {object} oSettings dataTables settings object
  26926. * @memberof DataTable#oApi
  26927. */
  26928. function _fnSortingClasses( settings )
  26929. {
  26930. var oldSort = settings.aLastSort;
  26931. var sortClass = settings.oClasses.sSortColumn;
  26932. var sort = _fnSortFlatten( settings );
  26933. var features = settings.oFeatures;
  26934. var i, ien, colIdx;
  26935. if ( features.bSort && features.bSortClasses ) {
  26936. // Remove old sorting classes
  26937. for ( i=0, ien=oldSort.length ; i<ien ; i++ ) {
  26938. colIdx = oldSort[i].src;
  26939. // Remove column sorting
  26940. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  26941. .removeClass( sortClass + (i<2 ? i+1 : 3) );
  26942. }
  26943. // Add new column sorting
  26944. for ( i=0, ien=sort.length ; i<ien ; i++ ) {
  26945. colIdx = sort[i].src;
  26946. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  26947. .addClass( sortClass + (i<2 ? i+1 : 3) );
  26948. }
  26949. }
  26950. settings.aLastSort = sort;
  26951. }
  26952. // Get the data to sort a column, be it from cache, fresh (populating the
  26953. // cache), or from a sort formatter
  26954. function _fnSortData( settings, idx )
  26955. {
  26956. // Custom sorting function - provided by the sort data type
  26957. var column = settings.aoColumns[ idx ];
  26958. var customSort = DataTable.ext.order[ column.sSortDataType ];
  26959. var customData;
  26960. if ( customSort ) {
  26961. customData = customSort.call( settings.oInstance, settings, idx,
  26962. _fnColumnIndexToVisible( settings, idx )
  26963. );
  26964. }
  26965. // Use / populate cache
  26966. var row, cellData;
  26967. var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
  26968. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  26969. row = settings.aoData[i];
  26970. if ( ! row._aSortData ) {
  26971. row._aSortData = [];
  26972. }
  26973. if ( ! row._aSortData[idx] || customSort ) {
  26974. cellData = customSort ?
  26975. customData[i] : // If there was a custom sort function, use data from there
  26976. _fnGetCellData( settings, i, idx, 'sort' );
  26977. row._aSortData[ idx ] = formatter ?
  26978. formatter( cellData ) :
  26979. cellData;
  26980. }
  26981. }
  26982. }
  26983. /**
  26984. * Save the state of a table
  26985. * @param {object} oSettings dataTables settings object
  26986. * @memberof DataTable#oApi
  26987. */
  26988. function _fnSaveState ( settings )
  26989. {
  26990. if ( !settings.oFeatures.bStateSave || settings.bDestroying )
  26991. {
  26992. return;
  26993. }
  26994. /* Store the interesting variables */
  26995. var state = {
  26996. time: +new Date(),
  26997. start: settings._iDisplayStart,
  26998. length: settings._iDisplayLength,
  26999. order: $.extend( true, [], settings.aaSorting ),
  27000. search: _fnSearchToCamel( settings.oPreviousSearch ),
  27001. columns: $.map( settings.aoColumns, function ( col, i ) {
  27002. return {
  27003. visible: col.bVisible,
  27004. search: _fnSearchToCamel( settings.aoPreSearchCols[i] )
  27005. };
  27006. } )
  27007. };
  27008. _fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
  27009. settings.oSavedState = state;
  27010. settings.fnStateSaveCallback.call( settings.oInstance, settings, state );
  27011. }
  27012. /**
  27013. * Attempt to load a saved table state
  27014. * @param {object} oSettings dataTables settings object
  27015. * @param {object} oInit DataTables init object so we can override settings
  27016. * @memberof DataTable#oApi
  27017. */
  27018. function _fnLoadState ( settings, oInit )
  27019. {
  27020. var i, ien;
  27021. var columns = settings.aoColumns;
  27022. if ( ! settings.oFeatures.bStateSave ) {
  27023. return;
  27024. }
  27025. var state = settings.fnStateLoadCallback.call( settings.oInstance, settings );
  27026. if ( ! state || ! state.time ) {
  27027. return;
  27028. }
  27029. /* Allow custom and plug-in manipulation functions to alter the saved data set and
  27030. * cancelling of loading by returning false
  27031. */
  27032. var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, state] );
  27033. if ( $.inArray( false, abStateLoad ) !== -1 ) {
  27034. return;
  27035. }
  27036. /* Reject old data */
  27037. var duration = settings.iStateDuration;
  27038. if ( duration > 0 && state.time < +new Date() - (duration*1000) ) {
  27039. return;
  27040. }
  27041. // Number of columns have changed - all bets are off, no restore of settings
  27042. if ( columns.length !== state.columns.length ) {
  27043. return;
  27044. }
  27045. // Store the saved state so it might be accessed at any time
  27046. settings.oLoadedState = $.extend( true, {}, state );
  27047. // Restore key features - todo - for 1.11 this needs to be done by
  27048. // subscribed events
  27049. if ( state.start !== undefined ) {
  27050. settings._iDisplayStart = state.start;
  27051. settings.iInitDisplayStart = state.start;
  27052. }
  27053. if ( state.length !== undefined ) {
  27054. settings._iDisplayLength = state.length;
  27055. }
  27056. // Order
  27057. if ( state.order !== undefined ) {
  27058. settings.aaSorting = [];
  27059. $.each( state.order, function ( i, col ) {
  27060. settings.aaSorting.push( col[0] >= columns.length ?
  27061. [ 0, col[1] ] :
  27062. col
  27063. );
  27064. } );
  27065. }
  27066. // Search
  27067. if ( state.search !== undefined ) {
  27068. $.extend( settings.oPreviousSearch, _fnSearchToHung( state.search ) );
  27069. }
  27070. // Columns
  27071. for ( i=0, ien=state.columns.length ; i<ien ; i++ ) {
  27072. var col = state.columns[i];
  27073. // Visibility
  27074. if ( col.visible !== undefined ) {
  27075. columns[i].bVisible = col.visible;
  27076. }
  27077. // Search
  27078. if ( col.search !== undefined ) {
  27079. $.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
  27080. }
  27081. }
  27082. _fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, state] );
  27083. }
  27084. /**
  27085. * Return the settings object for a particular table
  27086. * @param {node} table table we are using as a dataTable
  27087. * @returns {object} Settings object - or null if not found
  27088. * @memberof DataTable#oApi
  27089. */
  27090. function _fnSettingsFromNode ( table )
  27091. {
  27092. var settings = DataTable.settings;
  27093. var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
  27094. return idx !== -1 ?
  27095. settings[ idx ] :
  27096. null;
  27097. }
  27098. /**
  27099. * Log an error message
  27100. * @param {object} settings dataTables settings object
  27101. * @param {int} level log error messages, or display them to the user
  27102. * @param {string} msg error message
  27103. * @param {int} tn Technical note id to get more information about the error.
  27104. * @memberof DataTable#oApi
  27105. */
  27106. function _fnLog( settings, level, msg, tn )
  27107. {
  27108. msg = 'DataTables warning: '+
  27109. (settings ? 'table id='+settings.sTableId+' - ' : '')+msg;
  27110. if ( tn ) {
  27111. msg += '. For more information about this error, please see '+
  27112. 'http://datatables.net/tn/'+tn;
  27113. }
  27114. if ( ! level ) {
  27115. // Backwards compatibility pre 1.10
  27116. var ext = DataTable.ext;
  27117. var type = ext.sErrMode || ext.errMode;
  27118. if ( settings ) {
  27119. _fnCallbackFire( settings, null, 'error', [ settings, tn, msg ] );
  27120. }
  27121. if ( type == 'alert' ) {
  27122. alert( msg );
  27123. }
  27124. else if ( type == 'throw' ) {
  27125. throw new Error(msg);
  27126. }
  27127. else if ( typeof type == 'function' ) {
  27128. type( settings, tn, msg );
  27129. }
  27130. }
  27131. else if ( window.console && console.log ) {
  27132. console.log( msg );
  27133. }
  27134. }
  27135. /**
  27136. * See if a property is defined on one object, if so assign it to the other object
  27137. * @param {object} ret target object
  27138. * @param {object} src source object
  27139. * @param {string} name property
  27140. * @param {string} [mappedName] name to map too - optional, name used if not given
  27141. * @memberof DataTable#oApi
  27142. */
  27143. function _fnMap( ret, src, name, mappedName )
  27144. {
  27145. if ( $.isArray( name ) ) {
  27146. $.each( name, function (i, val) {
  27147. if ( $.isArray( val ) ) {
  27148. _fnMap( ret, src, val[0], val[1] );
  27149. }
  27150. else {
  27151. _fnMap( ret, src, val );
  27152. }
  27153. } );
  27154. return;
  27155. }
  27156. if ( mappedName === undefined ) {
  27157. mappedName = name;
  27158. }
  27159. if ( src[name] !== undefined ) {
  27160. ret[mappedName] = src[name];
  27161. }
  27162. }
  27163. /**
  27164. * Extend objects - very similar to jQuery.extend, but deep copy objects, and
  27165. * shallow copy arrays. The reason we need to do this, is that we don't want to
  27166. * deep copy array init values (such as aaSorting) since the dev wouldn't be
  27167. * able to override them, but we do want to deep copy arrays.
  27168. * @param {object} out Object to extend
  27169. * @param {object} extender Object from which the properties will be applied to
  27170. * out
  27171. * @param {boolean} breakRefs If true, then arrays will be sliced to take an
  27172. * independent copy with the exception of the `data` or `aaData` parameters
  27173. * if they are present. This is so you can pass in a collection to
  27174. * DataTables and have that used as your data source without breaking the
  27175. * references
  27176. * @returns {object} out Reference, just for convenience - out === the return.
  27177. * @memberof DataTable#oApi
  27178. * @todo This doesn't take account of arrays inside the deep copied objects.
  27179. */
  27180. function _fnExtend( out, extender, breakRefs )
  27181. {
  27182. var val;
  27183. for ( var prop in extender ) {
  27184. if ( extender.hasOwnProperty(prop) ) {
  27185. val = extender[prop];
  27186. if ( $.isPlainObject( val ) ) {
  27187. if ( ! $.isPlainObject( out[prop] ) ) {
  27188. out[prop] = {};
  27189. }
  27190. $.extend( true, out[prop], val );
  27191. }
  27192. else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && $.isArray(val) ) {
  27193. out[prop] = val.slice();
  27194. }
  27195. else {
  27196. out[prop] = val;
  27197. }
  27198. }
  27199. }
  27200. return out;
  27201. }
  27202. /**
  27203. * Bind an event handers to allow a click or return key to activate the callback.
  27204. * This is good for accessibility since a return on the keyboard will have the
  27205. * same effect as a click, if the element has focus.
  27206. * @param {element} n Element to bind the action to
  27207. * @param {object} oData Data object to pass to the triggered function
  27208. * @param {function} fn Callback function for when the event is triggered
  27209. * @memberof DataTable#oApi
  27210. */
  27211. function _fnBindAction( n, oData, fn )
  27212. {
  27213. $(n)
  27214. .bind( 'click.DT', oData, function (e) {
  27215. n.blur(); // Remove focus outline for mouse users
  27216. fn(e);
  27217. } )
  27218. .bind( 'keypress.DT', oData, function (e){
  27219. if ( e.which === 13 ) {
  27220. e.preventDefault();
  27221. fn(e);
  27222. }
  27223. } )
  27224. .bind( 'selectstart.DT', function () {
  27225. /* Take the brutal approach to cancelling text selection */
  27226. return false;
  27227. } );
  27228. }
  27229. /**
  27230. * Register a callback function. Easily allows a callback function to be added to
  27231. * an array store of callback functions that can then all be called together.
  27232. * @param {object} oSettings dataTables settings object
  27233. * @param {string} sStore Name of the array storage for the callbacks in oSettings
  27234. * @param {function} fn Function to be called back
  27235. * @param {string} sName Identifying name for the callback (i.e. a label)
  27236. * @memberof DataTable#oApi
  27237. */
  27238. function _fnCallbackReg( oSettings, sStore, fn, sName )
  27239. {
  27240. if ( fn )
  27241. {
  27242. oSettings[sStore].push( {
  27243. "fn": fn,
  27244. "sName": sName
  27245. } );
  27246. }
  27247. }
  27248. /**
  27249. * Fire callback functions and trigger events. Note that the loop over the
  27250. * callback array store is done backwards! Further note that you do not want to
  27251. * fire off triggers in time sensitive applications (for example cell creation)
  27252. * as its slow.
  27253. * @param {object} settings dataTables settings object
  27254. * @param {string} callbackArr Name of the array storage for the callbacks in
  27255. * oSettings
  27256. * @param {string} eventName Name of the jQuery custom event to trigger. If
  27257. * null no trigger is fired
  27258. * @param {array} args Array of arguments to pass to the callback function /
  27259. * trigger
  27260. * @memberof DataTable#oApi
  27261. */
  27262. function _fnCallbackFire( settings, callbackArr, eventName, args )
  27263. {
  27264. var ret = [];
  27265. if ( callbackArr ) {
  27266. ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
  27267. return val.fn.apply( settings.oInstance, args );
  27268. } );
  27269. }
  27270. if ( eventName !== null ) {
  27271. var e = $.Event( eventName+'.dt' );
  27272. $(settings.nTable).trigger( e, args );
  27273. ret.push( e.result );
  27274. }
  27275. return ret;
  27276. }
  27277. function _fnLengthOverflow ( settings )
  27278. {
  27279. var
  27280. start = settings._iDisplayStart,
  27281. end = settings.fnDisplayEnd(),
  27282. len = settings._iDisplayLength;
  27283. /* If we have space to show extra rows (backing up from the end point - then do so */
  27284. if ( start >= end )
  27285. {
  27286. start = end - len;
  27287. }
  27288. // Keep the start record on the current page
  27289. start -= (start % len);
  27290. if ( len === -1 || start < 0 )
  27291. {
  27292. start = 0;
  27293. }
  27294. settings._iDisplayStart = start;
  27295. }
  27296. function _fnRenderer( settings, type )
  27297. {
  27298. var renderer = settings.renderer;
  27299. var host = DataTable.ext.renderer[type];
  27300. if ( $.isPlainObject( renderer ) && renderer[type] ) {
  27301. // Specific renderer for this type. If available use it, otherwise use
  27302. // the default.
  27303. return host[renderer[type]] || host._;
  27304. }
  27305. else if ( typeof renderer === 'string' ) {
  27306. // Common renderer - if there is one available for this type use it,
  27307. // otherwise use the default
  27308. return host[renderer] || host._;
  27309. }
  27310. // Use the default
  27311. return host._;
  27312. }
  27313. /**
  27314. * Detect the data source being used for the table. Used to simplify the code
  27315. * a little (ajax) and to make it compress a little smaller.
  27316. *
  27317. * @param {object} settings dataTables settings object
  27318. * @returns {string} Data source
  27319. * @memberof DataTable#oApi
  27320. */
  27321. function _fnDataSource ( settings )
  27322. {
  27323. if ( settings.oFeatures.bServerSide ) {
  27324. return 'ssp';
  27325. }
  27326. else if ( settings.ajax || settings.sAjaxSource ) {
  27327. return 'ajax';
  27328. }
  27329. return 'dom';
  27330. }
  27331. /**
  27332. * Computed structure of the DataTables API, defined by the options passed to
  27333. * `DataTable.Api.register()` when building the API.
  27334. *
  27335. * The structure is built in order to speed creation and extension of the Api
  27336. * objects since the extensions are effectively pre-parsed.
  27337. *
  27338. * The array is an array of objects with the following structure, where this
  27339. * base array represents the Api prototype base:
  27340. *
  27341. * [
  27342. * {
  27343. * name: 'data' -- string - Property name
  27344. * val: function () {}, -- function - Api method (or undefined if just an object
  27345. * methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  27346. * propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  27347. * },
  27348. * {
  27349. * name: 'row'
  27350. * val: {},
  27351. * methodExt: [ ... ],
  27352. * propExt: [
  27353. * {
  27354. * name: 'data'
  27355. * val: function () {},
  27356. * methodExt: [ ... ],
  27357. * propExt: [ ... ]
  27358. * },
  27359. * ...
  27360. * ]
  27361. * }
  27362. * ]
  27363. *
  27364. * @type {Array}
  27365. * @ignore
  27366. */
  27367. var __apiStruct = [];
  27368. /**
  27369. * `Array.prototype` reference.
  27370. *
  27371. * @type object
  27372. * @ignore
  27373. */
  27374. var __arrayProto = Array.prototype;
  27375. /**
  27376. * Abstraction for `context` parameter of the `Api` constructor to allow it to
  27377. * take several different forms for ease of use.
  27378. *
  27379. * Each of the input parameter types will be converted to a DataTables settings
  27380. * object where possible.
  27381. *
  27382. * @param {string|node|jQuery|object} mixed DataTable identifier. Can be one
  27383. * of:
  27384. *
  27385. * * `string` - jQuery selector. Any DataTables' matching the given selector
  27386. * with be found and used.
  27387. * * `node` - `TABLE` node which has already been formed into a DataTable.
  27388. * * `jQuery` - A jQuery object of `TABLE` nodes.
  27389. * * `object` - DataTables settings object
  27390. * * `DataTables.Api` - API instance
  27391. * @return {array|null} Matching DataTables settings objects. `null` or
  27392. * `undefined` is returned if no matching DataTable is found.
  27393. * @ignore
  27394. */
  27395. var _toSettings = function ( mixed )
  27396. {
  27397. var idx, jq;
  27398. var settings = DataTable.settings;
  27399. var tables = $.map( settings, function (el, i) {
  27400. return el.nTable;
  27401. } );
  27402. if ( ! mixed ) {
  27403. return [];
  27404. }
  27405. else if ( mixed.nTable && mixed.oApi ) {
  27406. // DataTables settings object
  27407. return [ mixed ];
  27408. }
  27409. else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
  27410. // Table node
  27411. idx = $.inArray( mixed, tables );
  27412. return idx !== -1 ? [ settings[idx] ] : null;
  27413. }
  27414. else if ( mixed && typeof mixed.settings === 'function' ) {
  27415. return mixed.settings().toArray();
  27416. }
  27417. else if ( typeof mixed === 'string' ) {
  27418. // jQuery selector
  27419. jq = $(mixed);
  27420. }
  27421. else if ( mixed instanceof $ ) {
  27422. // jQuery object (also DataTables instance)
  27423. jq = mixed;
  27424. }
  27425. if ( jq ) {
  27426. return jq.map( function(i) {
  27427. idx = $.inArray( this, tables );
  27428. return idx !== -1 ? settings[idx] : null;
  27429. } ).toArray();
  27430. }
  27431. };
  27432. /**
  27433. * DataTables API class - used to control and interface with one or more
  27434. * DataTables enhanced tables.
  27435. *
  27436. * The API class is heavily based on jQuery, presenting a chainable interface
  27437. * that you can use to interact with tables. Each instance of the API class has
  27438. * a "context" - i.e. the tables that it will operate on. This could be a single
  27439. * table, all tables on a page or a sub-set thereof.
  27440. *
  27441. * Additionally the API is designed to allow you to easily work with the data in
  27442. * the tables, retrieving and manipulating it as required. This is done by
  27443. * presenting the API class as an array like interface. The contents of the
  27444. * array depend upon the actions requested by each method (for example
  27445. * `rows().nodes()` will return an array of nodes, while `rows().data()` will
  27446. * return an array of objects or arrays depending upon your table's
  27447. * configuration). The API object has a number of array like methods (`push`,
  27448. * `pop`, `reverse` etc) as well as additional helper methods (`each`, `pluck`,
  27449. * `unique` etc) to assist your working with the data held in a table.
  27450. *
  27451. * Most methods (those which return an Api instance) are chainable, which means
  27452. * the return from a method call also has all of the methods available that the
  27453. * top level object had. For example, these two calls are equivalent:
  27454. *
  27455. * // Not chained
  27456. * api.row.add( {...} );
  27457. * api.draw();
  27458. *
  27459. * // Chained
  27460. * api.row.add( {...} ).draw();
  27461. *
  27462. * @class DataTable.Api
  27463. * @param {array|object|string|jQuery} context DataTable identifier. This is
  27464. * used to define which DataTables enhanced tables this API will operate on.
  27465. * Can be one of:
  27466. *
  27467. * * `string` - jQuery selector. Any DataTables' matching the given selector
  27468. * with be found and used.
  27469. * * `node` - `TABLE` node which has already been formed into a DataTable.
  27470. * * `jQuery` - A jQuery object of `TABLE` nodes.
  27471. * * `object` - DataTables settings object
  27472. * @param {array} [data] Data to initialise the Api instance with.
  27473. *
  27474. * @example
  27475. * // Direct initialisation during DataTables construction
  27476. * var api = $('#example').DataTable();
  27477. *
  27478. * @example
  27479. * // Initialisation using a DataTables jQuery object
  27480. * var api = $('#example').dataTable().api();
  27481. *
  27482. * @example
  27483. * // Initialisation as a constructor
  27484. * var api = new $.fn.DataTable.Api( 'table.dataTable' );
  27485. */
  27486. _Api = function ( context, data )
  27487. {
  27488. if ( ! (this instanceof _Api) ) {
  27489. return new _Api( context, data );
  27490. }
  27491. var settings = [];
  27492. var ctxSettings = function ( o ) {
  27493. var a = _toSettings( o );
  27494. if ( a ) {
  27495. settings = settings.concat( a );
  27496. }
  27497. };
  27498. if ( $.isArray( context ) ) {
  27499. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  27500. ctxSettings( context[i] );
  27501. }
  27502. }
  27503. else {
  27504. ctxSettings( context );
  27505. }
  27506. // Remove duplicates
  27507. this.context = _unique( settings );
  27508. // Initial data
  27509. if ( data ) {
  27510. $.merge( this, data );
  27511. }
  27512. // selector
  27513. this.selector = {
  27514. rows: null,
  27515. cols: null,
  27516. opts: null
  27517. };
  27518. _Api.extend( this, this, __apiStruct );
  27519. };
  27520. DataTable.Api = _Api;
  27521. // Don't destroy the existing prototype, just extend it. Required for jQuery 2's
  27522. // isPlainObject.
  27523. $.extend( _Api.prototype, {
  27524. any: function ()
  27525. {
  27526. return this.count() !== 0;
  27527. },
  27528. concat: __arrayProto.concat,
  27529. context: [], // array of table settings objects
  27530. count: function ()
  27531. {
  27532. return this.flatten().length;
  27533. },
  27534. each: function ( fn )
  27535. {
  27536. for ( var i=0, ien=this.length ; i<ien; i++ ) {
  27537. fn.call( this, this[i], i, this );
  27538. }
  27539. return this;
  27540. },
  27541. eq: function ( idx )
  27542. {
  27543. var ctx = this.context;
  27544. return ctx.length > idx ?
  27545. new _Api( ctx[idx], this[idx] ) :
  27546. null;
  27547. },
  27548. filter: function ( fn )
  27549. {
  27550. var a = [];
  27551. if ( __arrayProto.filter ) {
  27552. a = __arrayProto.filter.call( this, fn, this );
  27553. }
  27554. else {
  27555. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  27556. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  27557. if ( fn.call( this, this[i], i, this ) ) {
  27558. a.push( this[i] );
  27559. }
  27560. }
  27561. }
  27562. return new _Api( this.context, a );
  27563. },
  27564. flatten: function ()
  27565. {
  27566. var a = [];
  27567. return new _Api( this.context, a.concat.apply( a, this.toArray() ) );
  27568. },
  27569. join: __arrayProto.join,
  27570. indexOf: __arrayProto.indexOf || function (obj, start)
  27571. {
  27572. for ( var i=(start || 0), ien=this.length ; i<ien ; i++ ) {
  27573. if ( this[i] === obj ) {
  27574. return i;
  27575. }
  27576. }
  27577. return -1;
  27578. },
  27579. iterator: function ( flatten, type, fn, alwaysNew ) {
  27580. var
  27581. a = [], ret,
  27582. i, ien, j, jen,
  27583. context = this.context,
  27584. rows, items, item,
  27585. selector = this.selector;
  27586. // Argument shifting
  27587. if ( typeof flatten === 'string' ) {
  27588. alwaysNew = fn;
  27589. fn = type;
  27590. type = flatten;
  27591. flatten = false;
  27592. }
  27593. for ( i=0, ien=context.length ; i<ien ; i++ ) {
  27594. var apiInst = new _Api( context[i] );
  27595. if ( type === 'table' ) {
  27596. ret = fn.call( apiInst, context[i], i );
  27597. if ( ret !== undefined ) {
  27598. a.push( ret );
  27599. }
  27600. }
  27601. else if ( type === 'columns' || type === 'rows' ) {
  27602. // this has same length as context - one entry for each table
  27603. ret = fn.call( apiInst, context[i], this[i], i );
  27604. if ( ret !== undefined ) {
  27605. a.push( ret );
  27606. }
  27607. }
  27608. else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) {
  27609. // columns and rows share the same structure.
  27610. // 'this' is an array of column indexes for each context
  27611. items = this[i];
  27612. if ( type === 'column-rows' ) {
  27613. rows = _selector_row_indexes( context[i], selector.opts );
  27614. }
  27615. for ( j=0, jen=items.length ; j<jen ; j++ ) {
  27616. item = items[j];
  27617. if ( type === 'cell' ) {
  27618. ret = fn.call( apiInst, context[i], item.row, item.column, i, j );
  27619. }
  27620. else {
  27621. ret = fn.call( apiInst, context[i], item, i, j, rows );
  27622. }
  27623. if ( ret !== undefined ) {
  27624. a.push( ret );
  27625. }
  27626. }
  27627. }
  27628. }
  27629. if ( a.length || alwaysNew ) {
  27630. var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a );
  27631. var apiSelector = api.selector;
  27632. apiSelector.rows = selector.rows;
  27633. apiSelector.cols = selector.cols;
  27634. apiSelector.opts = selector.opts;
  27635. return api;
  27636. }
  27637. return this;
  27638. },
  27639. lastIndexOf: __arrayProto.lastIndexOf || function (obj, start)
  27640. {
  27641. // Bit cheeky...
  27642. return this.indexOf.apply( this.toArray.reverse(), arguments );
  27643. },
  27644. length: 0,
  27645. map: function ( fn )
  27646. {
  27647. var a = [];
  27648. if ( __arrayProto.map ) {
  27649. a = __arrayProto.map.call( this, fn, this );
  27650. }
  27651. else {
  27652. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  27653. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  27654. a.push( fn.call( this, this[i], i ) );
  27655. }
  27656. }
  27657. return new _Api( this.context, a );
  27658. },
  27659. pluck: function ( prop )
  27660. {
  27661. return this.map( function ( el ) {
  27662. return el[ prop ];
  27663. } );
  27664. },
  27665. pop: __arrayProto.pop,
  27666. push: __arrayProto.push,
  27667. // Does not return an API instance
  27668. reduce: __arrayProto.reduce || function ( fn, init )
  27669. {
  27670. return _fnReduce( this, fn, init, 0, this.length, 1 );
  27671. },
  27672. reduceRight: __arrayProto.reduceRight || function ( fn, init )
  27673. {
  27674. return _fnReduce( this, fn, init, this.length-1, -1, -1 );
  27675. },
  27676. reverse: __arrayProto.reverse,
  27677. // Object with rows, columns and opts
  27678. selector: null,
  27679. shift: __arrayProto.shift,
  27680. sort: __arrayProto.sort, // ? name - order?
  27681. splice: __arrayProto.splice,
  27682. toArray: function ()
  27683. {
  27684. return __arrayProto.slice.call( this );
  27685. },
  27686. to$: function ()
  27687. {
  27688. return $( this );
  27689. },
  27690. toJQuery: function ()
  27691. {
  27692. return $( this );
  27693. },
  27694. unique: function ()
  27695. {
  27696. return new _Api( this.context, _unique(this) );
  27697. },
  27698. unshift: __arrayProto.unshift
  27699. } );
  27700. _Api.extend = function ( scope, obj, ext )
  27701. {
  27702. // Only extend API instances and static properties of the API
  27703. if ( ! ext.length || ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
  27704. return;
  27705. }
  27706. var
  27707. i, ien,
  27708. j, jen,
  27709. struct, inner,
  27710. methodScoping = function ( scope, fn, struc ) {
  27711. return function () {
  27712. var ret = fn.apply( scope, arguments );
  27713. // Method extension
  27714. _Api.extend( ret, ret, struc.methodExt );
  27715. return ret;
  27716. };
  27717. };
  27718. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  27719. struct = ext[i];
  27720. // Value
  27721. obj[ struct.name ] = typeof struct.val === 'function' ?
  27722. methodScoping( scope, struct.val, struct ) :
  27723. $.isPlainObject( struct.val ) ?
  27724. {} :
  27725. struct.val;
  27726. obj[ struct.name ].__dt_wrapper = true;
  27727. // Property extension
  27728. _Api.extend( scope, obj[ struct.name ], struct.propExt );
  27729. }
  27730. };
  27731. // @todo - Is there need for an augment function?
  27732. // _Api.augment = function ( inst, name )
  27733. // {
  27734. // // Find src object in the structure from the name
  27735. // var parts = name.split('.');
  27736. // _Api.extend( inst, obj );
  27737. // };
  27738. // [
  27739. // {
  27740. // name: 'data' -- string - Property name
  27741. // val: function () {}, -- function - Api method (or undefined if just an object
  27742. // methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  27743. // propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  27744. // },
  27745. // {
  27746. // name: 'row'
  27747. // val: {},
  27748. // methodExt: [ ... ],
  27749. // propExt: [
  27750. // {
  27751. // name: 'data'
  27752. // val: function () {},
  27753. // methodExt: [ ... ],
  27754. // propExt: [ ... ]
  27755. // },
  27756. // ...
  27757. // ]
  27758. // }
  27759. // ]
  27760. _Api.register = _api_register = function ( name, val )
  27761. {
  27762. if ( $.isArray( name ) ) {
  27763. for ( var j=0, jen=name.length ; j<jen ; j++ ) {
  27764. _Api.register( name[j], val );
  27765. }
  27766. return;
  27767. }
  27768. var
  27769. i, ien,
  27770. heir = name.split('.'),
  27771. struct = __apiStruct,
  27772. key, method;
  27773. var find = function ( src, name ) {
  27774. for ( var i=0, ien=src.length ; i<ien ; i++ ) {
  27775. if ( src[i].name === name ) {
  27776. return src[i];
  27777. }
  27778. }
  27779. return null;
  27780. };
  27781. for ( i=0, ien=heir.length ; i<ien ; i++ ) {
  27782. method = heir[i].indexOf('()') !== -1;
  27783. key = method ?
  27784. heir[i].replace('()', '') :
  27785. heir[i];
  27786. var src = find( struct, key );
  27787. if ( ! src ) {
  27788. src = {
  27789. name: key,
  27790. val: {},
  27791. methodExt: [],
  27792. propExt: []
  27793. };
  27794. struct.push( src );
  27795. }
  27796. if ( i === ien-1 ) {
  27797. src.val = val;
  27798. }
  27799. else {
  27800. struct = method ?
  27801. src.methodExt :
  27802. src.propExt;
  27803. }
  27804. }
  27805. };
  27806. _Api.registerPlural = _api_registerPlural = function ( pluralName, singularName, val ) {
  27807. _Api.register( pluralName, val );
  27808. _Api.register( singularName, function () {
  27809. var ret = val.apply( this, arguments );
  27810. if ( ret === this ) {
  27811. // Returned item is the API instance that was passed in, return it
  27812. return this;
  27813. }
  27814. else if ( ret instanceof _Api ) {
  27815. // New API instance returned, want the value from the first item
  27816. // in the returned array for the singular result.
  27817. return ret.length ?
  27818. $.isArray( ret[0] ) ?
  27819. new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
  27820. ret[0] :
  27821. undefined;
  27822. }
  27823. // Non-API return - just fire it back
  27824. return ret;
  27825. } );
  27826. };
  27827. /**
  27828. * Selector for HTML tables. Apply the given selector to the give array of
  27829. * DataTables settings objects.
  27830. *
  27831. * @param {string|integer} [selector] jQuery selector string or integer
  27832. * @param {array} Array of DataTables settings objects to be filtered
  27833. * @return {array}
  27834. * @ignore
  27835. */
  27836. var __table_selector = function ( selector, a )
  27837. {
  27838. // Integer is used to pick out a table by index
  27839. if ( typeof selector === 'number' ) {
  27840. return [ a[ selector ] ];
  27841. }
  27842. // Perform a jQuery selector on the table nodes
  27843. var nodes = $.map( a, function (el, i) {
  27844. return el.nTable;
  27845. } );
  27846. return $(nodes)
  27847. .filter( selector )
  27848. .map( function (i) {
  27849. // Need to translate back from the table node to the settings
  27850. var idx = $.inArray( this, nodes );
  27851. return a[ idx ];
  27852. } )
  27853. .toArray();
  27854. };
  27855. /**
  27856. * Context selector for the API's context (i.e. the tables the API instance
  27857. * refers to.
  27858. *
  27859. * @name DataTable.Api#tables
  27860. * @param {string|integer} [selector] Selector to pick which tables the iterator
  27861. * should operate on. If not given, all tables in the current context are
  27862. * used. This can be given as a jQuery selector (for example `':gt(0)'`) to
  27863. * select multiple tables or as an integer to select a single table.
  27864. * @returns {DataTable.Api} Returns a new API instance if a selector is given.
  27865. */
  27866. _api_register( 'tables()', function ( selector ) {
  27867. // A new instance is created if there was a selector specified
  27868. return selector ?
  27869. new _Api( __table_selector( selector, this.context ) ) :
  27870. this;
  27871. } );
  27872. _api_register( 'table()', function ( selector ) {
  27873. var tables = this.tables( selector );
  27874. var ctx = tables.context;
  27875. // Truncate to the first matched table
  27876. return ctx.length ?
  27877. new _Api( ctx[0] ) :
  27878. tables;
  27879. } );
  27880. _api_registerPlural( 'tables().nodes()', 'table().node()' , function () {
  27881. return this.iterator( 'table', function ( ctx ) {
  27882. return ctx.nTable;
  27883. }, 1 );
  27884. } );
  27885. _api_registerPlural( 'tables().body()', 'table().body()' , function () {
  27886. return this.iterator( 'table', function ( ctx ) {
  27887. return ctx.nTBody;
  27888. }, 1 );
  27889. } );
  27890. _api_registerPlural( 'tables().header()', 'table().header()' , function () {
  27891. return this.iterator( 'table', function ( ctx ) {
  27892. return ctx.nTHead;
  27893. }, 1 );
  27894. } );
  27895. _api_registerPlural( 'tables().footer()', 'table().footer()' , function () {
  27896. return this.iterator( 'table', function ( ctx ) {
  27897. return ctx.nTFoot;
  27898. }, 1 );
  27899. } );
  27900. _api_registerPlural( 'tables().containers()', 'table().container()' , function () {
  27901. return this.iterator( 'table', function ( ctx ) {
  27902. return ctx.nTableWrapper;
  27903. }, 1 );
  27904. } );
  27905. /**
  27906. * Redraw the tables in the current context.
  27907. */
  27908. _api_register( 'draw()', function ( paging ) {
  27909. return this.iterator( 'table', function ( settings ) {
  27910. if ( paging === 'page' ) {
  27911. _fnDraw( settings );
  27912. }
  27913. else {
  27914. if ( typeof paging === 'string' ) {
  27915. paging = paging === 'full-hold' ?
  27916. false :
  27917. true;
  27918. }
  27919. _fnReDraw( settings, paging===false );
  27920. }
  27921. } );
  27922. } );
  27923. /**
  27924. * Get the current page index.
  27925. *
  27926. * @return {integer} Current page index (zero based)
  27927. *//**
  27928. * Set the current page.
  27929. *
  27930. * Note that if you attempt to show a page which does not exist, DataTables will
  27931. * not throw an error, but rather reset the paging.
  27932. *
  27933. * @param {integer|string} action The paging action to take. This can be one of:
  27934. * * `integer` - The page index to jump to
  27935. * * `string` - An action to take:
  27936. * * `first` - Jump to first page.
  27937. * * `next` - Jump to the next page
  27938. * * `previous` - Jump to previous page
  27939. * * `last` - Jump to the last page.
  27940. * @returns {DataTables.Api} this
  27941. */
  27942. _api_register( 'page()', function ( action ) {
  27943. if ( action === undefined ) {
  27944. return this.page.info().page; // not an expensive call
  27945. }
  27946. // else, have an action to take on all tables
  27947. return this.iterator( 'table', function ( settings ) {
  27948. _fnPageChange( settings, action );
  27949. } );
  27950. } );
  27951. /**
  27952. * Paging information for the first table in the current context.
  27953. *
  27954. * If you require paging information for another table, use the `table()` method
  27955. * with a suitable selector.
  27956. *
  27957. * @return {object} Object with the following properties set:
  27958. * * `page` - Current page index (zero based - i.e. the first page is `0`)
  27959. * * `pages` - Total number of pages
  27960. * * `start` - Display index for the first record shown on the current page
  27961. * * `end` - Display index for the last record shown on the current page
  27962. * * `length` - Display length (number of records). Note that generally `start
  27963. * + length = end`, but this is not always true, for example if there are
  27964. * only 2 records to show on the final page, with a length of 10.
  27965. * * `recordsTotal` - Full data set length
  27966. * * `recordsDisplay` - Data set length once the current filtering criterion
  27967. * are applied.
  27968. */
  27969. _api_register( 'page.info()', function ( action ) {
  27970. if ( this.context.length === 0 ) {
  27971. return undefined;
  27972. }
  27973. var
  27974. settings = this.context[0],
  27975. start = settings._iDisplayStart,
  27976. len = settings.oFeatures.bPaginate ? settings._iDisplayLength : -1,
  27977. visRecords = settings.fnRecordsDisplay(),
  27978. all = len === -1;
  27979. return {
  27980. "page": all ? 0 : Math.floor( start / len ),
  27981. "pages": all ? 1 : Math.ceil( visRecords / len ),
  27982. "start": start,
  27983. "end": settings.fnDisplayEnd(),
  27984. "length": len,
  27985. "recordsTotal": settings.fnRecordsTotal(),
  27986. "recordsDisplay": visRecords,
  27987. "serverSide": _fnDataSource( settings ) === 'ssp'
  27988. };
  27989. } );
  27990. /**
  27991. * Get the current page length.
  27992. *
  27993. * @return {integer} Current page length. Note `-1` indicates that all records
  27994. * are to be shown.
  27995. *//**
  27996. * Set the current page length.
  27997. *
  27998. * @param {integer} Page length to set. Use `-1` to show all records.
  27999. * @returns {DataTables.Api} this
  28000. */
  28001. _api_register( 'page.len()', function ( len ) {
  28002. // Note that we can't call this function 'length()' because `length`
  28003. // is a Javascript property of functions which defines how many arguments
  28004. // the function expects.
  28005. if ( len === undefined ) {
  28006. return this.context.length !== 0 ?
  28007. this.context[0]._iDisplayLength :
  28008. undefined;
  28009. }
  28010. // else, set the page length
  28011. return this.iterator( 'table', function ( settings ) {
  28012. _fnLengthChange( settings, len );
  28013. } );
  28014. } );
  28015. var __reload = function ( settings, holdPosition, callback ) {
  28016. // Use the draw event to trigger a callback
  28017. if ( callback ) {
  28018. var api = new _Api( settings );
  28019. api.one( 'draw', function () {
  28020. callback( api.ajax.json() );
  28021. } );
  28022. }
  28023. if ( _fnDataSource( settings ) == 'ssp' ) {
  28024. _fnReDraw( settings, holdPosition );
  28025. }
  28026. else {
  28027. _fnProcessingDisplay( settings, true );
  28028. // Cancel an existing request
  28029. var xhr = settings.jqXHR;
  28030. if ( xhr && xhr.readyState !== 4 ) {
  28031. xhr.abort();
  28032. }
  28033. // Trigger xhr
  28034. _fnBuildAjax( settings, [], function( json ) {
  28035. _fnClearTable( settings );
  28036. var data = _fnAjaxDataSrc( settings, json );
  28037. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  28038. _fnAddData( settings, data[i] );
  28039. }
  28040. _fnReDraw( settings, holdPosition );
  28041. _fnProcessingDisplay( settings, false );
  28042. } );
  28043. }
  28044. };
  28045. /**
  28046. * Get the JSON response from the last Ajax request that DataTables made to the
  28047. * server. Note that this returns the JSON from the first table in the current
  28048. * context.
  28049. *
  28050. * @return {object} JSON received from the server.
  28051. */
  28052. _api_register( 'ajax.json()', function () {
  28053. var ctx = this.context;
  28054. if ( ctx.length > 0 ) {
  28055. return ctx[0].json;
  28056. }
  28057. // else return undefined;
  28058. } );
  28059. /**
  28060. * Get the data submitted in the last Ajax request
  28061. */
  28062. _api_register( 'ajax.params()', function () {
  28063. var ctx = this.context;
  28064. if ( ctx.length > 0 ) {
  28065. return ctx[0].oAjaxData;
  28066. }
  28067. // else return undefined;
  28068. } );
  28069. /**
  28070. * Reload tables from the Ajax data source. Note that this function will
  28071. * automatically re-draw the table when the remote data has been loaded.
  28072. *
  28073. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  28074. * position. A full re-sort and re-filter is performed when this method is
  28075. * called, which is why the pagination reset is the default action.
  28076. * @returns {DataTables.Api} this
  28077. */
  28078. _api_register( 'ajax.reload()', function ( callback, resetPaging ) {
  28079. return this.iterator( 'table', function (settings) {
  28080. __reload( settings, resetPaging===false, callback );
  28081. } );
  28082. } );
  28083. /**
  28084. * Get the current Ajax URL. Note that this returns the URL from the first
  28085. * table in the current context.
  28086. *
  28087. * @return {string} Current Ajax source URL
  28088. *//**
  28089. * Set the Ajax URL. Note that this will set the URL for all tables in the
  28090. * current context.
  28091. *
  28092. * @param {string} url URL to set.
  28093. * @returns {DataTables.Api} this
  28094. */
  28095. _api_register( 'ajax.url()', function ( url ) {
  28096. var ctx = this.context;
  28097. if ( url === undefined ) {
  28098. // get
  28099. if ( ctx.length === 0 ) {
  28100. return undefined;
  28101. }
  28102. ctx = ctx[0];
  28103. return ctx.ajax ?
  28104. $.isPlainObject( ctx.ajax ) ?
  28105. ctx.ajax.url :
  28106. ctx.ajax :
  28107. ctx.sAjaxSource;
  28108. }
  28109. // set
  28110. return this.iterator( 'table', function ( settings ) {
  28111. if ( $.isPlainObject( settings.ajax ) ) {
  28112. settings.ajax.url = url;
  28113. }
  28114. else {
  28115. settings.ajax = url;
  28116. }
  28117. // No need to consider sAjaxSource here since DataTables gives priority
  28118. // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
  28119. // value of `sAjaxSource` redundant.
  28120. } );
  28121. } );
  28122. /**
  28123. * Load data from the newly set Ajax URL. Note that this method is only
  28124. * available when `ajax.url()` is used to set a URL. Additionally, this method
  28125. * has the same effect as calling `ajax.reload()` but is provided for
  28126. * convenience when setting a new URL. Like `ajax.reload()` it will
  28127. * automatically redraw the table once the remote data has been loaded.
  28128. *
  28129. * @returns {DataTables.Api} this
  28130. */
  28131. _api_register( 'ajax.url().load()', function ( callback, resetPaging ) {
  28132. // Same as a reload, but makes sense to present it for easy access after a
  28133. // url change
  28134. return this.iterator( 'table', function ( ctx ) {
  28135. __reload( ctx, resetPaging===false, callback );
  28136. } );
  28137. } );
  28138. var _selector_run = function ( type, selector, selectFn, settings, opts )
  28139. {
  28140. var
  28141. out = [], res,
  28142. a, i, ien, j, jen,
  28143. selectorType = typeof selector;
  28144. // Can't just check for isArray here, as an API or jQuery instance might be
  28145. // given with their array like look
  28146. if ( ! selector || selectorType === 'string' || selectorType === 'function' || selector.length === undefined ) {
  28147. selector = [ selector ];
  28148. }
  28149. for ( i=0, ien=selector.length ; i<ien ; i++ ) {
  28150. a = selector[i] && selector[i].split ?
  28151. selector[i].split(',') :
  28152. [ selector[i] ];
  28153. for ( j=0, jen=a.length ; j<jen ; j++ ) {
  28154. res = selectFn( typeof a[j] === 'string' ? $.trim(a[j]) : a[j] );
  28155. if ( res && res.length ) {
  28156. out = out.concat( res );
  28157. }
  28158. }
  28159. }
  28160. // selector extensions
  28161. var ext = _ext.selector[ type ];
  28162. if ( ext.length ) {
  28163. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  28164. out = ext[i]( settings, opts, out );
  28165. }
  28166. }
  28167. return _unique( out );
  28168. };
  28169. var _selector_opts = function ( opts )
  28170. {
  28171. if ( ! opts ) {
  28172. opts = {};
  28173. }
  28174. // Backwards compatibility for 1.9- which used the terminology filter rather
  28175. // than search
  28176. if ( opts.filter && opts.search === undefined ) {
  28177. opts.search = opts.filter;
  28178. }
  28179. return $.extend( {
  28180. search: 'none',
  28181. order: 'current',
  28182. page: 'all'
  28183. }, opts );
  28184. };
  28185. var _selector_first = function ( inst )
  28186. {
  28187. // Reduce the API instance to the first item found
  28188. for ( var i=0, ien=inst.length ; i<ien ; i++ ) {
  28189. if ( inst[i].length > 0 ) {
  28190. // Assign the first element to the first item in the instance
  28191. // and truncate the instance and context
  28192. inst[0] = inst[i];
  28193. inst[0].length = 1;
  28194. inst.length = 1;
  28195. inst.context = [ inst.context[i] ];
  28196. return inst;
  28197. }
  28198. }
  28199. // Not found - return an empty instance
  28200. inst.length = 0;
  28201. return inst;
  28202. };
  28203. var _selector_row_indexes = function ( settings, opts )
  28204. {
  28205. var
  28206. i, ien, tmp, a=[],
  28207. displayFiltered = settings.aiDisplay,
  28208. displayMaster = settings.aiDisplayMaster;
  28209. var
  28210. search = opts.search, // none, applied, removed
  28211. order = opts.order, // applied, current, index (original - compatibility with 1.9)
  28212. page = opts.page; // all, current
  28213. if ( _fnDataSource( settings ) == 'ssp' ) {
  28214. // In server-side processing mode, most options are irrelevant since
  28215. // rows not shown don't exist and the index order is the applied order
  28216. // Removed is a special case - for consistency just return an empty
  28217. // array
  28218. return search === 'removed' ?
  28219. [] :
  28220. _range( 0, displayMaster.length );
  28221. }
  28222. else if ( page == 'current' ) {
  28223. // Current page implies that order=current and fitler=applied, since it is
  28224. // fairly senseless otherwise, regardless of what order and search actually
  28225. // are
  28226. for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
  28227. a.push( displayFiltered[i] );
  28228. }
  28229. }
  28230. else if ( order == 'current' || order == 'applied' ) {
  28231. a = search == 'none' ?
  28232. displayMaster.slice() : // no search
  28233. search == 'applied' ?
  28234. displayFiltered.slice() : // applied search
  28235. $.map( displayMaster, function (el, i) { // removed search
  28236. return $.inArray( el, displayFiltered ) === -1 ? el : null;
  28237. } );
  28238. }
  28239. else if ( order == 'index' || order == 'original' ) {
  28240. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  28241. if ( search == 'none' ) {
  28242. a.push( i );
  28243. }
  28244. else { // applied | removed
  28245. tmp = $.inArray( i, displayFiltered );
  28246. if ((tmp === -1 && search == 'removed') ||
  28247. (tmp >= 0 && search == 'applied') )
  28248. {
  28249. a.push( i );
  28250. }
  28251. }
  28252. }
  28253. }
  28254. return a;
  28255. };
  28256. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  28257. * Rows
  28258. *
  28259. * {} - no selector - use all available rows
  28260. * {integer} - row aoData index
  28261. * {node} - TR node
  28262. * {string} - jQuery selector to apply to the TR elements
  28263. * {array} - jQuery array of nodes, or simply an array of TR nodes
  28264. *
  28265. */
  28266. var __row_selector = function ( settings, selector, opts )
  28267. {
  28268. var run = function ( sel ) {
  28269. var selInt = _intVal( sel );
  28270. var i, ien;
  28271. // Short cut - selector is a number and no options provided (default is
  28272. // all records, so no need to check if the index is in there, since it
  28273. // must be - dev error if the index doesn't exist).
  28274. if ( selInt !== null && ! opts ) {
  28275. return [ selInt ];
  28276. }
  28277. var rows = _selector_row_indexes( settings, opts );
  28278. if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
  28279. // Selector - integer
  28280. return [ selInt ];
  28281. }
  28282. else if ( ! sel ) {
  28283. // Selector - none
  28284. return rows;
  28285. }
  28286. // Selector - function
  28287. if ( typeof sel === 'function' ) {
  28288. return $.map( rows, function (idx) {
  28289. var row = settings.aoData[ idx ];
  28290. return sel( idx, row._aData, row.nTr ) ? idx : null;
  28291. } );
  28292. }
  28293. // Get nodes in the order from the `rows` array with null values removed
  28294. var nodes = _removeEmpty(
  28295. _pluck_order( settings.aoData, rows, 'nTr' )
  28296. );
  28297. // Selector - node
  28298. if ( sel.nodeName ) {
  28299. if ( sel._DT_RowIndex !== undefined ) {
  28300. return [ sel._DT_RowIndex ]; // Property added by DT for fast lookup
  28301. }
  28302. else if ( sel._DT_CellIndex ) {
  28303. return [ sel._DT_CellIndex.row ];
  28304. }
  28305. else {
  28306. var host = $(sel).closest('*[data-dt-row]');
  28307. return host.length ?
  28308. [ host.data('dt-row') ] :
  28309. [];
  28310. }
  28311. }
  28312. // ID selector. Want to always be able to select rows by id, regardless
  28313. // of if the tr element has been created or not, so can't rely upon
  28314. // jQuery here - hence a custom implementation. This does not match
  28315. // Sizzle's fast selector or HTML4 - in HTML5 the ID can be anything,
  28316. // but to select it using a CSS selector engine (like Sizzle or
  28317. // querySelect) it would need to need to be escaped for some characters.
  28318. // DataTables simplifies this for row selectors since you can select
  28319. // only a row. A # indicates an id any anything that follows is the id -
  28320. // unescaped.
  28321. if ( typeof sel === 'string' && sel.charAt(0) === '#' ) {
  28322. // get row index from id
  28323. var rowObj = settings.aIds[ sel.replace( /^#/, '' ) ];
  28324. if ( rowObj !== undefined ) {
  28325. return [ rowObj.idx ];
  28326. }
  28327. // need to fall through to jQuery in case there is DOM id that
  28328. // matches
  28329. }
  28330. // Selector - jQuery selector string, array of nodes or jQuery object/
  28331. // As jQuery's .filter() allows jQuery objects to be passed in filter,
  28332. // it also allows arrays, so this will cope with all three options
  28333. return $(nodes)
  28334. .filter( sel )
  28335. .map( function () {
  28336. return this._DT_RowIndex;
  28337. } )
  28338. .toArray();
  28339. };
  28340. return _selector_run( 'row', selector, run, settings, opts );
  28341. };
  28342. _api_register( 'rows()', function ( selector, opts ) {
  28343. // argument shifting
  28344. if ( selector === undefined ) {
  28345. selector = '';
  28346. }
  28347. else if ( $.isPlainObject( selector ) ) {
  28348. opts = selector;
  28349. selector = '';
  28350. }
  28351. opts = _selector_opts( opts );
  28352. var inst = this.iterator( 'table', function ( settings ) {
  28353. return __row_selector( settings, selector, opts );
  28354. }, 1 );
  28355. // Want argument shifting here and in __row_selector?
  28356. inst.selector.rows = selector;
  28357. inst.selector.opts = opts;
  28358. return inst;
  28359. } );
  28360. _api_register( 'rows().nodes()', function () {
  28361. return this.iterator( 'row', function ( settings, row ) {
  28362. return settings.aoData[ row ].nTr || undefined;
  28363. }, 1 );
  28364. } );
  28365. _api_register( 'rows().data()', function () {
  28366. return this.iterator( true, 'rows', function ( settings, rows ) {
  28367. return _pluck_order( settings.aoData, rows, '_aData' );
  28368. }, 1 );
  28369. } );
  28370. _api_registerPlural( 'rows().cache()', 'row().cache()', function ( type ) {
  28371. return this.iterator( 'row', function ( settings, row ) {
  28372. var r = settings.aoData[ row ];
  28373. return type === 'search' ? r._aFilterData : r._aSortData;
  28374. }, 1 );
  28375. } );
  28376. _api_registerPlural( 'rows().invalidate()', 'row().invalidate()', function ( src ) {
  28377. return this.iterator( 'row', function ( settings, row ) {
  28378. _fnInvalidate( settings, row, src );
  28379. } );
  28380. } );
  28381. _api_registerPlural( 'rows().indexes()', 'row().index()', function () {
  28382. return this.iterator( 'row', function ( settings, row ) {
  28383. return row;
  28384. }, 1 );
  28385. } );
  28386. _api_registerPlural( 'rows().ids()', 'row().id()', function ( hash ) {
  28387. var a = [];
  28388. var context = this.context;
  28389. // `iterator` will drop undefined values, but in this case we want them
  28390. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  28391. for ( var j=0, jen=this[i].length ; j<jen ; j++ ) {
  28392. var id = context[i].rowIdFn( context[i].aoData[ this[i][j] ]._aData );
  28393. a.push( (hash === true ? '#' : '' )+ id );
  28394. }
  28395. }
  28396. return new _Api( context, a );
  28397. } );
  28398. _api_registerPlural( 'rows().remove()', 'row().remove()', function () {
  28399. var that = this;
  28400. this.iterator( 'row', function ( settings, row, thatIdx ) {
  28401. var data = settings.aoData;
  28402. var rowData = data[ row ];
  28403. var i, ien, j, jen;
  28404. var loopRow, loopCells;
  28405. data.splice( row, 1 );
  28406. // Update the cached indexes
  28407. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  28408. loopRow = data[i];
  28409. loopCells = loopRow.anCells;
  28410. // Rows
  28411. if ( loopRow.nTr !== null ) {
  28412. loopRow.nTr._DT_RowIndex = i;
  28413. }
  28414. // Cells
  28415. if ( loopCells !== null ) {
  28416. for ( j=0, jen=loopCells.length ; j<jen ; j++ ) {
  28417. loopCells[j]._DT_CellIndex.row = i;
  28418. }
  28419. }
  28420. }
  28421. // Delete from the display arrays
  28422. _fnDeleteIndex( settings.aiDisplayMaster, row );
  28423. _fnDeleteIndex( settings.aiDisplay, row );
  28424. _fnDeleteIndex( that[ thatIdx ], row, false ); // maintain local indexes
  28425. // Check for an 'overflow' they case for displaying the table
  28426. _fnLengthOverflow( settings );
  28427. // Remove the row's ID reference if there is one
  28428. var id = settings.rowIdFn( rowData._aData );
  28429. if ( id !== undefined ) {
  28430. delete settings.aIds[ id ];
  28431. }
  28432. } );
  28433. this.iterator( 'table', function ( settings ) {
  28434. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  28435. settings.aoData[i].idx = i;
  28436. }
  28437. } );
  28438. return this;
  28439. } );
  28440. _api_register( 'rows.add()', function ( rows ) {
  28441. var newRows = this.iterator( 'table', function ( settings ) {
  28442. var row, i, ien;
  28443. var out = [];
  28444. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  28445. row = rows[i];
  28446. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  28447. out.push( _fnAddTr( settings, row )[0] );
  28448. }
  28449. else {
  28450. out.push( _fnAddData( settings, row ) );
  28451. }
  28452. }
  28453. return out;
  28454. }, 1 );
  28455. // Return an Api.rows() extended instance, so rows().nodes() etc can be used
  28456. var modRows = this.rows( -1 );
  28457. modRows.pop();
  28458. $.merge( modRows, newRows );
  28459. return modRows;
  28460. } );
  28461. /**
  28462. *
  28463. */
  28464. _api_register( 'row()', function ( selector, opts ) {
  28465. return _selector_first( this.rows( selector, opts ) );
  28466. } );
  28467. _api_register( 'row().data()', function ( data ) {
  28468. var ctx = this.context;
  28469. if ( data === undefined ) {
  28470. // Get
  28471. return ctx.length && this.length ?
  28472. ctx[0].aoData[ this[0] ]._aData :
  28473. undefined;
  28474. }
  28475. // Set
  28476. ctx[0].aoData[ this[0] ]._aData = data;
  28477. // Automatically invalidate
  28478. _fnInvalidate( ctx[0], this[0], 'data' );
  28479. return this;
  28480. } );
  28481. _api_register( 'row().node()', function () {
  28482. var ctx = this.context;
  28483. return ctx.length && this.length ?
  28484. ctx[0].aoData[ this[0] ].nTr || null :
  28485. null;
  28486. } );
  28487. _api_register( 'row.add()', function ( row ) {
  28488. // Allow a jQuery object to be passed in - only a single row is added from
  28489. // it though - the first element in the set
  28490. if ( row instanceof $ && row.length ) {
  28491. row = row[0];
  28492. }
  28493. var rows = this.iterator( 'table', function ( settings ) {
  28494. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  28495. return _fnAddTr( settings, row )[0];
  28496. }
  28497. return _fnAddData( settings, row );
  28498. } );
  28499. // Return an Api.rows() extended instance, with the newly added row selected
  28500. return this.row( rows[0] );
  28501. } );
  28502. var __details_add = function ( ctx, row, data, klass )
  28503. {
  28504. // Convert to array of TR elements
  28505. var rows = [];
  28506. var addRow = function ( r, k ) {
  28507. // Recursion to allow for arrays of jQuery objects
  28508. if ( $.isArray( r ) || r instanceof $ ) {
  28509. for ( var i=0, ien=r.length ; i<ien ; i++ ) {
  28510. addRow( r[i], k );
  28511. }
  28512. return;
  28513. }
  28514. // If we get a TR element, then just add it directly - up to the dev
  28515. // to add the correct number of columns etc
  28516. if ( r.nodeName && r.nodeName.toLowerCase() === 'tr' ) {
  28517. rows.push( r );
  28518. }
  28519. else {
  28520. // Otherwise create a row with a wrapper
  28521. var created = $('<tr><td/></tr>').addClass( k );
  28522. $('td', created)
  28523. .addClass( k )
  28524. .html( r )
  28525. [0].colSpan = _fnVisbleColumns( ctx );
  28526. rows.push( created[0] );
  28527. }
  28528. };
  28529. addRow( data, klass );
  28530. if ( row._details ) {
  28531. row._details.remove();
  28532. }
  28533. row._details = $(rows);
  28534. // If the children were already shown, that state should be retained
  28535. if ( row._detailsShow ) {
  28536. row._details.insertAfter( row.nTr );
  28537. }
  28538. };
  28539. var __details_remove = function ( api, idx )
  28540. {
  28541. var ctx = api.context;
  28542. if ( ctx.length ) {
  28543. var row = ctx[0].aoData[ idx !== undefined ? idx : api[0] ];
  28544. if ( row && row._details ) {
  28545. row._details.remove();
  28546. row._detailsShow = undefined;
  28547. row._details = undefined;
  28548. }
  28549. }
  28550. };
  28551. var __details_display = function ( api, show ) {
  28552. var ctx = api.context;
  28553. if ( ctx.length && api.length ) {
  28554. var row = ctx[0].aoData[ api[0] ];
  28555. if ( row._details ) {
  28556. row._detailsShow = show;
  28557. if ( show ) {
  28558. row._details.insertAfter( row.nTr );
  28559. }
  28560. else {
  28561. row._details.detach();
  28562. }
  28563. __details_events( ctx[0] );
  28564. }
  28565. }
  28566. };
  28567. var __details_events = function ( settings )
  28568. {
  28569. var api = new _Api( settings );
  28570. var namespace = '.dt.DT_details';
  28571. var drawEvent = 'draw'+namespace;
  28572. var colvisEvent = 'column-visibility'+namespace;
  28573. var destroyEvent = 'destroy'+namespace;
  28574. var data = settings.aoData;
  28575. api.off( drawEvent +' '+ colvisEvent +' '+ destroyEvent );
  28576. if ( _pluck( data, '_details' ).length > 0 ) {
  28577. // On each draw, insert the required elements into the document
  28578. api.on( drawEvent, function ( e, ctx ) {
  28579. if ( settings !== ctx ) {
  28580. return;
  28581. }
  28582. api.rows( {page:'current'} ).eq(0).each( function (idx) {
  28583. // Internal data grab
  28584. var row = data[ idx ];
  28585. if ( row._detailsShow ) {
  28586. row._details.insertAfter( row.nTr );
  28587. }
  28588. } );
  28589. } );
  28590. // Column visibility change - update the colspan
  28591. api.on( colvisEvent, function ( e, ctx, idx, vis ) {
  28592. if ( settings !== ctx ) {
  28593. return;
  28594. }
  28595. // Update the colspan for the details rows (note, only if it already has
  28596. // a colspan)
  28597. var row, visible = _fnVisbleColumns( ctx );
  28598. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  28599. row = data[i];
  28600. if ( row._details ) {
  28601. row._details.children('td[colspan]').attr('colspan', visible );
  28602. }
  28603. }
  28604. } );
  28605. // Table destroyed - nuke any child rows
  28606. api.on( destroyEvent, function ( e, ctx ) {
  28607. if ( settings !== ctx ) {
  28608. return;
  28609. }
  28610. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  28611. if ( data[i]._details ) {
  28612. __details_remove( api, i );
  28613. }
  28614. }
  28615. } );
  28616. }
  28617. };
  28618. // Strings for the method names to help minification
  28619. var _emp = '';
  28620. var _child_obj = _emp+'row().child';
  28621. var _child_mth = _child_obj+'()';
  28622. // data can be:
  28623. // tr
  28624. // string
  28625. // jQuery or array of any of the above
  28626. _api_register( _child_mth, function ( data, klass ) {
  28627. var ctx = this.context;
  28628. if ( data === undefined ) {
  28629. // get
  28630. return ctx.length && this.length ?
  28631. ctx[0].aoData[ this[0] ]._details :
  28632. undefined;
  28633. }
  28634. else if ( data === true ) {
  28635. // show
  28636. this.child.show();
  28637. }
  28638. else if ( data === false ) {
  28639. // remove
  28640. __details_remove( this );
  28641. }
  28642. else if ( ctx.length && this.length ) {
  28643. // set
  28644. __details_add( ctx[0], ctx[0].aoData[ this[0] ], data, klass );
  28645. }
  28646. return this;
  28647. } );
  28648. _api_register( [
  28649. _child_obj+'.show()',
  28650. _child_mth+'.show()' // only when `child()` was called with parameters (without
  28651. ], function ( show ) { // it returns an object and this method is not executed)
  28652. __details_display( this, true );
  28653. return this;
  28654. } );
  28655. _api_register( [
  28656. _child_obj+'.hide()',
  28657. _child_mth+'.hide()' // only when `child()` was called with parameters (without
  28658. ], function () { // it returns an object and this method is not executed)
  28659. __details_display( this, false );
  28660. return this;
  28661. } );
  28662. _api_register( [
  28663. _child_obj+'.remove()',
  28664. _child_mth+'.remove()' // only when `child()` was called with parameters (without
  28665. ], function () { // it returns an object and this method is not executed)
  28666. __details_remove( this );
  28667. return this;
  28668. } );
  28669. _api_register( _child_obj+'.isShown()', function () {
  28670. var ctx = this.context;
  28671. if ( ctx.length && this.length ) {
  28672. // _detailsShown as false or undefined will fall through to return false
  28673. return ctx[0].aoData[ this[0] ]._detailsShow || false;
  28674. }
  28675. return false;
  28676. } );
  28677. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  28678. * Columns
  28679. *
  28680. * {integer} - column index (>=0 count from left, <0 count from right)
  28681. * "{integer}:visIdx" - visible column index (i.e. translate to column index) (>=0 count from left, <0 count from right)
  28682. * "{integer}:visible" - alias for {integer}:visIdx (>=0 count from left, <0 count from right)
  28683. * "{string}:name" - column name
  28684. * "{string}" - jQuery selector on column header nodes
  28685. *
  28686. */
  28687. // can be an array of these items, comma separated list, or an array of comma
  28688. // separated lists
  28689. var __re_column_selector = /^(.+):(name|visIdx|visible)$/;
  28690. // r1 and r2 are redundant - but it means that the parameters match for the
  28691. // iterator callback in columns().data()
  28692. var __columnData = function ( settings, column, r1, r2, rows ) {
  28693. var a = [];
  28694. for ( var row=0, ien=rows.length ; row<ien ; row++ ) {
  28695. a.push( _fnGetCellData( settings, rows[row], column ) );
  28696. }
  28697. return a;
  28698. };
  28699. var __column_selector = function ( settings, selector, opts )
  28700. {
  28701. var
  28702. columns = settings.aoColumns,
  28703. names = _pluck( columns, 'sName' ),
  28704. nodes = _pluck( columns, 'nTh' );
  28705. var run = function ( s ) {
  28706. var selInt = _intVal( s );
  28707. // Selector - all
  28708. if ( s === '' ) {
  28709. return _range( columns.length );
  28710. }
  28711. // Selector - index
  28712. if ( selInt !== null ) {
  28713. return [ selInt >= 0 ?
  28714. selInt : // Count from left
  28715. columns.length + selInt // Count from right (+ because its a negative value)
  28716. ];
  28717. }
  28718. // Selector = function
  28719. if ( typeof s === 'function' ) {
  28720. var rows = _selector_row_indexes( settings, opts );
  28721. return $.map( columns, function (col, idx) {
  28722. return s(
  28723. idx,
  28724. __columnData( settings, idx, 0, 0, rows ),
  28725. nodes[ idx ]
  28726. ) ? idx : null;
  28727. } );
  28728. }
  28729. // jQuery or string selector
  28730. var match = typeof s === 'string' ?
  28731. s.match( __re_column_selector ) :
  28732. '';
  28733. if ( match ) {
  28734. switch( match[2] ) {
  28735. case 'visIdx':
  28736. case 'visible':
  28737. var idx = parseInt( match[1], 10 );
  28738. // Visible index given, convert to column index
  28739. if ( idx < 0 ) {
  28740. // Counting from the right
  28741. var visColumns = $.map( columns, function (col,i) {
  28742. return col.bVisible ? i : null;
  28743. } );
  28744. return [ visColumns[ visColumns.length + idx ] ];
  28745. }
  28746. // Counting from the left
  28747. return [ _fnVisibleToColumnIndex( settings, idx ) ];
  28748. case 'name':
  28749. // match by name. `names` is column index complete and in order
  28750. return $.map( names, function (name, i) {
  28751. return name === match[1] ? i : null;
  28752. } );
  28753. default:
  28754. return [];
  28755. }
  28756. }
  28757. // Cell in the table body
  28758. if ( s.nodeName && s._DT_CellIndex ) {
  28759. return [ s._DT_CellIndex.column ];
  28760. }
  28761. // jQuery selector on the TH elements for the columns
  28762. var jqResult = $( nodes )
  28763. .filter( s )
  28764. .map( function () {
  28765. return $.inArray( this, nodes ); // `nodes` is column index complete and in order
  28766. } )
  28767. .toArray();
  28768. if ( jqResult.length || ! s.nodeName ) {
  28769. return jqResult;
  28770. }
  28771. // Otherwise a node which might have a `dt-column` data attribute, or be
  28772. // a child or such an element
  28773. var host = $(s).closest('*[data-dt-column]');
  28774. return host.length ?
  28775. [ host.data('dt-column') ] :
  28776. [];
  28777. };
  28778. return _selector_run( 'column', selector, run, settings, opts );
  28779. };
  28780. var __setColumnVis = function ( settings, column, vis ) {
  28781. var
  28782. cols = settings.aoColumns,
  28783. col = cols[ column ],
  28784. data = settings.aoData,
  28785. row, cells, i, ien, tr;
  28786. // Get
  28787. if ( vis === undefined ) {
  28788. return col.bVisible;
  28789. }
  28790. // Set
  28791. // No change
  28792. if ( col.bVisible === vis ) {
  28793. return;
  28794. }
  28795. if ( vis ) {
  28796. // Insert column
  28797. // Need to decide if we should use appendChild or insertBefore
  28798. var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 );
  28799. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  28800. tr = data[i].nTr;
  28801. cells = data[i].anCells;
  28802. if ( tr ) {
  28803. // insertBefore can act like appendChild if 2nd arg is null
  28804. tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );
  28805. }
  28806. }
  28807. }
  28808. else {
  28809. // Remove column
  28810. $( _pluck( settings.aoData, 'anCells', column ) ).detach();
  28811. }
  28812. // Common actions
  28813. col.bVisible = vis;
  28814. _fnDrawHead( settings, settings.aoHeader );
  28815. _fnDrawHead( settings, settings.aoFooter );
  28816. _fnSaveState( settings );
  28817. };
  28818. _api_register( 'columns()', function ( selector, opts ) {
  28819. // argument shifting
  28820. if ( selector === undefined ) {
  28821. selector = '';
  28822. }
  28823. else if ( $.isPlainObject( selector ) ) {
  28824. opts = selector;
  28825. selector = '';
  28826. }
  28827. opts = _selector_opts( opts );
  28828. var inst = this.iterator( 'table', function ( settings ) {
  28829. return __column_selector( settings, selector, opts );
  28830. }, 1 );
  28831. // Want argument shifting here and in _row_selector?
  28832. inst.selector.cols = selector;
  28833. inst.selector.opts = opts;
  28834. return inst;
  28835. } );
  28836. _api_registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) {
  28837. return this.iterator( 'column', function ( settings, column ) {
  28838. return settings.aoColumns[column].nTh;
  28839. }, 1 );
  28840. } );
  28841. _api_registerPlural( 'columns().footer()', 'column().footer()', function ( selector, opts ) {
  28842. return this.iterator( 'column', function ( settings, column ) {
  28843. return settings.aoColumns[column].nTf;
  28844. }, 1 );
  28845. } );
  28846. _api_registerPlural( 'columns().data()', 'column().data()', function () {
  28847. return this.iterator( 'column-rows', __columnData, 1 );
  28848. } );
  28849. _api_registerPlural( 'columns().dataSrc()', 'column().dataSrc()', function () {
  28850. return this.iterator( 'column', function ( settings, column ) {
  28851. return settings.aoColumns[column].mData;
  28852. }, 1 );
  28853. } );
  28854. _api_registerPlural( 'columns().cache()', 'column().cache()', function ( type ) {
  28855. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  28856. return _pluck_order( settings.aoData, rows,
  28857. type === 'search' ? '_aFilterData' : '_aSortData', column
  28858. );
  28859. }, 1 );
  28860. } );
  28861. _api_registerPlural( 'columns().nodes()', 'column().nodes()', function () {
  28862. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  28863. return _pluck_order( settings.aoData, rows, 'anCells', column ) ;
  28864. }, 1 );
  28865. } );
  28866. _api_registerPlural( 'columns().visible()', 'column().visible()', function ( vis, calc ) {
  28867. var ret = this.iterator( 'column', function ( settings, column ) {
  28868. if ( vis === undefined ) {
  28869. return settings.aoColumns[ column ].bVisible;
  28870. } // else
  28871. __setColumnVis( settings, column, vis );
  28872. } );
  28873. // Group the column visibility changes
  28874. if ( vis !== undefined ) {
  28875. // Second loop once the first is done for events
  28876. this.iterator( 'column', function ( settings, column ) {
  28877. _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis, calc] );
  28878. } );
  28879. if ( calc === undefined || calc ) {
  28880. this.columns.adjust();
  28881. }
  28882. }
  28883. return ret;
  28884. } );
  28885. _api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
  28886. return this.iterator( 'column', function ( settings, column ) {
  28887. return type === 'visible' ?
  28888. _fnColumnIndexToVisible( settings, column ) :
  28889. column;
  28890. }, 1 );
  28891. } );
  28892. _api_register( 'columns.adjust()', function () {
  28893. return this.iterator( 'table', function ( settings ) {
  28894. _fnAdjustColumnSizing( settings );
  28895. }, 1 );
  28896. } );
  28897. _api_register( 'column.index()', function ( type, idx ) {
  28898. if ( this.context.length !== 0 ) {
  28899. var ctx = this.context[0];
  28900. if ( type === 'fromVisible' || type === 'toData' ) {
  28901. return _fnVisibleToColumnIndex( ctx, idx );
  28902. }
  28903. else if ( type === 'fromData' || type === 'toVisible' ) {
  28904. return _fnColumnIndexToVisible( ctx, idx );
  28905. }
  28906. }
  28907. } );
  28908. _api_register( 'column()', function ( selector, opts ) {
  28909. return _selector_first( this.columns( selector, opts ) );
  28910. } );
  28911. var __cell_selector = function ( settings, selector, opts )
  28912. {
  28913. var data = settings.aoData;
  28914. var rows = _selector_row_indexes( settings, opts );
  28915. var cells = _removeEmpty( _pluck_order( data, rows, 'anCells' ) );
  28916. var allCells = $( [].concat.apply([], cells) );
  28917. var row;
  28918. var columns = settings.aoColumns.length;
  28919. var a, i, ien, j, o, host;
  28920. var run = function ( s ) {
  28921. var fnSelector = typeof s === 'function';
  28922. if ( s === null || s === undefined || fnSelector ) {
  28923. // All cells and function selectors
  28924. a = [];
  28925. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  28926. row = rows[i];
  28927. for ( j=0 ; j<columns ; j++ ) {
  28928. o = {
  28929. row: row,
  28930. column: j
  28931. };
  28932. if ( fnSelector ) {
  28933. // Selector - function
  28934. host = data[ row ];
  28935. if ( s( o, _fnGetCellData(settings, row, j), host.anCells ? host.anCells[j] : null ) ) {
  28936. a.push( o );
  28937. }
  28938. }
  28939. else {
  28940. // Selector - all
  28941. a.push( o );
  28942. }
  28943. }
  28944. }
  28945. return a;
  28946. }
  28947. // Selector - index
  28948. if ( $.isPlainObject( s ) ) {
  28949. return [s];
  28950. }
  28951. // Selector - jQuery filtered cells
  28952. var jqResult = allCells
  28953. .filter( s )
  28954. .map( function (i, el) {
  28955. return { // use a new object, in case someone changes the values
  28956. row: el._DT_CellIndex.row,
  28957. column: el._DT_CellIndex.column
  28958. };
  28959. } )
  28960. .toArray();
  28961. if ( jqResult.length || ! s.nodeName ) {
  28962. return jqResult;
  28963. }
  28964. // Otherwise the selector is a node, and there is one last option - the
  28965. // element might be a child of an element which has dt-row and dt-column
  28966. // data attributes
  28967. host = $(s).closest('*[data-dt-row]');
  28968. return host.length ?
  28969. [ {
  28970. row: host.data('dt-row'),
  28971. column: host.data('dt-column')
  28972. } ] :
  28973. [];
  28974. };
  28975. return _selector_run( 'cell', selector, run, settings, opts );
  28976. };
  28977. _api_register( 'cells()', function ( rowSelector, columnSelector, opts ) {
  28978. // Argument shifting
  28979. if ( $.isPlainObject( rowSelector ) ) {
  28980. // Indexes
  28981. if ( rowSelector.row === undefined ) {
  28982. // Selector options in first parameter
  28983. opts = rowSelector;
  28984. rowSelector = null;
  28985. }
  28986. else {
  28987. // Cell index objects in first parameter
  28988. opts = columnSelector;
  28989. columnSelector = null;
  28990. }
  28991. }
  28992. if ( $.isPlainObject( columnSelector ) ) {
  28993. opts = columnSelector;
  28994. columnSelector = null;
  28995. }
  28996. // Cell selector
  28997. if ( columnSelector === null || columnSelector === undefined ) {
  28998. return this.iterator( 'table', function ( settings ) {
  28999. return __cell_selector( settings, rowSelector, _selector_opts( opts ) );
  29000. } );
  29001. }
  29002. // Row + column selector
  29003. var columns = this.columns( columnSelector, opts );
  29004. var rows = this.rows( rowSelector, opts );
  29005. var a, i, ien, j, jen;
  29006. var cells = this.iterator( 'table', function ( settings, idx ) {
  29007. a = [];
  29008. for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
  29009. for ( j=0, jen=columns[idx].length ; j<jen ; j++ ) {
  29010. a.push( {
  29011. row: rows[idx][i],
  29012. column: columns[idx][j]
  29013. } );
  29014. }
  29015. }
  29016. return a;
  29017. }, 1 );
  29018. $.extend( cells.selector, {
  29019. cols: columnSelector,
  29020. rows: rowSelector,
  29021. opts: opts
  29022. } );
  29023. return cells;
  29024. } );
  29025. _api_registerPlural( 'cells().nodes()', 'cell().node()', function () {
  29026. return this.iterator( 'cell', function ( settings, row, column ) {
  29027. var data = settings.aoData[ row ];
  29028. return data && data.anCells ?
  29029. data.anCells[ column ] :
  29030. undefined;
  29031. }, 1 );
  29032. } );
  29033. _api_register( 'cells().data()', function () {
  29034. return this.iterator( 'cell', function ( settings, row, column ) {
  29035. return _fnGetCellData( settings, row, column );
  29036. }, 1 );
  29037. } );
  29038. _api_registerPlural( 'cells().cache()', 'cell().cache()', function ( type ) {
  29039. type = type === 'search' ? '_aFilterData' : '_aSortData';
  29040. return this.iterator( 'cell', function ( settings, row, column ) {
  29041. return settings.aoData[ row ][ type ][ column ];
  29042. }, 1 );
  29043. } );
  29044. _api_registerPlural( 'cells().render()', 'cell().render()', function ( type ) {
  29045. return this.iterator( 'cell', function ( settings, row, column ) {
  29046. return _fnGetCellData( settings, row, column, type );
  29047. }, 1 );
  29048. } );
  29049. _api_registerPlural( 'cells().indexes()', 'cell().index()', function () {
  29050. return this.iterator( 'cell', function ( settings, row, column ) {
  29051. return {
  29052. row: row,
  29053. column: column,
  29054. columnVisible: _fnColumnIndexToVisible( settings, column )
  29055. };
  29056. }, 1 );
  29057. } );
  29058. _api_registerPlural( 'cells().invalidate()', 'cell().invalidate()', function ( src ) {
  29059. return this.iterator( 'cell', function ( settings, row, column ) {
  29060. _fnInvalidate( settings, row, src, column );
  29061. } );
  29062. } );
  29063. _api_register( 'cell()', function ( rowSelector, columnSelector, opts ) {
  29064. return _selector_first( this.cells( rowSelector, columnSelector, opts ) );
  29065. } );
  29066. _api_register( 'cell().data()', function ( data ) {
  29067. var ctx = this.context;
  29068. var cell = this[0];
  29069. if ( data === undefined ) {
  29070. // Get
  29071. return ctx.length && cell.length ?
  29072. _fnGetCellData( ctx[0], cell[0].row, cell[0].column ) :
  29073. undefined;
  29074. }
  29075. // Set
  29076. _fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );
  29077. _fnInvalidate( ctx[0], cell[0].row, 'data', cell[0].column );
  29078. return this;
  29079. } );
  29080. /**
  29081. * Get current ordering (sorting) that has been applied to the table.
  29082. *
  29083. * @returns {array} 2D array containing the sorting information for the first
  29084. * table in the current context. Each element in the parent array represents
  29085. * a column being sorted upon (i.e. multi-sorting with two columns would have
  29086. * 2 inner arrays). The inner arrays may have 2 or 3 elements. The first is
  29087. * the column index that the sorting condition applies to, the second is the
  29088. * direction of the sort (`desc` or `asc`) and, optionally, the third is the
  29089. * index of the sorting order from the `column.sorting` initialisation array.
  29090. *//**
  29091. * Set the ordering for the table.
  29092. *
  29093. * @param {integer} order Column index to sort upon.
  29094. * @param {string} direction Direction of the sort to be applied (`asc` or `desc`)
  29095. * @returns {DataTables.Api} this
  29096. *//**
  29097. * Set the ordering for the table.
  29098. *
  29099. * @param {array} order 1D array of sorting information to be applied.
  29100. * @param {array} [...] Optional additional sorting conditions
  29101. * @returns {DataTables.Api} this
  29102. *//**
  29103. * Set the ordering for the table.
  29104. *
  29105. * @param {array} order 2D array of sorting information to be applied.
  29106. * @returns {DataTables.Api} this
  29107. */
  29108. _api_register( 'order()', function ( order, dir ) {
  29109. var ctx = this.context;
  29110. if ( order === undefined ) {
  29111. // get
  29112. return ctx.length !== 0 ?
  29113. ctx[0].aaSorting :
  29114. undefined;
  29115. }
  29116. // set
  29117. if ( typeof order === 'number' ) {
  29118. // Simple column / direction passed in
  29119. order = [ [ order, dir ] ];
  29120. }
  29121. else if ( order.length && ! $.isArray( order[0] ) ) {
  29122. // Arguments passed in (list of 1D arrays)
  29123. order = Array.prototype.slice.call( arguments );
  29124. }
  29125. // otherwise a 2D array was passed in
  29126. return this.iterator( 'table', function ( settings ) {
  29127. settings.aaSorting = order.slice();
  29128. } );
  29129. } );
  29130. /**
  29131. * Attach a sort listener to an element for a given column
  29132. *
  29133. * @param {node|jQuery|string} node Identifier for the element(s) to attach the
  29134. * listener to. This can take the form of a single DOM node, a jQuery
  29135. * collection of nodes or a jQuery selector which will identify the node(s).
  29136. * @param {integer} column the column that a click on this node will sort on
  29137. * @param {function} [callback] callback function when sort is run
  29138. * @returns {DataTables.Api} this
  29139. */
  29140. _api_register( 'order.listener()', function ( node, column, callback ) {
  29141. return this.iterator( 'table', function ( settings ) {
  29142. _fnSortAttachListener( settings, node, column, callback );
  29143. } );
  29144. } );
  29145. _api_register( 'order.fixed()', function ( set ) {
  29146. if ( ! set ) {
  29147. var ctx = this.context;
  29148. var fixed = ctx.length ?
  29149. ctx[0].aaSortingFixed :
  29150. undefined;
  29151. return $.isArray( fixed ) ?
  29152. { pre: fixed } :
  29153. fixed;
  29154. }
  29155. return this.iterator( 'table', function ( settings ) {
  29156. settings.aaSortingFixed = $.extend( true, {}, set );
  29157. } );
  29158. } );
  29159. // Order by the selected column(s)
  29160. _api_register( [
  29161. 'columns().order()',
  29162. 'column().order()'
  29163. ], function ( dir ) {
  29164. var that = this;
  29165. return this.iterator( 'table', function ( settings, i ) {
  29166. var sort = [];
  29167. $.each( that[i], function (j, col) {
  29168. sort.push( [ col, dir ] );
  29169. } );
  29170. settings.aaSorting = sort;
  29171. } );
  29172. } );
  29173. _api_register( 'search()', function ( input, regex, smart, caseInsen ) {
  29174. var ctx = this.context;
  29175. if ( input === undefined ) {
  29176. // get
  29177. return ctx.length !== 0 ?
  29178. ctx[0].oPreviousSearch.sSearch :
  29179. undefined;
  29180. }
  29181. // set
  29182. return this.iterator( 'table', function ( settings ) {
  29183. if ( ! settings.oFeatures.bFilter ) {
  29184. return;
  29185. }
  29186. _fnFilterComplete( settings, $.extend( {}, settings.oPreviousSearch, {
  29187. "sSearch": input+"",
  29188. "bRegex": regex === null ? false : regex,
  29189. "bSmart": smart === null ? true : smart,
  29190. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  29191. } ), 1 );
  29192. } );
  29193. } );
  29194. _api_registerPlural(
  29195. 'columns().search()',
  29196. 'column().search()',
  29197. function ( input, regex, smart, caseInsen ) {
  29198. return this.iterator( 'column', function ( settings, column ) {
  29199. var preSearch = settings.aoPreSearchCols;
  29200. if ( input === undefined ) {
  29201. // get
  29202. return preSearch[ column ].sSearch;
  29203. }
  29204. // set
  29205. if ( ! settings.oFeatures.bFilter ) {
  29206. return;
  29207. }
  29208. $.extend( preSearch[ column ], {
  29209. "sSearch": input+"",
  29210. "bRegex": regex === null ? false : regex,
  29211. "bSmart": smart === null ? true : smart,
  29212. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  29213. } );
  29214. _fnFilterComplete( settings, settings.oPreviousSearch, 1 );
  29215. } );
  29216. }
  29217. );
  29218. /*
  29219. * State API methods
  29220. */
  29221. _api_register( 'state()', function () {
  29222. return this.context.length ?
  29223. this.context[0].oSavedState :
  29224. null;
  29225. } );
  29226. _api_register( 'state.clear()', function () {
  29227. return this.iterator( 'table', function ( settings ) {
  29228. // Save an empty object
  29229. settings.fnStateSaveCallback.call( settings.oInstance, settings, {} );
  29230. } );
  29231. } );
  29232. _api_register( 'state.loaded()', function () {
  29233. return this.context.length ?
  29234. this.context[0].oLoadedState :
  29235. null;
  29236. } );
  29237. _api_register( 'state.save()', function () {
  29238. return this.iterator( 'table', function ( settings ) {
  29239. _fnSaveState( settings );
  29240. } );
  29241. } );
  29242. /**
  29243. * Provide a common method for plug-ins to check the version of DataTables being
  29244. * used, in order to ensure compatibility.
  29245. *
  29246. * @param {string} version Version string to check for, in the format "X.Y.Z".
  29247. * Note that the formats "X" and "X.Y" are also acceptable.
  29248. * @returns {boolean} true if this version of DataTables is greater or equal to
  29249. * the required version, or false if this version of DataTales is not
  29250. * suitable
  29251. * @static
  29252. * @dtopt API-Static
  29253. *
  29254. * @example
  29255. * alert( $.fn.dataTable.versionCheck( '1.9.0' ) );
  29256. */
  29257. DataTable.versionCheck = DataTable.fnVersionCheck = function( version )
  29258. {
  29259. var aThis = DataTable.version.split('.');
  29260. var aThat = version.split('.');
  29261. var iThis, iThat;
  29262. for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ) {
  29263. iThis = parseInt( aThis[i], 10 ) || 0;
  29264. iThat = parseInt( aThat[i], 10 ) || 0;
  29265. // Parts are the same, keep comparing
  29266. if (iThis === iThat) {
  29267. continue;
  29268. }
  29269. // Parts are different, return immediately
  29270. return iThis > iThat;
  29271. }
  29272. return true;
  29273. };
  29274. /**
  29275. * Check if a `<table>` node is a DataTable table already or not.
  29276. *
  29277. * @param {node|jquery|string} table Table node, jQuery object or jQuery
  29278. * selector for the table to test. Note that if more than more than one
  29279. * table is passed on, only the first will be checked
  29280. * @returns {boolean} true the table given is a DataTable, or false otherwise
  29281. * @static
  29282. * @dtopt API-Static
  29283. *
  29284. * @example
  29285. * if ( ! $.fn.DataTable.isDataTable( '#example' ) ) {
  29286. * $('#example').dataTable();
  29287. * }
  29288. */
  29289. DataTable.isDataTable = DataTable.fnIsDataTable = function ( table )
  29290. {
  29291. var t = $(table).get(0);
  29292. var is = false;
  29293. $.each( DataTable.settings, function (i, o) {
  29294. var head = o.nScrollHead ? $('table', o.nScrollHead)[0] : null;
  29295. var foot = o.nScrollFoot ? $('table', o.nScrollFoot)[0] : null;
  29296. if ( o.nTable === t || head === t || foot === t ) {
  29297. is = true;
  29298. }
  29299. } );
  29300. return is;
  29301. };
  29302. /**
  29303. * Get all DataTable tables that have been initialised - optionally you can
  29304. * select to get only currently visible tables.
  29305. *
  29306. * @param {boolean} [visible=false] Flag to indicate if you want all (default)
  29307. * or visible tables only.
  29308. * @returns {array} Array of `table` nodes (not DataTable instances) which are
  29309. * DataTables
  29310. * @static
  29311. * @dtopt API-Static
  29312. *
  29313. * @example
  29314. * $.each( $.fn.dataTable.tables(true), function () {
  29315. * $(table).DataTable().columns.adjust();
  29316. * } );
  29317. */
  29318. DataTable.tables = DataTable.fnTables = function ( visible )
  29319. {
  29320. var api = false;
  29321. if ( $.isPlainObject( visible ) ) {
  29322. api = visible.api;
  29323. visible = visible.visible;
  29324. }
  29325. var a = $.map( DataTable.settings, function (o) {
  29326. if ( !visible || (visible && $(o.nTable).is(':visible')) ) {
  29327. return o.nTable;
  29328. }
  29329. } );
  29330. return api ?
  29331. new _Api( a ) :
  29332. a;
  29333. };
  29334. /**
  29335. * Convert from camel case parameters to Hungarian notation. This is made public
  29336. * for the extensions to provide the same ability as DataTables core to accept
  29337. * either the 1.9 style Hungarian notation, or the 1.10+ style camelCase
  29338. * parameters.
  29339. *
  29340. * @param {object} src The model object which holds all parameters that can be
  29341. * mapped.
  29342. * @param {object} user The object to convert from camel case to Hungarian.
  29343. * @param {boolean} force When set to `true`, properties which already have a
  29344. * Hungarian value in the `user` object will be overwritten. Otherwise they
  29345. * won't be.
  29346. */
  29347. DataTable.camelToHungarian = _fnCamelToHungarian;
  29348. /**
  29349. *
  29350. */
  29351. _api_register( '$()', function ( selector, opts ) {
  29352. var
  29353. rows = this.rows( opts ).nodes(), // Get all rows
  29354. jqRows = $(rows);
  29355. return $( [].concat(
  29356. jqRows.filter( selector ).toArray(),
  29357. jqRows.find( selector ).toArray()
  29358. ) );
  29359. } );
  29360. // jQuery functions to operate on the tables
  29361. $.each( [ 'on', 'one', 'off' ], function (i, key) {
  29362. _api_register( key+'()', function ( /* event, handler */ ) {
  29363. var args = Array.prototype.slice.call(arguments);
  29364. // Add the `dt` namespace automatically if it isn't already present
  29365. if ( ! args[0].match(/\.dt\b/) ) {
  29366. args[0] += '.dt';
  29367. }
  29368. var inst = $( this.tables().nodes() );
  29369. inst[key].apply( inst, args );
  29370. return this;
  29371. } );
  29372. } );
  29373. _api_register( 'clear()', function () {
  29374. return this.iterator( 'table', function ( settings ) {
  29375. _fnClearTable( settings );
  29376. } );
  29377. } );
  29378. _api_register( 'settings()', function () {
  29379. return new _Api( this.context, this.context );
  29380. } );
  29381. _api_register( 'init()', function () {
  29382. var ctx = this.context;
  29383. return ctx.length ? ctx[0].oInit : null;
  29384. } );
  29385. _api_register( 'data()', function () {
  29386. return this.iterator( 'table', function ( settings ) {
  29387. return _pluck( settings.aoData, '_aData' );
  29388. } ).flatten();
  29389. } );
  29390. _api_register( 'destroy()', function ( remove ) {
  29391. remove = remove || false;
  29392. return this.iterator( 'table', function ( settings ) {
  29393. var orig = settings.nTableWrapper.parentNode;
  29394. var classes = settings.oClasses;
  29395. var table = settings.nTable;
  29396. var tbody = settings.nTBody;
  29397. var thead = settings.nTHead;
  29398. var tfoot = settings.nTFoot;
  29399. var jqTable = $(table);
  29400. var jqTbody = $(tbody);
  29401. var jqWrapper = $(settings.nTableWrapper);
  29402. var rows = $.map( settings.aoData, function (r) { return r.nTr; } );
  29403. var i, ien;
  29404. // Flag to note that the table is currently being destroyed - no action
  29405. // should be taken
  29406. settings.bDestroying = true;
  29407. // Fire off the destroy callbacks for plug-ins etc
  29408. _fnCallbackFire( settings, "aoDestroyCallback", "destroy", [settings] );
  29409. // If not being removed from the document, make all columns visible
  29410. if ( ! remove ) {
  29411. new _Api( settings ).columns().visible( true );
  29412. }
  29413. // Blitz all `DT` namespaced events (these are internal events, the
  29414. // lowercase, `dt` events are user subscribed and they are responsible
  29415. // for removing them
  29416. jqWrapper.unbind('.DT').find(':not(tbody *)').unbind('.DT');
  29417. $(window).unbind('.DT-'+settings.sInstance);
  29418. // When scrolling we had to break the table up - restore it
  29419. if ( table != thead.parentNode ) {
  29420. jqTable.children('thead').detach();
  29421. jqTable.append( thead );
  29422. }
  29423. if ( tfoot && table != tfoot.parentNode ) {
  29424. jqTable.children('tfoot').detach();
  29425. jqTable.append( tfoot );
  29426. }
  29427. settings.aaSorting = [];
  29428. settings.aaSortingFixed = [];
  29429. _fnSortingClasses( settings );
  29430. $( rows ).removeClass( settings.asStripeClasses.join(' ') );
  29431. $('th, td', thead).removeClass( classes.sSortable+' '+
  29432. classes.sSortableAsc+' '+classes.sSortableDesc+' '+classes.sSortableNone
  29433. );
  29434. if ( settings.bJUI ) {
  29435. $('th span.'+classes.sSortIcon+ ', td span.'+classes.sSortIcon, thead).detach();
  29436. $('th, td', thead).each( function () {
  29437. var wrapper = $('div.'+classes.sSortJUIWrapper, this);
  29438. $(this).append( wrapper.contents() );
  29439. wrapper.detach();
  29440. } );
  29441. }
  29442. // Add the TR elements back into the table in their original order
  29443. jqTbody.children().detach();
  29444. jqTbody.append( rows );
  29445. // Remove the DataTables generated nodes, events and classes
  29446. var removedMethod = remove ? 'remove' : 'detach';
  29447. jqTable[ removedMethod ]();
  29448. jqWrapper[ removedMethod ]();
  29449. // If we need to reattach the table to the document
  29450. if ( ! remove && orig ) {
  29451. // insertBefore acts like appendChild if !arg[1]
  29452. orig.insertBefore( table, settings.nTableReinsertBefore );
  29453. // Restore the width of the original table - was read from the style property,
  29454. // so we can restore directly to that
  29455. jqTable
  29456. .css( 'width', settings.sDestroyWidth )
  29457. .removeClass( classes.sTable );
  29458. // If the were originally stripe classes - then we add them back here.
  29459. // Note this is not fool proof (for example if not all rows had stripe
  29460. // classes - but it's a good effort without getting carried away
  29461. ien = settings.asDestroyStripes.length;
  29462. if ( ien ) {
  29463. jqTbody.children().each( function (i) {
  29464. $(this).addClass( settings.asDestroyStripes[i % ien] );
  29465. } );
  29466. }
  29467. }
  29468. /* Remove the settings object from the settings array */
  29469. var idx = $.inArray( settings, DataTable.settings );
  29470. if ( idx !== -1 ) {
  29471. DataTable.settings.splice( idx, 1 );
  29472. }
  29473. } );
  29474. } );
  29475. // Add the `every()` method for rows, columns and cells in a compact form
  29476. $.each( [ 'column', 'row', 'cell' ], function ( i, type ) {
  29477. _api_register( type+'s().every()', function ( fn ) {
  29478. var opts = this.selector.opts;
  29479. var api = this;
  29480. return this.iterator( type, function ( settings, arg1, arg2, arg3, arg4 ) {
  29481. // Rows and columns:
  29482. // arg1 - index
  29483. // arg2 - table counter
  29484. // arg3 - loop counter
  29485. // arg4 - undefined
  29486. // Cells:
  29487. // arg1 - row index
  29488. // arg2 - column index
  29489. // arg3 - table counter
  29490. // arg4 - loop counter
  29491. fn.call(
  29492. api[ type ](
  29493. arg1,
  29494. type==='cell' ? arg2 : opts,
  29495. type==='cell' ? opts : undefined
  29496. ),
  29497. arg1, arg2, arg3, arg4
  29498. );
  29499. } );
  29500. } );
  29501. } );
  29502. // i18n method for extensions to be able to use the language object from the
  29503. // DataTable
  29504. _api_register( 'i18n()', function ( token, def, plural ) {
  29505. var ctx = this.context[0];
  29506. var resolved = _fnGetObjectDataFn( token )( ctx.oLanguage );
  29507. if ( resolved === undefined ) {
  29508. resolved = def;
  29509. }
  29510. if ( plural !== undefined && $.isPlainObject( resolved ) ) {
  29511. resolved = resolved[ plural ] !== undefined ?
  29512. resolved[ plural ] :
  29513. resolved._;
  29514. }
  29515. return resolved.replace( '%d', plural ); // nb: plural might be undefined,
  29516. } );
  29517. /**
  29518. * Version string for plug-ins to check compatibility. Allowed format is
  29519. * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
  29520. * only for non-release builds. See http://semver.org/ for more information.
  29521. * @member
  29522. * @type string
  29523. * @default Version number
  29524. */
  29525. DataTable.version = "1.10.12";
  29526. /**
  29527. * Private data store, containing all of the settings objects that are
  29528. * created for the tables on a given page.
  29529. *
  29530. * Note that the `DataTable.settings` object is aliased to
  29531. * `jQuery.fn.dataTableExt` through which it may be accessed and
  29532. * manipulated, or `jQuery.fn.dataTable.settings`.
  29533. * @member
  29534. * @type array
  29535. * @default []
  29536. * @private
  29537. */
  29538. DataTable.settings = [];
  29539. /**
  29540. * Object models container, for the various models that DataTables has
  29541. * available to it. These models define the objects that are used to hold
  29542. * the active state and configuration of the table.
  29543. * @namespace
  29544. */
  29545. DataTable.models = {};
  29546. /**
  29547. * Template object for the way in which DataTables holds information about
  29548. * search information for the global filter and individual column filters.
  29549. * @namespace
  29550. */
  29551. DataTable.models.oSearch = {
  29552. /**
  29553. * Flag to indicate if the filtering should be case insensitive or not
  29554. * @type boolean
  29555. * @default true
  29556. */
  29557. "bCaseInsensitive": true,
  29558. /**
  29559. * Applied search term
  29560. * @type string
  29561. * @default <i>Empty string</i>
  29562. */
  29563. "sSearch": "",
  29564. /**
  29565. * Flag to indicate if the search term should be interpreted as a
  29566. * regular expression (true) or not (false) and therefore and special
  29567. * regex characters escaped.
  29568. * @type boolean
  29569. * @default false
  29570. */
  29571. "bRegex": false,
  29572. /**
  29573. * Flag to indicate if DataTables is to use its smart filtering or not.
  29574. * @type boolean
  29575. * @default true
  29576. */
  29577. "bSmart": true
  29578. };
  29579. /**
  29580. * Template object for the way in which DataTables holds information about
  29581. * each individual row. This is the object format used for the settings
  29582. * aoData array.
  29583. * @namespace
  29584. */
  29585. DataTable.models.oRow = {
  29586. /**
  29587. * TR element for the row
  29588. * @type node
  29589. * @default null
  29590. */
  29591. "nTr": null,
  29592. /**
  29593. * Array of TD elements for each row. This is null until the row has been
  29594. * created.
  29595. * @type array nodes
  29596. * @default []
  29597. */
  29598. "anCells": null,
  29599. /**
  29600. * Data object from the original data source for the row. This is either
  29601. * an array if using the traditional form of DataTables, or an object if
  29602. * using mData options. The exact type will depend on the passed in
  29603. * data from the data source, or will be an array if using DOM a data
  29604. * source.
  29605. * @type array|object
  29606. * @default []
  29607. */
  29608. "_aData": [],
  29609. /**
  29610. * Sorting data cache - this array is ostensibly the same length as the
  29611. * number of columns (although each index is generated only as it is
  29612. * needed), and holds the data that is used for sorting each column in the
  29613. * row. We do this cache generation at the start of the sort in order that
  29614. * the formatting of the sort data need be done only once for each cell
  29615. * per sort. This array should not be read from or written to by anything
  29616. * other than the master sorting methods.
  29617. * @type array
  29618. * @default null
  29619. * @private
  29620. */
  29621. "_aSortData": null,
  29622. /**
  29623. * Per cell filtering data cache. As per the sort data cache, used to
  29624. * increase the performance of the filtering in DataTables
  29625. * @type array
  29626. * @default null
  29627. * @private
  29628. */
  29629. "_aFilterData": null,
  29630. /**
  29631. * Filtering data cache. This is the same as the cell filtering cache, but
  29632. * in this case a string rather than an array. This is easily computed with
  29633. * a join on `_aFilterData`, but is provided as a cache so the join isn't
  29634. * needed on every search (memory traded for performance)
  29635. * @type array
  29636. * @default null
  29637. * @private
  29638. */
  29639. "_sFilterRow": null,
  29640. /**
  29641. * Cache of the class name that DataTables has applied to the row, so we
  29642. * can quickly look at this variable rather than needing to do a DOM check
  29643. * on className for the nTr property.
  29644. * @type string
  29645. * @default <i>Empty string</i>
  29646. * @private
  29647. */
  29648. "_sRowStripe": "",
  29649. /**
  29650. * Denote if the original data source was from the DOM, or the data source
  29651. * object. This is used for invalidating data, so DataTables can
  29652. * automatically read data from the original source, unless uninstructed
  29653. * otherwise.
  29654. * @type string
  29655. * @default null
  29656. * @private
  29657. */
  29658. "src": null,
  29659. /**
  29660. * Index in the aoData array. This saves an indexOf lookup when we have the
  29661. * object, but want to know the index
  29662. * @type integer
  29663. * @default -1
  29664. * @private
  29665. */
  29666. "idx": -1
  29667. };
  29668. /**
  29669. * Template object for the column information object in DataTables. This object
  29670. * is held in the settings aoColumns array and contains all the information that
  29671. * DataTables needs about each individual column.
  29672. *
  29673. * Note that this object is related to {@link DataTable.defaults.column}
  29674. * but this one is the internal data store for DataTables's cache of columns.
  29675. * It should NOT be manipulated outside of DataTables. Any configuration should
  29676. * be done through the initialisation options.
  29677. * @namespace
  29678. */
  29679. DataTable.models.oColumn = {
  29680. /**
  29681. * Column index. This could be worked out on-the-fly with $.inArray, but it
  29682. * is faster to just hold it as a variable
  29683. * @type integer
  29684. * @default null
  29685. */
  29686. "idx": null,
  29687. /**
  29688. * A list of the columns that sorting should occur on when this column
  29689. * is sorted. That this property is an array allows multi-column sorting
  29690. * to be defined for a column (for example first name / last name columns
  29691. * would benefit from this). The values are integers pointing to the
  29692. * columns to be sorted on (typically it will be a single integer pointing
  29693. * at itself, but that doesn't need to be the case).
  29694. * @type array
  29695. */
  29696. "aDataSort": null,
  29697. /**
  29698. * Define the sorting directions that are applied to the column, in sequence
  29699. * as the column is repeatedly sorted upon - i.e. the first value is used
  29700. * as the sorting direction when the column if first sorted (clicked on).
  29701. * Sort it again (click again) and it will move on to the next index.
  29702. * Repeat until loop.
  29703. * @type array
  29704. */
  29705. "asSorting": null,
  29706. /**
  29707. * Flag to indicate if the column is searchable, and thus should be included
  29708. * in the filtering or not.
  29709. * @type boolean
  29710. */
  29711. "bSearchable": null,
  29712. /**
  29713. * Flag to indicate if the column is sortable or not.
  29714. * @type boolean
  29715. */
  29716. "bSortable": null,
  29717. /**
  29718. * Flag to indicate if the column is currently visible in the table or not
  29719. * @type boolean
  29720. */
  29721. "bVisible": null,
  29722. /**
  29723. * Store for manual type assignment using the `column.type` option. This
  29724. * is held in store so we can manipulate the column's `sType` property.
  29725. * @type string
  29726. * @default null
  29727. * @private
  29728. */
  29729. "_sManualType": null,
  29730. /**
  29731. * Flag to indicate if HTML5 data attributes should be used as the data
  29732. * source for filtering or sorting. True is either are.
  29733. * @type boolean
  29734. * @default false
  29735. * @private
  29736. */
  29737. "_bAttrSrc": false,
  29738. /**
  29739. * Developer definable function that is called whenever a cell is created (Ajax source,
  29740. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  29741. * allowing you to modify the DOM element (add background colour for example) when the
  29742. * element is available.
  29743. * @type function
  29744. * @param {element} nTd The TD node that has been created
  29745. * @param {*} sData The Data for the cell
  29746. * @param {array|object} oData The data for the whole row
  29747. * @param {int} iRow The row index for the aoData data store
  29748. * @default null
  29749. */
  29750. "fnCreatedCell": null,
  29751. /**
  29752. * Function to get data from a cell in a column. You should <b>never</b>
  29753. * access data directly through _aData internally in DataTables - always use
  29754. * the method attached to this property. It allows mData to function as
  29755. * required. This function is automatically assigned by the column
  29756. * initialisation method
  29757. * @type function
  29758. * @param {array|object} oData The data array/object for the array
  29759. * (i.e. aoData[]._aData)
  29760. * @param {string} sSpecific The specific data type you want to get -
  29761. * 'display', 'type' 'filter' 'sort'
  29762. * @returns {*} The data for the cell from the given row's data
  29763. * @default null
  29764. */
  29765. "fnGetData": null,
  29766. /**
  29767. * Function to set data for a cell in the column. You should <b>never</b>
  29768. * set the data directly to _aData internally in DataTables - always use
  29769. * this method. It allows mData to function as required. This function
  29770. * is automatically assigned by the column initialisation method
  29771. * @type function
  29772. * @param {array|object} oData The data array/object for the array
  29773. * (i.e. aoData[]._aData)
  29774. * @param {*} sValue Value to set
  29775. * @default null
  29776. */
  29777. "fnSetData": null,
  29778. /**
  29779. * Property to read the value for the cells in the column from the data
  29780. * source array / object. If null, then the default content is used, if a
  29781. * function is given then the return from the function is used.
  29782. * @type function|int|string|null
  29783. * @default null
  29784. */
  29785. "mData": null,
  29786. /**
  29787. * Partner property to mData which is used (only when defined) to get
  29788. * the data - i.e. it is basically the same as mData, but without the
  29789. * 'set' option, and also the data fed to it is the result from mData.
  29790. * This is the rendering method to match the data method of mData.
  29791. * @type function|int|string|null
  29792. * @default null
  29793. */
  29794. "mRender": null,
  29795. /**
  29796. * Unique header TH/TD element for this column - this is what the sorting
  29797. * listener is attached to (if sorting is enabled.)
  29798. * @type node
  29799. * @default null
  29800. */
  29801. "nTh": null,
  29802. /**
  29803. * Unique footer TH/TD element for this column (if there is one). Not used
  29804. * in DataTables as such, but can be used for plug-ins to reference the
  29805. * footer for each column.
  29806. * @type node
  29807. * @default null
  29808. */
  29809. "nTf": null,
  29810. /**
  29811. * The class to apply to all TD elements in the table's TBODY for the column
  29812. * @type string
  29813. * @default null
  29814. */
  29815. "sClass": null,
  29816. /**
  29817. * When DataTables calculates the column widths to assign to each column,
  29818. * it finds the longest string in each column and then constructs a
  29819. * temporary table and reads the widths from that. The problem with this
  29820. * is that "mmm" is much wider then "iiii", but the latter is a longer
  29821. * string - thus the calculation can go wrong (doing it properly and putting
  29822. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  29823. * a "work around" we provide this option. It will append its value to the
  29824. * text that is found to be the longest string for the column - i.e. padding.
  29825. * @type string
  29826. */
  29827. "sContentPadding": null,
  29828. /**
  29829. * Allows a default value to be given for a column's data, and will be used
  29830. * whenever a null data source is encountered (this can be because mData
  29831. * is set to null, or because the data source itself is null).
  29832. * @type string
  29833. * @default null
  29834. */
  29835. "sDefaultContent": null,
  29836. /**
  29837. * Name for the column, allowing reference to the column by name as well as
  29838. * by index (needs a lookup to work by name).
  29839. * @type string
  29840. */
  29841. "sName": null,
  29842. /**
  29843. * Custom sorting data type - defines which of the available plug-ins in
  29844. * afnSortData the custom sorting will use - if any is defined.
  29845. * @type string
  29846. * @default std
  29847. */
  29848. "sSortDataType": 'std',
  29849. /**
  29850. * Class to be applied to the header element when sorting on this column
  29851. * @type string
  29852. * @default null
  29853. */
  29854. "sSortingClass": null,
  29855. /**
  29856. * Class to be applied to the header element when sorting on this column -
  29857. * when jQuery UI theming is used.
  29858. * @type string
  29859. * @default null
  29860. */
  29861. "sSortingClassJUI": null,
  29862. /**
  29863. * Title of the column - what is seen in the TH element (nTh).
  29864. * @type string
  29865. */
  29866. "sTitle": null,
  29867. /**
  29868. * Column sorting and filtering type
  29869. * @type string
  29870. * @default null
  29871. */
  29872. "sType": null,
  29873. /**
  29874. * Width of the column
  29875. * @type string
  29876. * @default null
  29877. */
  29878. "sWidth": null,
  29879. /**
  29880. * Width of the column when it was first "encountered"
  29881. * @type string
  29882. * @default null
  29883. */
  29884. "sWidthOrig": null
  29885. };
  29886. /*
  29887. * Developer note: The properties of the object below are given in Hungarian
  29888. * notation, that was used as the interface for DataTables prior to v1.10, however
  29889. * from v1.10 onwards the primary interface is camel case. In order to avoid
  29890. * breaking backwards compatibility utterly with this change, the Hungarian
  29891. * version is still, internally the primary interface, but is is not documented
  29892. * - hence the @name tags in each doc comment. This allows a Javascript function
  29893. * to create a map from Hungarian notation to camel case (going the other direction
  29894. * would require each property to be listed, which would at around 3K to the size
  29895. * of DataTables, while this method is about a 0.5K hit.
  29896. *
  29897. * Ultimately this does pave the way for Hungarian notation to be dropped
  29898. * completely, but that is a massive amount of work and will break current
  29899. * installs (therefore is on-hold until v2).
  29900. */
  29901. /**
  29902. * Initialisation options that can be given to DataTables at initialisation
  29903. * time.
  29904. * @namespace
  29905. */
  29906. DataTable.defaults = {
  29907. /**
  29908. * An array of data to use for the table, passed in at initialisation which
  29909. * will be used in preference to any data which is already in the DOM. This is
  29910. * particularly useful for constructing tables purely in Javascript, for
  29911. * example with a custom Ajax call.
  29912. * @type array
  29913. * @default null
  29914. *
  29915. * @dtopt Option
  29916. * @name DataTable.defaults.data
  29917. *
  29918. * @example
  29919. * // Using a 2D array data source
  29920. * $(document).ready( function () {
  29921. * $('#example').dataTable( {
  29922. * "data": [
  29923. * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
  29924. * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
  29925. * ],
  29926. * "columns": [
  29927. * { "title": "Engine" },
  29928. * { "title": "Browser" },
  29929. * { "title": "Platform" },
  29930. * { "title": "Version" },
  29931. * { "title": "Grade" }
  29932. * ]
  29933. * } );
  29934. * } );
  29935. *
  29936. * @example
  29937. * // Using an array of objects as a data source (`data`)
  29938. * $(document).ready( function () {
  29939. * $('#example').dataTable( {
  29940. * "data": [
  29941. * {
  29942. * "engine": "Trident",
  29943. * "browser": "Internet Explorer 4.0",
  29944. * "platform": "Win 95+",
  29945. * "version": 4,
  29946. * "grade": "X"
  29947. * },
  29948. * {
  29949. * "engine": "Trident",
  29950. * "browser": "Internet Explorer 5.0",
  29951. * "platform": "Win 95+",
  29952. * "version": 5,
  29953. * "grade": "C"
  29954. * }
  29955. * ],
  29956. * "columns": [
  29957. * { "title": "Engine", "data": "engine" },
  29958. * { "title": "Browser", "data": "browser" },
  29959. * { "title": "Platform", "data": "platform" },
  29960. * { "title": "Version", "data": "version" },
  29961. * { "title": "Grade", "data": "grade" }
  29962. * ]
  29963. * } );
  29964. * } );
  29965. */
  29966. "aaData": null,
  29967. /**
  29968. * If ordering is enabled, then DataTables will perform a first pass sort on
  29969. * initialisation. You can define which column(s) the sort is performed
  29970. * upon, and the sorting direction, with this variable. The `sorting` array
  29971. * should contain an array for each column to be sorted initially containing
  29972. * the column's index and a direction string ('asc' or 'desc').
  29973. * @type array
  29974. * @default [[0,'asc']]
  29975. *
  29976. * @dtopt Option
  29977. * @name DataTable.defaults.order
  29978. *
  29979. * @example
  29980. * // Sort by 3rd column first, and then 4th column
  29981. * $(document).ready( function() {
  29982. * $('#example').dataTable( {
  29983. * "order": [[2,'asc'], [3,'desc']]
  29984. * } );
  29985. * } );
  29986. *
  29987. * // No initial sorting
  29988. * $(document).ready( function() {
  29989. * $('#example').dataTable( {
  29990. * "order": []
  29991. * } );
  29992. * } );
  29993. */
  29994. "aaSorting": [[0,'asc']],
  29995. /**
  29996. * This parameter is basically identical to the `sorting` parameter, but
  29997. * cannot be overridden by user interaction with the table. What this means
  29998. * is that you could have a column (visible or hidden) which the sorting
  29999. * will always be forced on first - any sorting after that (from the user)
  30000. * will then be performed as required. This can be useful for grouping rows
  30001. * together.
  30002. * @type array
  30003. * @default null
  30004. *
  30005. * @dtopt Option
  30006. * @name DataTable.defaults.orderFixed
  30007. *
  30008. * @example
  30009. * $(document).ready( function() {
  30010. * $('#example').dataTable( {
  30011. * "orderFixed": [[0,'asc']]
  30012. * } );
  30013. * } )
  30014. */
  30015. "aaSortingFixed": [],
  30016. /**
  30017. * DataTables can be instructed to load data to display in the table from a
  30018. * Ajax source. This option defines how that Ajax call is made and where to.
  30019. *
  30020. * The `ajax` property has three different modes of operation, depending on
  30021. * how it is defined. These are:
  30022. *
  30023. * * `string` - Set the URL from where the data should be loaded from.
  30024. * * `object` - Define properties for `jQuery.ajax`.
  30025. * * `function` - Custom data get function
  30026. *
  30027. * `string`
  30028. * --------
  30029. *
  30030. * As a string, the `ajax` property simply defines the URL from which
  30031. * DataTables will load data.
  30032. *
  30033. * `object`
  30034. * --------
  30035. *
  30036. * As an object, the parameters in the object are passed to
  30037. * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
  30038. * of the Ajax request. DataTables has a number of default parameters which
  30039. * you can override using this option. Please refer to the jQuery
  30040. * documentation for a full description of the options available, although
  30041. * the following parameters provide additional options in DataTables or
  30042. * require special consideration:
  30043. *
  30044. * * `data` - As with jQuery, `data` can be provided as an object, but it
  30045. * can also be used as a function to manipulate the data DataTables sends
  30046. * to the server. The function takes a single parameter, an object of
  30047. * parameters with the values that DataTables has readied for sending. An
  30048. * object may be returned which will be merged into the DataTables
  30049. * defaults, or you can add the items to the object that was passed in and
  30050. * not return anything from the function. This supersedes `fnServerParams`
  30051. * from DataTables 1.9-.
  30052. *
  30053. * * `dataSrc` - By default DataTables will look for the property `data` (or
  30054. * `aaData` for compatibility with DataTables 1.9-) when obtaining data
  30055. * from an Ajax source or for server-side processing - this parameter
  30056. * allows that property to be changed. You can use Javascript dotted
  30057. * object notation to get a data source for multiple levels of nesting, or
  30058. * it my be used as a function. As a function it takes a single parameter,
  30059. * the JSON returned from the server, which can be manipulated as
  30060. * required, with the returned value being that used by DataTables as the
  30061. * data source for the table. This supersedes `sAjaxDataProp` from
  30062. * DataTables 1.9-.
  30063. *
  30064. * * `success` - Should not be overridden it is used internally in
  30065. * DataTables. To manipulate / transform the data returned by the server
  30066. * use `ajax.dataSrc`, or use `ajax` as a function (see below).
  30067. *
  30068. * `function`
  30069. * ----------
  30070. *
  30071. * As a function, making the Ajax call is left up to yourself allowing
  30072. * complete control of the Ajax request. Indeed, if desired, a method other
  30073. * than Ajax could be used to obtain the required data, such as Web storage
  30074. * or an AIR database.
  30075. *
  30076. * The function is given four parameters and no return is required. The
  30077. * parameters are:
  30078. *
  30079. * 1. _object_ - Data to send to the server
  30080. * 2. _function_ - Callback function that must be executed when the required
  30081. * data has been obtained. That data should be passed into the callback
  30082. * as the only parameter
  30083. * 3. _object_ - DataTables settings object for the table
  30084. *
  30085. * Note that this supersedes `fnServerData` from DataTables 1.9-.
  30086. *
  30087. * @type string|object|function
  30088. * @default null
  30089. *
  30090. * @dtopt Option
  30091. * @name DataTable.defaults.ajax
  30092. * @since 1.10.0
  30093. *
  30094. * @example
  30095. * // Get JSON data from a file via Ajax.
  30096. * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
  30097. * $('#example').dataTable( {
  30098. * "ajax": "data.json"
  30099. * } );
  30100. *
  30101. * @example
  30102. * // Get JSON data from a file via Ajax, using `dataSrc` to change
  30103. * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
  30104. * $('#example').dataTable( {
  30105. * "ajax": {
  30106. * "url": "data.json",
  30107. * "dataSrc": "tableData"
  30108. * }
  30109. * } );
  30110. *
  30111. * @example
  30112. * // Get JSON data from a file via Ajax, using `dataSrc` to read data
  30113. * // from a plain array rather than an array in an object
  30114. * $('#example').dataTable( {
  30115. * "ajax": {
  30116. * "url": "data.json",
  30117. * "dataSrc": ""
  30118. * }
  30119. * } );
  30120. *
  30121. * @example
  30122. * // Manipulate the data returned from the server - add a link to data
  30123. * // (note this can, should, be done using `render` for the column - this
  30124. * // is just a simple example of how the data can be manipulated).
  30125. * $('#example').dataTable( {
  30126. * "ajax": {
  30127. * "url": "data.json",
  30128. * "dataSrc": function ( json ) {
  30129. * for ( var i=0, ien=json.length ; i<ien ; i++ ) {
  30130. * json[i][0] = '<a href="/message/'+json[i][0]+'>View message</a>';
  30131. * }
  30132. * return json;
  30133. * }
  30134. * }
  30135. * } );
  30136. *
  30137. * @example
  30138. * // Add data to the request
  30139. * $('#example').dataTable( {
  30140. * "ajax": {
  30141. * "url": "data.json",
  30142. * "data": function ( d ) {
  30143. * return {
  30144. * "extra_search": $('#extra').val()
  30145. * };
  30146. * }
  30147. * }
  30148. * } );
  30149. *
  30150. * @example
  30151. * // Send request as POST
  30152. * $('#example').dataTable( {
  30153. * "ajax": {
  30154. * "url": "data.json",
  30155. * "type": "POST"
  30156. * }
  30157. * } );
  30158. *
  30159. * @example
  30160. * // Get the data from localStorage (could interface with a form for
  30161. * // adding, editing and removing rows).
  30162. * $('#example').dataTable( {
  30163. * "ajax": function (data, callback, settings) {
  30164. * callback(
  30165. * JSON.parse( localStorage.getItem('dataTablesData') )
  30166. * );
  30167. * }
  30168. * } );
  30169. */
  30170. "ajax": null,
  30171. /**
  30172. * This parameter allows you to readily specify the entries in the length drop
  30173. * down menu that DataTables shows when pagination is enabled. It can be
  30174. * either a 1D array of options which will be used for both the displayed
  30175. * option and the value, or a 2D array which will use the array in the first
  30176. * position as the value, and the array in the second position as the
  30177. * displayed options (useful for language strings such as 'All').
  30178. *
  30179. * Note that the `pageLength` property will be automatically set to the
  30180. * first value given in this array, unless `pageLength` is also provided.
  30181. * @type array
  30182. * @default [ 10, 25, 50, 100 ]
  30183. *
  30184. * @dtopt Option
  30185. * @name DataTable.defaults.lengthMenu
  30186. *
  30187. * @example
  30188. * $(document).ready( function() {
  30189. * $('#example').dataTable( {
  30190. * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
  30191. * } );
  30192. * } );
  30193. */
  30194. "aLengthMenu": [ 10, 25, 50, 100 ],
  30195. /**
  30196. * The `columns` option in the initialisation parameter allows you to define
  30197. * details about the way individual columns behave. For a full list of
  30198. * column options that can be set, please see
  30199. * {@link DataTable.defaults.column}. Note that if you use `columns` to
  30200. * define your columns, you must have an entry in the array for every single
  30201. * column that you have in your table (these can be null if you don't which
  30202. * to specify any options).
  30203. * @member
  30204. *
  30205. * @name DataTable.defaults.column
  30206. */
  30207. "aoColumns": null,
  30208. /**
  30209. * Very similar to `columns`, `columnDefs` allows you to target a specific
  30210. * column, multiple columns, or all columns, using the `targets` property of
  30211. * each object in the array. This allows great flexibility when creating
  30212. * tables, as the `columnDefs` arrays can be of any length, targeting the
  30213. * columns you specifically want. `columnDefs` may use any of the column
  30214. * options available: {@link DataTable.defaults.column}, but it _must_
  30215. * have `targets` defined in each object in the array. Values in the `targets`
  30216. * array may be:
  30217. * <ul>
  30218. * <li>a string - class name will be matched on the TH for the column</li>
  30219. * <li>0 or a positive integer - column index counting from the left</li>
  30220. * <li>a negative integer - column index counting from the right</li>
  30221. * <li>the string "_all" - all columns (i.e. assign a default)</li>
  30222. * </ul>
  30223. * @member
  30224. *
  30225. * @name DataTable.defaults.columnDefs
  30226. */
  30227. "aoColumnDefs": null,
  30228. /**
  30229. * Basically the same as `search`, this parameter defines the individual column
  30230. * filtering state at initialisation time. The array must be of the same size
  30231. * as the number of columns, and each element be an object with the parameters
  30232. * `search` and `escapeRegex` (the latter is optional). 'null' is also
  30233. * accepted and the default will be used.
  30234. * @type array
  30235. * @default []
  30236. *
  30237. * @dtopt Option
  30238. * @name DataTable.defaults.searchCols
  30239. *
  30240. * @example
  30241. * $(document).ready( function() {
  30242. * $('#example').dataTable( {
  30243. * "searchCols": [
  30244. * null,
  30245. * { "search": "My filter" },
  30246. * null,
  30247. * { "search": "^[0-9]", "escapeRegex": false }
  30248. * ]
  30249. * } );
  30250. * } )
  30251. */
  30252. "aoSearchCols": [],
  30253. /**
  30254. * An array of CSS classes that should be applied to displayed rows. This
  30255. * array may be of any length, and DataTables will apply each class
  30256. * sequentially, looping when required.
  30257. * @type array
  30258. * @default null <i>Will take the values determined by the `oClasses.stripe*`
  30259. * options</i>
  30260. *
  30261. * @dtopt Option
  30262. * @name DataTable.defaults.stripeClasses
  30263. *
  30264. * @example
  30265. * $(document).ready( function() {
  30266. * $('#example').dataTable( {
  30267. * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
  30268. * } );
  30269. * } )
  30270. */
  30271. "asStripeClasses": null,
  30272. /**
  30273. * Enable or disable automatic column width calculation. This can be disabled
  30274. * as an optimisation (it takes some time to calculate the widths) if the
  30275. * tables widths are passed in using `columns`.
  30276. * @type boolean
  30277. * @default true
  30278. *
  30279. * @dtopt Features
  30280. * @name DataTable.defaults.autoWidth
  30281. *
  30282. * @example
  30283. * $(document).ready( function () {
  30284. * $('#example').dataTable( {
  30285. * "autoWidth": false
  30286. * } );
  30287. * } );
  30288. */
  30289. "bAutoWidth": true,
  30290. /**
  30291. * Deferred rendering can provide DataTables with a huge speed boost when you
  30292. * are using an Ajax or JS data source for the table. This option, when set to
  30293. * true, will cause DataTables to defer the creation of the table elements for
  30294. * each row until they are needed for a draw - saving a significant amount of
  30295. * time.
  30296. * @type boolean
  30297. * @default false
  30298. *
  30299. * @dtopt Features
  30300. * @name DataTable.defaults.deferRender
  30301. *
  30302. * @example
  30303. * $(document).ready( function() {
  30304. * $('#example').dataTable( {
  30305. * "ajax": "sources/arrays.txt",
  30306. * "deferRender": true
  30307. * } );
  30308. * } );
  30309. */
  30310. "bDeferRender": false,
  30311. /**
  30312. * Replace a DataTable which matches the given selector and replace it with
  30313. * one which has the properties of the new initialisation object passed. If no
  30314. * table matches the selector, then the new DataTable will be constructed as
  30315. * per normal.
  30316. * @type boolean
  30317. * @default false
  30318. *
  30319. * @dtopt Options
  30320. * @name DataTable.defaults.destroy
  30321. *
  30322. * @example
  30323. * $(document).ready( function() {
  30324. * $('#example').dataTable( {
  30325. * "srollY": "200px",
  30326. * "paginate": false
  30327. * } );
  30328. *
  30329. * // Some time later....
  30330. * $('#example').dataTable( {
  30331. * "filter": false,
  30332. * "destroy": true
  30333. * } );
  30334. * } );
  30335. */
  30336. "bDestroy": false,
  30337. /**
  30338. * Enable or disable filtering of data. Filtering in DataTables is "smart" in
  30339. * that it allows the end user to input multiple words (space separated) and
  30340. * will match a row containing those words, even if not in the order that was
  30341. * specified (this allow matching across multiple columns). Note that if you
  30342. * wish to use filtering in DataTables this must remain 'true' - to remove the
  30343. * default filtering input box and retain filtering abilities, please use
  30344. * {@link DataTable.defaults.dom}.
  30345. * @type boolean
  30346. * @default true
  30347. *
  30348. * @dtopt Features
  30349. * @name DataTable.defaults.searching
  30350. *
  30351. * @example
  30352. * $(document).ready( function () {
  30353. * $('#example').dataTable( {
  30354. * "searching": false
  30355. * } );
  30356. * } );
  30357. */
  30358. "bFilter": true,
  30359. /**
  30360. * Enable or disable the table information display. This shows information
  30361. * about the data that is currently visible on the page, including information
  30362. * about filtered data if that action is being performed.
  30363. * @type boolean
  30364. * @default true
  30365. *
  30366. * @dtopt Features
  30367. * @name DataTable.defaults.info
  30368. *
  30369. * @example
  30370. * $(document).ready( function () {
  30371. * $('#example').dataTable( {
  30372. * "info": false
  30373. * } );
  30374. * } );
  30375. */
  30376. "bInfo": true,
  30377. /**
  30378. * Enable jQuery UI ThemeRoller support (required as ThemeRoller requires some
  30379. * slightly different and additional mark-up from what DataTables has
  30380. * traditionally used).
  30381. * @type boolean
  30382. * @default false
  30383. *
  30384. * @dtopt Features
  30385. * @name DataTable.defaults.jQueryUI
  30386. *
  30387. * @example
  30388. * $(document).ready( function() {
  30389. * $('#example').dataTable( {
  30390. * "jQueryUI": true
  30391. * } );
  30392. * } );
  30393. */
  30394. "bJQueryUI": false,
  30395. /**
  30396. * Allows the end user to select the size of a formatted page from a select
  30397. * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
  30398. * @type boolean
  30399. * @default true
  30400. *
  30401. * @dtopt Features
  30402. * @name DataTable.defaults.lengthChange
  30403. *
  30404. * @example
  30405. * $(document).ready( function () {
  30406. * $('#example').dataTable( {
  30407. * "lengthChange": false
  30408. * } );
  30409. * } );
  30410. */
  30411. "bLengthChange": true,
  30412. /**
  30413. * Enable or disable pagination.
  30414. * @type boolean
  30415. * @default true
  30416. *
  30417. * @dtopt Features
  30418. * @name DataTable.defaults.paging
  30419. *
  30420. * @example
  30421. * $(document).ready( function () {
  30422. * $('#example').dataTable( {
  30423. * "paging": false
  30424. * } );
  30425. * } );
  30426. */
  30427. "bPaginate": true,
  30428. /**
  30429. * Enable or disable the display of a 'processing' indicator when the table is
  30430. * being processed (e.g. a sort). This is particularly useful for tables with
  30431. * large amounts of data where it can take a noticeable amount of time to sort
  30432. * the entries.
  30433. * @type boolean
  30434. * @default false
  30435. *
  30436. * @dtopt Features
  30437. * @name DataTable.defaults.processing
  30438. *
  30439. * @example
  30440. * $(document).ready( function () {
  30441. * $('#example').dataTable( {
  30442. * "processing": true
  30443. * } );
  30444. * } );
  30445. */
  30446. "bProcessing": false,
  30447. /**
  30448. * Retrieve the DataTables object for the given selector. Note that if the
  30449. * table has already been initialised, this parameter will cause DataTables
  30450. * to simply return the object that has already been set up - it will not take
  30451. * account of any changes you might have made to the initialisation object
  30452. * passed to DataTables (setting this parameter to true is an acknowledgement
  30453. * that you understand this). `destroy` can be used to reinitialise a table if
  30454. * you need.
  30455. * @type boolean
  30456. * @default false
  30457. *
  30458. * @dtopt Options
  30459. * @name DataTable.defaults.retrieve
  30460. *
  30461. * @example
  30462. * $(document).ready( function() {
  30463. * initTable();
  30464. * tableActions();
  30465. * } );
  30466. *
  30467. * function initTable ()
  30468. * {
  30469. * return $('#example').dataTable( {
  30470. * "scrollY": "200px",
  30471. * "paginate": false,
  30472. * "retrieve": true
  30473. * } );
  30474. * }
  30475. *
  30476. * function tableActions ()
  30477. * {
  30478. * var table = initTable();
  30479. * // perform API operations with oTable
  30480. * }
  30481. */
  30482. "bRetrieve": false,
  30483. /**
  30484. * When vertical (y) scrolling is enabled, DataTables will force the height of
  30485. * the table's viewport to the given height at all times (useful for layout).
  30486. * However, this can look odd when filtering data down to a small data set,
  30487. * and the footer is left "floating" further down. This parameter (when
  30488. * enabled) will cause DataTables to collapse the table's viewport down when
  30489. * the result set will fit within the given Y height.
  30490. * @type boolean
  30491. * @default false
  30492. *
  30493. * @dtopt Options
  30494. * @name DataTable.defaults.scrollCollapse
  30495. *
  30496. * @example
  30497. * $(document).ready( function() {
  30498. * $('#example').dataTable( {
  30499. * "scrollY": "200",
  30500. * "scrollCollapse": true
  30501. * } );
  30502. * } );
  30503. */
  30504. "bScrollCollapse": false,
  30505. /**
  30506. * Configure DataTables to use server-side processing. Note that the
  30507. * `ajax` parameter must also be given in order to give DataTables a
  30508. * source to obtain the required data for each draw.
  30509. * @type boolean
  30510. * @default false
  30511. *
  30512. * @dtopt Features
  30513. * @dtopt Server-side
  30514. * @name DataTable.defaults.serverSide
  30515. *
  30516. * @example
  30517. * $(document).ready( function () {
  30518. * $('#example').dataTable( {
  30519. * "serverSide": true,
  30520. * "ajax": "xhr.php"
  30521. * } );
  30522. * } );
  30523. */
  30524. "bServerSide": false,
  30525. /**
  30526. * Enable or disable sorting of columns. Sorting of individual columns can be
  30527. * disabled by the `sortable` option for each column.
  30528. * @type boolean
  30529. * @default true
  30530. *
  30531. * @dtopt Features
  30532. * @name DataTable.defaults.ordering
  30533. *
  30534. * @example
  30535. * $(document).ready( function () {
  30536. * $('#example').dataTable( {
  30537. * "ordering": false
  30538. * } );
  30539. * } );
  30540. */
  30541. "bSort": true,
  30542. /**
  30543. * Enable or display DataTables' ability to sort multiple columns at the
  30544. * same time (activated by shift-click by the user).
  30545. * @type boolean
  30546. * @default true
  30547. *
  30548. * @dtopt Options
  30549. * @name DataTable.defaults.orderMulti
  30550. *
  30551. * @example
  30552. * // Disable multiple column sorting ability
  30553. * $(document).ready( function () {
  30554. * $('#example').dataTable( {
  30555. * "orderMulti": false
  30556. * } );
  30557. * } );
  30558. */
  30559. "bSortMulti": true,
  30560. /**
  30561. * Allows control over whether DataTables should use the top (true) unique
  30562. * cell that is found for a single column, or the bottom (false - default).
  30563. * This is useful when using complex headers.
  30564. * @type boolean
  30565. * @default false
  30566. *
  30567. * @dtopt Options
  30568. * @name DataTable.defaults.orderCellsTop
  30569. *
  30570. * @example
  30571. * $(document).ready( function() {
  30572. * $('#example').dataTable( {
  30573. * "orderCellsTop": true
  30574. * } );
  30575. * } );
  30576. */
  30577. "bSortCellsTop": false,
  30578. /**
  30579. * Enable or disable the addition of the classes `sorting\_1`, `sorting\_2` and
  30580. * `sorting\_3` to the columns which are currently being sorted on. This is
  30581. * presented as a feature switch as it can increase processing time (while
  30582. * classes are removed and added) so for large data sets you might want to
  30583. * turn this off.
  30584. * @type boolean
  30585. * @default true
  30586. *
  30587. * @dtopt Features
  30588. * @name DataTable.defaults.orderClasses
  30589. *
  30590. * @example
  30591. * $(document).ready( function () {
  30592. * $('#example').dataTable( {
  30593. * "orderClasses": false
  30594. * } );
  30595. * } );
  30596. */
  30597. "bSortClasses": true,
  30598. /**
  30599. * Enable or disable state saving. When enabled HTML5 `localStorage` will be
  30600. * used to save table display information such as pagination information,
  30601. * display length, filtering and sorting. As such when the end user reloads
  30602. * the page the display display will match what thy had previously set up.
  30603. *
  30604. * Due to the use of `localStorage` the default state saving is not supported
  30605. * in IE6 or 7. If state saving is required in those browsers, use
  30606. * `stateSaveCallback` to provide a storage solution such as cookies.
  30607. * @type boolean
  30608. * @default false
  30609. *
  30610. * @dtopt Features
  30611. * @name DataTable.defaults.stateSave
  30612. *
  30613. * @example
  30614. * $(document).ready( function () {
  30615. * $('#example').dataTable( {
  30616. * "stateSave": true
  30617. * } );
  30618. * } );
  30619. */
  30620. "bStateSave": false,
  30621. /**
  30622. * This function is called when a TR element is created (and all TD child
  30623. * elements have been inserted), or registered if using a DOM source, allowing
  30624. * manipulation of the TR element (adding classes etc).
  30625. * @type function
  30626. * @param {node} row "TR" element for the current row
  30627. * @param {array} data Raw data array for this row
  30628. * @param {int} dataIndex The index of this row in the internal aoData array
  30629. *
  30630. * @dtopt Callbacks
  30631. * @name DataTable.defaults.createdRow
  30632. *
  30633. * @example
  30634. * $(document).ready( function() {
  30635. * $('#example').dataTable( {
  30636. * "createdRow": function( row, data, dataIndex ) {
  30637. * // Bold the grade for all 'A' grade browsers
  30638. * if ( data[4] == "A" )
  30639. * {
  30640. * $('td:eq(4)', row).html( '<b>A</b>' );
  30641. * }
  30642. * }
  30643. * } );
  30644. * } );
  30645. */
  30646. "fnCreatedRow": null,
  30647. /**
  30648. * This function is called on every 'draw' event, and allows you to
  30649. * dynamically modify any aspect you want about the created DOM.
  30650. * @type function
  30651. * @param {object} settings DataTables settings object
  30652. *
  30653. * @dtopt Callbacks
  30654. * @name DataTable.defaults.drawCallback
  30655. *
  30656. * @example
  30657. * $(document).ready( function() {
  30658. * $('#example').dataTable( {
  30659. * "drawCallback": function( settings ) {
  30660. * alert( 'DataTables has redrawn the table' );
  30661. * }
  30662. * } );
  30663. * } );
  30664. */
  30665. "fnDrawCallback": null,
  30666. /**
  30667. * Identical to fnHeaderCallback() but for the table footer this function
  30668. * allows you to modify the table footer on every 'draw' event.
  30669. * @type function
  30670. * @param {node} foot "TR" element for the footer
  30671. * @param {array} data Full table data (as derived from the original HTML)
  30672. * @param {int} start Index for the current display starting point in the
  30673. * display array
  30674. * @param {int} end Index for the current display ending point in the
  30675. * display array
  30676. * @param {array int} display Index array to translate the visual position
  30677. * to the full data array
  30678. *
  30679. * @dtopt Callbacks
  30680. * @name DataTable.defaults.footerCallback
  30681. *
  30682. * @example
  30683. * $(document).ready( function() {
  30684. * $('#example').dataTable( {
  30685. * "footerCallback": function( tfoot, data, start, end, display ) {
  30686. * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
  30687. * }
  30688. * } );
  30689. * } )
  30690. */
  30691. "fnFooterCallback": null,
  30692. /**
  30693. * When rendering large numbers in the information element for the table
  30694. * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
  30695. * to have a comma separator for the 'thousands' units (e.g. 1 million is
  30696. * rendered as "1,000,000") to help readability for the end user. This
  30697. * function will override the default method DataTables uses.
  30698. * @type function
  30699. * @member
  30700. * @param {int} toFormat number to be formatted
  30701. * @returns {string} formatted string for DataTables to show the number
  30702. *
  30703. * @dtopt Callbacks
  30704. * @name DataTable.defaults.formatNumber
  30705. *
  30706. * @example
  30707. * // Format a number using a single quote for the separator (note that
  30708. * // this can also be done with the language.thousands option)
  30709. * $(document).ready( function() {
  30710. * $('#example').dataTable( {
  30711. * "formatNumber": function ( toFormat ) {
  30712. * return toFormat.toString().replace(
  30713. * /\B(?=(\d{3})+(?!\d))/g, "'"
  30714. * );
  30715. * };
  30716. * } );
  30717. * } );
  30718. */
  30719. "fnFormatNumber": function ( toFormat ) {
  30720. return toFormat.toString().replace(
  30721. /\B(?=(\d{3})+(?!\d))/g,
  30722. this.oLanguage.sThousands
  30723. );
  30724. },
  30725. /**
  30726. * This function is called on every 'draw' event, and allows you to
  30727. * dynamically modify the header row. This can be used to calculate and
  30728. * display useful information about the table.
  30729. * @type function
  30730. * @param {node} head "TR" element for the header
  30731. * @param {array} data Full table data (as derived from the original HTML)
  30732. * @param {int} start Index for the current display starting point in the
  30733. * display array
  30734. * @param {int} end Index for the current display ending point in the
  30735. * display array
  30736. * @param {array int} display Index array to translate the visual position
  30737. * to the full data array
  30738. *
  30739. * @dtopt Callbacks
  30740. * @name DataTable.defaults.headerCallback
  30741. *
  30742. * @example
  30743. * $(document).ready( function() {
  30744. * $('#example').dataTable( {
  30745. * "fheaderCallback": function( head, data, start, end, display ) {
  30746. * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
  30747. * }
  30748. * } );
  30749. * } )
  30750. */
  30751. "fnHeaderCallback": null,
  30752. /**
  30753. * The information element can be used to convey information about the current
  30754. * state of the table. Although the internationalisation options presented by
  30755. * DataTables are quite capable of dealing with most customisations, there may
  30756. * be times where you wish to customise the string further. This callback
  30757. * allows you to do exactly that.
  30758. * @type function
  30759. * @param {object} oSettings DataTables settings object
  30760. * @param {int} start Starting position in data for the draw
  30761. * @param {int} end End position in data for the draw
  30762. * @param {int} max Total number of rows in the table (regardless of
  30763. * filtering)
  30764. * @param {int} total Total number of rows in the data set, after filtering
  30765. * @param {string} pre The string that DataTables has formatted using it's
  30766. * own rules
  30767. * @returns {string} The string to be displayed in the information element.
  30768. *
  30769. * @dtopt Callbacks
  30770. * @name DataTable.defaults.infoCallback
  30771. *
  30772. * @example
  30773. * $('#example').dataTable( {
  30774. * "infoCallback": function( settings, start, end, max, total, pre ) {
  30775. * return start +" to "+ end;
  30776. * }
  30777. * } );
  30778. */
  30779. "fnInfoCallback": null,
  30780. /**
  30781. * Called when the table has been initialised. Normally DataTables will
  30782. * initialise sequentially and there will be no need for this function,
  30783. * however, this does not hold true when using external language information
  30784. * since that is obtained using an async XHR call.
  30785. * @type function
  30786. * @param {object} settings DataTables settings object
  30787. * @param {object} json The JSON object request from the server - only
  30788. * present if client-side Ajax sourced data is used
  30789. *
  30790. * @dtopt Callbacks
  30791. * @name DataTable.defaults.initComplete
  30792. *
  30793. * @example
  30794. * $(document).ready( function() {
  30795. * $('#example').dataTable( {
  30796. * "initComplete": function(settings, json) {
  30797. * alert( 'DataTables has finished its initialisation.' );
  30798. * }
  30799. * } );
  30800. * } )
  30801. */
  30802. "fnInitComplete": null,
  30803. /**
  30804. * Called at the very start of each table draw and can be used to cancel the
  30805. * draw by returning false, any other return (including undefined) results in
  30806. * the full draw occurring).
  30807. * @type function
  30808. * @param {object} settings DataTables settings object
  30809. * @returns {boolean} False will cancel the draw, anything else (including no
  30810. * return) will allow it to complete.
  30811. *
  30812. * @dtopt Callbacks
  30813. * @name DataTable.defaults.preDrawCallback
  30814. *
  30815. * @example
  30816. * $(document).ready( function() {
  30817. * $('#example').dataTable( {
  30818. * "preDrawCallback": function( settings ) {
  30819. * if ( $('#test').val() == 1 ) {
  30820. * return false;
  30821. * }
  30822. * }
  30823. * } );
  30824. * } );
  30825. */
  30826. "fnPreDrawCallback": null,
  30827. /**
  30828. * This function allows you to 'post process' each row after it have been
  30829. * generated for each table draw, but before it is rendered on screen. This
  30830. * function might be used for setting the row class name etc.
  30831. * @type function
  30832. * @param {node} row "TR" element for the current row
  30833. * @param {array} data Raw data array for this row
  30834. * @param {int} displayIndex The display index for the current table draw
  30835. * @param {int} displayIndexFull The index of the data in the full list of
  30836. * rows (after filtering)
  30837. *
  30838. * @dtopt Callbacks
  30839. * @name DataTable.defaults.rowCallback
  30840. *
  30841. * @example
  30842. * $(document).ready( function() {
  30843. * $('#example').dataTable( {
  30844. * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
  30845. * // Bold the grade for all 'A' grade browsers
  30846. * if ( data[4] == "A" ) {
  30847. * $('td:eq(4)', row).html( '<b>A</b>' );
  30848. * }
  30849. * }
  30850. * } );
  30851. * } );
  30852. */
  30853. "fnRowCallback": null,
  30854. /**
  30855. * __Deprecated__ The functionality provided by this parameter has now been
  30856. * superseded by that provided through `ajax`, which should be used instead.
  30857. *
  30858. * This parameter allows you to override the default function which obtains
  30859. * the data from the server so something more suitable for your application.
  30860. * For example you could use POST data, or pull information from a Gears or
  30861. * AIR database.
  30862. * @type function
  30863. * @member
  30864. * @param {string} source HTTP source to obtain the data from (`ajax`)
  30865. * @param {array} data A key/value pair object containing the data to send
  30866. * to the server
  30867. * @param {function} callback to be called on completion of the data get
  30868. * process that will draw the data on the page.
  30869. * @param {object} settings DataTables settings object
  30870. *
  30871. * @dtopt Callbacks
  30872. * @dtopt Server-side
  30873. * @name DataTable.defaults.serverData
  30874. *
  30875. * @deprecated 1.10. Please use `ajax` for this functionality now.
  30876. */
  30877. "fnServerData": null,
  30878. /**
  30879. * __Deprecated__ The functionality provided by this parameter has now been
  30880. * superseded by that provided through `ajax`, which should be used instead.
  30881. *
  30882. * It is often useful to send extra data to the server when making an Ajax
  30883. * request - for example custom filtering information, and this callback
  30884. * function makes it trivial to send extra information to the server. The
  30885. * passed in parameter is the data set that has been constructed by
  30886. * DataTables, and you can add to this or modify it as you require.
  30887. * @type function
  30888. * @param {array} data Data array (array of objects which are name/value
  30889. * pairs) that has been constructed by DataTables and will be sent to the
  30890. * server. In the case of Ajax sourced data with server-side processing
  30891. * this will be an empty array, for server-side processing there will be a
  30892. * significant number of parameters!
  30893. * @returns {undefined} Ensure that you modify the data array passed in,
  30894. * as this is passed by reference.
  30895. *
  30896. * @dtopt Callbacks
  30897. * @dtopt Server-side
  30898. * @name DataTable.defaults.serverParams
  30899. *
  30900. * @deprecated 1.10. Please use `ajax` for this functionality now.
  30901. */
  30902. "fnServerParams": null,
  30903. /**
  30904. * Load the table state. With this function you can define from where, and how, the
  30905. * state of a table is loaded. By default DataTables will load from `localStorage`
  30906. * but you might wish to use a server-side database or cookies.
  30907. * @type function
  30908. * @member
  30909. * @param {object} settings DataTables settings object
  30910. * @return {object} The DataTables state object to be loaded
  30911. *
  30912. * @dtopt Callbacks
  30913. * @name DataTable.defaults.stateLoadCallback
  30914. *
  30915. * @example
  30916. * $(document).ready( function() {
  30917. * $('#example').dataTable( {
  30918. * "stateSave": true,
  30919. * "stateLoadCallback": function (settings) {
  30920. * var o;
  30921. *
  30922. * // Send an Ajax request to the server to get the data. Note that
  30923. * // this is a synchronous request.
  30924. * $.ajax( {
  30925. * "url": "/state_load",
  30926. * "async": false,
  30927. * "dataType": "json",
  30928. * "success": function (json) {
  30929. * o = json;
  30930. * }
  30931. * } );
  30932. *
  30933. * return o;
  30934. * }
  30935. * } );
  30936. * } );
  30937. */
  30938. "fnStateLoadCallback": function ( settings ) {
  30939. try {
  30940. return JSON.parse(
  30941. (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
  30942. 'DataTables_'+settings.sInstance+'_'+location.pathname
  30943. )
  30944. );
  30945. } catch (e) {}
  30946. },
  30947. /**
  30948. * Callback which allows modification of the saved state prior to loading that state.
  30949. * This callback is called when the table is loading state from the stored data, but
  30950. * prior to the settings object being modified by the saved state. Note that for
  30951. * plug-in authors, you should use the `stateLoadParams` event to load parameters for
  30952. * a plug-in.
  30953. * @type function
  30954. * @param {object} settings DataTables settings object
  30955. * @param {object} data The state object that is to be loaded
  30956. *
  30957. * @dtopt Callbacks
  30958. * @name DataTable.defaults.stateLoadParams
  30959. *
  30960. * @example
  30961. * // Remove a saved filter, so filtering is never loaded
  30962. * $(document).ready( function() {
  30963. * $('#example').dataTable( {
  30964. * "stateSave": true,
  30965. * "stateLoadParams": function (settings, data) {
  30966. * data.oSearch.sSearch = "";
  30967. * }
  30968. * } );
  30969. * } );
  30970. *
  30971. * @example
  30972. * // Disallow state loading by returning false
  30973. * $(document).ready( function() {
  30974. * $('#example').dataTable( {
  30975. * "stateSave": true,
  30976. * "stateLoadParams": function (settings, data) {
  30977. * return false;
  30978. * }
  30979. * } );
  30980. * } );
  30981. */
  30982. "fnStateLoadParams": null,
  30983. /**
  30984. * Callback that is called when the state has been loaded from the state saving method
  30985. * and the DataTables settings object has been modified as a result of the loaded state.
  30986. * @type function
  30987. * @param {object} settings DataTables settings object
  30988. * @param {object} data The state object that was loaded
  30989. *
  30990. * @dtopt Callbacks
  30991. * @name DataTable.defaults.stateLoaded
  30992. *
  30993. * @example
  30994. * // Show an alert with the filtering value that was saved
  30995. * $(document).ready( function() {
  30996. * $('#example').dataTable( {
  30997. * "stateSave": true,
  30998. * "stateLoaded": function (settings, data) {
  30999. * alert( 'Saved filter was: '+data.oSearch.sSearch );
  31000. * }
  31001. * } );
  31002. * } );
  31003. */
  31004. "fnStateLoaded": null,
  31005. /**
  31006. * Save the table state. This function allows you to define where and how the state
  31007. * information for the table is stored By default DataTables will use `localStorage`
  31008. * but you might wish to use a server-side database or cookies.
  31009. * @type function
  31010. * @member
  31011. * @param {object} settings DataTables settings object
  31012. * @param {object} data The state object to be saved
  31013. *
  31014. * @dtopt Callbacks
  31015. * @name DataTable.defaults.stateSaveCallback
  31016. *
  31017. * @example
  31018. * $(document).ready( function() {
  31019. * $('#example').dataTable( {
  31020. * "stateSave": true,
  31021. * "stateSaveCallback": function (settings, data) {
  31022. * // Send an Ajax request to the server with the state object
  31023. * $.ajax( {
  31024. * "url": "/state_save",
  31025. * "data": data,
  31026. * "dataType": "json",
  31027. * "method": "POST"
  31028. * "success": function () {}
  31029. * } );
  31030. * }
  31031. * } );
  31032. * } );
  31033. */
  31034. "fnStateSaveCallback": function ( settings, data ) {
  31035. try {
  31036. (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
  31037. 'DataTables_'+settings.sInstance+'_'+location.pathname,
  31038. JSON.stringify( data )
  31039. );
  31040. } catch (e) {}
  31041. },
  31042. /**
  31043. * Callback which allows modification of the state to be saved. Called when the table
  31044. * has changed state a new state save is required. This method allows modification of
  31045. * the state saving object prior to actually doing the save, including addition or
  31046. * other state properties or modification. Note that for plug-in authors, you should
  31047. * use the `stateSaveParams` event to save parameters for a plug-in.
  31048. * @type function
  31049. * @param {object} settings DataTables settings object
  31050. * @param {object} data The state object to be saved
  31051. *
  31052. * @dtopt Callbacks
  31053. * @name DataTable.defaults.stateSaveParams
  31054. *
  31055. * @example
  31056. * // Remove a saved filter, so filtering is never saved
  31057. * $(document).ready( function() {
  31058. * $('#example').dataTable( {
  31059. * "stateSave": true,
  31060. * "stateSaveParams": function (settings, data) {
  31061. * data.oSearch.sSearch = "";
  31062. * }
  31063. * } );
  31064. * } );
  31065. */
  31066. "fnStateSaveParams": null,
  31067. /**
  31068. * Duration for which the saved state information is considered valid. After this period
  31069. * has elapsed the state will be returned to the default.
  31070. * Value is given in seconds.
  31071. * @type int
  31072. * @default 7200 <i>(2 hours)</i>
  31073. *
  31074. * @dtopt Options
  31075. * @name DataTable.defaults.stateDuration
  31076. *
  31077. * @example
  31078. * $(document).ready( function() {
  31079. * $('#example').dataTable( {
  31080. * "stateDuration": 60*60*24; // 1 day
  31081. * } );
  31082. * } )
  31083. */
  31084. "iStateDuration": 7200,
  31085. /**
  31086. * When enabled DataTables will not make a request to the server for the first
  31087. * page draw - rather it will use the data already on the page (no sorting etc
  31088. * will be applied to it), thus saving on an XHR at load time. `deferLoading`
  31089. * is used to indicate that deferred loading is required, but it is also used
  31090. * to tell DataTables how many records there are in the full table (allowing
  31091. * the information element and pagination to be displayed correctly). In the case
  31092. * where a filtering is applied to the table on initial load, this can be
  31093. * indicated by giving the parameter as an array, where the first element is
  31094. * the number of records available after filtering and the second element is the
  31095. * number of records without filtering (allowing the table information element
  31096. * to be shown correctly).
  31097. * @type int | array
  31098. * @default null
  31099. *
  31100. * @dtopt Options
  31101. * @name DataTable.defaults.deferLoading
  31102. *
  31103. * @example
  31104. * // 57 records available in the table, no filtering applied
  31105. * $(document).ready( function() {
  31106. * $('#example').dataTable( {
  31107. * "serverSide": true,
  31108. * "ajax": "scripts/server_processing.php",
  31109. * "deferLoading": 57
  31110. * } );
  31111. * } );
  31112. *
  31113. * @example
  31114. * // 57 records after filtering, 100 without filtering (an initial filter applied)
  31115. * $(document).ready( function() {
  31116. * $('#example').dataTable( {
  31117. * "serverSide": true,
  31118. * "ajax": "scripts/server_processing.php",
  31119. * "deferLoading": [ 57, 100 ],
  31120. * "search": {
  31121. * "search": "my_filter"
  31122. * }
  31123. * } );
  31124. * } );
  31125. */
  31126. "iDeferLoading": null,
  31127. /**
  31128. * Number of rows to display on a single page when using pagination. If
  31129. * feature enabled (`lengthChange`) then the end user will be able to override
  31130. * this to a custom setting using a pop-up menu.
  31131. * @type int
  31132. * @default 10
  31133. *
  31134. * @dtopt Options
  31135. * @name DataTable.defaults.pageLength
  31136. *
  31137. * @example
  31138. * $(document).ready( function() {
  31139. * $('#example').dataTable( {
  31140. * "pageLength": 50
  31141. * } );
  31142. * } )
  31143. */
  31144. "iDisplayLength": 10,
  31145. /**
  31146. * Define the starting point for data display when using DataTables with
  31147. * pagination. Note that this parameter is the number of records, rather than
  31148. * the page number, so if you have 10 records per page and want to start on
  31149. * the third page, it should be "20".
  31150. * @type int
  31151. * @default 0
  31152. *
  31153. * @dtopt Options
  31154. * @name DataTable.defaults.displayStart
  31155. *
  31156. * @example
  31157. * $(document).ready( function() {
  31158. * $('#example').dataTable( {
  31159. * "displayStart": 20
  31160. * } );
  31161. * } )
  31162. */
  31163. "iDisplayStart": 0,
  31164. /**
  31165. * By default DataTables allows keyboard navigation of the table (sorting, paging,
  31166. * and filtering) by adding a `tabindex` attribute to the required elements. This
  31167. * allows you to tab through the controls and press the enter key to activate them.
  31168. * The tabindex is default 0, meaning that the tab follows the flow of the document.
  31169. * You can overrule this using this parameter if you wish. Use a value of -1 to
  31170. * disable built-in keyboard navigation.
  31171. * @type int
  31172. * @default 0
  31173. *
  31174. * @dtopt Options
  31175. * @name DataTable.defaults.tabIndex
  31176. *
  31177. * @example
  31178. * $(document).ready( function() {
  31179. * $('#example').dataTable( {
  31180. * "tabIndex": 1
  31181. * } );
  31182. * } );
  31183. */
  31184. "iTabIndex": 0,
  31185. /**
  31186. * Classes that DataTables assigns to the various components and features
  31187. * that it adds to the HTML table. This allows classes to be configured
  31188. * during initialisation in addition to through the static
  31189. * {@link DataTable.ext.oStdClasses} object).
  31190. * @namespace
  31191. * @name DataTable.defaults.classes
  31192. */
  31193. "oClasses": {},
  31194. /**
  31195. * All strings that DataTables uses in the user interface that it creates
  31196. * are defined in this object, allowing you to modified them individually or
  31197. * completely replace them all as required.
  31198. * @namespace
  31199. * @name DataTable.defaults.language
  31200. */
  31201. "oLanguage": {
  31202. /**
  31203. * Strings that are used for WAI-ARIA labels and controls only (these are not
  31204. * actually visible on the page, but will be read by screenreaders, and thus
  31205. * must be internationalised as well).
  31206. * @namespace
  31207. * @name DataTable.defaults.language.aria
  31208. */
  31209. "oAria": {
  31210. /**
  31211. * ARIA label that is added to the table headers when the column may be
  31212. * sorted ascending by activing the column (click or return when focused).
  31213. * Note that the column header is prefixed to this string.
  31214. * @type string
  31215. * @default : activate to sort column ascending
  31216. *
  31217. * @dtopt Language
  31218. * @name DataTable.defaults.language.aria.sortAscending
  31219. *
  31220. * @example
  31221. * $(document).ready( function() {
  31222. * $('#example').dataTable( {
  31223. * "language": {
  31224. * "aria": {
  31225. * "sortAscending": " - click/return to sort ascending"
  31226. * }
  31227. * }
  31228. * } );
  31229. * } );
  31230. */
  31231. "sSortAscending": ": activate to sort column ascending",
  31232. /**
  31233. * ARIA label that is added to the table headers when the column may be
  31234. * sorted descending by activing the column (click or return when focused).
  31235. * Note that the column header is prefixed to this string.
  31236. * @type string
  31237. * @default : activate to sort column ascending
  31238. *
  31239. * @dtopt Language
  31240. * @name DataTable.defaults.language.aria.sortDescending
  31241. *
  31242. * @example
  31243. * $(document).ready( function() {
  31244. * $('#example').dataTable( {
  31245. * "language": {
  31246. * "aria": {
  31247. * "sortDescending": " - click/return to sort descending"
  31248. * }
  31249. * }
  31250. * } );
  31251. * } );
  31252. */
  31253. "sSortDescending": ": activate to sort column descending"
  31254. },
  31255. /**
  31256. * Pagination string used by DataTables for the built-in pagination
  31257. * control types.
  31258. * @namespace
  31259. * @name DataTable.defaults.language.paginate
  31260. */
  31261. "oPaginate": {
  31262. /**
  31263. * Text to use when using the 'full_numbers' type of pagination for the
  31264. * button to take the user to the first page.
  31265. * @type string
  31266. * @default First
  31267. *
  31268. * @dtopt Language
  31269. * @name DataTable.defaults.language.paginate.first
  31270. *
  31271. * @example
  31272. * $(document).ready( function() {
  31273. * $('#example').dataTable( {
  31274. * "language": {
  31275. * "paginate": {
  31276. * "first": "First page"
  31277. * }
  31278. * }
  31279. * } );
  31280. * } );
  31281. */
  31282. "sFirst": "First",
  31283. /**
  31284. * Text to use when using the 'full_numbers' type of pagination for the
  31285. * button to take the user to the last page.
  31286. * @type string
  31287. * @default Last
  31288. *
  31289. * @dtopt Language
  31290. * @name DataTable.defaults.language.paginate.last
  31291. *
  31292. * @example
  31293. * $(document).ready( function() {
  31294. * $('#example').dataTable( {
  31295. * "language": {
  31296. * "paginate": {
  31297. * "last": "Last page"
  31298. * }
  31299. * }
  31300. * } );
  31301. * } );
  31302. */
  31303. "sLast": "Last",
  31304. /**
  31305. * Text to use for the 'next' pagination button (to take the user to the
  31306. * next page).
  31307. * @type string
  31308. * @default Next
  31309. *
  31310. * @dtopt Language
  31311. * @name DataTable.defaults.language.paginate.next
  31312. *
  31313. * @example
  31314. * $(document).ready( function() {
  31315. * $('#example').dataTable( {
  31316. * "language": {
  31317. * "paginate": {
  31318. * "next": "Next page"
  31319. * }
  31320. * }
  31321. * } );
  31322. * } );
  31323. */
  31324. "sNext": "Next",
  31325. /**
  31326. * Text to use for the 'previous' pagination button (to take the user to
  31327. * the previous page).
  31328. * @type string
  31329. * @default Previous
  31330. *
  31331. * @dtopt Language
  31332. * @name DataTable.defaults.language.paginate.previous
  31333. *
  31334. * @example
  31335. * $(document).ready( function() {
  31336. * $('#example').dataTable( {
  31337. * "language": {
  31338. * "paginate": {
  31339. * "previous": "Previous page"
  31340. * }
  31341. * }
  31342. * } );
  31343. * } );
  31344. */
  31345. "sPrevious": "Previous"
  31346. },
  31347. /**
  31348. * This string is shown in preference to `zeroRecords` when the table is
  31349. * empty of data (regardless of filtering). Note that this is an optional
  31350. * parameter - if it is not given, the value of `zeroRecords` will be used
  31351. * instead (either the default or given value).
  31352. * @type string
  31353. * @default No data available in table
  31354. *
  31355. * @dtopt Language
  31356. * @name DataTable.defaults.language.emptyTable
  31357. *
  31358. * @example
  31359. * $(document).ready( function() {
  31360. * $('#example').dataTable( {
  31361. * "language": {
  31362. * "emptyTable": "No data available in table"
  31363. * }
  31364. * } );
  31365. * } );
  31366. */
  31367. "sEmptyTable": "No data available in table",
  31368. /**
  31369. * This string gives information to the end user about the information
  31370. * that is current on display on the page. The following tokens can be
  31371. * used in the string and will be dynamically replaced as the table
  31372. * display updates. This tokens can be placed anywhere in the string, or
  31373. * removed as needed by the language requires:
  31374. *
  31375. * * `\_START\_` - Display index of the first record on the current page
  31376. * * `\_END\_` - Display index of the last record on the current page
  31377. * * `\_TOTAL\_` - Number of records in the table after filtering
  31378. * * `\_MAX\_` - Number of records in the table without filtering
  31379. * * `\_PAGE\_` - Current page number
  31380. * * `\_PAGES\_` - Total number of pages of data in the table
  31381. *
  31382. * @type string
  31383. * @default Showing _START_ to _END_ of _TOTAL_ entries
  31384. *
  31385. * @dtopt Language
  31386. * @name DataTable.defaults.language.info
  31387. *
  31388. * @example
  31389. * $(document).ready( function() {
  31390. * $('#example').dataTable( {
  31391. * "language": {
  31392. * "info": "Showing page _PAGE_ of _PAGES_"
  31393. * }
  31394. * } );
  31395. * } );
  31396. */
  31397. "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
  31398. /**
  31399. * Display information string for when the table is empty. Typically the
  31400. * format of this string should match `info`.
  31401. * @type string
  31402. * @default Showing 0 to 0 of 0 entries
  31403. *
  31404. * @dtopt Language
  31405. * @name DataTable.defaults.language.infoEmpty
  31406. *
  31407. * @example
  31408. * $(document).ready( function() {
  31409. * $('#example').dataTable( {
  31410. * "language": {
  31411. * "infoEmpty": "No entries to show"
  31412. * }
  31413. * } );
  31414. * } );
  31415. */
  31416. "sInfoEmpty": "Showing 0 to 0 of 0 entries",
  31417. /**
  31418. * When a user filters the information in a table, this string is appended
  31419. * to the information (`info`) to give an idea of how strong the filtering
  31420. * is. The variable _MAX_ is dynamically updated.
  31421. * @type string
  31422. * @default (filtered from _MAX_ total entries)
  31423. *
  31424. * @dtopt Language
  31425. * @name DataTable.defaults.language.infoFiltered
  31426. *
  31427. * @example
  31428. * $(document).ready( function() {
  31429. * $('#example').dataTable( {
  31430. * "language": {
  31431. * "infoFiltered": " - filtering from _MAX_ records"
  31432. * }
  31433. * } );
  31434. * } );
  31435. */
  31436. "sInfoFiltered": "(filtered from _MAX_ total entries)",
  31437. /**
  31438. * If can be useful to append extra information to the info string at times,
  31439. * and this variable does exactly that. This information will be appended to
  31440. * the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
  31441. * being used) at all times.
  31442. * @type string
  31443. * @default <i>Empty string</i>
  31444. *
  31445. * @dtopt Language
  31446. * @name DataTable.defaults.language.infoPostFix
  31447. *
  31448. * @example
  31449. * $(document).ready( function() {
  31450. * $('#example').dataTable( {
  31451. * "language": {
  31452. * "infoPostFix": "All records shown are derived from real information."
  31453. * }
  31454. * } );
  31455. * } );
  31456. */
  31457. "sInfoPostFix": "",
  31458. /**
  31459. * This decimal place operator is a little different from the other
  31460. * language options since DataTables doesn't output floating point
  31461. * numbers, so it won't ever use this for display of a number. Rather,
  31462. * what this parameter does is modify the sort methods of the table so
  31463. * that numbers which are in a format which has a character other than
  31464. * a period (`.`) as a decimal place will be sorted numerically.
  31465. *
  31466. * Note that numbers with different decimal places cannot be shown in
  31467. * the same table and still be sortable, the table must be consistent.
  31468. * However, multiple different tables on the page can use different
  31469. * decimal place characters.
  31470. * @type string
  31471. * @default
  31472. *
  31473. * @dtopt Language
  31474. * @name DataTable.defaults.language.decimal
  31475. *
  31476. * @example
  31477. * $(document).ready( function() {
  31478. * $('#example').dataTable( {
  31479. * "language": {
  31480. * "decimal": ","
  31481. * "thousands": "."
  31482. * }
  31483. * } );
  31484. * } );
  31485. */
  31486. "sDecimal": "",
  31487. /**
  31488. * DataTables has a build in number formatter (`formatNumber`) which is
  31489. * used to format large numbers that are used in the table information.
  31490. * By default a comma is used, but this can be trivially changed to any
  31491. * character you wish with this parameter.
  31492. * @type string
  31493. * @default ,
  31494. *
  31495. * @dtopt Language
  31496. * @name DataTable.defaults.language.thousands
  31497. *
  31498. * @example
  31499. * $(document).ready( function() {
  31500. * $('#example').dataTable( {
  31501. * "language": {
  31502. * "thousands": "'"
  31503. * }
  31504. * } );
  31505. * } );
  31506. */
  31507. "sThousands": ",",
  31508. /**
  31509. * Detail the action that will be taken when the drop down menu for the
  31510. * pagination length option is changed. The '_MENU_' variable is replaced
  31511. * with a default select list of 10, 25, 50 and 100, and can be replaced
  31512. * with a custom select box if required.
  31513. * @type string
  31514. * @default Show _MENU_ entries
  31515. *
  31516. * @dtopt Language
  31517. * @name DataTable.defaults.language.lengthMenu
  31518. *
  31519. * @example
  31520. * // Language change only
  31521. * $(document).ready( function() {
  31522. * $('#example').dataTable( {
  31523. * "language": {
  31524. * "lengthMenu": "Display _MENU_ records"
  31525. * }
  31526. * } );
  31527. * } );
  31528. *
  31529. * @example
  31530. * // Language and options change
  31531. * $(document).ready( function() {
  31532. * $('#example').dataTable( {
  31533. * "language": {
  31534. * "lengthMenu": 'Display <select>'+
  31535. * '<option value="10">10</option>'+
  31536. * '<option value="20">20</option>'+
  31537. * '<option value="30">30</option>'+
  31538. * '<option value="40">40</option>'+
  31539. * '<option value="50">50</option>'+
  31540. * '<option value="-1">All</option>'+
  31541. * '</select> records'
  31542. * }
  31543. * } );
  31544. * } );
  31545. */
  31546. "sLengthMenu": "Show _MENU_ entries",
  31547. /**
  31548. * When using Ajax sourced data and during the first draw when DataTables is
  31549. * gathering the data, this message is shown in an empty row in the table to
  31550. * indicate to the end user the the data is being loaded. Note that this
  31551. * parameter is not used when loading data by server-side processing, just
  31552. * Ajax sourced data with client-side processing.
  31553. * @type string
  31554. * @default Loading...
  31555. *
  31556. * @dtopt Language
  31557. * @name DataTable.defaults.language.loadingRecords
  31558. *
  31559. * @example
  31560. * $(document).ready( function() {
  31561. * $('#example').dataTable( {
  31562. * "language": {
  31563. * "loadingRecords": "Please wait - loading..."
  31564. * }
  31565. * } );
  31566. * } );
  31567. */
  31568. "sLoadingRecords": "Loading...",
  31569. /**
  31570. * Text which is displayed when the table is processing a user action
  31571. * (usually a sort command or similar).
  31572. * @type string
  31573. * @default Processing...
  31574. *
  31575. * @dtopt Language
  31576. * @name DataTable.defaults.language.processing
  31577. *
  31578. * @example
  31579. * $(document).ready( function() {
  31580. * $('#example').dataTable( {
  31581. * "language": {
  31582. * "processing": "DataTables is currently busy"
  31583. * }
  31584. * } );
  31585. * } );
  31586. */
  31587. "sProcessing": "Processing...",
  31588. /**
  31589. * Details the actions that will be taken when the user types into the
  31590. * filtering input text box. The variable "_INPUT_", if used in the string,
  31591. * is replaced with the HTML text box for the filtering input allowing
  31592. * control over where it appears in the string. If "_INPUT_" is not given
  31593. * then the input box is appended to the string automatically.
  31594. * @type string
  31595. * @default Search:
  31596. *
  31597. * @dtopt Language
  31598. * @name DataTable.defaults.language.search
  31599. *
  31600. * @example
  31601. * // Input text box will be appended at the end automatically
  31602. * $(document).ready( function() {
  31603. * $('#example').dataTable( {
  31604. * "language": {
  31605. * "search": "Filter records:"
  31606. * }
  31607. * } );
  31608. * } );
  31609. *
  31610. * @example
  31611. * // Specify where the filter should appear
  31612. * $(document).ready( function() {
  31613. * $('#example').dataTable( {
  31614. * "language": {
  31615. * "search": "Apply filter _INPUT_ to table"
  31616. * }
  31617. * } );
  31618. * } );
  31619. */
  31620. "sSearch": "Search:",
  31621. /**
  31622. * Assign a `placeholder` attribute to the search `input` element
  31623. * @type string
  31624. * @default
  31625. *
  31626. * @dtopt Language
  31627. * @name DataTable.defaults.language.searchPlaceholder
  31628. */
  31629. "sSearchPlaceholder": "",
  31630. /**
  31631. * All of the language information can be stored in a file on the
  31632. * server-side, which DataTables will look up if this parameter is passed.
  31633. * It must store the URL of the language file, which is in a JSON format,
  31634. * and the object has the same properties as the oLanguage object in the
  31635. * initialiser object (i.e. the above parameters). Please refer to one of
  31636. * the example language files to see how this works in action.
  31637. * @type string
  31638. * @default <i>Empty string - i.e. disabled</i>
  31639. *
  31640. * @dtopt Language
  31641. * @name DataTable.defaults.language.url
  31642. *
  31643. * @example
  31644. * $(document).ready( function() {
  31645. * $('#example').dataTable( {
  31646. * "language": {
  31647. * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
  31648. * }
  31649. * } );
  31650. * } );
  31651. */
  31652. "sUrl": "",
  31653. /**
  31654. * Text shown inside the table records when the is no information to be
  31655. * displayed after filtering. `emptyTable` is shown when there is simply no
  31656. * information in the table at all (regardless of filtering).
  31657. * @type string
  31658. * @default No matching records found
  31659. *
  31660. * @dtopt Language
  31661. * @name DataTable.defaults.language.zeroRecords
  31662. *
  31663. * @example
  31664. * $(document).ready( function() {
  31665. * $('#example').dataTable( {
  31666. * "language": {
  31667. * "zeroRecords": "No records to display"
  31668. * }
  31669. * } );
  31670. * } );
  31671. */
  31672. "sZeroRecords": "No matching records found"
  31673. },
  31674. /**
  31675. * This parameter allows you to have define the global filtering state at
  31676. * initialisation time. As an object the `search` parameter must be
  31677. * defined, but all other parameters are optional. When `regex` is true,
  31678. * the search string will be treated as a regular expression, when false
  31679. * (default) it will be treated as a straight string. When `smart`
  31680. * DataTables will use it's smart filtering methods (to word match at
  31681. * any point in the data), when false this will not be done.
  31682. * @namespace
  31683. * @extends DataTable.models.oSearch
  31684. *
  31685. * @dtopt Options
  31686. * @name DataTable.defaults.search
  31687. *
  31688. * @example
  31689. * $(document).ready( function() {
  31690. * $('#example').dataTable( {
  31691. * "search": {"search": "Initial search"}
  31692. * } );
  31693. * } )
  31694. */
  31695. "oSearch": $.extend( {}, DataTable.models.oSearch ),
  31696. /**
  31697. * __Deprecated__ The functionality provided by this parameter has now been
  31698. * superseded by that provided through `ajax`, which should be used instead.
  31699. *
  31700. * By default DataTables will look for the property `data` (or `aaData` for
  31701. * compatibility with DataTables 1.9-) when obtaining data from an Ajax
  31702. * source or for server-side processing - this parameter allows that
  31703. * property to be changed. You can use Javascript dotted object notation to
  31704. * get a data source for multiple levels of nesting.
  31705. * @type string
  31706. * @default data
  31707. *
  31708. * @dtopt Options
  31709. * @dtopt Server-side
  31710. * @name DataTable.defaults.ajaxDataProp
  31711. *
  31712. * @deprecated 1.10. Please use `ajax` for this functionality now.
  31713. */
  31714. "sAjaxDataProp": "data",
  31715. /**
  31716. * __Deprecated__ The functionality provided by this parameter has now been
  31717. * superseded by that provided through `ajax`, which should be used instead.
  31718. *
  31719. * You can instruct DataTables to load data from an external
  31720. * source using this parameter (use aData if you want to pass data in you
  31721. * already have). Simply provide a url a JSON object can be obtained from.
  31722. * @type string
  31723. * @default null
  31724. *
  31725. * @dtopt Options
  31726. * @dtopt Server-side
  31727. * @name DataTable.defaults.ajaxSource
  31728. *
  31729. * @deprecated 1.10. Please use `ajax` for this functionality now.
  31730. */
  31731. "sAjaxSource": null,
  31732. /**
  31733. * This initialisation variable allows you to specify exactly where in the
  31734. * DOM you want DataTables to inject the various controls it adds to the page
  31735. * (for example you might want the pagination controls at the top of the
  31736. * table). DIV elements (with or without a custom class) can also be added to
  31737. * aid styling. The follow syntax is used:
  31738. * <ul>
  31739. * <li>The following options are allowed:
  31740. * <ul>
  31741. * <li>'l' - Length changing</li>
  31742. * <li>'f' - Filtering input</li>
  31743. * <li>'t' - The table!</li>
  31744. * <li>'i' - Information</li>
  31745. * <li>'p' - Pagination</li>
  31746. * <li>'r' - pRocessing</li>
  31747. * </ul>
  31748. * </li>
  31749. * <li>The following constants are allowed:
  31750. * <ul>
  31751. * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
  31752. * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
  31753. * </ul>
  31754. * </li>
  31755. * <li>The following syntax is expected:
  31756. * <ul>
  31757. * <li>'&lt;' and '&gt;' - div elements</li>
  31758. * <li>'&lt;"class" and '&gt;' - div with a class</li>
  31759. * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
  31760. * </ul>
  31761. * </li>
  31762. * <li>Examples:
  31763. * <ul>
  31764. * <li>'&lt;"wrapper"flipt&gt;'</li>
  31765. * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
  31766. * </ul>
  31767. * </li>
  31768. * </ul>
  31769. * @type string
  31770. * @default lfrtip <i>(when `jQueryUI` is false)</i> <b>or</b>
  31771. * <"H"lfr>t<"F"ip> <i>(when `jQueryUI` is true)</i>
  31772. *
  31773. * @dtopt Options
  31774. * @name DataTable.defaults.dom
  31775. *
  31776. * @example
  31777. * $(document).ready( function() {
  31778. * $('#example').dataTable( {
  31779. * "dom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
  31780. * } );
  31781. * } );
  31782. */
  31783. "sDom": "lfrtip",
  31784. /**
  31785. * Search delay option. This will throttle full table searches that use the
  31786. * DataTables provided search input element (it does not effect calls to
  31787. * `dt-api search()`, providing a delay before the search is made.
  31788. * @type integer
  31789. * @default 0
  31790. *
  31791. * @dtopt Options
  31792. * @name DataTable.defaults.searchDelay
  31793. *
  31794. * @example
  31795. * $(document).ready( function() {
  31796. * $('#example').dataTable( {
  31797. * "searchDelay": 200
  31798. * } );
  31799. * } )
  31800. */
  31801. "searchDelay": null,
  31802. /**
  31803. * DataTables features four different built-in options for the buttons to
  31804. * display for pagination control:
  31805. *
  31806. * * `simple` - 'Previous' and 'Next' buttons only
  31807. * * 'simple_numbers` - 'Previous' and 'Next' buttons, plus page numbers
  31808. * * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
  31809. * * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus
  31810. * page numbers
  31811. *
  31812. * Further methods can be added using {@link DataTable.ext.oPagination}.
  31813. * @type string
  31814. * @default simple_numbers
  31815. *
  31816. * @dtopt Options
  31817. * @name DataTable.defaults.pagingType
  31818. *
  31819. * @example
  31820. * $(document).ready( function() {
  31821. * $('#example').dataTable( {
  31822. * "pagingType": "full_numbers"
  31823. * } );
  31824. * } )
  31825. */
  31826. "sPaginationType": "simple_numbers",
  31827. /**
  31828. * Enable horizontal scrolling. When a table is too wide to fit into a
  31829. * certain layout, or you have a large number of columns in the table, you
  31830. * can enable x-scrolling to show the table in a viewport, which can be
  31831. * scrolled. This property can be `true` which will allow the table to
  31832. * scroll horizontally when needed, or any CSS unit, or a number (in which
  31833. * case it will be treated as a pixel measurement). Setting as simply `true`
  31834. * is recommended.
  31835. * @type boolean|string
  31836. * @default <i>blank string - i.e. disabled</i>
  31837. *
  31838. * @dtopt Features
  31839. * @name DataTable.defaults.scrollX
  31840. *
  31841. * @example
  31842. * $(document).ready( function() {
  31843. * $('#example').dataTable( {
  31844. * "scrollX": true,
  31845. * "scrollCollapse": true
  31846. * } );
  31847. * } );
  31848. */
  31849. "sScrollX": "",
  31850. /**
  31851. * This property can be used to force a DataTable to use more width than it
  31852. * might otherwise do when x-scrolling is enabled. For example if you have a
  31853. * table which requires to be well spaced, this parameter is useful for
  31854. * "over-sizing" the table, and thus forcing scrolling. This property can by
  31855. * any CSS unit, or a number (in which case it will be treated as a pixel
  31856. * measurement).
  31857. * @type string
  31858. * @default <i>blank string - i.e. disabled</i>
  31859. *
  31860. * @dtopt Options
  31861. * @name DataTable.defaults.scrollXInner
  31862. *
  31863. * @example
  31864. * $(document).ready( function() {
  31865. * $('#example').dataTable( {
  31866. * "scrollX": "100%",
  31867. * "scrollXInner": "110%"
  31868. * } );
  31869. * } );
  31870. */
  31871. "sScrollXInner": "",
  31872. /**
  31873. * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
  31874. * to the given height, and enable scrolling for any data which overflows the
  31875. * current viewport. This can be used as an alternative to paging to display
  31876. * a lot of data in a small area (although paging and scrolling can both be
  31877. * enabled at the same time). This property can be any CSS unit, or a number
  31878. * (in which case it will be treated as a pixel measurement).
  31879. * @type string
  31880. * @default <i>blank string - i.e. disabled</i>
  31881. *
  31882. * @dtopt Features
  31883. * @name DataTable.defaults.scrollY
  31884. *
  31885. * @example
  31886. * $(document).ready( function() {
  31887. * $('#example').dataTable( {
  31888. * "scrollY": "200px",
  31889. * "paginate": false
  31890. * } );
  31891. * } );
  31892. */
  31893. "sScrollY": "",
  31894. /**
  31895. * __Deprecated__ The functionality provided by this parameter has now been
  31896. * superseded by that provided through `ajax`, which should be used instead.
  31897. *
  31898. * Set the HTTP method that is used to make the Ajax call for server-side
  31899. * processing or Ajax sourced data.
  31900. * @type string
  31901. * @default GET
  31902. *
  31903. * @dtopt Options
  31904. * @dtopt Server-side
  31905. * @name DataTable.defaults.serverMethod
  31906. *
  31907. * @deprecated 1.10. Please use `ajax` for this functionality now.
  31908. */
  31909. "sServerMethod": "GET",
  31910. /**
  31911. * DataTables makes use of renderers when displaying HTML elements for
  31912. * a table. These renderers can be added or modified by plug-ins to
  31913. * generate suitable mark-up for a site. For example the Bootstrap
  31914. * integration plug-in for DataTables uses a paging button renderer to
  31915. * display pagination buttons in the mark-up required by Bootstrap.
  31916. *
  31917. * For further information about the renderers available see
  31918. * DataTable.ext.renderer
  31919. * @type string|object
  31920. * @default null
  31921. *
  31922. * @name DataTable.defaults.renderer
  31923. *
  31924. */
  31925. "renderer": null,
  31926. /**
  31927. * Set the data property name that DataTables should use to get a row's id
  31928. * to set as the `id` property in the node.
  31929. * @type string
  31930. * @default DT_RowId
  31931. *
  31932. * @name DataTable.defaults.rowId
  31933. */
  31934. "rowId": "DT_RowId"
  31935. };
  31936. _fnHungarianMap( DataTable.defaults );
  31937. /*
  31938. * Developer note - See note in model.defaults.js about the use of Hungarian
  31939. * notation and camel case.
  31940. */
  31941. /**
  31942. * Column options that can be given to DataTables at initialisation time.
  31943. * @namespace
  31944. */
  31945. DataTable.defaults.column = {
  31946. /**
  31947. * Define which column(s) an order will occur on for this column. This
  31948. * allows a column's ordering to take multiple columns into account when
  31949. * doing a sort or use the data from a different column. For example first
  31950. * name / last name columns make sense to do a multi-column sort over the
  31951. * two columns.
  31952. * @type array|int
  31953. * @default null <i>Takes the value of the column index automatically</i>
  31954. *
  31955. * @name DataTable.defaults.column.orderData
  31956. * @dtopt Columns
  31957. *
  31958. * @example
  31959. * // Using `columnDefs`
  31960. * $(document).ready( function() {
  31961. * $('#example').dataTable( {
  31962. * "columnDefs": [
  31963. * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
  31964. * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
  31965. * { "orderData": 2, "targets": [ 2 ] }
  31966. * ]
  31967. * } );
  31968. * } );
  31969. *
  31970. * @example
  31971. * // Using `columns`
  31972. * $(document).ready( function() {
  31973. * $('#example').dataTable( {
  31974. * "columns": [
  31975. * { "orderData": [ 0, 1 ] },
  31976. * { "orderData": [ 1, 0 ] },
  31977. * { "orderData": 2 },
  31978. * null,
  31979. * null
  31980. * ]
  31981. * } );
  31982. * } );
  31983. */
  31984. "aDataSort": null,
  31985. "iDataSort": -1,
  31986. /**
  31987. * You can control the default ordering direction, and even alter the
  31988. * behaviour of the sort handler (i.e. only allow ascending ordering etc)
  31989. * using this parameter.
  31990. * @type array
  31991. * @default [ 'asc', 'desc' ]
  31992. *
  31993. * @name DataTable.defaults.column.orderSequence
  31994. * @dtopt Columns
  31995. *
  31996. * @example
  31997. * // Using `columnDefs`
  31998. * $(document).ready( function() {
  31999. * $('#example').dataTable( {
  32000. * "columnDefs": [
  32001. * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
  32002. * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
  32003. * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
  32004. * ]
  32005. * } );
  32006. * } );
  32007. *
  32008. * @example
  32009. * // Using `columns`
  32010. * $(document).ready( function() {
  32011. * $('#example').dataTable( {
  32012. * "columns": [
  32013. * null,
  32014. * { "orderSequence": [ "asc" ] },
  32015. * { "orderSequence": [ "desc", "asc", "asc" ] },
  32016. * { "orderSequence": [ "desc" ] },
  32017. * null
  32018. * ]
  32019. * } );
  32020. * } );
  32021. */
  32022. "asSorting": [ 'asc', 'desc' ],
  32023. /**
  32024. * Enable or disable filtering on the data in this column.
  32025. * @type boolean
  32026. * @default true
  32027. *
  32028. * @name DataTable.defaults.column.searchable
  32029. * @dtopt Columns
  32030. *
  32031. * @example
  32032. * // Using `columnDefs`
  32033. * $(document).ready( function() {
  32034. * $('#example').dataTable( {
  32035. * "columnDefs": [
  32036. * { "searchable": false, "targets": [ 0 ] }
  32037. * ] } );
  32038. * } );
  32039. *
  32040. * @example
  32041. * // Using `columns`
  32042. * $(document).ready( function() {
  32043. * $('#example').dataTable( {
  32044. * "columns": [
  32045. * { "searchable": false },
  32046. * null,
  32047. * null,
  32048. * null,
  32049. * null
  32050. * ] } );
  32051. * } );
  32052. */
  32053. "bSearchable": true,
  32054. /**
  32055. * Enable or disable ordering on this column.
  32056. * @type boolean
  32057. * @default true
  32058. *
  32059. * @name DataTable.defaults.column.orderable
  32060. * @dtopt Columns
  32061. *
  32062. * @example
  32063. * // Using `columnDefs`
  32064. * $(document).ready( function() {
  32065. * $('#example').dataTable( {
  32066. * "columnDefs": [
  32067. * { "orderable": false, "targets": [ 0 ] }
  32068. * ] } );
  32069. * } );
  32070. *
  32071. * @example
  32072. * // Using `columns`
  32073. * $(document).ready( function() {
  32074. * $('#example').dataTable( {
  32075. * "columns": [
  32076. * { "orderable": false },
  32077. * null,
  32078. * null,
  32079. * null,
  32080. * null
  32081. * ] } );
  32082. * } );
  32083. */
  32084. "bSortable": true,
  32085. /**
  32086. * Enable or disable the display of this column.
  32087. * @type boolean
  32088. * @default true
  32089. *
  32090. * @name DataTable.defaults.column.visible
  32091. * @dtopt Columns
  32092. *
  32093. * @example
  32094. * // Using `columnDefs`
  32095. * $(document).ready( function() {
  32096. * $('#example').dataTable( {
  32097. * "columnDefs": [
  32098. * { "visible": false, "targets": [ 0 ] }
  32099. * ] } );
  32100. * } );
  32101. *
  32102. * @example
  32103. * // Using `columns`
  32104. * $(document).ready( function() {
  32105. * $('#example').dataTable( {
  32106. * "columns": [
  32107. * { "visible": false },
  32108. * null,
  32109. * null,
  32110. * null,
  32111. * null
  32112. * ] } );
  32113. * } );
  32114. */
  32115. "bVisible": true,
  32116. /**
  32117. * Developer definable function that is called whenever a cell is created (Ajax source,
  32118. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  32119. * allowing you to modify the DOM element (add background colour for example) when the
  32120. * element is available.
  32121. * @type function
  32122. * @param {element} td The TD node that has been created
  32123. * @param {*} cellData The Data for the cell
  32124. * @param {array|object} rowData The data for the whole row
  32125. * @param {int} row The row index for the aoData data store
  32126. * @param {int} col The column index for aoColumns
  32127. *
  32128. * @name DataTable.defaults.column.createdCell
  32129. * @dtopt Columns
  32130. *
  32131. * @example
  32132. * $(document).ready( function() {
  32133. * $('#example').dataTable( {
  32134. * "columnDefs": [ {
  32135. * "targets": [3],
  32136. * "createdCell": function (td, cellData, rowData, row, col) {
  32137. * if ( cellData == "1.7" ) {
  32138. * $(td).css('color', 'blue')
  32139. * }
  32140. * }
  32141. * } ]
  32142. * });
  32143. * } );
  32144. */
  32145. "fnCreatedCell": null,
  32146. /**
  32147. * This parameter has been replaced by `data` in DataTables to ensure naming
  32148. * consistency. `dataProp` can still be used, as there is backwards
  32149. * compatibility in DataTables for this option, but it is strongly
  32150. * recommended that you use `data` in preference to `dataProp`.
  32151. * @name DataTable.defaults.column.dataProp
  32152. */
  32153. /**
  32154. * This property can be used to read data from any data source property,
  32155. * including deeply nested objects / properties. `data` can be given in a
  32156. * number of different ways which effect its behaviour:
  32157. *
  32158. * * `integer` - treated as an array index for the data source. This is the
  32159. * default that DataTables uses (incrementally increased for each column).
  32160. * * `string` - read an object property from the data source. There are
  32161. * three 'special' options that can be used in the string to alter how
  32162. * DataTables reads the data from the source object:
  32163. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  32164. * Javascript to read from nested objects, so to can the options
  32165. * specified in `data`. For example: `browser.version` or
  32166. * `browser.name`. If your object parameter name contains a period, use
  32167. * `\\` to escape it - i.e. `first\\.name`.
  32168. * * `[]` - Array notation. DataTables can automatically combine data
  32169. * from and array source, joining the data with the characters provided
  32170. * between the two brackets. For example: `name[, ]` would provide a
  32171. * comma-space separated list from the source array. If no characters
  32172. * are provided between the brackets, the original array source is
  32173. * returned.
  32174. * * `()` - Function notation. Adding `()` to the end of a parameter will
  32175. * execute a function of the name given. For example: `browser()` for a
  32176. * simple function on the data source, `browser.version()` for a
  32177. * function in a nested property or even `browser().version` to get an
  32178. * object property if the function called returns an object. Note that
  32179. * function notation is recommended for use in `render` rather than
  32180. * `data` as it is much simpler to use as a renderer.
  32181. * * `null` - use the original data source for the row rather than plucking
  32182. * data directly from it. This action has effects on two other
  32183. * initialisation options:
  32184. * * `defaultContent` - When null is given as the `data` option and
  32185. * `defaultContent` is specified for the column, the value defined by
  32186. * `defaultContent` will be used for the cell.
  32187. * * `render` - When null is used for the `data` option and the `render`
  32188. * option is specified for the column, the whole data source for the
  32189. * row is used for the renderer.
  32190. * * `function` - the function given will be executed whenever DataTables
  32191. * needs to set or get the data for a cell in the column. The function
  32192. * takes three parameters:
  32193. * * Parameters:
  32194. * * `{array|object}` The data source for the row
  32195. * * `{string}` The type call data requested - this will be 'set' when
  32196. * setting data or 'filter', 'display', 'type', 'sort' or undefined
  32197. * when gathering data. Note that when `undefined` is given for the
  32198. * type DataTables expects to get the raw data for the object back<
  32199. * * `{*}` Data to set when the second parameter is 'set'.
  32200. * * Return:
  32201. * * The return value from the function is not required when 'set' is
  32202. * the type of call, but otherwise the return is what will be used
  32203. * for the data requested.
  32204. *
  32205. * Note that `data` is a getter and setter option. If you just require
  32206. * formatting of data for output, you will likely want to use `render` which
  32207. * is simply a getter and thus simpler to use.
  32208. *
  32209. * Note that prior to DataTables 1.9.2 `data` was called `mDataProp`. The
  32210. * name change reflects the flexibility of this property and is consistent
  32211. * with the naming of mRender. If 'mDataProp' is given, then it will still
  32212. * be used by DataTables, as it automatically maps the old name to the new
  32213. * if required.
  32214. *
  32215. * @type string|int|function|null
  32216. * @default null <i>Use automatically calculated column index</i>
  32217. *
  32218. * @name DataTable.defaults.column.data
  32219. * @dtopt Columns
  32220. *
  32221. * @example
  32222. * // Read table data from objects
  32223. * // JSON structure for each row:
  32224. * // {
  32225. * // "engine": {value},
  32226. * // "browser": {value},
  32227. * // "platform": {value},
  32228. * // "version": {value},
  32229. * // "grade": {value}
  32230. * // }
  32231. * $(document).ready( function() {
  32232. * $('#example').dataTable( {
  32233. * "ajaxSource": "sources/objects.txt",
  32234. * "columns": [
  32235. * { "data": "engine" },
  32236. * { "data": "browser" },
  32237. * { "data": "platform" },
  32238. * { "data": "version" },
  32239. * { "data": "grade" }
  32240. * ]
  32241. * } );
  32242. * } );
  32243. *
  32244. * @example
  32245. * // Read information from deeply nested objects
  32246. * // JSON structure for each row:
  32247. * // {
  32248. * // "engine": {value},
  32249. * // "browser": {value},
  32250. * // "platform": {
  32251. * // "inner": {value}
  32252. * // },
  32253. * // "details": [
  32254. * // {value}, {value}
  32255. * // ]
  32256. * // }
  32257. * $(document).ready( function() {
  32258. * $('#example').dataTable( {
  32259. * "ajaxSource": "sources/deep.txt",
  32260. * "columns": [
  32261. * { "data": "engine" },
  32262. * { "data": "browser" },
  32263. * { "data": "platform.inner" },
  32264. * { "data": "platform.details.0" },
  32265. * { "data": "platform.details.1" }
  32266. * ]
  32267. * } );
  32268. * } );
  32269. *
  32270. * @example
  32271. * // Using `data` as a function to provide different information for
  32272. * // sorting, filtering and display. In this case, currency (price)
  32273. * $(document).ready( function() {
  32274. * $('#example').dataTable( {
  32275. * "columnDefs": [ {
  32276. * "targets": [ 0 ],
  32277. * "data": function ( source, type, val ) {
  32278. * if (type === 'set') {
  32279. * source.price = val;
  32280. * // Store the computed dislay and filter values for efficiency
  32281. * source.price_display = val=="" ? "" : "$"+numberFormat(val);
  32282. * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
  32283. * return;
  32284. * }
  32285. * else if (type === 'display') {
  32286. * return source.price_display;
  32287. * }
  32288. * else if (type === 'filter') {
  32289. * return source.price_filter;
  32290. * }
  32291. * // 'sort', 'type' and undefined all just use the integer
  32292. * return source.price;
  32293. * }
  32294. * } ]
  32295. * } );
  32296. * } );
  32297. *
  32298. * @example
  32299. * // Using default content
  32300. * $(document).ready( function() {
  32301. * $('#example').dataTable( {
  32302. * "columnDefs": [ {
  32303. * "targets": [ 0 ],
  32304. * "data": null,
  32305. * "defaultContent": "Click to edit"
  32306. * } ]
  32307. * } );
  32308. * } );
  32309. *
  32310. * @example
  32311. * // Using array notation - outputting a list from an array
  32312. * $(document).ready( function() {
  32313. * $('#example').dataTable( {
  32314. * "columnDefs": [ {
  32315. * "targets": [ 0 ],
  32316. * "data": "name[, ]"
  32317. * } ]
  32318. * } );
  32319. * } );
  32320. *
  32321. */
  32322. "mData": null,
  32323. /**
  32324. * This property is the rendering partner to `data` and it is suggested that
  32325. * when you want to manipulate data for display (including filtering,
  32326. * sorting etc) without altering the underlying data for the table, use this
  32327. * property. `render` can be considered to be the the read only companion to
  32328. * `data` which is read / write (then as such more complex). Like `data`
  32329. * this option can be given in a number of different ways to effect its
  32330. * behaviour:
  32331. *
  32332. * * `integer` - treated as an array index for the data source. This is the
  32333. * default that DataTables uses (incrementally increased for each column).
  32334. * * `string` - read an object property from the data source. There are
  32335. * three 'special' options that can be used in the string to alter how
  32336. * DataTables reads the data from the source object:
  32337. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  32338. * Javascript to read from nested objects, so to can the options
  32339. * specified in `data`. For example: `browser.version` or
  32340. * `browser.name`. If your object parameter name contains a period, use
  32341. * `\\` to escape it - i.e. `first\\.name`.
  32342. * * `[]` - Array notation. DataTables can automatically combine data
  32343. * from and array source, joining the data with the characters provided
  32344. * between the two brackets. For example: `name[, ]` would provide a
  32345. * comma-space separated list from the source array. If no characters
  32346. * are provided between the brackets, the original array source is
  32347. * returned.
  32348. * * `()` - Function notation. Adding `()` to the end of a parameter will
  32349. * execute a function of the name given. For example: `browser()` for a
  32350. * simple function on the data source, `browser.version()` for a
  32351. * function in a nested property or even `browser().version` to get an
  32352. * object property if the function called returns an object.
  32353. * * `object` - use different data for the different data types requested by
  32354. * DataTables ('filter', 'display', 'type' or 'sort'). The property names
  32355. * of the object is the data type the property refers to and the value can
  32356. * defined using an integer, string or function using the same rules as
  32357. * `render` normally does. Note that an `_` option _must_ be specified.
  32358. * This is the default value to use if you haven't specified a value for
  32359. * the data type requested by DataTables.
  32360. * * `function` - the function given will be executed whenever DataTables
  32361. * needs to set or get the data for a cell in the column. The function
  32362. * takes three parameters:
  32363. * * Parameters:
  32364. * * {array|object} The data source for the row (based on `data`)
  32365. * * {string} The type call data requested - this will be 'filter',
  32366. * 'display', 'type' or 'sort'.
  32367. * * {array|object} The full data source for the row (not based on
  32368. * `data`)
  32369. * * Return:
  32370. * * The return value from the function is what will be used for the
  32371. * data requested.
  32372. *
  32373. * @type string|int|function|object|null
  32374. * @default null Use the data source value.
  32375. *
  32376. * @name DataTable.defaults.column.render
  32377. * @dtopt Columns
  32378. *
  32379. * @example
  32380. * // Create a comma separated list from an array of objects
  32381. * $(document).ready( function() {
  32382. * $('#example').dataTable( {
  32383. * "ajaxSource": "sources/deep.txt",
  32384. * "columns": [
  32385. * { "data": "engine" },
  32386. * { "data": "browser" },
  32387. * {
  32388. * "data": "platform",
  32389. * "render": "[, ].name"
  32390. * }
  32391. * ]
  32392. * } );
  32393. * } );
  32394. *
  32395. * @example
  32396. * // Execute a function to obtain data
  32397. * $(document).ready( function() {
  32398. * $('#example').dataTable( {
  32399. * "columnDefs": [ {
  32400. * "targets": [ 0 ],
  32401. * "data": null, // Use the full data source object for the renderer's source
  32402. * "render": "browserName()"
  32403. * } ]
  32404. * } );
  32405. * } );
  32406. *
  32407. * @example
  32408. * // As an object, extracting different data for the different types
  32409. * // This would be used with a data source such as:
  32410. * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
  32411. * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
  32412. * // (which has both forms) is used for filtering for if a user inputs either format, while
  32413. * // the formatted phone number is the one that is shown in the table.
  32414. * $(document).ready( function() {
  32415. * $('#example').dataTable( {
  32416. * "columnDefs": [ {
  32417. * "targets": [ 0 ],
  32418. * "data": null, // Use the full data source object for the renderer's source
  32419. * "render": {
  32420. * "_": "phone",
  32421. * "filter": "phone_filter",
  32422. * "display": "phone_display"
  32423. * }
  32424. * } ]
  32425. * } );
  32426. * } );
  32427. *
  32428. * @example
  32429. * // Use as a function to create a link from the data source
  32430. * $(document).ready( function() {
  32431. * $('#example').dataTable( {
  32432. * "columnDefs": [ {
  32433. * "targets": [ 0 ],
  32434. * "data": "download_link",
  32435. * "render": function ( data, type, full ) {
  32436. * return '<a href="'+data+'">Download</a>';
  32437. * }
  32438. * } ]
  32439. * } );
  32440. * } );
  32441. */
  32442. "mRender": null,
  32443. /**
  32444. * Change the cell type created for the column - either TD cells or TH cells. This
  32445. * can be useful as TH cells have semantic meaning in the table body, allowing them
  32446. * to act as a header for a row (you may wish to add scope='row' to the TH elements).
  32447. * @type string
  32448. * @default td
  32449. *
  32450. * @name DataTable.defaults.column.cellType
  32451. * @dtopt Columns
  32452. *
  32453. * @example
  32454. * // Make the first column use TH cells
  32455. * $(document).ready( function() {
  32456. * $('#example').dataTable( {
  32457. * "columnDefs": [ {
  32458. * "targets": [ 0 ],
  32459. * "cellType": "th"
  32460. * } ]
  32461. * } );
  32462. * } );
  32463. */
  32464. "sCellType": "td",
  32465. /**
  32466. * Class to give to each cell in this column.
  32467. * @type string
  32468. * @default <i>Empty string</i>
  32469. *
  32470. * @name DataTable.defaults.column.class
  32471. * @dtopt Columns
  32472. *
  32473. * @example
  32474. * // Using `columnDefs`
  32475. * $(document).ready( function() {
  32476. * $('#example').dataTable( {
  32477. * "columnDefs": [
  32478. * { "class": "my_class", "targets": [ 0 ] }
  32479. * ]
  32480. * } );
  32481. * } );
  32482. *
  32483. * @example
  32484. * // Using `columns`
  32485. * $(document).ready( function() {
  32486. * $('#example').dataTable( {
  32487. * "columns": [
  32488. * { "class": "my_class" },
  32489. * null,
  32490. * null,
  32491. * null,
  32492. * null
  32493. * ]
  32494. * } );
  32495. * } );
  32496. */
  32497. "sClass": "",
  32498. /**
  32499. * When DataTables calculates the column widths to assign to each column,
  32500. * it finds the longest string in each column and then constructs a
  32501. * temporary table and reads the widths from that. The problem with this
  32502. * is that "mmm" is much wider then "iiii", but the latter is a longer
  32503. * string - thus the calculation can go wrong (doing it properly and putting
  32504. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  32505. * a "work around" we provide this option. It will append its value to the
  32506. * text that is found to be the longest string for the column - i.e. padding.
  32507. * Generally you shouldn't need this!
  32508. * @type string
  32509. * @default <i>Empty string<i>
  32510. *
  32511. * @name DataTable.defaults.column.contentPadding
  32512. * @dtopt Columns
  32513. *
  32514. * @example
  32515. * // Using `columns`
  32516. * $(document).ready( function() {
  32517. * $('#example').dataTable( {
  32518. * "columns": [
  32519. * null,
  32520. * null,
  32521. * null,
  32522. * {
  32523. * "contentPadding": "mmm"
  32524. * }
  32525. * ]
  32526. * } );
  32527. * } );
  32528. */
  32529. "sContentPadding": "",
  32530. /**
  32531. * Allows a default value to be given for a column's data, and will be used
  32532. * whenever a null data source is encountered (this can be because `data`
  32533. * is set to null, or because the data source itself is null).
  32534. * @type string
  32535. * @default null
  32536. *
  32537. * @name DataTable.defaults.column.defaultContent
  32538. * @dtopt Columns
  32539. *
  32540. * @example
  32541. * // Using `columnDefs`
  32542. * $(document).ready( function() {
  32543. * $('#example').dataTable( {
  32544. * "columnDefs": [
  32545. * {
  32546. * "data": null,
  32547. * "defaultContent": "Edit",
  32548. * "targets": [ -1 ]
  32549. * }
  32550. * ]
  32551. * } );
  32552. * } );
  32553. *
  32554. * @example
  32555. * // Using `columns`
  32556. * $(document).ready( function() {
  32557. * $('#example').dataTable( {
  32558. * "columns": [
  32559. * null,
  32560. * null,
  32561. * null,
  32562. * {
  32563. * "data": null,
  32564. * "defaultContent": "Edit"
  32565. * }
  32566. * ]
  32567. * } );
  32568. * } );
  32569. */
  32570. "sDefaultContent": null,
  32571. /**
  32572. * This parameter is only used in DataTables' server-side processing. It can
  32573. * be exceptionally useful to know what columns are being displayed on the
  32574. * client side, and to map these to database fields. When defined, the names
  32575. * also allow DataTables to reorder information from the server if it comes
  32576. * back in an unexpected order (i.e. if you switch your columns around on the
  32577. * client-side, your server-side code does not also need updating).
  32578. * @type string
  32579. * @default <i>Empty string</i>
  32580. *
  32581. * @name DataTable.defaults.column.name
  32582. * @dtopt Columns
  32583. *
  32584. * @example
  32585. * // Using `columnDefs`
  32586. * $(document).ready( function() {
  32587. * $('#example').dataTable( {
  32588. * "columnDefs": [
  32589. * { "name": "engine", "targets": [ 0 ] },
  32590. * { "name": "browser", "targets": [ 1 ] },
  32591. * { "name": "platform", "targets": [ 2 ] },
  32592. * { "name": "version", "targets": [ 3 ] },
  32593. * { "name": "grade", "targets": [ 4 ] }
  32594. * ]
  32595. * } );
  32596. * } );
  32597. *
  32598. * @example
  32599. * // Using `columns`
  32600. * $(document).ready( function() {
  32601. * $('#example').dataTable( {
  32602. * "columns": [
  32603. * { "name": "engine" },
  32604. * { "name": "browser" },
  32605. * { "name": "platform" },
  32606. * { "name": "version" },
  32607. * { "name": "grade" }
  32608. * ]
  32609. * } );
  32610. * } );
  32611. */
  32612. "sName": "",
  32613. /**
  32614. * Defines a data source type for the ordering which can be used to read
  32615. * real-time information from the table (updating the internally cached
  32616. * version) prior to ordering. This allows ordering to occur on user
  32617. * editable elements such as form inputs.
  32618. * @type string
  32619. * @default std
  32620. *
  32621. * @name DataTable.defaults.column.orderDataType
  32622. * @dtopt Columns
  32623. *
  32624. * @example
  32625. * // Using `columnDefs`
  32626. * $(document).ready( function() {
  32627. * $('#example').dataTable( {
  32628. * "columnDefs": [
  32629. * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
  32630. * { "type": "numeric", "targets": [ 3 ] },
  32631. * { "orderDataType": "dom-select", "targets": [ 4 ] },
  32632. * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
  32633. * ]
  32634. * } );
  32635. * } );
  32636. *
  32637. * @example
  32638. * // Using `columns`
  32639. * $(document).ready( function() {
  32640. * $('#example').dataTable( {
  32641. * "columns": [
  32642. * null,
  32643. * null,
  32644. * { "orderDataType": "dom-text" },
  32645. * { "orderDataType": "dom-text", "type": "numeric" },
  32646. * { "orderDataType": "dom-select" },
  32647. * { "orderDataType": "dom-checkbox" }
  32648. * ]
  32649. * } );
  32650. * } );
  32651. */
  32652. "sSortDataType": "std",
  32653. /**
  32654. * The title of this column.
  32655. * @type string
  32656. * @default null <i>Derived from the 'TH' value for this column in the
  32657. * original HTML table.</i>
  32658. *
  32659. * @name DataTable.defaults.column.title
  32660. * @dtopt Columns
  32661. *
  32662. * @example
  32663. * // Using `columnDefs`
  32664. * $(document).ready( function() {
  32665. * $('#example').dataTable( {
  32666. * "columnDefs": [
  32667. * { "title": "My column title", "targets": [ 0 ] }
  32668. * ]
  32669. * } );
  32670. * } );
  32671. *
  32672. * @example
  32673. * // Using `columns`
  32674. * $(document).ready( function() {
  32675. * $('#example').dataTable( {
  32676. * "columns": [
  32677. * { "title": "My column title" },
  32678. * null,
  32679. * null,
  32680. * null,
  32681. * null
  32682. * ]
  32683. * } );
  32684. * } );
  32685. */
  32686. "sTitle": null,
  32687. /**
  32688. * The type allows you to specify how the data for this column will be
  32689. * ordered. Four types (string, numeric, date and html (which will strip
  32690. * HTML tags before ordering)) are currently available. Note that only date
  32691. * formats understood by Javascript's Date() object will be accepted as type
  32692. * date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
  32693. * 'numeric', 'date' or 'html' (by default). Further types can be adding
  32694. * through plug-ins.
  32695. * @type string
  32696. * @default null <i>Auto-detected from raw data</i>
  32697. *
  32698. * @name DataTable.defaults.column.type
  32699. * @dtopt Columns
  32700. *
  32701. * @example
  32702. * // Using `columnDefs`
  32703. * $(document).ready( function() {
  32704. * $('#example').dataTable( {
  32705. * "columnDefs": [
  32706. * { "type": "html", "targets": [ 0 ] }
  32707. * ]
  32708. * } );
  32709. * } );
  32710. *
  32711. * @example
  32712. * // Using `columns`
  32713. * $(document).ready( function() {
  32714. * $('#example').dataTable( {
  32715. * "columns": [
  32716. * { "type": "html" },
  32717. * null,
  32718. * null,
  32719. * null,
  32720. * null
  32721. * ]
  32722. * } );
  32723. * } );
  32724. */
  32725. "sType": null,
  32726. /**
  32727. * Defining the width of the column, this parameter may take any CSS value
  32728. * (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
  32729. * been given a specific width through this interface ensuring that the table
  32730. * remains readable.
  32731. * @type string
  32732. * @default null <i>Automatic</i>
  32733. *
  32734. * @name DataTable.defaults.column.width
  32735. * @dtopt Columns
  32736. *
  32737. * @example
  32738. * // Using `columnDefs`
  32739. * $(document).ready( function() {
  32740. * $('#example').dataTable( {
  32741. * "columnDefs": [
  32742. * { "width": "20%", "targets": [ 0 ] }
  32743. * ]
  32744. * } );
  32745. * } );
  32746. *
  32747. * @example
  32748. * // Using `columns`
  32749. * $(document).ready( function() {
  32750. * $('#example').dataTable( {
  32751. * "columns": [
  32752. * { "width": "20%" },
  32753. * null,
  32754. * null,
  32755. * null,
  32756. * null
  32757. * ]
  32758. * } );
  32759. * } );
  32760. */
  32761. "sWidth": null
  32762. };
  32763. _fnHungarianMap( DataTable.defaults.column );
  32764. /**
  32765. * DataTables settings object - this holds all the information needed for a
  32766. * given table, including configuration, data and current application of the
  32767. * table options. DataTables does not have a single instance for each DataTable
  32768. * with the settings attached to that instance, but rather instances of the
  32769. * DataTable "class" are created on-the-fly as needed (typically by a
  32770. * $().dataTable() call) and the settings object is then applied to that
  32771. * instance.
  32772. *
  32773. * Note that this object is related to {@link DataTable.defaults} but this
  32774. * one is the internal data store for DataTables's cache of columns. It should
  32775. * NOT be manipulated outside of DataTables. Any configuration should be done
  32776. * through the initialisation options.
  32777. * @namespace
  32778. * @todo Really should attach the settings object to individual instances so we
  32779. * don't need to create new instances on each $().dataTable() call (if the
  32780. * table already exists). It would also save passing oSettings around and
  32781. * into every single function. However, this is a very significant
  32782. * architecture change for DataTables and will almost certainly break
  32783. * backwards compatibility with older installations. This is something that
  32784. * will be done in 2.0.
  32785. */
  32786. DataTable.models.oSettings = {
  32787. /**
  32788. * Primary features of DataTables and their enablement state.
  32789. * @namespace
  32790. */
  32791. "oFeatures": {
  32792. /**
  32793. * Flag to say if DataTables should automatically try to calculate the
  32794. * optimum table and columns widths (true) or not (false).
  32795. * Note that this parameter will be set by the initialisation routine. To
  32796. * set a default use {@link DataTable.defaults}.
  32797. * @type boolean
  32798. */
  32799. "bAutoWidth": null,
  32800. /**
  32801. * Delay the creation of TR and TD elements until they are actually
  32802. * needed by a driven page draw. This can give a significant speed
  32803. * increase for Ajax source and Javascript source data, but makes no
  32804. * difference at all fro DOM and server-side processing tables.
  32805. * Note that this parameter will be set by the initialisation routine. To
  32806. * set a default use {@link DataTable.defaults}.
  32807. * @type boolean
  32808. */
  32809. "bDeferRender": null,
  32810. /**
  32811. * Enable filtering on the table or not. Note that if this is disabled
  32812. * then there is no filtering at all on the table, including fnFilter.
  32813. * To just remove the filtering input use sDom and remove the 'f' option.
  32814. * Note that this parameter will be set by the initialisation routine. To
  32815. * set a default use {@link DataTable.defaults}.
  32816. * @type boolean
  32817. */
  32818. "bFilter": null,
  32819. /**
  32820. * Table information element (the 'Showing x of y records' div) enable
  32821. * flag.
  32822. * Note that this parameter will be set by the initialisation routine. To
  32823. * set a default use {@link DataTable.defaults}.
  32824. * @type boolean
  32825. */
  32826. "bInfo": null,
  32827. /**
  32828. * Present a user control allowing the end user to change the page size
  32829. * when pagination is enabled.
  32830. * Note that this parameter will be set by the initialisation routine. To
  32831. * set a default use {@link DataTable.defaults}.
  32832. * @type boolean
  32833. */
  32834. "bLengthChange": null,
  32835. /**
  32836. * Pagination enabled or not. Note that if this is disabled then length
  32837. * changing must also be disabled.
  32838. * Note that this parameter will be set by the initialisation routine. To
  32839. * set a default use {@link DataTable.defaults}.
  32840. * @type boolean
  32841. */
  32842. "bPaginate": null,
  32843. /**
  32844. * Processing indicator enable flag whenever DataTables is enacting a
  32845. * user request - typically an Ajax request for server-side processing.
  32846. * Note that this parameter will be set by the initialisation routine. To
  32847. * set a default use {@link DataTable.defaults}.
  32848. * @type boolean
  32849. */
  32850. "bProcessing": null,
  32851. /**
  32852. * Server-side processing enabled flag - when enabled DataTables will
  32853. * get all data from the server for every draw - there is no filtering,
  32854. * sorting or paging done on the client-side.
  32855. * Note that this parameter will be set by the initialisation routine. To
  32856. * set a default use {@link DataTable.defaults}.
  32857. * @type boolean
  32858. */
  32859. "bServerSide": null,
  32860. /**
  32861. * Sorting enablement flag.
  32862. * Note that this parameter will be set by the initialisation routine. To
  32863. * set a default use {@link DataTable.defaults}.
  32864. * @type boolean
  32865. */
  32866. "bSort": null,
  32867. /**
  32868. * Multi-column sorting
  32869. * Note that this parameter will be set by the initialisation routine. To
  32870. * set a default use {@link DataTable.defaults}.
  32871. * @type boolean
  32872. */
  32873. "bSortMulti": null,
  32874. /**
  32875. * Apply a class to the columns which are being sorted to provide a
  32876. * visual highlight or not. This can slow things down when enabled since
  32877. * there is a lot of DOM interaction.
  32878. * Note that this parameter will be set by the initialisation routine. To
  32879. * set a default use {@link DataTable.defaults}.
  32880. * @type boolean
  32881. */
  32882. "bSortClasses": null,
  32883. /**
  32884. * State saving enablement flag.
  32885. * Note that this parameter will be set by the initialisation routine. To
  32886. * set a default use {@link DataTable.defaults}.
  32887. * @type boolean
  32888. */
  32889. "bStateSave": null
  32890. },
  32891. /**
  32892. * Scrolling settings for a table.
  32893. * @namespace
  32894. */
  32895. "oScroll": {
  32896. /**
  32897. * When the table is shorter in height than sScrollY, collapse the
  32898. * table container down to the height of the table (when true).
  32899. * Note that this parameter will be set by the initialisation routine. To
  32900. * set a default use {@link DataTable.defaults}.
  32901. * @type boolean
  32902. */
  32903. "bCollapse": null,
  32904. /**
  32905. * Width of the scrollbar for the web-browser's platform. Calculated
  32906. * during table initialisation.
  32907. * @type int
  32908. * @default 0
  32909. */
  32910. "iBarWidth": 0,
  32911. /**
  32912. * Viewport width for horizontal scrolling. Horizontal scrolling is
  32913. * disabled if an empty string.
  32914. * Note that this parameter will be set by the initialisation routine. To
  32915. * set a default use {@link DataTable.defaults}.
  32916. * @type string
  32917. */
  32918. "sX": null,
  32919. /**
  32920. * Width to expand the table to when using x-scrolling. Typically you
  32921. * should not need to use this.
  32922. * Note that this parameter will be set by the initialisation routine. To
  32923. * set a default use {@link DataTable.defaults}.
  32924. * @type string
  32925. * @deprecated
  32926. */
  32927. "sXInner": null,
  32928. /**
  32929. * Viewport height for vertical scrolling. Vertical scrolling is disabled
  32930. * if an empty string.
  32931. * Note that this parameter will be set by the initialisation routine. To
  32932. * set a default use {@link DataTable.defaults}.
  32933. * @type string
  32934. */
  32935. "sY": null
  32936. },
  32937. /**
  32938. * Language information for the table.
  32939. * @namespace
  32940. * @extends DataTable.defaults.oLanguage
  32941. */
  32942. "oLanguage": {
  32943. /**
  32944. * Information callback function. See
  32945. * {@link DataTable.defaults.fnInfoCallback}
  32946. * @type function
  32947. * @default null
  32948. */
  32949. "fnInfoCallback": null
  32950. },
  32951. /**
  32952. * Browser support parameters
  32953. * @namespace
  32954. */
  32955. "oBrowser": {
  32956. /**
  32957. * Indicate if the browser incorrectly calculates width:100% inside a
  32958. * scrolling element (IE6/7)
  32959. * @type boolean
  32960. * @default false
  32961. */
  32962. "bScrollOversize": false,
  32963. /**
  32964. * Determine if the vertical scrollbar is on the right or left of the
  32965. * scrolling container - needed for rtl language layout, although not
  32966. * all browsers move the scrollbar (Safari).
  32967. * @type boolean
  32968. * @default false
  32969. */
  32970. "bScrollbarLeft": false,
  32971. /**
  32972. * Flag for if `getBoundingClientRect` is fully supported or not
  32973. * @type boolean
  32974. * @default false
  32975. */
  32976. "bBounding": false,
  32977. /**
  32978. * Browser scrollbar width
  32979. * @type integer
  32980. * @default 0
  32981. */
  32982. "barWidth": 0
  32983. },
  32984. "ajax": null,
  32985. /**
  32986. * Array referencing the nodes which are used for the features. The
  32987. * parameters of this object match what is allowed by sDom - i.e.
  32988. * <ul>
  32989. * <li>'l' - Length changing</li>
  32990. * <li>'f' - Filtering input</li>
  32991. * <li>'t' - The table!</li>
  32992. * <li>'i' - Information</li>
  32993. * <li>'p' - Pagination</li>
  32994. * <li>'r' - pRocessing</li>
  32995. * </ul>
  32996. * @type array
  32997. * @default []
  32998. */
  32999. "aanFeatures": [],
  33000. /**
  33001. * Store data information - see {@link DataTable.models.oRow} for detailed
  33002. * information.
  33003. * @type array
  33004. * @default []
  33005. */
  33006. "aoData": [],
  33007. /**
  33008. * Array of indexes which are in the current display (after filtering etc)
  33009. * @type array
  33010. * @default []
  33011. */
  33012. "aiDisplay": [],
  33013. /**
  33014. * Array of indexes for display - no filtering
  33015. * @type array
  33016. * @default []
  33017. */
  33018. "aiDisplayMaster": [],
  33019. /**
  33020. * Map of row ids to data indexes
  33021. * @type object
  33022. * @default {}
  33023. */
  33024. "aIds": {},
  33025. /**
  33026. * Store information about each column that is in use
  33027. * @type array
  33028. * @default []
  33029. */
  33030. "aoColumns": [],
  33031. /**
  33032. * Store information about the table's header
  33033. * @type array
  33034. * @default []
  33035. */
  33036. "aoHeader": [],
  33037. /**
  33038. * Store information about the table's footer
  33039. * @type array
  33040. * @default []
  33041. */
  33042. "aoFooter": [],
  33043. /**
  33044. * Store the applied global search information in case we want to force a
  33045. * research or compare the old search to a new one.
  33046. * Note that this parameter will be set by the initialisation routine. To
  33047. * set a default use {@link DataTable.defaults}.
  33048. * @namespace
  33049. * @extends DataTable.models.oSearch
  33050. */
  33051. "oPreviousSearch": {},
  33052. /**
  33053. * Store the applied search for each column - see
  33054. * {@link DataTable.models.oSearch} for the format that is used for the
  33055. * filtering information for each column.
  33056. * @type array
  33057. * @default []
  33058. */
  33059. "aoPreSearchCols": [],
  33060. /**
  33061. * Sorting that is applied to the table. Note that the inner arrays are
  33062. * used in the following manner:
  33063. * <ul>
  33064. * <li>Index 0 - column number</li>
  33065. * <li>Index 1 - current sorting direction</li>
  33066. * </ul>
  33067. * Note that this parameter will be set by the initialisation routine. To
  33068. * set a default use {@link DataTable.defaults}.
  33069. * @type array
  33070. * @todo These inner arrays should really be objects
  33071. */
  33072. "aaSorting": null,
  33073. /**
  33074. * Sorting that is always applied to the table (i.e. prefixed in front of
  33075. * aaSorting).
  33076. * Note that this parameter will be set by the initialisation routine. To
  33077. * set a default use {@link DataTable.defaults}.
  33078. * @type array
  33079. * @default []
  33080. */
  33081. "aaSortingFixed": [],
  33082. /**
  33083. * Classes to use for the striping of a table.
  33084. * Note that this parameter will be set by the initialisation routine. To
  33085. * set a default use {@link DataTable.defaults}.
  33086. * @type array
  33087. * @default []
  33088. */
  33089. "asStripeClasses": null,
  33090. /**
  33091. * If restoring a table - we should restore its striping classes as well
  33092. * @type array
  33093. * @default []
  33094. */
  33095. "asDestroyStripes": [],
  33096. /**
  33097. * If restoring a table - we should restore its width
  33098. * @type int
  33099. * @default 0
  33100. */
  33101. "sDestroyWidth": 0,
  33102. /**
  33103. * Callback functions array for every time a row is inserted (i.e. on a draw).
  33104. * @type array
  33105. * @default []
  33106. */
  33107. "aoRowCallback": [],
  33108. /**
  33109. * Callback functions for the header on each draw.
  33110. * @type array
  33111. * @default []
  33112. */
  33113. "aoHeaderCallback": [],
  33114. /**
  33115. * Callback function for the footer on each draw.
  33116. * @type array
  33117. * @default []
  33118. */
  33119. "aoFooterCallback": [],
  33120. /**
  33121. * Array of callback functions for draw callback functions
  33122. * @type array
  33123. * @default []
  33124. */
  33125. "aoDrawCallback": [],
  33126. /**
  33127. * Array of callback functions for row created function
  33128. * @type array
  33129. * @default []
  33130. */
  33131. "aoRowCreatedCallback": [],
  33132. /**
  33133. * Callback functions for just before the table is redrawn. A return of
  33134. * false will be used to cancel the draw.
  33135. * @type array
  33136. * @default []
  33137. */
  33138. "aoPreDrawCallback": [],
  33139. /**
  33140. * Callback functions for when the table has been initialised.
  33141. * @type array
  33142. * @default []
  33143. */
  33144. "aoInitComplete": [],
  33145. /**
  33146. * Callbacks for modifying the settings to be stored for state saving, prior to
  33147. * saving state.
  33148. * @type array
  33149. * @default []
  33150. */
  33151. "aoStateSaveParams": [],
  33152. /**
  33153. * Callbacks for modifying the settings that have been stored for state saving
  33154. * prior to using the stored values to restore the state.
  33155. * @type array
  33156. * @default []
  33157. */
  33158. "aoStateLoadParams": [],
  33159. /**
  33160. * Callbacks for operating on the settings object once the saved state has been
  33161. * loaded
  33162. * @type array
  33163. * @default []
  33164. */
  33165. "aoStateLoaded": [],
  33166. /**
  33167. * Cache the table ID for quick access
  33168. * @type string
  33169. * @default <i>Empty string</i>
  33170. */
  33171. "sTableId": "",
  33172. /**
  33173. * The TABLE node for the main table
  33174. * @type node
  33175. * @default null
  33176. */
  33177. "nTable": null,
  33178. /**
  33179. * Permanent ref to the thead element
  33180. * @type node
  33181. * @default null
  33182. */
  33183. "nTHead": null,
  33184. /**
  33185. * Permanent ref to the tfoot element - if it exists
  33186. * @type node
  33187. * @default null
  33188. */
  33189. "nTFoot": null,
  33190. /**
  33191. * Permanent ref to the tbody element
  33192. * @type node
  33193. * @default null
  33194. */
  33195. "nTBody": null,
  33196. /**
  33197. * Cache the wrapper node (contains all DataTables controlled elements)
  33198. * @type node
  33199. * @default null
  33200. */
  33201. "nTableWrapper": null,
  33202. /**
  33203. * Indicate if when using server-side processing the loading of data
  33204. * should be deferred until the second draw.
  33205. * Note that this parameter will be set by the initialisation routine. To
  33206. * set a default use {@link DataTable.defaults}.
  33207. * @type boolean
  33208. * @default false
  33209. */
  33210. "bDeferLoading": false,
  33211. /**
  33212. * Indicate if all required information has been read in
  33213. * @type boolean
  33214. * @default false
  33215. */
  33216. "bInitialised": false,
  33217. /**
  33218. * Information about open rows. Each object in the array has the parameters
  33219. * 'nTr' and 'nParent'
  33220. * @type array
  33221. * @default []
  33222. */
  33223. "aoOpenRows": [],
  33224. /**
  33225. * Dictate the positioning of DataTables' control elements - see
  33226. * {@link DataTable.model.oInit.sDom}.
  33227. * Note that this parameter will be set by the initialisation routine. To
  33228. * set a default use {@link DataTable.defaults}.
  33229. * @type string
  33230. * @default null
  33231. */
  33232. "sDom": null,
  33233. /**
  33234. * Search delay (in mS)
  33235. * @type integer
  33236. * @default null
  33237. */
  33238. "searchDelay": null,
  33239. /**
  33240. * Which type of pagination should be used.
  33241. * Note that this parameter will be set by the initialisation routine. To
  33242. * set a default use {@link DataTable.defaults}.
  33243. * @type string
  33244. * @default two_button
  33245. */
  33246. "sPaginationType": "two_button",
  33247. /**
  33248. * The state duration (for `stateSave`) in seconds.
  33249. * Note that this parameter will be set by the initialisation routine. To
  33250. * set a default use {@link DataTable.defaults}.
  33251. * @type int
  33252. * @default 0
  33253. */
  33254. "iStateDuration": 0,
  33255. /**
  33256. * Array of callback functions for state saving. Each array element is an
  33257. * object with the following parameters:
  33258. * <ul>
  33259. * <li>function:fn - function to call. Takes two parameters, oSettings
  33260. * and the JSON string to save that has been thus far created. Returns
  33261. * a JSON string to be inserted into a json object
  33262. * (i.e. '"param": [ 0, 1, 2]')</li>
  33263. * <li>string:sName - name of callback</li>
  33264. * </ul>
  33265. * @type array
  33266. * @default []
  33267. */
  33268. "aoStateSave": [],
  33269. /**
  33270. * Array of callback functions for state loading. Each array element is an
  33271. * object with the following parameters:
  33272. * <ul>
  33273. * <li>function:fn - function to call. Takes two parameters, oSettings
  33274. * and the object stored. May return false to cancel state loading</li>
  33275. * <li>string:sName - name of callback</li>
  33276. * </ul>
  33277. * @type array
  33278. * @default []
  33279. */
  33280. "aoStateLoad": [],
  33281. /**
  33282. * State that was saved. Useful for back reference
  33283. * @type object
  33284. * @default null
  33285. */
  33286. "oSavedState": null,
  33287. /**
  33288. * State that was loaded. Useful for back reference
  33289. * @type object
  33290. * @default null
  33291. */
  33292. "oLoadedState": null,
  33293. /**
  33294. * Source url for AJAX data for the table.
  33295. * Note that this parameter will be set by the initialisation routine. To
  33296. * set a default use {@link DataTable.defaults}.
  33297. * @type string
  33298. * @default null
  33299. */
  33300. "sAjaxSource": null,
  33301. /**
  33302. * Property from a given object from which to read the table data from. This
  33303. * can be an empty string (when not server-side processing), in which case
  33304. * it is assumed an an array is given directly.
  33305. * Note that this parameter will be set by the initialisation routine. To
  33306. * set a default use {@link DataTable.defaults}.
  33307. * @type string
  33308. */
  33309. "sAjaxDataProp": null,
  33310. /**
  33311. * Note if draw should be blocked while getting data
  33312. * @type boolean
  33313. * @default true
  33314. */
  33315. "bAjaxDataGet": true,
  33316. /**
  33317. * The last jQuery XHR object that was used for server-side data gathering.
  33318. * This can be used for working with the XHR information in one of the
  33319. * callbacks
  33320. * @type object
  33321. * @default null
  33322. */
  33323. "jqXHR": null,
  33324. /**
  33325. * JSON returned from the server in the last Ajax request
  33326. * @type object
  33327. * @default undefined
  33328. */
  33329. "json": undefined,
  33330. /**
  33331. * Data submitted as part of the last Ajax request
  33332. * @type object
  33333. * @default undefined
  33334. */
  33335. "oAjaxData": undefined,
  33336. /**
  33337. * Function to get the server-side data.
  33338. * Note that this parameter will be set by the initialisation routine. To
  33339. * set a default use {@link DataTable.defaults}.
  33340. * @type function
  33341. */
  33342. "fnServerData": null,
  33343. /**
  33344. * Functions which are called prior to sending an Ajax request so extra
  33345. * parameters can easily be sent to the server
  33346. * @type array
  33347. * @default []
  33348. */
  33349. "aoServerParams": [],
  33350. /**
  33351. * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
  33352. * required).
  33353. * Note that this parameter will be set by the initialisation routine. To
  33354. * set a default use {@link DataTable.defaults}.
  33355. * @type string
  33356. */
  33357. "sServerMethod": null,
  33358. /**
  33359. * Format numbers for display.
  33360. * Note that this parameter will be set by the initialisation routine. To
  33361. * set a default use {@link DataTable.defaults}.
  33362. * @type function
  33363. */
  33364. "fnFormatNumber": null,
  33365. /**
  33366. * List of options that can be used for the user selectable length menu.
  33367. * Note that this parameter will be set by the initialisation routine. To
  33368. * set a default use {@link DataTable.defaults}.
  33369. * @type array
  33370. * @default []
  33371. */
  33372. "aLengthMenu": null,
  33373. /**
  33374. * Counter for the draws that the table does. Also used as a tracker for
  33375. * server-side processing
  33376. * @type int
  33377. * @default 0
  33378. */
  33379. "iDraw": 0,
  33380. /**
  33381. * Indicate if a redraw is being done - useful for Ajax
  33382. * @type boolean
  33383. * @default false
  33384. */
  33385. "bDrawing": false,
  33386. /**
  33387. * Draw index (iDraw) of the last error when parsing the returned data
  33388. * @type int
  33389. * @default -1
  33390. */
  33391. "iDrawError": -1,
  33392. /**
  33393. * Paging display length
  33394. * @type int
  33395. * @default 10
  33396. */
  33397. "_iDisplayLength": 10,
  33398. /**
  33399. * Paging start point - aiDisplay index
  33400. * @type int
  33401. * @default 0
  33402. */
  33403. "_iDisplayStart": 0,
  33404. /**
  33405. * Server-side processing - number of records in the result set
  33406. * (i.e. before filtering), Use fnRecordsTotal rather than
  33407. * this property to get the value of the number of records, regardless of
  33408. * the server-side processing setting.
  33409. * @type int
  33410. * @default 0
  33411. * @private
  33412. */
  33413. "_iRecordsTotal": 0,
  33414. /**
  33415. * Server-side processing - number of records in the current display set
  33416. * (i.e. after filtering). Use fnRecordsDisplay rather than
  33417. * this property to get the value of the number of records, regardless of
  33418. * the server-side processing setting.
  33419. * @type boolean
  33420. * @default 0
  33421. * @private
  33422. */
  33423. "_iRecordsDisplay": 0,
  33424. /**
  33425. * Flag to indicate if jQuery UI marking and classes should be used.
  33426. * Note that this parameter will be set by the initialisation routine. To
  33427. * set a default use {@link DataTable.defaults}.
  33428. * @type boolean
  33429. */
  33430. "bJUI": null,
  33431. /**
  33432. * The classes to use for the table
  33433. * @type object
  33434. * @default {}
  33435. */
  33436. "oClasses": {},
  33437. /**
  33438. * Flag attached to the settings object so you can check in the draw
  33439. * callback if filtering has been done in the draw. Deprecated in favour of
  33440. * events.
  33441. * @type boolean
  33442. * @default false
  33443. * @deprecated
  33444. */
  33445. "bFiltered": false,
  33446. /**
  33447. * Flag attached to the settings object so you can check in the draw
  33448. * callback if sorting has been done in the draw. Deprecated in favour of
  33449. * events.
  33450. * @type boolean
  33451. * @default false
  33452. * @deprecated
  33453. */
  33454. "bSorted": false,
  33455. /**
  33456. * Indicate that if multiple rows are in the header and there is more than
  33457. * one unique cell per column, if the top one (true) or bottom one (false)
  33458. * should be used for sorting / title by DataTables.
  33459. * Note that this parameter will be set by the initialisation routine. To
  33460. * set a default use {@link DataTable.defaults}.
  33461. * @type boolean
  33462. */
  33463. "bSortCellsTop": null,
  33464. /**
  33465. * Initialisation object that is used for the table
  33466. * @type object
  33467. * @default null
  33468. */
  33469. "oInit": null,
  33470. /**
  33471. * Destroy callback functions - for plug-ins to attach themselves to the
  33472. * destroy so they can clean up markup and events.
  33473. * @type array
  33474. * @default []
  33475. */
  33476. "aoDestroyCallback": [],
  33477. /**
  33478. * Get the number of records in the current record set, before filtering
  33479. * @type function
  33480. */
  33481. "fnRecordsTotal": function ()
  33482. {
  33483. return _fnDataSource( this ) == 'ssp' ?
  33484. this._iRecordsTotal * 1 :
  33485. this.aiDisplayMaster.length;
  33486. },
  33487. /**
  33488. * Get the number of records in the current record set, after filtering
  33489. * @type function
  33490. */
  33491. "fnRecordsDisplay": function ()
  33492. {
  33493. return _fnDataSource( this ) == 'ssp' ?
  33494. this._iRecordsDisplay * 1 :
  33495. this.aiDisplay.length;
  33496. },
  33497. /**
  33498. * Get the display end point - aiDisplay index
  33499. * @type function
  33500. */
  33501. "fnDisplayEnd": function ()
  33502. {
  33503. var
  33504. len = this._iDisplayLength,
  33505. start = this._iDisplayStart,
  33506. calc = start + len,
  33507. records = this.aiDisplay.length,
  33508. features = this.oFeatures,
  33509. paginate = features.bPaginate;
  33510. if ( features.bServerSide ) {
  33511. return paginate === false || len === -1 ?
  33512. start + records :
  33513. Math.min( start+len, this._iRecordsDisplay );
  33514. }
  33515. else {
  33516. return ! paginate || calc>records || len===-1 ?
  33517. records :
  33518. calc;
  33519. }
  33520. },
  33521. /**
  33522. * The DataTables object for this table
  33523. * @type object
  33524. * @default null
  33525. */
  33526. "oInstance": null,
  33527. /**
  33528. * Unique identifier for each instance of the DataTables object. If there
  33529. * is an ID on the table node, then it takes that value, otherwise an
  33530. * incrementing internal counter is used.
  33531. * @type string
  33532. * @default null
  33533. */
  33534. "sInstance": null,
  33535. /**
  33536. * tabindex attribute value that is added to DataTables control elements, allowing
  33537. * keyboard navigation of the table and its controls.
  33538. */
  33539. "iTabIndex": 0,
  33540. /**
  33541. * DIV container for the footer scrolling table if scrolling
  33542. */
  33543. "nScrollHead": null,
  33544. /**
  33545. * DIV container for the footer scrolling table if scrolling
  33546. */
  33547. "nScrollFoot": null,
  33548. /**
  33549. * Last applied sort
  33550. * @type array
  33551. * @default []
  33552. */
  33553. "aLastSort": [],
  33554. /**
  33555. * Stored plug-in instances
  33556. * @type object
  33557. * @default {}
  33558. */
  33559. "oPlugins": {},
  33560. /**
  33561. * Function used to get a row's id from the row's data
  33562. * @type function
  33563. * @default null
  33564. */
  33565. "rowIdFn": null,
  33566. /**
  33567. * Data location where to store a row's id
  33568. * @type string
  33569. * @default null
  33570. */
  33571. "rowId": null
  33572. };
  33573. /**
  33574. * Extension object for DataTables that is used to provide all extension
  33575. * options.
  33576. *
  33577. * Note that the `DataTable.ext` object is available through
  33578. * `jQuery.fn.dataTable.ext` where it may be accessed and manipulated. It is
  33579. * also aliased to `jQuery.fn.dataTableExt` for historic reasons.
  33580. * @namespace
  33581. * @extends DataTable.models.ext
  33582. */
  33583. /**
  33584. * DataTables extensions
  33585. *
  33586. * This namespace acts as a collection area for plug-ins that can be used to
  33587. * extend DataTables capabilities. Indeed many of the build in methods
  33588. * use this method to provide their own capabilities (sorting methods for
  33589. * example).
  33590. *
  33591. * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
  33592. * reasons
  33593. *
  33594. * @namespace
  33595. */
  33596. DataTable.ext = _ext = {
  33597. /**
  33598. * Buttons. For use with the Buttons extension for DataTables. This is
  33599. * defined here so other extensions can define buttons regardless of load
  33600. * order. It is _not_ used by DataTables core.
  33601. *
  33602. * @type object
  33603. * @default {}
  33604. */
  33605. buttons: {},
  33606. /**
  33607. * Element class names
  33608. *
  33609. * @type object
  33610. * @default {}
  33611. */
  33612. classes: {},
  33613. /**
  33614. * DataTables build type (expanded by the download builder)
  33615. *
  33616. * @type string
  33617. */
  33618. builder: "-source-",
  33619. /**
  33620. * Error reporting.
  33621. *
  33622. * How should DataTables report an error. Can take the value 'alert',
  33623. * 'throw', 'none' or a function.
  33624. *
  33625. * @type string|function
  33626. * @default alert
  33627. */
  33628. errMode: "alert",
  33629. /**
  33630. * Feature plug-ins.
  33631. *
  33632. * This is an array of objects which describe the feature plug-ins that are
  33633. * available to DataTables. These feature plug-ins are then available for
  33634. * use through the `dom` initialisation option.
  33635. *
  33636. * Each feature plug-in is described by an object which must have the
  33637. * following properties:
  33638. *
  33639. * * `fnInit` - function that is used to initialise the plug-in,
  33640. * * `cFeature` - a character so the feature can be enabled by the `dom`
  33641. * instillation option. This is case sensitive.
  33642. *
  33643. * The `fnInit` function has the following input parameters:
  33644. *
  33645. * 1. `{object}` DataTables settings object: see
  33646. * {@link DataTable.models.oSettings}
  33647. *
  33648. * And the following return is expected:
  33649. *
  33650. * * {node|null} The element which contains your feature. Note that the
  33651. * return may also be void if your plug-in does not require to inject any
  33652. * DOM elements into DataTables control (`dom`) - for example this might
  33653. * be useful when developing a plug-in which allows table control via
  33654. * keyboard entry
  33655. *
  33656. * @type array
  33657. *
  33658. * @example
  33659. * $.fn.dataTable.ext.features.push( {
  33660. * "fnInit": function( oSettings ) {
  33661. * return new TableTools( { "oDTSettings": oSettings } );
  33662. * },
  33663. * "cFeature": "T"
  33664. * } );
  33665. */
  33666. feature: [],
  33667. /**
  33668. * Row searching.
  33669. *
  33670. * This method of searching is complimentary to the default type based
  33671. * searching, and a lot more comprehensive as it allows you complete control
  33672. * over the searching logic. Each element in this array is a function
  33673. * (parameters described below) that is called for every row in the table,
  33674. * and your logic decides if it should be included in the searching data set
  33675. * or not.
  33676. *
  33677. * Searching functions have the following input parameters:
  33678. *
  33679. * 1. `{object}` DataTables settings object: see
  33680. * {@link DataTable.models.oSettings}
  33681. * 2. `{array|object}` Data for the row to be processed (same as the
  33682. * original format that was passed in as the data source, or an array
  33683. * from a DOM data source
  33684. * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
  33685. * can be useful to retrieve the `TR` element if you need DOM interaction.
  33686. *
  33687. * And the following return is expected:
  33688. *
  33689. * * {boolean} Include the row in the searched result set (true) or not
  33690. * (false)
  33691. *
  33692. * Note that as with the main search ability in DataTables, technically this
  33693. * is "filtering", since it is subtractive. However, for consistency in
  33694. * naming we call it searching here.
  33695. *
  33696. * @type array
  33697. * @default []
  33698. *
  33699. * @example
  33700. * // The following example shows custom search being applied to the
  33701. * // fourth column (i.e. the data[3] index) based on two input values
  33702. * // from the end-user, matching the data in a certain range.
  33703. * $.fn.dataTable.ext.search.push(
  33704. * function( settings, data, dataIndex ) {
  33705. * var min = document.getElementById('min').value * 1;
  33706. * var max = document.getElementById('max').value * 1;
  33707. * var version = data[3] == "-" ? 0 : data[3]*1;
  33708. *
  33709. * if ( min == "" && max == "" ) {
  33710. * return true;
  33711. * }
  33712. * else if ( min == "" && version < max ) {
  33713. * return true;
  33714. * }
  33715. * else if ( min < version && "" == max ) {
  33716. * return true;
  33717. * }
  33718. * else if ( min < version && version < max ) {
  33719. * return true;
  33720. * }
  33721. * return false;
  33722. * }
  33723. * );
  33724. */
  33725. search: [],
  33726. /**
  33727. * Selector extensions
  33728. *
  33729. * The `selector` option can be used to extend the options available for the
  33730. * selector modifier options (`selector-modifier` object data type) that
  33731. * each of the three built in selector types offer (row, column and cell +
  33732. * their plural counterparts). For example the Select extension uses this
  33733. * mechanism to provide an option to select only rows, columns and cells
  33734. * that have been marked as selected by the end user (`{selected: true}`),
  33735. * which can be used in conjunction with the existing built in selector
  33736. * options.
  33737. *
  33738. * Each property is an array to which functions can be pushed. The functions
  33739. * take three attributes:
  33740. *
  33741. * * Settings object for the host table
  33742. * * Options object (`selector-modifier` object type)
  33743. * * Array of selected item indexes
  33744. *
  33745. * The return is an array of the resulting item indexes after the custom
  33746. * selector has been applied.
  33747. *
  33748. * @type object
  33749. */
  33750. selector: {
  33751. cell: [],
  33752. column: [],
  33753. row: []
  33754. },
  33755. /**
  33756. * Internal functions, exposed for used in plug-ins.
  33757. *
  33758. * Please note that you should not need to use the internal methods for
  33759. * anything other than a plug-in (and even then, try to avoid if possible).
  33760. * The internal function may change between releases.
  33761. *
  33762. * @type object
  33763. * @default {}
  33764. */
  33765. internal: {},
  33766. /**
  33767. * Legacy configuration options. Enable and disable legacy options that
  33768. * are available in DataTables.
  33769. *
  33770. * @type object
  33771. */
  33772. legacy: {
  33773. /**
  33774. * Enable / disable DataTables 1.9 compatible server-side processing
  33775. * requests
  33776. *
  33777. * @type boolean
  33778. * @default null
  33779. */
  33780. ajax: null
  33781. },
  33782. /**
  33783. * Pagination plug-in methods.
  33784. *
  33785. * Each entry in this object is a function and defines which buttons should
  33786. * be shown by the pagination rendering method that is used for the table:
  33787. * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
  33788. * buttons are displayed in the document, while the functions here tell it
  33789. * what buttons to display. This is done by returning an array of button
  33790. * descriptions (what each button will do).
  33791. *
  33792. * Pagination types (the four built in options and any additional plug-in
  33793. * options defined here) can be used through the `paginationType`
  33794. * initialisation parameter.
  33795. *
  33796. * The functions defined take two parameters:
  33797. *
  33798. * 1. `{int} page` The current page index
  33799. * 2. `{int} pages` The number of pages in the table
  33800. *
  33801. * Each function is expected to return an array where each element of the
  33802. * array can be one of:
  33803. *
  33804. * * `first` - Jump to first page when activated
  33805. * * `last` - Jump to last page when activated
  33806. * * `previous` - Show previous page when activated
  33807. * * `next` - Show next page when activated
  33808. * * `{int}` - Show page of the index given
  33809. * * `{array}` - A nested array containing the above elements to add a
  33810. * containing 'DIV' element (might be useful for styling).
  33811. *
  33812. * Note that DataTables v1.9- used this object slightly differently whereby
  33813. * an object with two functions would be defined for each plug-in. That
  33814. * ability is still supported by DataTables 1.10+ to provide backwards
  33815. * compatibility, but this option of use is now decremented and no longer
  33816. * documented in DataTables 1.10+.
  33817. *
  33818. * @type object
  33819. * @default {}
  33820. *
  33821. * @example
  33822. * // Show previous, next and current page buttons only
  33823. * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
  33824. * return [ 'previous', page, 'next' ];
  33825. * };
  33826. */
  33827. pager: {},
  33828. renderer: {
  33829. pageButton: {},
  33830. header: {}
  33831. },
  33832. /**
  33833. * Ordering plug-ins - custom data source
  33834. *
  33835. * The extension options for ordering of data available here is complimentary
  33836. * to the default type based ordering that DataTables typically uses. It
  33837. * allows much greater control over the the data that is being used to
  33838. * order a column, but is necessarily therefore more complex.
  33839. *
  33840. * This type of ordering is useful if you want to do ordering based on data
  33841. * live from the DOM (for example the contents of an 'input' element) rather
  33842. * than just the static string that DataTables knows of.
  33843. *
  33844. * The way these plug-ins work is that you create an array of the values you
  33845. * wish to be ordering for the column in question and then return that
  33846. * array. The data in the array much be in the index order of the rows in
  33847. * the table (not the currently ordering order!). Which order data gathering
  33848. * function is run here depends on the `dt-init columns.orderDataType`
  33849. * parameter that is used for the column (if any).
  33850. *
  33851. * The functions defined take two parameters:
  33852. *
  33853. * 1. `{object}` DataTables settings object: see
  33854. * {@link DataTable.models.oSettings}
  33855. * 2. `{int}` Target column index
  33856. *
  33857. * Each function is expected to return an array:
  33858. *
  33859. * * `{array}` Data for the column to be ordering upon
  33860. *
  33861. * @type array
  33862. *
  33863. * @example
  33864. * // Ordering using `input` node values
  33865. * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
  33866. * {
  33867. * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
  33868. * return $('input', td).val();
  33869. * } );
  33870. * }
  33871. */
  33872. order: {},
  33873. /**
  33874. * Type based plug-ins.
  33875. *
  33876. * Each column in DataTables has a type assigned to it, either by automatic
  33877. * detection or by direct assignment using the `type` option for the column.
  33878. * The type of a column will effect how it is ordering and search (plug-ins
  33879. * can also make use of the column type if required).
  33880. *
  33881. * @namespace
  33882. */
  33883. type: {
  33884. /**
  33885. * Type detection functions.
  33886. *
  33887. * The functions defined in this object are used to automatically detect
  33888. * a column's type, making initialisation of DataTables super easy, even
  33889. * when complex data is in the table.
  33890. *
  33891. * The functions defined take two parameters:
  33892. *
  33893. * 1. `{*}` Data from the column cell to be analysed
  33894. * 2. `{settings}` DataTables settings object. This can be used to
  33895. * perform context specific type detection - for example detection
  33896. * based on language settings such as using a comma for a decimal
  33897. * place. Generally speaking the options from the settings will not
  33898. * be required
  33899. *
  33900. * Each function is expected to return:
  33901. *
  33902. * * `{string|null}` Data type detected, or null if unknown (and thus
  33903. * pass it on to the other type detection functions.
  33904. *
  33905. * @type array
  33906. *
  33907. * @example
  33908. * // Currency type detection plug-in:
  33909. * $.fn.dataTable.ext.type.detect.push(
  33910. * function ( data, settings ) {
  33911. * // Check the numeric part
  33912. * if ( ! $.isNumeric( data.substring(1) ) ) {
  33913. * return null;
  33914. * }
  33915. *
  33916. * // Check prefixed by currency
  33917. * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
  33918. * return 'currency';
  33919. * }
  33920. * return null;
  33921. * }
  33922. * );
  33923. */
  33924. detect: [],
  33925. /**
  33926. * Type based search formatting.
  33927. *
  33928. * The type based searching functions can be used to pre-format the
  33929. * data to be search on. For example, it can be used to strip HTML
  33930. * tags or to de-format telephone numbers for numeric only searching.
  33931. *
  33932. * Note that is a search is not defined for a column of a given type,
  33933. * no search formatting will be performed.
  33934. *
  33935. * Pre-processing of searching data plug-ins - When you assign the sType
  33936. * for a column (or have it automatically detected for you by DataTables
  33937. * or a type detection plug-in), you will typically be using this for
  33938. * custom sorting, but it can also be used to provide custom searching
  33939. * by allowing you to pre-processing the data and returning the data in
  33940. * the format that should be searched upon. This is done by adding
  33941. * functions this object with a parameter name which matches the sType
  33942. * for that target column. This is the corollary of <i>afnSortData</i>
  33943. * for searching data.
  33944. *
  33945. * The functions defined take a single parameter:
  33946. *
  33947. * 1. `{*}` Data from the column cell to be prepared for searching
  33948. *
  33949. * Each function is expected to return:
  33950. *
  33951. * * `{string|null}` Formatted string that will be used for the searching.
  33952. *
  33953. * @type object
  33954. * @default {}
  33955. *
  33956. * @example
  33957. * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
  33958. * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
  33959. * }
  33960. */
  33961. search: {},
  33962. /**
  33963. * Type based ordering.
  33964. *
  33965. * The column type tells DataTables what ordering to apply to the table
  33966. * when a column is sorted upon. The order for each type that is defined,
  33967. * is defined by the functions available in this object.
  33968. *
  33969. * Each ordering option can be described by three properties added to
  33970. * this object:
  33971. *
  33972. * * `{type}-pre` - Pre-formatting function
  33973. * * `{type}-asc` - Ascending order function
  33974. * * `{type}-desc` - Descending order function
  33975. *
  33976. * All three can be used together, only `{type}-pre` or only
  33977. * `{type}-asc` and `{type}-desc` together. It is generally recommended
  33978. * that only `{type}-pre` is used, as this provides the optimal
  33979. * implementation in terms of speed, although the others are provided
  33980. * for compatibility with existing Javascript sort functions.
  33981. *
  33982. * `{type}-pre`: Functions defined take a single parameter:
  33983. *
  33984. * 1. `{*}` Data from the column cell to be prepared for ordering
  33985. *
  33986. * And return:
  33987. *
  33988. * * `{*}` Data to be sorted upon
  33989. *
  33990. * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
  33991. * functions, taking two parameters:
  33992. *
  33993. * 1. `{*}` Data to compare to the second parameter
  33994. * 2. `{*}` Data to compare to the first parameter
  33995. *
  33996. * And returning:
  33997. *
  33998. * * `{*}` Ordering match: <0 if first parameter should be sorted lower
  33999. * than the second parameter, ===0 if the two parameters are equal and
  34000. * >0 if the first parameter should be sorted height than the second
  34001. * parameter.
  34002. *
  34003. * @type object
  34004. * @default {}
  34005. *
  34006. * @example
  34007. * // Numeric ordering of formatted numbers with a pre-formatter
  34008. * $.extend( $.fn.dataTable.ext.type.order, {
  34009. * "string-pre": function(x) {
  34010. * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
  34011. * return parseFloat( a );
  34012. * }
  34013. * } );
  34014. *
  34015. * @example
  34016. * // Case-sensitive string ordering, with no pre-formatting method
  34017. * $.extend( $.fn.dataTable.ext.order, {
  34018. * "string-case-asc": function(x,y) {
  34019. * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  34020. * },
  34021. * "string-case-desc": function(x,y) {
  34022. * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  34023. * }
  34024. * } );
  34025. */
  34026. order: {}
  34027. },
  34028. /**
  34029. * Unique DataTables instance counter
  34030. *
  34031. * @type int
  34032. * @private
  34033. */
  34034. _unique: 0,
  34035. //
  34036. // Depreciated
  34037. // The following properties are retained for backwards compatiblity only.
  34038. // The should not be used in new projects and will be removed in a future
  34039. // version
  34040. //
  34041. /**
  34042. * Version check function.
  34043. * @type function
  34044. * @depreciated Since 1.10
  34045. */
  34046. fnVersionCheck: DataTable.fnVersionCheck,
  34047. /**
  34048. * Index for what 'this' index API functions should use
  34049. * @type int
  34050. * @deprecated Since v1.10
  34051. */
  34052. iApiIndex: 0,
  34053. /**
  34054. * jQuery UI class container
  34055. * @type object
  34056. * @deprecated Since v1.10
  34057. */
  34058. oJUIClasses: {},
  34059. /**
  34060. * Software version
  34061. * @type string
  34062. * @deprecated Since v1.10
  34063. */
  34064. sVersion: DataTable.version
  34065. };
  34066. //
  34067. // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
  34068. //
  34069. $.extend( _ext, {
  34070. afnFiltering: _ext.search,
  34071. aTypes: _ext.type.detect,
  34072. ofnSearch: _ext.type.search,
  34073. oSort: _ext.type.order,
  34074. afnSortData: _ext.order,
  34075. aoFeatures: _ext.feature,
  34076. oApi: _ext.internal,
  34077. oStdClasses: _ext.classes,
  34078. oPagination: _ext.pager
  34079. } );
  34080. $.extend( DataTable.ext.classes, {
  34081. "sTable": "dataTable",
  34082. "sNoFooter": "no-footer",
  34083. /* Paging buttons */
  34084. "sPageButton": "paginate_button",
  34085. "sPageButtonActive": "current",
  34086. "sPageButtonDisabled": "disabled",
  34087. /* Striping classes */
  34088. "sStripeOdd": "odd",
  34089. "sStripeEven": "even",
  34090. /* Empty row */
  34091. "sRowEmpty": "dataTables_empty",
  34092. /* Features */
  34093. "sWrapper": "dataTables_wrapper",
  34094. "sFilter": "dataTables_filter",
  34095. "sInfo": "dataTables_info",
  34096. "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
  34097. "sLength": "dataTables_length",
  34098. "sProcessing": "dataTables_processing",
  34099. /* Sorting */
  34100. "sSortAsc": "sorting_asc",
  34101. "sSortDesc": "sorting_desc",
  34102. "sSortable": "sorting", /* Sortable in both directions */
  34103. "sSortableAsc": "sorting_asc_disabled",
  34104. "sSortableDesc": "sorting_desc_disabled",
  34105. "sSortableNone": "sorting_disabled",
  34106. "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
  34107. /* Filtering */
  34108. "sFilterInput": "",
  34109. /* Page length */
  34110. "sLengthSelect": "",
  34111. /* Scrolling */
  34112. "sScrollWrapper": "dataTables_scroll",
  34113. "sScrollHead": "dataTables_scrollHead",
  34114. "sScrollHeadInner": "dataTables_scrollHeadInner",
  34115. "sScrollBody": "dataTables_scrollBody",
  34116. "sScrollFoot": "dataTables_scrollFoot",
  34117. "sScrollFootInner": "dataTables_scrollFootInner",
  34118. /* Misc */
  34119. "sHeaderTH": "",
  34120. "sFooterTH": "",
  34121. // Deprecated
  34122. "sSortJUIAsc": "",
  34123. "sSortJUIDesc": "",
  34124. "sSortJUI": "",
  34125. "sSortJUIAscAllowed": "",
  34126. "sSortJUIDescAllowed": "",
  34127. "sSortJUIWrapper": "",
  34128. "sSortIcon": "",
  34129. "sJUIHeader": "",
  34130. "sJUIFooter": ""
  34131. } );
  34132. (function() {
  34133. // Reused strings for better compression. Closure compiler appears to have a
  34134. // weird edge case where it is trying to expand strings rather than use the
  34135. // variable version. This results in about 200 bytes being added, for very
  34136. // little preference benefit since it this run on script load only.
  34137. var _empty = '';
  34138. _empty = '';
  34139. var _stateDefault = _empty + 'ui-state-default';
  34140. var _sortIcon = _empty + 'css_right ui-icon ui-icon-';
  34141. var _headerFooter = _empty + 'fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix';
  34142. $.extend( DataTable.ext.oJUIClasses, DataTable.ext.classes, {
  34143. /* Full numbers paging buttons */
  34144. "sPageButton": "fg-button ui-button "+_stateDefault,
  34145. "sPageButtonActive": "ui-state-disabled",
  34146. "sPageButtonDisabled": "ui-state-disabled",
  34147. /* Features */
  34148. "sPaging": "dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi "+
  34149. "ui-buttonset-multi paging_", /* Note that the type is postfixed */
  34150. /* Sorting */
  34151. "sSortAsc": _stateDefault+" sorting_asc",
  34152. "sSortDesc": _stateDefault+" sorting_desc",
  34153. "sSortable": _stateDefault+" sorting",
  34154. "sSortableAsc": _stateDefault+" sorting_asc_disabled",
  34155. "sSortableDesc": _stateDefault+" sorting_desc_disabled",
  34156. "sSortableNone": _stateDefault+" sorting_disabled",
  34157. "sSortJUIAsc": _sortIcon+"triangle-1-n",
  34158. "sSortJUIDesc": _sortIcon+"triangle-1-s",
  34159. "sSortJUI": _sortIcon+"carat-2-n-s",
  34160. "sSortJUIAscAllowed": _sortIcon+"carat-1-n",
  34161. "sSortJUIDescAllowed": _sortIcon+"carat-1-s",
  34162. "sSortJUIWrapper": "DataTables_sort_wrapper",
  34163. "sSortIcon": "DataTables_sort_icon",
  34164. /* Scrolling */
  34165. "sScrollHead": "dataTables_scrollHead "+_stateDefault,
  34166. "sScrollFoot": "dataTables_scrollFoot "+_stateDefault,
  34167. /* Misc */
  34168. "sHeaderTH": _stateDefault,
  34169. "sFooterTH": _stateDefault,
  34170. "sJUIHeader": _headerFooter+" ui-corner-tl ui-corner-tr",
  34171. "sJUIFooter": _headerFooter+" ui-corner-bl ui-corner-br"
  34172. } );
  34173. }());
  34174. var extPagination = DataTable.ext.pager;
  34175. function _numbers ( page, pages ) {
  34176. var
  34177. numbers = [],
  34178. buttons = extPagination.numbers_length,
  34179. half = Math.floor( buttons / 2 ),
  34180. i = 1;
  34181. if ( pages <= buttons ) {
  34182. numbers = _range( 0, pages );
  34183. }
  34184. else if ( page <= half ) {
  34185. numbers = _range( 0, buttons-2 );
  34186. numbers.push( 'ellipsis' );
  34187. numbers.push( pages-1 );
  34188. }
  34189. else if ( page >= pages - 1 - half ) {
  34190. numbers = _range( pages-(buttons-2), pages );
  34191. numbers.splice( 0, 0, 'ellipsis' ); // no unshift in ie6
  34192. numbers.splice( 0, 0, 0 );
  34193. }
  34194. else {
  34195. numbers = _range( page-half+2, page+half-1 );
  34196. numbers.push( 'ellipsis' );
  34197. numbers.push( pages-1 );
  34198. numbers.splice( 0, 0, 'ellipsis' );
  34199. numbers.splice( 0, 0, 0 );
  34200. }
  34201. numbers.DT_el = 'span';
  34202. return numbers;
  34203. }
  34204. $.extend( extPagination, {
  34205. simple: function ( page, pages ) {
  34206. return [ 'previous', 'next' ];
  34207. },
  34208. full: function ( page, pages ) {
  34209. return [ 'first', 'previous', 'next', 'last' ];
  34210. },
  34211. numbers: function ( page, pages ) {
  34212. return [ _numbers(page, pages) ];
  34213. },
  34214. simple_numbers: function ( page, pages ) {
  34215. return [ 'previous', _numbers(page, pages), 'next' ];
  34216. },
  34217. full_numbers: function ( page, pages ) {
  34218. return [ 'first', 'previous', _numbers(page, pages), 'next', 'last' ];
  34219. },
  34220. // For testing and plug-ins to use
  34221. _numbers: _numbers,
  34222. // Number of number buttons (including ellipsis) to show. _Must be odd!_
  34223. numbers_length: 7
  34224. } );
  34225. $.extend( true, DataTable.ext.renderer, {
  34226. pageButton: {
  34227. _: function ( settings, host, idx, buttons, page, pages ) {
  34228. var classes = settings.oClasses;
  34229. var lang = settings.oLanguage.oPaginate;
  34230. var aria = settings.oLanguage.oAria.paginate || {};
  34231. var btnDisplay, btnClass, counter=0;
  34232. var attach = function( container, buttons ) {
  34233. var i, ien, node, button;
  34234. var clickHandler = function ( e ) {
  34235. _fnPageChange( settings, e.data.action, true );
  34236. };
  34237. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  34238. button = buttons[i];
  34239. if ( $.isArray( button ) ) {
  34240. var inner = $( '<'+(button.DT_el || 'div')+'/>' )
  34241. .appendTo( container );
  34242. attach( inner, button );
  34243. }
  34244. else {
  34245. btnDisplay = null;
  34246. btnClass = '';
  34247. switch ( button ) {
  34248. case 'ellipsis':
  34249. container.append('<span class="ellipsis">&#x2026;</span>');
  34250. break;
  34251. case 'first':
  34252. btnDisplay = lang.sFirst;
  34253. btnClass = button + (page > 0 ?
  34254. '' : ' '+classes.sPageButtonDisabled);
  34255. break;
  34256. case 'previous':
  34257. btnDisplay = lang.sPrevious;
  34258. btnClass = button + (page > 0 ?
  34259. '' : ' '+classes.sPageButtonDisabled);
  34260. break;
  34261. case 'next':
  34262. btnDisplay = lang.sNext;
  34263. btnClass = button + (page < pages-1 ?
  34264. '' : ' '+classes.sPageButtonDisabled);
  34265. break;
  34266. case 'last':
  34267. btnDisplay = lang.sLast;
  34268. btnClass = button + (page < pages-1 ?
  34269. '' : ' '+classes.sPageButtonDisabled);
  34270. break;
  34271. default:
  34272. btnDisplay = button + 1;
  34273. btnClass = page === button ?
  34274. classes.sPageButtonActive : '';
  34275. break;
  34276. }
  34277. if ( btnDisplay !== null ) {
  34278. node = $('<a>', {
  34279. 'class': classes.sPageButton+' '+btnClass,
  34280. 'aria-controls': settings.sTableId,
  34281. 'aria-label': aria[ button ],
  34282. 'data-dt-idx': counter,
  34283. 'tabindex': settings.iTabIndex,
  34284. 'id': idx === 0 && typeof button === 'string' ?
  34285. settings.sTableId +'_'+ button :
  34286. null
  34287. } )
  34288. .html( btnDisplay )
  34289. .appendTo( container );
  34290. _fnBindAction(
  34291. node, {action: button}, clickHandler
  34292. );
  34293. counter++;
  34294. }
  34295. }
  34296. }
  34297. };
  34298. // IE9 throws an 'unknown error' if document.activeElement is used
  34299. // inside an iframe or frame. Try / catch the error. Not good for
  34300. // accessibility, but neither are frames.
  34301. var activeEl;
  34302. try {
  34303. // Because this approach is destroying and recreating the paging
  34304. // elements, focus is lost on the select button which is bad for
  34305. // accessibility. So we want to restore focus once the draw has
  34306. // completed
  34307. activeEl = $(host).find(document.activeElement).data('dt-idx');
  34308. }
  34309. catch (e) {}
  34310. attach( $(host).empty(), buttons );
  34311. if ( activeEl ) {
  34312. $(host).find( '[data-dt-idx='+activeEl+']' ).focus();
  34313. }
  34314. }
  34315. }
  34316. } );
  34317. // Built in type detection. See model.ext.aTypes for information about
  34318. // what is required from this methods.
  34319. $.extend( DataTable.ext.type.detect, [
  34320. // Plain numbers - first since V8 detects some plain numbers as dates
  34321. // e.g. Date.parse('55') (but not all, e.g. Date.parse('22')...).
  34322. function ( d, settings )
  34323. {
  34324. var decimal = settings.oLanguage.sDecimal;
  34325. return _isNumber( d, decimal ) ? 'num'+decimal : null;
  34326. },
  34327. // Dates (only those recognised by the browser's Date.parse)
  34328. function ( d, settings )
  34329. {
  34330. // V8 will remove any unknown characters at the start and end of the
  34331. // expression, leading to false matches such as `$245.12` or `10%` being
  34332. // a valid date. See forum thread 18941 for detail.
  34333. if ( d && !(d instanceof Date) && ( ! _re_date_start.test(d) || ! _re_date_end.test(d) ) ) {
  34334. return null;
  34335. }
  34336. var parsed = Date.parse(d);
  34337. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  34338. },
  34339. // Formatted numbers
  34340. function ( d, settings )
  34341. {
  34342. var decimal = settings.oLanguage.sDecimal;
  34343. return _isNumber( d, decimal, true ) ? 'num-fmt'+decimal : null;
  34344. },
  34345. // HTML numeric
  34346. function ( d, settings )
  34347. {
  34348. var decimal = settings.oLanguage.sDecimal;
  34349. return _htmlNumeric( d, decimal ) ? 'html-num'+decimal : null;
  34350. },
  34351. // HTML numeric, formatted
  34352. function ( d, settings )
  34353. {
  34354. var decimal = settings.oLanguage.sDecimal;
  34355. return _htmlNumeric( d, decimal, true ) ? 'html-num-fmt'+decimal : null;
  34356. },
  34357. // HTML (this is strict checking - there must be html)
  34358. function ( d, settings )
  34359. {
  34360. return _empty( d ) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  34361. 'html' : null;
  34362. }
  34363. ] );
  34364. // Filter formatting functions. See model.ext.ofnSearch for information about
  34365. // what is required from these methods.
  34366. //
  34367. // Note that additional search methods are added for the html numbers and
  34368. // html formatted numbers by `_addNumericSort()` when we know what the decimal
  34369. // place is
  34370. $.extend( DataTable.ext.type.search, {
  34371. html: function ( data ) {
  34372. return _empty(data) ?
  34373. data :
  34374. typeof data === 'string' ?
  34375. data
  34376. .replace( _re_new_lines, " " )
  34377. .replace( _re_html, "" ) :
  34378. '';
  34379. },
  34380. string: function ( data ) {
  34381. return _empty(data) ?
  34382. data :
  34383. typeof data === 'string' ?
  34384. data.replace( _re_new_lines, " " ) :
  34385. data;
  34386. }
  34387. } );
  34388. var __numericReplace = function ( d, decimalPlace, re1, re2 ) {
  34389. if ( d !== 0 && (!d || d === '-') ) {
  34390. return -Infinity;
  34391. }
  34392. // If a decimal place other than `.` is used, it needs to be given to the
  34393. // function so we can detect it and replace with a `.` which is the only
  34394. // decimal place Javascript recognises - it is not locale aware.
  34395. if ( decimalPlace ) {
  34396. d = _numToDecimal( d, decimalPlace );
  34397. }
  34398. if ( d.replace ) {
  34399. if ( re1 ) {
  34400. d = d.replace( re1, '' );
  34401. }
  34402. if ( re2 ) {
  34403. d = d.replace( re2, '' );
  34404. }
  34405. }
  34406. return d * 1;
  34407. };
  34408. // Add the numeric 'deformatting' functions for sorting and search. This is done
  34409. // in a function to provide an easy ability for the language options to add
  34410. // additional methods if a non-period decimal place is used.
  34411. function _addNumericSort ( decimalPlace ) {
  34412. $.each(
  34413. {
  34414. // Plain numbers
  34415. "num": function ( d ) {
  34416. return __numericReplace( d, decimalPlace );
  34417. },
  34418. // Formatted numbers
  34419. "num-fmt": function ( d ) {
  34420. return __numericReplace( d, decimalPlace, _re_formatted_numeric );
  34421. },
  34422. // HTML numeric
  34423. "html-num": function ( d ) {
  34424. return __numericReplace( d, decimalPlace, _re_html );
  34425. },
  34426. // HTML numeric, formatted
  34427. "html-num-fmt": function ( d ) {
  34428. return __numericReplace( d, decimalPlace, _re_html, _re_formatted_numeric );
  34429. }
  34430. },
  34431. function ( key, fn ) {
  34432. // Add the ordering method
  34433. _ext.type.order[ key+decimalPlace+'-pre' ] = fn;
  34434. // For HTML types add a search formatter that will strip the HTML
  34435. if ( key.match(/^html\-/) ) {
  34436. _ext.type.search[ key+decimalPlace ] = _ext.type.search.html;
  34437. }
  34438. }
  34439. );
  34440. }
  34441. // Default sort methods
  34442. $.extend( _ext.type.order, {
  34443. // Dates
  34444. "date-pre": function ( d ) {
  34445. return Date.parse( d ) || 0;
  34446. },
  34447. // html
  34448. "html-pre": function ( a ) {
  34449. return _empty(a) ?
  34450. '' :
  34451. a.replace ?
  34452. a.replace( /<.*?>/g, "" ).toLowerCase() :
  34453. a+'';
  34454. },
  34455. // string
  34456. "string-pre": function ( a ) {
  34457. // This is a little complex, but faster than always calling toString,
  34458. // http://jsperf.com/tostring-v-check
  34459. return _empty(a) ?
  34460. '' :
  34461. typeof a === 'string' ?
  34462. a.toLowerCase() :
  34463. ! a.toString ?
  34464. '' :
  34465. a.toString();
  34466. },
  34467. // string-asc and -desc are retained only for compatibility with the old
  34468. // sort methods
  34469. "string-asc": function ( x, y ) {
  34470. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  34471. },
  34472. "string-desc": function ( x, y ) {
  34473. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  34474. }
  34475. } );
  34476. // Numeric sorting types - order doesn't matter here
  34477. _addNumericSort( '' );
  34478. $.extend( true, DataTable.ext.renderer, {
  34479. header: {
  34480. _: function ( settings, cell, column, classes ) {
  34481. // No additional mark-up required
  34482. // Attach a sort listener to update on sort - note that using the
  34483. // `DT` namespace will allow the event to be removed automatically
  34484. // on destroy, while the `dt` namespaced event is the one we are
  34485. // listening for
  34486. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  34487. if ( settings !== ctx ) { // need to check this this is the host
  34488. return; // table, not a nested one
  34489. }
  34490. var colIdx = column.idx;
  34491. cell
  34492. .removeClass(
  34493. column.sSortingClass +' '+
  34494. classes.sSortAsc +' '+
  34495. classes.sSortDesc
  34496. )
  34497. .addClass( columns[ colIdx ] == 'asc' ?
  34498. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  34499. classes.sSortDesc :
  34500. column.sSortingClass
  34501. );
  34502. } );
  34503. },
  34504. jqueryui: function ( settings, cell, column, classes ) {
  34505. $('<div/>')
  34506. .addClass( classes.sSortJUIWrapper )
  34507. .append( cell.contents() )
  34508. .append( $('<span/>')
  34509. .addClass( classes.sSortIcon+' '+column.sSortingClassJUI )
  34510. )
  34511. .appendTo( cell );
  34512. // Attach a sort listener to update on sort
  34513. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  34514. if ( settings !== ctx ) {
  34515. return;
  34516. }
  34517. var colIdx = column.idx;
  34518. cell
  34519. .removeClass( classes.sSortAsc +" "+classes.sSortDesc )
  34520. .addClass( columns[ colIdx ] == 'asc' ?
  34521. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  34522. classes.sSortDesc :
  34523. column.sSortingClass
  34524. );
  34525. cell
  34526. .find( 'span.'+classes.sSortIcon )
  34527. .removeClass(
  34528. classes.sSortJUIAsc +" "+
  34529. classes.sSortJUIDesc +" "+
  34530. classes.sSortJUI +" "+
  34531. classes.sSortJUIAscAllowed +" "+
  34532. classes.sSortJUIDescAllowed
  34533. )
  34534. .addClass( columns[ colIdx ] == 'asc' ?
  34535. classes.sSortJUIAsc : columns[ colIdx ] == 'desc' ?
  34536. classes.sSortJUIDesc :
  34537. column.sSortingClassJUI
  34538. );
  34539. } );
  34540. }
  34541. }
  34542. } );
  34543. /*
  34544. * Public helper functions. These aren't used internally by DataTables, or
  34545. * called by any of the options passed into DataTables, but they can be used
  34546. * externally by developers working with DataTables. They are helper functions
  34547. * to make working with DataTables a little bit easier.
  34548. */
  34549. var __htmlEscapeEntities = function ( d ) {
  34550. return typeof d === 'string' ?
  34551. d.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;') :
  34552. d;
  34553. };
  34554. /**
  34555. * Helpers for `columns.render`.
  34556. *
  34557. * The options defined here can be used with the `columns.render` initialisation
  34558. * option to provide a display renderer. The following functions are defined:
  34559. *
  34560. * * `number` - Will format numeric data (defined by `columns.data`) for
  34561. * display, retaining the original unformatted data for sorting and filtering.
  34562. * It takes 5 parameters:
  34563. * * `string` - Thousands grouping separator
  34564. * * `string` - Decimal point indicator
  34565. * * `integer` - Number of decimal points to show
  34566. * * `string` (optional) - Prefix.
  34567. * * `string` (optional) - Postfix (/suffix).
  34568. * * `text` - Escape HTML to help prevent XSS attacks. It has no optional
  34569. * parameters.
  34570. *
  34571. * @example
  34572. * // Column definition using the number renderer
  34573. * {
  34574. * data: "salary",
  34575. * render: $.fn.dataTable.render.number( '\'', '.', 0, '$' )
  34576. * }
  34577. *
  34578. * @namespace
  34579. */
  34580. DataTable.render = {
  34581. number: function ( thousands, decimal, precision, prefix, postfix ) {
  34582. return {
  34583. display: function ( d ) {
  34584. if ( typeof d !== 'number' && typeof d !== 'string' ) {
  34585. return d;
  34586. }
  34587. var negative = d < 0 ? '-' : '';
  34588. var flo = parseFloat( d );
  34589. // If NaN then there isn't much formatting that we can do - just
  34590. // return immediately, escaping any HTML (this was supposed to
  34591. // be a number after all)
  34592. if ( isNaN( flo ) ) {
  34593. return __htmlEscapeEntities( d );
  34594. }
  34595. d = Math.abs( flo );
  34596. var intPart = parseInt( d, 10 );
  34597. var floatPart = precision ?
  34598. decimal+(d - intPart).toFixed( precision ).substring( 2 ):
  34599. '';
  34600. return negative + (prefix||'') +
  34601. intPart.toString().replace(
  34602. /\B(?=(\d{3})+(?!\d))/g, thousands
  34603. ) +
  34604. floatPart +
  34605. (postfix||'');
  34606. }
  34607. };
  34608. },
  34609. text: function () {
  34610. return {
  34611. display: __htmlEscapeEntities
  34612. };
  34613. }
  34614. };
  34615. /*
  34616. * This is really a good bit rubbish this method of exposing the internal methods
  34617. * publicly... - To be fixed in 2.0 using methods on the prototype
  34618. */
  34619. /**
  34620. * Create a wrapper function for exporting an internal functions to an external API.
  34621. * @param {string} fn API function name
  34622. * @returns {function} wrapped function
  34623. * @memberof DataTable#internal
  34624. */
  34625. function _fnExternApiFunc (fn)
  34626. {
  34627. return function() {
  34628. var args = [_fnSettingsFromNode( this[DataTable.ext.iApiIndex] )].concat(
  34629. Array.prototype.slice.call(arguments)
  34630. );
  34631. return DataTable.ext.internal[fn].apply( this, args );
  34632. };
  34633. }
  34634. /**
  34635. * Reference to internal functions for use by plug-in developers. Note that
  34636. * these methods are references to internal functions and are considered to be
  34637. * private. If you use these methods, be aware that they are liable to change
  34638. * between versions.
  34639. * @namespace
  34640. */
  34641. $.extend( DataTable.ext.internal, {
  34642. _fnExternApiFunc: _fnExternApiFunc,
  34643. _fnBuildAjax: _fnBuildAjax,
  34644. _fnAjaxUpdate: _fnAjaxUpdate,
  34645. _fnAjaxParameters: _fnAjaxParameters,
  34646. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  34647. _fnAjaxDataSrc: _fnAjaxDataSrc,
  34648. _fnAddColumn: _fnAddColumn,
  34649. _fnColumnOptions: _fnColumnOptions,
  34650. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  34651. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  34652. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  34653. _fnVisbleColumns: _fnVisbleColumns,
  34654. _fnGetColumns: _fnGetColumns,
  34655. _fnColumnTypes: _fnColumnTypes,
  34656. _fnApplyColumnDefs: _fnApplyColumnDefs,
  34657. _fnHungarianMap: _fnHungarianMap,
  34658. _fnCamelToHungarian: _fnCamelToHungarian,
  34659. _fnLanguageCompat: _fnLanguageCompat,
  34660. _fnBrowserDetect: _fnBrowserDetect,
  34661. _fnAddData: _fnAddData,
  34662. _fnAddTr: _fnAddTr,
  34663. _fnNodeToDataIndex: _fnNodeToDataIndex,
  34664. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  34665. _fnGetCellData: _fnGetCellData,
  34666. _fnSetCellData: _fnSetCellData,
  34667. _fnSplitObjNotation: _fnSplitObjNotation,
  34668. _fnGetObjectDataFn: _fnGetObjectDataFn,
  34669. _fnSetObjectDataFn: _fnSetObjectDataFn,
  34670. _fnGetDataMaster: _fnGetDataMaster,
  34671. _fnClearTable: _fnClearTable,
  34672. _fnDeleteIndex: _fnDeleteIndex,
  34673. _fnInvalidate: _fnInvalidate,
  34674. _fnGetRowElements: _fnGetRowElements,
  34675. _fnCreateTr: _fnCreateTr,
  34676. _fnBuildHead: _fnBuildHead,
  34677. _fnDrawHead: _fnDrawHead,
  34678. _fnDraw: _fnDraw,
  34679. _fnReDraw: _fnReDraw,
  34680. _fnAddOptionsHtml: _fnAddOptionsHtml,
  34681. _fnDetectHeader: _fnDetectHeader,
  34682. _fnGetUniqueThs: _fnGetUniqueThs,
  34683. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  34684. _fnFilterComplete: _fnFilterComplete,
  34685. _fnFilterCustom: _fnFilterCustom,
  34686. _fnFilterColumn: _fnFilterColumn,
  34687. _fnFilter: _fnFilter,
  34688. _fnFilterCreateSearch: _fnFilterCreateSearch,
  34689. _fnEscapeRegex: _fnEscapeRegex,
  34690. _fnFilterData: _fnFilterData,
  34691. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  34692. _fnUpdateInfo: _fnUpdateInfo,
  34693. _fnInfoMacros: _fnInfoMacros,
  34694. _fnInitialise: _fnInitialise,
  34695. _fnInitComplete: _fnInitComplete,
  34696. _fnLengthChange: _fnLengthChange,
  34697. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  34698. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  34699. _fnPageChange: _fnPageChange,
  34700. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  34701. _fnProcessingDisplay: _fnProcessingDisplay,
  34702. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  34703. _fnScrollDraw: _fnScrollDraw,
  34704. _fnApplyToChildren: _fnApplyToChildren,
  34705. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  34706. _fnThrottle: _fnThrottle,
  34707. _fnConvertToWidth: _fnConvertToWidth,
  34708. _fnGetWidestNode: _fnGetWidestNode,
  34709. _fnGetMaxLenString: _fnGetMaxLenString,
  34710. _fnStringToCss: _fnStringToCss,
  34711. _fnSortFlatten: _fnSortFlatten,
  34712. _fnSort: _fnSort,
  34713. _fnSortAria: _fnSortAria,
  34714. _fnSortListener: _fnSortListener,
  34715. _fnSortAttachListener: _fnSortAttachListener,
  34716. _fnSortingClasses: _fnSortingClasses,
  34717. _fnSortData: _fnSortData,
  34718. _fnSaveState: _fnSaveState,
  34719. _fnLoadState: _fnLoadState,
  34720. _fnSettingsFromNode: _fnSettingsFromNode,
  34721. _fnLog: _fnLog,
  34722. _fnMap: _fnMap,
  34723. _fnBindAction: _fnBindAction,
  34724. _fnCallbackReg: _fnCallbackReg,
  34725. _fnCallbackFire: _fnCallbackFire,
  34726. _fnLengthOverflow: _fnLengthOverflow,
  34727. _fnRenderer: _fnRenderer,
  34728. _fnDataSource: _fnDataSource,
  34729. _fnRowAttributes: _fnRowAttributes,
  34730. _fnCalculateEnd: function () {} // Used by a lot of plug-ins, but redundant
  34731. // in 1.10, so this dead-end function is
  34732. // added to prevent errors
  34733. } );
  34734. // jQuery access
  34735. $.fn.dataTable = DataTable;
  34736. // Provide access to the host jQuery object (circular reference)
  34737. DataTable.$ = $;
  34738. // Legacy aliases
  34739. $.fn.dataTableSettings = DataTable.settings;
  34740. $.fn.dataTableExt = DataTable.ext;
  34741. // With a capital `D` we return a DataTables API instance rather than a
  34742. // jQuery object
  34743. $.fn.DataTable = function ( opts ) {
  34744. return $(this).dataTable( opts ).api();
  34745. };
  34746. // All properties that are available to $.fn.dataTable should also be
  34747. // available on $.fn.DataTable
  34748. $.each( DataTable, function ( prop, val ) {
  34749. $.fn.DataTable[ prop ] = val;
  34750. } );
  34751. // Information about events fired by DataTables - for documentation.
  34752. /**
  34753. * Draw event, fired whenever the table is redrawn on the page, at the same
  34754. * point as fnDrawCallback. This may be useful for binding events or
  34755. * performing calculations when the table is altered at all.
  34756. * @name DataTable#draw.dt
  34757. * @event
  34758. * @param {event} e jQuery event object
  34759. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  34760. */
  34761. /**
  34762. * Search event, fired when the searching applied to the table (using the
  34763. * built-in global search, or column filters) is altered.
  34764. * @name DataTable#search.dt
  34765. * @event
  34766. * @param {event} e jQuery event object
  34767. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  34768. */
  34769. /**
  34770. * Page change event, fired when the paging of the table is altered.
  34771. * @name DataTable#page.dt
  34772. * @event
  34773. * @param {event} e jQuery event object
  34774. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  34775. */
  34776. /**
  34777. * Order event, fired when the ordering applied to the table is altered.
  34778. * @name DataTable#order.dt
  34779. * @event
  34780. * @param {event} e jQuery event object
  34781. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  34782. */
  34783. /**
  34784. * DataTables initialisation complete event, fired when the table is fully
  34785. * drawn, including Ajax data loaded, if Ajax data is required.
  34786. * @name DataTable#init.dt
  34787. * @event
  34788. * @param {event} e jQuery event object
  34789. * @param {object} oSettings DataTables settings object
  34790. * @param {object} json The JSON object request from the server - only
  34791. * present if client-side Ajax sourced data is used</li></ol>
  34792. */
  34793. /**
  34794. * State save event, fired when the table has changed state a new state save
  34795. * is required. This event allows modification of the state saving object
  34796. * prior to actually doing the save, including addition or other state
  34797. * properties (for plug-ins) or modification of a DataTables core property.
  34798. * @name DataTable#stateSaveParams.dt
  34799. * @event
  34800. * @param {event} e jQuery event object
  34801. * @param {object} oSettings DataTables settings object
  34802. * @param {object} json The state information to be saved
  34803. */
  34804. /**
  34805. * State load event, fired when the table is loading state from the stored
  34806. * data, but prior to the settings object being modified by the saved state
  34807. * - allowing modification of the saved state is required or loading of
  34808. * state for a plug-in.
  34809. * @name DataTable#stateLoadParams.dt
  34810. * @event
  34811. * @param {event} e jQuery event object
  34812. * @param {object} oSettings DataTables settings object
  34813. * @param {object} json The saved state information
  34814. */
  34815. /**
  34816. * State loaded event, fired when state has been loaded from stored data and
  34817. * the settings object has been modified by the loaded data.
  34818. * @name DataTable#stateLoaded.dt
  34819. * @event
  34820. * @param {event} e jQuery event object
  34821. * @param {object} oSettings DataTables settings object
  34822. * @param {object} json The saved state information
  34823. */
  34824. /**
  34825. * Processing event, fired when DataTables is doing some kind of processing
  34826. * (be it, order, searcg or anything else). It can be used to indicate to
  34827. * the end user that there is something happening, or that something has
  34828. * finished.
  34829. * @name DataTable#processing.dt
  34830. * @event
  34831. * @param {event} e jQuery event object
  34832. * @param {object} oSettings DataTables settings object
  34833. * @param {boolean} bShow Flag for if DataTables is doing processing or not
  34834. */
  34835. /**
  34836. * Ajax (XHR) event, fired whenever an Ajax request is completed from a
  34837. * request to made to the server for new data. This event is called before
  34838. * DataTables processed the returned data, so it can also be used to pre-
  34839. * process the data returned from the server, if needed.
  34840. *
  34841. * Note that this trigger is called in `fnServerData`, if you override
  34842. * `fnServerData` and which to use this event, you need to trigger it in you
  34843. * success function.
  34844. * @name DataTable#xhr.dt
  34845. * @event
  34846. * @param {event} e jQuery event object
  34847. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  34848. * @param {object} json JSON returned from the server
  34849. *
  34850. * @example
  34851. * // Use a custom property returned from the server in another DOM element
  34852. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  34853. * $('#status').html( json.status );
  34854. * } );
  34855. *
  34856. * @example
  34857. * // Pre-process the data returned from the server
  34858. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  34859. * for ( var i=0, ien=json.aaData.length ; i<ien ; i++ ) {
  34860. * json.aaData[i].sum = json.aaData[i].one + json.aaData[i].two;
  34861. * }
  34862. * // Note no return - manipulate the data directly in the JSON object.
  34863. * } );
  34864. */
  34865. /**
  34866. * Destroy event, fired when the DataTable is destroyed by calling fnDestroy
  34867. * or passing the bDestroy:true parameter in the initialisation object. This
  34868. * can be used to remove bound events, added DOM nodes, etc.
  34869. * @name DataTable#destroy.dt
  34870. * @event
  34871. * @param {event} e jQuery event object
  34872. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  34873. */
  34874. /**
  34875. * Page length change event, fired when number of records to show on each
  34876. * page (the length) is changed.
  34877. * @name DataTable#length.dt
  34878. * @event
  34879. * @param {event} e jQuery event object
  34880. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  34881. * @param {integer} len New length
  34882. */
  34883. /**
  34884. * Column sizing has changed.
  34885. * @name DataTable#column-sizing.dt
  34886. * @event
  34887. * @param {event} e jQuery event object
  34888. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  34889. */
  34890. /**
  34891. * Column visibility has changed.
  34892. * @name DataTable#column-visibility.dt
  34893. * @event
  34894. * @param {event} e jQuery event object
  34895. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  34896. * @param {int} column Column index
  34897. * @param {bool} vis `false` if column now hidden, or `true` if visible
  34898. */
  34899. return $.fn.dataTable;
  34900. }));
  34901. /*! DataTables Bootstrap 4 integration
  34902. * ©2011-2017 SpryMedia Ltd - datatables.net/license
  34903. */
  34904. (function( factory ){
  34905. if ( typeof define === 'function' && define.amd ) {
  34906. // AMD
  34907. define( ['jquery', 'datatables.net'], function ( $ ) {
  34908. return factory( $, window, document );
  34909. } );
  34910. }
  34911. else if ( typeof exports === 'object' ) {
  34912. // CommonJS
  34913. module.exports = function (root, $) {
  34914. if ( ! root ) {
  34915. // CommonJS environments without a window global must pass a
  34916. // root. This will give an error otherwise
  34917. root = window;
  34918. }
  34919. if ( ! $ ) {
  34920. $ = typeof window !== 'undefined' ? // jQuery's factory checks for a global window
  34921. require('jquery') :
  34922. require('jquery')( root );
  34923. }
  34924. if ( ! $.fn.dataTable ) {
  34925. require('datatables.net')(root, $);
  34926. }
  34927. return factory( $, root, root.document );
  34928. };
  34929. }
  34930. else {
  34931. // Browser
  34932. factory( jQuery, window, document );
  34933. }
  34934. }(function( $, window, document, undefined ) {
  34935. 'use strict';
  34936. var DataTable = $.fn.dataTable;
  34937. /**
  34938. * DataTables integration for Bootstrap 4. This requires Bootstrap 4 and
  34939. * DataTables 1.10 or newer.
  34940. *
  34941. * This file sets the defaults and adds options to DataTables to style its
  34942. * controls using Bootstrap. See http://datatables.net/manual/styling/bootstrap
  34943. * for further information.
  34944. */
  34945. /* Set the defaults for DataTables initialisation */
  34946. $.extend( true, DataTable.defaults, {
  34947. dom:
  34948. "<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>>" +
  34949. "<'row'<'col-sm-12'tr>>" +
  34950. "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
  34951. renderer: 'bootstrap'
  34952. } );
  34953. /* Default class modification */
  34954. $.extend( DataTable.ext.classes, {
  34955. sWrapper: "dataTables_wrapper dt-bootstrap4",
  34956. sFilterInput: "form-control form-control-sm",
  34957. sLengthSelect: "custom-select custom-select-sm form-control form-control-sm",
  34958. sProcessing: "dataTables_processing card",
  34959. sPageButton: "paginate_button page-item"
  34960. } );
  34961. /* Bootstrap paging button renderer */
  34962. DataTable.ext.renderer.pageButton.bootstrap = function ( settings, host, idx, buttons, page, pages ) {
  34963. var api = new DataTable.Api( settings );
  34964. var classes = settings.oClasses;
  34965. var lang = settings.oLanguage.oPaginate;
  34966. var aria = settings.oLanguage.oAria.paginate || {};
  34967. var btnDisplay, btnClass;
  34968. var attach = function( container, buttons ) {
  34969. var i, ien, node, button;
  34970. var clickHandler = function ( e ) {
  34971. e.preventDefault();
  34972. if ( !$(e.currentTarget).hasClass('disabled') && api.page() != e.data.action ) {
  34973. api.page( e.data.action ).draw( 'page' );
  34974. }
  34975. };
  34976. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  34977. button = buttons[i];
  34978. if ( Array.isArray( button ) ) {
  34979. attach( container, button );
  34980. }
  34981. else {
  34982. btnDisplay = '';
  34983. btnClass = '';
  34984. switch ( button ) {
  34985. case 'ellipsis':
  34986. btnDisplay = '&#x2026;';
  34987. btnClass = 'disabled';
  34988. break;
  34989. case 'first':
  34990. btnDisplay = lang.sFirst;
  34991. btnClass = button + (page > 0 ?
  34992. '' : ' disabled');
  34993. break;
  34994. case 'previous':
  34995. btnDisplay = lang.sPrevious;
  34996. btnClass = button + (page > 0 ?
  34997. '' : ' disabled');
  34998. break;
  34999. case 'next':
  35000. btnDisplay = lang.sNext;
  35001. btnClass = button + (page < pages-1 ?
  35002. '' : ' disabled');
  35003. break;
  35004. case 'last':
  35005. btnDisplay = lang.sLast;
  35006. btnClass = button + (page < pages-1 ?
  35007. '' : ' disabled');
  35008. break;
  35009. default:
  35010. btnDisplay = button + 1;
  35011. btnClass = page === button ?
  35012. 'active' : '';
  35013. break;
  35014. }
  35015. if ( btnDisplay ) {
  35016. node = $('<li>', {
  35017. 'class': classes.sPageButton+' '+btnClass,
  35018. 'id': idx === 0 && typeof button === 'string' ?
  35019. settings.sTableId +'_'+ button :
  35020. null
  35021. } )
  35022. .append( $('<a>', {
  35023. 'href': '#',
  35024. 'aria-controls': settings.sTableId,
  35025. 'aria-label': aria[ button ],
  35026. 'data-dt-idx': button,
  35027. 'tabindex': settings.iTabIndex,
  35028. 'class': 'page-link'
  35029. } )
  35030. .html( btnDisplay )
  35031. )
  35032. .appendTo( container );
  35033. settings.oApi._fnBindAction(
  35034. node, {action: button}, clickHandler
  35035. );
  35036. }
  35037. }
  35038. }
  35039. };
  35040. // IE9 throws an 'unknown error' if document.activeElement is used
  35041. // inside an iframe or frame.
  35042. var activeEl;
  35043. try {
  35044. // Because this approach is destroying and recreating the paging
  35045. // elements, focus is lost on the select button which is bad for
  35046. // accessibility. So we want to restore focus once the draw has
  35047. // completed
  35048. activeEl = $(host).find(document.activeElement).data('dt-idx');
  35049. }
  35050. catch (e) {}
  35051. attach(
  35052. $(host).empty().html('<ul class="pagination"/>').children('ul'),
  35053. buttons
  35054. );
  35055. if ( activeEl !== undefined ) {
  35056. $(host).find( '[data-dt-idx='+activeEl+']' ).trigger('focus');
  35057. }
  35058. };
  35059. return DataTable;
  35060. }));
  35061. /**
  35062. * Bootstrap Multiselect (https://github.com/davidstutz/bootstrap-multiselect)
  35063. *
  35064. * Apache License, Version 2.0:
  35065. * Copyright (c) 2012 - 2015 David Stutz
  35066. *
  35067. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  35068. * use this file except in compliance with the License. You may obtain a
  35069. * copy of the License at http://www.apache.org/licenses/LICENSE-2.0
  35070. *
  35071. * Unless required by applicable law or agreed to in writing, software
  35072. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  35073. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  35074. * License for the specific language governing permissions and limitations
  35075. * under the License.
  35076. *
  35077. * BSD 3-Clause License:
  35078. * Copyright (c) 2012 - 2015 David Stutz
  35079. * All rights reserved.
  35080. *
  35081. * Redistribution and use in source and binary forms, with or without
  35082. * modification, are permitted provided that the following conditions are met:
  35083. * - Redistributions of source code must retain the above copyright notice,
  35084. * this list of conditions and the following disclaimer.
  35085. * - Redistributions in binary form must reproduce the above copyright notice,
  35086. * this list of conditions and the following disclaimer in the documentation
  35087. * and/or other materials provided with the distribution.
  35088. * - Neither the name of David Stutz nor the names of its contributors may be
  35089. * used to endorse or promote products derived from this software without
  35090. * specific prior written permission.
  35091. *
  35092. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  35093. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  35094. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  35095. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  35096. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  35097. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  35098. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  35099. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  35100. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  35101. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  35102. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35103. */
  35104. !function ($) {
  35105. "use strict";// jshint ;_;
  35106. if (typeof ko !== 'undefined' && ko.bindingHandlers && !ko.bindingHandlers.multiselect) {
  35107. ko.bindingHandlers.multiselect = {
  35108. after: ['options', 'value', 'selectedOptions'],
  35109. init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
  35110. var $element = $(element);
  35111. var config = ko.toJS(valueAccessor());
  35112. $element.multiselect(config);
  35113. if (allBindings.has('options')) {
  35114. var options = allBindings.get('options');
  35115. if (ko.isObservable(options)) {
  35116. ko.computed({
  35117. read: function() {
  35118. options();
  35119. setTimeout(function() {
  35120. var ms = $element.data('multiselect');
  35121. if (ms)
  35122. ms.updateOriginalOptions();//Not sure how beneficial this is.
  35123. $element.multiselect('rebuild');
  35124. }, 1);
  35125. },
  35126. disposeWhenNodeIsRemoved: element
  35127. });
  35128. }
  35129. }
  35130. //value and selectedOptions are two-way, so these will be triggered even by our own actions.
  35131. //It needs some way to tell if they are triggered because of us or because of outside change.
  35132. //It doesn't loop but it's a waste of processing.
  35133. if (allBindings.has('value')) {
  35134. var value = allBindings.get('value');
  35135. if (ko.isObservable(value)) {
  35136. ko.computed({
  35137. read: function() {
  35138. value();
  35139. setTimeout(function() {
  35140. $element.multiselect('refresh');
  35141. }, 1);
  35142. },
  35143. disposeWhenNodeIsRemoved: element
  35144. }).extend({ rateLimit: 100, notifyWhenChangesStop: true });
  35145. }
  35146. }
  35147. //Switched from arrayChange subscription to general subscription using 'refresh'.
  35148. //Not sure performance is any better using 'select' and 'deselect'.
  35149. if (allBindings.has('selectedOptions')) {
  35150. var selectedOptions = allBindings.get('selectedOptions');
  35151. if (ko.isObservable(selectedOptions)) {
  35152. ko.computed({
  35153. read: function() {
  35154. selectedOptions();
  35155. setTimeout(function() {
  35156. $element.multiselect('refresh');
  35157. }, 1);
  35158. },
  35159. disposeWhenNodeIsRemoved: element
  35160. }).extend({ rateLimit: 100, notifyWhenChangesStop: true });
  35161. }
  35162. }
  35163. ko.utils.domNodeDisposal.addDisposeCallback(element, function() {
  35164. $element.multiselect('destroy');
  35165. });
  35166. },
  35167. update: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
  35168. var $element = $(element);
  35169. var config = ko.toJS(valueAccessor());
  35170. $element.multiselect('setOptions', config);
  35171. $element.multiselect('rebuild');
  35172. }
  35173. };
  35174. }
  35175. function forEach(array, callback) {
  35176. for (var index = 0; index < array.length; ++index) {
  35177. callback(array[index], index);
  35178. }
  35179. }
  35180. /**
  35181. * Constructor to create a new multiselect using the given select.
  35182. *
  35183. * @param {jQuery} select
  35184. * @param {Object} options
  35185. * @returns {Multiselect}
  35186. */
  35187. function Multiselect(select, options) {
  35188. this.$select = $(select);
  35189. // Placeholder via data attributes
  35190. if (this.$select.attr("data-placeholder")) {
  35191. options.nonSelectedText = this.$select.data("placeholder");
  35192. }
  35193. this.options = this.mergeOptions($.extend({}, options, this.$select.data()));
  35194. // Initialization.
  35195. // We have to clone to create a new reference.
  35196. this.originalOptions = this.$select.clone()[0].options;
  35197. this.query = '';
  35198. this.searchTimeout = null;
  35199. this.lastToggledInput = null
  35200. this.options.multiple = this.$select.attr('multiple') === "multiple";
  35201. this.options.onChange = $.proxy(this.options.onChange, this);
  35202. this.options.onDropdownShow = $.proxy(this.options.onDropdownShow, this);
  35203. this.options.onDropdownHide = $.proxy(this.options.onDropdownHide, this);
  35204. this.options.onDropdownShown = $.proxy(this.options.onDropdownShown, this);
  35205. this.options.onDropdownHidden = $.proxy(this.options.onDropdownHidden, this);
  35206. // Build select all if enabled.
  35207. this.buildContainer();
  35208. this.buildButton();
  35209. this.buildDropdown();
  35210. this.buildSelectAll();
  35211. this.buildDropdownOptions();
  35212. this.buildFilter();
  35213. this.updateButtonText();
  35214. this.updateSelectAll();
  35215. if (this.options.disableIfEmpty && $('option', this.$select).length <= 0) {
  35216. this.disable();
  35217. }
  35218. this.$select.hide().after(this.$container);
  35219. };
  35220. Multiselect.prototype = {
  35221. defaults: {
  35222. /**
  35223. * Default text function will either print 'None selected' in case no
  35224. * option is selected or a list of the selected options up to a length
  35225. * of 3 selected options.
  35226. *
  35227. * @param {jQuery} options
  35228. * @param {jQuery} select
  35229. * @returns {String}
  35230. */
  35231. buttonText: function(options, select) {
  35232. if (options.length === 0) {
  35233. return this.nonSelectedText;
  35234. }
  35235. else if (this.allSelectedText
  35236. && options.length === $('option', $(select)).length
  35237. && $('option', $(select)).length !== 1
  35238. && this.multiple) {
  35239. if (this.selectAllNumber) {
  35240. return this.allSelectedText + ' (' + options.length + ')';
  35241. }
  35242. else {
  35243. return this.allSelectedText;
  35244. }
  35245. }
  35246. else if (options.length > this.numberDisplayed) {
  35247. return options.length + ' ' + this.nSelectedText;
  35248. }
  35249. else {
  35250. var selected = '';
  35251. var delimiter = this.delimiterText;
  35252. options.each(function() {
  35253. var label = ($(this).attr('label') !== undefined) ? $(this).attr('label') : $(this).text();
  35254. selected += label + delimiter;
  35255. });
  35256. return selected.substr(0, selected.length - 2);
  35257. }
  35258. },
  35259. /**
  35260. * Updates the title of the button similar to the buttonText function.
  35261. *
  35262. * @param {jQuery} options
  35263. * @param {jQuery} select
  35264. * @returns {@exp;selected@call;substr}
  35265. */
  35266. buttonTitle: function(options, select) {
  35267. if (options.length === 0) {
  35268. return this.nonSelectedText;
  35269. }
  35270. else {
  35271. var selected = '';
  35272. var delimiter = this.delimiterText;
  35273. options.each(function () {
  35274. var label = ($(this).attr('label') !== undefined) ? $(this).attr('label') : $(this).text();
  35275. selected += label + delimiter;
  35276. });
  35277. return selected.substr(0, selected.length - 2);
  35278. }
  35279. },
  35280. /**
  35281. * Create a label.
  35282. *
  35283. * @param {jQuery} element
  35284. * @returns {String}
  35285. */
  35286. optionLabel: function(element){
  35287. return $(element).attr('label') || $(element).text();
  35288. },
  35289. /**
  35290. * Triggered on change of the multiselect.
  35291. *
  35292. * Not triggered when selecting/deselecting options manually.
  35293. *
  35294. * @param {jQuery} option
  35295. * @param {Boolean} checked
  35296. */
  35297. onChange : function(option, checked) {
  35298. },
  35299. /**
  35300. * Triggered when the dropdown is shown.
  35301. *
  35302. * @param {jQuery} event
  35303. */
  35304. onDropdownShow: function(event) {
  35305. },
  35306. /**
  35307. * Triggered when the dropdown is hidden.
  35308. *
  35309. * @param {jQuery} event
  35310. */
  35311. onDropdownHide: function(event) {
  35312. },
  35313. /**
  35314. * Triggered after the dropdown is shown.
  35315. *
  35316. * @param {jQuery} event
  35317. */
  35318. onDropdownShown: function(event) {
  35319. },
  35320. /**
  35321. * Triggered after the dropdown is hidden.
  35322. *
  35323. * @param {jQuery} event
  35324. */
  35325. onDropdownHidden: function(event) {
  35326. },
  35327. /**
  35328. * Triggered on select all.
  35329. */
  35330. onSelectAll: function() {
  35331. },
  35332. enableHTML: false,
  35333. buttonClass: 'btn btn-default',
  35334. inheritClass: false,
  35335. buttonWidth: 'auto',
  35336. buttonContainer: '<div class="btn-group" />',
  35337. dropRight: false,
  35338. selectedClass: 'active',
  35339. // Maximum height of the dropdown menu.
  35340. // If maximum height is exceeded a scrollbar will be displayed.
  35341. maxHeight: false,
  35342. checkboxName: false,
  35343. includeSelectAllOption: false,
  35344. includeSelectAllIfMoreThan: 0,
  35345. selectAllText: ' Select all',
  35346. selectAllValue: 'multiselect-all',
  35347. selectAllName: false,
  35348. selectAllNumber: true,
  35349. enableFiltering: false,
  35350. enableCaseInsensitiveFiltering: false,
  35351. enableClickableOptGroups: false,
  35352. filterPlaceholder: 'Search',
  35353. // possible options: 'text', 'value', 'both'
  35354. filterBehavior: 'text',
  35355. includeFilterClearBtn: true,
  35356. preventInputChangeEvent: false,
  35357. nonSelectedText: 'None selected',
  35358. nSelectedText: 'selected',
  35359. allSelectedText: 'All selected',
  35360. numberDisplayed: 3,
  35361. disableIfEmpty: false,
  35362. delimiterText: ', ',
  35363. templates: {
  35364. button: '<button type="button" class="multiselect dropdown-toggle" data-toggle="dropdown"><span class="multiselect-selected-text"></span> <b class="caret"></b></button>',
  35365. ul: '<ul class="multiselect-container dropdown-menu"></ul>',
  35366. filter: '<li class="multiselect-item filter"><div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span><input class="form-control multiselect-search" type="text"></div></li>',
  35367. filterClearBtn: '<span class="input-group-btn"><button class="btn btn-default multiselect-clear-filter" type="button"><i class="glyphicon glyphicon-remove-circle"></i></button></span>',
  35368. li: '<li><a tabindex="0"><label></label></a></li>',
  35369. divider: '<li class="multiselect-item divider"></li>',
  35370. liGroup: '<li class="multiselect-item multiselect-group"><label></label></li>'
  35371. }
  35372. },
  35373. constructor: Multiselect,
  35374. /**
  35375. * Builds the container of the multiselect.
  35376. */
  35377. buildContainer: function() {
  35378. this.$container = $(this.options.buttonContainer);
  35379. this.$container.on('show.bs.dropdown', this.options.onDropdownShow);
  35380. this.$container.on('hide.bs.dropdown', this.options.onDropdownHide);
  35381. this.$container.on('shown.bs.dropdown', this.options.onDropdownShown);
  35382. this.$container.on('hidden.bs.dropdown', this.options.onDropdownHidden);
  35383. },
  35384. /**
  35385. * Builds the button of the multiselect.
  35386. */
  35387. buildButton: function() {
  35388. this.$button = $(this.options.templates.button).addClass(this.options.buttonClass);
  35389. if (this.$select.attr('class') && this.options.inheritClass) {
  35390. this.$button.addClass(this.$select.attr('class'));
  35391. }
  35392. // Adopt active state.
  35393. if (this.$select.prop('disabled')) {
  35394. this.disable();
  35395. }
  35396. else {
  35397. this.enable();
  35398. }
  35399. // Manually add button width if set.
  35400. if (this.options.buttonWidth && this.options.buttonWidth !== 'auto') {
  35401. this.$button.css({
  35402. 'width' : this.options.buttonWidth,
  35403. 'overflow' : 'hidden',
  35404. 'text-overflow' : 'ellipsis'
  35405. });
  35406. this.$container.css({
  35407. 'width': this.options.buttonWidth
  35408. });
  35409. }
  35410. // Keep the tab index from the select.
  35411. var tabindex = this.$select.attr('tabindex');
  35412. if (tabindex) {
  35413. this.$button.attr('tabindex', tabindex);
  35414. }
  35415. this.$container.prepend(this.$button);
  35416. },
  35417. /**
  35418. * Builds the ul representing the dropdown menu.
  35419. */
  35420. buildDropdown: function() {
  35421. // Build ul.
  35422. this.$ul = $(this.options.templates.ul);
  35423. if (this.options.dropRight) {
  35424. this.$ul.addClass('pull-right');
  35425. }
  35426. // Set max height of dropdown menu to activate auto scrollbar.
  35427. if (this.options.maxHeight) {
  35428. // TODO: Add a class for this option to move the css declarations.
  35429. this.$ul.css({
  35430. 'max-height': this.options.maxHeight + 'px',
  35431. 'overflow-y': 'auto',
  35432. 'overflow-x': 'hidden'
  35433. });
  35434. }
  35435. this.$container.append(this.$ul);
  35436. },
  35437. /**
  35438. * Build the dropdown options and binds all nessecary events.
  35439. *
  35440. * Uses createDivider and createOptionValue to create the necessary options.
  35441. */
  35442. buildDropdownOptions: function() {
  35443. this.$select.children().each($.proxy(function(index, element) {
  35444. var $element = $(element);
  35445. // Support optgroups and options without a group simultaneously.
  35446. var tag = $element.prop('tagName')
  35447. .toLowerCase();
  35448. if ($element.prop('value') === this.options.selectAllValue) {
  35449. return;
  35450. }
  35451. if (tag === 'optgroup') {
  35452. this.createOptgroup(element);
  35453. }
  35454. else if (tag === 'option') {
  35455. if ($element.data('role') === 'divider') {
  35456. this.createDivider();
  35457. }
  35458. else {
  35459. this.createOptionValue(element);
  35460. }
  35461. }
  35462. // Other illegal tags will be ignored.
  35463. }, this));
  35464. // Bind the change event on the dropdown elements.
  35465. $('li input', this.$ul).on('change', $.proxy(function(event) {
  35466. var $target = $(event.target);
  35467. var checked = $target.prop('checked') || false;
  35468. var isSelectAllOption = $target.val() === this.options.selectAllValue;
  35469. // Apply or unapply the configured selected class.
  35470. if (this.options.selectedClass) {
  35471. if (checked) {
  35472. $target.closest('li')
  35473. .addClass(this.options.selectedClass);
  35474. }
  35475. else {
  35476. $target.closest('li')
  35477. .removeClass(this.options.selectedClass);
  35478. }
  35479. }
  35480. // Get the corresponding option.
  35481. var value = $target.val();
  35482. var $option = this.getOptionByValue(value);
  35483. var $optionsNotThis = $('option', this.$select).not($option);
  35484. var $checkboxesNotThis = $('input', this.$container).not($target);
  35485. if (isSelectAllOption) {
  35486. if (checked) {
  35487. this.selectAll();
  35488. }
  35489. else {
  35490. this.deselectAll();
  35491. }
  35492. }
  35493. if(!isSelectAllOption){
  35494. if (checked) {
  35495. $option.prop('selected', true);
  35496. if (this.options.multiple) {
  35497. // Simply select additional option.
  35498. $option.prop('selected', true);
  35499. }
  35500. else {
  35501. // Unselect all other options and corresponding checkboxes.
  35502. if (this.options.selectedClass) {
  35503. $($checkboxesNotThis).closest('li').removeClass(this.options.selectedClass);
  35504. }
  35505. $($checkboxesNotThis).prop('checked', false);
  35506. $optionsNotThis.prop('selected', false);
  35507. // It's a single selection, so close.
  35508. this.$button.click();
  35509. }
  35510. if (this.options.selectedClass === "active") {
  35511. $optionsNotThis.closest("a").css("outline", "");
  35512. }
  35513. }
  35514. else {
  35515. // Unselect option.
  35516. $option.prop('selected', false);
  35517. }
  35518. }
  35519. this.$select.change();
  35520. this.updateButtonText();
  35521. this.updateSelectAll();
  35522. this.options.onChange($option, checked);
  35523. if(this.options.preventInputChangeEvent) {
  35524. return false;
  35525. }
  35526. }, this));
  35527. $('li a', this.$ul).on('mousedown', function(e) {
  35528. if (e.shiftKey) {
  35529. // Prevent selecting text by Shift+click
  35530. return false;
  35531. }
  35532. });
  35533. $('li a', this.$ul).on('touchstart click', $.proxy(function(event) {
  35534. event.stopPropagation();
  35535. var $target = $(event.target);
  35536. if (event.shiftKey && this.options.multiple) {
  35537. if($target.is("label")){ // Handles checkbox selection manually (see https://github.com/davidstutz/bootstrap-multiselect/issues/431)
  35538. event.preventDefault();
  35539. $target = $target.find("input");
  35540. $target.prop("checked", !$target.prop("checked"));
  35541. }
  35542. var checked = $target.prop('checked') || false;
  35543. if (this.lastToggledInput !== null && this.lastToggledInput !== $target) { // Make sure we actually have a range
  35544. var from = $target.closest("li").index();
  35545. var to = this.lastToggledInput.closest("li").index();
  35546. if (from > to) { // Swap the indices
  35547. var tmp = to;
  35548. to = from;
  35549. from = tmp;
  35550. }
  35551. // Make sure we grab all elements since slice excludes the last index
  35552. ++to;
  35553. // Change the checkboxes and underlying options
  35554. var range = this.$ul.find("li").slice(from, to).find("input");
  35555. range.prop('checked', checked);
  35556. if (this.options.selectedClass) {
  35557. range.closest('li')
  35558. .toggleClass(this.options.selectedClass, checked);
  35559. }
  35560. for (var i = 0, j = range.length; i < j; i++) {
  35561. var $checkbox = $(range[i]);
  35562. var $option = this.getOptionByValue($checkbox.val());
  35563. $option.prop('selected', checked);
  35564. }
  35565. }
  35566. // Trigger the select "change" event
  35567. $target.trigger("change");
  35568. }
  35569. // Remembers last clicked option
  35570. if($target.is("input") && !$target.closest("li").is(".multiselect-item")){
  35571. this.lastToggledInput = $target;
  35572. }
  35573. $target.blur();
  35574. }, this));
  35575. // Keyboard support.
  35576. this.$container.off('keydown.multiselect').on('keydown.multiselect', $.proxy(function(event) {
  35577. if ($('input[type="text"]', this.$container).is(':focus')) {
  35578. return;
  35579. }
  35580. if (event.keyCode === 9 && this.$container.hasClass('open')) {
  35581. this.$button.click();
  35582. }
  35583. else {
  35584. var $items = $(this.$container).find("li:not(.divider):not(.disabled) a").filter(":visible");
  35585. if (!$items.length) {
  35586. return;
  35587. }
  35588. var index = $items.index($items.filter(':focus'));
  35589. // Navigation up.
  35590. if (event.keyCode === 38 && index > 0) {
  35591. index--;
  35592. }
  35593. // Navigate down.
  35594. else if (event.keyCode === 40 && index < $items.length - 1) {
  35595. index++;
  35596. }
  35597. else if (!~index) {
  35598. index = 0;
  35599. }
  35600. var $current = $items.eq(index);
  35601. $current.focus();
  35602. if (event.keyCode === 32 || event.keyCode === 13) {
  35603. var $checkbox = $current.find('input');
  35604. $checkbox.prop("checked", !$checkbox.prop("checked"));
  35605. $checkbox.change();
  35606. }
  35607. event.stopPropagation();
  35608. event.preventDefault();
  35609. }
  35610. }, this));
  35611. if(this.options.enableClickableOptGroups && this.options.multiple) {
  35612. $('li.multiselect-group', this.$ul).on('click', $.proxy(function(event) {
  35613. event.stopPropagation();
  35614. var group = $(event.target).parent();
  35615. // Search all option in optgroup
  35616. var $options = group.nextUntil('li.multiselect-group');
  35617. var $visibleOptions = $options.filter(":visible:not(.disabled)");
  35618. // check or uncheck items
  35619. var allChecked = true;
  35620. var optionInputs = $visibleOptions.find('input');
  35621. optionInputs.each(function() {
  35622. allChecked = allChecked && $(this).prop('checked');
  35623. });
  35624. optionInputs.prop('checked', !allChecked).trigger('change');
  35625. }, this));
  35626. }
  35627. },
  35628. /**
  35629. * Create an option using the given select option.
  35630. *
  35631. * @param {jQuery} element
  35632. */
  35633. createOptionValue: function(element) {
  35634. var $element = $(element);
  35635. if ($element.is(':selected')) {
  35636. $element.prop('selected', true);
  35637. }
  35638. // Support the label attribute on options.
  35639. var label = this.options.optionLabel(element);
  35640. var value = $element.val();
  35641. var inputType = this.options.multiple ? "checkbox" : "radio";
  35642. var $li = $(this.options.templates.li);
  35643. var $label = $('label', $li);
  35644. $label.addClass(inputType);
  35645. if (this.options.enableHTML) {
  35646. $label.html(" " + label);
  35647. }
  35648. else {
  35649. $label.text(" " + label);
  35650. }
  35651. var $checkbox = $('<input/>').attr('type', inputType);
  35652. if (this.options.checkboxName) {
  35653. $checkbox.attr('name', this.options.checkboxName);
  35654. }
  35655. $label.prepend($checkbox);
  35656. var selected = $element.prop('selected') || false;
  35657. $checkbox.val(value);
  35658. if (value === this.options.selectAllValue) {
  35659. $li.addClass("multiselect-item multiselect-all");
  35660. $checkbox.parent().parent()
  35661. .addClass('multiselect-all');
  35662. }
  35663. $label.attr('title', $element.attr('title'));
  35664. this.$ul.append($li);
  35665. if ($element.is(':disabled')) {
  35666. $checkbox.attr('disabled', 'disabled')
  35667. .prop('disabled', true)
  35668. .closest('a')
  35669. .attr("tabindex", "-1")
  35670. .closest('li')
  35671. .addClass('disabled');
  35672. }
  35673. $checkbox.prop('checked', selected);
  35674. if (selected && this.options.selectedClass) {
  35675. $checkbox.closest('li')
  35676. .addClass(this.options.selectedClass);
  35677. }
  35678. },
  35679. /**
  35680. * Creates a divider using the given select option.
  35681. *
  35682. * @param {jQuery} element
  35683. */
  35684. createDivider: function(element) {
  35685. var $divider = $(this.options.templates.divider);
  35686. this.$ul.append($divider);
  35687. },
  35688. /**
  35689. * Creates an optgroup.
  35690. *
  35691. * @param {jQuery} group
  35692. */
  35693. createOptgroup: function(group) {
  35694. var groupName = $(group).prop('label');
  35695. // Add a header for the group.
  35696. var $li = $(this.options.templates.liGroup);
  35697. if (this.options.enableHTML) {
  35698. $('label', $li).html(groupName);
  35699. }
  35700. else {
  35701. $('label', $li).text(groupName);
  35702. }
  35703. if (this.options.enableClickableOptGroups) {
  35704. $li.addClass('multiselect-group-clickable');
  35705. }
  35706. this.$ul.append($li);
  35707. if ($(group).is(':disabled')) {
  35708. $li.addClass('disabled');
  35709. }
  35710. // Add the options of the group.
  35711. $('option', group).each($.proxy(function(index, element) {
  35712. this.createOptionValue(element);
  35713. }, this));
  35714. },
  35715. /**
  35716. * Build the selct all.
  35717. *
  35718. * Checks if a select all has already been created.
  35719. */
  35720. buildSelectAll: function() {
  35721. if (typeof this.options.selectAllValue === 'number') {
  35722. this.options.selectAllValue = this.options.selectAllValue.toString();
  35723. }
  35724. var alreadyHasSelectAll = this.hasSelectAll();
  35725. if (!alreadyHasSelectAll && this.options.includeSelectAllOption && this.options.multiple
  35726. && $('option', this.$select).length > this.options.includeSelectAllIfMoreThan) {
  35727. // Check whether to add a divider after the select all.
  35728. if (this.options.includeSelectAllDivider) {
  35729. this.$ul.prepend($(this.options.templates.divider));
  35730. }
  35731. var $li = $(this.options.templates.li);
  35732. $('label', $li).addClass("checkbox");
  35733. if (this.options.enableHTML) {
  35734. $('label', $li).html(" " + this.options.selectAllText);
  35735. }
  35736. else {
  35737. $('label', $li).text(" " + this.options.selectAllText);
  35738. }
  35739. if (this.options.selectAllName) {
  35740. $('label', $li).prepend('<input type="checkbox" name="' + this.options.selectAllName + '" />');
  35741. }
  35742. else {
  35743. $('label', $li).prepend('<input type="checkbox" />');
  35744. }
  35745. var $checkbox = $('input', $li);
  35746. $checkbox.val(this.options.selectAllValue);
  35747. $li.addClass("multiselect-item multiselect-all");
  35748. $checkbox.parent().parent()
  35749. .addClass('multiselect-all');
  35750. this.$ul.prepend($li);
  35751. $checkbox.prop('checked', false);
  35752. }
  35753. },
  35754. /**
  35755. * Builds the filter.
  35756. */
  35757. buildFilter: function() {
  35758. // Build filter if filtering OR case insensitive filtering is enabled and the number of options exceeds (or equals) enableFilterLength.
  35759. if (this.options.enableFiltering || this.options.enableCaseInsensitiveFiltering) {
  35760. var enableFilterLength = Math.max(this.options.enableFiltering, this.options.enableCaseInsensitiveFiltering);
  35761. if (this.$select.find('option').length >= enableFilterLength) {
  35762. this.$filter = $(this.options.templates.filter);
  35763. $('input', this.$filter).attr('placeholder', this.options.filterPlaceholder);
  35764. // Adds optional filter clear button
  35765. if(this.options.includeFilterClearBtn){
  35766. var clearBtn = $(this.options.templates.filterClearBtn);
  35767. clearBtn.on('click', $.proxy(function(event){
  35768. clearTimeout(this.searchTimeout);
  35769. this.$filter.find('.multiselect-search').val('');
  35770. $('li', this.$ul).show().removeClass("filter-hidden");
  35771. this.updateSelectAll();
  35772. }, this));
  35773. this.$filter.find('.input-group').append(clearBtn);
  35774. }
  35775. this.$ul.prepend(this.$filter);
  35776. this.$filter.val(this.query).on('click', function(event) {
  35777. event.stopPropagation();
  35778. }).on('input keydown', $.proxy(function(event) {
  35779. // Cancel enter key default behaviour
  35780. if (event.which === 13) {
  35781. event.preventDefault();
  35782. }
  35783. // This is useful to catch "keydown" events after the browser has updated the control.
  35784. clearTimeout(this.searchTimeout);
  35785. this.searchTimeout = this.asyncFunction($.proxy(function() {
  35786. if (this.query !== event.target.value) {
  35787. this.query = event.target.value;
  35788. var currentGroup, currentGroupVisible;
  35789. $.each($('li', this.$ul), $.proxy(function(index, element) {
  35790. var value = $('input', element).length > 0 ? $('input', element).val() : "";
  35791. var text = $('label', element).text();
  35792. var filterCandidate = '';
  35793. if ((this.options.filterBehavior === 'text')) {
  35794. filterCandidate = text;
  35795. }
  35796. else if ((this.options.filterBehavior === 'value')) {
  35797. filterCandidate = value;
  35798. }
  35799. else if (this.options.filterBehavior === 'both') {
  35800. filterCandidate = text + '\n' + value;
  35801. }
  35802. if (value !== this.options.selectAllValue && text) {
  35803. // By default lets assume that element is not
  35804. // interesting for this search.
  35805. var showElement = false;
  35806. if (this.options.enableCaseInsensitiveFiltering && filterCandidate.toLowerCase().indexOf(this.query.toLowerCase()) > -1) {
  35807. showElement = true;
  35808. }
  35809. else if (filterCandidate.indexOf(this.query) > -1) {
  35810. showElement = true;
  35811. }
  35812. // Toggle current element (group or group item) according to showElement boolean.
  35813. $(element).toggle(showElement).toggleClass('filter-hidden', !showElement);
  35814. // Differentiate groups and group items.
  35815. if ($(element).hasClass('multiselect-group')) {
  35816. // Remember group status.
  35817. currentGroup = element;
  35818. currentGroupVisible = showElement;
  35819. }
  35820. else {
  35821. // Show group name when at least one of its items is visible.
  35822. if (showElement) {
  35823. $(currentGroup).show().removeClass('filter-hidden');
  35824. }
  35825. // Show all group items when group name satisfies filter.
  35826. if (!showElement && currentGroupVisible) {
  35827. $(element).show().removeClass('filter-hidden');
  35828. }
  35829. }
  35830. }
  35831. }, this));
  35832. }
  35833. this.updateSelectAll();
  35834. }, this), 300, this);
  35835. }, this));
  35836. }
  35837. }
  35838. },
  35839. /**
  35840. * Unbinds the whole plugin.
  35841. */
  35842. destroy: function() {
  35843. this.$container.remove();
  35844. this.$select.show();
  35845. this.$select.data('multiselect', null);
  35846. },
  35847. /**
  35848. * Refreshs the multiselect based on the selected options of the select.
  35849. */
  35850. refresh: function() {
  35851. $('option', this.$select).each($.proxy(function(index, element) {
  35852. var $input = $('li input', this.$ul).filter(function() {
  35853. return $(this).val() === $(element).val();
  35854. });
  35855. if ($(element).is(':selected')) {
  35856. $input.prop('checked', true);
  35857. if (this.options.selectedClass) {
  35858. $input.closest('li')
  35859. .addClass(this.options.selectedClass);
  35860. }
  35861. }
  35862. else {
  35863. $input.prop('checked', false);
  35864. if (this.options.selectedClass) {
  35865. $input.closest('li')
  35866. .removeClass(this.options.selectedClass);
  35867. }
  35868. }
  35869. if ($(element).is(":disabled")) {
  35870. $input.attr('disabled', 'disabled')
  35871. .prop('disabled', true)
  35872. .closest('li')
  35873. .addClass('disabled');
  35874. }
  35875. else {
  35876. $input.prop('disabled', false)
  35877. .closest('li')
  35878. .removeClass('disabled');
  35879. }
  35880. }, this));
  35881. this.updateButtonText();
  35882. this.updateSelectAll();
  35883. },
  35884. /**
  35885. * Select all options of the given values.
  35886. *
  35887. * If triggerOnChange is set to true, the on change event is triggered if
  35888. * and only if one value is passed.
  35889. *
  35890. * @param {Array} selectValues
  35891. * @param {Boolean} triggerOnChange
  35892. */
  35893. select: function(selectValues, triggerOnChange) {
  35894. if(!$.isArray(selectValues)) {
  35895. selectValues = [selectValues];
  35896. }
  35897. for (var i = 0; i < selectValues.length; i++) {
  35898. var value = selectValues[i];
  35899. if (value === null || value === undefined) {
  35900. continue;
  35901. }
  35902. var $option = this.getOptionByValue(value);
  35903. var $checkbox = this.getInputByValue(value);
  35904. if($option === undefined || $checkbox === undefined) {
  35905. continue;
  35906. }
  35907. if (!this.options.multiple) {
  35908. this.deselectAll(false);
  35909. }
  35910. if (this.options.selectedClass) {
  35911. $checkbox.closest('li')
  35912. .addClass(this.options.selectedClass);
  35913. }
  35914. $checkbox.prop('checked', true);
  35915. $option.prop('selected', true);
  35916. if (triggerOnChange) {
  35917. this.options.onChange($option, true);
  35918. }
  35919. }
  35920. this.updateButtonText();
  35921. this.updateSelectAll();
  35922. },
  35923. /**
  35924. * Clears all selected items.
  35925. */
  35926. clearSelection: function () {
  35927. this.deselectAll(false);
  35928. this.updateButtonText();
  35929. this.updateSelectAll();
  35930. },
  35931. /**
  35932. * Deselects all options of the given values.
  35933. *
  35934. * If triggerOnChange is set to true, the on change event is triggered, if
  35935. * and only if one value is passed.
  35936. *
  35937. * @param {Array} deselectValues
  35938. * @param {Boolean} triggerOnChange
  35939. */
  35940. deselect: function(deselectValues, triggerOnChange) {
  35941. if(!$.isArray(deselectValues)) {
  35942. deselectValues = [deselectValues];
  35943. }
  35944. for (var i = 0; i < deselectValues.length; i++) {
  35945. var value = deselectValues[i];
  35946. if (value === null || value === undefined) {
  35947. continue;
  35948. }
  35949. var $option = this.getOptionByValue(value);
  35950. var $checkbox = this.getInputByValue(value);
  35951. if($option === undefined || $checkbox === undefined) {
  35952. continue;
  35953. }
  35954. if (this.options.selectedClass) {
  35955. $checkbox.closest('li')
  35956. .removeClass(this.options.selectedClass);
  35957. }
  35958. $checkbox.prop('checked', false);
  35959. $option.prop('selected', false);
  35960. if (triggerOnChange) {
  35961. this.options.onChange($option, false);
  35962. }
  35963. }
  35964. this.updateButtonText();
  35965. this.updateSelectAll();
  35966. },
  35967. /**
  35968. * Selects all enabled & visible options.
  35969. *
  35970. * If justVisible is true or not specified, only visible options are selected.
  35971. *
  35972. * @param {Boolean} justVisible
  35973. * @param {Boolean} triggerOnSelectAll
  35974. */
  35975. selectAll: function (justVisible, triggerOnSelectAll) {
  35976. var justVisible = typeof justVisible === 'undefined' ? true : justVisible;
  35977. var allCheckboxes = $("li input[type='checkbox']:enabled", this.$ul);
  35978. var visibleCheckboxes = allCheckboxes.filter(":visible");
  35979. var allCheckboxesCount = allCheckboxes.length;
  35980. var visibleCheckboxesCount = visibleCheckboxes.length;
  35981. if(justVisible) {
  35982. visibleCheckboxes.prop('checked', true);
  35983. $("li:not(.divider):not(.disabled)", this.$ul).filter(":visible").addClass(this.options.selectedClass);
  35984. }
  35985. else {
  35986. allCheckboxes.prop('checked', true);
  35987. $("li:not(.divider):not(.disabled)", this.$ul).addClass(this.options.selectedClass);
  35988. }
  35989. if (allCheckboxesCount === visibleCheckboxesCount || justVisible === false) {
  35990. $("option:enabled", this.$select).prop('selected', true);
  35991. }
  35992. else {
  35993. var values = visibleCheckboxes.map(function() {
  35994. return $(this).val();
  35995. }).get();
  35996. $("option:enabled", this.$select).filter(function(index) {
  35997. return $.inArray($(this).val(), values) !== -1;
  35998. }).prop('selected', true);
  35999. }
  36000. if (triggerOnSelectAll) {
  36001. this.options.onSelectAll();
  36002. }
  36003. },
  36004. /**
  36005. * Deselects all options.
  36006. *
  36007. * If justVisible is true or not specified, only visible options are deselected.
  36008. *
  36009. * @param {Boolean} justVisible
  36010. */
  36011. deselectAll: function (justVisible) {
  36012. var justVisible = typeof justVisible === 'undefined' ? true : justVisible;
  36013. if(justVisible) {
  36014. var visibleCheckboxes = $("li input[type='checkbox']:not(:disabled)", this.$ul).filter(":visible");
  36015. visibleCheckboxes.prop('checked', false);
  36016. var values = visibleCheckboxes.map(function() {
  36017. return $(this).val();
  36018. }).get();
  36019. $("option:enabled", this.$select).filter(function(index) {
  36020. return $.inArray($(this).val(), values) !== -1;
  36021. }).prop('selected', false);
  36022. if (this.options.selectedClass) {
  36023. $("li:not(.divider):not(.disabled)", this.$ul).filter(":visible").removeClass(this.options.selectedClass);
  36024. }
  36025. }
  36026. else {
  36027. $("li input[type='checkbox']:enabled", this.$ul).prop('checked', false);
  36028. $("option:enabled", this.$select).prop('selected', false);
  36029. if (this.options.selectedClass) {
  36030. $("li:not(.divider):not(.disabled)", this.$ul).removeClass(this.options.selectedClass);
  36031. }
  36032. }
  36033. },
  36034. /**
  36035. * Rebuild the plugin.
  36036. *
  36037. * Rebuilds the dropdown, the filter and the select all option.
  36038. */
  36039. rebuild: function() {
  36040. this.$ul.html('');
  36041. // Important to distinguish between radios and checkboxes.
  36042. this.options.multiple = this.$select.attr('multiple') === "multiple";
  36043. this.buildSelectAll();
  36044. this.buildDropdownOptions();
  36045. this.buildFilter();
  36046. this.updateButtonText();
  36047. this.updateSelectAll();
  36048. if (this.options.disableIfEmpty && $('option', this.$select).length <= 0) {
  36049. this.disable();
  36050. }
  36051. else {
  36052. this.enable();
  36053. }
  36054. if (this.options.dropRight) {
  36055. this.$ul.addClass('pull-right');
  36056. }
  36057. },
  36058. /**
  36059. * The provided data will be used to build the dropdown.
  36060. */
  36061. dataprovider: function(dataprovider) {
  36062. var groupCounter = 0;
  36063. var $select = this.$select.empty();
  36064. $.each(dataprovider, function (index, option) {
  36065. var $tag;
  36066. if ($.isArray(option.children)) { // create optiongroup tag
  36067. groupCounter++;
  36068. $tag = $('<optgroup/>').attr({
  36069. label: option.label || 'Group ' + groupCounter,
  36070. disabled: !!option.disabled
  36071. });
  36072. forEach(option.children, function(subOption) { // add children option tags
  36073. $tag.append($('<option/>').attr({
  36074. value: subOption.value,
  36075. label: subOption.label || subOption.value,
  36076. title: subOption.title,
  36077. selected: !!subOption.selected,
  36078. disabled: !!subOption.disabled
  36079. }));
  36080. });
  36081. }
  36082. else {
  36083. $tag = $('<option/>').attr({
  36084. value: option.value,
  36085. label: option.label || option.value,
  36086. title: option.title,
  36087. selected: !!option.selected,
  36088. disabled: !!option.disabled
  36089. });
  36090. }
  36091. $select.append($tag);
  36092. });
  36093. this.rebuild();
  36094. },
  36095. /**
  36096. * Enable the multiselect.
  36097. */
  36098. enable: function() {
  36099. this.$select.prop('disabled', false);
  36100. this.$button.prop('disabled', false)
  36101. .removeClass('disabled');
  36102. },
  36103. /**
  36104. * Disable the multiselect.
  36105. */
  36106. disable: function() {
  36107. this.$select.prop('disabled', true);
  36108. this.$button.prop('disabled', true)
  36109. .addClass('disabled');
  36110. },
  36111. /**
  36112. * Set the options.
  36113. *
  36114. * @param {Array} options
  36115. */
  36116. setOptions: function(options) {
  36117. this.options = this.mergeOptions(options);
  36118. },
  36119. /**
  36120. * Merges the given options with the default options.
  36121. *
  36122. * @param {Array} options
  36123. * @returns {Array}
  36124. */
  36125. mergeOptions: function(options) {
  36126. return $.extend(true, {}, this.defaults, this.options, options);
  36127. },
  36128. /**
  36129. * Checks whether a select all checkbox is present.
  36130. *
  36131. * @returns {Boolean}
  36132. */
  36133. hasSelectAll: function() {
  36134. return $('li.multiselect-all', this.$ul).length > 0;
  36135. },
  36136. /**
  36137. * Updates the select all checkbox based on the currently displayed and selected checkboxes.
  36138. */
  36139. updateSelectAll: function() {
  36140. if (this.hasSelectAll()) {
  36141. var allBoxes = $("li:not(.multiselect-item):not(.filter-hidden) input:enabled", this.$ul);
  36142. var allBoxesLength = allBoxes.length;
  36143. var checkedBoxesLength = allBoxes.filter(":checked").length;
  36144. var selectAllLi = $("li.multiselect-all", this.$ul);
  36145. var selectAllInput = selectAllLi.find("input");
  36146. if (checkedBoxesLength > 0 && checkedBoxesLength === allBoxesLength) {
  36147. selectAllInput.prop("checked", true);
  36148. selectAllLi.addClass(this.options.selectedClass);
  36149. this.options.onSelectAll();
  36150. }
  36151. else {
  36152. selectAllInput.prop("checked", false);
  36153. selectAllLi.removeClass(this.options.selectedClass);
  36154. }
  36155. }
  36156. },
  36157. /**
  36158. * Update the button text and its title based on the currently selected options.
  36159. */
  36160. updateButtonText: function() {
  36161. var options = this.getSelected();
  36162. // First update the displayed button text.
  36163. if (this.options.enableHTML) {
  36164. $('.multiselect .multiselect-selected-text', this.$container).html(this.options.buttonText(options, this.$select));
  36165. }
  36166. else {
  36167. $('.multiselect .multiselect-selected-text', this.$container).text(this.options.buttonText(options, this.$select));
  36168. }
  36169. // Now update the title attribute of the button.
  36170. $('.multiselect', this.$container).attr('title', this.options.buttonTitle(options, this.$select));
  36171. },
  36172. /**
  36173. * Get all selected options.
  36174. *
  36175. * @returns {jQUery}
  36176. */
  36177. getSelected: function() {
  36178. return $('option', this.$select).filter(":selected");
  36179. },
  36180. /**
  36181. * Gets a select option by its value.
  36182. *
  36183. * @param {String} value
  36184. * @returns {jQuery}
  36185. */
  36186. getOptionByValue: function (value) {
  36187. var options = $('option', this.$select);
  36188. var valueToCompare = value.toString();
  36189. for (var i = 0; i < options.length; i = i + 1) {
  36190. var option = options[i];
  36191. if (option.value === valueToCompare) {
  36192. return $(option);
  36193. }
  36194. }
  36195. },
  36196. /**
  36197. * Get the input (radio/checkbox) by its value.
  36198. *
  36199. * @param {String} value
  36200. * @returns {jQuery}
  36201. */
  36202. getInputByValue: function (value) {
  36203. var checkboxes = $('li input', this.$ul);
  36204. var valueToCompare = value.toString();
  36205. for (var i = 0; i < checkboxes.length; i = i + 1) {
  36206. var checkbox = checkboxes[i];
  36207. if (checkbox.value === valueToCompare) {
  36208. return $(checkbox);
  36209. }
  36210. }
  36211. },
  36212. /**
  36213. * Used for knockout integration.
  36214. */
  36215. updateOriginalOptions: function() {
  36216. this.originalOptions = this.$select.clone()[0].options;
  36217. },
  36218. asyncFunction: function(callback, timeout, self) {
  36219. var args = Array.prototype.slice.call(arguments, 3);
  36220. return setTimeout(function() {
  36221. callback.apply(self || window, args);
  36222. }, timeout);
  36223. },
  36224. setAllSelectedText: function(allSelectedText) {
  36225. this.options.allSelectedText = allSelectedText;
  36226. this.updateButtonText();
  36227. }
  36228. };
  36229. $.fn.multiselect = function(option, parameter, extraOptions) {
  36230. return this.each(function() {
  36231. var data = $(this).data('multiselect');
  36232. var options = typeof option === 'object' && option;
  36233. // Initialize the multiselect.
  36234. if (!data) {
  36235. data = new Multiselect(this, options);
  36236. $(this).data('multiselect', data);
  36237. }
  36238. // Call multiselect method.
  36239. if (typeof option === 'string') {
  36240. data[option](parameter, extraOptions);
  36241. if (option === 'destroy') {
  36242. $(this).data('multiselect', false);
  36243. }
  36244. }
  36245. });
  36246. };
  36247. $.fn.multiselect.Constructor = Multiselect;
  36248. $(function() {
  36249. $("select[data-role=multiselect]").multiselect();
  36250. });
  36251. }(window.jQuery);
  36252. /*
  36253. * International Telephone Input v12.0.2
  36254. * https://github.com/jackocnr/intl-tel-input.git
  36255. * Licensed under the MIT license
  36256. */
  36257. // wrap in UMD - see https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js
  36258. (function(factory) {
  36259. if (typeof define === "function" && define.amd) {
  36260. define([ "jquery" ], function($) {
  36261. factory($, window, document);
  36262. });
  36263. } else if (typeof module === "object" && module.exports) {
  36264. module.exports = factory(require("jquery"), window, document);
  36265. } else {
  36266. factory(jQuery, window, document);
  36267. }
  36268. })(function($, window, document, undefined) {
  36269. "use strict";
  36270. // these vars persist through all instances of the plugin
  36271. var pluginName = "intlTelInput", id = 1, // give each instance it's own id for namespaced event handling
  36272. defaults = {
  36273. // whether or not to allow the dropdown
  36274. allowDropdown: true,
  36275. // if there is just a dial code in the input: remove it on blur, and re-add it on focus
  36276. autoHideDialCode: true,
  36277. // add a placeholder in the input with an example number for the selected country
  36278. autoPlaceholder: "polite",
  36279. // modify the auto placeholder
  36280. customPlaceholder: null,
  36281. // append menu to a specific element
  36282. dropdownContainer: "",
  36283. // don't display these countries
  36284. excludeCountries: [],
  36285. // format the input value during initialisation and on setNumber
  36286. formatOnDisplay: true,
  36287. // geoIp lookup function
  36288. geoIpLookup: null,
  36289. // inject a hidden input with this name, and on submit, populate it with the result of getNumber
  36290. hiddenInput: "",
  36291. // initial country
  36292. initialCountry: "",
  36293. // don't insert international dial codes
  36294. nationalMode: true,
  36295. // display only these countries
  36296. onlyCountries: [],
  36297. // number type to use for placeholders
  36298. placeholderNumberType: "MOBILE",
  36299. // the countries at the top of the list. defaults to united states and united kingdom
  36300. preferredCountries: [ "us", "gb" ],
  36301. // display the country dial code next to the selected flag so it's not part of the typed number
  36302. separateDialCode: false,
  36303. // specify the path to the libphonenumber script to enable validation/formatting
  36304. utilsScript: ""
  36305. }, keys = {
  36306. UP: 38,
  36307. DOWN: 40,
  36308. ENTER: 13,
  36309. ESC: 27,
  36310. PLUS: 43,
  36311. A: 65,
  36312. Z: 90,
  36313. SPACE: 32,
  36314. TAB: 9
  36315. }, // https://en.wikipedia.org/wiki/List_of_North_American_Numbering_Plan_area_codes#Non-geographic_area_codes
  36316. regionlessNanpNumbers = [ "800", "822", "833", "844", "855", "866", "877", "880", "881", "882", "883", "884", "885", "886", "887", "888", "889" ];
  36317. // keep track of if the window.load event has fired as impossible to check after the fact
  36318. $(window).on("load", function() {
  36319. // UPDATE: use a public static field so we can fudge it in the tests
  36320. $.fn[pluginName].windowLoaded = true;
  36321. });
  36322. function Plugin(element, options) {
  36323. this.telInput = $(element);
  36324. this.options = $.extend({}, defaults, options);
  36325. // event namespace
  36326. this.ns = "." + pluginName + id++;
  36327. // Chrome, FF, Safari, IE9+
  36328. this.isGoodBrowser = Boolean(element.setSelectionRange);
  36329. this.hadInitialPlaceholder = Boolean($(element).attr("placeholder"));
  36330. }
  36331. Plugin.prototype = {
  36332. _init: function() {
  36333. // if in nationalMode, disable options relating to dial codes
  36334. if (this.options.nationalMode) {
  36335. this.options.autoHideDialCode = false;
  36336. }
  36337. // if separateDialCode then doesn't make sense to A) insert dial code into input (autoHideDialCode), and B) display national numbers (because we're displaying the country dial code next to them)
  36338. if (this.options.separateDialCode) {
  36339. this.options.autoHideDialCode = this.options.nationalMode = false;
  36340. }
  36341. // we cannot just test screen size as some smartphones/website meta tags will report desktop resolutions
  36342. // Note: for some reason jasmine breaks if you put this in the main Plugin function with the rest of these declarations
  36343. // Note: to target Android Mobiles (and not Tablets), we must find "Android" and "Mobile"
  36344. this.isMobile = /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
  36345. if (this.isMobile) {
  36346. // trigger the mobile dropdown css
  36347. $("body").addClass("iti-mobile");
  36348. // on mobile, we want a full screen dropdown, so we must append it to the body
  36349. if (!this.options.dropdownContainer) {
  36350. this.options.dropdownContainer = "body";
  36351. }
  36352. }
  36353. // we return these deferred objects from the _init() call so they can be watched, and then we resolve them when each specific request returns
  36354. // Note: again, jasmine breaks when I put these in the Plugin function
  36355. this.autoCountryDeferred = new $.Deferred();
  36356. this.utilsScriptDeferred = new $.Deferred();
  36357. // in various situations there could be no country selected initially, but we need to be able to assume this variable exists
  36358. this.selectedCountryData = {};
  36359. // process all the data: onlyCountries, excludeCountries, preferredCountries etc
  36360. this._processCountryData();
  36361. // generate the markup
  36362. this._generateMarkup();
  36363. // set the initial state of the input value and the selected flag
  36364. this._setInitialState();
  36365. // start all of the event listeners: autoHideDialCode, input keydown, selectedFlag click
  36366. this._initListeners();
  36367. // utils script, and auto country
  36368. this._initRequests();
  36369. // return the deferreds
  36370. return [ this.autoCountryDeferred, this.utilsScriptDeferred ];
  36371. },
  36372. /********************
  36373. * PRIVATE METHODS
  36374. ********************/
  36375. // prepare all of the country data, including onlyCountries, excludeCountries and preferredCountries options
  36376. _processCountryData: function() {
  36377. // process onlyCountries or excludeCountries array if present
  36378. this._processAllCountries();
  36379. // process the countryCodes map
  36380. this._processCountryCodes();
  36381. // process the preferredCountries
  36382. this._processPreferredCountries();
  36383. },
  36384. // add a country code to this.countryCodes
  36385. _addCountryCode: function(iso2, dialCode, priority) {
  36386. if (!(dialCode in this.countryCodes)) {
  36387. this.countryCodes[dialCode] = [];
  36388. }
  36389. var index = priority || 0;
  36390. this.countryCodes[dialCode][index] = iso2;
  36391. },
  36392. // process onlyCountries or excludeCountries array if present
  36393. _processAllCountries: function() {
  36394. if (this.options.onlyCountries.length) {
  36395. var lowerCaseOnlyCountries = this.options.onlyCountries.map(function(country) {
  36396. return country.toLowerCase();
  36397. });
  36398. this.countries = allCountries.filter(function(country) {
  36399. return lowerCaseOnlyCountries.indexOf(country.iso2) > -1;
  36400. });
  36401. } else if (this.options.excludeCountries.length) {
  36402. var lowerCaseExcludeCountries = this.options.excludeCountries.map(function(country) {
  36403. return country.toLowerCase();
  36404. });
  36405. this.countries = allCountries.filter(function(country) {
  36406. return lowerCaseExcludeCountries.indexOf(country.iso2) === -1;
  36407. });
  36408. } else {
  36409. this.countries = allCountries;
  36410. }
  36411. },
  36412. // process the countryCodes map
  36413. _processCountryCodes: function() {
  36414. this.countryCodes = {};
  36415. for (var i = 0; i < this.countries.length; i++) {
  36416. var c = this.countries[i];
  36417. this._addCountryCode(c.iso2, c.dialCode, c.priority);
  36418. // area codes
  36419. if (c.areaCodes) {
  36420. for (var j = 0; j < c.areaCodes.length; j++) {
  36421. // full dial code is country code + dial code
  36422. this._addCountryCode(c.iso2, c.dialCode + c.areaCodes[j]);
  36423. }
  36424. }
  36425. }
  36426. },
  36427. // process preferred countries - iterate through the preferences, fetching the country data for each one
  36428. _processPreferredCountries: function() {
  36429. this.preferredCountries = [];
  36430. for (var i = 0; i < this.options.preferredCountries.length; i++) {
  36431. var countryCode = this.options.preferredCountries[i].toLowerCase(), countryData = this._getCountryData(countryCode, false, true);
  36432. if (countryData) {
  36433. this.preferredCountries.push(countryData);
  36434. }
  36435. }
  36436. },
  36437. // generate all of the markup for the plugin: the selected flag overlay, and the dropdown
  36438. _generateMarkup: function() {
  36439. // prevent autocomplete as there's no safe, cross-browser event we can react to, so it can easily put the plugin in an inconsistent state e.g. the wrong flag selected for the autocompleted number, which on submit could mean the wrong number is saved (esp in nationalMode)
  36440. this.telInput.attr("autocomplete", "off");
  36441. // containers (mostly for positioning)
  36442. var parentClass = "intl-tel-input";
  36443. if (this.options.allowDropdown) {
  36444. parentClass += " allow-dropdown";
  36445. }
  36446. if (this.options.separateDialCode) {
  36447. parentClass += " separate-dial-code";
  36448. }
  36449. this.telInput.wrap($("<div>", {
  36450. "class": parentClass
  36451. }));
  36452. this.flagsContainer = $("<div>", {
  36453. "class": "flag-container"
  36454. }).insertBefore(this.telInput);
  36455. // currently selected flag (displayed to left of input)
  36456. var selectedFlag = $("<div>", {
  36457. "class": "selected-flag"
  36458. });
  36459. selectedFlag.appendTo(this.flagsContainer);
  36460. this.selectedFlagInner = $("<div>", {
  36461. "class": "iti-flag"
  36462. }).appendTo(selectedFlag);
  36463. if (this.options.separateDialCode) {
  36464. this.selectedDialCode = $("<div>", {
  36465. "class": "selected-dial-code"
  36466. }).appendTo(selectedFlag);
  36467. }
  36468. if (this.options.allowDropdown) {
  36469. // make element focusable and tab naviagable
  36470. selectedFlag.attr("tabindex", "0");
  36471. // CSS triangle
  36472. $("<div>", {
  36473. "class": "iti-arrow"
  36474. }).appendTo(selectedFlag);
  36475. // country dropdown: preferred countries, then divider, then all countries
  36476. this.countryList = $("<ul>", {
  36477. "class": "country-list hide"
  36478. });
  36479. if (this.preferredCountries.length) {
  36480. this._appendListItems(this.preferredCountries, "preferred");
  36481. $("<li>", {
  36482. "class": "divider"
  36483. }).appendTo(this.countryList);
  36484. }
  36485. this._appendListItems(this.countries, "");
  36486. // this is useful in lots of places
  36487. this.countryListItems = this.countryList.children(".country");
  36488. // create dropdownContainer markup
  36489. if (this.options.dropdownContainer) {
  36490. this.dropdown = $("<div>", {
  36491. "class": "intl-tel-input iti-container"
  36492. }).append(this.countryList);
  36493. } else {
  36494. this.countryList.appendTo(this.flagsContainer);
  36495. }
  36496. } else {
  36497. // a little hack so we don't break anything
  36498. this.countryListItems = $();
  36499. }
  36500. if (this.options.hiddenInput) {
  36501. this.hiddenInput = $("<input>", {
  36502. type: "hidden",
  36503. name: this.options.hiddenInput
  36504. }).insertBefore(this.telInput);
  36505. }
  36506. },
  36507. // add a country <li> to the countryList <ul> container
  36508. _appendListItems: function(countries, className) {
  36509. // we create so many DOM elements, it is faster to build a temp string
  36510. // and then add everything to the DOM in one go at the end
  36511. var tmp = "";
  36512. // for each country
  36513. for (var i = 0; i < countries.length; i++) {
  36514. var c = countries[i];
  36515. // open the list item
  36516. tmp += "<li class='country " + className + "' data-dial-code='" + c.dialCode + "' data-country-code='" + c.iso2 + "'>";
  36517. // add the flag
  36518. tmp += "<div class='flag-box'><div class='iti-flag " + c.iso2 + "'></div></div>";
  36519. // and the country name and dial code
  36520. tmp += "<span class='country-name'>" + c.name + "</span>";
  36521. tmp += "<span class='dial-code'>+" + c.dialCode + "</span>";
  36522. // close the list item
  36523. tmp += "</li>";
  36524. }
  36525. this.countryList.append(tmp);
  36526. },
  36527. // set the initial state of the input value and the selected flag by:
  36528. // 1. extracting a dial code from the given number
  36529. // 2. using explicit initialCountry
  36530. // 3. picking the first preferred country
  36531. // 4. picking the first country
  36532. _setInitialState: function() {
  36533. var val = this.telInput.val();
  36534. // if we already have a dial code, and it's not a regionlessNanp, we can go ahead and set the flag, else fall back to the default country
  36535. // UPDATE: actually we do want to set the flag for a regionlessNanp in one situation: if we're in nationalMode and there's no initialCountry - otherwise we lose the +1 and we're left with an invalid number
  36536. if (this._getDialCode(val) && (!this._isRegionlessNanp(val) || this.options.nationalMode && !this.options.initialCountry)) {
  36537. this._updateFlagFromNumber(val);
  36538. } else if (this.options.initialCountry !== "auto") {
  36539. // see if we should select a flag
  36540. if (this.options.initialCountry) {
  36541. this._setFlag(this.options.initialCountry.toLowerCase());
  36542. } else {
  36543. // no dial code and no initialCountry, so default to first in list
  36544. this.defaultCountry = this.preferredCountries.length ? this.preferredCountries[0].iso2 : this.countries[0].iso2;
  36545. if (!val) {
  36546. this._setFlag(this.defaultCountry);
  36547. }
  36548. }
  36549. // if empty and no nationalMode and no autoHideDialCode then insert the default dial code
  36550. if (!val && !this.options.nationalMode && !this.options.autoHideDialCode && !this.options.separateDialCode) {
  36551. this.telInput.val("+" + this.selectedCountryData.dialCode);
  36552. }
  36553. }
  36554. // NOTE: if initialCountry is set to auto, that will be handled separately
  36555. // format
  36556. if (val) {
  36557. // this wont be run after _updateDialCode as that's only called if no val
  36558. this._updateValFromNumber(val);
  36559. }
  36560. },
  36561. // initialise the main event listeners: input keyup, and click selected flag
  36562. _initListeners: function() {
  36563. this._initKeyListeners();
  36564. if (this.options.autoHideDialCode) {
  36565. this._initFocusListeners();
  36566. }
  36567. if (this.options.allowDropdown) {
  36568. this._initDropdownListeners();
  36569. }
  36570. if (this.hiddenInput) {
  36571. this._initHiddenInputListener();
  36572. }
  36573. },
  36574. // update hidden input on form submit
  36575. _initHiddenInputListener: function() {
  36576. var that = this;
  36577. var form = this.telInput.closest("form");
  36578. if (form.length) {
  36579. form.submit(function() {
  36580. that.hiddenInput.val(that.getNumber());
  36581. });
  36582. }
  36583. },
  36584. // initialise the dropdown listeners
  36585. _initDropdownListeners: function() {
  36586. var that = this;
  36587. // hack for input nested inside label: clicking the selected-flag to open the dropdown would then automatically trigger a 2nd click on the input which would close it again
  36588. var label = this.telInput.closest("label");
  36589. if (label.length) {
  36590. label.on("click" + this.ns, function(e) {
  36591. // if the dropdown is closed, then focus the input, else ignore the click
  36592. if (that.countryList.hasClass("hide")) {
  36593. that.telInput.focus();
  36594. } else {
  36595. e.preventDefault();
  36596. }
  36597. });
  36598. }
  36599. // toggle country dropdown on click
  36600. var selectedFlag = this.selectedFlagInner.parent();
  36601. selectedFlag.on("click" + this.ns, function(e) {
  36602. // only intercept this event if we're opening the dropdown
  36603. // else let it bubble up to the top ("click-off-to-close" listener)
  36604. // we cannot just stopPropagation as it may be needed to close another instance
  36605. if (that.countryList.hasClass("hide") && !that.telInput.prop("disabled") && !that.telInput.prop("readonly")) {
  36606. that._showDropdown();
  36607. }
  36608. });
  36609. // open dropdown list if currently focused
  36610. this.flagsContainer.on("keydown" + that.ns, function(e) {
  36611. var isDropdownHidden = that.countryList.hasClass("hide");
  36612. if (isDropdownHidden && (e.which == keys.UP || e.which == keys.DOWN || e.which == keys.SPACE || e.which == keys.ENTER)) {
  36613. // prevent form from being submitted if "ENTER" was pressed
  36614. e.preventDefault();
  36615. // prevent event from being handled again by document
  36616. e.stopPropagation();
  36617. that._showDropdown();
  36618. }
  36619. // allow navigation from dropdown to input on TAB
  36620. if (e.which == keys.TAB) {
  36621. that._closeDropdown();
  36622. }
  36623. });
  36624. },
  36625. // init many requests: utils script / geo ip lookup
  36626. _initRequests: function() {
  36627. var that = this;
  36628. // if the user has specified the path to the utils script, fetch it on window.load, else resolve
  36629. if (this.options.utilsScript) {
  36630. // if the plugin is being initialised after the window.load event has already been fired
  36631. if ($.fn[pluginName].windowLoaded) {
  36632. $.fn[pluginName].loadUtils(this.options.utilsScript, this.utilsScriptDeferred);
  36633. } else {
  36634. // wait until the load event so we don't block any other requests e.g. the flags image
  36635. $(window).on("load", function() {
  36636. $.fn[pluginName].loadUtils(that.options.utilsScript, that.utilsScriptDeferred);
  36637. });
  36638. }
  36639. } else {
  36640. this.utilsScriptDeferred.resolve();
  36641. }
  36642. if (this.options.initialCountry === "auto") {
  36643. this._loadAutoCountry();
  36644. } else {
  36645. this.autoCountryDeferred.resolve();
  36646. }
  36647. },
  36648. // perform the geo ip lookup
  36649. _loadAutoCountry: function() {
  36650. var that = this;
  36651. // 3 options:
  36652. // 1) already loaded (we're done)
  36653. // 2) not already started loading (start)
  36654. // 3) already started loading (do nothing - just wait for loading callback to fire)
  36655. if ($.fn[pluginName].autoCountry) {
  36656. this.handleAutoCountry();
  36657. } else if (!$.fn[pluginName].startedLoadingAutoCountry) {
  36658. // don't do this twice!
  36659. $.fn[pluginName].startedLoadingAutoCountry = true;
  36660. if (typeof this.options.geoIpLookup === "function") {
  36661. this.options.geoIpLookup(function(countryCode) {
  36662. $.fn[pluginName].autoCountry = countryCode.toLowerCase();
  36663. // tell all instances the auto country is ready
  36664. // TODO: this should just be the current instances
  36665. // UPDATE: use setTimeout in case their geoIpLookup function calls this callback straight away (e.g. if they have already done the geo ip lookup somewhere else). Using setTimeout means that the current thread of execution will finish before executing this, which allows the plugin to finish initialising.
  36666. setTimeout(function() {
  36667. $(".intl-tel-input input").intlTelInput("handleAutoCountry");
  36668. });
  36669. });
  36670. }
  36671. }
  36672. },
  36673. // initialize any key listeners
  36674. _initKeyListeners: function() {
  36675. var that = this;
  36676. // update flag on keyup
  36677. // (keep this listener separate otherwise the setTimeout breaks all the tests)
  36678. this.telInput.on("keyup" + this.ns, function() {
  36679. if (that._updateFlagFromNumber(that.telInput.val())) {
  36680. that._triggerCountryChange();
  36681. }
  36682. });
  36683. // update flag on cut/paste events (now supported in all major browsers)
  36684. this.telInput.on("cut" + this.ns + " paste" + this.ns, function() {
  36685. // hack because "paste" event is fired before input is updated
  36686. setTimeout(function() {
  36687. if (that._updateFlagFromNumber(that.telInput.val())) {
  36688. that._triggerCountryChange();
  36689. }
  36690. });
  36691. });
  36692. },
  36693. // adhere to the input's maxlength attr
  36694. _cap: function(number) {
  36695. var max = this.telInput.attr("maxlength");
  36696. return max && number.length > max ? number.substr(0, max) : number;
  36697. },
  36698. // listen for mousedown, focus and blur
  36699. _initFocusListeners: function() {
  36700. var that = this;
  36701. // mousedown decides where the cursor goes, so if we're focusing we must preventDefault as we'll be inserting the dial code, and we want the cursor to be at the end no matter where they click
  36702. this.telInput.on("mousedown" + this.ns, function(e) {
  36703. if (!that.telInput.is(":focus") && !that.telInput.val()) {
  36704. e.preventDefault();
  36705. // but this also cancels the focus, so we must trigger that manually
  36706. that.telInput.focus();
  36707. }
  36708. });
  36709. // on focus: if empty, insert the dial code for the currently selected flag
  36710. this.telInput.on("focus" + this.ns, function(e) {
  36711. if (!that.telInput.val() && !that.telInput.prop("readonly") && that.selectedCountryData.dialCode) {
  36712. // insert the dial code
  36713. that.telInput.val("+" + that.selectedCountryData.dialCode);
  36714. // after auto-inserting a dial code, if the first key they hit is '+' then assume they are entering a new number, so remove the dial code. use keypress instead of keydown because keydown gets triggered for the shift key (required to hit the + key), and instead of keyup because that shows the new '+' before removing the old one
  36715. that.telInput.one("keypress.plus" + that.ns, function(e) {
  36716. if (e.which == keys.PLUS) {
  36717. that.telInput.val("");
  36718. }
  36719. });
  36720. // after tabbing in, make sure the cursor is at the end we must use setTimeout to get outside of the focus handler as it seems the selection happens after that
  36721. setTimeout(function() {
  36722. var input = that.telInput[0];
  36723. if (that.isGoodBrowser) {
  36724. var len = that.telInput.val().length;
  36725. input.setSelectionRange(len, len);
  36726. }
  36727. });
  36728. }
  36729. });
  36730. // on blur or form submit: if just a dial code then remove it
  36731. var form = this.telInput.prop("form");
  36732. if (form) {
  36733. $(form).on("submit" + this.ns, function() {
  36734. that._removeEmptyDialCode();
  36735. });
  36736. }
  36737. this.telInput.on("blur" + this.ns, function() {
  36738. that._removeEmptyDialCode();
  36739. });
  36740. },
  36741. _removeEmptyDialCode: function() {
  36742. var value = this.telInput.val(), startsPlus = value.charAt(0) == "+";
  36743. if (startsPlus) {
  36744. var numeric = this._getNumeric(value);
  36745. // if just a plus, or if just a dial code
  36746. if (!numeric || this.selectedCountryData.dialCode == numeric) {
  36747. this.telInput.val("");
  36748. }
  36749. }
  36750. // remove the keypress listener we added on focus
  36751. this.telInput.off("keypress.plus" + this.ns);
  36752. },
  36753. // extract the numeric digits from the given string
  36754. _getNumeric: function(s) {
  36755. return s.replace(/\D/g, "");
  36756. },
  36757. // show the dropdown
  36758. _showDropdown: function() {
  36759. this._setDropdownPosition();
  36760. // update highlighting and scroll to active list item
  36761. var activeListItem = this.countryList.children(".active");
  36762. if (activeListItem.length) {
  36763. this._highlightListItem(activeListItem);
  36764. this._scrollTo(activeListItem);
  36765. }
  36766. // bind all the dropdown-related listeners: mouseover, click, click-off, keydown
  36767. this._bindDropdownListeners();
  36768. // update the arrow
  36769. this.selectedFlagInner.children(".iti-arrow").addClass("up");
  36770. this.telInput.trigger("open:countrydropdown");
  36771. },
  36772. // decide where to position dropdown (depends on position within viewport, and scroll)
  36773. _setDropdownPosition: function() {
  36774. var that = this;
  36775. if (this.options.dropdownContainer) {
  36776. this.dropdown.appendTo(this.options.dropdownContainer);
  36777. }
  36778. // show the menu and grab the dropdown height
  36779. this.dropdownHeight = this.countryList.removeClass("hide").outerHeight();
  36780. if (!this.isMobile) {
  36781. var pos = this.telInput.offset(), inputTop = pos.top, windowTop = $(window).scrollTop(), // dropdownFitsBelow = (dropdownBottom < windowBottom)
  36782. dropdownFitsBelow = inputTop + this.telInput.outerHeight() + this.dropdownHeight < windowTop + $(window).height(), dropdownFitsAbove = inputTop - this.dropdownHeight > windowTop;
  36783. // by default, the dropdown will be below the input. If we want to position it above the input, we add the dropup class.
  36784. this.countryList.toggleClass("dropup", !dropdownFitsBelow && dropdownFitsAbove);
  36785. // if dropdownContainer is enabled, calculate postion
  36786. if (this.options.dropdownContainer) {
  36787. // by default the dropdown will be directly over the input because it's not in the flow. If we want to position it below, we need to add some extra top value.
  36788. var extraTop = !dropdownFitsBelow && dropdownFitsAbove ? 0 : this.telInput.innerHeight();
  36789. // calculate placement
  36790. this.dropdown.css({
  36791. top: inputTop + extraTop,
  36792. left: pos.left
  36793. });
  36794. // close menu on window scroll
  36795. $(window).on("scroll" + this.ns, function() {
  36796. that._closeDropdown();
  36797. });
  36798. }
  36799. }
  36800. },
  36801. // we only bind dropdown listeners when the dropdown is open
  36802. _bindDropdownListeners: function() {
  36803. var that = this;
  36804. // when mouse over a list item, just highlight that one
  36805. // we add the class "highlight", so if they hit "enter" we know which one to select
  36806. this.countryList.on("mouseover" + this.ns, ".country", function(e) {
  36807. that._highlightListItem($(this));
  36808. });
  36809. // listen for country selection
  36810. this.countryList.on("click" + this.ns, ".country", function(e) {
  36811. that._selectListItem($(this));
  36812. });
  36813. // click off to close
  36814. // (except when this initial opening click is bubbling up)
  36815. // we cannot just stopPropagation as it may be needed to close another instance
  36816. var isOpening = true;
  36817. $("html").on("click" + this.ns, function(e) {
  36818. if (!isOpening) {
  36819. that._closeDropdown();
  36820. }
  36821. isOpening = false;
  36822. });
  36823. // listen for up/down scrolling, enter to select, or letters to jump to country name.
  36824. // use keydown as keypress doesn't fire for non-char keys and we want to catch if they
  36825. // just hit down and hold it to scroll down (no keyup event).
  36826. // listen on the document because that's where key events are triggered if no input has focus
  36827. var query = "", queryTimer = null;
  36828. $(document).on("keydown" + this.ns, function(e) {
  36829. // prevent down key from scrolling the whole page,
  36830. // and enter key from submitting a form etc
  36831. e.preventDefault();
  36832. if (e.which == keys.UP || e.which == keys.DOWN) {
  36833. // up and down to navigate
  36834. that._handleUpDownKey(e.which);
  36835. } else if (e.which == keys.ENTER) {
  36836. // enter to select
  36837. that._handleEnterKey();
  36838. } else if (e.which == keys.ESC) {
  36839. // esc to close
  36840. that._closeDropdown();
  36841. } else if (e.which >= keys.A && e.which <= keys.Z || e.which == keys.SPACE) {
  36842. // upper case letters (note: keyup/keydown only return upper case letters)
  36843. // jump to countries that start with the query string
  36844. if (queryTimer) {
  36845. clearTimeout(queryTimer);
  36846. }
  36847. query += String.fromCharCode(e.which);
  36848. that._searchForCountry(query);
  36849. // if the timer hits 1 second, reset the query
  36850. queryTimer = setTimeout(function() {
  36851. query = "";
  36852. }, 1e3);
  36853. }
  36854. });
  36855. },
  36856. // highlight the next/prev item in the list (and ensure it is visible)
  36857. _handleUpDownKey: function(key) {
  36858. var current = this.countryList.children(".highlight").first();
  36859. var next = key == keys.UP ? current.prev() : current.next();
  36860. if (next.length) {
  36861. // skip the divider
  36862. if (next.hasClass("divider")) {
  36863. next = key == keys.UP ? next.prev() : next.next();
  36864. }
  36865. this._highlightListItem(next);
  36866. this._scrollTo(next);
  36867. }
  36868. },
  36869. // select the currently highlighted item
  36870. _handleEnterKey: function() {
  36871. var currentCountry = this.countryList.children(".highlight").first();
  36872. if (currentCountry.length) {
  36873. this._selectListItem(currentCountry);
  36874. }
  36875. },
  36876. // find the first list item whose name starts with the query string
  36877. _searchForCountry: function(query) {
  36878. for (var i = 0; i < this.countries.length; i++) {
  36879. if (this._startsWith(this.countries[i].name, query)) {
  36880. var listItem = this.countryList.children("[data-country-code=" + this.countries[i].iso2 + "]").not(".preferred");
  36881. // update highlighting and scroll
  36882. this._highlightListItem(listItem);
  36883. this._scrollTo(listItem, true);
  36884. break;
  36885. }
  36886. }
  36887. },
  36888. // check if (uppercase) string a starts with string b
  36889. _startsWith: function(a, b) {
  36890. return a.substr(0, b.length).toUpperCase() == b;
  36891. },
  36892. // update the input's value to the given val (format first if possible)
  36893. // NOTE: this is called from _setInitialState, handleUtils and setNumber
  36894. _updateValFromNumber: function(number) {
  36895. if (this.options.formatOnDisplay && window.intlTelInputUtils && this.selectedCountryData) {
  36896. var format = !this.options.separateDialCode && (this.options.nationalMode || number.charAt(0) != "+") ? intlTelInputUtils.numberFormat.NATIONAL : intlTelInputUtils.numberFormat.INTERNATIONAL;
  36897. number = intlTelInputUtils.formatNumber(number, this.selectedCountryData.iso2, format);
  36898. }
  36899. number = this._beforeSetNumber(number);
  36900. this.telInput.val(number);
  36901. },
  36902. // check if need to select a new flag based on the given number
  36903. // Note: called from _setInitialState, keyup handler, setNumber
  36904. _updateFlagFromNumber: function(number) {
  36905. // if we're in nationalMode and we already have US/Canada selected, make sure the number starts with a +1 so _getDialCode will be able to extract the area code
  36906. // update: if we dont yet have selectedCountryData, but we're here (trying to update the flag from the number), that means we're initialising the plugin with a number that already has a dial code, so fine to ignore this bit
  36907. if (number && this.options.nationalMode && this.selectedCountryData.dialCode == "1" && number.charAt(0) != "+") {
  36908. if (number.charAt(0) != "1") {
  36909. number = "1" + number;
  36910. }
  36911. number = "+" + number;
  36912. }
  36913. // try and extract valid dial code from input
  36914. var dialCode = this._getDialCode(number), countryCode = null, numeric = this._getNumeric(number);
  36915. if (dialCode) {
  36916. // check if one of the matching countries is already selected
  36917. var countryCodes = this.countryCodes[this._getNumeric(dialCode)], alreadySelected = $.inArray(this.selectedCountryData.iso2, countryCodes) > -1, // check if the given number contains a NANP area code i.e. the only dialCode that could be extracted was +1 (instead of say +1204) and the actual number's length is >=4
  36918. isNanpAreaCode = dialCode == "+1" && numeric.length >= 4, nanpSelected = this.selectedCountryData.dialCode == "1";
  36919. // only update the flag if:
  36920. // A) NOT (we currently have a NANP flag selected, and the number is a regionlessNanp)
  36921. // AND
  36922. // B) either a matching country is not already selected OR the number contains a NANP area code (ensure the flag is set to the first matching country)
  36923. if (!(nanpSelected && this._isRegionlessNanp(numeric)) && (!alreadySelected || isNanpAreaCode)) {
  36924. // if using onlyCountries option, countryCodes[0] may be empty, so we must find the first non-empty index
  36925. for (var j = 0; j < countryCodes.length; j++) {
  36926. if (countryCodes[j]) {
  36927. countryCode = countryCodes[j];
  36928. break;
  36929. }
  36930. }
  36931. }
  36932. } else if (number.charAt(0) == "+" && numeric.length) {
  36933. // invalid dial code, so empty
  36934. // Note: use getNumeric here because the number has not been formatted yet, so could contain bad chars
  36935. countryCode = "";
  36936. } else if (!number || number == "+") {
  36937. // empty, or just a plus, so default
  36938. countryCode = this.defaultCountry;
  36939. }
  36940. if (countryCode !== null) {
  36941. return this._setFlag(countryCode);
  36942. }
  36943. return false;
  36944. },
  36945. // check if the given number is a regionless NANP number (expects the number to contain an international dial code)
  36946. _isRegionlessNanp: function(number) {
  36947. var numeric = this._getNumeric(number);
  36948. if (numeric.charAt(0) == "1") {
  36949. var areaCode = numeric.substr(1, 3);
  36950. return $.inArray(areaCode, regionlessNanpNumbers) > -1;
  36951. }
  36952. return false;
  36953. },
  36954. // remove highlighting from other list items and highlight the given item
  36955. _highlightListItem: function(listItem) {
  36956. this.countryListItems.removeClass("highlight");
  36957. listItem.addClass("highlight");
  36958. },
  36959. // find the country data for the given country code
  36960. // the ignoreOnlyCountriesOption is only used during init() while parsing the onlyCountries array
  36961. _getCountryData: function(countryCode, ignoreOnlyCountriesOption, allowFail) {
  36962. var countryList = ignoreOnlyCountriesOption ? allCountries : this.countries;
  36963. for (var i = 0; i < countryList.length; i++) {
  36964. if (countryList[i].iso2 == countryCode) {
  36965. return countryList[i];
  36966. }
  36967. }
  36968. if (allowFail) {
  36969. return null;
  36970. } else {
  36971. throw new Error("No country data for '" + countryCode + "'");
  36972. }
  36973. },
  36974. // select the given flag, update the placeholder and the active list item
  36975. // Note: called from _setInitialState, _updateFlagFromNumber, _selectListItem, setCountry
  36976. _setFlag: function(countryCode) {
  36977. var prevCountry = this.selectedCountryData.iso2 ? this.selectedCountryData : {};
  36978. // do this first as it will throw an error and stop if countryCode is invalid
  36979. this.selectedCountryData = countryCode ? this._getCountryData(countryCode, false, false) : {};
  36980. // update the defaultCountry - we only need the iso2 from now on, so just store that
  36981. if (this.selectedCountryData.iso2) {
  36982. this.defaultCountry = this.selectedCountryData.iso2;
  36983. }
  36984. this.selectedFlagInner.attr("class", "iti-flag " + countryCode);
  36985. // update the selected country's title attribute
  36986. var title = countryCode ? this.selectedCountryData.name + ": +" + this.selectedCountryData.dialCode : "Unknown";
  36987. this.selectedFlagInner.parent().attr("title", title);
  36988. if (this.options.separateDialCode) {
  36989. var dialCode = this.selectedCountryData.dialCode ? "+" + this.selectedCountryData.dialCode : "", parent = this.telInput.parent();
  36990. if (prevCountry.dialCode) {
  36991. parent.removeClass("iti-sdc-" + (prevCountry.dialCode.length + 1));
  36992. }
  36993. if (dialCode) {
  36994. parent.addClass("iti-sdc-" + dialCode.length);
  36995. }
  36996. this.selectedDialCode.text(dialCode);
  36997. }
  36998. // and the input's placeholder
  36999. this._updatePlaceholder();
  37000. // update the active list item
  37001. this.countryListItems.removeClass("active");
  37002. if (countryCode) {
  37003. this.countryListItems.find(".iti-flag." + countryCode).first().closest(".country").addClass("active");
  37004. }
  37005. // return if the flag has changed or not
  37006. return prevCountry.iso2 !== countryCode;
  37007. },
  37008. // update the input placeholder to an example number from the currently selected country
  37009. _updatePlaceholder: function() {
  37010. var shouldSetPlaceholder = this.options.autoPlaceholder === "aggressive" || !this.hadInitialPlaceholder && (this.options.autoPlaceholder === true || this.options.autoPlaceholder === "polite");
  37011. if (window.intlTelInputUtils && shouldSetPlaceholder) {
  37012. var numberType = intlTelInputUtils.numberType[this.options.placeholderNumberType], placeholder = this.selectedCountryData.iso2 ? intlTelInputUtils.getExampleNumber(this.selectedCountryData.iso2, this.options.nationalMode, numberType) : "";
  37013. placeholder = this._beforeSetNumber(placeholder);
  37014. if (typeof this.options.customPlaceholder === "function") {
  37015. placeholder = this.options.customPlaceholder(placeholder, this.selectedCountryData);
  37016. }
  37017. this.telInput.attr("placeholder", placeholder);
  37018. }
  37019. },
  37020. // called when the user selects a list item from the dropdown
  37021. _selectListItem: function(listItem) {
  37022. // update selected flag and active list item
  37023. var flagChanged = this._setFlag(listItem.attr("data-country-code"));
  37024. this._closeDropdown();
  37025. this._updateDialCode(listItem.attr("data-dial-code"), true);
  37026. // focus the input
  37027. this.telInput.focus();
  37028. // put cursor at end - this fix is required for FF and IE11 (with nationalMode=false i.e. auto inserting dial code), who try to put the cursor at the beginning the first time
  37029. if (this.isGoodBrowser) {
  37030. var len = this.telInput.val().length;
  37031. this.telInput[0].setSelectionRange(len, len);
  37032. }
  37033. if (flagChanged) {
  37034. this._triggerCountryChange();
  37035. }
  37036. },
  37037. // close the dropdown and unbind any listeners
  37038. _closeDropdown: function() {
  37039. this.countryList.addClass("hide");
  37040. // update the arrow
  37041. this.selectedFlagInner.children(".iti-arrow").removeClass("up");
  37042. // unbind key events
  37043. $(document).off(this.ns);
  37044. // unbind click-off-to-close
  37045. $("html").off(this.ns);
  37046. // unbind hover and click listeners
  37047. this.countryList.off(this.ns);
  37048. // remove menu from container
  37049. if (this.options.dropdownContainer) {
  37050. if (!this.isMobile) {
  37051. $(window).off("scroll" + this.ns);
  37052. }
  37053. this.dropdown.detach();
  37054. }
  37055. this.telInput.trigger("close:countrydropdown");
  37056. },
  37057. // check if an element is visible within it's container, else scroll until it is
  37058. _scrollTo: function(element, middle) {
  37059. var container = this.countryList, containerHeight = container.height(), containerTop = container.offset().top, containerBottom = containerTop + containerHeight, elementHeight = element.outerHeight(), elementTop = element.offset().top, elementBottom = elementTop + elementHeight, newScrollTop = elementTop - containerTop + container.scrollTop(), middleOffset = containerHeight / 2 - elementHeight / 2;
  37060. if (elementTop < containerTop) {
  37061. // scroll up
  37062. if (middle) {
  37063. newScrollTop -= middleOffset;
  37064. }
  37065. container.scrollTop(newScrollTop);
  37066. } else if (elementBottom > containerBottom) {
  37067. // scroll down
  37068. if (middle) {
  37069. newScrollTop += middleOffset;
  37070. }
  37071. var heightDifference = containerHeight - elementHeight;
  37072. container.scrollTop(newScrollTop - heightDifference);
  37073. }
  37074. },
  37075. // replace any existing dial code with the new one
  37076. // Note: called from _selectListItem and setCountry
  37077. _updateDialCode: function(newDialCode, hasSelectedListItem) {
  37078. var inputVal = this.telInput.val(), newNumber;
  37079. // save having to pass this every time
  37080. newDialCode = "+" + newDialCode;
  37081. if (inputVal.charAt(0) == "+") {
  37082. // there's a plus so we're dealing with a replacement (doesn't matter if nationalMode or not)
  37083. var prevDialCode = this._getDialCode(inputVal);
  37084. if (prevDialCode) {
  37085. // current number contains a valid dial code, so replace it
  37086. newNumber = inputVal.replace(prevDialCode, newDialCode);
  37087. } else {
  37088. // current number contains an invalid dial code, so ditch it
  37089. // (no way to determine where the invalid dial code ends and the rest of the number begins)
  37090. newNumber = newDialCode;
  37091. }
  37092. } else if (this.options.nationalMode || this.options.separateDialCode) {
  37093. // don't do anything
  37094. return;
  37095. } else {
  37096. // nationalMode is disabled
  37097. if (inputVal) {
  37098. // there is an existing value with no dial code: prefix the new dial code
  37099. newNumber = newDialCode + inputVal;
  37100. } else if (hasSelectedListItem || !this.options.autoHideDialCode) {
  37101. // no existing value and either they've just selected a list item, or autoHideDialCode is disabled: insert new dial code
  37102. newNumber = newDialCode;
  37103. } else {
  37104. return;
  37105. }
  37106. }
  37107. this.telInput.val(newNumber);
  37108. },
  37109. // try and extract a valid international dial code from a full telephone number
  37110. // Note: returns the raw string inc plus character and any whitespace/dots etc
  37111. _getDialCode: function(number) {
  37112. var dialCode = "";
  37113. // only interested in international numbers (starting with a plus)
  37114. if (number.charAt(0) == "+") {
  37115. var numericChars = "";
  37116. // iterate over chars
  37117. for (var i = 0; i < number.length; i++) {
  37118. var c = number.charAt(i);
  37119. // if char is number
  37120. if ($.isNumeric(c)) {
  37121. numericChars += c;
  37122. // if current numericChars make a valid dial code
  37123. if (this.countryCodes[numericChars]) {
  37124. // store the actual raw string (useful for matching later)
  37125. dialCode = number.substr(0, i + 1);
  37126. }
  37127. // longest dial code is 4 chars
  37128. if (numericChars.length == 4) {
  37129. break;
  37130. }
  37131. }
  37132. }
  37133. }
  37134. return dialCode;
  37135. },
  37136. // get the input val, adding the dial code if separateDialCode is enabled
  37137. _getFullNumber: function() {
  37138. var val = $.trim(this.telInput.val()), dialCode = this.selectedCountryData.dialCode, prefix, numericVal = this._getNumeric(val), // normalized means ensure starts with a 1, so we can match against the full dial code
  37139. normalizedVal = numericVal.charAt(0) == "1" ? numericVal : "1" + numericVal;
  37140. if (this.options.separateDialCode) {
  37141. prefix = "+" + dialCode;
  37142. } else if (val.charAt(0) != "+" && val.charAt(0) != "1" && dialCode && dialCode.charAt(0) == "1" && dialCode.length == 4 && dialCode != normalizedVal.substr(0, 4)) {
  37143. // if the user has entered a national NANP number, then ensure it includes the full dial code / area code
  37144. prefix = dialCode.substr(1);
  37145. } else {
  37146. prefix = "";
  37147. }
  37148. return prefix + val;
  37149. },
  37150. // remove the dial code if separateDialCode is enabled
  37151. _beforeSetNumber: function(number) {
  37152. if (this.options.separateDialCode) {
  37153. var dialCode = this._getDialCode(number);
  37154. if (dialCode) {
  37155. // US dialCode is "+1", which is what we want
  37156. // CA dialCode is "+1 123", which is wrong - should be "+1" (as it has multiple area codes)
  37157. // AS dialCode is "+1 684", which is what we want
  37158. // Solution: if the country has area codes, then revert to just the dial code
  37159. if (this.selectedCountryData.areaCodes !== null) {
  37160. dialCode = "+" + this.selectedCountryData.dialCode;
  37161. }
  37162. // a lot of numbers will have a space separating the dial code and the main number, and some NANP numbers will have a hyphen e.g. +1 684-733-1234 - in both cases we want to get rid of it
  37163. // NOTE: don't just trim all non-numerics as may want to preserve an open parenthesis etc
  37164. var start = number[dialCode.length] === " " || number[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length;
  37165. number = number.substr(start);
  37166. }
  37167. }
  37168. return this._cap(number);
  37169. },
  37170. // trigger the 'countrychange' event
  37171. _triggerCountryChange: function() {
  37172. this.telInput.trigger("countrychange", this.selectedCountryData);
  37173. },
  37174. /**************************
  37175. * SECRET PUBLIC METHODS
  37176. **************************/
  37177. // this is called when the geoip call returns
  37178. handleAutoCountry: function() {
  37179. if (this.options.initialCountry === "auto") {
  37180. // we must set this even if there is an initial val in the input: in case the initial val is invalid and they delete it - they should see their auto country
  37181. this.defaultCountry = $.fn[pluginName].autoCountry;
  37182. // if there's no initial value in the input, then update the flag
  37183. if (!this.telInput.val()) {
  37184. this.setCountry(this.defaultCountry);
  37185. }
  37186. this.autoCountryDeferred.resolve();
  37187. }
  37188. },
  37189. // this is called when the utils request completes
  37190. handleUtils: function() {
  37191. // if the request was successful
  37192. if (window.intlTelInputUtils) {
  37193. // if there's an initial value in the input, then format it
  37194. if (this.telInput.val()) {
  37195. this._updateValFromNumber(this.telInput.val());
  37196. }
  37197. this._updatePlaceholder();
  37198. }
  37199. this.utilsScriptDeferred.resolve();
  37200. },
  37201. /********************
  37202. * PUBLIC METHODS
  37203. ********************/
  37204. // remove plugin
  37205. destroy: function() {
  37206. if (this.allowDropdown) {
  37207. // make sure the dropdown is closed (and unbind listeners)
  37208. this._closeDropdown();
  37209. // click event to open dropdown
  37210. this.selectedFlagInner.parent().off(this.ns);
  37211. // label click hack
  37212. this.telInput.closest("label").off(this.ns);
  37213. }
  37214. // unbind submit event handler on form
  37215. if (this.options.autoHideDialCode) {
  37216. var form = this.telInput.prop("form");
  37217. if (form) {
  37218. $(form).off(this.ns);
  37219. }
  37220. }
  37221. // unbind all events: key events, and focus/blur events if autoHideDialCode=true
  37222. this.telInput.off(this.ns);
  37223. // remove markup (but leave the original input)
  37224. var container = this.telInput.parent();
  37225. container.before(this.telInput).remove();
  37226. },
  37227. // get the extension from the current number
  37228. getExtension: function() {
  37229. if (window.intlTelInputUtils) {
  37230. return intlTelInputUtils.getExtension(this._getFullNumber(), this.selectedCountryData.iso2);
  37231. }
  37232. return "";
  37233. },
  37234. // format the number to the given format
  37235. getNumber: function(format) {
  37236. if (window.intlTelInputUtils) {
  37237. return intlTelInputUtils.formatNumber(this._getFullNumber(), this.selectedCountryData.iso2, format);
  37238. }
  37239. return "";
  37240. },
  37241. // get the type of the entered number e.g. landline/mobile
  37242. getNumberType: function() {
  37243. if (window.intlTelInputUtils) {
  37244. return intlTelInputUtils.getNumberType(this._getFullNumber(), this.selectedCountryData.iso2);
  37245. }
  37246. return -99;
  37247. },
  37248. // get the country data for the currently selected flag
  37249. getSelectedCountryData: function() {
  37250. return this.selectedCountryData;
  37251. },
  37252. // get the validation error
  37253. getValidationError: function() {
  37254. if (window.intlTelInputUtils) {
  37255. return intlTelInputUtils.getValidationError(this._getFullNumber(), this.selectedCountryData.iso2);
  37256. }
  37257. return -99;
  37258. },
  37259. // validate the input val - assumes the global function isValidNumber (from utilsScript)
  37260. isValidNumber: function() {
  37261. var val = $.trim(this._getFullNumber()), countryCode = this.options.nationalMode ? this.selectedCountryData.iso2 : "";
  37262. return window.intlTelInputUtils ? intlTelInputUtils.isValidNumber(val, countryCode) : null;
  37263. },
  37264. // update the selected flag, and update the input val accordingly
  37265. setCountry: function(countryCode) {
  37266. countryCode = countryCode.toLowerCase();
  37267. // check if already selected
  37268. if (!this.selectedFlagInner.hasClass(countryCode)) {
  37269. this._setFlag(countryCode);
  37270. this._updateDialCode(this.selectedCountryData.dialCode, false);
  37271. this._triggerCountryChange();
  37272. }
  37273. },
  37274. // set the input value and update the flag
  37275. setNumber: function(number) {
  37276. // we must update the flag first, which updates this.selectedCountryData, which is used for formatting the number before displaying it
  37277. var flagChanged = this._updateFlagFromNumber(number);
  37278. this._updateValFromNumber(number);
  37279. if (flagChanged) {
  37280. this._triggerCountryChange();
  37281. }
  37282. }
  37283. };
  37284. // using https://github.com/jquery-boilerplate/jquery-boilerplate/wiki/Extending-jQuery-Boilerplate
  37285. // (adapted to allow public functions)
  37286. $.fn[pluginName] = function(options) {
  37287. var args = arguments;
  37288. // Is the first parameter an object (options), or was omitted,
  37289. // instantiate a new instance of the plugin.
  37290. if (options === undefined || typeof options === "object") {
  37291. // collect all of the deferred objects for all instances created with this selector
  37292. var deferreds = [];
  37293. this.each(function() {
  37294. if (!$.data(this, "plugin_" + pluginName)) {
  37295. var instance = new Plugin(this, options);
  37296. var instanceDeferreds = instance._init();
  37297. // we now have 2 deffereds: 1 for auto country, 1 for utils script
  37298. deferreds.push(instanceDeferreds[0]);
  37299. deferreds.push(instanceDeferreds[1]);
  37300. $.data(this, "plugin_" + pluginName, instance);
  37301. }
  37302. });
  37303. // return the promise from the "master" deferred object that tracks all the others
  37304. return $.when.apply(null, deferreds);
  37305. } else if (typeof options === "string" && options[0] !== "_") {
  37306. // If the first parameter is a string and it doesn't start
  37307. // with an underscore or "contains" the `init`-function,
  37308. // treat this as a call to a public method.
  37309. // Cache the method call to make it possible to return a value
  37310. var returns;
  37311. this.each(function() {
  37312. var instance = $.data(this, "plugin_" + pluginName);
  37313. // Tests that there's already a plugin-instance
  37314. // and checks that the requested public method exists
  37315. if (instance instanceof Plugin && typeof instance[options] === "function") {
  37316. // Call the method of our plugin instance,
  37317. // and pass it the supplied arguments.
  37318. returns = instance[options].apply(instance, Array.prototype.slice.call(args, 1));
  37319. }
  37320. // Allow instances to be destroyed via the 'destroy' method
  37321. if (options === "destroy") {
  37322. $.data(this, "plugin_" + pluginName, null);
  37323. }
  37324. });
  37325. // If the earlier cached method gives a value back return the value,
  37326. // otherwise return this to preserve chainability.
  37327. return returns !== undefined ? returns : this;
  37328. }
  37329. };
  37330. /********************
  37331. * STATIC METHODS
  37332. ********************/
  37333. // get the country data object
  37334. $.fn[pluginName].getCountryData = function() {
  37335. return allCountries;
  37336. };
  37337. // load the utils script
  37338. $.fn[pluginName].loadUtils = function(path, utilsScriptDeferred) {
  37339. if (!$.fn[pluginName].loadedUtilsScript) {
  37340. // don't do this twice! (dont just check if window.intlTelInputUtils exists as if init plugin multiple times in quick succession, it may not have finished loading yet)
  37341. $.fn[pluginName].loadedUtilsScript = true;
  37342. // dont use $.getScript as it prevents caching
  37343. $.ajax({
  37344. type: "GET",
  37345. url: path,
  37346. complete: function() {
  37347. // tell all instances that the utils request is complete
  37348. $(".intl-tel-input input").intlTelInput("handleUtils");
  37349. },
  37350. dataType: "script",
  37351. cache: true
  37352. });
  37353. } else if (utilsScriptDeferred) {
  37354. utilsScriptDeferred.resolve();
  37355. }
  37356. };
  37357. // default options
  37358. $.fn[pluginName].defaults = defaults;
  37359. // version
  37360. $.fn[pluginName].version = "12.0.2";
  37361. // Array of country objects for the flag dropdown.
  37362. // Here is the criteria for the plugin to support a given country/territory
  37363. // - It has an iso2 code: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
  37364. // - It has it's own country calling code (it is not a sub-region of another country): https://en.wikipedia.org/wiki/List_of_country_calling_codes
  37365. // - It has a flag in the region-flags project: https://github.com/behdad/region-flags/tree/gh-pages/png
  37366. // - It is supported by libphonenumber (it must be listed on this page): https://github.com/googlei18n/libphonenumber/blob/master/resources/ShortNumberMetadata.xml
  37367. // Each country array has the following information:
  37368. // [
  37369. // Country name,
  37370. // iso2 code,
  37371. // International dial code,
  37372. // Order (if >1 country with same dial code),
  37373. // Area codes
  37374. // ]
  37375. var allCountries = [ [ "Afghanistan (‫افغانستان‬‎)", "af", "93" ], [ "Albania (Shqipëri)", "al", "355" ], [ "Algeria (‫الجزائر‬‎)", "dz", "213" ], [ "American Samoa", "as", "1684" ], [ "Andorra", "ad", "376" ], [ "Angola", "ao", "244" ], [ "Anguilla", "ai", "1264" ], [ "Antigua and Barbuda", "ag", "1268" ], [ "Argentina", "ar", "54" ], [ "Armenia (Հայաստան)", "am", "374" ], [ "Aruba", "aw", "297" ], [ "Australia", "au", "61", 0 ], [ "Austria (Österreich)", "at", "43" ], [ "Azerbaijan (Azərbaycan)", "az", "994" ], [ "Bahamas", "bs", "1242" ], [ "Bahrain (‫البحرين‬‎)", "bh", "973" ], [ "Bangladesh (বাংলাদেশ)", "bd", "880" ], [ "Barbados", "bb", "1246" ], [ "Belarus (Беларусь)", "by", "375" ], [ "Belgium (België)", "be", "32" ], [ "Belize", "bz", "501" ], [ "Benin (Bénin)", "bj", "229" ], [ "Bermuda", "bm", "1441" ], [ "Bhutan (འབྲུག)", "bt", "975" ], [ "Bolivia", "bo", "591" ], [ "Bosnia and Herzegovina (Босна и Херцеговина)", "ba", "387" ], [ "Botswana", "bw", "267" ], [ "Brazil (Brasil)", "br", "55" ], [ "British Indian Ocean Territory", "io", "246" ], [ "British Virgin Islands", "vg", "1284" ], [ "Brunei", "bn", "673" ], [ "Bulgaria (България)", "bg", "359" ], [ "Burkina Faso", "bf", "226" ], [ "Burundi (Uburundi)", "bi", "257" ], [ "Cambodia (កម្ពុជា)", "kh", "855" ], [ "Cameroon (Cameroun)", "cm", "237" ], [ "Canada", "ca", "1", 1, [ "204", "226", "236", "249", "250", "289", "306", "343", "365", "387", "403", "416", "418", "431", "437", "438", "450", "506", "514", "519", "548", "579", "581", "587", "604", "613", "639", "647", "672", "705", "709", "742", "778", "780", "782", "807", "819", "825", "867", "873", "902", "905" ] ], [ "Cape Verde (Kabu Verdi)", "cv", "238" ], [ "Caribbean Netherlands", "bq", "599", 1 ], [ "Cayman Islands", "ky", "1345" ], [ "Central African Republic (République centrafricaine)", "cf", "236" ], [ "Chad (Tchad)", "td", "235" ], [ "Chile", "cl", "56" ], [ "China (中国)", "cn", "86" ], [ "Christmas Island", "cx", "61", 2 ], [ "Cocos (Keeling) Islands", "cc", "61", 1 ], [ "Colombia", "co", "57" ], [ "Comoros (‫جزر القمر‬‎)", "km", "269" ], [ "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)", "cd", "243" ], [ "Congo (Republic) (Congo-Brazzaville)", "cg", "242" ], [ "Cook Islands", "ck", "682" ], [ "Costa Rica", "cr", "506" ], [ "Côte d’Ivoire", "ci", "225" ], [ "Croatia (Hrvatska)", "hr", "385" ], [ "Cuba", "cu", "53" ], [ "Curaçao", "cw", "599", 0 ], [ "Cyprus (Κύπρος)", "cy", "357" ], [ "Czech Republic (Česká republika)", "cz", "420" ], [ "Denmark (Danmark)", "dk", "45" ], [ "Djibouti", "dj", "253" ], [ "Dominica", "dm", "1767" ], [ "Dominican Republic (República Dominicana)", "do", "1", 2, [ "809", "829", "849" ] ], [ "Ecuador", "ec", "593" ], [ "Egypt (‫مصر‬‎)", "eg", "20" ], [ "El Salvador", "sv", "503" ], [ "Equatorial Guinea (Guinea Ecuatorial)", "gq", "240" ], [ "Eritrea", "er", "291" ], [ "Estonia (Eesti)", "ee", "372" ], [ "Ethiopia", "et", "251" ], [ "Falkland Islands (Islas Malvinas)", "fk", "500" ], [ "Faroe Islands (Føroyar)", "fo", "298" ], [ "Fiji", "fj", "679" ], [ "Finland (Suomi)", "fi", "358", 0 ], [ "France", "fr", "33" ], [ "French Guiana (Guyane française)", "gf", "594" ], [ "French Polynesia (Polynésie française)", "pf", "689" ], [ "Gabon", "ga", "241" ], [ "Gambia", "gm", "220" ], [ "Georgia (საქართველო)", "ge", "995" ], [ "Germany (Deutschland)", "de", "49" ], [ "Ghana (Gaana)", "gh", "233" ], [ "Gibraltar", "gi", "350" ], [ "Greece (Ελλάδα)", "gr", "30" ], [ "Greenland (Kalaallit Nunaat)", "gl", "299" ], [ "Grenada", "gd", "1473" ], [ "Guadeloupe", "gp", "590", 0 ], [ "Guam", "gu", "1671" ], [ "Guatemala", "gt", "502" ], [ "Guernsey", "gg", "44", 1 ], [ "Guinea (Guinée)", "gn", "224" ], [ "Guinea-Bissau (Guiné Bissau)", "gw", "245" ], [ "Guyana", "gy", "592" ], [ "Haiti", "ht", "509" ], [ "Honduras", "hn", "504" ], [ "Hong Kong (香港)", "hk", "852" ], [ "Hungary (Magyarország)", "hu", "36" ], [ "Iceland (Ísland)", "is", "354" ], [ "India (भारत)", "in", "91" ], [ "Indonesia", "id", "62" ], [ "Iran (‫ایران‬‎)", "ir", "98" ], [ "Iraq (‫العراق‬‎)", "iq", "964" ], [ "Ireland", "ie", "353" ], [ "Isle of Man", "im", "44", 2 ], [ "Israel (‫ישראל‬‎)", "il", "972" ], [ "Italy (Italia)", "it", "39", 0 ], [ "Jamaica", "jm", "1876" ], [ "Japan (日本)", "jp", "81" ], [ "Jersey", "je", "44", 3 ], [ "Jordan (‫الأردن‬‎)", "jo", "962" ], [ "Kazakhstan (Казахстан)", "kz", "7", 1 ], [ "Kenya", "ke", "254" ], [ "Kiribati", "ki", "686" ], [ "Kosovo", "xk", "383" ], [ "Kuwait (‫الكويت‬‎)", "kw", "965" ], [ "Kyrgyzstan (Кыргызстан)", "kg", "996" ], [ "Laos (ລາວ)", "la", "856" ], [ "Latvia (Latvija)", "lv", "371" ], [ "Lebanon (‫لبنان‬‎)", "lb", "961" ], [ "Lesotho", "ls", "266" ], [ "Liberia", "lr", "231" ], [ "Libya (‫ليبيا‬‎)", "ly", "218" ], [ "Liechtenstein", "li", "423" ], [ "Lithuania (Lietuva)", "lt", "370" ], [ "Luxembourg", "lu", "352" ], [ "Macau (澳門)", "mo", "853" ], [ "Macedonia (FYROM) (Македонија)", "mk", "389" ], [ "Madagascar (Madagasikara)", "mg", "261" ], [ "Malawi", "mw", "265" ], [ "Malaysia", "my", "60" ], [ "Maldives", "mv", "960" ], [ "Mali", "ml", "223" ], [ "Malta", "mt", "356" ], [ "Marshall Islands", "mh", "692" ], [ "Martinique", "mq", "596" ], [ "Mauritania (‫موريتانيا‬‎)", "mr", "222" ], [ "Mauritius (Moris)", "mu", "230" ], [ "Mayotte", "yt", "262", 1 ], [ "Mexico (México)", "mx", "52" ], [ "Micronesia", "fm", "691" ], [ "Moldova (Republica Moldova)", "md", "373" ], [ "Monaco", "mc", "377" ], [ "Mongolia (Монгол)", "mn", "976" ], [ "Montenegro (Crna Gora)", "me", "382" ], [ "Montserrat", "ms", "1664" ], [ "Morocco (‫المغرب‬‎)", "ma", "212", 0 ], [ "Mozambique (Moçambique)", "mz", "258" ], [ "Myanmar (Burma) (မြန်မာ)", "mm", "95" ], [ "Namibia (Namibië)", "na", "264" ], [ "Nauru", "nr", "674" ], [ "Nepal (नेपाल)", "np", "977" ], [ "Netherlands (Nederland)", "nl", "31" ], [ "New Caledonia (Nouvelle-Calédonie)", "nc", "687" ], [ "New Zealand", "nz", "64" ], [ "Nicaragua", "ni", "505" ], [ "Niger (Nijar)", "ne", "227" ], [ "Nigeria", "ng", "234" ], [ "Niue", "nu", "683" ], [ "Norfolk Island", "nf", "672" ], [ "North Korea (조선 민주주의 인민 공화국)", "kp", "850" ], [ "Northern Mariana Islands", "mp", "1670" ], [ "Norway (Norge)", "no", "47", 0 ], [ "Oman (‫عُمان‬‎)", "om", "968" ], [ "Pakistan (‫پاکستان‬‎)", "pk", "92" ], [ "Palau", "pw", "680" ], [ "Palestine (‫فلسطين‬‎)", "ps", "970" ], [ "Panama (Panamá)", "pa", "507" ], [ "Papua New Guinea", "pg", "675" ], [ "Paraguay", "py", "595" ], [ "Peru (Perú)", "pe", "51" ], [ "Philippines", "ph", "63" ], [ "Poland (Polska)", "pl", "48" ], [ "Portugal", "pt", "351" ], [ "Puerto Rico", "pr", "1", 3, [ "787", "939" ] ], [ "Qatar (‫قطر‬‎)", "qa", "974" ], [ "Réunion (La Réunion)", "re", "262", 0 ], [ "Romania (România)", "ro", "40" ], [ "Russia (Россия)", "ru", "7", 0 ], [ "Rwanda", "rw", "250" ], [ "Saint Barthélemy", "bl", "590", 1 ], [ "Saint Helena", "sh", "290" ], [ "Saint Kitts and Nevis", "kn", "1869" ], [ "Saint Lucia", "lc", "1758" ], [ "Saint Martin (Saint-Martin (partie française))", "mf", "590", 2 ], [ "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)", "pm", "508" ], [ "Saint Vincent and the Grenadines", "vc", "1784" ], [ "Samoa", "ws", "685" ], [ "San Marino", "sm", "378" ], [ "São Tomé and Príncipe (São Tomé e Príncipe)", "st", "239" ], [ "Saudi Arabia (‫المملكة العربية السعودية‬‎)", "sa", "966" ], [ "Senegal (Sénégal)", "sn", "221" ], [ "Serbia (Србија)", "rs", "381" ], [ "Seychelles", "sc", "248" ], [ "Sierra Leone", "sl", "232" ], [ "Singapore", "sg", "65" ], [ "Sint Maarten", "sx", "1721" ], [ "Slovakia (Slovensko)", "sk", "421" ], [ "Slovenia (Slovenija)", "si", "386" ], [ "Solomon Islands", "sb", "677" ], [ "Somalia (Soomaaliya)", "so", "252" ], [ "South Africa", "za", "27" ], [ "South Korea (대한민국)", "kr", "82" ], [ "South Sudan (‫جنوب السودان‬‎)", "ss", "211" ], [ "Spain (España)", "es", "34" ], [ "Sri Lanka (ශ්‍රී ලංකාව)", "lk", "94" ], [ "Sudan (‫السودان‬‎)", "sd", "249" ], [ "Suriname", "sr", "597" ], [ "Svalbard and Jan Mayen", "sj", "47", 1 ], [ "Swaziland", "sz", "268" ], [ "Sweden (Sverige)", "se", "46" ], [ "Switzerland (Schweiz)", "ch", "41" ], [ "Syria (‫سوريا‬‎)", "sy", "963" ], [ "Taiwan (台灣)", "tw", "886" ], [ "Tajikistan", "tj", "992" ], [ "Tanzania", "tz", "255" ], [ "Thailand (ไทย)", "th", "66" ], [ "Timor-Leste", "tl", "670" ], [ "Togo", "tg", "228" ], [ "Tokelau", "tk", "690" ], [ "Tonga", "to", "676" ], [ "Trinidad and Tobago", "tt", "1868" ], [ "Tunisia (‫تونس‬‎)", "tn", "216" ], [ "Turkey (Türkiye)", "tr", "90" ], [ "Turkmenistan", "tm", "993" ], [ "Turks and Caicos Islands", "tc", "1649" ], [ "Tuvalu", "tv", "688" ], [ "U.S. Virgin Islands", "vi", "1340" ], [ "Uganda", "ug", "256" ], [ "Ukraine (Україна)", "ua", "380" ], [ "United Arab Emirates (‫الإمارات العربية المتحدة‬‎)", "ae", "971" ], [ "United Kingdom", "gb", "44", 0 ], [ "United States", "us", "1", 0 ], [ "Uruguay", "uy", "598" ], [ "Uzbekistan (Oʻzbekiston)", "uz", "998" ], [ "Vanuatu", "vu", "678" ], [ "Vatican City (Città del Vaticano)", "va", "39", 1 ], [ "Venezuela", "ve", "58" ], [ "Vietnam (Việt Nam)", "vn", "84" ], [ "Wallis and Futuna (Wallis-et-Futuna)", "wf", "681" ], [ "Western Sahara (‫الصحراء الغربية‬‎)", "eh", "212", 1 ], [ "Yemen (‫اليمن‬‎)", "ye", "967" ], [ "Zambia", "zm", "260" ], [ "Zimbabwe", "zw", "263" ], [ "Åland Islands", "ax", "358", 1 ] ];
  37376. // loop over all of the countries above
  37377. for (var i = 0; i < allCountries.length; i++) {
  37378. var c = allCountries[i];
  37379. allCountries[i] = {
  37380. name: c[0],
  37381. iso2: c[1],
  37382. dialCode: c[2],
  37383. priority: c[3] || 0,
  37384. areaCodes: c[4] || null
  37385. };
  37386. }
  37387. });
  37388. (function(){for(var aa="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)},l="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this,m=["String","prototype","repeat"],n=0;n<m.length-1;n++){var p=m[n];p in l||(l[p]={});l=l[p]}
  37389. var ba=m[m.length-1],r=l[ba],t=r?r:function(a){var b;if(null==this)throw new TypeError("The 'this' value for String.prototype.repeat must not be null or undefined");b=this+"";if(0>a||1342177279<a)throw new RangeError("Invalid count value");a|=0;for(var c="";a;)if(a&1&&(c+=b),a>>>=1)b+=b;return c};t!=r&&null!=t&&aa(l,ba,{configurable:!0,writable:!0,value:t});var ca=this;function u(a){return"string"==typeof a}
  37390. function v(a,b){var c=a.split("."),d=ca;c[0]in d||!d.execScript||d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)c.length||void 0===b?d[e]?d=d[e]:d=d[e]={}:d[e]=b}function w(a,b){function c(){}c.prototype=b.prototype;a.aa=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.$=function(a,c,f){for(var d=Array(arguments.length-2),e=2;e<arguments.length;e++)d[e-2]=arguments[e];return b.prototype[c].apply(a,d)}};var x=Array.prototype.indexOf?function(a,b,c){return Array.prototype.indexOf.call(a,b,c)}:function(a,b,c){c=null==c?0:0>c?Math.max(0,a.length+c):c;if(u(a))return u(b)&&1==b.length?a.indexOf(b,c):-1;for(;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1};function y(a,b){a.sort(b||da)}function da(a,b){return a>b?1:a<b?-1:0};function ea(a){var b=[],c=0,d;for(d in a)b[c++]=a[d];return b};function fa(a,b){this.a=a;this.h=!!b.i;this.b=b.c;this.m=b.type;this.l=!1;switch(this.b){case ga:case ha:case ia:case ja:case ka:case la:case ma:this.l=!0}this.g=b.defaultValue}var ma=1,la=2,ga=3,ha=4,ia=6,ja=16,ka=18;function na(a,b){this.b=a;this.a={};for(var c=0;c<b.length;c++){var d=b[c];this.a[d.a]=d}}function oa(a){a=ea(a.a);y(a,function(a,c){return a.a-c.a});return a};function A(){this.a={};this.g=this.f().a;this.b=this.h=null}A.prototype.has=function(a){return null!=this.a[a.a]};A.prototype.get=function(a,b){return B(this,a.a,b)};A.prototype.set=function(a,b){C(this,a.a,b)};
  37391. function pa(a,b){for(var c=oa(a.f()),d=0;d<c.length;d++){var e=c[d],f=e.a;if(null!=b.a[f]){a.b&&delete a.b[e.a];var g=11==e.b||10==e.b;if(e.h)for(var e=D(b,f),h=0;h<e.length;h++){var k=a,q=f,z=g?e[h].clone():e[h];k.a[q]||(k.a[q]=[]);k.a[q].push(z);k.b&&delete k.b[q]}else e=E(b,f),g?(g=E(a,f))?pa(g,e):C(a,f,e.clone()):C(a,f,e)}}}A.prototype.clone=function(){var a=new this.constructor;a!=this&&(a.a={},a.b&&(a.b={}),pa(a,this));return a};
  37392. function E(a,b){var c=a.a[b];if(null==c)return null;if(a.h){if(!(b in a.b)){var d=a.h,e=a.g[b];if(null!=c)if(e.h){for(var f=[],g=0;g<c.length;g++)f[g]=d.a(e,c[g]);c=f}else c=d.a(e,c);return a.b[b]=c}return a.b[b]}return c}function B(a,b,c){var d=E(a,b);return a.g[b].h?d[c||0]:d}function F(a,b){var c;if(null!=a.a[b])c=B(a,b,void 0);else a:{c=a.g[b];if(void 0===c.g){var d=c.m;if(d===Boolean)c.g=!1;else if(d===Number)c.g=0;else if(d===String)c.g=c.l?"0":"";else{c=new d;break a}}c=c.g}return c}
  37393. function D(a,b){return E(a,b)||[]}function G(a,b){return a.g[b].h?null!=a.a[b]?a.a[b].length:0:null!=a.a[b]?1:0}function C(a,b,c){a.a[b]=c;a.b&&(a.b[b]=c)}function H(a,b){var c=[],d;for(d in b)0!=d&&c.push(new fa(d,b[d]));return new na(a,c)};function I(){}I.prototype.b=function(a){new a.b;throw Error("Unimplemented");};I.prototype.a=function(a,b){if(11==a.b||10==a.b)return b instanceof A?b:this.b(a.m.prototype.f(),b);if(14==a.b){if(u(b)&&qa.test(b)){var c=Number(b);if(0<c)return c}return b}if(!a.l)return b;c=a.m;if(c===String){if("number"==typeof b)return String(b)}else if(c===Number&&u(b)&&("Infinity"===b||"-Infinity"===b||"NaN"===b||qa.test(b)))return Number(b);return b};var qa=/^-?[0-9]+$/;function J(){}w(J,I);J.prototype.b=function(a,b){var c=new a.b;c.h=this;c.a=b;c.b={};return c};function ra(){}w(ra,J);ra.prototype.a=function(a,b){return 8==a.b?!!b:I.prototype.a.apply(this,arguments)};function K(a,b){null!=a&&this.a.apply(this,arguments)}K.prototype.b="";K.prototype.set=function(a){this.b=""+a};K.prototype.a=function(a,b,c){this.b+=String(a);if(null!=b)for(var d=1;d<arguments.length;d++)this.b+=arguments[d];return this};K.prototype.toString=function(){return this.b};/*
  37394. Protocol Buffer 2 Copyright 2008 Google Inc.
  37395. All other code copyright its respective owners.
  37396. Copyright (C) 2010 The Libphonenumber Authors
  37397. Licensed under the Apache License, Version 2.0 (the "License");
  37398. you may not use this file except in compliance with the License.
  37399. You may obtain a copy of the License at
  37400. http://www.apache.org/licenses/LICENSE-2.0
  37401. Unless required by applicable law or agreed to in writing, software
  37402. distributed under the License is distributed on an "AS IS" BASIS,
  37403. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  37404. See the License for the specific language governing permissions and
  37405. limitations under the License.
  37406. */
  37407. function L(){A.call(this)}w(L,A);var sa=null;function M(){A.call(this)}w(M,A);var ta=null;function N(){A.call(this)}w(N,A);var ua=null;
  37408. L.prototype.f=function(){var a=sa;a||(sa=a=H(L,{0:{name:"NumberFormat",j:"i18n.phonenumbers.NumberFormat"},1:{name:"pattern",required:!0,c:9,type:String},2:{name:"format",required:!0,c:9,type:String},3:{name:"leading_digits_pattern",i:!0,c:9,type:String},4:{name:"national_prefix_formatting_rule",c:9,type:String},6:{name:"national_prefix_optional_when_formatting",c:8,defaultValue:!1,type:Boolean},5:{name:"domestic_carrier_code_formatting_rule",c:9,type:String}}));return a};L.f=L.prototype.f;
  37409. M.prototype.f=function(){var a=ta;a||(ta=a=H(M,{0:{name:"PhoneNumberDesc",j:"i18n.phonenumbers.PhoneNumberDesc"},2:{name:"national_number_pattern",c:9,type:String},9:{name:"possible_length",i:!0,c:5,type:Number},10:{name:"possible_length_local_only",i:!0,c:5,type:Number},6:{name:"example_number",c:9,type:String}}));return a};M.f=M.prototype.f;
  37410. N.prototype.f=function(){var a=ua;a||(ua=a=H(N,{0:{name:"PhoneMetadata",j:"i18n.phonenumbers.PhoneMetadata"},1:{name:"general_desc",c:11,type:M},2:{name:"fixed_line",c:11,type:M},3:{name:"mobile",c:11,type:M},4:{name:"toll_free",c:11,type:M},5:{name:"premium_rate",c:11,type:M},6:{name:"shared_cost",c:11,type:M},7:{name:"personal_number",c:11,type:M},8:{name:"voip",c:11,type:M},21:{name:"pager",c:11,type:M},25:{name:"uan",c:11,type:M},27:{name:"emergency",c:11,type:M},28:{name:"voicemail",c:11,type:M},
  37411. 24:{name:"no_international_dialling",c:11,type:M},9:{name:"id",required:!0,c:9,type:String},10:{name:"country_code",c:5,type:Number},11:{name:"international_prefix",c:9,type:String},17:{name:"preferred_international_prefix",c:9,type:String},12:{name:"national_prefix",c:9,type:String},13:{name:"preferred_extn_prefix",c:9,type:String},15:{name:"national_prefix_for_parsing",c:9,type:String},16:{name:"national_prefix_transform_rule",c:9,type:String},18:{name:"same_mobile_and_fixed_line_pattern",c:8,defaultValue:!1,
  37412. type:Boolean},19:{name:"number_format",i:!0,c:11,type:L},20:{name:"intl_number_format",i:!0,c:11,type:L},22:{name:"main_country_for_code",c:8,defaultValue:!1,type:Boolean},23:{name:"leading_digits",c:9,type:String},26:{name:"leading_zero_possible",c:8,defaultValue:!1,type:Boolean}}));return a};N.f=N.prototype.f;function O(){A.call(this)}w(O,A);var va=null,wa={w:0,v:1,u:5,s:10,o:20};
  37413. O.prototype.f=function(){var a=va;a||(va=a=H(O,{0:{name:"PhoneNumber",j:"i18n.phonenumbers.PhoneNumber"},1:{name:"country_code",required:!0,c:5,type:Number},2:{name:"national_number",required:!0,c:4,type:Number},3:{name:"extension",c:9,type:String},4:{name:"italian_leading_zero",c:8,type:Boolean},8:{name:"number_of_leading_zeros",c:5,defaultValue:1,type:Number},5:{name:"raw_input",c:9,type:String},6:{name:"country_code_source",c:14,defaultValue:0,type:wa},7:{name:"preferred_domestic_carrier_code",
  37414. c:9,type:String}}));return a};O.ctor=O;O.ctor.f=O.prototype.f;/*
  37415. Copyright (C) 2010 The Libphonenumber Authors
  37416. Licensed under the Apache License, Version 2.0 (the "License");
  37417. you may not use this file except in compliance with the License.
  37418. You may obtain a copy of the License at
  37419. http://www.apache.org/licenses/LICENSE-2.0
  37420. Unless required by applicable law or agreed to in writing, software
  37421. distributed under the License is distributed on an "AS IS" BASIS,
  37422. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  37423. See the License for the specific language governing permissions and
  37424. limitations under the License.
  37425. */
  37426. var P={1:"US AG AI AS BB BM BS CA DM DO GD GU JM KN KY LC MP MS PR SX TC TT VC VG VI".split(" "),7:["RU","KZ"],20:["EG"],27:["ZA"],30:["GR"],31:["NL"],32:["BE"],33:["FR"],34:["ES"],36:["HU"],39:["IT","VA"],40:["RO"],41:["CH"],43:["AT"],44:["GB","GG","IM","JE"],45:["DK"],46:["SE"],47:["NO","SJ"],48:["PL"],49:["DE"],51:["PE"],52:["MX"],53:["CU"],54:["AR"],55:["BR"],56:["CL"],57:["CO"],58:["VE"],60:["MY"],61:["AU","CC","CX"],62:["ID"],63:["PH"],64:["NZ"],65:["SG"],66:["TH"],81:["JP"],82:["KR"],84:["VN"],
  37427. 86:["CN"],90:["TR"],91:["IN"],92:["PK"],93:["AF"],94:["LK"],95:["MM"],98:["IR"],211:["SS"],212:["MA","EH"],213:["DZ"],216:["TN"],218:["LY"],220:["GM"],221:["SN"],222:["MR"],223:["ML"],224:["GN"],225:["CI"],226:["BF"],227:["NE"],228:["TG"],229:["BJ"],230:["MU"],231:["LR"],232:["SL"],233:["GH"],234:["NG"],235:["TD"],236:["CF"],237:["CM"],238:["CV"],239:["ST"],240:["GQ"],241:["GA"],242:["CG"],243:["CD"],244:["AO"],245:["GW"],246:["IO"],247:["AC"],248:["SC"],249:["SD"],250:["RW"],251:["ET"],252:["SO"],
  37428. 253:["DJ"],254:["KE"],255:["TZ"],256:["UG"],257:["BI"],258:["MZ"],260:["ZM"],261:["MG"],262:["RE","YT"],263:["ZW"],264:["NA"],265:["MW"],266:["LS"],267:["BW"],268:["SZ"],269:["KM"],290:["SH","TA"],291:["ER"],297:["AW"],298:["FO"],299:["GL"],350:["GI"],351:["PT"],352:["LU"],353:["IE"],354:["IS"],355:["AL"],356:["MT"],357:["CY"],358:["FI","AX"],359:["BG"],370:["LT"],371:["LV"],372:["EE"],373:["MD"],374:["AM"],375:["BY"],376:["AD"],377:["MC"],378:["SM"],380:["UA"],381:["RS"],382:["ME"],385:["HR"],386:["SI"],
  37429. 387:["BA"],389:["MK"],420:["CZ"],421:["SK"],423:["LI"],500:["FK"],501:["BZ"],502:["GT"],503:["SV"],504:["HN"],505:["NI"],506:["CR"],507:["PA"],508:["PM"],509:["HT"],590:["GP","BL","MF"],591:["BO"],592:["GY"],593:["EC"],594:["GF"],595:["PY"],596:["MQ"],597:["SR"],598:["UY"],599:["CW","BQ"],670:["TL"],672:["NF"],673:["BN"],674:["NR"],675:["PG"],676:["TO"],677:["SB"],678:["VU"],679:["FJ"],680:["PW"],681:["WF"],682:["CK"],683:["NU"],685:["WS"],686:["KI"],687:["NC"],688:["TV"],689:["PF"],690:["TK"],691:["FM"],
  37430. 692:["MH"],800:["001"],808:["001"],850:["KP"],852:["HK"],853:["MO"],855:["KH"],856:["LA"],870:["001"],878:["001"],880:["BD"],881:["001"],882:["001"],883:["001"],886:["TW"],888:["001"],960:["MV"],961:["LB"],962:["JO"],963:["SY"],964:["IQ"],965:["KW"],966:["SA"],967:["YE"],968:["OM"],970:["PS"],971:["AE"],972:["IL"],973:["BH"],974:["QA"],975:["BT"],976:["MN"],977:["NP"],979:["001"],992:["TJ"],993:["TM"],994:["AZ"],995:["GE"],996:["KG"],998:["UZ"]},xa={AC:[,[,,"[46]\\d{4}|[01589]\\d{5}",,,,,,,[5,6]],
  37431. [,,"6[2-467]\\d{3}",,,,"62889",,,[5]],[,,"4\\d{4}",,,,"40123",,,[5]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"AC",247,"00",,,,,,,,,,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"[01589]\\d{5}",,,,"542011",,,[6]],,,[,,,,,,,,,[-1]]],AD:[,[,,"[16]\\d{5,8}|[37-9]\\d{5}",,,,,,,[6,8,9]],[,,"[78]\\d{5}",,,,"712345",,,[6]],[,,"(?:3\\d|6(?:[0-8]|90\\d{2}))\\d{4}",,,,"312345",,,[6,9]],[,,"180[02]\\d{4}",,,,"18001234",,,[8]],[,,"[19]\\d{5}",,,,"912345",,,[6]],[,,,,,,,,,[-1]],
  37432. [,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"AD",376,"00",,,,,,,,[[,"(\\d{3})(\\d{3})","$1 $2",["[137-9]|6[0-8]"]],[,"(\\d{4})(\\d{4})","$1 $2",["180","180[02]"]],[,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["690"]]],,[,,,,,,,,,[-1]],,,[,,"1800\\d{4}",,,,"18000000",,,[8]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],AE:[,[,,"[2-79]\\d{7,8}|800\\d{2,9}",,,,,,,[5,6,7,8,9,10,11,12]],[,,"[2-4679][2-8]\\d{6}",,,,"22345678",,,[8],[7]],[,,"5[024-68]\\d{7}",,,,"501234567",,,[9]],[,,"400\\d{6}|800\\d{2,9}",,,,"800123456"],[,,"900[02]\\d{5}",
  37433. ,,,"900234567",,,[9]],[,,"700[05]\\d{5}",,,,"700012345",,,[9]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"AE",971,"00","0",,,"0",,,,[[,"([2-4679])(\\d{3})(\\d{4})","$1 $2 $3",["[2-4679][2-8]"],"0$1"],[,"(5\\d)(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"],[,"([479]00)(\\d)(\\d{5})","$1 $2 $3",["[479]0"],"$1"],[,"([68]00)(\\d{2,9})","$1 $2",["60|8"],"$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"600[25]\\d{5}",,,,"600212345",,,[9]],,,[,,,,,,,,,[-1]]],AF:[,[,,"[2-7]\\d{8}",,,,,,,[9],[7]],[,,"(?:[25][0-8]|[34][0-4]|6[0-5])[2-9]\\d{6}",
  37434. ,,,"234567890",,,,[7]],[,,"7(?:[014-9]\\d|2[89]|30)\\d{6}",,,,"701234567"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"AF",93,"00","0",,,"0",,,,[[,"([2-7]\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],AG:[,[,,"[2589]\\d{9}",,,,,,,[10],[7]],[,,"268(?:4(?:6[0-38]|84)|56[0-2])\\d{4}",,,,"2684601234",,,,[7]],[,,"268(?:464|7(?:1[3-9]|2\\d|3[246]|64|7[0-689]|8[02-68]))\\d{4}",,,,"2684641234",,
  37435. ,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002123456"],[,,"900[2-9]\\d{6}",,,,"9002123456"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,"26848[01]\\d{4}",,,,"2684801234",,,,[7]],"AG",1,"011","1",,,"1",,,,,,[,,"26840[69]\\d{4}",,,,"2684061234",,,,[7]],,"268",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],AI:[,[,,"[2589]\\d{9}",,,,,,,[10],[7]],[,,"2644(?:6[12]|9[78])\\d{4}",,,,"2644612345",,,,[7]],[,,"264(?:235|476|5(?:3[6-9]|8[1-4])|7(?:29|72))\\d{4}",
  37436. ,,,"2642351234",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002123456"],[,,"900[2-9]\\d{6}",,,,"9002123456"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"AI",1,"011","1",,,"1",,,,,,[,,,,,,,,,[-1]],,"264",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],AL:[,[,,"[2-57]\\d{7}|6\\d{8}|8\\d{5,7}|9\\d{5}",,,,,,,[6,7,8,9],[5]],[,,"(?:2(?:1(?:0[2-9]|[1-9]\\d)|[247]\\d{2}|[35][2-9]\\d|[68](?:0[2-9]|[1-9]\\d)|9(?:[089][2-9]|[1-7]\\d))|3(?:1(?:[04-9][2-9]|[1-3]\\d)|[2-6]\\d{2}|[79](?:[09][2-9]|[1-8]\\d)|8(?:0[2-9]|[1-9]\\d))|4\\d{3}|5(?:1(?:[05-9][2-9]|[1-4]\\d)|[2-578]\\d{2}|6(?:[06-9][2-9]|[1-5]\\d)|9(?:[089][2-9]|[1-7]\\d))|8(?:[19](?:[06-9][2-9]|[1-5]\\d)|[2-6]\\d{2}|[78](?:[089][2-9]|[1-7]\\d)))\\d{4}",
  37437. ,,,"22345678",,,[8],[5,6,7]],[,,"6(?:[689][2-9]|7[2-6])\\d{6}",,,,"662123456",,,[9]],[,,"800\\d{4}",,,,"8001234",,,[7]],[,,"900[1-9]\\d{2}",,,,"900123",,,[6]],[,,"808[1-9]\\d{2}",,,,"808123",,,[6]],[,,"700[2-9]\\d{4}",,,,"70021234",,,[8]],[,,,,,,,,,[-1]],"AL",355,"00","0",,,"0",,,,[[,"(4)(\\d{3})(\\d{4})","$1 $2 $3",["4[0-6]"],"0$1"],[,"(6\\d)(\\d{3})(\\d{4})","$1 $2 $3",["6"],"0$1"],[,"(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2358][2-5]|4[7-9]"],"0$1"],[,"(\\d{3})(\\d{3,5})","$1 $2",["[235][16-9]|8[016-9]|[79]"],
  37438. "0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],AM:[,[,,"[1-9]\\d{7}",,,,,,,[8],[5,6]],[,,"(?:1[0-2]\\d|2(?:2[2-46]|3[1-8]|4[2-69]|5[2-7]|6[1-9]|8[1-7])|3[12]2|47\\d)\\d{5}",,,,"10123456",,,,[5,6]],[,,"(?:4[1349]|55|77|88|9[1-9])\\d{6}",,,,"77123456"],[,,"800\\d{5}",,,,"80012345"],[,,"90[016]\\d{5}",,,,"90012345"],[,,"80[1-4]\\d{5}",,,,"80112345"],[,,,,,,,,,[-1]],[,,"60(?:2[078]|[3-7]\\d|8[0-5])\\d{4}",,,,"60271234"],"AM",374,"00","0",,,"0",,,,[[,"(\\d{2})(\\d{6})","$1 $2",
  37439. ["1|47"],"(0$1)"],[,"(\\d{2})(\\d{6})","$1 $2",["4[1349]|[5-7]|88|9[1-9]"],"0$1"],[,"(\\d{3})(\\d{5})","$1 $2",["[23]"],"(0$1)"],[,"(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["8|90"],"0 $1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],AO:[,[,,"[29]\\d{8}",,,,,,,[9]],[,,"2\\d(?:[26-9]\\d|\\d[26-9])\\d{5}",,,,"222123456"],[,,"9[1-49]\\d{7}",,,,"923123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"AO",244,"00",,,,,,,,[[,"(\\d{3})(\\d{3})(\\d{3})",
  37440. "$1 $2 $3"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],AR:[,[,,"11\\d{8}|[2368]\\d{9}|9\\d{10}",,,,,,,[10,11],[6,7,8]],[,,"11\\d{8}|(?:2(?:2(?:[013]\\d|2[13-79]|4[1-6]|5[2457]|6[124-8]|7[1-4]|8[13-6]|9[1267])|3(?:1[467]|2[03-6]|3[13-8]|[49][2-6]|5[2-8]|[067]\\d)|4(?:7[3-8]|9\\d)|6(?:[01346]\\d|2[24-6]|5[15-8])|80\\d|9(?:[0124789]\\d|3[1-6]|5[234]|6[2-46]))|3(?:3(?:2[79]|6\\d|8[2578])|4(?:[78]\\d|0[0124-9]|[1-35]\\d|4[24-7]|6[02-9]|9[123678])|5(?:[138]\\d|2[1245]|4[1-9]|6[2-4]|7[1-6])|6[24]\\d|7(?:[0469]\\d|1[1568]|2[013-9]|3[145]|5[14-8]|7[2-57]|8[0-24-9])|8(?:[013578]\\d|2[15-7]|4[13-6]|6[1-357-9]|9[124]))|670\\d)\\d{6}",
  37441. ,,,"1123456789",,,[10],[6,7,8]],[,,"675\\d{7}|9(?:11[2-9]\\d{7}|(?:2(?:2[013]|3[067]|49|6[01346]|80|9[147-9])|3(?:36|4[12358]|5[138]|6[24]|7[069]|8[013578]))[2-9]\\d{6}|\\d{4}[2-9]\\d{5})",,,,"91123456789",,,,[6,7,8]],[,,"800\\d{7}",,,,"8001234567",,,[10]],[,,"60[04579]\\d{7}",,,,"6001234567",,,[10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"AR",54,"00","0",,,"0?(?:(11|2(?:2(?:02?|[13]|2[13-79]|4[1-6]|5[2457]|6[124-8]|7[1-4]|8[13-6]|9[1267])|3(?:02?|1[467]|2[03-6]|3[13-8]|[49][2-6]|5[2-8]|[67])|4(?:7[3-578]|9)|6(?:[0136]|2[24-6]|4[6-8]?|5[15-8])|80|9(?:0[1-3]|[19]|2\\d|3[1-6]|4[02568]?|5[2-4]|6[2-46]|72?|8[23]?))|3(?:3(?:2[79]|6|8[2578])|4(?:0[0-24-9]|[12]|3[5-8]?|4[24-7]|5[4-68]?|6[02-9]|7[126]|8[2379]?|9[1-36-8])|5(?:1|2[1245]|3[237]?|4[1-46-9]|6[2-4]|7[1-6]|8[2-5]?)|6[24]|7(?:[069]|1[1568]|2[15]|3[145]|4[13]|5[14-8]|7[2-57]|8[126])|8(?:[01]|2[15-7]|3[2578]?|4[13-6]|5[4-8]?|6[1-357-9]|7[36-8]?|8[5-8]?|9[124])))?15)?",
  37442. "9$1",,,[[,"([68]\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[68]"],"0$1"],[,"(\\d{2})(\\d{4})","$1-$2",["[2-9]"],"$1"],[,"(\\d{3})(\\d{4})","$1-$2",["[2-9]"],"$1"],[,"(\\d{4})(\\d{4})","$1-$2",["[2-9]"],"$1"],[,"(9)(11)(\\d{4})(\\d{4})","$2 15-$3-$4",["911"],"0$1"],[,"(9)(\\d{3})(\\d{3})(\\d{4})","$2 15-$3-$4",["9(?:2[234689]|3[3-8])","9(?:2(?:2[013]|3[067]|49|6[01346]|80|9[147-9])|3(?:36|4[1-358]|5[138]|6[24]|7[069]|8[013578]))","9(?:2(?:2(?:0[013-9]|[13])|3(?:0[013-9]|[67])|49|6(?:[0136]|4[0-59])|8|9(?:[19]|44|7[013-9]|8[14]))|3(?:36|4(?:[12]|3[456]|[58]4)|5(?:1|3[0-24-689]|8[46])|6|7[069]|8(?:[01]|34|[578][45])))",
  37443. "9(?:2(?:2(?:0[013-9]|[13])|3(?:0[013-9]|[67])|49|6(?:[0136]|4[0-59])|8|9(?:[19]|44|7[013-9]|8[14]))|3(?:36|4(?:[12]|3(?:4|5[014]|6[1239])|[58]4)|5(?:1|3[0-24-689]|8[46])|6|7[069]|8(?:[01]|34|[578][45])))"],"0$1"],[,"(9)(\\d{4})(\\d{2})(\\d{4})","$2 15-$3-$4",["9[23]"],"0$1"],[,"(11)(\\d{4})(\\d{4})","$1 $2-$3",["1"],"0$1",,1],[,"(\\d{3})(\\d{3})(\\d{4})","$1 $2-$3",["2(?:2[013]|3[067]|49|6[01346]|80|9[147-9])|3(?:36|4[1-358]|5[138]|6[24]|7[069]|8[013578])","2(?:2(?:0[013-9]|[13])|3(?:0[013-9]|[67])|49|6(?:[0136]|4[0-59])|8|9(?:[19]|44|7[013-9]|8[14]))|3(?:36|4(?:[12]|3[456]|[58]4)|5(?:1|3[0-24-689]|8[46])|6|7[069]|8(?:[01]|34|[578][45]))",
  37444. "2(?:2(?:0[013-9]|[13])|3(?:0[013-9]|[67])|49|6(?:[0136]|4[0-59])|8|9(?:[19]|44|7[013-9]|8[14]))|3(?:36|4(?:[12]|3(?:4|5[014]|6[1239])|[58]4)|5(?:1|3[0-24-689]|8[46])|6|7[069]|8(?:[01]|34|[578][45]))"],"0$1",,1],[,"(\\d{4})(\\d{2})(\\d{4})","$1 $2-$3",["[23]"],"0$1",,1],[,"(\\d{3})","$1",["1[012]|911"],"$1"]],[[,"([68]\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[68]"],"0$1"],[,"(9)(11)(\\d{4})(\\d{4})","$1 $2 $3-$4",["911"]],[,"(9)(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3-$4",["9(?:2[234689]|3[3-8])","9(?:2(?:2[013]|3[067]|49|6[01346]|80|9[147-9])|3(?:36|4[1-358]|5[138]|6[24]|7[069]|8[013578]))",
  37445. "9(?:2(?:2(?:0[013-9]|[13])|3(?:0[013-9]|[67])|49|6(?:[0136]|4[0-59])|8|9(?:[19]|44|7[013-9]|8[14]))|3(?:36|4(?:[12]|3[456]|[58]4)|5(?:1|3[0-24-689]|8[46])|6|7[069]|8(?:[01]|34|[578][45])))","9(?:2(?:2(?:0[013-9]|[13])|3(?:0[013-9]|[67])|49|6(?:[0136]|4[0-59])|8|9(?:[19]|44|7[013-9]|8[14]))|3(?:36|4(?:[12]|3(?:4|5[014]|6[1239])|[58]4)|5(?:1|3[0-24-689]|8[46])|6|7[069]|8(?:[01]|34|[578][45])))"]],[,"(9)(\\d{4})(\\d{2})(\\d{4})","$1 $2 $3-$4",["9[23]"]],[,"(11)(\\d{4})(\\d{4})","$1 $2-$3",["1"],"0$1",
  37446. ,1],[,"(\\d{3})(\\d{3})(\\d{4})","$1 $2-$3",["2(?:2[013]|3[067]|49|6[01346]|80|9[147-9])|3(?:36|4[1-358]|5[138]|6[24]|7[069]|8[013578])","2(?:2(?:0[013-9]|[13])|3(?:0[013-9]|[67])|49|6(?:[0136]|4[0-59])|8|9(?:[19]|44|7[013-9]|8[14]))|3(?:36|4(?:[12]|3[456]|[58]4)|5(?:1|3[0-24-689]|8[46])|6|7[069]|8(?:[01]|34|[578][45]))","2(?:2(?:0[013-9]|[13])|3(?:0[013-9]|[67])|49|6(?:[0136]|4[0-59])|8|9(?:[19]|44|7[013-9]|8[14]))|3(?:36|4(?:[12]|3(?:4|5[014]|6[1239])|[58]4)|5(?:1|3[0-24-689]|8[46])|6|7[069]|8(?:[01]|34|[578][45]))"],
  37447. "0$1",,1],[,"(\\d{4})(\\d{2})(\\d{4})","$1 $2-$3",["[23]"],"0$1",,1]],[,,,,,,,,,[-1]],,,[,,"810\\d{7}",,,,"8101234567",,,[10]],[,,"810\\d{7}",,,,"8101234567",,,[10]],,,[,,,,,,,,,[-1]]],AS:[,[,,"[5689]\\d{9}",,,,,,,[10],[7]],[,,"6846(?:22|33|44|55|77|88|9[19])\\d{4}",,,,"6846221234",,,,[7]],[,,"684(?:2(?:5[2468]|72)|7(?:3[13]|70))\\d{4}",,,,"6847331234",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002123456"],[,,"900[2-9]\\d{6}",,,,"9002123456"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",
  37448. ,,,"5002345678"],[,,,,,,,,,[-1]],"AS",1,"011","1",,,"1",,,,,,[,,,,,,,,,[-1]],,"684",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],AT:[,[,,"[1-9]\\d{3,12}",,,,,,,[4,5,6,7,8,9,10,11,12,13],[3]],[,,"1\\d{3,12}|(?:2(?:1[467]|2[13-8]|5[2357]|6[1-46-8]|7[1-8]|8[124-7]|9[1458])|3(?:1[1-8]|3[23568]|4[5-7]|5[1378]|6[1-38]|8[3-68])|4(?:2[1-8]|35|63|7[1368]|8[2457])|5(?:12|2[1-8]|3[357]|4[147]|5[12578]|6[37])|6(?:13|2[1-47]|4[1-35-8]|5[468]|62)|7(?:2[1-8]|3[25]|4[13478]|5[68]|6[16-8]|7[1-6]|9[45]))\\d{3,10}",
  37449. ,,,"1234567890",,,,[3]],[,,"6(?:5[0-3579]|6[013-9]|[7-9]\\d)\\d{4,10}",,,,"664123456",,,[7,8,9,10,11,12,13]],[,,"800\\d{6,10}",,,,"800123456",,,[9,10,11,12,13]],[,,"9(?:0[01]|3[019])\\d{6,10}",,,,"900123456",,,[9,10,11,12,13]],[,,"8(?:10\\d|2(?:[01]\\d|8\\d?))\\d{5,9}",,,,"810123456",,,[8,9,10,11,12,13]],[,,,,,,,,,[-1]],[,,"780\\d{6,10}",,,,"780123456",,,[9,10,11,12,13]],"AT",43,"00","0",,,"0",,,,[[,"(116\\d{3})","$1",["116"],"$1"],[,"(1)(\\d{3,12})","$1 $2",["1"],"0$1"],[,"(5\\d)(\\d{3,5})","$1 $2",
  37450. ["5[079]"],"0$1"],[,"(5\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["5[079]"],"0$1"],[,"(5\\d)(\\d{4})(\\d{4,7})","$1 $2 $3",["5[079]"],"0$1"],[,"(\\d{3})(\\d{3,10})","$1 $2",["316|46|51|732|6(?:5[0-3579]|[6-9])|7(?:[28]0)|[89]"],"0$1"],[,"(\\d{4})(\\d{3,9})","$1 $2",["2|3(?:1[1-578]|[3-8])|4[2378]|5[2-6]|6(?:[12]|4[1-9]|5[468])|7(?:2[1-8]|35|4[1-8]|[5-79])"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"5(?:(?:0[1-9]|17)\\d{2,10}|[79]\\d{3,11})|720\\d{6,10}",,,,"50123",,,[5,6,7,8,9,10,11,12,13]],,,[,,,,
  37451. ,,,,,[-1]]],AU:[,[,,"1\\d{4,9}|[2-578]\\d{8}",,,,,,,[5,6,7,8,9,10]],[,,"[237]\\d{8}|8(?:[6-8]\\d{3}|9(?:[02-9]\\d{2}|1(?:[0-57-9]\\d|6[0135-9])))\\d{4}",,,,"212345678",,,[9],[8]],[,,"14(?:5\\d|71)\\d{5}|4(?:[0-3]\\d|4[47-9]|5[0-25-9]|6[6-9]|7[02-9]|8[147-9]|9[017-9])\\d{6}",,,,"412345678",,,[9]],[,,"180(?:0\\d{3}|2)\\d{3}",,,,"1800123456",,,[7,10]],[,,"19(?:0[0126]\\d|[679])\\d{5}",,,,"1900123456",,,[8,10]],[,,"13(?:00\\d{3}|45[0-4]|\\d)\\d{3}",,,,"1300123456",,,[6,8,10]],[,,"500\\d{6}",,,,"500123456",
  37452. ,,[9]],[,,"550\\d{6}",,,,"550123456",,,[9]],"AU",61,"(?:14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011)|001[14-689]","0",,,"0",,"0011",,[[,"([2378])(\\d{4})(\\d{4})","$1 $2 $3",["[2378]"],"(0$1)"],[,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[45]|14"],"0$1"],[,"(16)(\\d{3,4})","$1 $2",["16"],"0$1"],[,"(16)(\\d{3})(\\d{2,4})","$1 $2 $3",["16"],"0$1"],[,"(1[389]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:[38]0|90)","1(?:[38]00|90)"],"$1"],[,"(180)(2\\d{3})","$1 $2",["180","1802"],"$1"],[,"(19\\d)(\\d{3})","$1 $2",
  37453. ["19[13]"],"$1"],[,"(19\\d{2})(\\d{4})","$1 $2",["19[679]"],"$1"],[,"(13)(\\d{2})(\\d{2})","$1 $2 $3",["13[1-9]"],"$1"]],,[,,"16\\d{3,7}",,,,"1612345",,,[5,6,7,8,9]],1,,[,,"1(?:3(?:00\\d{3}|45[0-4]|\\d)\\d{3}|80(?:0\\d{6}|2\\d{3}))",,,,"1300123456",,,[6,7,8,10]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],AW:[,[,,"[25-9]\\d{6}",,,,,,,[7]],[,,"5(?:2\\d|8[1-9])\\d{4}",,,,"5212345"],[,,"(?:5(?:6\\d|9[2-478])|6(?:[039]0|22|4[01]|6[0-2])|7[34]\\d|9(?:6[45]|9[4-8]))\\d{4}",,,,"5601234"],[,,"800\\d{4}",,,,"8001234"],
  37454. [,,"900\\d{4}",,,,"9001234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"28\\d{5}|501\\d{4}",,,,"5011234"],"AW",297,"00",,,,,,,,[[,"(\\d{3})(\\d{4})","$1 $2"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],AX:[,[,,"[15]\\d{6,9}|2\\d{4,9}|3\\d{5,9}|4\\d{7,10}|[67]\\d{7,9}|8\\d{7,8}",,,,,,,[5,6,7,8,9,10,11]],[,,"18[1-8]\\d{4,6}",,,,"181234567",,,[7,8,9]],[,,"4(?:[0-8]\\d{6,8}|9\\d{9})|50\\d{6,8}",,,,"412345678",,,[8,9,10,11]],[,,"800\\d{5,6}",,,,"800123456",,,[8,9]],[,,"[67]00\\d{5,6}",
  37455. ,,,"600123456",,,[8,9]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"AX",358,"00|99(?:[02469]|5(?:11|33|5[59]|88|9[09]))","0",,,"0",,"00",,,,[,,,,,,,,,[-1]],,,[,,"100\\d{4,6}|20(?:0\\d{4,6}|2[023]\\d{4,5}|9[89]\\d{1,6})|300\\d{3,7}|60(?:[12]\\d{5,6}|6\\d{7})|7(?:1\\d{7}|3\\d{8}|5[03-9]\\d{5,6})",,,,"1001234",,,[5,6,7,8,9,10]],[,,"10(?:0\\d{4,6}|[1-9]\\d{5,7})|2(?:0(?:0\\d{4,6}|[13-8]\\d{5,7}|2(?:[023]\\d{4,5}|[14-9]\\d{4,6})|9(?:[0-7]\\d{4,6}|[89]\\d{1,6}))|9\\d{5,8})|3(?:0(?:0\\d{3,7}|[1-57-9]\\d{5,7}|6(?:\\d{3}|\\d{5,7}))|93\\d{5,7})|60(?:[12]\\d{5,6}|6\\d{7})|7(?:1\\d{7}|3\\d{8}|5[03-9]\\d{5,6})",
  37456. ,,,"10112345",,,[5,6,7,8,9,10]],,,[,,,,,,,,,[-1]]],AZ:[,[,,"[1-9]\\d{8}",,,,,,,[9],[7]],[,,"(?:1[28]\\d{3}|2(?:02|1[24]|2[2-4]|33|[45]2|6[23])\\d{2}|365(?:[0-46-9]\\d|5[0-35-9]))\\d{4}",,,,"123123456",,,,[7]],[,,"(?:36554|(?:4[04]|5[015]|60|7[07])\\d{3})\\d{4}",,,,"401234567"],[,,"88\\d{7}",,,,"881234567"],[,,"900200\\d{3}",,,,"900200123"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"AZ",994,"00","0",,,"0",,,,[[,"(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["(?:1[28]|2(?:[45]2|[0-36])|365)"],
  37457. "(0$1)"],[,"(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[4-8]"],"0$1"],[,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["9"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],BA:[,[,,"[3-9]\\d{7,8}",,,,,,,[8,9],[6]],[,,"(?:[35]\\d|49)\\d{6}",,,,"30123456",,,[8],[6]],[,,"6(?:0(?:3\\d|40)|[1-356]\\d|44[0-6]|71[137])\\d{5}",,,,"61123456"],[,,"8[08]\\d{6}",,,,"80123456",,,[8]],[,,"9[0246]\\d{6}",,,,"90123456",,,[8]],[,,"8[12]\\d{6}",,,,"82123456",,,[8]],[,,,,,,,,,
  37458. [-1]],[,,,,,,,,,[-1]],"BA",387,"00","0",,,"0",,,,[[,"(\\d{2})(\\d{3})(\\d{3})","$1 $2-$3",["[3-5]"],"0$1"],[,"(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["6[1-356]|[7-9]"],"0$1"],[,"(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["6[047]"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"70[23]\\d{5}",,,,"70223456",,,[8]],,,[,,,,,,,,,[-1]]],BB:[,[,,"[2589]\\d{9}",,,,,,,[10],[7]],[,,"246(?:2(?:2[78]|7[0-4])|4(?:1[024-6]|2\\d|3[2-9])|5(?:20|[34]\\d|54|7[1-3])|6(?:2\\d|38)|7(?:37|57)|9(?:1[89]|63))\\d{4}",
  37459. ,,,"2464123456",,,,[7]],[,,"246(?:2(?:[356]\\d|4[0-57-9]|8[0-79])|45\\d|8(?:[2-5]\\d|83))\\d{4}",,,,"2462501234",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002123456"],[,,"900\\d{7}|246976\\d{4}",,,,"9002123456",,,,[7]],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,"24631\\d{5}",,,,"2463101234",,,,[7]],"BB",1,"011","1",,,"1",,,,,,[,,,,,,,,,[-1]],,"246",[,,,,,,,,,[-1]],[,,"246(?:292|367|4(?:1[7-9]|3[01]|44|67)|736)\\d{4}",,,,"2464301234",,,,[7]],,,[,,,,,
  37460. ,,,,[-1]]],BD:[,[,,"[2-79]\\d{5,9}|1\\d{9}|8[0-7]\\d{4,8}",,,,,,,[6,7,8,9,10]],[,,"2(?:[45]\\d{3}|7(?:1[0-267]|2[0-289]|3[0-29]|4[01]|5[1-3]|6[013]|7[0178]|91)|8(?:0[125]|[139][1-6]|2[0157-9]|41|6[1-35]|7[1-5]|8[1-8]|90)|9(?:0[0-2]|1[0-4]|2[568]|3[3-6]|5[5-7]|6[0167]|7[15]|8[0146-9]))\\d{4}|3(?:12?[5-7]\\d{2}|0(?:2(?:[025-79]\\d|[348]\\d{1,2})|3(?:[2-4]\\d|[56]\\d?))|2(?:1\\d{2}|2(?:[12]\\d|[35]\\d{1,2}|4\\d?))|3(?:1\\d{2}|2(?:[2356]\\d|4\\d{1,2}))|4(?:1\\d{2}|2(?:2\\d{1,2}|[47]|5\\d{2}))|5(?:1\\d{2}|29)|[67]1\\d{2}|8(?:1\\d{2}|2(?:2\\d{2}|3|4\\d)))\\d{3}|4(?:0(?:2(?:[09]\\d|7)|33\\d{2})|1\\d{3}|2(?:1\\d{2}|2(?:[25]\\d?|[348]\\d|[67]\\d{1,2}))|3(?:1\\d{2}(?:\\d{2})?|2(?:[045]\\d|[236-9]\\d{1,2})|32\\d{2})|4(?:[18]\\d{2}|2(?:[2-46]\\d{2}|3)|5[25]\\d{2})|5(?:1\\d{2}|2(?:3\\d|5))|6(?:[18]\\d{2}|2(?:3(?:\\d{2})?|[46]\\d{1,2}|5\\d{2}|7\\d)|5(?:3\\d?|4\\d|[57]\\d{1,2}|6\\d{2}|8))|71\\d{2}|8(?:[18]\\d{2}|23\\d{2}|54\\d{2})|9(?:[18]\\d{2}|2[2-5]\\d{2}|53\\d{1,2}))\\d{3}|5(?:02[03489]\\d{2}|1\\d{2}|2(?:1\\d{2}|2(?:2(?:\\d{2})?|[457]\\d{2}))|3(?:1\\d{2}|2(?:[37](?:\\d{2})?|[569]\\d{2}))|4(?:1\\d{2}|2[46]\\d{2})|5(?:1\\d{2}|26\\d{1,2})|6(?:[18]\\d{2}|2|53\\d{2})|7(?:1|24)\\d{2}|8(?:1|26)\\d{2}|91\\d{2})\\d{3}|6(?:0(?:1\\d{2}|2(?:3\\d{2}|4\\d{1,2}))|2(?:2[2-5]\\d{2}|5(?:[3-5]\\d{2}|7)|8\\d{2})|3(?:1|2[3478])\\d{2}|4(?:1|2[34])\\d{2}|5(?:1|2[47])\\d{2}|6(?:[18]\\d{2}|6(?:2(?:2\\d|[34]\\d{2})|5(?:[24]\\d{2}|3\\d|5\\d{1,2})))|72[2-5]\\d{2}|8(?:1\\d{2}|2[2-5]\\d{2})|9(?:1\\d{2}|2[2-6]\\d{2}))\\d{3}|7(?:(?:02|[3-589]1|6[12]|72[24])\\d{2}|21\\d{3}|32)\\d{3}|8(?:(?:4[12]|[5-7]2|1\\d?)|(?:0|3[12]|[5-7]1|217)\\d)\\d{4}|9(?:[35]1|(?:[024]2|81)\\d|(?:1|[24]1)\\d{2})\\d{3}",
  37461. ,,,"27111234",,,[6,7,8,9]],[,,"(?:1[13-9]\\d|(?:3[78]|44)[02-9]|6(?:44|6[02-9]))\\d{7}",,,,"1812345678",,,[10]],[,,"80[03]\\d{7}",,,,"8001234567",,,[10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"96(?:0[49]|1[0-4]|6[69])\\d{6}",,,,"9604123456",,,[10]],"BD",880,"00","0",,,"0",,,,[[,"(2)(\\d{7,8})","$1-$2",["2"],"0$1"],[,"(\\d{2})(\\d{4,6})","$1-$2",["[3-79]1"],"0$1"],[,"(\\d{4})(\\d{3,6})","$1-$2",["1|3(?:0|[2-58]2)|4(?:0|[25]2|3[23]|[4689][25])|5(?:[02-578]2|6[25])|6(?:[0347-9]2|[26][25])|7[02-9]2|8(?:[023][23]|[4-7]2)|9(?:[02][23]|[458]2|6[016])"],
  37462. "0$1"],[,"(\\d{3})(\\d{3,7})","$1-$2",["[3-79][2-9]|8"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],BE:[,[,,"[1-9]\\d{7,8}",,,,,,,[8,9]],[,,"(?:1[0-69]|[23][2-8]|4[23]|5\\d|6[013-57-9]|71|8[1-79]|9[2-4])\\d{6}|80[2-8]\\d{5}",,,,"12345678",,,[8]],[,,"4(?:6[0135-8]|[79]\\d|8[3-9])\\d{6}",,,,"470123456",,,[9]],[,,"800\\d{5}",,,,"80012345",,,[8]],[,,"(?:70[2-467]|90[0-79])\\d{5}",,,,"90123456",,,[8]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"BE",32,"00","0",,,
  37463. "0",,,,[[,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4[6-9]"],"0$1"],[,"(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[23]|4[23]|9[2-4]"],"0$1"],[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[156]|7[018]|8(?:0[1-9]|[1-79])"],"0$1"],[,"(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:80|9)0"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"78\\d{6}",,,,"78123456",,,[8]],,,[,,,,,,,,,[-1]]],BF:[,[,,"[25-7]\\d{7}",,,,,,,[8]],[,,"2(?:0(?:49|5[23]|6[56]|9[016-9])|4(?:4[569]|5[4-6]|6[56]|7[0179])|5(?:[34]\\d|50|6[5-7]))\\d{4}",
  37464. ,,,"20491234"],[,,"(?:5[15-8]|[67]\\d)\\d{6}",,,,"70123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"BF",226,"00",,,,,,,,[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],BG:[,[,,"[23567]\\d{5,7}|[489]\\d{6,8}",,,,,,,[6,7,8,9],[4,5]],[,,"2\\d{5,7}|(?:[36]\\d|5[1-9]|8[1-6]|9[1-7])\\d{5,6}|(?:4(?:[124-7]\\d|3[1-6])|7(?:0[1-9]|[1-9]\\d))\\d{4,5}",,,,"2123456",,,[6,7,8],[4,5]],[,,"(?:8[7-9]\\d|9(?:8\\d|9[69]))\\d{6}|4(?:3[0789]|8\\d)\\d{5}",
  37465. ,,,"48123456",,,[8,9]],[,,"800\\d{5}",,,,"80012345",,,[8]],[,,"90\\d{6}",,,,"90123456",,,[8]],[,,,,,,,,,[-1]],[,,"700\\d{5}",,,,"70012345",,,[8]],[,,,,,,,,,[-1]],"BG",359,"00","0",,,"0",,,,[[,"(2)(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["2"],"0$1"],[,"(2)(\\d{3})(\\d{3,4})","$1 $2 $3",["2"],"0$1"],[,"(\\d{3})(\\d{4})","$1 $2",["43[124-7]|70[1-9]"],"0$1"],[,"(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3",["43[124-7]|70[1-9]"],"0$1"],[,"(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[78]00"],"0$1"],[,"(\\d{3})(\\d{3})(\\d{3})",
  37466. "$1 $2 $3",["99[69]"],"0$1"],[,"(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["[356]|4[124-7]|7[1-9]|8[1-6]|9[1-7]"],"0$1"],[,"(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["48|8[7-9]|9[08]"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],BH:[,[,,"[136-9]\\d{7}",,,,,,,[8]],[,,"(?:1(?:3[1356]|6[0156]|7\\d)\\d|6(?:1[16]\\d|500|6(?:0\\d|3[12]|44|7[7-9])|9[69][69])|7(?:1(?:11|78)|7\\d{2}))\\d{4}",,,,"17001234"],[,,"(?:3(?:[1-4679]\\d|5[013-69]|8[0-47-9])\\d|6(?:3(?:00|33|6[16])|6(?:[69]\\d|3[03-9]|7[0-6])))\\d{4}",
  37467. ,,,"36001234"],[,,"80\\d{6}",,,,"80123456"],[,,"(?:87|9[014578])\\d{6}",,,,"90123456"],[,,"84\\d{6}",,,,"84123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"BH",973,"00",,,,,,,,[[,"(\\d{4})(\\d{4})","$1 $2"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],BI:[,[,,"[267]\\d{7}",,,,,,,[8]],[,,"22\\d{6}",,,,"22201234"],[,,"(?:29|6[189]|7[124-9])\\d{6}",,,,"79561234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"BI",257,"00",,,,,,,,[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})",
  37468. "$1 $2 $3 $4"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],BJ:[,[,,"[2689]\\d{7}",,,,,,,[8]],[,,"2(?:02|1[037]|2[45]|3[68])\\d{5}",,,,"20211234"],[,,"(?:6[1-8]|9[03-9])\\d{6}",,,,"90011234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"857[58]\\d{4}",,,,"85751234"],"BJ",229,"00",,,,,,,,[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2689]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"81\\d{6}",,,,"81123456"],,,[,,,,,,,,,[-1]]],BL:[,[,,"[56]\\d{8}",
  37469. ,,,,,,[9]],[,,"590(?:2[7-9]|5[12]|87)\\d{4}",,,,"590271234"],[,,"690(?:0[05-9]|[1-9]\\d)\\d{4}",,,,"690001234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"BL",590,"00","0",,,"0",,,,,,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],BM:[,[,,"[4589]\\d{9}",,,,,,,[10],[7]],[,,"441(?:2(?:02|23|61|[3479]\\d)|[46]\\d{2}|5(?:4\\d|60|89)|824)\\d{4}",,,,"4412345678",,,,[7]],[,,"441(?:[37]\\d|5[0-39])\\d{5}",,,,"4413701234",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",
  37470. ,,,"8002123456"],[,,"900[2-9]\\d{6}",,,,"9002123456"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"BM",1,"011","1",,,"1",,,,,,[,,,,,,,,,[-1]],,"441",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],BN:[,[,,"[2-578]\\d{6}",,,,,,,[7]],[,,"2(?:[013-9]\\d|2[0-7])\\d{4}|[3-5]\\d{6}",,,,"2345678"],[,,"22[89]\\d{4}|[78]\\d{6}",,,,"7123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"BN",673,"00",,,,,,,,[[,"([2-578]\\d{2})(\\d{4})",
  37471. "$1 $2"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],BO:[,[,,"[23467]\\d{7}|8\\d{8}",,,,,,,[8,9],[7]],[,,"(?:2(?:2\\d{2}|5(?:11|[258]\\d|9[67])|6(?:12|2\\d|9[34])|8(?:2[34]|39|62))|3(?:3\\d{2}|4(?:6\\d|8[24])|8(?:25|42|5[257]|86|9[25])|9(?:2\\d|3[234]|4[248]|5[24]|6[2-6]|7\\d))|4(?:4\\d{2}|6(?:11|[24689]\\d|72)))\\d{4}",,,,"22123456",,,[8],[7]],[,,"[67]\\d{7}",,,,"71234567",,,[8]],[,,"80017\\d{4}",,,,"800171234",,,[9]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,
  37472. ,,,,,,,[-1]],"BO",591,"00(1\\d)?","0",,,"0(1\\d)?",,,,[[,"([234])(\\d{7})","$1 $2",["[234]"],,"0$CC $1"],[,"([67]\\d{7})","$1",["[67]"],,"0$CC $1"],[,"(800)(\\d{2})(\\d{4})","$1 $2 $3",["800"],,"0$CC $1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],BQ:[,[,,"[347]\\d{6}",,,,,,,[7]],[,,"(?:318[023]|41(?:6[023]|70)|7(?:1[578]|50)\\d)\\d{3}",,,,"7151234"],[,,"(?:31(?:8[14-8]|9[14578])|416[145-9]|7(?:0[01]|7[07]|8\\d|9[056])\\d)\\d{3}",,,,"3181234"],[,,,,,,,,,[-1]],[,,,,,,,,
  37473. ,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"BQ",599,"00",,,,,,,,,,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],BR:[,[,,"[1-46-9]\\d{7,10}|5(?:[0-4]\\d{7,9}|5(?:[2-8]\\d{7}|9\\d{7,8}))",,,,,,,[8,9,10,11]],[,,"(?:[14689][1-9]|2[12478]|3[1-578]|5[13-5]|7[13-579])[2-5]\\d{7}",,,,"1123456789",,,[10],[8]],[,,"(?:[189][1-9]|2[12478])(?:7|9\\d)\\d{7}|(?:3[1-578]|[46][1-9]|5[13-5]|7[13-579])(?:[6-8]|9\\d?)\\d{7}",,,,"11961234567",,,[10,11],[8]],[,,"800\\d{6,7}",,,,"800123456",
  37474. ,,[9,10]],[,,"(?:300|[59]00\\d?)\\d{6}",,,,"300123456",,,[9,10]],[,,"(?:300\\d(?:\\d{2})?|40(?:0\\d|20))\\d{4}",,,,"40041234",,,[8,10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"BR",55,"00(?:1[245]|2[1-35]|31|4[13]|[56]5|99)","0",,,"0(?:(1[245]|2[1-35]|31|4[13]|[56]5|99)(\\d{10,11}))?","$2",,,[[,"(\\d{4})(\\d{4})","$1-$2",["(?:300|40[02])","(?:300|40(?:0|20))"]],[,"([3589]00)(\\d{2,3})(\\d{4})","$1 $2 $3",["[3589]00"],"0$1"],[,"(\\d{3,5})","$1",["1[125689]"],"$1"],[,"(\\d{4})(\\d{4})","$1-$2",["[2-9](?:[1-9]|0[1-9])"],
  37475. "$1"],[,"(\\d{5})(\\d{4})","$1-$2",["9(?:[1-9]|0[1-9])"],"$1"],[,"(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["[1-9][1-9]"],"($1)","0 $CC ($1)"],[,"(\\d{2})(\\d{5})(\\d{4})","$1 $2-$3",["[1-9][1-9]9"],"($1)","0 $CC ($1)"]],[[,"(\\d{4})(\\d{4})","$1-$2",["(?:300|40[02])","(?:300|40(?:0|20))"]],[,"([3589]00)(\\d{2,3})(\\d{4})","$1 $2 $3",["[3589]00"],"0$1"],[,"(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["[1-9][1-9]"],"($1)","0 $CC ($1)"],[,"(\\d{2})(\\d{5})(\\d{4})","$1 $2-$3",["[1-9][1-9]9"],"($1)","0 $CC ($1)"]],
  37476. [,,,,,,,,,[-1]],,,[,,"(?:300\\d|40(?:0\\d|20))\\d{4}",,,,"40041234",,,[8]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],BS:[,[,,"[2589]\\d{9}",,,,,,,[10],[7]],[,,"242(?:3(?:02|[236][1-9]|4[0-24-9]|5[0-68]|7[3467]|8[0-4]|9[2-467])|461|502|6(?:0[1-3]|12|7[67]|8[78]|9[89])|7(?:02|88))\\d{4}",,,,"2423456789",,,,[7]],[,,"242(?:3(?:5[79]|[79]5)|4(?:[2-4][1-9]|5[1-8]|6[2-8]|7\\d|81)|5(?:2[45]|3[35]|44|5[1-9]|65|77)|6[34]6|7(?:27|38)|8(?:0[1-9]|1[02-9]|2\\d|99))\\d{4}",,,,"2423591234",,,,[7]],[,,"242300\\d{4}|8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",
  37477. ,,,"8002123456",,,,[7]],[,,"900[2-9]\\d{6}",,,,"9002123456"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"BS",1,"011","1",,,"1",,,,,,[,,,,,,,,,[-1]],,"242",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],BT:[,[,,"[1-8]\\d{6,7}",,,,,,,[7,8],[6]],[,,"(?:2[3-6]|[34][5-7]|5[236]|6[2-46]|7[246]|8[2-4])\\d{5}",,,,"2345678",,,[7],[6]],[,,"(?:1[67]|77)\\d{6}",,,,"17123456",,,[8]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],
  37478. "BT",975,"00",,,,,,,,[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1|77"]],[,"([2-8])(\\d{3})(\\d{3})","$1 $2 $3",["[2-68]|7[246]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],BW:[,[,,"[2-79]\\d{6,7}",,,,,,,[7,8]],[,,"(?:2(?:4[0-48]|6[0-24]|9[0578])|3(?:1[0-35-9]|55|[69]\\d|7[01])|4(?:6[03]|7[1267]|9[0-5])|5(?:3[0389]|4[0489]|7[1-47]|88|9[0-49])|6(?:2[1-35]|5[149]|8[067]))\\d{4}",,,,"2401234",,,[7]],[,,"7(?:[1-6]\\d|7[014-8])\\d{5}",,,,"71123456",,,[8]],[,,,,,,
  37479. ,,,[-1]],[,,"90\\d{5}",,,,"9012345",,,[7]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"79[12][01]\\d{4}",,,,"79101234",,,[8]],"BW",267,"00",,,,,,,,[[,"(\\d{3})(\\d{4})","$1 $2",["[2-6]"]],[,"(7\\d)(\\d{3})(\\d{3})","$1 $2 $3",["7"]],[,"(90)(\\d{5})","$1 $2",["9"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],BY:[,[,,"[1-4]\\d{8}|800\\d{3,7}|[89]\\d{9,10}",,,,,,,[6,7,8,9,10,11],[5]],[,,"(?:1(?:5(?:1[1-5]|[24]\\d|6[2-4]|9[1-7])|6(?:[235]\\d|4[1-7])|7\\d{2})|2(?:1(?:[246]\\d|3[0-35-9]|5[1-9])|2(?:[235]\\d|4[0-8])|3(?:[26]\\d|3[02-79]|4[024-7]|5[03-7])))\\d{5}",
  37480. ,,,"152450911",,,[9],[5,6,7]],[,,"(?:2(?:5[5679]|9[1-9])|33\\d|44\\d)\\d{6}",,,,"294911911",,,[9]],[,,"8(?:0[13]|20\\d)\\d{7}|800\\d{3,7}",,,,"8011234567"],[,,"(?:810|902)\\d{7}",,,,"9021234567",,,[10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"249\\d{6}",,,,"249123456",,,[9]],"BY",375,"810","8",,,"8?0?",,"8~10",,[[,"(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["17[0-3589]|2[4-9]|[34]","17(?:[02358]|1[0-2]|9[0189])|2[4-9]|[34]"],"8 0$1"],[,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["1(?:5[24]|6[235]|7[467])|2(?:1[246]|2[25]|3[26])",
  37481. "1(?:5[24]|6(?:2|3[04-9]|5[0346-9])|7(?:[46]|7[37-9]))|2(?:1[246]|2[25]|3[26])"],"8 0$1"],[,"(\\d{4})(\\d{2})(\\d{3})","$1 $2-$3",["1(?:5[169]|6[3-5]|7[179])|2(?:1[35]|2[34]|3[3-5])","1(?:5[169]|6(?:3[1-3]|4|5[125])|7(?:1[3-9]|7[0-24-6]|9[2-7]))|2(?:1[35]|2[34]|3[3-5])"],"8 0$1"],[,"([89]\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["8[01]|9"],"8 $1"],[,"(82\\d)(\\d{4})(\\d{4})","$1 $2 $3",["82"],"8 $1"],[,"(800)(\\d{3})","$1 $2",["800"],"8 $1"],[,"(800)(\\d{2})(\\d{2,4})","$1 $2 $3",["800"],"8 $1"]],,[,,
  37482. ,,,,,,,[-1]],,,[,,"8(?:0[13]|10|20\\d)\\d{7}|800\\d{3,7}|902\\d{7}",,,,"82012345678"],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],BZ:[,[,,"[2-8]\\d{6}|0\\d{10}",,,,,,,[7,11]],[,,"(?:2(?:[02]\\d|36)|[3-58][02]\\d|7(?:[02]\\d|32))\\d{4}",,,,"2221234",,,[7]],[,,"6[0-35-7]\\d{5}",,,,"6221234",,,[7]],[,,"0800\\d{7}",,,,"08001234123",,,[11]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"BZ",501,"00",,,,,,,,[[,"(\\d{3})(\\d{4})","$1-$2",["[2-8]"]],[,"(0)(800)(\\d{4})(\\d{3})","$1-$2-$3-$4",["0"]]],
  37483. ,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],CA:[,[,,"[2-9]\\d{9}|3\\d{6}",,,,,,,[7,10]],[,,"(?:2(?:04|[23]6|[48]9|50)|3(?:06|43|65)|4(?:03|1[68]|3[178]|50)|5(?:06|1[49]|48|79|8[17])|6(?:0[04]|13|22|39|47)|7(?:0[59]|78|8[02])|8(?:[06]7|19|25|73)|90[25])[2-9]\\d{6}|310\\d{4}",,,,"2042345678",,,[10],[7]],[,,"(?:2(?:04|[23]6|[48]9|50)|3(?:06|43|65)|4(?:03|1[68]|3[178]|50)|5(?:06|1[49]|48|79|8[17])|6(?:0[04]|13|22|39|47)|7(?:0[59]|78|8[02])|8(?:[06]7|19|25|73)|90[25])[2-9]\\d{6}",
  37484. ,,,"2042345678",,,[10],[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}|310\\d{4}",,,,"8002123456"],[,,"900[2-9]\\d{6}",,,,"9002123456",,,[10]],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678",,,[10]],[,,,,,,,,,[-1]],"CA",1,"011","1",,,"1",,,,,,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],CC:[,[,,"[1458]\\d{5,9}",,,,,,,[6,7,9,10],[8]],[,,"89162\\d{4}",,,,"891621234",,,[9],[8]],[,,"14(?:5\\d|71)\\d{5}|4(?:[0-2]\\d|3[0-57-9]|4[47-9]|5[0-25-9]|6[6-9]|7[02-9]|8[147-9]|9[017-9])\\d{6}",
  37485. ,,,"412345678",,,[9]],[,,"180(?:0\\d{3}|2)\\d{3}",,,,"1800123456",,,[7,10]],[,,"190[0126]\\d{6}",,,,"1900123456",,,[10]],[,,"13(?:00\\d{2})?\\d{4}",,,,"1300123456",,,[6,10]],[,,"500\\d{6}",,,,"500123456",,,[9]],[,,"550\\d{6}",,,,"550123456",,,[9]],"CC",61,"(?:14(?:1[14]|34|4[17]|[56]6|7[47]|88))?001[14-689]","0",,,"0",,"0011",,,,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],CD:[,[,,"[2-6]\\d{6}|[18]\\d{6,8}|9\\d{8}",,,,,,,[7,9]],[,,"1(?:2\\d{7}|\\d{6})|[2-6]\\d{6}",,,,"1234567"],
  37486. [,,"8(?:[0-2459]\\d{2}|8)\\d{5}|9[017-9]\\d{7}",,,,"991234567"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"CD",243,"00","0",,,"0",,,,[[,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["12"],"0$1"],[,"([89]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["8[0-2459]|9"],"0$1"],[,"(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["88"],"0$1"],[,"(\\d{2})(\\d{5})","$1 $2",["[1-6]"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],CF:[,[,,"[278]\\d{7}",,,,,,,[8]],[,,"2[12]\\d{6}",
  37487. ,,,"21612345"],[,,"7[0257]\\d{6}",,,,"70012345"],[,,,,,,,,,[-1]],[,,"8776\\d{4}",,,,"87761234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"CF",236,"00",,,,,,,,[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],CG:[,[,,"[028]\\d{8}",,,,,,,[9]],[,,"222[1-589]\\d{5}",,,,"222123456"],[,,"0[14-6]\\d{7}",,,,"061234567"],[,,,,,,,,,[-1]],[,,"80(?:0\\d{2}|11[01])\\d{4}",,,,"800123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,
  37488. [-1]],"CG",242,"00",,,,,,,,[[,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["801"]],[,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[02]"]],[,"(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["800"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],CH:[,[,,"[2-9]\\d{8}|860\\d{9}",,,,,,,[9,12]],[,,"(?:2[12467]|3[1-4]|4[134]|5[256]|6[12]|[7-9]1)\\d{7}",,,,"212345678",,,[9]],[,,"7[5-9]\\d{7}",,,,"781234567",,,[9]],[,,"800\\d{6}",,,,"800123456",,,[9]],[,,"90[016]\\d{6}",,,,"900123456",,,[9]],[,
  37489. ,"84[0248]\\d{6}",,,,"840123456",,,[9]],[,,"878\\d{6}",,,,"878123456",,,[9]],[,,,,,,,,,[-1]],"CH",41,"00","0",,,"0",,,,[[,"([2-9]\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-7]|[89]1"],"0$1"],[,"([89]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["8[047]|90"],"0$1"],[,"(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["860"],"0$1"]],,[,,"74[0248]\\d{6}",,,,"740123456",,,[9]],,,[,,,,,,,,,[-1]],[,,"5[18]\\d{7}",,,,"581234567",,,[9]],,,[,,"860\\d{9}",,,,"860123456789",,,[12]]],CI:[,[,,"[02-8]\\d{7}",
  37490. ,,,,,,[8]],[,,"(?:2(?:0[023]|1[02357]|[23][045]|4[03-5])|3(?:0[06]|1[069]|[2-4][07]|5[09]|6[08]))\\d{5}",,,,"21234567"],[,,"(?:0[1-9]|4\\d|5[14-9]|6[015-79]|[78][4-9])\\d{6}",,,,"01234567"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"CI",225,"00",,,,,,,,[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],CK:[,[,,"[2-8]\\d{4}",,,,,,,[5]],[,,"(?:2\\d|3[13-7]|4[1-5])\\d{3}",,,,"21234"],[,,"[5-8]\\d{4}",
  37491. ,,,"71234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"CK",682,"00",,,,,,,,[[,"(\\d{2})(\\d{3})","$1 $2"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],CL:[,[,,"(?:[2-9]|600|123)\\d{7,8}",,,,,,,[9,10,11],[7,8]],[,,"2(?:1962\\d{4}|2\\d{7}|32[0-467]\\d{5})|(?:3[2-5]|[47][1-35]|5[1-3578]|6[13-57]|9[3-9])\\d{7}",,,,"221234567",,,[9],[7,8]],[,,"2(?:1962\\d{4}|2\\d{7}|32[0-467]\\d{5})|(?:3[2-5]|[47][1-35]|5[1-3578]|6[13-57]|9[3-9])\\d{7}",,
  37492. ,,"961234567",,,[9],[8]],[,,"800\\d{6}|1230\\d{7}",,,,"800123456",,,[9,11]],[,,,,,,,,,[-1]],[,,"600\\d{7,8}",,,,"6001234567",,,[10,11]],[,,,,,,,,,[-1]],[,,"44\\d{7}",,,,"441234567",,,[9]],"CL",56,"(?:0|1(?:1[0-69]|2[0-57]|5[13-58]|69|7[0167]|8[018]))0","0",,,"0|(1(?:1[0-69]|2[0-57]|5[13-58]|69|7[0167]|8[018]))",,,1,[[,"(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2[23]"],"($1)","$CC ($1)"],[,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[357]|4[1-35]|6[13-57]"],"($1)","$CC ($1)"],[,"(9)(\\d{4})(\\d{4})","$1 $2 $3",
  37493. ["9"],"0$1"],[,"(44)(\\d{3})(\\d{4})","$1 $2 $3",["44"],"0$1"],[,"([68]00)(\\d{3})(\\d{3,4})","$1 $2 $3",["60|8"],"$1"],[,"(600)(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3 $4",["60"],"$1"],[,"(1230)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"$1"],[,"(\\d{5})(\\d{4})","$1 $2",["219"],"($1)","$CC ($1)"],[,"(\\d{4,5})","$1",["[1-9]"],"$1"]],[[,"(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2[23]"],"($1)","$CC ($1)"],[,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[357]|4[1-35]|6[13-57]"],"($1)","$CC ($1)"],[,"(9)(\\d{4})(\\d{4})",
  37494. "$1 $2 $3",["9"],"0$1"],[,"(44)(\\d{3})(\\d{4})","$1 $2 $3",["44"],"0$1"],[,"([68]00)(\\d{3})(\\d{3,4})","$1 $2 $3",["60|8"],"$1"],[,"(600)(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3 $4",["60"],"$1"],[,"(1230)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"$1"],[,"(\\d{5})(\\d{4})","$1 $2",["219"],"($1)","$CC ($1)"]],[,,,,,,,,,[-1]],,,[,,"600\\d{7,8}",,,,"6001234567",,,[10,11]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],CM:[,[,,"[2368]\\d{7,8}",,,,,,,[8,9]],[,,"2(?:22|33|4[23])\\d{6}",,,,"222123456",,,[9]],[,,"6[5-9]\\d{7}",
  37495. ,,,"671234567",,,[9]],[,,"88\\d{6}",,,,"88012345",,,[8]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"CM",237,"00",,,,,,,,[[,"([26])(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[26]"]],[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[23]|88"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],CN:[,[,,"[1-7]\\d{6,11}|8[0-357-9]\\d{6,9}|9\\d{7,10}",,,,,,,[7,8,9,10,11,12],[5,6]],[,,"21(?:100\\d{2}|95\\d{3,4}|\\d{8,10})|(?:10|2[02-57-9]|3(?:11|7[179])|4(?:[15]1|3[1-35])|5(?:1\\d|2[37]|3[12]|51|7[13-79]|9[15])|7(?:31|5[457]|6[09]|91)|8(?:[57]1|98))(?:100\\d{2}|95\\d{3,4}|\\d{8})|(?:3(?:1[02-9]|35|49|5\\d|7[02-68]|9[1-68])|4(?:1[02-9]|2[179]|3[3-9]|5[2-9]|6[4789]|7\\d|8[23])|5(?:3[03-9]|4[36]|5[02-9]|6[1-46]|7[028]|80|9[2-46-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[17]\\d|2[248]|3[04-9]|4[3-6]|5[0-4689]|6[2368]|9[02-9])|8(?:078|1[236-8]|2[5-7]|3\\d|5[1-9]|7[02-9]|8[3678]|9[1-7])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:100\\d{2}|95\\d{3,4}|\\d{7})|80(?:29|6[03578]|7[018]|81)\\d{4}",
  37496. ,,,"1012345678",,,,[5,6]],[,,"1(?:[38]\\d|4[57]|5[0-35-9]|7[0-35-8])\\d{8}",,,,"13123456789",,,[11]],[,,"(?:10)?800\\d{7}",,,,"8001234567",,,[10,12]],[,,"16[08]\\d{5}",,,,"16812345",,,[8]],[,,"400\\d{7}|950\\d{7,8}|(?:10|2[0-57-9]|3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[4789]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[3678]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))96\\d{3,4}",
  37497. ,,,"4001234567",,,[7,8,9,10,11],[5,6]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"CN",86,"(1(?:[129]\\d{3}|79\\d{2}))?00","0",,,"(1(?:[129]\\d{3}|79\\d{2}))|0",,"00",,[[,"(80\\d{2})(\\d{4})","$1 $2",["80[2678]"],"0$1","$CC $1",1],[,"([48]00)(\\d{3})(\\d{4})","$1 $2 $3",["[48]00"]],[,"(\\d{5,6})","$1",["100|95"]],[,"(\\d{2})(\\d{5,6})","$1 $2",["(?:10|2\\d)[19]","(?:10|2\\d)(?:10|9[56])","(?:10|2\\d)(?:100|9[56])"],"0$1","$CC $1"],[,"(\\d{3})(\\d{5,6})","$1 $2",["[3-9]","[3-9]\\d{2}[19]","[3-9]\\d{2}(?:10|9[56])"],
  37498. "0$1","$CC $1"],[,"(\\d{3,4})(\\d{4})","$1 $2",["[2-9]"]],[,"(21)(\\d{4})(\\d{4,6})","$1 $2 $3",["21"],"0$1","$CC $1",1],[,"([12]\\d)(\\d{4})(\\d{4})","$1 $2 $3",["10[1-9]|2[02-9]","10[1-9]|2[02-9]","10(?:[1-79]|8(?:[1-9]|0[1-9]))|2[02-9]"],"0$1","$CC $1",1],[,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["3(?:1[02-9]|35|49|5|7[02-68]|9[1-68])|4(?:1[02-9]|2[179]|[35][2-9]|6[4789]|7\\d|8[23])|5(?:3[03-9]|4[36]|5[02-9]|6[1-46]|7[028]|80|9[2-46-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[04-9]|4[3-6]|6[2368])|8(?:1[236-8]|2[5-7]|3|5[1-9]|7[02-9]|8[3678]|9[1-7])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])"],
  37499. "0$1","$CC $1",1],[,"(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["3(?:11|7[179])|4(?:[15]1|3[1-35])|5(?:1|2[37]|3[12]|51|7[13-79]|9[15])|7(?:31|5[457]|6[09]|91)|8(?:[57]1|98)"],"0$1","$CC $1",1],[,"(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["807","8078"],"0$1","$CC $1",1],[,"(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["1[3-578]"],,"$CC $1"],[,"(10800)(\\d{3})(\\d{4})","$1 $2 $3",["108","1080","10800"]],[,"(\\d{3})(\\d{7,8})","$1 $2",["950"]]],[[,"(80\\d{2})(\\d{4})","$1 $2",["80[2678]"],"0$1","$CC $1",1],[,"([48]00)(\\d{3})(\\d{4})",
  37500. "$1 $2 $3",["[48]00"]],[,"(\\d{2})(\\d{5,6})","$1 $2",["(?:10|2\\d)[19]","(?:10|2\\d)(?:10|9[56])","(?:10|2\\d)(?:100|9[56])"],"0$1","$CC $1"],[,"(\\d{3})(\\d{5,6})","$1 $2",["[3-9]","[3-9]\\d{2}[19]","[3-9]\\d{2}(?:10|9[56])"],"0$1","$CC $1"],[,"(21)(\\d{4})(\\d{4,6})","$1 $2 $3",["21"],"0$1","$CC $1",1],[,"([12]\\d)(\\d{4})(\\d{4})","$1 $2 $3",["10[1-9]|2[02-9]","10[1-9]|2[02-9]","10(?:[1-79]|8(?:[1-9]|0[1-9]))|2[02-9]"],"0$1","$CC $1",1],[,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["3(?:1[02-9]|35|49|5|7[02-68]|9[1-68])|4(?:1[02-9]|2[179]|[35][2-9]|6[4789]|7\\d|8[23])|5(?:3[03-9]|4[36]|5[02-9]|6[1-46]|7[028]|80|9[2-46-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[04-9]|4[3-6]|6[2368])|8(?:1[236-8]|2[5-7]|3|5[1-9]|7[02-9]|8[3678]|9[1-7])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])"],
  37501. "0$1","$CC $1",1],[,"(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["3(?:11|7[179])|4(?:[15]1|3[1-35])|5(?:1|2[37]|3[12]|51|7[13-79]|9[15])|7(?:31|5[457]|6[09]|91)|8(?:[57]1|98)"],"0$1","$CC $1",1],[,"(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["807","8078"],"0$1","$CC $1",1],[,"(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["1[3-578]"],,"$CC $1"],[,"(10800)(\\d{3})(\\d{4})","$1 $2 $3",["108","1080","10800"]],[,"(\\d{3})(\\d{7,8})","$1 $2",["950"]]],[,,,,,,,,,[-1]],,,[,,"(?:4|(?:10)?8)00\\d{7}|950\\d{7,8}",,,,"4001234567",
  37502. ,,[10,11,12]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],CO:[,[,,"(?:[13]\\d{0,3}|[24-8])\\d{7}",,,,,,,[8,10,11],[7]],[,,"[124-8][2-9]\\d{6}",,,,"12345678",,,[8],[7]],[,,"3(?:0[0-5]|1\\d|2[0-3]|5[01])\\d{7}",,,,"3211234567",,,[10]],[,,"1800\\d{7}",,,,"18001234567",,,[11]],[,,"19(?:0[01]|4[78])\\d{7}",,,,"19001234567",,,[11]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"CO",57,"00(?:4(?:[14]4|56)|[579])","0",,,"0([3579]|4(?:44|56))?",,,,[[,"(\\d)(\\d{7})","$1 $2",["1(?:8[2-9]|9[0-3]|[2-7])|[24-8]","1(?:8[2-9]|9(?:09|[1-3])|[2-7])|[24-8]"],
  37503. "($1)","0$CC $1"],[,"(\\d{3})(\\d{7})","$1 $2",["3"],,"0$CC $1"],[,"(1)(\\d{3})(\\d{7})","$1-$2-$3",["1(?:80|9[04])","1(?:800|9(?:0[01]|4[78]))"],"0$1"]],[[,"(\\d)(\\d{7})","$1 $2",["1(?:8[2-9]|9[0-3]|[2-7])|[24-8]","1(?:8[2-9]|9(?:09|[1-3])|[2-7])|[24-8]"],"($1)","0$CC $1"],[,"(\\d{3})(\\d{7})","$1 $2",["3"],,"0$CC $1"],[,"(1)(\\d{3})(\\d{7})","$1 $2 $3",["1(?:80|9[04])","1(?:800|9(?:0[01]|4[78]))"]]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],CR:[,[,,"[24-9]\\d{7,9}",,
  37504. ,,,,,[8,10]],[,,"2[0-24-7]\\d{6}",,,,"22123456",,,[8]],[,,"5(?:0[01]|7[0-3])\\d{5}|6(?:[0-4]\\d{3}|500[01])\\d{3}|(?:7[0-3]|8[3-9])\\d{6}",,,,"83123456",,,[8]],[,,"800\\d{7}",,,,"8001234567",,,[10]],[,,"90[059]\\d{7}",,,,"9001234567",,,[10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"210[0-6]\\d{4}|4\\d{7}|5100\\d{4}",,,,"40001234",,,[8]],"CR",506,"00",,,,"(19(?:0[012468]|1[09]|20|66|77|99))",,,,[[,"(\\d{4})(\\d{4})","$1 $2",["[24-7]|8[3-9]"],,"$CC $1"],[,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[89]0"],
  37505. ,"$CC $1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],CU:[,[,,"[2-57]\\d{5,7}",,,,,,,[6,7,8],[4,5]],[,,"2[1-4]\\d{5,6}|3(?:1\\d{6}|[23]\\d{4,6})|4(?:[125]\\d{5,6}|[36]\\d{6}|[78]\\d{4,6})|7\\d{6,7}",,,,"71234567",,,,[4,5]],[,,"5\\d{7}",,,,"51234567",,,[8]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"CU",53,"119","0",,,"0",,,,[[,"(\\d)(\\d{6,7})","$1 $2",["7"],"(0$1)"],[,"(\\d{2})(\\d{4,6})","$1 $2",["[2-4]"],"(0$1)"],[,"(\\d)(\\d{7})",
  37506. "$1 $2",["5"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],CV:[,[,,"[259]\\d{6}",,,,,,,[7]],[,,"2(?:2[1-7]|3[0-8]|4[12]|5[1256]|6\\d|7[1-3]|8[1-5])\\d{4}",,,,"2211234"],[,,"(?:9\\d|59)\\d{5}",,,,"9911234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"CV",238,"0",,,,,,,,[[,"(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],CW:[,[,,"[169]\\d{6,7}",,,,,,,[7,8]],[,,"9(?:[48]\\d{2}|50\\d|7(?:2[0-24]|[34]\\d|6[35-7]|77|8[7-9]))\\d{4}",
  37507. ,,,"94151234",,,[8]],[,,"9(?:5(?:[12467]\\d|3[01])|6(?:[15-9]\\d|3[01]))\\d{4}",,,,"95181234",,,[8]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"60[0-2]\\d{4}",,,,"6001234",,,[7]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"CW",599,"00",,,,,,,,[[,"(\\d{3})(\\d{4})","$1 $2",["[13-7]"]],[,"(9)(\\d{3})(\\d{4})","$1 $2 $3",["9"]]],,[,,"955\\d{5}",,,,"95581234",,,[8]],1,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],CX:[,[,,"[1458]\\d{5,9}",,,,,,,[6,7,8,9,10]],[,,"89164\\d{4}",,,,"891641234",,,[9],[8]],[,,"14(?:5\\d|71)\\d{5}|4(?:[0-2]\\d|3[0-57-9]|4[47-9]|5[0-25-9]|6[6-9]|7[02-9]|8[147-9]|9[017-9])\\d{6}",
  37508. ,,,"412345678",,,[9]],[,,"180(?:0\\d{3}|2)\\d{3}",,,,"1800123456",,,[7,10]],[,,"190[0126]\\d{6}",,,,"1900123456",,,[10]],[,,"13(?:00\\d{2})?\\d{4}",,,,"1300123456",,,[6,8,10]],[,,"500\\d{6}",,,,"500123456",,,[9]],[,,"550\\d{6}",,,,"550123456",,,[9]],"CX",61,"(?:14(?:1[14]|34|4[17]|[56]6|7[47]|88))?001[14-689]","0",,,"0",,"0011",,,,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],CY:[,[,,"[257-9]\\d{7}",,,,,,,[8]],[,,"2[2-6]\\d{6}",,,,"22345678"],[,,"9[4-79]\\d{6}",,,,"96123456"],
  37509. [,,"800\\d{5}",,,,"80001234"],[,,"90[09]\\d{5}",,,,"90012345"],[,,"80[1-9]\\d{5}",,,,"80112345"],[,,"700\\d{5}",,,,"70012345"],[,,,,,,,,,[-1]],"CY",357,"00",,,,,,,,[[,"(\\d{2})(\\d{6})","$1 $2"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"(?:50|77)\\d{6}",,,,"77123456"],,,[,,,,,,,,,[-1]]],CZ:[,[,,"[2-8]\\d{8}|9\\d{8,11}",,,,,,,[9,10,11,12]],[,,"2\\d{8}|(?:3[1257-9]|4[16-9]|5[13-9])\\d{7}",,,,"212345678",,,[9]],[,,"(?:60[1-8]|7(?:0[2-5]|[2379]\\d))\\d{6}",,,,"601123456",,,[9]],[,,"800\\d{6}",,,,"800123456",
  37510. ,,[9]],[,,"9(?:0[05689]|76)\\d{6}",,,,"900123456",,,[9]],[,,"8[134]\\d{7}",,,,"811234567",,,[9]],[,,"70[01]\\d{6}",,,,"700123456",,,[9]],[,,"9[17]0\\d{6}",,,,"910123456",,,[9]],"CZ",420,"00",,,,,,,,[[,"([2-9]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]|9[015-7]"]],[,"(96\\d)(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["96"]],[,"(9\\d)(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9[36]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"9(?:5\\d|7[234])\\d{6}",,,,"972123456",,,[9]],,,[,,"9(?:3\\d{9}|6\\d{7,10})",,,
  37511. ,"93123456789"]],DE:[,[,,"[1-35-9]\\d{3,14}|4(?:[0-8]\\d{3,12}|9(?:[0-37]\\d|4(?:[1-35-8]|4\\d?)|5\\d{1,2}|6[1-8]\\d?)\\d{2,8})",,,,,,,[4,5,6,7,8,9,10,11,12,13,14,15],[3]],[,,"2\\d{5,13}|3(?:0\\d{3,13}|2\\d{9}|[3-9]\\d{4,13})|4(?:0\\d{3,12}|\\d{5,13})|5(?:0[2-8]|[1256]\\d|[38][0-8]|4\\d{0,2}|[79][0-7])\\d{3,11}|6(?:\\d{5,13}|9\\d{3,12})|7(?:0[2-8]|[1-9]\\d)\\d{3,10}|8(?:0[2-9]|[1-8]\\d|9\\d?)\\d{3,10}|9(?:0[6-9]\\d{3,10}|1\\d{4,12}|[2-9]\\d{4,11})",,,,"30123456",,,[5,6,7,8,9,10,11,12,13,14,15],[3,
  37512. 4]],[,,"1(?:5[0-25-9]\\d{8}|6[023]\\d{7,8}|7\\d{8,9})",,,,"15123456789",,,[10,11]],[,,"800\\d{7,12}",,,,"8001234567890",,,[10,11,12,13,14,15]],[,,"137[7-9]\\d{6}|900(?:[135]\\d{6}|9\\d{7})",,,,"9001234567",,,[10,11]],[,,"1(?:3(?:7[1-6]\\d{6}|8\\d{4})|80\\d{5,11})",,,,"18012345",,,[7,8,9,10,11,12,13,14]],[,,"700\\d{8}",,,,"70012345678",,,[11]],[,,,,,,,,,[-1]],"DE",49,"00","0",,,"0",,,,[[,"(1\\d{2})(\\d{7,8})","$1 $2",["1[67]"],"0$1"],[,"(15\\d{3})(\\d{6})","$1 $2",["15[0568]"],"0$1"],[,"(1\\d{3})(\\d{7})",
  37513. "$1 $2",["15"],"0$1"],[,"(\\d{2})(\\d{3,11})","$1 $2",["3[02]|40|[68]9"],"0$1"],[,"(\\d{3})(\\d{3,11})","$1 $2",["2(?:\\d1|0[2389]|1[24]|28|34)|3(?:[3-9][15]|40)|[4-8][1-9]1|9(?:06|[1-9]1)"],"0$1"],[,"(\\d{4})(\\d{2,11})","$1 $2",["[24-6]|[7-9](?:\\d[1-9]|[1-9]\\d)|3(?:[3569][02-46-9]|4[2-4679]|7[2-467]|8[2-46-8])","[24-6]|[7-9](?:\\d[1-9]|[1-9]\\d)|3(?:3(?:0[1-467]|2[127-9]|3[124578]|[46][1246]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|3[1357]|4[13578]|6[1246]|7[1356]|9[1346])|5(?:0[14]|2[1-3589]|3[1357]|4[1246]|6[1-4]|7[1346]|8[13568]|9[1246])|6(?:0[356]|2[1-489]|3[124-6]|4[1347]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|3[1357]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|4[1347]|6[0135-9]|7[1467]|8[136])|9(?:0[12479]|2[1358]|3[1357]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))"],
  37514. "0$1"],[,"(3\\d{4})(\\d{1,10})","$1 $2",["3"],"0$1"],[,"(800)(\\d{7,12})","$1 $2",["800"],"0$1"],[,"(\\d{3})(\\d)(\\d{4,10})","$1 $2 $3",["(?:18|90)0|137","1(?:37|80)|900[1359]"],"0$1"],[,"(1\\d{2})(\\d{5,11})","$1 $2",["181"],"0$1"],[,"(18\\d{3})(\\d{6})","$1 $2",["185","1850","18500"],"0$1"],[,"(18\\d{2})(\\d{7})","$1 $2",["18[68]"],"0$1"],[,"(18\\d)(\\d{8})","$1 $2",["18[2-579]"],"0$1"],[,"(700)(\\d{4})(\\d{4})","$1 $2 $3",["700"],"0$1"],[,"(138)(\\d{4})","$1 $2",["138"],"0$1"],[,"(15[013-68])(\\d{2})(\\d{8})",
  37515. "$1 $2 $3",["15[013-68]"],"0$1"],[,"(15[279]\\d)(\\d{2})(\\d{7})","$1 $2 $3",["15[279]"],"0$1"],[,"(1[67]\\d)(\\d{2})(\\d{7,8})","$1 $2 $3",["1(?:6[023]|7)"],"0$1"]],,[,,"16(?:4\\d{1,10}|[89]\\d{1,11})",,,,"16412345",,,[4,5,6,7,8,9,10,11,12,13,14]],,,[,,,,,,,,,[-1]],[,,"18(?:1\\d{5,11}|[2-9]\\d{8})",,,,"18500123456",,,[8,9,10,11,12,13,14]],,,[,,"1(?:5(?:(?:2\\d55|7\\d99|9\\d33)\\d{7}|(?:[034568]00|113)\\d{8})|6(?:013|255|399)\\d{7,8}|7(?:[015]13|[234]55|[69]33|[78]99)\\d{7,8})",,,,"177991234567",
  37516. ,,[12,13]]],DJ:[,[,,"[27]\\d{7}",,,,,,,[8]],[,,"2(?:1[2-5]|7[45])\\d{5}",,,,"21360003"],[,,"77\\d{6}",,,,"77831001"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"DJ",253,"00",,,,,,,,[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],DK:[,[,,"[2-9]\\d{7}",,,,,,,[8]],[,,"(?:[2-7]\\d|8[126-9]|9[1-36-9])\\d{6}",,,,"32123456"],[,,"(?:[2-7]\\d|8[126-9]|9[1-36-9])\\d{6}",,,,"20123456"],[,,"80\\d{6}",
  37517. ,,,"80123456"],[,,"90\\d{6}",,,,"90123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"DK",45,"00",,,,,,,1,[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],DM:[,[,,"[57-9]\\d{9}",,,,,,,[10],[7]],[,,"767(?:2(?:55|66)|4(?:2[01]|4[0-25-9])|50[0-4]|70[1-3])\\d{4}",,,,"7674201234",,,,[7]],[,,"767(?:2(?:[234689]5|7[5-7])|31[5-7]|61[1-7])\\d{4}",,,,"7672251234",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002123456"],
  37518. [,,"900[2-9]\\d{6}",,,,"9002123456"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"DM",1,"011","1",,,"1",,,,,,[,,,,,,,,,[-1]],,"767",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],DO:[,[,,"[589]\\d{9}",,,,,,,[10],[7]],[,,"8(?:[04]9[2-9]\\d{6}|29(?:2(?:[0-59]\\d|6[04-9]|7[0-27]|8[0237-9])|3(?:[0-35-9]\\d|4[7-9])|[45]\\d{2}|6(?:[0-27-9]\\d|[3-5][1-9]|6[0135-8])|7(?:0[013-9]|[1-37]\\d|4[1-35689]|5[1-4689]|6[1-57-9]|8[1-79]|9[1-8])|8(?:0[146-9]|1[0-48]|[248]\\d|3[1-79]|5[01589]|6[013-68]|7[124-8]|9[0-8])|9(?:[0-24]\\d|3[02-46-9]|5[0-79]|60|7[0169]|8[57-9]|9[02-9]))\\d{4})",
  37519. ,,,"8092345678",,,,[7]],[,,"8[024]9[2-9]\\d{6}",,,,"8092345678",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002123456"],[,,"900[2-9]\\d{6}",,,,"9002123456"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"DO",1,"011","1",,,"1",,,,,,[,,,,,,,,,[-1]],,"8[024]9",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],DZ:[,[,,"(?:[1-4]|[5-9]\\d)\\d{7}",,,,,,,[8,9]],[,,"(?:1\\d|2[013-79]|3[0-8]|4[0135689])\\d{6}|9619\\d{5}",,,,"12345678"],[,,"(?:5[4-6]|7[7-9])\\d{7}|6(?:[569]\\d|7[0-6])\\d{6}",
  37520. ,,,"551234567",,,[9]],[,,"800\\d{6}",,,,"800123456",,,[9]],[,,"80[3-689]1\\d{5}",,,,"808123456",,,[9]],[,,"80[12]1\\d{5}",,,,"801123456",,,[9]],[,,,,,,,,,[-1]],[,,"98[23]\\d{6}",,,,"983123456",,,[9]],"DZ",213,"00","0",,,"0",,,,[[,"([1-4]\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-4]"],"0$1"],[,"([5-8]\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-8]"],"0$1"],[,"(9\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["9"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],
  37521. EC:[,[,,"1\\d{9,10}|[2-8]\\d{7}|9\\d{8}",,,,,,,[8,9,10,11],[7]],[,,"[2-7][2-7]\\d{6}",,,,"22123456",,,[8],[7]],[,,"9(?:(?:39|[45][89]|7[7-9]|[89]\\d)\\d|6(?:[017-9]\\d|2[0-4]))\\d{5}",,,,"991234567",,,[9]],[,,"1800\\d{6,7}",,,,"18001234567",,,[10,11]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"[2-7]890\\d{4}",,,,"28901234",,,[8]],"EC",593,"00","0",,,"0",,,,[[,"(\\d)(\\d{3})(\\d{4})","$1 $2-$3",["[247]|[356][2-8]"],"(0$1)"],[,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["9"],"0$1"],[,"(1800)(\\d{3})(\\d{3,4})",
  37522. "$1 $2 $3",["1"],"$1"]],[[,"(\\d)(\\d{3})(\\d{4})","$1-$2-$3",["[247]|[356][2-8]"]],[,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["9"],"0$1"],[,"(1800)(\\d{3})(\\d{3,4})","$1 $2 $3",["1"],"$1"]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],EE:[,[,,"[3-9]\\d{6,7}|800\\d{6,7}",,,,,,,[7,8,10]],[,,"(?:3[23589]|4[3-8]|6\\d|7[1-9]|88)\\d{5}",,,,"3212345",,,[7]],[,,"(?:5\\d|8[1-5])\\d{6}|5(?:[02]\\d{2}|1(?:[0-8]\\d|95)|5[0-478]\\d|64[0-4]|65[1-589])\\d{3}",,,,"51234567",,,[7,8]],[,,"800(?:0\\d{3}|1\\d|[2-9])\\d{3}",
  37523. ,,,"80012345"],[,,"(?:40\\d{2}|900)\\d{4}",,,,"9001234",,,[7,8]],[,,,,,,,,,[-1]],[,,"70[0-2]\\d{5}",,,,"70012345",,,[8]],[,,,,,,,,,[-1]],"EE",372,"00",,,,,,,,[[,"([3-79]\\d{2})(\\d{4})","$1 $2",["[369]|4[3-8]|5(?:[0-2]|5[0-478]|6[45])|7[1-9]","[369]|4[3-8]|5(?:[02]|1(?:[0-8]|95)|5[0-478]|6(?:4[0-4]|5[1-589]))|7[1-9]"]],[,"(70)(\\d{2})(\\d{4})","$1 $2 $3",["70"]],[,"(8000)(\\d{3})(\\d{3})","$1 $2 $3",["800","8000"]],[,"([458]\\d{3})(\\d{3,4})","$1 $2",["40|5|8(?:00|[1-5])","40|5|8(?:00[1-9]|[1-5])"]]],
  37524. ,[,,,,,,,,,[-1]],,,[,,"800[2-9]\\d{3}",,,,"8002123",,,[7]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],EG:[,[,,"1\\d{4,9}|[2456]\\d{8}|3\\d{7}|[89]\\d{8,9}",,,,,,,[8,9,10],[7]],[,,"(?:1(?:3[23]\\d|5(?:[23]|9\\d))|2[2-4]\\d{2}|3\\d{2}|4(?:0[2-5]|[578][23]|64)\\d|5(?:0[2-7]|[57][23])\\d|6[24-689]3\\d|8(?:2[2-57]|4[26]|6[237]|8[2-4])\\d|9(?:2[27]|3[24]|52|6[2356]|7[2-4])\\d)\\d{5}",,,,"234567890",,,[8,9],[7]],[,,"1(?:0[0-269]|1[0-245]|2[0-278]|55)\\d{7}",,,,"1001234567",,,[10]],[,,"800\\d{7}",,,,"8001234567",
  37525. ,,[10]],[,,"900\\d{7}",,,,"9001234567",,,[10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"EG",20,"00","0",,,"0",,,,[[,"(\\d)(\\d{7,8})","$1 $2",["[23]"],"0$1"],[,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1[012]|[89]00"],"0$1"],[,"(\\d{2})(\\d{6,7})","$1 $2",["1[35]|[4-6]|[89][2-9]"],"0$1"],[,"(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["155"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],EH:[,[,,"[5-9]\\d{8}",,,,,,,[9]],[,,"528[89]\\d{5}",,,,"528812345"],[,,"(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[07][07]|6[12]))\\d{6}",
  37526. ,,,"650123456"],[,,"80\\d{7}",,,,"801234567"],[,,"89\\d{7}",,,,"891234567"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"5924[01]\\d{4}",,,,"592401234"],"EH",212,"00","0",,,"0",,,,,,[,,,,,,,,,[-1]],,"528[89]",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],ER:[,[,,"[178]\\d{6}",,,,,,,[7],[6]],[,,"1(?:1[12568]|20|40|55|6[146])\\d{4}|8\\d{6}",,,,"8370362",,,,[6]],[,,"17[1-3]\\d{4}|7\\d{6}",,,,"7123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"ER",291,"00","0",,,"0",
  37527. ,,,[[,"(\\d)(\\d{3})(\\d{3})","$1 $2 $3",,"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],ES:[,[,,"[5-9]\\d{8}",,,,,,,[9]],[,,"8(?:[1356]\\d|[28][0-8]|[47][1-9])\\d{6}|9(?:[135]\\d{7}|[28][0-8]\\d{6}|4[1-9]\\d{6}|6(?:[0-8]\\d{6}|9(?:0(?:[0-57-9]\\d{4}|6(?:0[0-8]|1[1-9]|[2-9]\\d)\\d{2})|[1-9]\\d{5}))|7(?:[124-9]\\d{2}|3(?:[0-8]\\d|9[1-9]))\\d{4})",,,,"810123456"],[,,"(?:6\\d{6}|7[1-48]\\d{5}|9(?:6906(?:09|10)|7390\\d{2}))\\d{2}",,,,"612345678"],[,,"[89]00\\d{6}",,,,"800123456"],
  37528. [,,"80[367]\\d{6}",,,,"803123456"],[,,"90[12]\\d{6}",,,,"901123456"],[,,"70\\d{7}",,,,"701234567"],[,,,,,,,,,[-1]],"ES",34,"00",,,,,,,,[[,"([89]00)(\\d{3})(\\d{3})","$1 $2 $3",["[89]00"]],[,"([5-9]\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[568]|[79][0-8]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"51\\d{7}",,,,"511234567"],,,[,,,,,,,,,[-1]]],ET:[,[,,"[1-59]\\d{8}",,,,,,,[9],[7]],[,,"(?:11(?:1(?:1[124]|2[2-57]|3[1-5]|5[5-8]|8[6-8])|2(?:13|3[6-8]|5[89]|7[05-9]|8[2-6])|3(?:2[01]|3[0-289]|4[1289]|7[1-4]|87)|4(?:1[69]|3[2-49]|4[0-3]|6[5-8])|5(?:1[578]|44|5[0-4])|6(?:18|2[69]|39|4[5-7]|5[1-5]|6[0-59]|8[015-8]))|2(?:2(?:11[1-9]|22[0-7]|33\\d|44[1467]|66[1-68])|5(?:11[124-6]|33[2-8]|44[1467]|55[14]|66[1-3679]|77[124-79]|880))|3(?:3(?:11[0-46-8]|22[0-6]|33[0134689]|44[04]|55[0-6]|66[01467])|4(?:44[0-8]|55[0-69]|66[0-3]|77[1-5]))|4(?:6(?:22[0-24-7]|33[1-5]|44[13-69]|55[14-689]|660|88[1-4])|7(?:11[1-9]|22[1-9]|33[13-7]|44[13-6]|55[1-689]))|5(?:7(?:227|55[05]|(?:66|77)[14-8])|8(?:11[149]|22[013-79]|33[0-68]|44[013-8]|550|66[1-5]|77\\d)))\\d{4}",
  37529. ,,,"111112345",,,,[7]],[,,"9(?:[1-46-8]\\d|5[89])\\d{6}",,,,"911234567"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"ET",251,"00","0",,,"0",,,,[[,"([1-59]\\d)(\\d{3})(\\d{4})","$1 $2 $3",,"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],FI:[,[,,"[16]\\d{6,9}|2\\d{4,9}|[35]\\d{5,9}|4\\d{7,10}|7\\d{7,9}|[89]\\d{6,8}",,,,,,,[5,6,7,8,9,10,11]],[,,"1[3-79][1-8]\\d{4,6}|[235689][1-8]\\d{5,7}",,,,"131234567",,,[7,8,9]],[,,"4(?:[0-8]\\d{6,8}|9\\d{9})|50\\d{4,8}",
  37530. ,,,"412345678",,,[6,7,8,9,10,11]],[,,"800\\d{5,6}",,,,"800123456",,,[8,9]],[,,"[67]00\\d{5,6}",,,,"600123456",,,[8,9]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"FI",358,"00|99(?:[02469]|5(?:11|33|5[59]|88|9[09]))","0",,,"0",,"00",,[[,"(\\d{3})(\\d{3,7})","$1 $2",["(?:[1-3]00|[6-8]0)"],"0$1"],[,"(116\\d{3})","$1",["116"],"$1"],[,"(\\d{2})(\\d{3,9})","$1 $2",["1(?:0[1-9]|[3-9])|2(?:0[1-9]|9)|30[1-9]|4|50|7(?:[13]|5[03-9])"],"0$1"],[,"(75\\d{3})","$1",["75[12]"],"0$1"],[,"(\\d)(\\d{5,9})","$1 $2",
  37531. ["[235689][1-8]"],"0$1"],[,"(39\\d)(\\d{3})(\\d{3})","$1 $2 $3",["39"],"0$1"]],[[,"(\\d{3})(\\d{3,7})","$1 $2",["(?:[1-3]00|[6-8]0)"],"0$1"],[,"(116\\d{3})","$1",["116"],"$1"],[,"(\\d{2})(\\d{3,9})","$1 $2",["1(?:0[1-9]|[3-9])|2(?:0[1-9]|9)|30[1-9]|4|50|7(?:[13]|5[03-9])"],"0$1"],[,"(\\d)(\\d{5,9})","$1 $2",["[235689][1-8]"],"0$1"],[,"(39\\d)(\\d{3})(\\d{3})","$1 $2 $3",["39"],"0$1"]],[,,,,,,,,,[-1]],1,,[,,"100\\d{4,6}|20(?:0\\d{4,6}|2[023]\\d{4,5}|9[89]\\d{1,6})|300\\d{3,7}|60(?:[12]\\d{5,6}|6\\d{7})|7(?:1\\d{7}|3\\d{8}|5[03-9]\\d{5,6})",
  37532. ,,,"1001234",,,[5,6,7,8,9,10]],[,,"10(?:0\\d{4,6}|[1-9]\\d{5,7})|2(?:0(?:0\\d{4,6}|[13-8]\\d{5,7}|2(?:[023]\\d{4,5}|[14-9]\\d{4,6})|9(?:[0-7]\\d{4,6}|[89]\\d{1,6}))|9\\d{5,8})|3(?:0(?:0\\d{3,7}|[1-57-9]\\d{5,7}|6(?:\\d{3}|\\d{5,7}))|93\\d{5,7})|60(?:[12]\\d{5,6}|6\\d{7})|7(?:1\\d{7}|3\\d{8}|5[03-9]\\d{5,6})",,,,"10112345",,,[5,6,7,8,9,10]],,,[,,,,,,,,,[-1]]],FJ:[,[,,"[35-9]\\d{6}|0\\d{10}",,,,,,,[7,11]],[,,"(?:3[0-5]|6[25-7]|8[58])\\d{5}",,,,"3212345",,,[7]],[,,"(?:5[018]|[79]\\d|8[034679])\\d{5}",
  37533. ,,,"7012345",,,[7]],[,,"0800\\d{7}",,,,"08001234567",,,[11]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"FJ",679,"0(?:0|52)",,,,,,"00",,[[,"(\\d{3})(\\d{4})","$1 $2",["[35-9]"]],[,"(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],FK:[,[,,"[2-7]\\d{4}",,,,,,,[5]],[,,"[2-47]\\d{4}",,,,"31234"],[,,"[56]\\d{4}",,,,"51234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"FK",500,"00",
  37534. ,,,,,,,,,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],FM:[,[,,"[39]\\d{6}",,,,,,,[7]],[,,"3[2357]0[1-9]\\d{3}|9[2-6]\\d{5}",,,,"3201234"],[,,"3[2357]0[1-9]\\d{3}|9[2-7]\\d{5}",,,,"3501234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"FM",691,"00",,,,,,,,[[,"(\\d{3})(\\d{4})","$1 $2"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],FO:[,[,,"[2-9]\\d{5}",,,,,,,[6]],[,,"(?:20|[3-4]\\d|8[19])\\d{4}",,,,"201234"],[,,"(?:[27][1-9]|5\\d)\\d{4}",
  37535. ,,,"211234"],[,,"80[257-9]\\d{3}",,,,"802123"],[,,"90(?:[1345][15-7]|2[125-7]|99)\\d{2}",,,,"901123"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"(?:6[0-36]|88)\\d{4}",,,,"601234"],"FO",298,"00",,,,"(10(?:01|[12]0|88))",,,,[[,"(\\d{6})","$1",,,"$CC $1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],FR:[,[,,"[1-9]\\d{8}",,,,,,,[9]],[,,"[1-5]\\d{8}",,,,"123456789"],[,,"(?:6\\d|7[3-9])\\d{7}",,,,"612345678"],[,,"80[0-5]\\d{6}",,,,"801234567"],[,,"89[1-37-9]\\d{6}",,,,"891123456"],[,
  37536. ,"8(?:1[0-29]|2[0156]|84|90)\\d{6}",,,,"810123456"],[,,,,,,,,,[-1]],[,,"9\\d{8}",,,,"912345678"],"FR",33,"00","0",,,"0",,,,[[,"([1-79])(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[1-79]"],"0$1"],[,"(1\\d{2})(\\d{3})","$1 $2",["11"],"$1"],[,"(8\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0 $1"]],[[,"([1-79])(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[1-79]"],"0$1"],[,"(8\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0 $1"]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"80[6-9]\\d{6}",
  37537. ,,,"806123456"],,,[,,,,,,,,,[-1]]],GA:[,[,,"0?\\d{7}",,,,,,,[7,8]],[,,"01\\d{6}",,,,"01441234",,,[8]],[,,"0?[2-7]\\d{6}",,,,"06031234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"GA",241,"00",,,,,,,,[[,"(\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-7]"],"0$1"],[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],GB:[,[,,"\\d{7,10}",,,,,,,[7,9,10],[4,5,6,8]],[,,"2(?:0[01378]|3[0189]|4[017]|8[0-46-9]|9[0-2])\\d{7}|1(?:1(?:3[0-48]|[46][0-4]|5[0-26-9]|[78][0-49])|21[0-7]|31[0-8]|[4-69]1\\d)\\d{6}|1(?:2(?:0[024-9]|2[3-9]|3[3-79]|4[1-689]|[58][02-9]|6[0-47-9]|7[013-9]|9\\d)|3(?:0\\d|[25][02-9]|3[02-579]|[468][0-46-9]|7[1-35-79]|9[2-578])|4(?:0[03-9]|[28][02-57-9]|[37]\\d|4[02-69]|5[0-8]|[69][0-79])|5(?:0[1-35-9]|2[024-9]|3[015689]|4[02-9]|5[03-9]|6\\d|7[0-35-9]|8[0-468]|9[0-57-9])|6(?:0[034689]|2[0-35689]|[38][013-9]|4[1-467]|5[0-69]|6[13-9]|7[0-8]|9[0124578])|7(?:0[0246-9]|2\\d|3[0236-8]|4[03-9]|5[0-46-9]|6[013-9]|7[0-35-9]|8[024-9]|9[02-9])|8(?:0[35-9]|2[1-57-9]|3[02-578]|4[0-578]|5[124-9]|6[2-69]|7\\d|8[02-9]|9[02569])|9(?:0[02-589]|2[02-689]|3[1-57-9]|4[2-9]|5[0-579]|6[2-47-9]|7[0-24578]|8\\d|9[2-57]))\\d{6}|1(?:2(?:0(?:46[1-4]|87[2-9])|545[1-79]|76(?:2\\d|3[1-8]|6[1-6])|9(?:7(?:2[0-4]|3[2-5])|8(?:2[2-8]|7[0-47-9]|8[345])))|3(?:638[2-5]|647[23]|8(?:47[04-9]|64[0157-9]))|4(?:044[1-7]|20(?:2[23]|8\\d)|6(?:0(?:30|5[2-57]|6[1-8]|7[2-8])|140)|8(?:052|87[123]))|5(?:24(?:3[2-79]|6\\d)|276\\d|6(?:26[06-9]|686))|6(?:06(?:4\\d|7[4-79])|295[567]|35[34]\\d|47(?:24|61)|59(?:5[08]|6[67]|74)|955[0-4])|7(?:26(?:6[13-9]|7[0-7])|442\\d|50(?:2[0-3]|[3-68]2|76))|8(?:27[56]\\d|37(?:5[2-5]|8[239])|84(?:3[2-58]))|9(?:0(?:0(?:6[1-8]|85)|52\\d)|3583|4(?:66[1-8]|9(?:2[01]|81))|63(?:23|3[1-4])|9561))\\d{3}|176888[2-46-8]\\d{2}|16977[23]\\d{3}",
  37538. ,,,"1212345678",,,[9,10],[4,5,6,7,8]],[,,"7(?:[1-3]\\d{3}|4(?:[0-46-9]\\d{2}|5(?:[0-689]\\d|7[0-57-9]))|5(?:0[0-8]|[13-9]\\d|2[0-35-9])\\d|7(?:0(?:0[01]|[1-9]\\d)|[1-7]\\d{2}|8[02-9]\\d|9[0-689]\\d)|8(?:[014-9]\\d|[23][0-8])\\d|9(?:[024-9]\\d{2}|1(?:[02-9]\\d|1[028])|3[0-689]\\d))\\d{5}",,,,"7400123456",,,[10]],[,,"80(?:0(?:1111|\\d{6,7})|8\\d{7})|500\\d{6}",,,,"8001234567"],[,,"(?:87[123]|9(?:[01]\\d|8[2349]))\\d{7}",,,,"9012345678",,,[10]],[,,"8(?:4(?:5464\\d|[2-5]\\d{7})|70\\d{7})",,,,"8431234567",
  37539. ,,[7,10]],[,,"70\\d{8}",,,,"7012345678",,,[10]],[,,"56\\d{8}",,,,"5612345678",,,[10]],"GB",44,"00","0"," x",,"0",,,,[[,"(7\\d{3})(\\d{6})","$1 $2",["7(?:[1-57-9]|62)","7(?:[1-57-9]|624)"],"0$1"],[,"(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["2|5[56]|7[06]"],"0$1"],[,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1(?:1|\\d1)|3|9[018]"],"0$1"],[,"(\\d{5})(\\d{4,5})","$1 $2",["1(?:38|5[23]|69|76|94)","1(?:387|5(?:24|39)|697|768|946)","1(?:3873|5(?:242|39[456])|697[347]|768[347]|9467)"],"0$1"],[,"(1\\d{3})(\\d{5,6})",
  37540. "$1 $2",["1"],"0$1"],[,"(800)(\\d{4})","$1 $2",["800","8001","80011","800111","8001111"],"0$1"],[,"(845)(46)(4\\d)","$1 $2 $3",["845","8454","84546","845464"],"0$1"],[,"(8\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["8(?:4[2-5]|7[0-3])"],"0$1"],[,"(80\\d)(\\d{3})(\\d{4})","$1 $2 $3",["80"],"0$1"],[,"([58]00)(\\d{6})","$1 $2",["[58]00"],"0$1"]],,[,,"76(?:0[012]|2[356]|4[0134]|5[49]|6[0-369]|77|81|9[39])\\d{6}",,,,"7640123456",,,[10]],1,,[,,,,,,,,,[-1]],[,,"(?:3[0347]|55)\\d{8}",,,,"5512345678",,,[10]],,,[,
  37541. ,,,,,,,,[-1]]],GD:[,[,,"[4589]\\d{9}",,,,,,,[10],[7]],[,,"473(?:2(?:3[0-2]|69)|3(?:2[89]|86)|4(?:[06]8|3[5-9]|4[0-49]|5[5-79]|68|73|90)|63[68]|7(?:58|84)|800|938)\\d{4}",,,,"4732691234",,,,[7]],[,,"473(?:4(?:0[2-79]|1[04-9]|2[0-5]|58)|5(?:2[01]|3[3-8])|901)\\d{4}",,,,"4734031234",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002123456"],[,,"900[2-9]\\d{6}",,,,"9002123456"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"GD",1,"011","1",,,"1",,,
  37542. ,,,[,,,,,,,,,[-1]],,"473",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],GE:[,[,,"[34578]\\d{8}",,,,,,,[9],[6]],[,,"(?:3(?:[256]\\d|4[124-9]|7[0-4])|4(?:1\\d|2[2-7]|3[1-79]|4[2-8]|7[239]|9[1-7]))\\d{6}",,,,"322123456",,,,[6]],[,,"5(?:[14]4|5[0157-9]|68|7[0147-9]|9[0-35-9])\\d{6}",,,,"555123456"],[,,"800\\d{6}",,,,"800123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"706\\d{6}",,,,"706123456"],"GE",995,"00","0",,,"0",,,,[[,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[348]"],"0$1"],
  37543. [,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"],"0$1"],[,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5"],"$1"]],,[,,,,,,,,,[-1]],,,[,,"706\\d{6}",,,,"706123456"],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],GF:[,[,,"[56]\\d{8}",,,,,,,[9]],[,,"594(?:10|2[012457-9]|3[0-57-9]|4[3-9]|5[7-9]|6[0-3]|9[014])\\d{4}",,,,"594101234"],[,,"694(?:[0249]\\d|1[2-9]|3[0-48])\\d{4}",,,,"694201234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"GF",594,"00","0",,,"0",,,,[[,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})",
  37544. "$1 $2 $3 $4",,"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],GG:[,[,,"[135789]\\d{6,9}",,,,,,,[7,9,10],[6]],[,,"1481[25-9]\\d{5}",,,,"1481256789",,,[10],[6]],[,,"7(?:781\\d|839\\d|911[17])\\d{5}",,,,"7781123456",,,[10]],[,,"80(?:0(?:1111|\\d{6,7})|8\\d{7})|500\\d{6}",,,,"8001234567"],[,,"(?:87[123]|9(?:[01]\\d|8[0-3]))\\d{7}",,,,"9012345678",,,[10]],[,,"8(?:4(?:5464\\d|[2-5]\\d{7})|70\\d{7})",,,,"8431234567",,,[7,10]],[,,"70\\d{8}",,,,"7012345678",,,[10]],[,,"56\\d{8}",
  37545. ,,,"5612345678",,,[10]],"GG",44,"00","0",,,"0",,,,,,[,,"76(?:0[012]|2[356]|4[0134]|5[49]|6[0-369]|77|81|9[39])\\d{6}",,,,"7640123456",,,[10]],,,[,,,,,,,,,[-1]],[,,"(?:3[0347]|55)\\d{8}",,,,"5512345678",,,[10]],,,[,,,,,,,,,[-1]]],GH:[,[,,"[235]\\d{8}|8\\d{7}",,,,,,,[8,9],[7]],[,,"3(?:0(?:[237]\\d|80)|[167](?:2[0-6]|7\\d|80)|2(?:2[0-5]|7\\d|80)|3(?:2[0-3]|7\\d|80)|4(?:2[013-9]|3[01]|7\\d|80)|5(?:2[0-7]|7\\d|80)|8(?:2[0-2]|7\\d|80)|9(?:[28]0|7\\d))\\d{5}",,,,"302345678",,,[9],[7]],[,,"(?:2[034678]\\d|5(?:[0457]\\d|6[01]))\\d{6}",
  37546. ,,,"231234567",,,[9]],[,,"800\\d{5}",,,,"80012345",,,[8]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"GH",233,"00","0",,,"0",,,,[[,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[235]"],"0$1"],[,"(\\d{3})(\\d{5})","$1 $2",["8"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,"800\\d{5}",,,,"80012345",,,[8]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],GI:[,[,,"[256]\\d{7}",,,,,,,[8]],[,,"2(?:00\\d{2}|1(?:6[24-7]\\d|90[0-2])|2(?:2[2457]\\d|50[0-2]))\\d{3}",,,,"20012345"],[,,"(?:5[46-8]|62)\\d{6}",,,,"57123456"],
  37547. [,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"GI",350,"00",,,,,,,,[[,"(\\d{3})(\\d{5})","$1 $2",["2"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],GL:[,[,,"[1-689]\\d{5}",,,,,,,[6]],[,,"(?:19|3[1-6]|6[14689]|8[14-79]|9\\d)\\d{4}",,,,"321000"],[,,"[245][2-9]\\d{4}",,,,"221234"],[,,"80\\d{4}",,,,"801234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"3[89]\\d{4}",,,,"381234"],"GL",299,"00",,,,,,,,[[,"(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3"]],
  37548. ,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],GM:[,[,,"[2-9]\\d{6}",,,,,,,[7]],[,,"(?:4(?:[23]\\d{2}|4(?:1[024679]|[6-9]\\d))|5(?:54[0-7]|6(?:[67]\\d)|7(?:1[04]|2[035]|3[58]|48))|8\\d{3})\\d{3}",,,,"5661234"],[,,"[23679]\\d{6}",,,,"3012345"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"GM",220,"00",,,,,,,,[[,"(\\d{3})(\\d{4})","$1 $2"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],GN:[,[,,"[367]\\d{7,8}",,,,,,,[8,
  37549. 9]],[,,"30(?:24|3[12]|4[1-35-7]|5[13]|6[189]|[78]1|9[1478])\\d{4}",,,,"30241234",,,[8]],[,,"6[02356]\\d{7}",,,,"601123456",,,[9]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"722\\d{6}",,,,"722123456",,,[9]],"GN",224,"00",,,,,,,,[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["3"]],[,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[67]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],GP:[,[,,"[56]\\d{8}",,,,,,,[9]],[,,"590(?:0[13468]|1[012]|2[0-68]|3[28]|4[0-8]|5[579]|6[0189]|70|8[0-689]|9\\d)\\d{4}",
  37550. ,,,"590201234"],[,,"690(?:0[05-9]|[1-9]\\d)\\d{4}",,,,"690001234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"GP",590,"00","0",,,"0",,,,[[,"([56]90)(\\d{2})(\\d{4})","$1 $2-$3",,"0$1"]],,[,,,,,,,,,[-1]],1,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],GQ:[,[,,"[23589]\\d{8}",,,,,,,[9]],[,,"3(?:3(?:3\\d[7-9]|[0-24-9]\\d[46])|5\\d{2}[7-9])\\d{4}",,,,"333091234"],[,,"(?:222|55[15])\\d{6}",,,,"222123456"],[,,"80\\d[1-9]\\d{5}",,,,"800123456"],[,,"90\\d[1-9]\\d{5}",
  37551. ,,,"900123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"GQ",240,"00",,,,,,,,[[,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235]"]],[,"(\\d{3})(\\d{6})","$1 $2",["[89]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],GR:[,[,,"[26-9]\\d{9}",,,,,,,[10]],[,,"2(?:1\\d{2}|2(?:2[1-46-9]|3[1-8]|4[1-7]|5[1-4]|6[1-8]|7[1-5]|[89][1-9])|3(?:1\\d|2[1-57]|[35][1-3]|4[13]|7[1-7]|8[124-6]|9[1-79])|4(?:1\\d|2[1-8]|3[1-4]|4[13-5]|6[1-578]|9[1-5])|5(?:1\\d|[29][1-4]|3[1-5]|4[124]|5[1-6])|6(?:1\\d|3[1245]|4[1-7]|5[13-9]|[269][1-6]|7[14]|8[1-5])|7(?:1\\d|2[1-5]|3[1-6]|4[1-7]|5[1-57]|6[135]|9[125-7])|8(?:1\\d|2[1-5]|[34][1-4]|9[1-57]))\\d{6}",
  37552. ,,,"2123456789"],[,,"69\\d{8}",,,,"6912345678"],[,,"800\\d{7}",,,,"8001234567"],[,,"90[19]\\d{7}",,,,"9091234567"],[,,"8(?:0[16]|12|25)\\d{7}",,,,"8011234567"],[,,"70\\d{8}",,,,"7012345678"],[,,,,,,,,,[-1]],"GR",30,"00",,,,,,,,[[,"([27]\\d)(\\d{4})(\\d{4})","$1 $2 $3",["21|7"]],[,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["2[2-9]1|[689]"]],[,"(2\\d{3})(\\d{6})","$1 $2",["2[2-9][02-9]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],GT:[,[,,"[2-7]\\d{7}|1[89]\\d{9}",,,,,,,[8,11]],
  37553. [,,"[267][2-9]\\d{6}",,,,"22456789",,,[8]],[,,"[345]\\d{7}",,,,"51234567",,,[8]],[,,"18[01]\\d{8}",,,,"18001112222",,,[11]],[,,"19\\d{9}",,,,"19001112222",,,[11]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"GT",502,"00",,,,,,,,[[,"(\\d{4})(\\d{4})","$1 $2",["[2-7]"]],[,"(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],GU:[,[,,"[5689]\\d{9}",,,,,,,[10],[7]],[,,"671(?:3(?:00|3[39]|4[349]|55|6[26])|4(?:56|7[1-9]|8[0236-9])|5(?:55|6[2-5]|88)|6(?:3[2-578]|4[24-9]|5[34]|78|8[5-9])|7(?:[079]7|2[0167]|3[45]|47|8[789])|8(?:[2-5789]8|6[48])|9(?:2[29]|6[79]|7[179]|8[789]|9[78]))\\d{4}",
  37554. ,,,"6713001234",,,,[7]],[,,"671(?:3(?:00|3[39]|4[349]|55|6[26])|4(?:56|7[1-9]|8[0236-9])|5(?:55|6[2-5]|88)|6(?:3[2-578]|4[24-9]|5[34]|78|8[5-9])|7(?:[079]7|2[0167]|3[45]|47|8[789])|8(?:[2-5789]8|6[48])|9(?:2[29]|6[79]|7[179]|8[789]|9[78]))\\d{4}",,,,"6713001234",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002123456"],[,,"900[2-9]\\d{6}",,,,"9002123456"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"GU",1,"011","1",,,"1",,,1,,,[,,,,,,,,,[-1]],
  37555. ,"671",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],GW:[,[,,"(?:4(?:0\\d{5}|4\\d{7})|9\\d{8})",,,,,,,[7,9]],[,,"443\\d{6}",,,,"443201234",,,[9]],[,,"9(?:5(?:5\\d|6[0-2])|6(?:5[0-2]|6\\d|9[012])|77\\d)\\d{5}",,,,"955012345",,,[9]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"40\\d{5}",,,,"4012345",,,[7]],"GW",245,"00",,,,,,,,[[,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["44|9[567]"]],[,"(\\d{3})(\\d{4})","$1 $2",["40"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,
  37556. ,[,,,,,,,,,[-1]]],GY:[,[,,"[2-46-9]\\d{6}",,,,,,,[7]],[,,"(?:2(?:1[6-9]|2[0-35-9]|3[1-4]|5[3-9]|6\\d|7[0-24-79])|3(?:2[25-9]|3\\d)|4(?:4[0-24]|5[56])|77[1-57])\\d{4}",,,,"2201234"],[,,"6\\d{6}",,,,"6091234"],[,,"(?:289|862)\\d{4}",,,,"2891234"],[,,"9008\\d{3}",,,,"9008123"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"GY",592,"001",,,,,,,,[[,"(\\d{3})(\\d{4})","$1 $2"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],HK:[,[,,"[235-7]\\d{7}|8\\d{7,8}|9\\d{4,10}",,,,,,,[5,
  37557. 6,7,8,9,11]],[,,"(?:2(?:[13-8]\\d|2[013-9]|9[0-24-9])|3(?:[1569][0-24-9]|4[0-246-9]|7[0-24-69]|89)|58[01])\\d{5}",,,,"21234567",,,[8]],[,,"(?:5(?:[1-59][0-46-9]|6[0-4689]|7[0-469])|6(?:0[1-9]|[1459]\\d|[2368][0-57-9]|7[0-79])|9(?:0[1-9]|1[02-9]|[2358][0-8]|[467]\\d))\\d{5}",,,,"51234567",,,[8]],[,,"800\\d{6}",,,,"800123456",,,[9]],[,,"900(?:[0-24-9]\\d{7}|3\\d{1,4})",,,,"90012345678",,,[5,6,7,8,11]],[,,,,,,,,,[-1]],[,,"8(?:1[1-4679]|2[0-367]|3[02-47])\\d{5}",,,,"81123456",,,[8]],[,,,,,,,,,[-1]],"HK",
  37558. 852,"00(?:[126-9]|30|5[09])?",,,,,,"00",,[[,"(\\d{4})(\\d{4})","$1 $2",["[235-7]|[89](?:0[1-9]|[1-9])"]],[,"(800)(\\d{3})(\\d{3})","$1 $2 $3",["800"]],[,"(900)(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["900"]],[,"(900)(\\d{2,5})","$1 $2",["900"]]],,[,,"7(?:1[0-369]|[23][0-37-9]|47|5[1578]|6[0235]|7[278]|8[236-9]|9[025-9])\\d{5}",,,,"71234567",,,[8]],,,[,,,,,,,,,[-1]],[,,"30(?:0[1-9]|[15-7]\\d|2[047]|89)\\d{4}",,,,"30161234",,,[8]],,,[,,,,,,,,,[-1]]],HN:[,[,,"[237-9]\\d{7}",,,,,,,[8]],[,,"2(?:2(?:0[019]|1[1-36]|[23]\\d|4[04-6]|5[57]|7[01389]|8[0146-9]|9[012])|4(?:07|2[3-59]|3[13-689]|4[0-68]|5[1-35])|5(?:16|4[03-5]|5\\d|6[4-6]|74)|6(?:[056]\\d|17|3[04]|4[0-378]|[78][0-8]|9[01])|7(?:6[46-9]|7[02-9]|8[034])|8(?:79|8[0-35789]|9[1-57-9]))\\d{4}",
  37559. ,,,"22123456"],[,,"[37-9]\\d{7}",,,,"91234567"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"HN",504,"00",,,,,,,,[[,"(\\d{4})(\\d{4})","$1-$2"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],HR:[,[,,"[1-7]\\d{5,8}|[89]\\d{6,8}",,,,,,,[6,7,8,9]],[,,"1\\d{7}|(?:2[0-3]|3[1-5]|4[02-47-9]|5[1-3])\\d{6,7}",,,,"12345678",,,[8,9],[6,7]],[,,"9(?:01\\d|[1259]\\d{2}|7(?:[0679]\\d|51)|8\\d{1,2})\\d{5}",,,,"921234567",,,[8,9]],[,,"80[01]\\d{4,6}",,,,
  37560. "800123456",,,[7,8,9]],[,,"6(?:[01]\\d{0,2}|[459]\\d{2})\\d{4}",,,,"611234",,,[6,7,8]],[,,,,,,,,,[-1]],[,,"7[45]\\d{6}",,,,"74123456",,,[8]],[,,,,,,,,,[-1]],"HR",385,"00","0",,,"0",,,,[[,"(1)(\\d{4})(\\d{3})","$1 $2 $3",["1"],"0$1"],[,"([2-5]\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-5]"],"0$1"],[,"(9\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],[,"(6[01])(\\d{2})(\\d{2,3})","$1 $2 $3",["6[01]"],"0$1"],[,"([67]\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[67]"],"0$1"],[,"(80[01])(\\d{2})(\\d{2,3})","$1 $2 $3",
  37561. ["8"],"0$1"],[,"(80[01])(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"(?:62\\d?|72)\\d{6}",,,,"62123456",,,[8,9]],,,[,,,,,,,,,[-1]]],HT:[,[,,"[2-489]\\d{7}",,,,,,,[8]],[,,"2(?:2\\d|5[1-5]|81|9[149])\\d{5}",,,,"22453300"],[,,"[34]\\d{7}",,,,"34101234"],[,,"8\\d{7}",,,,"80012345"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"(?:9(?:[67][0-4]|8[0-3589]|9\\d))\\d{5}",,,,"98901234"],"HT",509,"00",,,,,,,,[[,"(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3"]],,[,,,,,,,,,[-1]],
  37562. ,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],HU:[,[,,"[1-9]\\d{7,8}",,,,,,,[8,9],[6]],[,,"(?:1\\d|2[2-9]|3[2-7]|4[24-9]|5[2-79]|6[23689]|7[2-9]|8[2-57-9]|9[2-69])\\d{6}",,,,"12345678",,,[8],[6]],[,,"(?:[257]0|3[01])\\d{7}",,,,"201234567",,,[9]],[,,"[48]0\\d{6}",,,,"80123456",,,[8]],[,,"9[01]\\d{6}",,,,"90123456",,,[8]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"21\\d{7}",,,,"211234567",,,[9]],"HU",36,"00","06",,,"06",,,,[[,"(1)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"($1)"],[,"(\\d{2})(\\d{3})(\\d{3,4})",
  37563. "$1 $2 $3",["[2-9]"],"($1)"]],,[,,,,,,,,,[-1]],,,[,,"[48]0\\d{6}",,,,"80123456",,,[8]],[,,"38\\d{7}",,,,"381234567",,,[9]],,,[,,,,,,,,,[-1]]],ID:[,[,,"(?:[1-79]\\d{6,10}|8\\d{7,11})",,,,,,,[7,8,9,10,11,12],[5,6]],[,,"2(?:1(?:14\\d{3}|[0-8]\\d{6,7}|500\\d{3}|9\\d{6})|2\\d{6,8}|4\\d{7,8})|(?:2(?:[35][1-4]|6[0-8]|7[1-6]|8\\d|9[1-8])|3(?:1|[25][1-8]|3[1-68]|4[1-3]|6[1-3568]|7[0-469]|8\\d)|4(?:0[1-589]|1[01347-9]|2[0-36-8]|3[0-24-68]|43|5[1-378]|6[1-5]|7[134]|8[1245])|5(?:1[1-35-9]|2[25-8]|3[124-9]|4[1-3589]|5[1-46]|6[1-8])|6(?:19?|[25]\\d|3[1-69]|4[1-6])|7(?:02|[125][1-9]|[36]\\d|4[1-8]|7[0-36-9])|9(?:0[12]|1[013-8]|2[0-479]|5[125-8]|6[23679]|7[159]|8[01346]))\\d{5,8}",
  37564. ,,,"612345678",,,[7,8,9,10,11],[5,6]],[,,"(?:2(?:1(?:3[145]|4[01]|5[1-469]|60|8[0359]|9\\d)|2(?:88|9[1256])|3[1-4]9|4(?:36|91)|5(?:1[349]|[2-4]9)|6[0-7]9|7(?:[1-36]9|4[39])|8[1-5]9|9[1-48]9)|3(?:19[1-3]|2[12]9|3[13]9|4(?:1[69]|39)|5[14]9|6(?:1[69]|2[89])|709)|4[13]19|5(?:1(?:19|8[39])|4[129]9|6[12]9)|6(?:19[12]|2(?:[23]9|77))|7(?:1[13]9|2[15]9|419|5(?:1[89]|29)|6[15]9|7[178]9))\\d{5,6}|8[1-35-9]\\d{7,10}",,,,"812345678",,,[9,10,11,12]],[,,"177\\d{6,8}|800\\d{5,7}",,,,"8001234567",,,[8,9,10,11]],[,
  37565. ,"809\\d{7}",,,,"8091234567",,,[10]],[,,"804\\d{7}",,,,"8041234567",,,[10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"ID",62,"0(?:0[1789]|10(?:00|1[67]))","0",,,"0",,,,[[,"(\\d{2})(\\d{5,8})","$1 $2",["2[124]|[36]1"],"(0$1)"],[,"(\\d{3})(\\d{5,8})","$1 $2",["[4579]|2[035-9]|[36][02-9]"],"(0$1)"],[,"(8\\d{2})(\\d{3,4})(\\d{3})","$1-$2-$3",["8[1-35-9]"],"0$1"],[,"(8\\d{2})(\\d{4})(\\d{4,5})","$1-$2-$3",["8[1-35-9]"],"0$1"],[,"(1)(500)(\\d{3})","$1 $2 $3",["15"],"$1"],[,"(177)(\\d{6,8})","$1 $2",["17"],"0$1"],
  37566. [,"(800)(\\d{5,7})","$1 $2",["800"],"0$1"],[,"(804)(\\d{3})(\\d{4})","$1 $2 $3",["804"],"0$1"],[,"(80\\d)(\\d)(\\d{3})(\\d{3})","$1 $2 $3 $4",["80[79]"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,"8071\\d{6}",,,,"8071123456",,,[10]],[,,"1500\\d{3}|8071\\d{6}",,,,"8071123456",,,[7,10]],,,[,,,,,,,,,[-1]]],IE:[,[,,"[124-9]\\d{6,9}",,,,,,,[7,8,9,10],[5,6]],[,,"1\\d{7,8}|2(?:1\\d{6,7}|3\\d{7}|[24-9]\\d{5})|4(?:0[24]\\d{5}|[1-469]\\d{7}|5\\d{6}|7\\d{5}|8[0-46-9]\\d{7})|5(?:0[45]\\d{5}|1\\d{6}|[23679]\\d{7}|8\\d{5})|6(?:1\\d{6}|[237-9]\\d{5}|[4-6]\\d{7})|7[14]\\d{7}|9(?:1\\d{6}|[04]\\d{7}|[35-9]\\d{5})",
  37567. ,,,"2212345",,,,[5,6]],[,,"8(?:22\\d{6}|[35-9]\\d{7})",,,,"850123456",,,[9]],[,,"1800\\d{6}",,,,"1800123456",,,[10]],[,,"15(?:1[2-8]|[2-8]0|9[089])\\d{6}",,,,"1520123456",,,[10]],[,,"18[59]0\\d{6}",,,,"1850123456",,,[10]],[,,"700\\d{6}",,,,"700123456",,,[9]],[,,"76\\d{7}",,,,"761234567",,,[9]],"IE",353,"00","0",,,"0",,,,[[,"(1)(\\d{3,4})(\\d{4})","$1 $2 $3",["1"],"(0$1)"],[,"(\\d{2})(\\d{5})","$1 $2",["2[24-9]|47|58|6[237-9]|9[35-9]"],"(0$1)"],[,"(\\d{3})(\\d{5})","$1 $2",["40[24]|50[45]"],"(0$1)"],
  37568. [,"(48)(\\d{4})(\\d{4})","$1 $2 $3",["48"],"(0$1)"],[,"(818)(\\d{3})(\\d{3})","$1 $2 $3",["81"],"(0$1)"],[,"(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[24-69]|7[14]"],"(0$1)"],[,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["76|8[35-9]"],"0$1"],[,"(8\\d)(\\d)(\\d{3})(\\d{4})","$1 $2 $3 $4",["8[35-9]5"],"0$1"],[,"(700)(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],[,"(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:8[059]|5)","1(?:8[059]0|5)"],"$1"]],,[,,,,,,,,,[-1]],,,[,,"18[59]0\\d{6}",,,,"1850123456",,,[10]],[,,"818\\d{6}",
  37569. ,,,"818123456",,,[9]],,,[,,"8[35-9]5\\d{7}",,,,"8551234567",,,[10]]],IL:[,[,,"1\\d{6,11}|[2-589]\\d{3}(?:\\d{3,6})?|6\\d{3}|7\\d{6,9}",,,,,,,[4,7,8,9,10,11,12]],[,,"(?:153\\d{1,2}|[2-489])\\d{7}",,,,"21234567",,,[8,11,12],[7]],[,,"5(?:[0-47-9]\\d{2}|5(?:01|2[23]|3[2-4]|4[45]|5[5689]|6[6-8]|7[0178]|8[6-9]|9[2-9])|6[2-9]\\d)\\d{5}",,,,"501234567",,,[9]],[,,"1(?:80[019]\\d{3}|255)\\d{3}",,,,"1800123456",,,[7,10]],[,,"1(?:212|(?:9(?:0[01]|19)|200)\\d{2})\\d{4}",,,,"1919123456",,,[8,9,10]],[,,"1700\\d{6}",
  37570. ,,,"1700123456",,,[10]],[,,,,,,,,,[-1]],[,,"7(?:18\\d|2[23]\\d|3[237]\\d|47\\d|6[58]\\d|7\\d{2}|8(?:2\\d|33|55|77|81)|9[2579]\\d)\\d{5}",,,,"771234567",,,[9]],"IL",972,"0(?:0|1[2-9])","0",,,"0",,,,[[,"([2-489])(\\d{3})(\\d{4})","$1-$2-$3",["[2-489]"],"0$1"],[,"([57]\\d)(\\d{3})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],[,"(153)(\\d{1,2})(\\d{3})(\\d{4})","$1 $2 $3 $4",["153"],"$1"],[,"(1)([7-9]\\d{2})(\\d{3})(\\d{3})","$1-$2-$3-$4",["1[7-9]"],"$1"],[,"(1255)(\\d{3})","$1-$2",["125"],"$1"],[,"(1200)(\\d{3})(\\d{3})",
  37571. "$1-$2-$3",["120"],"$1"],[,"(1212)(\\d{2})(\\d{2})","$1-$2-$3",["121"],"$1"],[,"(1599)(\\d{6})","$1-$2",["1599"],"$1"],[,"(151)(\\d{1,2})(\\d{3})(\\d{4})","$1-$2 $3-$4",["151"],"$1"],[,"(\\d{4})","*$1",["[2-689]"],"$1"]],,[,,,,,,,,,[-1]],,,[,,"1700\\d{6}|[2-689]\\d{3}",,,,"1700123456",,,[4,10]],[,,"[2-689]\\d{3}|1599\\d{6}",,,,"1599123456",,,[4,10]],,,[,,"151\\d{8,9}",,,,"15112340000",,,[11,12]]],IM:[,[,,"[135789]\\d{6,9}",,,,,,,[10],[6]],[,,"1624[5-8]\\d{5}",,,,"1624756789",,,,[6]],[,,"7(?:4576|[59]24\\d|624[2-4])\\d{5}",
  37572. ,,,"7924123456"],[,,"808162\\d{4}",,,,"8081624567"],[,,"(?:872299|90[0167]624)\\d{4}",,,,"9016247890"],[,,"8(?:4(?:40[49]06|5624\\d)|70624\\d)\\d{3}",,,,"8456247890"],[,,"70\\d{8}",,,,"7012345678"],[,,"56\\d{8}",,,,"5612345678"],"IM",44,"00","0",,,"0",,,,,,[,,"7624[01689]\\d{5}",,,,"7624012345"],,,[,,,,,,,,,[-1]],[,,"3(?:08162\\d|3\\d{5}|4(?:40[49]06|5624\\d)|7(?:0624\\d|2299\\d))\\d{3}|55\\d{8}",,,,"5512345678"],,,[,,,,,,,,,[-1]]],IN:[,[,,"008\\d{9}|1\\d{7,12}|[2-9]\\d{9,10}",,,,,,,[8,9,10,11,12,
  37573. 13],[6,7]],[,,"(?:11|2[02]|33|4[04]|79)[2-7]\\d{7}|3880\\d{6}|80[2-467]\\d{7}|(?:1(?:2[0-249]|3[0-25]|4[145]|[59][14]|6[014]|7[1257]|8[01346])|2(?:1[257]|3[013]|4[01]|5[0137]|6[0158]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|[36][25]|22|4[28]|5[12]|[78]1|9[15])|6(?:12|[2345]1|57|6[13]|7[14]|80)|7(?:12|2[14]|3[134]|4[47]|5[15]|[67]1|88)|8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91))[2-7]\\d{6}|(?:(?:1(?:2[35-8]|3[346-9]|4[236-9]|[59][0235-9]|6[235-9]|7[34689]|8[257-9])|2(?:1[134689]|3[24-8]|4[2-8]|5[25689]|6[2-4679]|7[13-79]|8[2-479]|9[235-9])|3(?:01|1[79]|2[1-5]|4[25-8]|5[125689]|6[235-7]|7[157-9]|8[2-467])|4(?:1[14578]|2[5689]|3[2-467]|5[4-7]|6[35]|73|8[2689]|9[2389])|5(?:[16][146-9]|2[14-8]|3[1346]|4[14-69]|5[46]|7[2-4]|8[2-8]|9[246])|6(?:1[1358]|2[2457]|3[2-4]|4[235-7]|[57][2-689]|6[24-578]|8[1-6])|8(?:1[1357-9]|2[235-8]|3[03-57-9]|4[0-24-9]|5\\d|6[2457-9]|7[1-6]|8[1256]|9[2-4]))\\d|7(?:(?:1[013-9]|2[0235-9]|3[2679]|4[1-35689]|5[2-46-9]|[67][02-9]|9\\d)\\d|8(?:2[0-6]|[013-8]\\d)))[2-7]\\d{5}",
  37574. ,,,"1123456789",,,[10],[6,7,8]],[,,"(?:600[1-3]\\d|7(?:0\\d{3}|19[0-5]\\d|2(?:[0235679]\\d{2}|[14][017-9]\\d|8(?:[0-59]\\d|[678][089]))|3(?:[05-8]\\d{2}|1(?:[089]\\d|11|7[5-8])|2(?:[0-49][089]|[5-8]\\d)|3[017-9]\\d|4(?:[07-9]\\d|11)|9(?:[016-9]\\d|[2-5][089]))|4(?:0\\d{2}|1(?:[015-9]\\d|[23][089]|4[089])|2(?:0[089]|[1-7][089]|[89]\\d)|3(?:[0-8][089]|9\\d)|4(?:[089]\\d|11|7[02-8])|[56]\\d[089]|7(?:[089]\\d|11|7[02-8])|8(?:[0-24-7][089]|[389]\\d)|9(?:[0-6][089]|7[089]|[89]\\d))|5(?:[0346-8]\\d{2}|1(?:[07-9]\\d|11)|2(?:[04-9]\\d|[123][089])|5[017-9]\\d|9(?:[0-6][089]|[7-9]\\d))|6(?:0(?:[0-47]\\d|[5689][089])|(?:1[0-257-9]|[6-9]\\d)\\d|2(?:[0-4]\\d|[5-9][089])|3(?:[02-8][089]|[19]\\d)|4\\d[089]|5(?:[0-367][089]|[4589]\\d))|7(?:0(?:0[02-9]|[13-6][089]|[289]\\d|7[89])|[1-9]\\d{2})|8(?:[0-79]\\d{2}|8(?:[089]\\d|11|7[02-9]))|9(?:[089]\\d{2}|313|7(?:[02-8]\\d|9[07-9])))|8(?:0(?:[01589]\\d{2}|6[67]\\d|7(?:[02-8]\\d|9[05-9]))|1(?:[02-57-9]\\d{2}|1(?:[0-35-9]\\d|4[0-46-9])|6(?:[089]\\d|7[02-8]))|2(?:0(?:[089]\\d|7[02])|[14](?:[089]\\d|7[02-8])|[235-9]\\d{2})|3(?:[0357-9]\\d{2}|1(?:[089]\\d|7[02-6])|2(?:[09]\\d|77|8[0-689])|4(?:0[1-7]|[1-9]\\d)|6(?:[089]\\d|7[02-7]))|[45]\\d{3}|6(?:[02457-9]\\d{2}|1(?:[089]\\d|7[02-8])|3(?:[089]\\d|7[02-8])|6(?:[08]\\d|7[02-8]|9\\d))|7(?:0[07-9]\\d|[1-69]\\d{2}|[78](?:[089]\\d|7[02-8]))|8(?:[0-25-9]\\d{2}|3(?:[089]\\d|7[02-8])|4(?:[0489]\\d|7[02-68]))|9(?:[02-9]\\d{2}|1(?:[0289]\\d|7[2-6])))|9\\d{4})\\d{5}",
  37575. ,,,"8123456789",,,[10]],[,,"00800\\d{7}|1(?:600\\d{6}|80(?:0\\d{4,9}|3\\d{9}))",,,,"1800123456"],[,,"186[12]\\d{9}",,,,"1861123456789",,,[13]],[,,"1860\\d{7}",,,,"18603451234",,,[11]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"IN",91,"00","0",,,"0",,,,[[,"(\\d{8})","$1",["561","5616","56161"],"$1",,1],[,"(\\d{5})(\\d{5})","$1 $2",["600|7(?:[02-8]|19|9[037-9])|8(?:0[015-9]|[1-9])|9","600|7(?:[078]|19[0-5]|2(?:[02356-9]|[14][017-9]|9[389])|3(?:[025-9]|1[017-9]|[34][017-9])|4(?:[0-35689]|[47][017-9])|5(?:[02346-9]|1[017-9]|5[017-9])|6(?:[02-9]|1[0-257-9])|9(?:[089]|31|7[02-9]))|8(?:0(?:[01589]|6[67]|7[02-9])|1(?:[0-57-9]|6[07-9])|2(?:0[07-9]|[14][07-9]|[235-9])|3(?:[03-57-9]|[126][07-9])|[45]|6(?:[02457-9]|[136][07-9])|7(?:[078][07-9]|[1-69])|8(?:[0-25-9]|3[07-9]|4[047-9])|9(?:[02-9]|1[027-9]))|9",
  37576. "600|7(?:0|19[0-5]|2(?:[0235679]|[14][017-9]|8(?:[0-569]|[78][089])|9[389])|3(?:[05-8]|1(?:[0189]|7[5-9])|2(?:[5-8]|[0-49][089])|3[017-9]|4(?:[07-9]|11)|9(?:[01689]|[2345][089]|40|7[0189]))|4(?:[056]|1(?:[0135-9]|[23][089]|2[089]|4[089])|2(?:0[089]|[1-7][089]|[89])|3(?:[0-8][089]|9)|4(?:[089]|11|7[02-8])|7(?:[089]|11|7[02-8])|8(?:[0-24-7][089]|[389])|9(?:[0-7][089]|[89]))|5(?:[0346-9]|1[017-9]|2(?:[03-9]|[12][089])|5[017-9])|6(?:[0346-9]|1[0-257-9]|2(?:[0-4]\\d|[5-9][089])|5(?:[0-367][089]|[4589]))|7(?:0(?:[02-9]|1[089])|[1-9])|8(?:[0-79]|8(?:0[0189]|11|8[013-9]|9))|9(?:[089]|313|7(?:[02-8]|9[07-9])))|8(?:0(?:[01589]|6[67]|7(?:[02-8]|9[05-9]))|1(?:[02-57-9]|1(?:[0-35-9]|4[0-46-9])|6(?:[089]|7[02-8]))|2(?:0(?:[089]|7[02])|[14](?:[089]|7[02-8])|[235-9])|3(?:[0357-9]|1(?:[089]|7[02-6])|2(?:[09]|77|8[0-689])|4(?:0[1-7]|[1-9])|6(?:[089]|7[02-7]))|[45]|6(?:[02457-9]|1(?:[089]|7[02-8])|3(?:[089]|7[02-8])|6(?:[08]|7[02-8]|9\\d))|7(?:0[07-9]|[1-69]|7(?:[089]|7[02-8])|8(?:[089]|7[02-8]))|8(?:[0-25-9]|3(?:[089]|7[02-8])|4(?:[0489]|7[02-68]))|9(?:[02-9]|1(?:[0289]|7[2-6])))|9"],
  37577. "0$1",,1],[,"(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["11|2[02]|33|4[04]|79[1-9]|80[2-46]"],"0$1",,1],[,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1(?:2[0-249]|3[0-25]|4[145]|[59][14]|7[1257]|[68][1-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[0158]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|[36][25]|22|4[28]|5[12]|[78]1|9[15])|6(?:12|[2-4]1|5[17]|6[13]|7[14]|80)|7(?:12|2[14]|3[134]|4[47]|5[15]|[67]1|88)|8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91)"],
  37578. "0$1",,1],[,"(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:[23579]|[468][1-9])|[2-8]"],"0$1",,1],[,"(\\d{2})(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3 $4",["008"],"0$1",,1],[,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["140"],"$1",,1],[,"(\\d{4})(\\d{2})(\\d{4})","$1 $2 $3",["160","1600"],"$1",,1],[,"(\\d{4})(\\d{4,5})","$1 $2",["180","1800"],"$1",,1],[,"(\\d{4})(\\d{2,4})(\\d{4})","$1 $2 $3",["180","1800"],"$1",,1],[,"(\\d{4})(\\d{3,4})(\\d{4})","$1 $2 $3",["186","1860"],"$1",,1],[,"(\\d{4})(\\d{3})(\\d{3})(\\d{3})",
  37579. "$1 $2 $3 $4",["18[06]"],"$1",,1]],,[,,,,,,,,,[-1]],,,[,,"00800\\d{7}|1(?:600\\d{6}|8(?:0(?:0\\d{4,9}|3\\d{9})|6(?:0\\d{7}|[12]\\d{9})))",,,,"1800123456"],[,,"140\\d{7}",,,,"1409305260",,,[10]],,,[,,,,,,,,,[-1]]],IO:[,[,,"3\\d{6}",,,,,,,[7]],[,,"37\\d{5}",,,,"3709100"],[,,"38\\d{5}",,,,"3801234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"IO",246,"00",,,,,,,,[[,"(\\d{3})(\\d{4})","$1 $2"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],
  37580. IQ:[,[,,"[1-7]\\d{7,9}",,,,,,,[8,9,10],[6,7]],[,,"1\\d{7}|(?:2[13-5]|3[02367]|4[023]|5[03]|6[026])\\d{6,7}",,,,"12345678",,,[8,9],[6,7]],[,,"7[3-9]\\d{8}",,,,"7912345678",,,[10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"IQ",964,"00","0",,,"0",,,,[[,"(1)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],[,"([2-6]\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-6]"],"0$1"],[,"(7\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],
  37581. ,,[,,,,,,,,,[-1]]],IR:[,[,,"[1-8]\\d{5,9}|9(?:[0-4]\\d{8}|9\\d{8})",,,,,,,[6,7,10],[4,5,8]],[,,"(?:(?:1[137]|2[13-68]|3[1458]|4[145]|5[1468]|6[16]|7[1467]|8[13467])(?:\\d{8}|(?:[16]|[289]\\d?)\\d{3}))|94(?:000|11[1-7]|2\\d{2}|440)\\d{5}",,,,"2123456789",,,,[4,5,8]],[,,"9(?:0[1-3]\\d{2}|[1-3]\\d{3}|9(?:0\\d{2}|44\\d|810|9(?:00|11|9[89])))\\d{5}",,,,"9123456789",,,[10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"(?:[2-6]0\\d|993)\\d{7}",,,,"9932123456",,,[10]],"IR",98,"00",
  37582. "0",,,"0",,,,[[,"(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[1-8]"],"0$1"],[,"(\\d{2})(\\d{4,5})","$1 $2",["[1-8]"],"0$1"],[,"(\\d{4,5})","$1",["96"],"0$1"],[,"(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"]],,[,,"943\\d{7}",,,,"9432123456",,,[10]],,,[,,"(?:9411[1-7]|94440)\\d{5}",,,,"9411110000",,,[10]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],IS:[,[,,"[4-9]\\d{6}|38\\d{7}",,,,,,,[7,9]],[,,"(?:4(?:1[0-24-69]|2[0-7]|[37][0-8]|4[0-245]|5[0-68]|6\\d|8[0-36-8])|5(?:05|[156]\\d|2[02578]|3[0-79]|4[03-7]|7[0-2578]|8[0-35-9]|9[013-689])|87[23])\\d{4}",
  37583. ,,,"4101234",,,[7]],[,,"38[589]\\d{6}|(?:6(?:1[1-8]|2[0-6]|3[027-9]|4[014679]|5[0159]|[67][0-69]|9\\d)|7(?:5[057]|[6-8]\\d)|8(?:2[0-59]|3[0-4]|[469]\\d|5[1-9]|88))\\d{4}",,,,"6111234"],[,,"800\\d{4}",,,,"8001234",,,[7]],[,,"90\\d{5}",,,,"9011234",,,[7]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"49\\d{5}",,,,"4921234",,,[7]],"IS",354,"1(?:0(?:01|10|20)|100)|00",,,,,,"00",,[[,"(\\d{3})(\\d{4})","$1 $2",["[4-9]"]],[,"(3\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["3"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"809\\d{4}",
  37584. ,,,"8091234",,,[7]],,,[,,"(?:6(?:2[78]|49|8\\d)|8(?:7[0189]|80)|95[48])\\d{4}",,,,"6271234",,,[7]]],IT:[,[,,"[01589]\\d{5,10}|3(?:[12457-9]\\d{8}|[36]\\d{7,9})",,,,,,,[6,7,8,9,10,11]],[,,"0(?:[26]\\d{4,9}|(?:1(?:[0159]\\d|[27][1-5]|31|4[1-4]|6[1356]|8[2-57])|3(?:[0159]\\d|2[1-4]|3[12]|[48][1-6]|6[2-59]|7[1-7])|4(?:[0159]\\d|[23][1-9]|4[245]|6[1-5]|7[1-4]|81)|5(?:[0159]\\d|2[1-5]|3[2-6]|4[1-79]|6[4-6]|7[1-578]|8[3-8])|7(?:[0159]\\d|2[12]|3[1-7]|4[2346]|6[13569]|7[13-6]|8[1-59])|8(?:[0159]\\d|2[34578]|3[1-356]|[6-8][1-5])|9(?:[0159]\\d|[238][1-5]|4[12]|6[1-8]|7[1-6]))\\d{2,7})",
  37585. ,,,"0212345678"],[,,"3(?:[12457-9]\\d{8}|6\\d{7,8}|3\\d{7,9})",,,,"3123456789",,,[9,10,11]],[,,"80(?:0\\d{6}|3\\d{3})",,,,"800123456",,,[6,9]],[,,"0878\\d{5}|1(?:44|6[346])\\d{6}|89(?:2\\d{3}|4(?:[0-4]\\d{2}|[5-9]\\d{4})|5(?:[0-4]\\d{2}|[5-9]\\d{6})|9\\d{6})",,,,"899123456",,,[6,8,9,10]],[,,"84(?:[08]\\d{6}|[17]\\d{3})",,,,"848123456",,,[6,9]],[,,"1(?:78\\d|99)\\d{6}",,,,"1781234567",,,[9,10]],[,,"55\\d{8}",,,,"5512345678",,,[10]],"IT",39,"00",,,,,,,,[[,"(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[26]|55"]],
  37586. [,"(0[26])(\\d{4})(\\d{5})","$1 $2 $3",["0[26]"]],[,"(0[26])(\\d{4,6})","$1 $2",["0[26]"]],[,"(0\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[13-57-9][0159]"]],[,"(\\d{3})(\\d{3,6})","$1 $2",["0[13-57-9][0159]|8(?:03|4[17]|9[245])","0[13-57-9][0159]|8(?:03|4[17]|9(?:2|[45][0-4]))"]],[,"(0\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["0[13-57-9][2-46-8]"]],[,"(0\\d{3})(\\d{2,6})","$1 $2",["0[13-57-9][2-46-8]"]],[,"(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13]|8(?:00|4[08]|9[59])","[13]|8(?:00|4[08]|9(?:5[5-9]|9))"]],
  37587. [,"(\\d{4})(\\d{4})","$1 $2",["894","894[5-9]"]],[,"(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["3"]]],,[,,,,,,,,,[-1]],1,,[,,"848\\d{6}",,,,"848123456",,,[9]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],JE:[,[,,"[135789]\\d{6,9}",,,,,,,[10],[6]],[,,"1534[0-24-8]\\d{5}",,,,"1534456789",,,,[6]],[,,"7(?:509\\d|7(?:00[378]|97[7-9])|829\\d|937\\d)\\d{5}",,,,"7797712345"],[,,"80(?:07(?:35|81)|8901)\\d{4}",,,,"8007354567"],[,,"(?:871206|90(?:066[59]|1810|71(?:07|55)))\\d{4}",,,,"9018105678"],[,,"8(?:4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|70002)\\d{4}",
  37588. ,,,"8447034567"],[,,"701511\\d{4}",,,,"7015115678"],[,,"56\\d{8}",,,,"5612345678"],"JE",44,"00","0",,,"0",,,,,,[,,"76(?:0[012]|2[356]|4[0134]|5[49]|6[0-369]|77|81|9[39])\\d{6}",,,,"7640123456"],,,[,,,,,,,,,[-1]],[,,"3(?:0(?:07(?:35|81)|8901)|3\\d{4}|4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))\\d{4}|55\\d{8}",,,,"5512345678"],,,[,,,,,,,,,[-1]]],JM:[,[,,"[589]\\d{9}",,,,,,,[10],[7]],[,,"876(?:5(?:0[12]|1[0-468]|2[35]|63)|6(?:0[1-3579]|1[027-9]|[23]\\d|40|5[06]|6[2-589]|7[05]|8[04]|9[4-9])|7(?:0[2-689]|[1-6]\\d|8[056]|9[45])|9(?:0[1-8]|1[02378]|[2-8]\\d|9[2-468]))\\d{4}",
  37589. ,,,"8765123456",,,,[7]],[,,"876(?:2[14-9]\\d|[348]\\d{2}|5(?:0[3-9]|[2-57-9]\\d|6[0-24-9])|7(?:0[07]|7\\d|8[1-47-9]|9[0-36-9])|9(?:[01]9|9[0579]))\\d{4}",,,,"8762101234",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002123456"],[,,"900[2-9]\\d{6}",,,,"9002123456"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"JM",1,"011","1",,,"1",,,,,,[,,,,,,,,,[-1]],,"876",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],JO:[,[,,"[235-9]\\d{7,8}",,,,,,,[8,
  37590. 9]],[,,"(?:2(?:6(?:2[0-35-9]|3[0-57-8]|4[24-7]|5[0-24-8]|[6-8][023]|9[0-3])|7(?:0[1-79]|10|2[014-7]|3[0-689]|4[019]|5[0-3578]))|32(?:0[1-69]|1[1-35-7]|2[024-7]|3\\d|4[0-3]|[57][023]|6[03])|53(?:0[0-3]|[13][023]|2[0-59]|49|5[0-35-9]|6[15]|7[45]|8[1-6]|9[0-36-9])|6(?:2[50]0|3(?:00|33)|4(?:0[0125]|1[2-7]|2[0569]|[38][07-9]|4[025689]|6[0-589]|7\\d|9[0-2])|5(?:[01][056]|2[034]|3[0-57-9]|4[17-8]|5[0-69]|6[0-35-9]|7[1-379]|8[0-68]|9[02-39]))|87(?:[02]0|7[08]|90))\\d{4}",,,,"62001234",,,[8]],[,,"7(?:55|7[025-9]|8[0-25-9]|9[0-25-9])\\d{6}",
  37591. ,,,"790123456",,,[9]],[,,"80\\d{6}",,,,"80012345",,,[8]],[,,"900\\d{5}",,,,"90012345",,,[8]],[,,"85\\d{6}",,,,"85012345",,,[8]],[,,"70\\d{7}",,,,"700123456",,,[9]],[,,,,,,,,,[-1]],"JO",962,"00","0",,,"0",,,,[[,"(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2356]|87"],"(0$1)"],[,"(7)(\\d{4})(\\d{4})","$1 $2 $3",["7[457-9]"],"0$1"],[,"(\\d{2})(\\d{7})","$1 $2",["70"],"0$1"],[,"(\\d{3})(\\d{5,6})","$1 $2",["8[0158]|9"],"0$1"]],,[,,"74(?:66|77)\\d{5}",,,,"746612345",,,[9]],,,[,,,,,,,,,[-1]],[,,"8(?:10|8\\d)\\d{5}",
  37592. ,,,"88101234",,,[8]],,,[,,,,,,,,,[-1]]],JP:[,[,,"[1-9]\\d{8,9}|00(?:[36]\\d{7,14}|7\\d{5,7}|8\\d{7})",,,,,,,[8,9,10,11,12,13,14,15,16,17]],[,,"(?:1(?:1[235-8]|2[3-6]|3[3-9]|4[2-6]|[58][2-8]|6[2-7]|7[2-9]|9[1-9])|2[2-9]\\d|[36][1-9]\\d|4(?:6[02-8]|[2-578]\\d|9[2-59])|5(?:6[1-9]|7[2-8]|[2-589]\\d)|7(?:3[4-9]|4[02-9]|[25-9]\\d)|8(?:3[2-9]|4[5-9]|5[1-9]|8[03-9]|[2679]\\d)|9(?:[679][1-9]|[2-58]\\d))\\d{6}",,,,"312345678",,,[9]],[,,"[7-9]0[1-9]\\d{7}",,,,"9012345678",,,[10]],[,,"120\\d{6}|800\\d{7}|00(?:37\\d{6,13}|66\\d{6,13}|777(?:[01]\\d{2}|5\\d{3}|8\\d{4})|882[1245]\\d{4})",
  37593. ,,,"120123456"],[,,"990\\d{6}",,,,"990123456",,,[9]],[,,,,,,,,,[-1]],[,,"60\\d{7}",,,,"601234567",,,[9]],[,,"50[1-9]\\d{7}",,,,"5012345678",,,[10]],"JP",81,"010","0",,,"0",,,,[[,"(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3",["(?:12|57|99)0"],"0$1"],[,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["800"],"0$1"],[,"(\\d{4})(\\d{4})","$1-$2",["0077"],"$1"],[,"(\\d{4})(\\d{2})(\\d{3,4})","$1-$2-$3",["0077"],"$1"],[,"(\\d{4})(\\d{2})(\\d{4})","$1-$2-$3",["0088"],"$1"],[,"(\\d{4})(\\d{3})(\\d{3,4})","$1-$2-$3",["00(?:37|66)"],
  37594. "$1"],[,"(\\d{4})(\\d{4})(\\d{4,5})","$1-$2-$3",["00(?:37|66)"],"$1"],[,"(\\d{4})(\\d{5})(\\d{5,6})","$1-$2-$3",["00(?:37|66)"],"$1"],[,"(\\d{4})(\\d{6})(\\d{6,7})","$1-$2-$3",["00(?:37|66)"],"$1"],[,"(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[2579]0|80[1-9]"],"0$1"],[,"(\\d{4})(\\d)(\\d{4})","$1-$2-$3",["1(?:26|3[79]|4[56]|5[4-68]|6[3-5])|5(?:76|97)|499|746|8(?:3[89]|63|47|51)|9(?:49|80|9[16])","1(?:267|3(?:7[247]|9[278])|4(?:5[67]|66)|5(?:47|58|64|8[67])|6(?:3[245]|48|5[4-68]))|5(?:76|97)9|499[2468]|7468|8(?:3(?:8[78]|96)|636|477|51[24])|9(?:496|802|9(?:1[23]|69))",
  37595. "1(?:267|3(?:7[247]|9[278])|4(?:5[67]|66)|5(?:47|58|64|8[67])|6(?:3[245]|48|5[4-68]))|5(?:769|979[2-69])|499[2468]|7468|8(?:3(?:8[78]|96[2457-9])|636[2-57-9]|477|51[24])|9(?:496|802|9(?:1[23]|69))"],"0$1"],[,"(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["1(?:2[3-6]|3[3-9]|4[2-6]|5[2-8]|[68][2-7]|7[2-689]|9[1-578])|2(?:2[03-689]|3[3-58]|4[0-468]|5[04-8]|6[013-8]|7[06-9]|8[02-57-9]|9[13])|4(?:2[28]|3[689]|6[035-7]|7[05689]|80|9[3-5])|5(?:3[1-36-9]|4[4578]|5[013-8]|6[1-9]|7[2-8]|8[14-7]|9[4-9])|7(?:2[15]|3[5-9]|4[02-9]|6[135-8]|7[0-4689]|9[014-9])|8(?:2[49]|3[3-8]|4[5-8]|5[2-9]|6[35-9]|7[579]|8[03-579]|9[2-8])|9(?:[23]0|4[02-46-9]|5[024-79]|6[4-9]|7[2-47-9]|8[02-7]|9[3-7])",
  37596. "1(?:2[3-6]|3[3-9]|4[2-6]|5(?:[236-8]|[45][2-69])|[68][2-7]|7[2-689]|9[1-578])|2(?:2(?:[04-689]|3[23])|3[3-58]|4[0-468]|5(?:5[78]|7[2-4]|[0468][2-9])|6(?:[0135-8]|4[2-5])|7(?:[0679]|8[2-7])|8(?:[024578]|3[25-9]|9[6-9])|9(?:11|3[2-4]))|4(?:2(?:2[2-9]|8[237-9])|3[689]|6[035-7]|7(?:[059][2-8]|[68])|80|9[3-5])|5(?:3[1-36-9]|4[4578]|5[013-8]|6[1-9]|7[2-8]|8[14-7]|9(?:[89][2-8]|[4-7]))|7(?:2[15]|3[5-9]|4[02-9]|6[135-8]|7[0-4689]|9(?:[017-9]|4[6-8]|5[2-478]|6[2-589]))|8(?:2(?:4[4-8]|9[2-8])|3(?:7[2-6]|[3-6][2-9]|8[2-5])|4[5-8]|5[2-9]|6(?:[37]|5[4-7]|6[2-9]|8[2-8]|9[236-9])|7[579]|8[03-579]|9[2-8])|9(?:[23]0|4[02-46-9]|5[024-79]|6[4-9]|7[2-47-9]|8[02-7]|9(?:3[34]|[4-7]))",
  37597. "1(?:2[3-6]|3[3-9]|4[2-6]|5(?:[236-8]|[45][2-69])|[68][2-7]|7[2-689]|9[1-578])|2(?:2(?:[04-689]|3[23])|3[3-58]|4[0-468]|5(?:5[78]|7[2-4]|[0468][2-9])|6(?:[0135-8]|4[2-5])|7(?:[0679]|8[2-7])|8(?:[024578]|3[25-9]|9[6-9])|9(?:11|3[2-4]))|4(?:2(?:2[2-9]|8[237-9])|3[689]|6[035-7]|7(?:[059][2-8]|[68])|80|9[3-5])|5(?:3[1-36-9]|4[4578]|5[013-8]|6[1-9]|7[2-8]|8[14-7]|9(?:[89][2-8]|[4-7]))|7(?:2[15]|3[5-9]|4[02-9]|6[135-8]|7[0-4689]|9(?:[017-9]|4[6-8]|5[2-478]|6[2-589]))|8(?:2(?:4[4-8]|9(?:[3578]|20|4[04-9]|6[56]))|3(?:7(?:[2-5]|6[0-59])|[3-6][2-9]|8[2-5])|4[5-8]|5[2-9]|6(?:[37]|5(?:[467]|5[014-9])|6(?:[2-8]|9[02-69])|8[2-8]|9(?:[236-8]|9[23]))|7[579]|8[03-579]|9[2-8])|9(?:[23]0|4[02-46-9]|5[024-79]|6[4-9]|7[2-47-9]|8[02-7]|9(?:3(?:3[02-9]|4[0-24689])|4[2-69]|[5-7]))",
  37598. "1(?:2[3-6]|3[3-9]|4[2-6]|5(?:[236-8]|[45][2-69])|[68][2-7]|7[2-689]|9[1-578])|2(?:2(?:[04-689]|3[23])|3[3-58]|4[0-468]|5(?:5[78]|7[2-4]|[0468][2-9])|6(?:[0135-8]|4[2-5])|7(?:[0679]|8[2-7])|8(?:[024578]|3[25-9]|9[6-9])|9(?:11|3[2-4]))|4(?:2(?:2[2-9]|8[237-9])|3[689]|6[035-7]|7(?:[059][2-8]|[68])|80|9[3-5])|5(?:3[1-36-9]|4[4578]|5[013-8]|6[1-9]|7[2-8]|8[14-7]|9(?:[89][2-8]|[4-7]))|7(?:2[15]|3[5-9]|4[02-9]|6[135-8]|7[0-4689]|9(?:[017-9]|4[6-8]|5[2-478]|6[2-589]))|8(?:2(?:4[4-8]|9(?:[3578]|20|4[04-9]|6(?:5[25]|60)))|3(?:7(?:[2-5]|6[0-59])|[3-6][2-9]|8[2-5])|4[5-8]|5[2-9]|6(?:[37]|5(?:[467]|5[014-9])|6(?:[2-8]|9[02-69])|8[2-8]|9(?:[236-8]|9[23]))|7[579]|8[03-579]|9[2-8])|9(?:[23]0|4[02-46-9]|5[024-79]|6[4-9]|7[2-47-9]|8[02-7]|9(?:3(?:3[02-9]|4[0-24689])|4[2-69]|[5-7]))"],
  37599. "0$1"],[,"(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["1|2(?:2[37]|5[5-9]|64|78|8[39]|91)|4(?:2[2689]|64|7[347])|5(?:[2-589]|39)|60|8(?:[46-9]|3[279]|2[124589])|9(?:[235-8]|93)","1|2(?:2[37]|5(?:[57]|[68]0|9[19])|64|78|8[39]|917)|4(?:2(?:[68]|20|9[178])|64|7[347])|5(?:[2-589]|39[67])|60|8(?:[46-9]|3[279]|2[124589])|9(?:[235-8]|93[34])","1|2(?:2[37]|5(?:[57]|[68]0|9(?:17|99))|64|78|8[39]|917)|4(?:2(?:[68]|20|9[178])|64|7[347])|5(?:[2-589]|39[67])|60|8(?:[46-9]|3[279]|2[124589])|9(?:[235-8]|93(?:31|4))"],
  37600. "0$1"],[,"(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["2(?:9[14-79]|74|[34]7|[56]9)|82|993"],"0$1"],[,"(\\d)(\\d{4})(\\d{4})","$1-$2-$3",["3|4(?:2[09]|7[01])|6[1-9]"],"0$1"],[,"(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[2479][1-9]"],"0$1"]],[[,"(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3",["(?:12|57|99)0"],"0$1"],[,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["800"],"0$1"],[,"(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[2579]0|80[1-9]"],"0$1"],[,"(\\d{4})(\\d)(\\d{4})","$1-$2-$3",["1(?:26|3[79]|4[56]|5[4-68]|6[3-5])|5(?:76|97)|499|746|8(?:3[89]|63|47|51)|9(?:49|80|9[16])",
  37601. "1(?:267|3(?:7[247]|9[278])|4(?:5[67]|66)|5(?:47|58|64|8[67])|6(?:3[245]|48|5[4-68]))|5(?:76|97)9|499[2468]|7468|8(?:3(?:8[78]|96)|636|477|51[24])|9(?:496|802|9(?:1[23]|69))","1(?:267|3(?:7[247]|9[278])|4(?:5[67]|66)|5(?:47|58|64|8[67])|6(?:3[245]|48|5[4-68]))|5(?:769|979[2-69])|499[2468]|7468|8(?:3(?:8[78]|96[2457-9])|636[2-57-9]|477|51[24])|9(?:496|802|9(?:1[23]|69))"],"0$1"],[,"(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["1(?:2[3-6]|3[3-9]|4[2-6]|5[2-8]|[68][2-7]|7[2-689]|9[1-578])|2(?:2[03-689]|3[3-58]|4[0-468]|5[04-8]|6[013-8]|7[06-9]|8[02-57-9]|9[13])|4(?:2[28]|3[689]|6[035-7]|7[05689]|80|9[3-5])|5(?:3[1-36-9]|4[4578]|5[013-8]|6[1-9]|7[2-8]|8[14-7]|9[4-9])|7(?:2[15]|3[5-9]|4[02-9]|6[135-8]|7[0-4689]|9[014-9])|8(?:2[49]|3[3-8]|4[5-8]|5[2-9]|6[35-9]|7[579]|8[03-579]|9[2-8])|9(?:[23]0|4[02-46-9]|5[024-79]|6[4-9]|7[2-47-9]|8[02-7]|9[3-7])",
  37602. "1(?:2[3-6]|3[3-9]|4[2-6]|5(?:[236-8]|[45][2-69])|[68][2-7]|7[2-689]|9[1-578])|2(?:2(?:[04-689]|3[23])|3[3-58]|4[0-468]|5(?:5[78]|7[2-4]|[0468][2-9])|6(?:[0135-8]|4[2-5])|7(?:[0679]|8[2-7])|8(?:[024578]|3[25-9]|9[6-9])|9(?:11|3[2-4]))|4(?:2(?:2[2-9]|8[237-9])|3[689]|6[035-7]|7(?:[059][2-8]|[68])|80|9[3-5])|5(?:3[1-36-9]|4[4578]|5[013-8]|6[1-9]|7[2-8]|8[14-7]|9(?:[89][2-8]|[4-7]))|7(?:2[15]|3[5-9]|4[02-9]|6[135-8]|7[0-4689]|9(?:[017-9]|4[6-8]|5[2-478]|6[2-589]))|8(?:2(?:4[4-8]|9[2-8])|3(?:7[2-6]|[3-6][2-9]|8[2-5])|4[5-8]|5[2-9]|6(?:[37]|5[4-7]|6[2-9]|8[2-8]|9[236-9])|7[579]|8[03-579]|9[2-8])|9(?:[23]0|4[02-46-9]|5[024-79]|6[4-9]|7[2-47-9]|8[02-7]|9(?:3[34]|[4-7]))",
  37603. "1(?:2[3-6]|3[3-9]|4[2-6]|5(?:[236-8]|[45][2-69])|[68][2-7]|7[2-689]|9[1-578])|2(?:2(?:[04-689]|3[23])|3[3-58]|4[0-468]|5(?:5[78]|7[2-4]|[0468][2-9])|6(?:[0135-8]|4[2-5])|7(?:[0679]|8[2-7])|8(?:[024578]|3[25-9]|9[6-9])|9(?:11|3[2-4]))|4(?:2(?:2[2-9]|8[237-9])|3[689]|6[035-7]|7(?:[059][2-8]|[68])|80|9[3-5])|5(?:3[1-36-9]|4[4578]|5[013-8]|6[1-9]|7[2-8]|8[14-7]|9(?:[89][2-8]|[4-7]))|7(?:2[15]|3[5-9]|4[02-9]|6[135-8]|7[0-4689]|9(?:[017-9]|4[6-8]|5[2-478]|6[2-589]))|8(?:2(?:4[4-8]|9(?:[3578]|20|4[04-9]|6[56]))|3(?:7(?:[2-5]|6[0-59])|[3-6][2-9]|8[2-5])|4[5-8]|5[2-9]|6(?:[37]|5(?:[467]|5[014-9])|6(?:[2-8]|9[02-69])|8[2-8]|9(?:[236-8]|9[23]))|7[579]|8[03-579]|9[2-8])|9(?:[23]0|4[02-46-9]|5[024-79]|6[4-9]|7[2-47-9]|8[02-7]|9(?:3(?:3[02-9]|4[0-24689])|4[2-69]|[5-7]))",
  37604. "1(?:2[3-6]|3[3-9]|4[2-6]|5(?:[236-8]|[45][2-69])|[68][2-7]|7[2-689]|9[1-578])|2(?:2(?:[04-689]|3[23])|3[3-58]|4[0-468]|5(?:5[78]|7[2-4]|[0468][2-9])|6(?:[0135-8]|4[2-5])|7(?:[0679]|8[2-7])|8(?:[024578]|3[25-9]|9[6-9])|9(?:11|3[2-4]))|4(?:2(?:2[2-9]|8[237-9])|3[689]|6[035-7]|7(?:[059][2-8]|[68])|80|9[3-5])|5(?:3[1-36-9]|4[4578]|5[013-8]|6[1-9]|7[2-8]|8[14-7]|9(?:[89][2-8]|[4-7]))|7(?:2[15]|3[5-9]|4[02-9]|6[135-8]|7[0-4689]|9(?:[017-9]|4[6-8]|5[2-478]|6[2-589]))|8(?:2(?:4[4-8]|9(?:[3578]|20|4[04-9]|6(?:5[25]|60)))|3(?:7(?:[2-5]|6[0-59])|[3-6][2-9]|8[2-5])|4[5-8]|5[2-9]|6(?:[37]|5(?:[467]|5[014-9])|6(?:[2-8]|9[02-69])|8[2-8]|9(?:[236-8]|9[23]))|7[579]|8[03-579]|9[2-8])|9(?:[23]0|4[02-46-9]|5[024-79]|6[4-9]|7[2-47-9]|8[02-7]|9(?:3(?:3[02-9]|4[0-24689])|4[2-69]|[5-7]))"],
  37605. "0$1"],[,"(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["1|2(?:2[37]|5[5-9]|64|78|8[39]|91)|4(?:2[2689]|64|7[347])|5(?:[2-589]|39)|60|8(?:[46-9]|3[279]|2[124589])|9(?:[235-8]|93)","1|2(?:2[37]|5(?:[57]|[68]0|9[19])|64|78|8[39]|917)|4(?:2(?:[68]|20|9[178])|64|7[347])|5(?:[2-589]|39[67])|60|8(?:[46-9]|3[279]|2[124589])|9(?:[235-8]|93[34])","1|2(?:2[37]|5(?:[57]|[68]0|9(?:17|99))|64|78|8[39]|917)|4(?:2(?:[68]|20|9[178])|64|7[347])|5(?:[2-589]|39[67])|60|8(?:[46-9]|3[279]|2[124589])|9(?:[235-8]|93(?:31|4))"],
  37606. "0$1"],[,"(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["2(?:9[14-79]|74|[34]7|[56]9)|82|993"],"0$1"],[,"(\\d)(\\d{4})(\\d{4})","$1-$2-$3",["3|4(?:2[09]|7[01])|6[1-9]"],"0$1"],[,"(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[2479][1-9]"],"0$1"]],[,,"20\\d{8}",,,,"2012345678",,,[10]],,,[,,"00(?:37\\d{6,13}|66\\d{6,13}|777(?:[01]\\d{2}|5\\d{3}|8\\d{4})|882[1245]\\d{4})",,,,"00777012"],[,,"570\\d{6}",,,,"570123456",,,[9]],,,[,,,,,,,,,[-1]]],KE:[,[,,"20\\d{6,7}|[4-9]\\d{6,9}",,,,,,,[7,8,9,10]],[,,"20\\d{6,7}|4(?:0\\d{6,7}|[136]\\d{7}|[245]\\d{5,7})|5(?:[08]\\d{7}|[1-79]\\d{5,7})|6(?:[01457-9]\\d{5,7}|2\\d{7}|6\\d{6,7})",
  37607. ,,,"202012345",,,[7,8,9]],[,,"7(?:[0-3679]\\d|4[0-46-9]|5[0-6]|8[0-25-9])\\d{6}",,,,"712123456",,,[9]],[,,"800[24-8]\\d{5,6}",,,,"800223456",,,[9,10]],[,,"900[02-9]\\d{5}",,,,"900223456",,,[9]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"KE",254,"000","0",,,"005|0",,,,[[,"(\\d{2})(\\d{5,7})","$1 $2",["[24-6]"],"0$1"],[,"(\\d{3})(\\d{6})","$1 $2",["7"],"0$1"],[,"(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],KG:[,[,
  37608. ,"[235-8]\\d{8,9}",,,,,,,[9,10],[5,6]],[,,"(?:3(?:1(?:[256]\\d|3[1-9]|47)|2(?:22|3[0-479]|6[0-7])|4(?:22|5[6-9]|6\\d)|5(?:22|3[4-7]|59|6\\d)|6(?:22|5[35-7]|6\\d)|7(?:22|3[468]|4[1-9]|59|[67]\\d)|9(?:22|4[1-8]|6\\d))|6(?:09|12|2[2-4])\\d)\\d{5}",,,,"312123456",,,[9],[5,6]],[,,"(?:20[0-35]|5[0-24-7]\\d|7[07]\\d)\\d{6}",,,,"700123456",,,[9]],[,,"800\\d{6,7}",,,,"800123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"KG",996,"00","0",,,"0",,,,[[,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",
  37609. ["[25-7]|31[25]"],"0$1"],[,"(\\d{4})(\\d{5})","$1 $2",["3(?:1[36]|[2-9])"],"0$1"],[,"(\\d{3})(\\d{3})(\\d)(\\d{3})","$1 $2 $3 $4",["8"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],KH:[,[,,"[1-9]\\d{7,9}",,,,,,,[8,9,10],[6,7]],[,,"(?:2[3-6]|3[2-6]|4[2-4]|[5-7][2-5])(?:[237-9]|4[56]|5\\d|6\\d?)\\d{5}|23(?:4[234]|8\\d{2})\\d{4}",,,,"23756789",,,[8,9],[6,7]],[,,"(?:1(?:[013-79]\\d|[28]\\d{1,2})|2[3-6]48|3(?:[18]\\d{2}|[2-6]48)|4[2-4]48|5[2-5]48|6(?:[016-9]\\d|[2-5]48)|7(?:[07-9]\\d|[16]\\d{2}|[2-5]48)|8(?:[013-79]\\d|8\\d{2})|9(?:6\\d{2}|7\\d{1,2}|[0-589]\\d))\\d{5}",
  37610. ,,,"91234567",,,[8,9]],[,,"1800(?:1\\d|2[019])\\d{4}",,,,"1800123456",,,[10]],[,,"1900(?:1\\d|2[09])\\d{4}",,,,"1900123456",,,[10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"KH",855,"00[14-9]","0",,,"0",,,,[[,"(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["1\\d[1-9]|[2-9]"],"0$1"],[,"(1[89]00)(\\d{3})(\\d{3})","$1 $2 $3",["1[89]0"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],KI:[,[,,"[2458]\\d{4}|3\\d{4,7}|7\\d{7}",,,,,,,[5,8]],[,,"(?:[24]\\d|3[1-9]|50|8[0-5])\\d{3}|7(?:27|31|5[0-4])\\d{5}",
  37611. ,,,"31234"],[,,"7[23]0\\d{5}",,,,"72012345",,,[8]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"30(?:0[01]\\d{2}|12(?:11|20))\\d{2}",,,,"30010000",,,[8]],"KI",686,"00",,,,"0",,,,,,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],KM:[,[,,"[3478]\\d{6}",,,,,,,[7]],[,,"7[4-7]\\d{5}",,,,"7712345"],[,,"[34]\\d{6}",,,,"3212345"],[,,,,,,,,,[-1]],[,,"(?:39[01]|8\\d{2})\\d{4}",,,,"8001234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"KM",269,"00",,,,,,,,[[,"(\\d{3})(\\d{2})(\\d{2})",
  37612. "$1 $2 $3"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],KN:[,[,,"[589]\\d{9}",,,,,,,[10],[7]],[,,"869(?:2(?:29|36)|302|4(?:6[015-9]|70))\\d{4}",,,,"8692361234",,,,[7]],[,,"869(?:5(?:5[6-8]|6[5-7])|66\\d|76[02-7])\\d{4}",,,,"8697652917",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002123456"],[,,"900[2-9]\\d{6}",,,,"9002123456"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"KN",1,"011","1",,,"1",,,,,,[,,,,,,,,,[-1]],
  37613. ,"869",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],KP:[,[,,"1\\d{9}|[28]\\d{7}",,,,,,,[8,10],[6,7]],[,,"2\\d{7}|85\\d{6}",,,,"21234567",,,[8],[6,7]],[,,"19[123]\\d{7}",,,,"1921234567",,,[10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"KP",850,"00|99","0",,,"0",,,,[[,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],[,"(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1"],[,"(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,"2(?:[0-24-9]\\d{2}|3(?:[0-79]\\d|8[02-9]))\\d{4}",
  37614. ,,,"23821234",,,[8]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],KR:[,[,,"007\\d{9,11}|[1-7]\\d{3,9}|8\\d{8}",,,,,,,[4,5,6,8,9,10,12,13,14],[3,7]],[,,"(?:2|3[1-3]|[46][1-4]|5[1-5])(?:1\\d{2,3}|[1-9]\\d{6,7})",,,,"22123456",,,[4,5,6,8,9,10],[3,7]],[,,"1[0-26-9]\\d{7,8}",,,,"1000000000",,,[9,10]],[,,"(?:00798\\d{0,2}|80)\\d{7}",,,,"801234567",,,[9,12,13,14]],[,,"60[2-9]\\d{6}",,,,"602345678",,,[9]],[,,,,,,,,,[-1]],[,,"50\\d{8}",,,,"5012345678",,,[10]],[,,"70\\d{8}",,,,"7012345678",,,[10]],"KR",82,"00(?:[124-68]|3\\d{2}|7(?:[0-8]\\d|9[0-79]))",
  37615. "0",,,"0(8[1-46-8]|85\\d{2})?",,,,[[,"(\\d{5})(\\d{3,4})(\\d{4})","$1 $2 $3",["00798"],"$1","0$CC-$1"],[,"(\\d{5})(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3 $4",["00798"],"$1","0$CC-$1"],[,"(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["1(?:0|1[19]|[69]9|5[458])|[57]0","1(?:0|1[19]|[69]9|5(?:44|59|8))|[57]0"],"0$1","0$CC-$1"],[,"(\\d{2})(\\d{3,4})(\\d{4})","$1-$2-$3",["1(?:[01]|5[1-4]|6[2-8]|[7-9])|[68]0|[3-6][1-9][1-9]","1(?:[01]|5(?:[1-3]|4[56])|6[2-8]|[7-9])|[68]0|[3-6][1-9][1-9]"],"0$1","0$CC-$1"],[,"(\\d{3})(\\d)(\\d{4})",
  37616. "$1-$2-$3",["131","1312"],"0$1","0$CC-$1"],[,"(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["131","131[13-9]"],"0$1","0$CC-$1"],[,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["13[2-9]"],"0$1","0$CC-$1"],[,"(\\d{2})(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3-$4",["30"],"0$1","0$CC-$1"],[,"(\\d)(\\d{3,4})(\\d{4})","$1-$2-$3",["2[1-9]"],"0$1","0$CC-$1"],[,"(\\d)(\\d{3,4})","$1-$2",["21[0-46-9]"],"0$1","0$CC-$1"],[,"(\\d{2})(\\d{3,4})","$1-$2",["[3-6][1-9]1","[3-6][1-9]1(?:[0-46-9])"],"0$1","0$CC-$1"],[,"(\\d{4})(\\d{4})",
  37617. "$1-$2",["1(?:5[246-9]|6[04678]|8[03579])","1(?:5(?:22|44|66|77|88|99)|6(?:00|44|6[16]|70|88)|8(?:00|33|55|77|99))"],"$1","0$CC-$1"]],[[,"(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["1(?:0|1[19]|[69]9|5[458])|[57]0","1(?:0|1[19]|[69]9|5(?:44|59|8))|[57]0"],"0$1","0$CC-$1"],[,"(\\d{2})(\\d{3,4})(\\d{4})","$1-$2-$3",["1(?:[01]|5[1-4]|6[2-8]|[7-9])|[68]0|[3-6][1-9][1-9]","1(?:[01]|5(?:[1-3]|4[56])|6[2-8]|[7-9])|[68]0|[3-6][1-9][1-9]"],"0$1","0$CC-$1"],[,"(\\d{3})(\\d)(\\d{4})","$1-$2-$3",["131","1312"],"0$1",
  37618. "0$CC-$1"],[,"(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["131","131[13-9]"],"0$1","0$CC-$1"],[,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["13[2-9]"],"0$1","0$CC-$1"],[,"(\\d{2})(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3-$4",["30"],"0$1","0$CC-$1"],[,"(\\d)(\\d{3,4})(\\d{4})","$1-$2-$3",["2[1-9]"],"0$1","0$CC-$1"],[,"(\\d)(\\d{3,4})","$1-$2",["21[0-46-9]"],"0$1","0$CC-$1"],[,"(\\d{2})(\\d{3,4})","$1-$2",["[3-6][1-9]1","[3-6][1-9]1(?:[0-46-9])"],"0$1","0$CC-$1"],[,"(\\d{4})(\\d{4})","$1-$2",["1(?:5[246-9]|6[04678]|8[03579])",
  37619. "1(?:5(?:22|44|66|77|88|99)|6(?:00|44|6[16]|70|88)|8(?:00|33|55|77|99))"],"$1","0$CC-$1"]],[,,"15\\d{7,8}",,,,"1523456789",,,[9,10]],,,[,,"00798\\d{7,9}",,,,"007981234567",,,[12,13,14]],[,,"1(?:5(?:22|44|66|77|88|99)|6(?:00|44|6[16]|70|88)|8(?:00|33|55|77|99))\\d{4}",,,,"15441234",,,[8]],,,[,,,,,,,,,[-1]]],KW:[,[,,"[12569]\\d{6,7}",,,,,,,[7,8]],[,,"(?:18\\d|2(?:[23]\\d{2}|4(?:[1-35-9]\\d|44)|5(?:0[034]|[2-46]\\d|5[1-3]|7[1-7])))\\d{4}",,,,"22345678"],[,,"(?:5(?:[05]\\d{2}|1[0-7]\\d|2(?:22|5[25])|6[56]\\d)|6(?:0[034679]\\d|222|5[015-9]\\d|6\\d{2}|7(?:0[013-9]|[67]\\d)|9(?:[069]\\d|3[039]))|9(?:0[09]\\d|22\\d|4[01479]\\d|55\\d|6[0679]\\d|7(?:02|[1-9]\\d)|8[057-9]\\d|9\\d{2}))\\d{4}",
  37620. ,,,"50012345",,,[8]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"KW",965,"00",,,,,,,,[[,"(\\d{4})(\\d{3,4})","$1 $2",["[16]|2(?:[0-35-9]|4[0-35-9])|9[024-9]|52[25]"]],[,"(\\d{3})(\\d{5})","$1 $2",["244|5(?:[015]|6[56])"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],KY:[,[,,"[3589]\\d{9}",,,,,,,[10],[7]],[,,"345(?:2(?:22|44)|444|6(?:23|38|40)|7(?:4[35-79]|6[6-9]|77)|8(?:00|1[45]|25|[48]8)|9(?:14|4[035-9]))\\d{4}",,,,"3452221234",,,,[7]],
  37621. [,,"345(?:32[1-9]|5(?:1[67]|2[5-79]|4[6-9]|50|76)|649|9(?:1[67]|2[2-9]|3[689]))\\d{4}",,,,"3453231234",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002345678"],[,,"900[2-9]\\d{6}|345976\\d{4}",,,,"9002345678"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"KY",1,"011","1",,,"1",,,,,,[,,"345849\\d{4}",,,,"3458491234"],,"345",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],KZ:[,[,,"(?:33\\d|7\\d{2}|80[089])\\d{7}",,,,,,,[10]],[,,"33622\\d{5}|7(?:1(?:0(?:[23]\\d|4[0-3]|59|63)|1(?:[23]\\d|4[0-79]|59)|2(?:[23]\\d|59)|3(?:2\\d|3[0-79]|4[0-35-9]|59)|4(?:[24]\\d|3[013-9]|5[1-9])|5(?:2\\d|3[1-9]|4[0-7]|59)|6(?:[234]\\d|5[19]|61)|72\\d|8(?:[27]\\d|3[1-46-9]|4[0-5]))|2(?:1(?:[23]\\d|4[46-9]|5[3469])|2(?:2\\d|3[0679]|46|5[12679])|3(?:[234]\\d|5[139])|4(?:2\\d|3[1235-9]|59)|5(?:[23]\\d|4[01246-8]|59|61)|6(?:2\\d|3[1-9]|4[0-4]|59)|7(?:[2379]\\d|40|5[279])|8(?:[23]\\d|4[0-3]|59)|9(?:2\\d|3[124578]|59)))\\d{5}",
  37622. ,,,"7123456789"],[,,"7(?:0[012578]|47|6[02-4]|7[15-8]|85)\\d{7}",,,,"7710009998"],[,,"800\\d{7}",,,,"8001234567"],[,,"809\\d{7}",,,,"8091234567"],[,,,,,,,,,[-1]],[,,"808\\d{7}",,,,"8081234567"],[,,"751\\d{7}",,,,"7511234567"],"KZ",7,"810","8",,,"8",,"8~10",,,,[,,,,,,,,,[-1]],,,[,,"751\\d{7}",,,,"7511234567"],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],LA:[,[,,"[2-8]\\d{7,9}",,,,,,,[8,9,10],[6]],[,,"(?:2[13]|3(?:0\\d|[14])|[5-7][14]|41|8[1468])\\d{6}",,,,"21212862",,,[8,9],[6]],[,,"20(?:2[2389]|5[24-689]|7[6-8]|9[125-9])\\d{6}",
  37623. ,,,"2023123456",,,[10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"LA",856,"00","0",,,"0",,,,[[,"(20)(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["20"],"0$1"],[,"([2-8]\\d)(\\d{3})(\\d{3})","$1 $2 $3",["2[13]|3[14]|[4-8]"],"0$1"],[,"(30)(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["30"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],LB:[,[,,"[13-9]\\d{6,7}",,,,,,,[7,8]],[,,"(?:[14-6]\\d{2}|7(?:[2-57]\\d|62|8[0-7]|9[04-9])|8[02-9]\\d|9\\d{2})\\d{4}",
  37624. ,,,"1123456",,,[7]],[,,"(?:3\\d|7(?:[01]\\d|6[013-9]|8[89]|9[1-3])|81\\d)\\d{5}",,,,"71123456"],[,,,,,,,,,[-1]],[,,"9[01]\\d{6}",,,,"90123456",,,[8]],[,,"80\\d{6}",,,,"80123456",,,[8]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"LB",961,"00","0",,,"0",,,,[[,"(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[13-6]|7(?:[2-57]|62|8[0-7]|9[04-9])|8[02-9]|9"],"0$1"],[,"([7-9]\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[89][01]|7(?:[01]|6[013-9]|8[89]|9[1-3])"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],LC:[,
  37625. [,,"[5789]\\d{9}",,,,,,,[10],[7]],[,,"758(?:4(?:30|5[0-9]|6[2-9]|8[0-2])|57[0-2]|638)\\d{4}",,,,"7584305678",,,,[7]],[,,"758(?:28[4-7]|384|4(?:6[01]|8[4-9])|5(?:1[89]|20|84)|7(?:1[2-9]|2\\d|3[01]))\\d{4}",,,,"7582845678",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002123456"],[,,"900[2-9]\\d{6}",,,,"9002123456"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"LC",1,"011","1",,,"1",,,,,,[,,,,,,,,,[-1]],,"758",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,
  37626. [,,,,,,,,,[-1]]],LI:[,[,,"6\\d{8}|[23789]\\d{6}",,,,,,,[7,9]],[,,"(?:2(?:01|1[27]|3\\d|6[02-578]|96)|3(?:7[0135-7]|8[048]|9[0269]))\\d{4}",,,,"2345678",,,[7]],[,,"6(?:5(?:09|1\\d|20)|6(?:0[0-6]|10|2[06-9]|39))\\d{5}|7(?:[37-9]\\d|42|56)\\d{4}",,,,"660234567"],[,,"80(?:02[28]|9\\d{2})\\d{2}",,,,"8002222",,,[7]],[,,"90(?:02[258]|1(?:23|3[14])|66[136])\\d{2}",,,,"9002222",,,[7]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"LI",423,"00","0",,,"0|10(?:01|20|66)",,,,[[,"(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",
  37627. ["[23789]"]],[,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6[56]"]],[,"(69)(7\\d{2})(\\d{4})","$1 $2 $3",["697"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"870(?:28|87)\\d{2}",,,,"8702812",,,[7]],,,[,,"697(?:42|56|[78]\\d)\\d{4}",,,,"697861234",,,[9]]],LK:[,[,,"[1-9]\\d{8}",,,,,,,[9],[7]],[,,"1(?:1[2-57]\\d{6}|973\\d{5})|(?:2[13-7]|3[1-8]|4[157]|5[12457]|6[35-7]|[89]1)[2-57]\\d{6}",,,,"112345678",,,,[7]],[,,"7[0125-8]\\d{7}",,,,"712345678"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],
  37628. [,,,,,,,,,[-1]],"LK",94,"00","0",,,"0",,,,[[,"(\\d{2})(\\d{1})(\\d{6})","$1 $2 $3",["[1-689]"],"0$1"],[,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],LR:[,[,,"2\\d{7,8}|[378]\\d{8}|4\\d{6}|5\\d{6,8}",,,,,,,[7,8,9]],[,,"(?:2\\d{3}|33333)\\d{4}",,,,"21234567",,,[8,9]],[,,"(?:20\\d{2}|330\\d|4[67]|5(?:55)?\\d|77\\d{2}|88\\d{2})\\d{5}",,,,"770123456",,,[7,9]],[,,,,,,,,,[-1]],[,,"332(?:02|[2-5]\\d)\\d{4}",,,,"332021234",,,[9]],
  37629. [,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"LR",231,"00","0",,,"0",,,,[[,"(2\\d)(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],[,"([4-5])(\\d{3})(\\d{3})","$1 $2 $3",["[45]"],"0$1"],[,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[23578]"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],LS:[,[,,"[2568]\\d{7}",,,,,,,[8]],[,,"2\\d{7}",,,,"22123456"],[,,"[56]\\d{7}",,,,"50123456"],[,,"800[256]\\d{4}",,,,"80021234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],
  37630. "LS",266,"00",,,,,,,,[[,"(\\d{4})(\\d{4})","$1 $2"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],LT:[,[,,"[3-9]\\d{7}",,,,,,,[8]],[,,"(?:3[1478]|4[124-6]|52)\\d{6}",,,,"31234567"],[,,"6\\d{7}",,,,"61234567"],[,,"800\\d{5}",,,,"80012345"],[,,"9(?:0[0239]|10)\\d{5}",,,,"90012345"],[,,"808\\d{5}",,,,"80812345"],[,,"700\\d{5}",,,,"70012345"],[,,,,,,,,,[-1]],"LT",370,"00","8",,,"[08]",,,,[[,"([34]\\d)(\\d{6})","$1 $2",["37|4(?:1|5[45]|6[2-4])"],"(8-$1)",,1],[,"([3-6]\\d{2})(\\d{5})",
  37631. "$1 $2",["3[148]|4(?:[24]|6[09])|528|6"],"(8-$1)",,1],[,"([7-9]\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["[7-9]"],"8 $1",,1],[,"(5)(2\\d{2})(\\d{4})","$1 $2 $3",["52[0-79]"],"(8-$1)",,1]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"70[67]\\d{5}",,,,"70712345"],,,[,,,,,,,,,[-1]]],LU:[,[,,"[24-9]\\d{3,10}|3(?:[0-46-9]\\d{2,9}|5[013-9]\\d{1,8})",,,,,,,[4,5,6,7,8,9,10,11]],[,,"(?:2[2-9]\\d{2,9}|(?:[3457]\\d{2}|8(?:0[2-9]|[13-9]\\d)|9(?:0[89]|[2-579]\\d))\\d{1,8})",,,,"27123456"],[,,"6[25-79][18]\\d{6}",,,,"628123456",
  37632. ,,[9]],[,,"800\\d{5}",,,,"80012345",,,[8]],[,,"90[015]\\d{5}",,,,"90012345",,,[8]],[,,"801\\d{5}",,,,"80112345",,,[8]],[,,"70\\d{6}",,,,"70123456",,,[8]],[,,"20(?:1\\d{5}|[2-689]\\d{1,7})",,,,"20201234",,,[4,5,6,7,8,9,10]],"LU",352,"00",,,,"(15(?:0[06]|1[12]|35|4[04]|55|6[26]|77|88|99)\\d)",,,,[[,"(\\d{2})(\\d{3})","$1 $2",["[2-5]|7[1-9]|[89](?:[1-9]|0[2-9])"],,"$CC $1"],[,"(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[2-5]|7[1-9]|[89](?:[1-9]|0[2-9])"],,"$CC $1"],[,"(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",
  37633. ["20"],,"$CC $1"],[,"(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4",["2(?:[0367]|4[3-8])"],,"$CC $1"],[,"(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["20"],,"$CC $1"],[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4 $5",["2(?:[0367]|4[3-8])"],,"$CC $1"],[,"(\\d{2})(\\d{2})(\\d{2})(\\d{1,4})","$1 $2 $3 $4",["2(?:[12589]|4[12])|[3-5]|7[1-9]|8(?:[1-9]|0[2-9])|9(?:[1-9]|0[2-46-9])"],,"$CC $1"],[,"(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["70|80[01]|90[015]"],,"$CC $1"],[,"(\\d{3})(\\d{3})(\\d{3})",
  37634. "$1 $2 $3",["6"],,"$CC $1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],LV:[,[,,"[2689]\\d{7}",,,,,,,[8]],[,,"6\\d{7}",,,,"63123456"],[,,"2\\d{7}",,,,"21234567"],[,,"80\\d{6}",,,,"80123456"],[,,"90\\d{6}",,,,"90123456"],[,,"81\\d{6}",,,,"81123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"LV",371,"00",,,,,,,,[[,"([2689]\\d)(\\d{3})(\\d{3})","$1 $2 $3"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],LY:[,[,,"[25679]\\d{8}",,,,,,,[9],[7]],[,,"(?:2[1345]|5[1347]|6[123479]|71)\\d{7}",
  37635. ,,,"212345678",,,,[7]],[,,"9[1-6]\\d{7}",,,,"912345678"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"LY",218,"00","0",,,"0",,,,[[,"([25679]\\d)(\\d{7})","$1-$2",,"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],MA:[,[,,"[5-9]\\d{8}",,,,,,,[9]],[,,"5(?:2(?:[015-79]\\d|2[02-9]|3[2-57]|4[2-8]|8[235-7])\\d|3(?:[0-48]\\d|[57][2-9]|6[2-8]|9[3-9])\\d|4[067]\\d{2}|5[03]\\d{2})\\d{4}",,,,"520123456"],[,,"(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[07][07]|6[12]))\\d{6}",
  37636. ,,,"650123456"],[,,"80\\d{7}",,,,"801234567"],[,,"89\\d{7}",,,,"891234567"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"5924[01]\\d{4}",,,,"592401234"],"MA",212,"00","0",,,"0",,,,[[,"([5-7]\\d{2})(\\d{6})","$1-$2",["5(?:2[015-7]|3[0-4])|[67]"],"0$1"],[,"([58]\\d{3})(\\d{5})","$1-$2",["5(?:2[2-489]|3[5-9]|92)|892","5(?:2(?:[2-48]|9[0-7])|3(?:[5-79]|8[0-7])|924)|892"],"0$1"],[,"(5\\d{4})(\\d{4})","$1-$2",["5(?:29|38)","5(?:29|38)[89]"],"0$1"],[,"([5]\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5(?:4[067]|5[03])"],
  37637. "0$1"],[,"(8[09])(\\d{7})","$1-$2",["8(?:0|9[013-9])"],"0$1"]],,[,,,,,,,,,[-1]],1,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],MC:[,[,,"[34689]\\d{7,8}",,,,,,,[8,9]],[,,"870\\d{5}|9[2-47-9]\\d{6}",,,,"99123456",,,[8]],[,,"3\\d{7}|4(?:4\\d|5[1-9])\\d{5}|6\\d{8}",,,,"612345678"],[,,"90\\d{6}",,,,"90123456",,,[8]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"MC",377,"00","0",,,"0",,,,[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[39]"],"$1"],[,"(\\d{2})(\\d{3})(\\d{3})",
  37638. "$1 $2 $3",["4"],"0$1"],[,"(6)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["6"],"0$1"],[,"(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3",["8"],"$1"]],,[,,,,,,,,,[-1]],,,[,,"870\\d{5}",,,,"87012345",,,[8]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],MD:[,[,,"[235-9]\\d{7}",,,,,,,[8]],[,,"(?:2[1-9]\\d|3[1-79]\\d|5(?:33|5[257]))\\d{5}",,,,"22212345"],[,,"(?:562|6\\d{2}|7(?:[189]\\d|6[07]|7[457-9]))\\d{5}",,,,"62112345"],[,,"800\\d{5}",,,,"80012345"],[,,"90[056]\\d{5}",,,,"90012345"],[,,"808\\d{5}",,,,"80812345"],
  37639. [,,,,,,,,,[-1]],[,,"3[08]\\d{6}",,,,"30123456"],"MD",373,"00","0",,,"0",,,,[[,"(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["22|3"],"0$1"],[,"([25-7]\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["2[13-9]|[5-7]"],"0$1"],[,"([89]\\d{2})(\\d{5})","$1 $2",["[89]"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"803\\d{5}",,,,"80312345"],,,[,,,,,,,,,[-1]]],ME:[,[,,"[2-9]\\d{7,8}",,,,,,,[8],[6]],[,,"(?:20[2-8]|3(?:0[2-7]|[12][235-7]|3[24-7])|4(?:0[2-467]|1[267])|5(?:0[2467]|1[267]|2[2367]))\\d{5}",,,,"30234567",,,,[6]],
  37640. [,,"6(?:00\\d|3[024]\\d|6[0-25]\\d|[7-9]\\d{2})\\d{4}",,,,"67622901"],[,,"80[0-258]\\d{5}",,,,"80080002"],[,,"(?:9(?:4[1568]|5[178]))\\d{5}",,,,"94515151"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"78[1-49]\\d{5}",,,,"78108780"],"ME",382,"00","0",,,"0",,,,[[,"(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-57-9]|6[036-9]"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"77[1-9]\\d{5}",,,,"77273012"],,,[,,,,,,,,,[-1]]],MF:[,[,,"[56]\\d{8}",,,,,,,[9]],[,,"590(?:[02][79]|13|5[0-268]|[78]7)\\d{4}",,,,"590271234"],
  37641. [,,"690(?:0[05-9]|[1-9]\\d)\\d{4}",,,,"690001234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"MF",590,"00","0",,,"0",,,,,,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],MG:[,[,,"[23]\\d{8}",,,,,,,[9],[7]],[,,"20(?:2\\d{2}|4[47]\\d|5[3467]\\d|6[279]\\d|7(?:2[29]|[35]\\d)|8[268]\\d|9[245]\\d)\\d{4}",,,,"202123456",,,,[7]],[,,"3[2-49]\\d{7}",,,,"321234567"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"22\\d{7}",,,,"221234567"],
  37642. "MG",261,"00","0",,,"0",,,,[[,"([23]\\d)(\\d{2})(\\d{3})(\\d{2})","$1 $2 $3 $4",,"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],MH:[,[,,"[2-6]\\d{6}",,,,,,,[7]],[,,"(?:247|528|625)\\d{4}",,,,"2471234"],[,,"(?:235|329|45[56]|545)\\d{4}",,,,"2351234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"635\\d{4}",,,,"6351234"],"MH",692,"011","1",,,"1",,,,[[,"(\\d{3})(\\d{4})","$1-$2"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],
  37643. MK:[,[,,"[2-578]\\d{7}",,,,,,,[8],[6,7]],[,,"(?:2(?:[23]\\d|5[124578]|6[01])|3(?:1[3-6]|[23][2-6]|4[2356])|4(?:[23][2-6]|4[3-6]|5[256]|6[25-8]|7[24-6]|8[4-6]))\\d{5}",,,,"22212345",,,,[6,7]],[,,"7(?:[0-25-8]\\d{2}|32\\d|421|9[23]\\d)\\d{4}",,,,"72345678"],[,,"800\\d{5}",,,,"80012345"],[,,"5[02-9]\\d{6}",,,,"50012345"],[,,"8(?:0[1-9]|[1-9]\\d)\\d{5}",,,,"80123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"MK",389,"00","0",,,"0",,,,[[,"(2)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1"],[,"([347]\\d)(\\d{3})(\\d{3})",
  37644. "$1 $2 $3",["[347]"],"0$1"],[,"([58]\\d{2})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["[58]"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],ML:[,[,,"[246-9]\\d{7}",,,,,,,[8]],[,,"(?:2(?:0(?:2\\d|7[0-8])|1(?:2[5-7]|[3-689]\\d))|44[1239]\\d)\\d{4}",,,,"20212345"],[,,"(?:2(?:079|17\\d)|[679]\\d{3}|8[239]\\d{2})\\d{4}",,,,"65012345"],[,,"80\\d{6}",,,,"80012345"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"ML",223,"00",,,,,,,,[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})",
  37645. "$1 $2 $3 $4",["[246-9]"]],[,"(\\d{4})","$1",["67|74"]]],[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[246-9]"]]],[,,,,,,,,,[-1]],,,[,,"80\\d{6}",,,,"80012345"],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],MM:[,[,,"[178]\\d{5,7}|[24-6]\\d{5,8}|9(?:[279]\\d{0,2}|5|[34]\\d{1,2}|6(?:\\d{1,2})?|8(?:\\d{2})?)\\d{6}",,,,,,,[6,7,8,9,10],[5]],[,,"1(?:2\\d{1,2}|[35]\\d|4(?:\\d|2[236]|39)|6\\d?|[89][0-6]\\d)\\d{4}|2(?:2(?:000\\d{3}|\\d{4})|3\\d{4}|4(?:0\\d{5}|26\\d{4}|39\\d{4}|\\d{4})|5(?:1\\d{3,6}|[02-9]\\d{3,5})|[6-9]\\d{4})|4(?:2[245-8]|3(?:2(?:02)?|[346]|56?)|[46][2-6]|5[3-5])\\d{4}|5(?:2(?:2(?:\\d{1,2})?|[3-8])|3[2-68]|4(?:21?|[4-8])|5[23]|6[2-4]|7[2-8]|8[24-7]|9[2-7])\\d{4}|6(?:0[23]|1(?:2(?:0|4\\d)?|[356])|2[2-6]|3[24-6]|4(?:2(?:4\\d)?|[3-6])|5[2-4]|6[2-8]|7(?:[2367]|4(?:\\d|39)|5\\d?|8[145]\\d)|8[245]|9(?:20?|4))\\d{4}|7(?:[04][24-8]|1(?:20?|[3-7])|22|3[2-4]|5[2-7])\\d{4}|8(?:1(?:2\\d{1,2}|[3-689]\\d)|2(?:2\\d|3(?:\\d|20)|[4-8]\\d)|3[24]\\d|4[24-7]\\d|5[245]\\d|6[23]\\d)\\d{3}",
  37646. ,,,"1234567",,,[6,7,8,9],[5]],[,,"17[01]\\d{4}|9(?:2(?:[0-4]|5\\d{2}|6[0-5]\\d)|3(?:[0-36]|4[069])\\d|4(?:0[0-4]\\d|[1379]\\d|2\\d{2}|4[0-589]\\d|5\\d{2}|88)|5[0-6]|6(?:1\\d|9\\d{2}|\\d)|7(?:3\\d|[6-9]\\d{2})|8(?:\\d|9\\d{2})|9(?:1\\d|[5-7]\\d{2}|[089]))\\d{5}",,,,"92123456",,,[7,8,9,10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"1333\\d{4}",,,,"13331234",,,[8]],"MM",95,"00","0",,,"0",,,,[[,"(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["1|2[245]"],"0$1"],[,"(2)(\\d{4})(\\d{4})",
  37647. "$1 $2 $3",["251"],"0$1"],[,"(\\d)(\\d{2})(\\d{3})","$1 $2 $3",["16|2"],"0$1"],[,"(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["432|67|81"],"0$1"],[,"(\\d{2})(\\d{2})(\\d{3,4})","$1 $2 $3",["[4-8]"],"0$1"],[,"(9)(\\d{3})(\\d{4,6})","$1 $2 $3",["9(?:2[0-4]|[35-9]|4[137-9])"],"0$1"],[,"(9)([34]\\d{4})(\\d{4})","$1 $2 $3",["9(?:3[0-36]|4[0-57-9])"],"0$1"],[,"(9)(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["92[56]"],"0$1"],[,"(9)(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3 $4",["93"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,
  37648. ,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],MN:[,[,,"[12]\\d{7,9}|[57-9]\\d{7}",,,,,,,[8,9,10],[6,7]],[,,"[12](?:1\\d|2(?:[1-3]\\d?|7\\d)|3[2-8]\\d{1,2}|4[2-68]\\d{1,2}|5[1-4689]\\d{1,2})\\d{5}|5[0568]\\d{6}",,,,"50123456",,,,[6,7]],[,,"(?:8(?:[05689]\\d|3[01])|9[013-9]\\d)\\d{5}",,,,"88123456",,,[8]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"7[05-8]\\d{6}",,,,"75123456",,,[8]],"MN",976,"001","0",,,"0",,,,[[,"([12]\\d)(\\d{2})(\\d{4})","$1 $2 $3",["[12]1"],"0$1"],[,"([12]2\\d)(\\d{5,6})",
  37649. "$1 $2",["[12]2[1-3]"],"0$1"],[,"([12]\\d{3})(\\d{5})","$1 $2",["[12](?:27|[3-5])","[12](?:27|[3-5]\\d)2"],"0$1"],[,"(\\d{4})(\\d{4})","$1 $2",["[57-9]"],"$1"],[,"([12]\\d{4})(\\d{4,5})","$1 $2",["[12](?:27|[3-5])","[12](?:27|[3-5]\\d)[4-9]"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],MO:[,[,,"[268]\\d{7}",,,,,,,[8]],[,,"(?:28[2-57-9]|8[2-57-9]\\d)\\d{5}",,,,"28212345"],[,,"6(?:[2356]\\d|8[158])\\d{5}",,,,"66123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],
  37650. [,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"MO",853,"00",,,,,,,,[[,"([268]\\d{3})(\\d{4})","$1 $2"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],MP:[,[,,"[5689]\\d{9}",,,,,,,[10],[7]],[,,"670(?:2(?:3[3-7]|56|8[5-8])|32[1238]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[3589]|8[3-9]8|989)\\d{4}",,,,"6702345678",,,,[7]],[,,"670(?:2(?:3[3-7]|56|8[5-8])|32[1238]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[3589]|8[3-9]8|989)\\d{4}",,,,"6702345678",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",
  37651. ,,,"8002123456"],[,,"900[2-9]\\d{6}",,,,"9002123456"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"MP",1,"011","1",,,"1",,,1,,,[,,,,,,,,,[-1]],,"670",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],MQ:[,[,,"[56]\\d{8}",,,,,,,[9]],[,,"596(?:0[2-5]|[12]0|3[05-9]|4[024-8]|[5-7]\\d|89|9[4-8])\\d{4}",,,,"596301234"],[,,"696(?:[0-47-9]\\d|5[0-6]|6[0-4])\\d{4}",,,,"696201234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],
  37652. "MQ",596,"00","0",,,"0",,,,[[,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",,"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],MR:[,[,,"[2-48]\\d{7}",,,,,,,[8]],[,,"25[08]\\d{5}|35\\d{6}|45[1-7]\\d{5}",,,,"35123456"],[,,"[234][0-46-9]\\d{6}",,,,"22123456"],[,,"800\\d{5}",,,,"80012345"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"MR",222,"00",,,,,,,,[[,"([2-48]\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,
  37653. ,,,,[-1]],,,[,,,,,,,,,[-1]]],MS:[,[,,"[5689]\\d{9}",,,,,,,[10],[7]],[,,"664491\\d{4}",,,,"6644912345",,,,[7]],[,,"66449[2-6]\\d{4}",,,,"6644923456",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002123456"],[,,"900[2-9]\\d{6}",,,,"9002123456"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"MS",1,"011","1",,,"1",,,,,,[,,,,,,,,,[-1]],,"664",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],MT:[,[,,"[2357-9]\\d{7}",,,,,,,[8]],[,,"2(?:0(?:[169]\\d|3[1-4])|[1-357]\\d{2})\\d{4}",
  37654. ,,,"21001234"],[,,"(?:7(?:210|[79]\\d{2})|9(?:2(?:1[01]|31)|69[67]|8(?:1[1-3]|89|97)|9\\d{2}))\\d{4}",,,,"96961234"],[,,"800[3467]\\d{4}",,,,"80071234"],[,,"5(?:0(?:0(?:37|43)|6\\d{2}|70\\d|9[0168]\\d)|[12]\\d0[1-5])\\d{3}",,,,"50037123"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"3550\\d{4}",,,,"35501234"],"MT",356,"00",,,,,,,,[[,"(\\d{4})(\\d{4})","$1 $2"]],,[,,"7117\\d{4}",,,,"71171234"],,,[,,,,,,,,,[-1]],[,,"501\\d{5}",,,,"50112345"],,,[,,,,,,,,,[-1]]],MU:[,[,,"[2-9]\\d{6,7}",,,,,,,[7,8]],[,,"(?:2(?:[03478]\\d|1[0-7]|6[1-69])|4(?:[013568]\\d|2[4-7])|5(?:44\\d|471)|6\\d{2}|8(?:14|3[129]))\\d{4}",
  37655. ,,,"2012345"],[,,"5(?:2[59]\\d|4(?:2[1-389]|4\\d|7[1-9]|9\\d)|7\\d{2}|8(?:[0-25689]\\d|4[3479]|7[15-8])|9[0-8]\\d)\\d{4}",,,,"52512345",,,[8]],[,,"80[012]\\d{4}",,,,"8001234",,,[7]],[,,"30\\d{5}",,,,"3012345",,,[7]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"3(?:20|9\\d)\\d{4}",,,,"3201234",,,[7]],"MU",230,"0(?:0|[2-7]0|33)",,,,,,"020",,[[,"([2-46-9]\\d{2})(\\d{4})","$1 $2",["[2-46-9]"]],[,"(5\\d{3})(\\d{4})","$1 $2",["5"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],MV:[,[,,"[346-8]\\d{6,9}|9(?:00\\d{7}|\\d{6})",
  37656. ,,,,,,[7,10]],[,,"(?:3(?:0[0-3]|3[0-59])|6(?:[57][02468]|6[024568]|8[024689]|90))\\d{4}",,,,"6701234",,,[7]],[,,"(?:46[46]|7[3-9]\\d|9[15-9]\\d)\\d{4}",,,,"7712345",,,[7]],[,,"800\\d{7}",,,,"8001234567",,,[10]],[,,"900\\d{7}",,,,"9001234567",,,[10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"MV",960,"0(?:0|19)",,,,,,"00",,[[,"(\\d{3})(\\d{4})","$1-$2",["[3467]|9(?:[1-9]|0[1-9])"]],[,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]00"]]],,[,,"781\\d{4}",,,,"7812345",,,[7]],,,[,,,,,,,,,[-1]],[,,"4[05]0\\d{4}",
  37657. ,,,"4001234",,,[7]],,,[,,,,,,,,,[-1]]],MW:[,[,,"(?:1(?:\\d{2})?|[2789]\\d{2})\\d{6}",,,,,,,[7,9]],[,,"(?:1[2-9]|21\\d{2})\\d{5}",,,,"1234567"],[,,"(?:111|77\\d|88\\d|99\\d)\\d{6}",,,,"991234567",,,[9]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"MW",265,"00","0",,,"0",,,,[[,"(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["1"],"0$1"],[,"(2\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],[,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1789]"],"0$1"]],,[,,,,,,,,,[-1]],
  37658. ,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],MX:[,[,,"[1-9]\\d{9,10}",,,,,,,[10,11],[7,8]],[,,"(?:33|55|81)\\d{8}|(?:2(?:0[01]|2[1-9]|3[1-35-8]|4[13-9]|7[1-689]|8[1-578]|9[467])|3(?:1[1-79]|[2458][1-9]|7[1-8]|9[1-5])|4(?:1[1-57-9]|[24-6][1-9]|[37][1-8]|8[1-35-9]|9[2-689])|5(?:88|9[1-79])|6(?:1[2-68]|[234][1-9]|5[1-3689]|6[12457-9]|7[1-7]|8[67]|9[4-8])|7(?:[13467][1-9]|2[1-8]|5[13-9]|8[1-69]|9[17])|8(?:2[13-689]|3[1-6]|4[124-6]|6[1246-9]|7[1-378]|9[12479])|9(?:1[346-9]|2[1-4]|3[2-46-8]|5[1348]|[69][1-9]|7[12]|8[1-8]))\\d{7}",
  37659. ,,,"2221234567",,,[10],[7,8]],[,,"1(?:(?:33|55|81)\\d{8}|(?:2(?:2[1-9]|3[1-35-8]|4[13-9]|7[1-689]|8[1-578]|9[467])|3(?:1[1-79]|[2458][1-9]|7[1-8]|9[1-5])|4(?:1[1-57-9]|[24-6][1-9]|[37][1-8]|8[1-35-9]|9[2-689])|5(?:88|9[1-79])|6(?:1[2-68]|[2-4][1-9]|5[1-3689]|6[12457-9]|7[1-7]|8[67]|9[4-8])|7(?:[13467][1-9]|2[1-8]|5[13-9]|8[1-69]|9[17])|8(?:2[13-689]|3[1-6]|4[124-6]|6[1246-9]|7[1-378]|9[12479])|9(?:1[346-9]|2[1-4]|3[2-46-8]|5[1348]|[69][1-9]|7[12]|8[1-8]))\\d{7})",,,,"12221234567",,,[11]],[,,"8(?:00|88)\\d{7}",
  37660. ,,,"8001234567",,,[10]],[,,"900\\d{7}",,,,"9001234567",,,[10]],[,,"300\\d{7}",,,,"3001234567",,,[10]],[,,"500\\d{7}",,,,"5001234567",,,[10]],[,,,,,,,,,[-1]],"MX",52,"0[09]","01",,,"0[12]|04[45](\\d{10})","1$1",,,[[,"([358]\\d)(\\d{4})(\\d{4})","$1 $2 $3",["33|55|81"],"01 $1",,1],[,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2467]|3[0-2457-9]|5[089]|8[02-9]|9[0-35-9]"],"01 $1",,1],[,"(1)([358]\\d)(\\d{4})(\\d{4})","044 $2 $3 $4",["1(?:33|55|81)"],"$1",,1],[,"(1)(\\d{3})(\\d{3})(\\d{4})","044 $2 $3 $4",
  37661. ["1(?:[2467]|3[0-2457-9]|5[089]|8[2-9]|9[1-35-9])"],"$1",,1]],[[,"([358]\\d)(\\d{4})(\\d{4})","$1 $2 $3",["33|55|81"],"01 $1",,1],[,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2467]|3[0-2457-9]|5[089]|8[02-9]|9[0-35-9]"],"01 $1",,1],[,"(1)([358]\\d)(\\d{4})(\\d{4})","$1 $2 $3 $4",["1(?:33|55|81)"]],[,"(1)(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3 $4",["1(?:[2467]|3[0-2457-9]|5[089]|8[2-9]|9[1-35-9])"]]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],MY:[,[,,"[13-9]\\d{7,9}",,,,,,,[8,9,
  37662. 10],[6,7]],[,,"(?:3[2-9]\\d|[4-9][2-9])\\d{6}",,,,"323456789",,,[8,9],[6,7]],[,,"1(?:1[1-6]\\d{2}|[02-4679][2-9]\\d|59\\d{2}|8(?:1[23]|[2-9]\\d))\\d{5}",,,,"123456789",,,[9,10]],[,,"1[378]00\\d{6}",,,,"1300123456",,,[10]],[,,"1600\\d{6}",,,,"1600123456",,,[10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"154\\d{7}",,,,"1541234567",,,[10]],"MY",60,"00","0",,,"0",,,,[[,"([4-79])(\\d{3})(\\d{4})","$1-$2 $3",["[4-79]"],"0$1"],[,"(3)(\\d{4})(\\d{4})","$1-$2 $3",["3"],"0$1"],[,"([18]\\d)(\\d{3})(\\d{3,4})","$1-$2 $3",
  37663. ["1[02-46-9][1-9]|8"],"0$1"],[,"(1)([36-8]00)(\\d{2})(\\d{4})","$1-$2-$3-$4",["1[36-8]0"]],[,"(11)(\\d{4})(\\d{4})","$1-$2 $3",["11"],"0$1"],[,"(15[49])(\\d{3})(\\d{4})","$1-$2 $3",["15"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],MZ:[,[,,"[28]\\d{7,8}",,,,,,,[8,9]],[,,"2(?:[1346]\\d|5[0-2]|[78][12]|93)\\d{5}",,,,"21123456",,,[8]],[,,"8[2-7]\\d{7}",,,,"821234567",,,[9]],[,,"800\\d{6}",,,,"800123456",,,[9]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,
  37664. ,,[-1]],"MZ",258,"00",,,,,,,,[[,"([28]\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["2|8[2-7]"]],[,"(80\\d)(\\d{3})(\\d{3})","$1 $2 $3",["80"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],NA:[,[,,"[68]\\d{7,8}",,,,,,,[8,9]],[,,"6(?:1(?:17|2(?:[0189]\\d|[2-6]|7\\d?)|3(?:[01378]|2\\d)|4(?:[024]|10?|3[15]?)|69|7[014])|2(?:17|5(?:[0-36-8]|4\\d?)|69|70)|3(?:17|2(?:[0237]\\d?|[14-689])|34|6[289]|7[01]|81)|4(?:17|2(?:[012]|7\\d?)|4(?:[06]|1\\d?)|5(?:[01357]|[25]\\d?)|69|7[01])|5(?:17|2(?:[0459]|[23678]\\d?)|69|7[01])|6(?:17|2(?:5|6\\d?)|38|42|69|7[01])|7(?:17|2(?:[569]|[234]\\d?)|3(?:0\\d?|[13])|6[89]|7[01]))\\d{4}",
  37665. ,,,"61221234"],[,,"(?:60|8[125])\\d{7}",,,,"811234567",,,[9]],[,,,,,,,,,[-1]],[,,"8701\\d{5}",,,,"870123456",,,[9]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"8(?:3\\d{2}|86)\\d{5}",,,,"88612345"],"NA",264,"00","0",,,"0",,,,[[,"(8\\d)(\\d{3})(\\d{4})","$1 $2 $3",["8[1235]"],"0$1"],[,"(6\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["6"],"0$1"],[,"(88)(\\d{3})(\\d{3})","$1 $2 $3",["88"],"0$1"],[,"(870)(\\d{3})(\\d{3})","$1 $2 $3",["870"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],
  37666. NC:[,[,,"[2-57-9]\\d{5}",,,,,,,[6]],[,,"(?:2[03-9]|3[0-5]|4[1-7]|88)\\d{4}",,,,"201234"],[,,"(?:5[0-4]|[79]\\d|8[0-79])\\d{4}",,,,"751234"],[,,,,,,,,,[-1]],[,,"36\\d{4}",,,,"366711"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"NC",687,"00",,,,,,,,[[,"(\\d{2})(\\d{2})(\\d{2})","$1.$2.$3",["[2-46-9]|5[0-4]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],NE:[,[,,"[0289]\\d{7}",,,,,,,[8]],[,,"2(?:0(?:20|3[1-7]|4[134]|5[14]|6[14578]|7[1-578])|1(?:4[145]|5[14]|6[14-68]|7[169]|88))\\d{4}",
  37667. ,,,"20201234"],[,,"(?:8[089]|9\\d)\\d{6}",,,,"93123456"],[,,"08\\d{6}",,,,"08123456"],[,,"09\\d{6}",,,,"09123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"NE",227,"00",,,,,,,,[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[289]|09"]],[,"(08)(\\d{3})(\\d{3})","$1 $2 $3",["08"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],NF:[,[,,"[13]\\d{5}",,,,,,,[6],[5]],[,,"(?:1(?:06|17|28|39)|3[012]\\d)\\d{3}",,,,"106609",,,,[5]],[,,"3[58]\\d{4}",,,,"381234",,,,[5]],[,
  37668. ,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"NF",672,"00",,,,,,,,[[,"(\\d{2})(\\d{4})","$1 $2",["1"]],[,"(\\d)(\\d{5})","$1 $2",["3"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],NG:[,[,,"[1-6]\\d{5,8}|9\\d{5,9}|[78]\\d{5,13}",,,,,,,[7,8,10,11,12,13,14],[5,6]],[,,"[12]\\d{6,7}|9(?:0[3-9]|[1-9]\\d)\\d{5}|(?:3\\d|4[023568]|5[02368]|6[02-469]|7[4-69]|8[2-9])\\d{6}|(?:4[47]|5[14579]|6[1578]|7[0-357])\\d{5,6}|(?:78|41)\\d{5}",,,,"12345678",,
  37669. ,[7,8],[5,6]],[,,"(?:1(?:7[34]\\d|8(?:04|[124579]\\d|8[0-3])|95\\d)|287[0-7]|3(?:18[1-8]|88[0-7]|9(?:8[5-9]|6[1-5]))|4(?:28[0-2]|6(?:7[1-9]|8[02-47])|88[0-2])|5(?:2(?:7[7-9]|8\\d)|38[1-79]|48[0-7]|68[4-7])|6(?:2(?:7[7-9]|8\\d)|4(?:3[7-9]|[68][129]|7[04-69]|9[1-8])|58[0-2]|98[7-9])|7(?:38[0-7]|69[1-8]|78[2-4])|8(?:28[3-9]|38[0-2]|4(?:2[12]|3[147-9]|5[346]|7[4-9]|8[014-689]|90)|58[1-8]|78[2-9]|88[5-7])|98[07]\\d)\\d{4}|(?:70(?:[1-689]\\d|7[0-3])|8(?:0(?:1[01]|[2-9]\\d)|1(?:[0-8]\\d|9[01]))|90[235-9]\\d)\\d{6}",
  37670. ,,,"8021234567",,,[8,10]],[,,"800\\d{7,11}",,,,"80017591759",,,[10,11,12,13,14]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"NG",234,"009","0",,,"0",,,,[[,"(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[12]|9(?:0[3-9]|[1-9])"],"0$1"],[,"(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["[3-6]|7(?:[1-79]|0[1-9])|8[2-9]"],"0$1"],[,"(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["70|8[01]|90[235-9]"],"0$1"],[,"([78]00)(\\d{4})(\\d{4,5})","$1 $2 $3",["[78]00"],"0$1"],[,"([78]00)(\\d{5})(\\d{5,6})","$1 $2 $3",
  37671. ["[78]00"],"0$1"],[,"(78)(\\d{2})(\\d{3})","$1 $2 $3",["78"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"700\\d{7,11}",,,,"7001234567",,,[10,11,12,13,14]],,,[,,,,,,,,,[-1]]],NI:[,[,,"[125-8]\\d{7}",,,,,,,[8]],[,,"2\\d{7}",,,,"21234567"],[,,"(?:5(?:5[0-7]|[78]\\d)|6(?:20|3[035]|4[045]|5[05]|77|8[1-9]|9[059])|7[5-8]\\d|8\\d{2})\\d{5}",,,,"81234567"],[,,"1800\\d{4}",,,,"18001234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"NI",505,"00",,,,,,,,[[,"(\\d{4})(\\d{4})","$1 $2"]],
  37672. ,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],NL:[,[,,"1\\d{4,8}|[2-7]\\d{8}|[89]\\d{6,9}",,,,,,,[5,6,7,8,9,10]],[,,"(?:1[0135-8]|2[02-69]|3[0-68]|4[0135-9]|[57]\\d|8[478])\\d{7}",,,,"101234567",,,[9]],[,,"6[1-58]\\d{7}",,,,"612345678",,,[9]],[,,"800\\d{4,7}",,,,"8001234",,,[7,8,9,10]],[,,"90[069]\\d{4,7}",,,,"9061234",,,[7,8,9,10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"(?:6760|85\\d{2})\\d{5}",,,,"851234567",,,[9]],"NL",31,"00","0",,,"0",,,,[[,"([1-578]\\d)(\\d{3})(\\d{4})",
  37673. "$1 $2 $3",["1[035]|2[0346]|3[03568]|4[0356]|5[0358]|7|8[4578]"],"0$1"],[,"([1-5]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["1[16-8]|2[259]|3[124]|4[17-9]|5[124679]"],"0$1"],[,"(6)(\\d{8})","$1 $2",["6[0-57-9]"],"0$1"],[,"(66)(\\d{7})","$1 $2",["66"],"0$1"],[,"(14)(\\d{3,4})","$1 $2",["14"],"$1"],[,"([89]0\\d)(\\d{4,7})","$1 $2",["80|9"],"0$1"]],,[,,"66\\d{7}",,,,"662345678",,,[9]],,,[,,"14\\d{3,4}",,,,"14123",,,[5,6]],[,,"140(?:1(?:[035]|[16-8]\\d)|2(?:[0346]|[259]\\d)|3(?:[03568]|[124]\\d)|4(?:[0356]|[17-9]\\d)|5(?:[0358]|[124679]\\d)|7\\d|8[458])",
  37674. ,,,"14020",,,[5,6]],,,[,,,,,,,,,[-1]]],NO:[,[,,"0\\d{4}|[2-9]\\d{7}",,,,,,,[5,8]],[,,"(?:2[1-4]|3[1-3578]|5[1-35-7]|6[1-4679]|7[0-8])\\d{6}",,,,"21234567",,,[8]],[,,"(?:4[015-8]|5[89]|87|9\\d)\\d{6}",,,,"40612345",,,[8]],[,,"80[01]\\d{5}",,,,"80012345",,,[8]],[,,"82[09]\\d{5}",,,,"82012345",,,[8]],[,,"810(?:0[0-6]|[2-8]\\d)\\d{3}",,,,"81021234",,,[8]],[,,"880\\d{5}",,,,"88012345",,,[8]],[,,"85[0-5]\\d{5}",,,,"85012345",,,[8]],"NO",47,"00",,,,,,,,[[,"([489]\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["[489]"]],
  37675. [,"([235-7]\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[235-7]"]]],,[,,,,,,,,,[-1]],1,,[,,,,,,,,,[-1]],[,,"0\\d{4}|81(?:0(?:0[7-9]|1\\d)|5\\d{2})\\d{3}",,,,"01234"],,,[,,"81[23]\\d{5}",,,,"81212345",,,[8]]],NP:[,[,,"[1-8]\\d{7}|9(?:[1-69]\\d{6,8}|7[2-6]\\d{5,7}|8\\d{8})",,,,,,,[8,10],[6,7]],[,,"(?:1[0-6]\\d|2[13-79][2-6]|3[135-8][2-6]|4[146-9][2-6]|5[135-7][2-6]|6[13-9][2-6]|7[15-9][2-6]|8[1-46-9][2-6]|9[1-79][2-6])\\d{5}",,,,"14567890",,,[8],[6,7]],[,,"9(?:6[013]|7[245]|8[0-24-6])\\d{7}",,,,"9841234567",
  37676. ,,[10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"NP",977,"00","0",,,"0",,,,[[,"(1)(\\d{7})","$1-$2",["1[2-6]"],"0$1"],[,"(\\d{2})(\\d{6})","$1-$2",["1[01]|[2-8]|9(?:[1-69]|7[15-9])"],"0$1"],[,"(9\\d{2})(\\d{7})","$1-$2",["9(?:6[013]|7[245]|8)"],"$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],NR:[,[,,"[458]\\d{6}",,,,,,,[7]],[,,"(?:444|888)\\d{4}",,,,"4441234"],[,,"55[5-9]\\d{4}",,,,"5551234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,
  37677. ,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"NR",674,"00",,,,,,,,[[,"(\\d{3})(\\d{4})","$1 $2"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],NU:[,[,,"[1-5]\\d{3}",,,,,,,[4]],[,,"[34]\\d{3}",,,,"4002"],[,,"[125]\\d{3}",,,,"1234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"NU",683,"00",,,,,,,,,,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],NZ:[,[,,"6[235-9]\\d{6}|[2-57-9]\\d{7,9}",,,,,,,[8,9,10],[7]],[,,"(?:3[2-79]|[49][2-9]|6[235-9]|7[2-57-9])\\d{6}|24099\\d{3}",
  37678. ,,,"32345678",,,[8],[7]],[,,"2(?:[028]\\d{7,8}|1(?:[03]\\d{5,7}|[12457]\\d{5,6}|[689]\\d{5})|[79]\\d{7})",,,,"211234567"],[,,"508\\d{6,7}|80\\d{6,8}",,,,"800123456"],[,,"90\\d{6,7}",,,,"900123456",,,[8,9]],[,,,,,,,,,[-1]],[,,"70\\d{7}",,,,"701234567",,,[9]],[,,,,,,,,,[-1]],"NZ",64,"0(?:0|161)","0",,,"0",,"00",,[[,"(\\d)(\\d{3})(\\d{4})","$1-$2 $3",["240|[346]|7[2-57-9]|9[1-9]"],"0$1"],[,"(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["21"],"0$1"],[,"(\\d{2})(\\d{3})(\\d{3,5})","$1 $2 $3",["2(?:1[1-9]|[69]|7[0-35-9])|70|86"],
  37679. "0$1"],[,"(2\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["2[028]"],"0$1"],[,"(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["90"],"0$1"],[,"(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:10|74)|5|[89]0"],"0$1"]],,[,,"[28]6\\d{6,7}",,,,"26123456",,,[8,9]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],OM:[,[,,"(?:5|[279]\\d)\\d{6}|800\\d{5,6}",,,,,,,[7,8,9]],[,,"2[2-6]\\d{6}",,,,"23123456",,,[8]],[,,"7[19]\\d{6}|9(?:0[1-9]|[1-9]\\d)\\d{5}",,,,"92123456",,,[8]],[,,"8007\\d{4,5}|500\\d{4}",,,,"80071234"],[,,"900\\d{5}",
  37680. ,,,"90012345",,,[8]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"OM",968,"00",,,,,,,,[[,"(2\\d)(\\d{6})","$1 $2",["2"]],[,"([79]\\d{3})(\\d{4})","$1 $2",["[79]"]],[,"([58]00)(\\d{4,6})","$1 $2",["[58]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],PA:[,[,,"[1-9]\\d{6,7}",,,,,,,[7,8]],[,,"(?:1(?:0[0-8]|1[49]|2[37]|3[0137]|4[147]|5[05]|6[58]|7[0167]|8[58]|9[139])|2(?:[0235679]\\d|1[0-7]|4[04-9]|8[028])|3(?:[09]\\d|1[014-7]|2[0-3]|3[03]|4[03-57]|55|6[068]|7[06-8]|8[06-9])|4(?:3[013-69]|4\\d|7[0-589])|5(?:[01]\\d|2[0-7]|[56]0|79)|7(?:0[09]|2[0-267]|3[06]|[469]0|5[06-9]|7[0-24-79]|8[7-9])|8(?:09|[34]\\d|5[0134]|8[02])|9(?:0[6-9]|1[016-8]|2[036-8]|3[3679]|40|5[0489]|6[06-9]|7[046-9]|8[36-8]|9[1-9]))\\d{4}",
  37681. ,,,"2001234",,,[7]],[,,"(?:1[16]1|21[89]|8(?:1[01]|7[23]))\\d{4}|6(?:[024-9]\\d|1[0-5]|3[0-24-9])\\d{5}",,,,"60012345"],[,,"80[09]\\d{4}",,,,"8001234",,,[7]],[,,"(?:779|8(?:55|60|7[78])|9(?:00|81))\\d{4}",,,,"8601234",,,[7]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"PA",507,"00",,,,,,,,[[,"(\\d{3})(\\d{4})","$1-$2",["[1-57-9]"]],[,"(\\d{4})(\\d{4})","$1-$2",["6"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],PE:[,[,,"[14-9]\\d{7,8}",,,,,,,[8,9],[6,7]],[,,"(?:1\\d|4[1-4]|5[1-46]|6[1-7]|7[2-46]|8[2-4])\\d{6}",
  37682. ,,,"11234567",,,[8],[6,7]],[,,"9\\d{8}",,,,"912345678",,,[9]],[,,"800\\d{5}",,,,"80012345",,,[8]],[,,"805\\d{5}",,,,"80512345",,,[8]],[,,"801\\d{5}",,,,"80112345",,,[8]],[,,"80[24]\\d{5}",,,,"80212345",,,[8]],[,,,,,,,,,[-1]],"PE",51,"19(?:1[124]|77|90)00","0"," Anexo ",,"0",,,,[[,"(1)(\\d{7})","$1 $2",["1"],"(0$1)"],[,"([4-8]\\d)(\\d{6})","$1 $2",["[4-7]|8[2-4]"],"(0$1)"],[,"(\\d{3})(\\d{5})","$1 $2",["80"],"(0$1)"],[,"(9\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,
  37683. ,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],PF:[,[,,"4\\d{5,7}|8\\d{7}",,,,,,,[6,8]],[,,"4(?:[09][45689]\\d|4)\\d{4}",,,,"40412345"],[,,"8[79]\\d{6}",,,,"87123456",,,[8]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"PF",689,"00",,,,,,,,[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4[09]|8[79]"]],[,"(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["44"]]],,[,,,,,,,,,[-1]],,,[,,"44\\d{4}",,,,"441234",,,[6]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],PG:[,[,,"[1-9]\\d{6,7}",,
  37684. ,,,,,[7,8]],[,,"(?:3[0-2]\\d|4[257]\\d|5[34]\\d|64[1-9]|77(?:[0-24]\\d|30)|85[02-46-9]|9[78]\\d)\\d{4}",,,,"3123456",,,[7]],[,,"7(?:[0-689]\\d|75)\\d{5}",,,,"70123456",,,[8]],[,,"180\\d{4}",,,,"1801234",,,[7]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"2(?:0[0-47]|7[568])\\d{4}",,,,"2751234",,,[7]],"PG",675,"140[1-3]|00",,,,,,"00",,[[,"(\\d{3})(\\d{4})","$1 $2",["[13-689]|27"]],[,"(\\d{4})(\\d{4})","$1 $2",["20|7"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],PH:[,
  37685. [,,"2\\d{5,7}|[3-9]\\d{7,9}|1800\\d{7,9}",,,,,,,[6,8,9,10,11,12,13],[5,7]],[,,"2\\d{5}(?:\\d{2})?|(?:3[2-68]|4[2-9]|5[2-6]|6[2-58]|7[24578]|8[2-8])\\d{7}|88(?:22\\d{6}|42\\d{4})",,,,"21234567",,,[6,8,9,10],[5,7]],[,,"(?:81[37]|9(?:0[5-9]|1[024-9]|2[0-35-9]|3[02-9]|4[235-9]|5[056]|6[5-7]|7[34-79]|89|9[4-9]))\\d{7}",,,,"9051234567",,,[10]],[,,"1800\\d{7,9}",,,,"180012345678",,,[11,12,13]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"PH",63,"00","0",,,"0",,,,[[,"(2)(\\d{3})(\\d{4})",
  37686. "$1 $2 $3",["2"],"(0$1)"],[,"(2)(\\d{5})","$1 $2",["2"],"(0$1)"],[,"(\\d{4})(\\d{4,6})","$1 $2",["3(?:23|39|46)|4(?:2[3-6]|[35]9|4[26]|76)|5(?:22|44)|642|8(?:62|8[245])","3(?:230|397|461)|4(?:2(?:35|[46]4|51)|396|4(?:22|63)|59[347]|76[15])|5(?:221|446)|642[23]|8(?:622|8(?:[24]2|5[13]))"],"(0$1)"],[,"(\\d{5})(\\d{4})","$1 $2",["346|4(?:27|9[35])|883","3469|4(?:279|9(?:30|56))|8834"],"(0$1)"],[,"([3-8]\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[3-8]"],"(0$1)"],[,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["81|9"],
  37687. "0$1"],[,"(1800)(\\d{3})(\\d{4})","$1 $2 $3",["1"]],[,"(1800)(\\d{1,2})(\\d{3})(\\d{4})","$1 $2 $3 $4",["1"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],PK:[,[,,"1\\d{8}|[2-8]\\d{5,11}|9(?:[013-9]\\d{4,9}|2\\d(?:111\\d{6}|\\d{3,7}))",,,,,,,[8,9,10,11,12],[6,7]],[,,"(?:21|42)[2-9]\\d{7}|(?:2[25]|4[0146-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)[2-9]\\d{6}|(?:2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:2[2-8]|3[27-9]|4[2-6]|6[3569]|9[25-8]))[2-9]\\d{5,6}|58[126]\\d{7}",
  37688. ,,,"2123456789",,,[9,10],[6,7,8]],[,,"3(?:[014]\\d|2[0-5]|3[0-7]|55|64)\\d{7}",,,,"3012345678",,,[10]],[,,"800\\d{5}",,,,"80012345",,,[8]],[,,"900\\d{5}",,,,"90012345",,,[8]],[,,,,,,,,,[-1]],[,,"122\\d{6}",,,,"122044444",,,[9]],[,,,,,,,,,[-1]],"PK",92,"00","0",,,"0",,,,[[,"(\\d{2})(111)(\\d{3})(\\d{3})","$1 $2 $3 $4",["(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)1","(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)11","(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)111"],"(0$1)"],
  37689. [,"(\\d{3})(111)(\\d{3})(\\d{3})","$1 $2 $3 $4",["2[349]|45|54|60|72|8[2-5]|9[2-9]","(?:2[349]|45|54|60|72|8[2-5]|9[2-9])\\d1","(?:2[349]|45|54|60|72|8[2-5]|9[2-9])\\d11","(?:2[349]|45|54|60|72|8[2-5]|9[2-9])\\d111"],"(0$1)"],[,"(\\d{2})(\\d{7,8})","$1 $2",["(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)[2-9]"],"(0$1)"],[,"(\\d{3})(\\d{6,7})","$1 $2",["2[349]|45|5(?:4|8[12])|60|72|8[2-5]|9[2-9]","(?:2[349]|45|5(?:4|8[12])|60|72|8[2-5]|9[2-9])\\d[2-9]"],"(0$1)"],[,"(3\\d{2})(\\d{7})","$1 $2",
  37690. ["3"],"0$1"],[,"(1\\d{3})(\\d{5,6})","$1 $2",["1"],"$1"],[,"(586\\d{2})(\\d{5})","$1 $2",["586"],"(0$1)"],[,"([89]00)(\\d{3})(\\d{2})","$1 $2 $3",["[89]00"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"(?:2(?:[125]|3[2358]|4[2-4]|9[2-8])|4(?:[0-246-9]|5[3479])|5(?:[1-35-7]|4[2-467])|6(?:[1-8]|0[468])|7(?:[14]|2[236])|8(?:[16]|2[2-689]|3[23578]|4[3478]|5[2356])|9(?:1|22|3[27-9]|4[2-6]|6[3569]|9[2-7]))111\\d{6}",,,,"21111825888",,,[11,12]],,,[,,,,,,,,,[-1]]],PL:[,[,,"[1-57-9]\\d{6,8}|6\\d{5,8}",,
  37691. ,,,,,[6,7,8,9]],[,,"(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])(?:\\d{7}|19\\d{3})",,,,"123456789",,,[7,9]],[,,"(?:45|5[0137]|6[069]|7[2389]|88)\\d{7}",,,,"512345678",,,[9]],[,,"800\\d{6}",,,,"800123456",,,[9]],[,,"70[01346-8]\\d{6}",,,,"701234567",,,[9]],[,,"801\\d{6}",,,,"801234567",,,[9]],[,,,,,,,,,[-1]],[,,"39\\d{7}",,,,"391234567",,,[9]],"PL",48,"00",,,,,,,,[[,"(\\d{3})(\\d{3})","$1 $2",["11[68]|64"]],[,"(\\d{5})","$1",["19"]],[,"(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",
  37692. ["1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145]"]],[,"(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["64"]],[,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["26|39|45|5[0137]|6[0469]|7[02389]|8[08]"]],[,"(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[14]|2[0-57-9]|3[2-4]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145]"]]],,[,,"64\\d{4,7}",,,,"641234567"],,,[,,,,,,,,,[-1]],[,,"804\\d{6}",,,,"804123456",,,[9]],,,[,,,,,,,,,[-1]]],PM:[,[,,"[45]\\d{5}",,,,,,,[6]],[,,"41\\d{4}",,,,"411234"],
  37693. [,,"(?:40|55)\\d{4}",,,,"551234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"PM",508,"00","0",,,"0",,,,[[,"([45]\\d)(\\d{2})(\\d{2})","$1 $2 $3",,"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],PR:[,[,,"[5789]\\d{9}",,,,,,,[10],[7]],[,,"(?:787|939)[2-9]\\d{6}",,,,"7872345678",,,,[7]],[,,"(?:787|939)[2-9]\\d{6}",,,,"7872345678",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002345678"],[,,"900[2-9]\\d{6}",,,,"9002345678"],
  37694. [,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"PR",1,"011","1",,,"1",,,1,,,[,,,,,,,,,[-1]],,"787|939",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],PS:[,[,,"1\\d{9}|[24589]\\d{7,8}",,,,,,,[8,9,10],[7]],[,,"(?:22[234789]|42[45]|82[01458]|92[369])\\d{5}",,,,"22234567",,,[8],[7]],[,,"5[69]\\d{7}",,,,"599123456",,,[9]],[,,"1800\\d{6}",,,,"1800123456",,,[10]],[,,,,,,,,,[-1]],[,,"1700\\d{6}",,,,"1700123456",,,[10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"PS",970,
  37695. "00","0",,,"0",,,,[[,"([2489])(2\\d{2})(\\d{4})","$1 $2 $3",["[2489]"],"0$1"],[,"(5[69]\\d)(\\d{3})(\\d{3})","$1 $2 $3",["5"],"0$1"],[,"(1[78]00)(\\d{3})(\\d{3})","$1 $2 $3",["1"],"$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],PT:[,[,,"[2-46-9]\\d{8}",,,,,,,[9]],[,,"2(?:[12]\\d|[35][1-689]|4[1-59]|6[1-35689]|7[1-9]|8[1-69]|9[1256])\\d{6}",,,,"212345678"],[,,"9(?:[1236]\\d{2}|480)\\d{5}",,,,"912345678"],[,,"80[02]\\d{6}",,,,"800123456"],[,,"6(?:0[178]|4[68])\\d{6}|76(?:0[1-57]|1[2-47]|2[237])\\d{5}",
  37696. ,,,"760123456"],[,,"80(?:8\\d|9[1579])\\d{5}",,,,"808123456"],[,,"884[0-4689]\\d{5}",,,,"884123456"],[,,"30\\d{7}",,,,"301234567"],"PT",351,"00",,,,,,,,[[,"(2\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2[12]"]],[,"([2-46-9]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2[3-9]|[346-9]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"7(?:0(?:7\\d|8[17]))\\d{5}",,,,"707123456"],,,[,,"600\\d{6}",,,,"600110000"]],PW:[,[,,"[2-8]\\d{6}",,,,,,,[7]],[,,"2552255|(?:277|345|488|5(?:35|44|87)|6(?:22|54|79)|7(?:33|47)|8(?:24|55|76))\\d{4}",
  37697. ,,,"2771234"],[,,"(?:6[234689]0|77[45789])\\d{4}",,,,"6201234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"PW",680,"01[12]",,,,,,,,[[,"(\\d{3})(\\d{4})","$1 $2"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],PY:[,[,,"5[0-5]\\d{4,7}|[2-46-9]\\d{5,8}",,,,,,,[6,7,8,9],[5]],[,,"(?:[26]1|3[289]|4[124678]|7[123]|8[1236])\\d{5,7}|(?:2(?:2[4568]|7[15]|9[1-5])|3(?:18|3[167]|4[2357]|51)|4(?:18|2[45]|3[12]|5[13]|64|71|9[1-47])|5(?:[1-4]\\d|5[0234])|6(?:3[1-3]|44|7[1-4678])|7(?:17|4[0-4]|6[1-578]|75|8[0-8])|858)\\d{5,6}",
  37698. ,,,"212345678",,,[7,8,9],[5,6]],[,,"9(?:6[12]|[78][1-6]|9[1-5])\\d{6}",,,,"961456789",,,[9]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"8700[0-4]\\d{4}",,,,"870012345",,,[9]],"PY",595,"00","0",,,"0",,,,[[,"(\\d{2})(\\d{5})","$1 $2",["(?:[26]1|3[289]|4[124678]|7[123]|8[1236])"],"(0$1)"],[,"(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["(?:[26]1|3[289]|4[124678]|7[123]|8[1236])"],"(0$1)"],[,"(\\d{3})(\\d{3,6})","$1 $2",["[2-9]0"],"0$1"],[,"(\\d{3})(\\d{6})","$1 $2",["9[1-9]"],"0$1"],
  37699. [,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["8700"]],[,"(\\d{3})(\\d{4,5})","$1 $2",["[2-8][1-9]"],"(0$1)"],[,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8][1-9]"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"[2-9]0\\d{4,7}",,,,"201234567"],,,[,,,,,,,,,[-1]]],QA:[,[,,"[2-8]\\d{6,7}",,,,,,,[7,8]],[,,"4[04]\\d{6}",,,,"44123456",,,[8]],[,,"[3567]\\d{7}",,,,"33123456",,,[8]],[,,"800\\d{4}",,,,"8001234",,,[7]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"QA",974,"00",,,,,,,,[[,"([28]\\d{2})(\\d{4})",
  37700. "$1 $2",["[28]"]],[,"([3-7]\\d{3})(\\d{4})","$1 $2",["[3-7]"]]],,[,,"2(?:[12]\\d|61)\\d{4}",,,,"2123456",,,[7]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],RE:[,[,,"[268]\\d{8}",,,,,,,[9]],[,,"262\\d{6}",,,,"262161234"],[,,"69(?:2\\d{2}|3(?:0[0-46]|1[013]|2[0-2]|3[039]|4[0-7]|5[05]|6[06]|7[07]|8[0-38]|9[0-479]))\\d{4}",,,,"692123456"],[,,"80\\d{7}",,,,"801234567"],[,,"89[1-37-9]\\d{6}",,,,"891123456"],[,,"8(?:1[019]|2[0156]|84|90)\\d{6}",,,,"810123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"RE",
  37701. 262,"00","0",,,"0",,,,[[,"([268]\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",,"0$1"]],,[,,,,,,,,,[-1]],1,"262|69|8",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],RO:[,[,,"[23]\\d{5,8}|[7-9]\\d{8}",,,,,,,[6,9]],[,,"2(?:1(?:\\d{7}|9\\d{3})|[3-6](?:\\d{7}|\\d9\\d{2}))|3(?:1\\d{4}(?:\\d{3})?|[3-6]\\d{7})",,,,"211234567"],[,,"7(?:[0-8]\\d{2}|99\\d)\\d{5}",,,,"712345678",,,[9]],[,,"800\\d{6}",,,,"800123456",,,[9]],[,,"90[036]\\d{6}",,,,"900123456",,,[9]],[,,"801\\d{6}",,,,"801123456",,,[9]],[,,,
  37702. ,,,,,,[-1]],[,,,,,,,,,[-1]],"RO",40,"00","0"," int ",,"0",,,,[[,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[23]1"],"0$1"],[,"(\\d{2})(\\d{4})","$1 $2",["[23]1"],"0$1"],[,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[23][3-7]|[7-9]"],"0$1"],[,"(2\\d{2})(\\d{3})","$1 $2",["2[3-6]"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"37\\d{7}",,,,"372123456",,,[9]],,,[,,,,,,,,,[-1]]],RS:[,[,,"[126-9]\\d{4,11}|3(?:[0-79]\\d{3,10}|8[2-9]\\d{2,9})",,,,,,,[6,7,8,9,10,11,12],[5]],[,,"(?:1(?:[02-9][2-9]|1[1-9])\\d|2(?:[0-24-7][2-9]\\d|[389](?:0[2-9]|[2-9]\\d))|3(?:[0-8][2-9]\\d|9(?:[2-9]\\d|0[2-9])))\\d{3,8}",
  37703. ,,,"10234567",,,[7,8,9,10,11,12],[5,6]],[,,"6(?:[0-689]|7\\d)\\d{6,7}",,,,"601234567",,,[8,9,10]],[,,"800\\d{3,9}",,,,"80012345"],[,,"(?:90[0169]|78\\d)\\d{3,7}",,,,"90012345"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"RS",381,"00","0",,,"0",,,,[[,"([23]\\d{2})(\\d{4,9})","$1 $2",["(?:2[389]|39)0"],"0$1"],[,"([1-3]\\d)(\\d{5,10})","$1 $2",["1|2(?:[0-24-7]|[389][1-9])|3(?:[0-8]|9[1-9])"],"0$1"],[,"(6\\d)(\\d{6,8})","$1 $2",["6"],"0$1"],[,"([89]\\d{2})(\\d{3,9})","$1 $2",["[89]"],"0$1"],[,"(7[26])(\\d{4,9})",
  37704. "$1 $2",["7[26]"],"0$1"],[,"(7[08]\\d)(\\d{4,9})","$1 $2",["7[08]"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"7[06]\\d{4,10}",,,,"700123456"],,,[,,,,,,,,,[-1]]],RU:[,[,,"[3489]\\d{9}",,,,,,,[10]],[,,"(?:3(?:0[12]|4[1-35-79]|5[1-3]|65|8[1-58]|9[0145])|4(?:01|1[1356]|2[13467]|7[1-5]|8[1-7]|9[1-689])|8(?:1[1-8]|2[01]|3[13-6]|4[0-8]|5[15]|6[1-35-79]|7[1-37-9]))\\d{7}",,,,"3011234567"],[,,"9\\d{9}",,,,"9123456789"],[,,"80[04]\\d{7}",,,,"8001234567"],[,,"80[39]\\d{7}",,,,"8091234567"],[,,,,,,,,,[-1]],
  37705. [,,"808\\d{7}",,,,"8081234567"],[,,,,,,,,,[-1]],"RU",7,"810","8",,,"8",,"8~10",,[[,"(\\d{3})(\\d{2})(\\d{2})","$1-$2-$3",["[1-79]"],"$1",,1],[,"([3489]\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[34689]"],"8 ($1)",,1],[,"(7\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"8 ($1)",,1]],[[,"([3489]\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[34689]"],"8 ($1)",,1],[,"(7\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"8 ($1)",,1]],[,,,,,,,,,[-1]],1,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],RW:[,
  37706. [,,"[027-9]\\d{7,8}",,,,,,,[8,9]],[,,"2[258]\\d{7}|06\\d{6}",,,,"250123456"],[,,"7[238]\\d{7}",,,,"720123456",,,[9]],[,,"800\\d{6}",,,,"800123456",,,[9]],[,,"900\\d{6}",,,,"900123456",,,[9]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"RW",250,"00","0",,,"0",,,,[[,"(2\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"$1"],[,"([7-9]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[7-9]"],"0$1"],[,"(0\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,
  37707. ,[-1]]],SA:[,[,,"1\\d{7,8}|(?:[2-467]|92)\\d{7}|5\\d{8}|8\\d{9}",,,,,,,[8,9,10],[7]],[,,"11\\d{7}|1?(?:2[24-8]|3[35-8]|4[3-68]|6[2-5]|7[235-7])\\d{6}",,,,"112345678",,,[8,9],[7]],[,,"(?:5(?:[013-689]\\d|7[0-36-8])|811\\d)\\d{6}",,,,"512345678",,,[9,10]],[,,"800\\d{7}",,,,"8001234567",,,[10]],[,,,,,,,,,[-1]],[,,"92[05]\\d{6}",,,,"920012345",,,[9]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"SA",966,"00","0",,,"0",,,,[[,"([1-467])(\\d{3})(\\d{4})","$1 $2 $3",["[1-467]"],"0$1"],[,"(1\\d)(\\d{3})(\\d{4})","$1 $2 $3",
  37708. ["1[1-467]"],"0$1"],[,"(5\\d)(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"],[,"(92\\d{2})(\\d{5})","$1 $2",["92"],"$1"],[,"(800)(\\d{3})(\\d{4})","$1 $2 $3",["80"],"$1"],[,"(811)(\\d{3})(\\d{3,4})","$1 $2 $3",["81"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],SB:[,[,,"[1-9]\\d{4,6}",,,,,,,[5,7]],[,,"(?:1[4-79]|[23]\\d|4[0-2]|5[03]|6[0-37])\\d{3}",,,,"40123",,,[5]],[,,"48\\d{3}|7(?:30|[46-8]\\d|5[025-9]|9[0-5])\\d{4}|8[4-9]\\d{5}|9(?:1[2-9]|2[013-9]|3[0-2]|[46]\\d|5[0-46-9]|7[0-689]|8[0-79]|9[0-8])\\d{4}",
  37709. ,,,"7421234"],[,,"1[38]\\d{3}",,,,"18123",,,[5]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"5[12]\\d{3}",,,,"51123",,,[5]],"SB",677,"0[01]",,,,,,,,[[,"(\\d{2})(\\d{5})","$1 $2",["[7-9]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],SC:[,[,,"[24689]\\d{5,6}",,,,,,,[7]],[,,"4[2-46]\\d{5}",,,,"4217123"],[,,"2[5-8]\\d{5}",,,,"2510123"],[,,"8000\\d{3}",,,,"8000000"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"(?:64\\d|971)\\d{4}",,,,"6412345"],"SC",248,"0(?:[02]|10?)",
  37710. ,,,,,"00",,[[,"(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[246]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],SD:[,[,,"[19]\\d{8}",,,,,,,[9]],[,,"1(?:[125]\\d|8[3567])\\d{6}",,,,"121231234"],[,,"9[0-3569]\\d{7}",,,,"911231234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"SD",249,"00","0",,,"0",,,,[[,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",,"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],SE:[,[,,"[1-35-9]\\d{5,11}|4\\d{6,8}",
  37711. ,,,,,,[6,7,8,9,10,12]],[,,"1(?:0[1-8]\\d{6}|[136]\\d{5,7}|(?:2[0-35]|4[0-4]|5[0-25-9]|7[13-6]|[89]\\d)\\d{5,6})|2(?:[136]\\d{5,7}|(?:2[0-7]|4[0136-8]|5[0138]|7[018]|8[01]|9[0-57])\\d{5,6})|3(?:[356]\\d{5,7}|(?:0[0-4]|1\\d|2[0-25]|4[056]|7[0-2]|8[0-3]|9[023])\\d{5,6})|4(?:[0246]\\d{5,7}|(?:1[013-8]|3[0135]|5[14-79]|7[0-246-9]|8[0156]|9[0-689])\\d{5,6})|5(?:0[0-6]|[15][0-5]|2[0-68]|3[0-4]|4\\d|6[03-5]|7[013]|8[0-79]|9[01])\\d{5,6}|6(?:[03]\\d{5,7}|(?:1[1-3]|2[0-4]|4[02-57]|5[0-37]|6[0-3]|7[0-2]|8[0247]|9[0-356])\\d{5,6})|8\\d{6,8}|9(?:0[1-9]\\d{4,6}|(?:1[0-68]|2\\d|3[02-5]|4[0-3]|5[0-4]|[68][01]|7[0135-8])\\d{5,6})",
  37712. ,,,"8123456",,,[7,8,9]],[,,"7[02369]\\d{7}",,,,"701234567",,,[9]],[,,"20\\d{4,7}",,,,"20123456",,,[6,7,8,9]],[,,"649\\d{6}|9(?:00|39|44)[1-8]\\d{3,6}",,,,"9001234567",,,[7,8,9,10]],[,,"77(?:0\\d{3}(?:\\d{3})?|[1-7]\\d{6})",,,,"771234567",,,[6,9]],[,,"75[1-8]\\d{6}",,,,"751234567",,,[9]],[,,,,,,,,,[-1]],"SE",46,"00","0",,,"0",,,,[[,"(8)(\\d{2,3})(\\d{2,3})(\\d{2})","$1-$2 $3 $4",["8"],"0$1"],[,"([1-69]\\d)(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["1[013689]|2[0136]|3[1356]|4[0246]|54|6[03]|90"],"0$1"],
  37713. [,"([1-469]\\d)(\\d{3})(\\d{2})","$1-$2 $3",["1[136]|2[136]|3[356]|4[0246]|6[03]|90"],"0$1"],[,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1-$2 $3 $4",["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[0-5]|4[0-3])"],"0$1"],[,"(\\d{3})(\\d{2,3})(\\d{2})","$1-$2 $3",["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[0-5]|4[0-3])"],"0$1"],[,"(7\\d)(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["7"],"0$1"],[,"(77)(\\d{2})(\\d{2})",
  37714. "$1-$2$3",["7"],"0$1"],[,"(20)(\\d{2,3})(\\d{2})","$1-$2 $3",["20"],"0$1"],[,"(9[034]\\d)(\\d{2})(\\d{2})(\\d{3})","$1-$2 $3 $4",["9[034]"],"0$1"],[,"(9[034]\\d)(\\d{4})","$1-$2",["9[034]"],"0$1"],[,"(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4 $5",["25[245]|67[3-6]"],"0$1"]],[[,"(8)(\\d{2,3})(\\d{2,3})(\\d{2})","$1 $2 $3 $4",["8"]],[,"([1-69]\\d)(\\d{2,3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[013689]|2[0136]|3[1356]|4[0246]|54|6[03]|90"]],[,"([1-469]\\d)(\\d{3})(\\d{2})","$1 $2 $3",["1[136]|2[136]|3[356]|4[0246]|6[03]|90"]],
  37715. [,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[0-5]|4[0-3])"]],[,"(\\d{3})(\\d{2,3})(\\d{2})","$1 $2 $3",["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[0-5]|4[0-3])"]],[,"(7\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["7"]],[,"(77)(\\d{2})(\\d{2})","$1 $2 $3",["7"]],[,"(20)(\\d{2,3})(\\d{2})","$1 $2 $3",["20"]],[,"(9[034]\\d)(\\d{2})(\\d{2})(\\d{3})",
  37716. "$1 $2 $3 $4",["9[034]"]],[,"(9[034]\\d)(\\d{4})","$1 $2",["9[034]"]],[,"(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["25[245]|67[3-6]"]]],[,,"74[02-9]\\d{6}",,,,"740123456",,,[9]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,"(?:25[245]|67[3-6])\\d{9}",,,,"254123456789",,,[12]]],SG:[,[,,"[36]\\d{7}|[17-9]\\d{7,10}",,,,,,,[8,10,11]],[,,"6[1-9]\\d{6}",,,,"61234567",,,[8]],[,,"(?:8[1-8]|9[0-8])\\d{6}",,,,"81234567",,,[8]],[,,"1?800\\d{7}",,,,"18001234567",,,[10,11]],[,,"1900\\d{7}",,,,"19001234567",
  37717. ,,[11]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"3[12]\\d{6}",,,,"31234567",,,[8]],"SG",65,"0[0-3]\\d",,,,,,,,[[,"([3689]\\d{3})(\\d{4})","$1 $2",["[369]|8[1-9]"]],[,"(1[89]00)(\\d{3})(\\d{4})","$1 $2 $3",["1[89]"]],[,"(7000)(\\d{4})(\\d{3})","$1 $2 $3",["70"]],[,"(800)(\\d{3})(\\d{4})","$1 $2 $3",["80"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"7000\\d{7}",,,,"70001234567",,,[11]],,,[,,,,,,,,,[-1]]],SH:[,[,,"[256]\\d{4}",,,,,,,[4,5]],[,,"2(?:[0-57-9]\\d|6[4-9])\\d{2}",,,,"22158"],[,,"[56]\\d{4}",,,,"51234",
  37718. ,,[5]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"262\\d{2}",,,,"26212",,,[5]],"SH",290,"00",,,,,,,,,,[,,,,,,,,,[-1]],1,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],SI:[,[,,"[1-7]\\d{6,7}|[89]\\d{4,7}",,,,,,,[5,6,7,8]],[,,"(?:1\\d|[25][2-8]|3[24-8]|4[24-8]|7[3-8])\\d{6}",,,,"11234567",,,[8],[7]],[,,"(?:[37][01]\\d|4[0139]\\d|51\\d|6(?:[48]\\d|9[69]))\\d{5}",,,,"31234567",,,[8]],[,,"80\\d{4,6}",,,,"80123456",,,[6,7,8]],[,,"90\\d{4,6}|89[1-3]\\d{2,5}",,,,"90123456"],
  37719. [,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"(?:59|8[1-3])\\d{6}",,,,"59012345",,,[8]],"SI",386,"00","0",,,"0",,,,[[,"(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[12]|3[24-8]|4[24-8]|5[2-8]|7[3-8]"],"(0$1)"],[,"([3-7]\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[37][01]|4[0139]|51|6"],"0$1"],[,"([89][09])(\\d{3,6})","$1 $2",["[89][09]"],"0$1"],[,"([58]\\d{2})(\\d{5})","$1 $2",["59|8[1-3]"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],SJ:[,[,,"0\\d{4}|[45789]\\d{7}",,,,,,,[5,8]],[,
  37720. ,"79\\d{6}",,,,"79123456",,,[8]],[,,"(?:4[015-8]|5[89]|9\\d)\\d{6}",,,,"41234567",,,[8]],[,,"80[01]\\d{5}",,,,"80012345",,,[8]],[,,"82[09]\\d{5}",,,,"82012345",,,[8]],[,,"810(?:0[0-6]|[2-8]\\d)\\d{3}",,,,"81021234",,,[8]],[,,"880\\d{5}",,,,"88012345",,,[8]],[,,"85[0-5]\\d{5}",,,,"85012345",,,[8]],"SJ",47,"00",,,,,,,,,,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"0\\d{4}|81(?:0(?:0[7-9]|1\\d)|5\\d{2})\\d{3}",,,,"01234"],,,[,,"81[23]\\d{5}",,,,"81212345",,,[8]]],SK:[,[,,"(?:[2-68]\\d{5,8}|9\\d{6,8})",,,,,
  37721. ,,[6,7,9]],[,,"2(?:1(?:6\\d{3,4}|7\\d{3})|[2-9]\\d{7})|[3-5][1-8](?:1(?:6\\d{2,3}|7\\d{3})|\\d{7})",,,,"221234567"],[,,"9(?:0(?:[1-8]\\d|9[1-9])|(?:1[0-24-9]|[45]\\d)\\d)\\d{5}",,,,"912123456",,,[9]],[,,"800\\d{6}",,,,"800123456",,,[9]],[,,"9(?:[78]\\d{7}|00\\d{6})",,,,"900123456",,,[9]],[,,"8[5-9]\\d{7}",,,,"850123456",,,[9]],[,,,,,,,,,[-1]],[,,"6(?:02|5[0-4]|9[0-6])\\d{6}",,,,"690123456",,,[9]],"SK",421,"00","0",,,"0",,,,[[,"(2)(1[67])(\\d{3,4})","$1 $2 $3",["21[67]"],"0$1"],[,"([3-5]\\d)(1[67])(\\d{2,3})",
  37722. "$1 $2 $3",["[3-5]"],"0$1"],[,"(2)(\\d{3})(\\d{3})(\\d{2})","$1/$2 $3 $4",["2"],"0$1"],[,"([3-5]\\d)(\\d{3})(\\d{2})(\\d{2})","$1/$2 $3 $4",["[3-5]"],"0$1"],[,"([689]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[689]"],"0$1"],[,"(9090)(\\d{3})","$1 $2",["9090"],"0$1"]],,[,,"9090\\d{3}",,,,"9090123",,,[7]],,,[,,"(?:602|8(?:00|[5-9]\\d)|9(?:00|[78]\\d))\\d{6}|9090\\d{3}",,,,"800123456",,,[7,9]],[,,"96\\d{7}",,,,"961234567",,,[9]],,,[,,,,,,,,,[-1]]],SL:[,[,,"[2-9]\\d{7}",,,,,,,[8],[6]],[,,"[235]2[2-4][2-9]\\d{4}",
  37723. ,,,"22221234",,,,[6]],[,,"(?:2[15]|3[03-5]|4[04]|5[05]|66|7[6-9]|8[08]|99)\\d{6}",,,,"25123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"SL",232,"00","0",,,"0",,,,[[,"(\\d{2})(\\d{6})","$1 $2",,"(0$1)"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],SM:[,[,,"[05-7]\\d{7,9}",,,,,,,[8,10],[6]],[,,"0549(?:8[0157-9]|9\\d)\\d{4}",,,,"0549886377",,,[10],[6]],[,,"6[16]\\d{6}",,,,"66661212",,,[8]],[,,,,,,,,,[-1]],[,,"7[178]\\d{6}",,,,"71123456",
  37724. ,,[8]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"5[158]\\d{6}",,,,"58001110",,,[8]],"SM",378,"00",,,,"(?:0549)?([89]\\d{5})","0549$1",,,[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]"]],[,"(0549)(\\d{6})","$1 $2",["0"]],[,"(\\d{6})","0549 $1",["[89]"]]],[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]"]],[,"(0549)(\\d{6})","($1) $2",["0"]],[,"(\\d{6})","(0549) $1",["[89]"]]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],SN:[,[,,"[3789]\\d{8}",,,,,,,[9]],[,
  37725. ,"3(?:0(?:1[0-2]|80)|282|3(?:8[1-9]|9[3-9])|611)\\d{5}",,,,"301012345"],[,,"7(?:[06-8]\\d|21|90)\\d{6}",,,,"701234567"],[,,"800\\d{6}",,,,"800123456"],[,,"88[4689]\\d{6}",,,,"884123456"],[,,"81[02468]\\d{6}",,,,"810123456"],[,,,,,,,,,[-1]],[,,"39[01]\\d{6}|3392\\d{5}|93330\\d{4}",,,,"933301234"],"SN",221,"00",,,,,,,,[[,"(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[379]"]],[,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,
  37726. ,,[-1]]],SO:[,[,,"[1-9]\\d{5,8}",,,,,,,[6,7,8,9]],[,,"(?:1\\d{1,2}|2[0-79]\\d|3[0-46-8]?\\d|4[0-7]?\\d|59\\d|8[125])\\d{4}",,,,"4012345",,,[6,7]],[,,"(?:15\\d|2(?:4\\d|8)|3[59]\\d{2}|4[89]\\d{2}|6[1-9]?\\d{2}|7(?:[1-8]\\d|9\\d{1,2})|8[08]\\d{2}|9(?:0[67]|[2-9])\\d)\\d{5}",,,,"71123456",,,[7,8,9]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"SO",252,"00","0",,,"0",,,,[[,"(\\d{6})","$1",["[134]"]],[,"(\\d)(\\d{6})","$1 $2",["2[0-79]|[13-5]"]],[,"(\\d)(\\d{7})","$1 $2",
  37727. ["24|[67]"]],[,"(\\d{2})(\\d{4})","$1 $2",["8[125]"]],[,"(\\d{2})(\\d{5,7})","$1 $2",["15|28|6[1-35-9]|799|9[2-9]"]],[,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["3[59]|4[89]|6[24-6]|79|8[08]|90"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],SR:[,[,,"[2-8]\\d{5,6}",,,,,,,[6,7]],[,,"(?:2[1-3]|3[0-7]|4\\d|5[2-58]|68\\d)\\d{4}",,,,"211234"],[,,"(?:7[124-7]|8[1-9])\\d{5}",,,,"7412345",,,[7]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"56\\d{4}",,,,"561234",
  37728. ,,[6]],"SR",597,"00",,,,,,,,[[,"(\\d{3})(\\d{3})","$1-$2",["[2-4]|5[2-58]"]],[,"(\\d{2})(\\d{2})(\\d{2})","$1-$2-$3",["56"]],[,"(\\d{3})(\\d{4})","$1-$2",["[6-8]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],SS:[,[,,"[19]\\d{8}",,,,,,,[9]],[,,"18\\d{7}",,,,"181234567"],[,,"(?:12|9[1257])\\d{7}",,,,"977123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"SS",211,"00","0",,,"0",,,,[[,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",,"0$1"]],,[,,
  37729. ,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],ST:[,[,,"[29]\\d{6}",,,,,,,[7]],[,,"22\\d{5}",,,,"2221234"],[,,"9(?:0(?:0[5-9]|[1-9]\\d)|[89]\\d{2})\\d{3}",,,,"9812345"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"ST",239,"00",,,,,,,,[[,"(\\d{3})(\\d{4})","$1 $2"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],SV:[,[,,"[267]\\d{7}|[89]\\d{6}(?:\\d{4})?",,,,,,,[7,8,11]],[,,"2[1-6]\\d{6}",,,,"21234567",,,[8]],[,,"[67]\\d{7}",
  37730. ,,,"70123456",,,[8]],[,,"800\\d{4}(?:\\d{4})?",,,,"8001234",,,[7,11]],[,,"900\\d{4}(?:\\d{4})?",,,,"9001234",,,[7,11]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"SV",503,"00",,,,,,,,[[,"(\\d{4})(\\d{4})","$1 $2",["[267]"]],[,"(\\d{3})(\\d{4})","$1 $2",["[89]"]],[,"(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[89]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],SX:[,[,,"[5789]\\d{9}",,,,,,,[10],[7]],[,,"7215(?:4[2-8]|8[239]|9[056])\\d{4}",,,,"7215425678",,,,[7]],[,,"7215(?:1[02]|2\\d|5[034679]|8[014-8])\\d{4}",
  37731. ,,,"7215205678",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002123456"],[,,"900[2-9]\\d{6}",,,,"9002123456"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"SX",1,"011","1",,,"1",,,,,,[,,,,,,,,,[-1]],,"721",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],SY:[,[,,"[1-59]\\d{7,8}",,,,,,,[8,9],[6,7]],[,,"(?:1(?:1\\d?|4\\d|[2356])|2(?:1\\d?|[235])|3(?:[13]\\d|4)|4[13]|5[1-3])\\d{6}",,,,"112345678",,,,[6,7]],[,,"9(?:22|[3-589]\\d|6[024-9])\\d{6}",
  37732. ,,,"944567890",,,[9]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"SY",963,"00","0",,,"0",,,,[[,"(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-5]"],"0$1",,1],[,"(9\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1",,1]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],SZ:[,[,,"[027]\\d{7}",,,,,,,[8]],[,,"2[2-9]\\d{6}",,,,"22171234"],[,,"7[6-9]\\d{6}",,,,"76123456"],[,,"0800\\d{4}",,,,"08001234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,
  37733. ,,,,,,,[-1]],"SZ",268,"00",,,,,,,,[[,"(\\d{4})(\\d{4})","$1 $2",["[027]"]]],,[,,,,,,,,,[-1]],,,[,,"0800\\d{4}",,,,"08001234"],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],TA:[,[,,"8\\d{3}",,,,,,,[4]],[,,"8\\d{3}",,,,"8999"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"TA",290,"00",,,,,,,,,,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],TC:[,[,,"[5689]\\d{9}",,,,,,,[10],[7]],[,,"649(?:712|9(?:4\\d|50))\\d{4}",,,,"6497121234",,,,[7]],[,
  37734. ,"649(?:2(?:3[129]|4[1-7])|3(?:3[1-389]|4[1-8])|4[34][1-3])\\d{4}",,,,"6492311234",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002345678"],[,,"900[2-9]\\d{6}",,,,"9002345678"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,"64971[01]\\d{4}",,,,"6497101234",,,,[7]],"TC",1,"011","1",,,"1",,,,,,[,,,,,,,,,[-1]],,"649",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],TD:[,[,,"[2679]\\d{7}",,,,,,,[8]],[,,"22(?:[3789]0|5[0-5]|6[89])\\d{4}",,,,"22501234"],[,,"(?:6[023568]\\d|77\\d|9\\d{2})\\d{5}",
  37735. ,,,"63012345"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"TD",235,"00|16",,,,,,"00",,[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],TG:[,[,,"[29]\\d{7}",,,,,,,[8]],[,,"2(?:2[2-7]|3[23]|44|55|66|77)\\d{5}",,,,"22212345"],[,,"9[0-36-9]\\d{6}",,,,"90112345"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"TG",228,"00",,,,,,,,[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})",
  37736. "$1 $2 $3 $4",["[29]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],TH:[,[,,"1\\d{8,9}|[2-9]\\d{7,8}",,,,,,,[8,9,10]],[,,"(?:2\\d|3[2-9]|4[2-5]|5[2-6]|7[3-7])\\d{6}",,,,"21234567",,,[8]],[,,"(?:14|6[1-6]|[89]\\d)\\d{7}",,,,"812345678",,,[9]],[,,"1800\\d{6}",,,,"1800123456",,,[10]],[,,"1900\\d{6}",,,,"1900123456",,,[10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"6[08]\\d{7}",,,,"601234567",,,[9]],"TH",66,"00","0",,,"0",,,,[[,"(2)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1"],[,"([13-9]\\d)(\\d{3})(\\d{3,4})",
  37737. "$1 $2 $3",["14|[3-9]"],"0$1"],[,"(1[89]00)(\\d{3})(\\d{3})","$1 $2 $3",["1"],"$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],TJ:[,[,,"[3-57-9]\\d{8}",,,,,,,[9],[3,5,7]],[,,"(?:3(?:1[3-5]|2[245]|3[12]|4[24-7]|5[25]|72)|4(?:46|74|87))\\d{6}",,,,"372123456",,,,[3,5,7]],[,,"(?:41[18]|(?:5[05]|77|88|9[0-35-9])\\d)\\d{6}",,,,"917123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"TJ",992,"810","8",,,"8",,"8~10",,[[,"([349]\\d{2})(\\d{2})(\\d{4})",
  37738. "$1 $2 $3",["[34]7|91[78]"],"$1",,1],[,"([457-9]\\d)(\\d{3})(\\d{4})","$1 $2 $3",["4[148]|[578]|9(?:1[59]|[0235-9])"],"$1",,1],[,"(331700)(\\d)(\\d{2})","$1 $2 $3",["331","3317","33170","331700"],"$1",,1],[,"(\\d{4})(\\d)(\\d{4})","$1 $2 $3",["3[1-5]","3(?:[1245]|3(?:[02-9]|1[0-589]))"],"$1",,1]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],TK:[,[,,"[2-47]\\d{3,6}",,,,,,,[4,5,6,7]],[,,"(?:2[2-4]|[34]\\d)\\d{2,5}",,,,"3101"],[,,"7[2-4]\\d{2,5}",,,,"7290"],[,,,,,,,,,[-1]],[,
  37739. ,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"TK",690,"00",,,,,,,,,,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],TL:[,[,,"[2-489]\\d{6}|7\\d{6,7}",,,,,,,[7,8]],[,,"(?:2[1-5]|3[1-9]|4[1-4])\\d{5}",,,,"2112345",,,[7]],[,,"7[3-8]\\d{6}",,,,"77212345",,,[8]],[,,"80\\d{5}",,,,"8012345",,,[7]],[,,"90\\d{5}",,,,"9012345",,,[7]],[,,,,,,,,,[-1]],[,,"70\\d{5}",,,,"7012345",,,[7]],[,,,,,,,,,[-1]],"TL",670,"00",,,,,,,,[[,"(\\d{3})(\\d{4})","$1 $2",["[2-489]|70"]],[,"(\\d{4})(\\d{4})",
  37740. "$1 $2",["7[3-8]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],TM:[,[,,"[1-6]\\d{7}",,,,,,,[8]],[,,"(?:1(?:2\\d|3[1-9])|2(?:22|4[0-35-8])|3(?:22|4[03-9])|4(?:22|3[128]|4\\d|6[15])|5(?:22|5[7-9]|6[014-689]))\\d{5}",,,,"12345678"],[,,"6[1-9]\\d{6}",,,,"66123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"TM",993,"810","8",,,"8",,"8~10",,[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["12"],"(8 $1)"],[,"(\\d{2})(\\d{6})","$1 $2",
  37741. ["6"],"8 $1"],[,"(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2-$3-$4",["13|[2-5]"],"(8 $1)"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],TN:[,[,,"[2-57-9]\\d{7}",,,,,,,[8]],[,,"3(?:[012]\\d|6[0-4]|91)\\d{5}|7\\d{7}|81200\\d{3}",,,,"71234567"],[,,"(?:[259]\\d|4[0-6])\\d{6}",,,,"20123456"],[,,"8010\\d{4}",,,,"80101234"],[,,"88\\d{6}",,,,"88123456"],[,,"8[12]10\\d{4}",,,,"81101234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"TN",216,"00",,,,,,,,[[,"(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3"]],,[,
  37742. ,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],TO:[,[,,"[02-8]\\d{4,6}",,,,,,,[5,7]],[,,"(?:2\\d|3[1-8]|4[1-4]|[56]0|7[0149]|8[05])\\d{3}",,,,"20123",,,[5]],[,,"(?:7[578]|8[47-9])\\d{5}",,,,"7715123",,,[7]],[,,"0800\\d{3}",,,,"0800222",,,[7]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"TO",676,"00",,,,,,,,[[,"(\\d{2})(\\d{3})","$1-$2",["[1-6]|7[0-4]|8[05]"]],[,"(\\d{3})(\\d{4})","$1 $2",["7[5-9]|8[47-9]"]],[,"(\\d{4})(\\d{3})","$1 $2",["0"]]],,[,,,,,,,,,[-1]],
  37743. ,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],TR:[,[,,"[2-589]\\d{9}|444\\d{4}",,,,,,,[7,10]],[,,"(?:2(?:[13][26]|[28][2468]|[45][268]|[67][246])|3(?:[13][28]|[24-6][2468]|[78][02468]|92)|4(?:[16][246]|[23578][2468]|4[26]))\\d{7}",,,,"2123456789",,,[10]],[,,"5(?:(?:0[1-7]|22|[34]\\d|5[1-59]|9[246])\\d{2}|6161)\\d{5}",,,,"5012345678",,,[10]],[,,"800\\d{7}",,,,"8001234567",,,[10]],[,,"900\\d{7}",,,,"9001234567",,,[10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"TR",90,"00","0",,,"0",,,
  37744. ,[[,"(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[23]|4(?:[0-35-9]|4[0-35-9])"],"(0$1)",,1],[,"(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5[02-69]"],"0$1",,1],[,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["51|[89]"],"0$1",,1],[,"(444)(\\d{1})(\\d{3})","$1 $2 $3",["444"]]],,[,,"512\\d{7}",,,,"5123456789",,,[10]],,,[,,"444\\d{4}",,,,"4441444",,,[7]],[,,"444\\d{4}|850\\d{7}",,,,"4441444"],,,[,,,,,,,,,[-1]]],TT:[,[,,"[589]\\d{9}",,,,,,,[10],[7]],[,,"868(?:2(?:01|[23]\\d)|6(?:0[79]|1[02-8]|2[1-9]|[3-69]\\d|7[0-79])|82[124])\\d{4}",
  37745. ,,,"8682211234",,,,[7]],[,,"868(?:2(?:6[6-9]|[789]\\d)|3(?:0[1-9]|1[02-9]|[2-9]\\d)|4[6-9]\\d|6(?:20|78|8\\d)|7(?:0[1-9]|1[02-9]|[2-9]\\d))\\d{4}",,,,"8682911234",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002345678"],[,,"900[2-9]\\d{6}",,,,"9002345678"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"TT",1,"011","1",,,"1",,,,,,[,,,,,,,,,[-1]],,"868",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,"868619\\d{4}",,,,"8686191234",,,,[7]]],TV:[,[,,"[279]\\d{4,6}",
  37746. ,,,,,,[5,6,7]],[,,"2[02-9]\\d{3}",,,,"20123",,,[5]],[,,"(?:70\\d|90)\\d{4}",,,,"901234",,,[6,7]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"TV",688,"00",,,,,,,,,,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],TW:[,[,,"2\\d{6,8}|[3-689]\\d{7,8}|7\\d{7,9}",,,,,,,[7,8,9,10]],[,,"2(?:[235-8]\\d{7}|4\\d{6,7})|[3-8]\\d{7,8}",,,,"221234567",,,[8,9]],[,,"9\\d{8}",,,,"912345678",,,[9]],[,,"800\\d{6}",,,,"800123456",,,[9]],[,,"20(?:2|[013-9]\\d{2})\\d{4}",
  37747. ,,,"203123456",,,[7,9]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"70\\d{8}",,,,"7012345678",,,[10]],"TW",886,"0(?:0[25679]|19)","0","#",,"0",,,,[[,"(20)(\\d)(\\d{4})","$1 $2 $3",["202"],"0$1"],[,"(20)(\\d{3})(\\d{4})","$1 $2 $3",["20[013-9]"],"0$1"],[,"([2-8])(\\d{3,4})(\\d{4})","$1 $2 $3",["2[23-8]|[3-6]|[78][1-9]"],"0$1"],[,"([89]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["80|9"],"0$1"],[,"(70)(\\d{4})(\\d{4})","$1 $2 $3",["70"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],
  37748. TZ:[,[,,"\\d{9}",,,,,,,[7,9]],[,,"2[2-8]\\d{7}",,,,"222345678"],[,,"(?:6[2-9]|7[13-9])\\d{7}",,,,"621234567",,,[9]],[,,"80[08]\\d{6}",,,,"800123456",,,[9]],[,,"90\\d{7}",,,,"900123456",,,[9]],[,,"8(?:40|6[01])\\d{6}",,,,"840123456",,,[9]],[,,,,,,,,,[-1]],[,,"41\\d{7}",,,,"412345678",,,[9]],"TZ",255,"00[056]","0",,,"0",,,,[[,"([24]\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[24]"],"0$1"],[,"([67]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[67]"],"0$1"],[,"([89]\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[89]"],"0$1"]],
  37749. ,[,,,,,,,,,[-1]],,,[,,"(?:8(?:[04]0|6[01])|90\\d)\\d{6}",,,,"800123456",,,[9]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],UA:[,[,,"[3-9]\\d{8}",,,,,,,[9],[5,6,7]],[,,"(?:3[1-8]|4[13-8]|5[1-7]|6[12459])\\d{7}",,,,"311234567",,,,[5,6,7]],[,,"(?:39|50|6[36-8]|7[1-3]|9[1-9])\\d{7}",,,,"391234567"],[,,"800\\d{6}",,,,"800123456"],[,,"900[2-49]\\d{5}",,,,"900212345"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"89\\d{7}",,,,"891234567"],"UA",380,"00","0",,,"0",,"0~0",,[[,"([3-9]\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[38]9|4(?:[45][0-5]|87)|5(?:0|6[37]|7[37])|6[36-8]|7|9[1-9]",
  37750. "[38]9|4(?:[45][0-5]|87)|5(?:0|6(?:3[14-7]|7)|7[37])|6[36-8]|7|9[1-9]"],"0$1"],[,"([3-689]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["3[1-8]2|4[13678]2|5(?:[12457]2|6[24])|6(?:[49]2|[12][29]|5[24])|8[0-8]|90","3(?:[1-46-8]2[013-9]|52)|4(?:[1378]2|62[013-9])|5(?:[12457]2|6[24])|6(?:[49]2|[12][29]|5[24])|8[0-8]|90"],"0$1"],[,"([3-6]\\d{3})(\\d{5})","$1 $2",["3(?:5[013-9]|[1-46-8])|4(?:[137][013-9]|6|[45][6-9]|8[4-6])|5(?:[1245][013-9]|6[0135-9]|3|7[4-6])|6(?:[49][013-9]|5[0135-9]|[12][13-8])","3(?:5[013-9]|[1-46-8](?:22|[013-9]))|4(?:[137][013-9]|6(?:[013-9]|22)|[45][6-9]|8[4-6])|5(?:[1245][013-9]|6(?:3[02389]|[015689])|3|7[4-6])|6(?:[49][013-9]|5[0135-9]|[12][13-8])"],
  37751. "0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],UG:[,[,,"\\d{9}",,,,,,,[9],[5,6,7]],[,,"20(?:[0147]\\d{2}|2(?:40|[5-9]\\d)|3(?:0[0-4]|[23]\\d)|5[0-4]\\d|6[035-9]\\d|8[0-2]\\d)\\d{4}|[34]\\d{8}",,,,"312345678",,,,[5,6,7]],[,,"7(?:(?:0[0-7]|[15789]\\d|30|4[0-4])\\d|2(?:[03]\\d|60))\\d{5}",,,,"712345678"],[,,"800[123]\\d{5}",,,,"800123456"],[,,"90[123]\\d{6}",,,,"901123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"UG",256,"00[057]","0",,,"0",,,,[[,"(\\d{3})(\\d{6})",
  37752. "$1 $2",["[7-9]|20(?:[013-8]|2[5-9])|4(?:6[45]|[7-9])"],"0$1"],[,"(\\d{2})(\\d{7})","$1 $2",["3|4(?:[1-5]|6[0-36-9])"],"0$1"],[,"(2024)(\\d{5})","$1 $2",["2024"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],US:[,[,,"[2-9]\\d{9}",,,,,,,[10],[7]],[,,"(?:2(?:0[1-35-9]|1[02-9]|2[04589]|3[149]|4[08]|5[1-46]|6[0279]|7[026]|8[13])|3(?:0[1-57-9]|1[02-9]|2[0135]|3[0-24679]|4[67]|5[12]|6[014]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[0235]|58|6[39]|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[19]|6[1-47]|7[013-5]|8[056])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[16]|5[017]|6[0-279]|78|8[012])|7(?:0[1-46-8]|1[02-9]|2[0457]|3[1247]|4[037]|5[47]|6[02359]|7[02-59]|8[156])|8(?:0[1-68]|1[02-8]|28|3[0-25]|4[3578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[014678]|4[0179]|5[12469]|7[0-3589]|8[04-69]))[2-9]\\d{6}",
  37753. ,,,"2015550123",,,,[7]],[,,"(?:2(?:0[1-35-9]|1[02-9]|2[04589]|3[149]|4[08]|5[1-46]|6[0279]|7[026]|8[13])|3(?:0[1-57-9]|1[02-9]|2[0135]|3[0-24679]|4[67]|5[12]|6[014]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[0235]|58|6[39]|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[19]|6[1-47]|7[013-5]|8[056])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[16]|5[017]|6[0-279]|78|8[012])|7(?:0[1-46-8]|1[02-9]|2[0457]|3[1247]|4[037]|5[47]|6[02359]|7[02-59]|8[156])|8(?:0[1-68]|1[02-8]|28|3[0-25]|4[3578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[014678]|4[0179]|5[12469]|7[0-3589]|8[04-69]))[2-9]\\d{6}",
  37754. ,,,"2015550123",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002345678"],[,,"900[2-9]\\d{6}",,,,"9002345678"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"US",1,"011","1",,,"1",,,1,[[,"(\\d{3})(\\d{4})","$1-$2",,,,1],[,"(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",,,,1]],[[,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3"]],[,,,,,,,,,[-1]],1,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],UY:[,[,,"[2489]\\d{6,7}",,,,,,,[7,8]],[,,"2\\d{7}|4[2-7]\\d{6}",,
  37755. ,,"21231234",,,[8],[7]],[,,"9[1-9]\\d{6}",,,,"94231234",,,[8]],[,,"80[05]\\d{4}",,,,"8001234",,,[7]],[,,"90[0-8]\\d{4}",,,,"9001234",,,[7]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"UY",598,"0(?:1[3-9]\\d|0)","0"," int. ",,"0",,"00",,[[,"(\\d{4})(\\d{4})","$1 $2",["[24]"]],[,"(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["9[1-9]"],"0$1"],[,"(\\d{3})(\\d{4})","$1 $2",["[89]0"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],UZ:[,[,,"[679]\\d{8}",,,,,,,[9],[7]],[,,"(?:6(?:1(?:22|3[124]|4[1-4]|5[123578]|64)|2(?:22|3[0-57-9]|41)|5(?:22|3[3-7]|5[024-8])|6\\d{2}|7(?:[23]\\d|7[69])|9(?:22|4[1-8]|6[135]))|7(?:0(?:5[4-9]|6[0146]|7[12456]|9[135-8])|1[12]\\d|2(?:22|3[1345789]|4[123579]|5[14])|3(?:2\\d|3[1578]|4[1-35-7]|5[1-57]|61)|4(?:2\\d|3[1-579]|7[1-79])|5(?:22|5[1-9]|6[1457])|6(?:22|3[12457]|4[13-8])|9(?:22|5[1-9])))\\d{5}",
  37756. ,,,"662345678",,,,[7]],[,,"6(?:1(?:2(?:98|2[01])|35[0-4]|50\\d|61[23]|7(?:[01][017]|4\\d|55|9[5-9]))|2(?:11\\d|2(?:[12]1|9[01379])|5(?:[126]\\d|3[0-4])|7\\d{2})|5(?:19[01]|2(?:27|9[26])|30\\d|59\\d|7\\d{2})|6(?:2(?:1[5-9]|2[0367]|38|41|52|60)|3[79]\\d|4(?:56|83)|7(?:[07]\\d|1[017]|3[07]|4[047]|5[057]|67|8[0178]|9[79])|9[0-3]\\d)|7(?:2(?:24|3[237]|4[5-9]|7[15-8])|5(?:7[12]|8[0589])|7(?:0\\d|[39][07])|9(?:0\\d|7[079]))|9(?:2(?:1[1267]|5\\d|3[01]|7[0-4])|5[67]\\d|6(?:2[0-26]|8\\d)|7\\d{2}))\\d{4}|7(?:0\\d{3}|1(?:13[01]|6(?:0[47]|1[67]|66)|71[3-69]|98\\d)|2(?:2(?:2[79]|95)|3(?:2[5-9]|6[0-6])|57\\d|7(?:0\\d|1[17]|2[27]|3[37]|44|5[057]|66|88))|3(?:2(?:1[0-6]|21|3[469]|7[159])|33\\d|5(?:0[0-4]|5[579]|9\\d)|7(?:[0-3579]\\d|4[0467]|6[67]|8[078])|9[4-6]\\d)|4(?:2(?:29|5[0257]|6[0-7]|7[1-57])|5(?:1[0-4]|8\\d|9[5-9])|7(?:0\\d|1[024589]|2[0127]|3[0137]|[46][07]|5[01]|7[5-9]|9[079])|9(?:7[015-9]|[89]\\d))|5(?:112|2(?:0\\d|2[29]|[49]4)|3[1568]\\d|52[6-9]|7(?:0[01578]|1[017]|[23]7|4[047]|[5-7]\\d|8[78]|9[079]))|6(?:2(?:2[1245]|4[2-4])|39\\d|41[179]|5(?:[349]\\d|5[0-2])|7(?:0[017]|[13]\\d|22|44|55|67|88))|9(?:22[128]|3(?:2[0-4]|7\\d)|57[05629]|7(?:2[05-9]|3[37]|4\\d|60|7[2579]|87|9[07])))\\d{4}|9[0-57-9]\\d{7}",
  37757. ,,,"912345678"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"UZ",998,"810","8",,,"8",,"8~10",,[[,"([679]\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",,"8 $1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],VA:[,[,,"(?:0(?:878\\d{5}|6698\\d{5})|[1589]\\d{5,10}|3(?:[12457-9]\\d{8}|[36]\\d{7,9}))",,,,,,,[6,8,9,10,11]],[,,"06698\\d{5}",,,,"0669812345",,,[10]],[,,"3(?:[12457-9]\\d{8}|6\\d{7,8}|3\\d{7,9})",,,,"3123456789",,,[9,10,11]],[,,"80(?:0\\d{6}|3\\d{3})",
  37758. ,,,"800123456",,,[6,9]],[,,"0878\\d{5}|1(?:44|6[346])\\d{6}|89(?:2\\d{3}|4(?:[0-4]\\d{2}|[5-9]\\d{4})|5(?:[0-4]\\d{2}|[5-9]\\d{6})|9\\d{6})",,,,"899123456",,,[6,8,9,10]],[,,"84(?:[08]\\d{6}|[17]\\d{3})",,,,"848123456",,,[6,9]],[,,"1(?:78\\d|99)\\d{6}",,,,"1781234567",,,[9,10]],[,,"55\\d{8}",,,,"5512345678",,,[10]],"VA",39,"00",,,,,,,,,,[,,,,,,,,,[-1]],,,[,,"848\\d{6}",,,,"848123456",,,[9]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],VC:[,[,,"[5789]\\d{9}",,,,,,,[10],[7]],[,,"784(?:266|3(?:6[6-9]|7\\d|8[0-24-6])|4(?:38|5[0-36-8]|8[0-8])|5(?:55|7[0-2]|93)|638|784)\\d{4}",
  37759. ,,,"7842661234",,,,[7]],[,,"784(?:4(?:3[0-5]|5[45]|89|9[0-58])|5(?:2[6-9]|3[0-4]))\\d{4}",,,,"7844301234",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002345678"],[,,"900[2-9]\\d{6}",,,,"9002345678"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"VC",1,"011","1",,,"1",,,,,,[,,,,,,,,,[-1]],,"784",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],VE:[,[,,"[24589]\\d{9}",,,,,,,[10],[7]],[,,"(?:2(?:12|3[457-9]|[58][1-9]|[467]\\d|9[1-6])|50[01])\\d{7}",
  37760. ,,,"2121234567",,,,[7]],[,,"4(?:1[24-8]|2[46])\\d{7}",,,,"4121234567"],[,,"800\\d{7}",,,,"8001234567"],[,,"900\\d{7}",,,,"9001234567"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"VE",58,"00","0",,,"0",,,,[[,"(\\d{3})(\\d{7})","$1-$2",,"0$1","$CC $1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],VG:[,[,,"[2589]\\d{9}",,,,,,,[10],[7]],[,,"284(?:(?:229|4(?:22|9[45])|774|8(?:52|6[459]))\\d{4}|496[0-5]\\d{3})",,,,"2842291234",,,,[7]],[,,"284(?:(?:3(?:0[0-3]|4[0-7]|68|9[34])|4(?:4[0-6]|68|99)|54[0-57])\\d{4}|496[6-9]\\d{3})",
  37761. ,,,"2843001234",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002345678"],[,,"900[2-9]\\d{6}",,,,"9002345678"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"VG",1,"011","1",,,"1",,,,,,[,,,,,,,,,[-1]],,"284",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],VI:[,[,,"[3589]\\d{9}",,,,,,,[10],[7]],[,,"340(?:2(?:01|2[0678]|44|77)|3(?:32|44)|4(?:22|7[34])|5(?:1[34]|55)|6(?:26|4[23]|77|9[023])|7(?:1[2-589]|27|7\\d)|884|998)\\d{4}",,,,"3406421234",
  37762. ,,,[7]],[,,"340(?:2(?:01|2[0678]|44|77)|3(?:32|44)|4(?:22|7[34])|5(?:1[34]|55)|6(?:26|4[23]|77|9[023])|7(?:1[2-589]|27|7\\d)|884|998)\\d{4}",,,,"3406421234",,,,[7]],[,,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",,,,"8002345678"],[,,"900[2-9]\\d{6}",,,,"9002345678"],[,,,,,,,,,[-1]],[,,"5(?:00|22|33|44|66|77|88)[2-9]\\d{6}",,,,"5002345678"],[,,,,,,,,,[-1]],"VI",1,"011","1",,,"1",,,1,,,[,,,,,,,,,[-1]],,"340",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],VN:[,[,,"[167]\\d{6,9}|[2-59]\\d{7,9}|8\\d{6,8}",
  37763. ,,,,,,[7,8,9,10]],[,,"(?:2(?:0[3-9]|1[0-689]|2[0-25-9]|3[2-9]|[48][2-7]|5[124-9]|6[0-39]|7[0-7]|9[0-4679])|4\\d|5(?:0[01]|[5-9])|6(?:[0-46-8]|5[01])|7[0235])\\d{7}|8(?:[2-5]\\d|6[236]|7[13])\\d{6}",,,,"2101234567",,,[9,10]],[,,"(?:9\\d|1(?:2\\d|6[2-9]|8[68]|99))\\d{7}|8(?:6[89]|8\\d|9[89])\\d{6}",,,,"912345678",,,[9,10]],[,,"1800\\d{4,6}",,,,"1800123456",,,[8,9,10]],[,,"1900\\d{4,6}",,,,"1900123456",,,[8,9,10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"VN",84,"00","0",,,"0",,,,[[,"([17]99)(\\d{4})",
  37764. "$1 $2",["[17]99"],"0$1",,1],[,"([48])(\\d{4})(\\d{4})","$1 $2 $3",["4|8(?:[2-5]|6[236]|7[13])"],"0$1",,1],[,"(\\d{2})(\\d{4})(\\d{3,4})","$1 $2 $3",["2[48]|5[5-9]|6[0-46-8]|7[0235]"],"0$1",,1],[,"(80)(\\d{5})","$1 $2",["80"],"0$1",,1],[,"(69\\d)(\\d{4,5})","$1 $2",["69"],"0$1",,1],[,"(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["2[0-35-79]|50|65"],"0$1",,1],[,"([89]\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8(?:8|9[89])|9"],"0$1",,1],[,"(1[2689]\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1(?:[26]|8[68]|99)"],
  37765. "0$1",,1],[,"(86[89])(\\d{3})(\\d{3})","$1 $2 $3",["86[89]"],"0$1",,1],[,"(1[89]00)(\\d{4,6})","$1 $2",["1[89]0"],"$1",,1]],,[,,,,,,,,,[-1]],,,[,,"[17]99\\d{4}|69\\d{5,6}",,,,"1992000",,,[7,8]],[,,"[17]99\\d{4}|69\\d{5,6}|80\\d{5}",,,,"1992000",,,[7,8]],,,[,,,,,,,,,[-1]]],VU:[,[,,"[2-57-9]\\d{4,6}",,,,,,,[5,7]],[,,"(?:2[02-9]\\d|3(?:[5-7]\\d|8[0-8])|48[4-9]|88\\d)\\d{2}",,,,"22123",,,[5]],[,,"(?:5(?:7[2-5]|[0-689]\\d)|7[013-7]\\d)\\d{4}",,,,"5912345",,,[7]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,
  37766. ,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"VU",678,"00",,,,,,,,[[,"(\\d{3})(\\d{4})","$1 $2",["[579]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"3[03]\\d{3}|900\\d{4}",,,,"30123"],,,[,,,,,,,,,[-1]]],WF:[,[,,"[4-8]\\d{5}",,,,,,,[6]],[,,"(?:50|68|72)\\d{4}",,,,"501234"],[,,"(?:50|68|72|8[23])\\d{4}",,,,"501234"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"WF",681,"00",,,,,,,,[[,"(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],
  37767. ,,[,,"[48]0\\d{4}",,,,"401234"]],WS:[,[,,"[2-8]\\d{4,6}",,,,,,,[5,6,7]],[,,"(?:[2-5]\\d|6[1-9]|84\\d{2})\\d{3}",,,,"22123",,,[5,7]],[,,"(?:60|7[25-7]\\d)\\d{4}",,,,"601234",,,[6,7]],[,,"800\\d{3}",,,,"800123",,,[6]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"WS",685,"0",,,,,,,,[[,"(8\\d{2})(\\d{3,4})","$1 $2",["8"]],[,"(7\\d)(\\d{5})","$1 $2",["7"]],[,"(\\d{5})","$1",["[2-6]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],YE:[,[,,"[1-7]\\d{6,8}",,,,
  37768. ,,,[7,8,9],[6]],[,,"(?:1(?:7\\d|[2-68])|2[2-68]|3[2358]|4[2-58]|5[2-6]|6[3-58]|7[24-68])\\d{5}",,,,"1234567",,,[7,8],[6]],[,,"7[0137]\\d{7}",,,,"712345678",,,[9]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"YE",967,"00","0",,,"0",,,,[[,"([1-7])(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-6]|7[24-68]"],"0$1"],[,"(7\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["7[0137]"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],YT:[,[,,"[268]\\d{8}",,,,,,,[9]],
  37769. [,,"269(?:6[0-4]|50)\\d{4}",,,,"269601234"],[,,"639(?:0[0-79]|1[019]|[26]\\d|3[09]|[45]0|7[06]|9[04-79])\\d{4}",,,,"639012345"],[,,"80\\d{7}",,,,"801234567"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"YT",262,"00","0",,,"0",,,,,,[,,,,,,,,,[-1]],,"269|63",[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],ZA:[,[,,"[1-79]\\d{8}|8\\d{4,8}",,,,,,,[5,6,7,8,9]],[,,"(?:1[0-8]|2[1-378]|3[1-69]|4\\d|5[1346-8])\\d{7}",,,,"101234567",,,[9]],[,,"(?:6\\d|7[0-46-9])\\d{7}|8(?:[1-4]\\d{1,5}|5\\d{5})\\d{2}",
  37770. ,,,"711234567"],[,,"80\\d{7}",,,,"801234567",,,[9]],[,,"86[2-9]\\d{6}|9[0-2]\\d{7}",,,,"862345678",,,[9]],[,,"860\\d{6}",,,,"860123456",,,[9]],[,,,,,,,,,[-1]],[,,"87\\d{7}",,,,"871234567",,,[9]],"ZA",27,"00","0",,,"0",,,,[[,"(860)(\\d{3})(\\d{3})","$1 $2 $3",["860"],"0$1"],[,"(\\d{2})(\\d{3,4})","$1 $2",["8[1-4]"],"0$1"],[,"(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["8[1-4]"],"0$1"],[,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-79]|8(?:[0-57]|6[1-9])"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"861\\d{6}",
  37771. ,,,"861123456",,,[9]],,,[,,,,,,,,,[-1]]],ZM:[,[,,"[289]\\d{8}",,,,,,,[9]],[,,"21[1-8]\\d{6}",,,,"211234567"],[,,"9(?:5[034589]|[67]\\d)\\d{6}",,,,"955123456"],[,,"800\\d{6}",,,,"800123456"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"ZM",260,"00","0",,,"0",,,,[[,"([29]\\d)(\\d{7})","$1 $2",["[29]"],"0$1"],[,"(800)(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],ZW:[,[,,"2(?:[0-2457-9]\\d{3,8}|6(?:[14]\\d{7}|\\d{4}))|[13-79]\\d{4,9}|8[06]\\d{5,8}",
  37772. ,,,,,,[5,6,7,8,9,10],[3,4]],[,,"(?:2(?:0(?:4\\d|5\\d{2})|2[278]\\d|48\\d|7(?:[1-7]\\d|[089]\\d{2})|8(?:[2-57-9]|[146]\\d{2})|98)|3(?:08|17|3[78]|7(?:[19]|[56]\\d)|8[37]|98)|5[15][78]|6(?:28\\d{2}|37|6[78]|75\\d|98|8(?:7\\d|8)))\\d{3}|(?:2(?:1[39]|2[0157]|31|[56][14]|7[35]|84)|329)\\d{7}|(?:1(?:3\\d{2}|[4-8]|9\\d)|2(?:0\\d{2}|12|292|[569]\\d)|3(?:[26]|[013459]\\d)|5(?:0|1[2-4]|26|[37]2|5\\d{2}|[689]\\d)|6(?:[39]|[01246]\\d|[78]\\d{2}))\\d{3}|(?:29\\d|39|54)\\d{6}|(?:(?:25|54)83\\d|2582\\d{2}|65[2-8])\\d{2}|(?:4\\d{6,7}|9[2-9]\\d{4,5})",
  37773. ,,,"1312345",,,,[3,4]],[,,"(?:7(?:1[2-8]|3[2-9]|7[1-9]|8[2-5])|8644)\\d{6}",,,,"712345678",,,[9,10]],[,,"80(?:[01]\\d|20|8[0-8])\\d{3}",,,,"8001234",,,[7]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"86(?:1[12]|30|55|77|8[368])\\d{6}",,,,"8686123456",,,[10]],"ZW",263,"00","0",,,"0",,,,[[,"([49])(\\d{3})(\\d{2,4})","$1 $2 $3",["4|9[2-9]"],"0$1"],[,"(7\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["7"],"0$1"],[,"(86\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["86[24]"],"0$1"],[,"([2356]\\d{2})(\\d{3,5})","$1 $2",
  37774. ["2(?:0[45]|2[278]|[49]8|[78])|3(?:08|17|3[78]|7[1569]|8[37]|98)|5[15][78]|6(?:[29]8|[38]7|6[78]|75|[89]8)"],"0$1"],[,"(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:1[39]|2[0157]|31|[56][14]|7[35]|84)|329"],"0$1"],[,"([1-356]\\d)(\\d{3,5})","$1 $2",["1[3-9]|2[02569]|3[0-69]|5[05689]|6\\d"],"0$1"],[,"([235]\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[23]9|54"],"0$1"],[,"([25]\\d{3})(\\d{3,5})","$1 $2",["(?:25|54)8","258[23]|5483"],"0$1"],[,"(8\\d{3})(\\d{6})","$1 $2",["86"],"0$1"],[,"(80\\d)(\\d{4})","$1 $2",
  37775. ["80"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],800:[,[,,"\\d{8}",,,,,,,[8]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"\\d{8}",,,,"12345678"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"001",800,,,,,,,,1,[[,"(\\d{4})(\\d{4})","$1 $2"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],808:[,[,,"\\d{8}",,,,,,,[8]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"\\d{8}",,,,"12345678"],[,,,,,,,,,[-1]],[,,,,,,
  37776. ,,,[-1]],"001",808,,,,,,,,1,[[,"(\\d{4})(\\d{4})","$1 $2"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],870:[,[,,"[35-7]\\d{8}",,,,,,,[9]],[,,,,,,,,,[-1]],[,,"(?:[356]\\d|7[6-8])\\d{7}",,,,"301234567"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"001",870,,,,,,,,,[[,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],878:[,[,,"1\\d{11}",,,,,,,[12]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],
  37777. [,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"10\\d{10}",,,,"101234567890"],"001",878,,,,,,,,1,[[,"(\\d{2})(\\d{5})(\\d{5})","$1 $2 $3"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],881:[,[,,"[67]\\d{8}",,,,,,,[9]],[,,,,,,,,,[-1]],[,,"[67]\\d{8}",,,,"612345678"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"001",881,,,,,,,,,[[,"(\\d)(\\d{3})(\\d{5})","$1 $2 $3",["[67]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,
  37778. ,,[-1]],,,[,,,,,,,,,[-1]]],882:[,[,,"[13]\\d{6,11}",,,,,,,[7,8,9,10,11,12]],[,,,,,,,,,[-1]],[,,"3(?:2\\d{3}|37\\d{2}|4(?:2|7\\d{3}))\\d{4}",,,,"3421234",,,[7,9,10]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"1(?:3(?:0[0347]|[13][0139]|2[035]|4[013568]|6[0459]|7[06]|8[15678]|9[0689])\\d{4}|6\\d{5,10})|3(?:45|9\\d{3})\\d{7}",,,,"390123456789"],"001",882,,,,,,,,,[[,"(\\d{2})(\\d{4})(\\d{3})","$1 $2 $3",["3[23]"]],[,"(\\d{2})(\\d{5})","$1 $2",["16|342"]],[,"(\\d{2})(\\d{4})(\\d{4})",
  37779. "$1 $2 $3",["34[57]"]],[,"(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["348"]],[,"(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["1"]],[,"(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["16"]],[,"(\\d{2})(\\d{4,5})(\\d{5})","$1 $2 $3",["16|39"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,"348[57]\\d{7}",,,,"34851234567",,,[11]]],883:[,[,,"51\\d{7}(?:\\d{3})?",,,,,,,[9,12]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"51(?:00\\d{5}(?:\\d{3})?|[13]0\\d{8})",
  37780. ,,,"510012345"],"001",883,,,,,,,,1,[[,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["510"]],[,"(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["510"]],[,"(\\d{4})(\\d{4})(\\d{4})","$1 $2 $3",["51[13]"]]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],888:[,[,,"\\d{11}",,,,,,,[11]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"001",888,,,,,,,,1,[[,"(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,
  37781. ,[-1]],[,,"\\d{11}",,,,"12345678901"],,,[,,,,,,,,,[-1]]],979:[,[,,"\\d{9}",,,,,,,[9]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,"\\d{9}",,,,"123456789"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"001",979,,,,,,,,1,[[,"(\\d)(\\d{4})(\\d{4})","$1 $2 $3"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]]};/*
  37782. Copyright (C) 2010 The Libphonenumber Authors.
  37783. Licensed under the Apache License, Version 2.0 (the "License");
  37784. you may not use this file except in compliance with the License.
  37785. You may obtain a copy of the License at
  37786. http://www.apache.org/licenses/LICENSE-2.0
  37787. Unless required by applicable law or agreed to in writing, software
  37788. distributed under the License is distributed on an "AS IS" BASIS,
  37789. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  37790. See the License for the specific language governing permissions and
  37791. limitations under the License.
  37792. */
  37793. function Q(){this.a={}}Q.a=function(){return Q.b?Q.b:Q.b=new Q};
  37794. var ya={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","\uff10":"0","\uff11":"1","\uff12":"2","\uff13":"3","\uff14":"4","\uff15":"5","\uff16":"6","\uff17":"7","\uff18":"8","\uff19":"9","\u0660":"0","\u0661":"1","\u0662":"2","\u0663":"3","\u0664":"4","\u0665":"5","\u0666":"6","\u0667":"7","\u0668":"8","\u0669":"9","\u06f0":"0","\u06f1":"1","\u06f2":"2","\u06f3":"3","\u06f4":"4","\u06f5":"5","\u06f6":"6","\u06f7":"7","\u06f8":"8","\u06f9":"9"},Aa={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",
  37795. 7:"7",8:"8",9:"9","\uff10":"0","\uff11":"1","\uff12":"2","\uff13":"3","\uff14":"4","\uff15":"5","\uff16":"6","\uff17":"7","\uff18":"8","\uff19":"9","\u0660":"0","\u0661":"1","\u0662":"2","\u0663":"3","\u0664":"4","\u0665":"5","\u0666":"6","\u0667":"7","\u0668":"8","\u0669":"9","\u06f0":"0","\u06f1":"1","\u06f2":"2","\u06f3":"3","\u06f4":"4","\u06f5":"5","\u06f6":"6","\u06f7":"7","\u06f8":"8","\u06f9":"9",A:"2",B:"2",C:"2",D:"3",E:"3",F:"3",G:"4",H:"4",I:"4",J:"5",K:"5",L:"5",M:"6",N:"6",O:"6",P:"7",
  37796. Q:"7",R:"7",S:"7",T:"8",U:"8",V:"8",W:"9",X:"9",Y:"9",Z:"9"},R=RegExp("^[+\uff0b]+"),Ba=RegExp("([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9])"),Ca=RegExp("[+\uff0b0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]"),Da=/[\\\/] *x/,Ea=RegExp("[^0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9A-Za-z#]+$"),Fa=/(?:.*?[A-Za-z]){3}.*/,Ga=RegExp("(?:;ext=([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,7})|[ \u00a0\\t,]*(?:e?xt(?:ensi(?:o\u0301?|\u00f3))?n?|\uff45?\uff58\uff54\uff4e?|[;,x\uff58#\uff03~\uff5e]|int|anexo|\uff49\uff4e\uff54)[:\\.\uff0e]?[ \u00a0\\t,-]*([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,7})#?|[- ]+([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,5})#)$",
  37797. "i"),Ha=RegExp("^[0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{2}$|^[+\uff0b]*(?:[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e*]*[0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]){3,}[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e*A-Za-z0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]*(?:;ext=([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,7})|[ \u00a0\\t,]*(?:e?xt(?:ensi(?:o\u0301?|\u00f3))?n?|\uff45?\uff58\uff54\uff4e?|[;,x\uff58#\uff03~\uff5e]|int|anexo|\uff49\uff4e\uff54)[:\\.\uff0e]?[ \u00a0\\t,-]*([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,7})#?|[- ]+([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,5})#)?$",
  37798. "i"),Ia=/(\$\d)/;function Ja(a){var b=a.search(Ca);0<=b?(a=a.substring(b),a=a.replace(Ea,""),b=a.search(Da),0<=b&&(a=a.substring(0,b))):a="";return a}function Ka(a){return 2>a.length?!1:S(Ha,a)}function La(a){return S(Fa,a)?Ma(a,Aa):Ma(a,ya)}function Na(a){var b=La(a.toString());a.b="";a.a(b)}function Oa(a){return!!a&&(1!=G(a,9)||-1!=D(a,9)[0])}function Ma(a,b){for(var c=new K,d,e=a.length,f=0;f<e;++f)d=a.charAt(f),d=b[d.toUpperCase()],null!=d&&c.a(d);return c.toString()}
  37799. function Pa(a){return null!=a&&isNaN(a)&&a.toUpperCase()in xa}
  37800. function Qa(a,b,c){if(0==B(b,2)&&null!=b.a[5]){var d=F(b,5);if(0<d.length)return d}var d=F(b,1),e=T(b);if(0==c)return Ra(d,0,e,"");if(!(d in P))return e;a=U(a,d,Sa(d));b=null!=b.a[3]&&B(b,3).length?3==c?";ext="+B(b,3):null!=a.a[13]?B(a,13)+F(b,3):" ext. "+F(b,3):"";a:{a=D(a,20).length&&2!=c?D(a,20):D(a,19);for(var f,g=a.length,h=0;h<g;++h){f=a[h];var k=G(f,3);if(!k||!e.search(B(f,3,k-1)))if(k=new RegExp(B(f,1)),S(k,e)){a=f;break a}}a=null}a&&(g=a,a=F(g,2),f=new RegExp(B(g,1)),F(g,5),g=F(g,4),e=2==
  37801. c&&null!=g&&0<g.length?e.replace(f,a.replace(Ia,g)):e.replace(f,a),3==c&&(e=e.replace(RegExp("^[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e]+"),""),e=e.replace(RegExp("[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e]+","g"),"-")));return Ra(d,c,e,b)}function U(a,b,c){return"001"==c?V(a,""+b):V(a,c)}
  37802. function T(a){if(null==a.a[2])return"";var b=""+B(a,2);return null!=a.a[4]&&B(a,4)&&0<F(a,8)?Array(F(a,8)+1).join("0")+b:b}function Ra(a,b,c,d){switch(b){case 0:return"+"+a+c+d;case 1:return"+"+a+" "+c+d;case 3:return"tel:+"+a+"-"+c+d;default:return c+d}}
  37803. function W(a,b){switch(b){case 4:return B(a,5);case 3:return B(a,4);case 1:return B(a,3);case 0:case 2:return B(a,2);case 5:return B(a,6);case 6:return B(a,8);case 7:return B(a,7);case 8:return B(a,21);case 9:return B(a,25);case 10:return B(a,28);default:return B(a,1)}}function Ta(a,b){return X(a,B(b,1))?X(a,B(b,5))?4:X(a,B(b,4))?3:X(a,B(b,6))?5:X(a,B(b,8))?6:X(a,B(b,7))?7:X(a,B(b,21))?8:X(a,B(b,25))?9:X(a,B(b,28))?10:X(a,B(b,2))?B(b,18)||X(a,B(b,3))?2:0:!B(b,18)&&X(a,B(b,3))?1:-1:-1}
  37804. function V(a,b){if(null==b)return null;b=b.toUpperCase();var c=a.a[b];if(!c){c=xa[b];if(!c)return null;c=(new ra).b(N.f(),c);a.a[b]=c}return c}function X(a,b){var c=a.length;return 0<G(b,9)&&-1==x(D(b,9),c)?!1:S(F(b,2),a)}function Ua(a,b){if(!b)return null;var c=F(b,1);if(c=P[c])if(1==c.length)c=c[0];else a:{for(var d=T(b),e,f=c.length,g=0;g<f;g++){e=c[g];var h=V(a,e);if(null!=h.a[23]){if(!d.search(B(h,23))){c=e;break a}}else if(-1!=Ta(d,h)){c=e;break a}}c=null}else c=null;return c}
  37805. function Sa(a){return(a=P[a])?a[0]:"ZZ"}function Y(a,b,c,d){var e=W(c,d),f=G(e,9)?D(e,9):D(B(c,1),9),e=D(e,10);if(2==d)if(Oa(W(c,0)))a=W(c,1),Oa(a)&&(f=f.concat(G(a,9)?D(a,9):D(B(c,1),9)),y(f),e.length?(e=e.concat(D(a,10)),y(e)):e=D(a,10));else return Y(a,b,c,1);if(-1==f[0])return 5;b=b.length;if(-1<x(e,b))return 4;c=f[0];return c==b?0:c>b?2:f[f.length-1]<b?3:-1<x(f,b,1)?0:5}
  37806. function Va(a,b,c,d,e,f){if(!b.length)return 0;b=new K(b);var g;c&&(g=B(c,11));null==g&&(g="NonMatch");var h=b.toString();if(h.length)if(R.test(h))h=h.replace(R,""),b.b="",b.a(La(h)),g=1;else{h=new RegExp(g);Na(b);g=b.toString();if(g.search(h))g=!1;else{var h=g.match(h)[0].length,k=g.substring(h).match(Ba);k&&null!=k[1]&&0<k[1].length&&"0"==Ma(k[1],ya)?g=!1:(b.b="",b.a(g.substring(h)),g=!0)}g=g?5:20}else g=20;e&&C(f,6,g);if(20!=g){if(2>=b.b.length)throw Error("Phone number too short after IDD");a:{a=
  37807. b.toString();if(a.length&&"0"!=a.charAt(0))for(e=a.length,b=1;3>=b&&b<=e;++b)if(c=parseInt(a.substring(0,b),10),c in P){d.a(a.substring(b));d=c;break a}d=0}if(d)return C(f,1,d),d;throw Error("Invalid country calling code");}if(c&&(g=F(c,10),h=""+g,k=b.toString(),!k.lastIndexOf(h,0)&&(h=new K(k.substring(h.length)),k=B(c,1),k=new RegExp(F(k,2)),Wa(h,c,null),h=h.toString(),!S(k,b.toString())&&S(k,h)||3==Y(a,b.toString(),c,-1))))return d.a(h),e&&C(f,6,10),C(f,1,g),g;C(f,1,0);return 0}
  37808. function Wa(a,b,c){var d=a.toString(),e=d.length,f=B(b,15);if(e&&null!=f&&f.length){var g=new RegExp("^(?:"+f+")");if(e=g.exec(d)){var f=new RegExp(F(B(b,1),2)),h=S(f,d),k=e.length-1;b=B(b,16);if(null!=b&&b.length&&null!=e[k]&&e[k].length){if(d=d.replace(g,b),!h||S(f,d))c&&0<k&&c.a(e[1]),a.set(d)}else if(!h||S(f,d.substring(e[0].length)))c&&0<k&&null!=e[k]&&c.a(e[1]),a.set(d.substring(e[0].length))}}}
  37809. function Z(a,b,c){if(!Pa(c)&&0<b.length&&"+"!=b.charAt(0))throw Error("Invalid country calling code");return Xa(a,b,c,!0)}
  37810. function Xa(a,b,c,d){if(null==b)throw Error("The string supplied did not seem to be a phone number");if(250<b.length)throw Error("The string supplied is too long to be a phone number");var e=new K,f=b.indexOf(";phone-context=");if(0<=f){var g=f+15;if("+"==b.charAt(g)){var h=b.indexOf(";",g);0<h?e.a(b.substring(g,h)):e.a(b.substring(g))}g=b.indexOf("tel:");e.a(b.substring(0<=g?g+4:0,f))}else e.a(Ja(b));f=e.toString();g=f.indexOf(";isub=");0<g&&(e.b="",e.a(f.substring(0,g)));if(!Ka(e.toString()))throw Error("The string supplied did not seem to be a phone number");
  37811. f=e.toString();if(!(Pa(c)||null!=f&&0<f.length&&R.test(f)))throw Error("Invalid country calling code");f=new O;d&&C(f,5,b);a:{b=e.toString();g=b.search(Ga);if(0<=g&&Ka(b.substring(0,g)))for(var h=b.match(Ga),k=h.length,q=1;q<k;++q)if(null!=h[q]&&0<h[q].length){e.b="";e.a(b.substring(0,g));b=h[q];break a}b=""}0<b.length&&C(f,3,b);g=V(a,c);b=new K;h=0;k=e.toString();try{h=Va(a,k,g,b,d,f)}catch(z){if("Invalid country calling code"==z.message&&R.test(k)){if(k=k.replace(R,""),h=Va(a,k,g,b,d,f),!h)throw z;
  37812. }else throw z;}h?(e=Sa(h),e!=c&&(g=U(a,h,e))):(Na(e),b.a(e.toString()),null!=c?(h=F(g,10),C(f,1,h)):d&&(delete f.a[6],f.b&&delete f.b[6]));if(2>b.b.length)throw Error("The string supplied is too short to be a phone number");g&&(c=new K,e=new K(b.toString()),Wa(e,g,c),a=Y(a,e.toString(),g,-1),2!=a&&4!=a&&5!=a&&(b=e,d&&0<c.toString().length&&C(f,7,c.toString())));d=b.toString();a=d.length;if(2>a)throw Error("The string supplied is too short to be a phone number");if(17<a)throw Error("The string supplied is too long to be a phone number");
  37813. if(1<d.length&&"0"==d.charAt(0)){C(f,4,!0);for(a=1;a<d.length-1&&"0"==d.charAt(a);)a++;1!=a&&C(f,8,a)}C(f,2,parseInt(d,10));return f}function S(a,b){var c="string"==typeof a?b.match("^(?:"+a+")$"):b.match(a);return c&&c[0].length==b.length?!0:!1};v("intlTelInputUtils",{});v("intlTelInputUtils.formatNumber",function(a,b,c){try{var d=Q.a(),e=Z(d,a,b);return Qa(d,e,"undefined"==typeof c?0:c)}catch(f){return a}});v("intlTelInputUtils.getExampleNumber",function(a,b,c){try{var d=Q.a(),e;a:{if(Pa(a)){var f=W(V(d,a),c);try{if(null!=f.a[6]){var g=B(f,6);e=Xa(d,g,a,!1);break a}}catch(h){}}e=null}return Qa(d,e,b?2:1)}catch(h){return""}});v("intlTelInputUtils.getExtension",function(a,b){try{return B(Z(Q.a(),a,b),3)}catch(c){return""}});
  37814. v("intlTelInputUtils.getNumberType",function(a,b){try{var c=Q.a(),d;var e=Z(c,a,b),f=Ua(c,e),g=U(c,F(e,1),f);if(g){var h=T(e);d=Ta(h,g)}else d=-1;return d}catch(k){return-99}});
  37815. v("intlTelInputUtils.getValidationError",function(a,b){try{var c=Q.a(),d;var e=Z(c,a,b),f=T(e),g=F(e,1);if(g in P){var h=U(c,g,Sa(g));d=Y(c,f,h,-1)}else d=1;return d}catch(k){return"Invalid country calling code"==k.message?1:"The string supplied did not seem to be a phone number"==k.message?4:"Phone number too short after IDD"==k.message||"The string supplied is too short to be a phone number"==k?2:"The string supplied is too long to be a phone number"==k.message?3:-99}});
  37816. v("intlTelInputUtils.isValidNumber",function(a,b){try{var c=Q.a(),d=Z(c,a,b),e;var f=Ua(c,d),g=F(d,1),h=U(c,g,f),k;if(!(k=!h)){var q;if(q="001"!=f){var z,za=V(c,f);if(!za)throw Error("Invalid region code: "+f);z=F(za,10);q=g!=z}k=q}if(k)e=!1;else{var Ya=T(d);e=-1!=Ta(Ya,h)}return e}catch(Za){return!1}});v("intlTelInputUtils.numberFormat",{E164:0,INTERNATIONAL:1,NATIONAL:2,RFC3966:3});
  37817. v("intlTelInputUtils.numberType",{FIXED_LINE:0,MOBILE:1,FIXED_LINE_OR_MOBILE:2,TOLL_FREE:3,PREMIUM_RATE:4,SHARED_COST:5,VOIP:6,PERSONAL_NUMBER:7,PAGER:8,UAN:9,VOICEMAIL:10,UNKNOWN:-1});v("intlTelInputUtils.validationError",{IS_POSSIBLE:0,INVALID_COUNTRY_CODE:1,TOO_SHORT:2,TOO_LONG:3,NOT_A_NUMBER:4});})();
  37818. /**
  37819. * WHMCS Telephone Country Code Dropdown
  37820. *
  37821. * Using https://github.com/jackocnr/intl-tel-input
  37822. *
  37823. * @copyright Copyright (c) WHMCS Limited 2005-2019
  37824. * @license https://www.whmcs.com/license/ WHMCS Eula
  37825. */
  37826. jQuery(document).ready(function() {
  37827. const telephoneSharedCountries = new Map([
  37828. ['um', 'us'], // United States Outlying Islands shares dialing code with the US
  37829. ['ic', 'es'], // Canary Islands shares dialing code with Spain
  37830. ['gs', 'fk'], // South Georgia and Sandwich Islands shares dialing code with Falkland Islands
  37831. ['aq', 'nf'], // Antarctica shares dialing code with Norfolk Island
  37832. ['tf', 're'], // French Southern Territories shares dialing code with Réunion (La Réunion)
  37833. ['hm', 'nf'], // Heard Island and Mcdonald Islands shares dialing code with Norfolk Island
  37834. ['an', 'bq'], // Netherlands Antilles shares dialing code with Caribbean Netherlands
  37835. ['pn', 'nz'], // Pitcairn shares dialing code with New Zealand
  37836. ]);
  37837. function assertTelephoneCountry(country) {
  37838. country = country.toLowerCase();
  37839. if (telephoneSharedCountries.has(country)) {
  37840. return telephoneSharedCountries.get(country);
  37841. }
  37842. return country;
  37843. }
  37844. if (typeof customCountryData !== "undefined") {
  37845. var teleCountryData = $.fn['intlTelInput'].getCountryData();
  37846. for (var code in customCountryData) {
  37847. if (customCountryData.hasOwnProperty(code)) {
  37848. var countryDetails = customCountryData[code];
  37849. codeLower = code.toLowerCase();
  37850. if (countryDetails === false) {
  37851. for (var i = 0; i < teleCountryData.length; i++) {
  37852. if (codeLower === teleCountryData[i].iso2) {
  37853. teleCountryData.splice(i, 1);
  37854. break;
  37855. }
  37856. }
  37857. } else {
  37858. teleCountryData.push(
  37859. {
  37860. name: countryDetails.name,
  37861. iso2: codeLower,
  37862. dialCode: countryDetails.callingCode,
  37863. priority: 0,
  37864. areaCodes: null
  37865. }
  37866. );
  37867. }
  37868. }
  37869. }
  37870. }
  37871. if (jQuery('body').data('phone-cc-input')) {
  37872. var phoneInput = jQuery('input[name^="phone"], input[name$="phone"], input[name="domaincontactphonenumber"]').not('input[type="hidden"]');
  37873. if (phoneInput.length) {
  37874. var countryInput = jQuery('[name^="country"], [name$="country"]'),
  37875. initialCountry = 'us';
  37876. if (countryInput.length) {
  37877. initialCountry = assertTelephoneCountry(countryInput.val());
  37878. }
  37879. phoneInput.each(function(){
  37880. var thisInput = jQuery(this),
  37881. inputName = thisInput.attr('name');
  37882. if (inputName === 'domaincontactphonenumber') {
  37883. initialCountry = jQuery('[name="domaincontactcountry"]').val().toLowerCase();
  37884. }
  37885. jQuery(this).before(
  37886. '<input id="populatedCountryCode' + inputName + '" type="hidden" name="country-calling-code-' + inputName + '" value="" />'
  37887. );
  37888. try {
  37889. thisInput.intlTelInput({
  37890. preferredCountries: [initialCountry, "us", "gb"].filter(function (value, index, self) {
  37891. return self.indexOf(value) === index;
  37892. }),
  37893. initialCountry: initialCountry,
  37894. autoPlaceholder: 'polite', //always show the helper placeholder
  37895. separateDialCode: true
  37896. });
  37897. } catch (error) {
  37898. console.log(error.message);
  37899. return false;
  37900. }
  37901. thisInput.on('countrychange', function (e, countryData) {
  37902. jQuery('#populatedCountryCode' + inputName).val(countryData.dialCode);
  37903. if (jQuery(this).val() === '+' + countryData.dialCode) {
  37904. jQuery(this).val('');
  37905. }
  37906. });
  37907. thisInput.on('blur keydown', function (e) {
  37908. if (e.type === 'blur' || (e.type === 'keydown' && e.keyCode === 13)) {
  37909. var number = jQuery(this).intlTelInput("getNumber"),
  37910. countryData = jQuery(this).intlTelInput("getSelectedCountryData"),
  37911. countryPrefix = '+' + countryData.dialCode;
  37912. if (number.indexOf(countryPrefix) === 0 && (number.match(/\+/g) || []).length > 1) {
  37913. number = number.substr(countryPrefix.length);
  37914. }
  37915. jQuery(this).intlTelInput("setNumber", number);
  37916. }
  37917. });
  37918. jQuery('#populatedCountryCode' + inputName).val(thisInput.intlTelInput('getSelectedCountryData').dialCode);
  37919. countryInput.on('change', function() {
  37920. if (thisInput.val() === '') {
  37921. var country = assertTelephoneCountry(jQuery(this).val());
  37922. try {
  37923. phoneInput.intlTelInput('setCountry', country);
  37924. } catch (error) {
  37925. console.log(error.message);
  37926. return false;
  37927. }
  37928. }
  37929. });
  37930. // this must be .attr (not .data) in order for it to be found by [data-initial-value] selector
  37931. thisInput.attr('data-initial-value', $(thisInput).val());
  37932. thisInput.parents('form').find('input[type=reset]').each(function() {
  37933. var resetButton = this;
  37934. var form = $(resetButton).parents('form');
  37935. if (!$(resetButton).data('phone-handler')) {
  37936. $(resetButton).data('phone-handler', true);
  37937. $(resetButton).click(function(e) {
  37938. e.stopPropagation();
  37939. $(form).trigger('reset');
  37940. $(form).find('input[data-initial-value]').each(function() {
  37941. var inputToReset = this;
  37942. $(inputToReset).val(
  37943. $(inputToReset).attr('data-initial-value')
  37944. );
  37945. });
  37946. return false;
  37947. });
  37948. }
  37949. });
  37950. });
  37951. /**
  37952. * In places where a form icon is present, hide it.
  37953. * Where the input has a class of field, remove that and add form-control in place.
  37954. */
  37955. phoneInput.parents('div.form-group').find('.field-icon').hide().end();
  37956. phoneInput.removeClass('field').addClass('form-control');
  37957. }
  37958. var registrarPhoneInput = jQuery('input[name$="][Phone Number]"], input[name$="][Phone]"]').not('input[type="hidden"]');
  37959. if (registrarPhoneInput.length) {
  37960. jQuery.each(registrarPhoneInput, function(index, input) {
  37961. var thisInput = jQuery(this),
  37962. inputName = thisInput.attr('name');
  37963. inputName = inputName.replace('contactdetails[', '').replace('][Phone Number]', '').replace('][Phone]', '');
  37964. var countryInput = jQuery('[name$="' + inputName + '][Country]"]'),
  37965. initialCountry = assertTelephoneCountry(countryInput.val());
  37966. thisInput.before('<input id="populated' + inputName + 'CountryCode" class="' + inputName + 'customwhois" type="hidden" name="contactdetails[' + inputName + '][Phone Country Code]" value="" />');
  37967. thisInput.intlTelInput({
  37968. preferredCountries: [initialCountry, "us", "gb"].filter(function(value, index, self) {
  37969. return self.indexOf(value) === index;
  37970. }),
  37971. initialCountry: initialCountry,
  37972. autoPlaceholder: 'polite', //always show the helper placeholder
  37973. separateDialCode: true
  37974. });
  37975. thisInput.on('countrychange', function (e, countryData) {
  37976. jQuery('#populated' + inputName + 'CountryCode').val(countryData.dialCode);
  37977. if (jQuery(this).val() === '+' + countryData.dialCode) {
  37978. jQuery(this).val('');
  37979. }
  37980. });
  37981. thisInput.on('blur keydown', function (e) {
  37982. if (e.type === 'blur' || (e.type === 'keydown' && e.keyCode === 13)) {
  37983. var number = jQuery(this).intlTelInput("getNumber"),
  37984. countryData = jQuery(this).intlTelInput("getSelectedCountryData"),
  37985. countryPrefix = '+' + countryData.dialCode;
  37986. if (number.indexOf(countryPrefix) === 0 && (number.match(/\+/g) || []).length > 1) {
  37987. number = number.substr(countryPrefix.length);
  37988. }
  37989. jQuery(this).intlTelInput("setNumber", number);
  37990. }
  37991. });
  37992. jQuery('#populated' + inputName + 'CountryCode').val(thisInput.intlTelInput('getSelectedCountryData').dialCode);
  37993. countryInput.on('blur', function() {
  37994. if (thisInput.val() === '') {
  37995. var country = assertTelephoneCountry(jQuery(this).val());
  37996. thisInput.intlTelInput('setCountry', country);
  37997. }
  37998. });
  37999. });
  38000. }
  38001. }
  38002. });
  38003. /*!
  38004. * Lightbox v2.8.1
  38005. * by Lokesh Dhakar
  38006. *
  38007. * More info:
  38008. * http://lokeshdhakar.com/projects/lightbox2/
  38009. *
  38010. * Copyright 2007, 2015 Lokesh Dhakar
  38011. * Released under the MIT license
  38012. * https://github.com/lokesh/lightbox2/blob/master/LICENSE
  38013. */
  38014. // Uses Node, AMD or browser globals to create a module.
  38015. (function (root, factory) {
  38016. if (typeof define === 'function' && define.amd) {
  38017. // AMD. Register as an anonymous module.
  38018. define(['jquery'], factory);
  38019. } else if (typeof exports === 'object') {
  38020. // Node. Does not work with strict CommonJS, but
  38021. // only CommonJS-like environments that support module.exports,
  38022. // like Node.
  38023. module.exports = factory(require('jquery'));
  38024. } else {
  38025. // Browser globals (root is window)
  38026. root.lightbox = factory(root.jQuery);
  38027. }
  38028. }(this, function ($) {
  38029. function Lightbox(options) {
  38030. this.album = [];
  38031. this.currentImageIndex = void 0;
  38032. this.init();
  38033. // options
  38034. this.options = $.extend({}, this.constructor.defaults);
  38035. this.option(options);
  38036. }
  38037. // Descriptions of all options available on the demo site:
  38038. // http://lokeshdhakar.com/projects/lightbox2/index.html#options
  38039. Lightbox.defaults = {
  38040. albumLabel: 'Image %1 of %2',
  38041. alwaysShowNavOnTouchDevices: false,
  38042. fadeDuration: 500,
  38043. fitImagesInViewport: true,
  38044. // maxWidth: 800,
  38045. // maxHeight: 600,
  38046. positionFromTop: 50,
  38047. resizeDuration: 700,
  38048. showImageNumberLabel: true,
  38049. wrapAround: false
  38050. };
  38051. Lightbox.prototype.option = function(options) {
  38052. $.extend(this.options, options);
  38053. };
  38054. Lightbox.prototype.imageCountLabel = function(currentImageNum, totalImages) {
  38055. return this.options.albumLabel.replace(/%1/g, currentImageNum).replace(/%2/g, totalImages);
  38056. };
  38057. Lightbox.prototype.init = function() {
  38058. this.enable();
  38059. this.build();
  38060. };
  38061. // Loop through anchors and areamaps looking for either data-lightbox attributes or rel attributes
  38062. // that contain 'lightbox'. When these are clicked, start lightbox.
  38063. Lightbox.prototype.enable = function() {
  38064. var self = this;
  38065. $('body').on('click', 'a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]', function(event) {
  38066. self.start($(event.currentTarget));
  38067. return false;
  38068. });
  38069. };
  38070. // Build html for the lightbox and the overlay.
  38071. // Attach event handlers to the new DOM elements. click click click
  38072. Lightbox.prototype.build = function() {
  38073. var self = this;
  38074. $('<div id="lightboxOverlay" class="lightboxOverlay"></div><div id="lightbox" class="lightbox"><div class="lb-outerContainer"><div class="lb-container"><img class="lb-image" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" /><div class="lb-nav"><a class="lb-prev" href="" ></a><a class="lb-next" href="" ></a></div><div class="lb-loader"><a class="lb-cancel"></a></div></div></div><div class="lb-dataContainer"><div class="lb-data"><div class="lb-details"><span class="lb-caption"></span><span class="lb-number"></span></div><div class="lb-closeContainer"><a class="lb-close"></a></div></div></div></div>').appendTo($('body'));
  38075. // Cache jQuery objects
  38076. this.$lightbox = $('#lightbox');
  38077. this.$overlay = $('#lightboxOverlay');
  38078. this.$outerContainer = this.$lightbox.find('.lb-outerContainer');
  38079. this.$container = this.$lightbox.find('.lb-container');
  38080. // Store css values for future lookup
  38081. this.containerTopPadding = parseInt(this.$container.css('padding-top'), 10);
  38082. this.containerRightPadding = parseInt(this.$container.css('padding-right'), 10);
  38083. this.containerBottomPadding = parseInt(this.$container.css('padding-bottom'), 10);
  38084. this.containerLeftPadding = parseInt(this.$container.css('padding-left'), 10);
  38085. // Attach event handlers to the newly minted DOM elements
  38086. this.$overlay.hide().on('click', function() {
  38087. self.end();
  38088. return false;
  38089. });
  38090. this.$lightbox.hide().on('click', function(event) {
  38091. if ($(event.target).attr('id') === 'lightbox') {
  38092. self.end();
  38093. }
  38094. return false;
  38095. });
  38096. this.$outerContainer.on('click', function(event) {
  38097. if ($(event.target).attr('id') === 'lightbox') {
  38098. self.end();
  38099. }
  38100. return false;
  38101. });
  38102. this.$lightbox.find('.lb-prev').on('click', function() {
  38103. if (self.currentImageIndex === 0) {
  38104. self.changeImage(self.album.length - 1);
  38105. } else {
  38106. self.changeImage(self.currentImageIndex - 1);
  38107. }
  38108. return false;
  38109. });
  38110. this.$lightbox.find('.lb-next').on('click', function() {
  38111. if (self.currentImageIndex === self.album.length - 1) {
  38112. self.changeImage(0);
  38113. } else {
  38114. self.changeImage(self.currentImageIndex + 1);
  38115. }
  38116. return false;
  38117. });
  38118. this.$lightbox.find('.lb-loader, .lb-close').on('click', function() {
  38119. self.end();
  38120. return false;
  38121. });
  38122. };
  38123. // Show overlay and lightbox. If the image is part of a set, add siblings to album array.
  38124. Lightbox.prototype.start = function($link) {
  38125. var self = this;
  38126. var $window = $(window);
  38127. $window.on('resize', $.proxy(this.sizeOverlay, this));
  38128. $('select, object, embed').css({
  38129. visibility: 'hidden'
  38130. });
  38131. this.sizeOverlay();
  38132. this.album = [];
  38133. var imageNumber = 0;
  38134. function addToAlbum($link) {
  38135. self.album.push({
  38136. link: $link.attr('href'),
  38137. title: $link.attr('data-title') || $link.attr('title')
  38138. });
  38139. }
  38140. // Support both data-lightbox attribute and rel attribute implementations
  38141. var dataLightboxValue = $link.attr('data-lightbox');
  38142. var $links;
  38143. if (dataLightboxValue) {
  38144. $links = $($link.prop('tagName') + '[data-lightbox="' + dataLightboxValue + '"]');
  38145. for (var i = 0; i < $links.length; i = ++i) {
  38146. addToAlbum($($links[i]));
  38147. if ($links[i] === $link[0]) {
  38148. imageNumber = i;
  38149. }
  38150. }
  38151. } else {
  38152. if ($link.attr('rel') === 'lightbox') {
  38153. // If image is not part of a set
  38154. addToAlbum($link);
  38155. } else {
  38156. // If image is part of a set
  38157. $links = $($link.prop('tagName') + '[rel="' + $link.attr('rel') + '"]');
  38158. for (var j = 0; j < $links.length; j = ++j) {
  38159. addToAlbum($($links[j]));
  38160. if ($links[j] === $link[0]) {
  38161. imageNumber = j;
  38162. }
  38163. }
  38164. }
  38165. }
  38166. // Position Lightbox
  38167. var top = $window.scrollTop() + this.options.positionFromTop;
  38168. var left = $window.scrollLeft();
  38169. this.$lightbox.css({
  38170. top: top + 'px',
  38171. left: left + 'px'
  38172. }).fadeIn(this.options.fadeDuration);
  38173. this.changeImage(imageNumber);
  38174. };
  38175. // Hide most UI elements in preparation for the animated resizing of the lightbox.
  38176. Lightbox.prototype.changeImage = function(imageNumber) {
  38177. var self = this;
  38178. this.disableKeyboardNav();
  38179. var $image = this.$lightbox.find('.lb-image');
  38180. this.$overlay.fadeIn(this.options.fadeDuration);
  38181. $('.lb-loader').fadeIn('slow');
  38182. this.$lightbox.find('.lb-image, .lb-nav, .lb-prev, .lb-next, .lb-dataContainer, .lb-numbers, .lb-caption').hide();
  38183. this.$outerContainer.addClass('animating');
  38184. // When image to show is preloaded, we send the width and height to sizeContainer()
  38185. var preloader = new Image();
  38186. preloader.onload = function() {
  38187. var $preloader;
  38188. var imageHeight;
  38189. var imageWidth;
  38190. var maxImageHeight;
  38191. var maxImageWidth;
  38192. var windowHeight;
  38193. var windowWidth;
  38194. $image.attr('src', self.album[imageNumber].link);
  38195. $preloader = $(preloader);
  38196. $image.width(preloader.width);
  38197. $image.height(preloader.height);
  38198. if (self.options.fitImagesInViewport) {
  38199. // Fit image inside the viewport.
  38200. // Take into account the border around the image and an additional 10px gutter on each side.
  38201. windowWidth = $(window).width();
  38202. windowHeight = $(window).height();
  38203. maxImageWidth = windowWidth - self.containerLeftPadding - self.containerRightPadding - 20;
  38204. maxImageHeight = windowHeight - self.containerTopPadding - self.containerBottomPadding - 120;
  38205. // Check if image size is larger then maxWidth|maxHeight in settings
  38206. if (self.options.maxWidth && self.options.maxWidth < maxImageWidth) {
  38207. maxImageWidth = self.options.maxWidth;
  38208. }
  38209. if (self.options.maxHeight && self.options.maxHeight < maxImageWidth) {
  38210. maxImageHeight = self.options.maxHeight;
  38211. }
  38212. // Is there a fitting issue?
  38213. if ((preloader.width > maxImageWidth) || (preloader.height > maxImageHeight)) {
  38214. if ((preloader.width / maxImageWidth) > (preloader.height / maxImageHeight)) {
  38215. imageWidth = maxImageWidth;
  38216. imageHeight = parseInt(preloader.height / (preloader.width / imageWidth), 10);
  38217. $image.width(imageWidth);
  38218. $image.height(imageHeight);
  38219. } else {
  38220. imageHeight = maxImageHeight;
  38221. imageWidth = parseInt(preloader.width / (preloader.height / imageHeight), 10);
  38222. $image.width(imageWidth);
  38223. $image.height(imageHeight);
  38224. }
  38225. }
  38226. }
  38227. self.sizeContainer($image.width(), $image.height());
  38228. };
  38229. preloader.src = this.album[imageNumber].link;
  38230. this.currentImageIndex = imageNumber;
  38231. };
  38232. // Stretch overlay to fit the viewport
  38233. Lightbox.prototype.sizeOverlay = function() {
  38234. this.$overlay
  38235. .width($(window).width())
  38236. .height($(document).height());
  38237. };
  38238. // Animate the size of the lightbox to fit the image we are showing
  38239. Lightbox.prototype.sizeContainer = function(imageWidth, imageHeight) {
  38240. var self = this;
  38241. var oldWidth = this.$outerContainer.outerWidth();
  38242. var oldHeight = this.$outerContainer.outerHeight();
  38243. var newWidth = imageWidth + this.containerLeftPadding + this.containerRightPadding;
  38244. var newHeight = imageHeight + this.containerTopPadding + this.containerBottomPadding;
  38245. function postResize() {
  38246. self.$lightbox.find('.lb-dataContainer').width(newWidth);
  38247. self.$lightbox.find('.lb-prevLink').height(newHeight);
  38248. self.$lightbox.find('.lb-nextLink').height(newHeight);
  38249. self.showImage();
  38250. }
  38251. if (oldWidth !== newWidth || oldHeight !== newHeight) {
  38252. this.$outerContainer.animate({
  38253. width: newWidth,
  38254. height: newHeight
  38255. }, this.options.resizeDuration, 'swing', function() {
  38256. postResize();
  38257. });
  38258. } else {
  38259. postResize();
  38260. }
  38261. };
  38262. // Display the image and its details and begin preload neighboring images.
  38263. Lightbox.prototype.showImage = function() {
  38264. this.$lightbox.find('.lb-loader').stop(true).hide();
  38265. this.$lightbox.find('.lb-image').fadeIn('slow');
  38266. this.updateNav();
  38267. this.updateDetails();
  38268. this.preloadNeighboringImages();
  38269. this.enableKeyboardNav();
  38270. };
  38271. // Display previous and next navigation if appropriate.
  38272. Lightbox.prototype.updateNav = function() {
  38273. // Check to see if the browser supports touch events. If so, we take the conservative approach
  38274. // and assume that mouse hover events are not supported and always show prev/next navigation
  38275. // arrows in image sets.
  38276. var alwaysShowNav = false;
  38277. try {
  38278. document.createEvent('TouchEvent');
  38279. alwaysShowNav = (this.options.alwaysShowNavOnTouchDevices) ? true : false;
  38280. } catch (e) {}
  38281. this.$lightbox.find('.lb-nav').show();
  38282. if (this.album.length > 1) {
  38283. if (this.options.wrapAround) {
  38284. if (alwaysShowNav) {
  38285. this.$lightbox.find('.lb-prev, .lb-next').css('opacity', '1');
  38286. }
  38287. this.$lightbox.find('.lb-prev, .lb-next').show();
  38288. } else {
  38289. if (this.currentImageIndex > 0) {
  38290. this.$lightbox.find('.lb-prev').show();
  38291. if (alwaysShowNav) {
  38292. this.$lightbox.find('.lb-prev').css('opacity', '1');
  38293. }
  38294. }
  38295. if (this.currentImageIndex < this.album.length - 1) {
  38296. this.$lightbox.find('.lb-next').show();
  38297. if (alwaysShowNav) {
  38298. this.$lightbox.find('.lb-next').css('opacity', '1');
  38299. }
  38300. }
  38301. }
  38302. }
  38303. };
  38304. // Display caption, image number, and closing button.
  38305. Lightbox.prototype.updateDetails = function() {
  38306. var self = this;
  38307. // Enable anchor clicks in the injected caption html.
  38308. // Thanks Nate Wright for the fix. @https://github.com/NateWr
  38309. if (typeof this.album[this.currentImageIndex].title !== 'undefined' &&
  38310. this.album[this.currentImageIndex].title !== '') {
  38311. this.$lightbox.find('.lb-caption')
  38312. .html(this.album[this.currentImageIndex].title)
  38313. .fadeIn('fast')
  38314. .find('a').on('click', function(event) {
  38315. if ($(this).attr('target') !== undefined) {
  38316. window.open($(this).attr('href'), $(this).attr('target'));
  38317. } else {
  38318. location.href = $(this).attr('href');
  38319. }
  38320. });
  38321. }
  38322. if (this.album.length > 1 && this.options.showImageNumberLabel) {
  38323. var labelText = this.imageCountLabel(this.currentImageIndex + 1, this.album.length);
  38324. this.$lightbox.find('.lb-number').text(labelText).fadeIn('fast');
  38325. } else {
  38326. this.$lightbox.find('.lb-number').hide();
  38327. }
  38328. this.$outerContainer.removeClass('animating');
  38329. this.$lightbox.find('.lb-dataContainer').fadeIn(this.options.resizeDuration, function() {
  38330. return self.sizeOverlay();
  38331. });
  38332. };
  38333. // Preload previous and next images in set.
  38334. Lightbox.prototype.preloadNeighboringImages = function() {
  38335. if (this.album.length > this.currentImageIndex + 1) {
  38336. var preloadNext = new Image();
  38337. preloadNext.src = this.album[this.currentImageIndex + 1].link;
  38338. }
  38339. if (this.currentImageIndex > 0) {
  38340. var preloadPrev = new Image();
  38341. preloadPrev.src = this.album[this.currentImageIndex - 1].link;
  38342. }
  38343. };
  38344. Lightbox.prototype.enableKeyboardNav = function() {
  38345. $(document).on('keyup.keyboard', $.proxy(this.keyboardAction, this));
  38346. };
  38347. Lightbox.prototype.disableKeyboardNav = function() {
  38348. $(document).off('.keyboard');
  38349. };
  38350. Lightbox.prototype.keyboardAction = function(event) {
  38351. var KEYCODE_ESC = 27;
  38352. var KEYCODE_LEFTARROW = 37;
  38353. var KEYCODE_RIGHTARROW = 39;
  38354. var keycode = event.keyCode;
  38355. var key = String.fromCharCode(keycode).toLowerCase();
  38356. if (keycode === KEYCODE_ESC || key.match(/x|o|c/)) {
  38357. this.end();
  38358. } else if (key === 'p' || keycode === KEYCODE_LEFTARROW) {
  38359. if (this.currentImageIndex !== 0) {
  38360. this.changeImage(this.currentImageIndex - 1);
  38361. } else if (this.options.wrapAround && this.album.length > 1) {
  38362. this.changeImage(this.album.length - 1);
  38363. }
  38364. } else if (key === 'n' || keycode === KEYCODE_RIGHTARROW) {
  38365. if (this.currentImageIndex !== this.album.length - 1) {
  38366. this.changeImage(this.currentImageIndex + 1);
  38367. } else if (this.options.wrapAround && this.album.length > 1) {
  38368. this.changeImage(0);
  38369. }
  38370. }
  38371. };
  38372. // Closing time. :-(
  38373. Lightbox.prototype.end = function() {
  38374. this.disableKeyboardNav();
  38375. $(window).off('resize', this.sizeOverlay);
  38376. this.$lightbox.fadeOut(this.options.fadeDuration);
  38377. this.$overlay.fadeOut(this.options.fadeDuration);
  38378. $('select, object, embed').css({
  38379. visibility: 'visible'
  38380. });
  38381. };
  38382. return new Lightbox();
  38383. }));
  38384. // TinyColor v1.4.2
  38385. // https://github.com/bgrins/TinyColor
  38386. // Brian Grinstead, MIT License
  38387. (function(Math) {
  38388. var trimLeft = /^\s+/,
  38389. trimRight = /\s+$/,
  38390. tinyCounter = 0,
  38391. mathRound = Math.round,
  38392. mathMin = Math.min,
  38393. mathMax = Math.max,
  38394. mathRandom = Math.random;
  38395. function tinycolor (color, opts) {
  38396. color = (color) ? color : '';
  38397. opts = opts || { };
  38398. // If input is already a tinycolor, return itself
  38399. if (color instanceof tinycolor) {
  38400. return color;
  38401. }
  38402. // If we are called as a function, call using new instead
  38403. if (!(this instanceof tinycolor)) {
  38404. return new tinycolor(color, opts);
  38405. }
  38406. var rgb = inputToRGB(color);
  38407. this._originalInput = color,
  38408. this._r = rgb.r,
  38409. this._g = rgb.g,
  38410. this._b = rgb.b,
  38411. this._a = rgb.a,
  38412. this._roundA = mathRound(100*this._a) / 100,
  38413. this._format = opts.format || rgb.format;
  38414. this._gradientType = opts.gradientType;
  38415. // Don't let the range of [0,255] come back in [0,1].
  38416. // Potentially lose a little bit of precision here, but will fix issues where
  38417. // .5 gets interpreted as half of the total, instead of half of 1
  38418. // If it was supposed to be 128, this was already taken care of by `inputToRgb`
  38419. if (this._r < 1) { this._r = mathRound(this._r); }
  38420. if (this._g < 1) { this._g = mathRound(this._g); }
  38421. if (this._b < 1) { this._b = mathRound(this._b); }
  38422. this._ok = rgb.ok;
  38423. this._tc_id = tinyCounter++;
  38424. }
  38425. tinycolor.prototype = {
  38426. isDark: function() {
  38427. return this.getBrightness() < 128;
  38428. },
  38429. isLight: function() {
  38430. return !this.isDark();
  38431. },
  38432. isValid: function() {
  38433. return this._ok;
  38434. },
  38435. getOriginalInput: function() {
  38436. return this._originalInput;
  38437. },
  38438. getFormat: function() {
  38439. return this._format;
  38440. },
  38441. getAlpha: function() {
  38442. return this._a;
  38443. },
  38444. getBrightness: function() {
  38445. //http://www.w3.org/TR/AERT#color-contrast
  38446. var rgb = this.toRgb();
  38447. return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
  38448. },
  38449. getLuminance: function() {
  38450. //http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
  38451. var rgb = this.toRgb();
  38452. var RsRGB, GsRGB, BsRGB, R, G, B;
  38453. RsRGB = rgb.r/255;
  38454. GsRGB = rgb.g/255;
  38455. BsRGB = rgb.b/255;
  38456. if (RsRGB <= 0.03928) {R = RsRGB / 12.92;} else {R = Math.pow(((RsRGB + 0.055) / 1.055), 2.4);}
  38457. if (GsRGB <= 0.03928) {G = GsRGB / 12.92;} else {G = Math.pow(((GsRGB + 0.055) / 1.055), 2.4);}
  38458. if (BsRGB <= 0.03928) {B = BsRGB / 12.92;} else {B = Math.pow(((BsRGB + 0.055) / 1.055), 2.4);}
  38459. return (0.2126 * R) + (0.7152 * G) + (0.0722 * B);
  38460. },
  38461. setAlpha: function(value) {
  38462. this._a = boundAlpha(value);
  38463. this._roundA = mathRound(100*this._a) / 100;
  38464. return this;
  38465. },
  38466. toHsv: function() {
  38467. var hsv = rgbToHsv(this._r, this._g, this._b);
  38468. return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a };
  38469. },
  38470. toHsvString: function() {
  38471. var hsv = rgbToHsv(this._r, this._g, this._b);
  38472. var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100);
  38473. return (this._a == 1) ?
  38474. "hsv(" + h + ", " + s + "%, " + v + "%)" :
  38475. "hsva(" + h + ", " + s + "%, " + v + "%, "+ this._roundA + ")";
  38476. },
  38477. toHsl: function() {
  38478. var hsl = rgbToHsl(this._r, this._g, this._b);
  38479. return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a };
  38480. },
  38481. toHslString: function() {
  38482. var hsl = rgbToHsl(this._r, this._g, this._b);
  38483. var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100);
  38484. return (this._a == 1) ?
  38485. "hsl(" + h + ", " + s + "%, " + l + "%)" :
  38486. "hsla(" + h + ", " + s + "%, " + l + "%, "+ this._roundA + ")";
  38487. },
  38488. toHex: function(allow3Char) {
  38489. return rgbToHex(this._r, this._g, this._b, allow3Char);
  38490. },
  38491. toHexString: function(allow3Char) {
  38492. return '#' + this.toHex(allow3Char);
  38493. },
  38494. toHex8: function(allow4Char) {
  38495. return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char);
  38496. },
  38497. toHex8String: function(allow4Char) {
  38498. return '#' + this.toHex8(allow4Char);
  38499. },
  38500. toRgb: function() {
  38501. return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a };
  38502. },
  38503. toRgbString: function() {
  38504. return (this._a == 1) ?
  38505. "rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" :
  38506. "rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")";
  38507. },
  38508. toPercentageRgb: function() {
  38509. return { r: mathRound(bound01(this._r, 255) * 100) + "%", g: mathRound(bound01(this._g, 255) * 100) + "%", b: mathRound(bound01(this._b, 255) * 100) + "%", a: this._a };
  38510. },
  38511. toPercentageRgbString: function() {
  38512. return (this._a == 1) ?
  38513. "rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" :
  38514. "rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")";
  38515. },
  38516. toName: function() {
  38517. if (this._a === 0) {
  38518. return "transparent";
  38519. }
  38520. if (this._a < 1) {
  38521. return false;
  38522. }
  38523. return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
  38524. },
  38525. toFilter: function(secondColor) {
  38526. var hex8String = '#' + rgbaToArgbHex(this._r, this._g, this._b, this._a);
  38527. var secondHex8String = hex8String;
  38528. var gradientType = this._gradientType ? "GradientType = 1, " : "";
  38529. if (secondColor) {
  38530. var s = tinycolor(secondColor);
  38531. secondHex8String = '#' + rgbaToArgbHex(s._r, s._g, s._b, s._a);
  38532. }
  38533. return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")";
  38534. },
  38535. toString: function(format) {
  38536. var formatSet = !!format;
  38537. format = format || this._format;
  38538. var formattedString = false;
  38539. var hasAlpha = this._a < 1 && this._a >= 0;
  38540. var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name");
  38541. if (needsAlphaFormat) {
  38542. // Special case for "transparent", all other non-alpha formats
  38543. // will return rgba when there is transparency.
  38544. if (format === "name" && this._a === 0) {
  38545. return this.toName();
  38546. }
  38547. return this.toRgbString();
  38548. }
  38549. if (format === "rgb") {
  38550. formattedString = this.toRgbString();
  38551. }
  38552. if (format === "prgb") {
  38553. formattedString = this.toPercentageRgbString();
  38554. }
  38555. if (format === "hex" || format === "hex6") {
  38556. formattedString = this.toHexString();
  38557. }
  38558. if (format === "hex3") {
  38559. formattedString = this.toHexString(true);
  38560. }
  38561. if (format === "hex4") {
  38562. formattedString = this.toHex8String(true);
  38563. }
  38564. if (format === "hex8") {
  38565. formattedString = this.toHex8String();
  38566. }
  38567. if (format === "name") {
  38568. formattedString = this.toName();
  38569. }
  38570. if (format === "hsl") {
  38571. formattedString = this.toHslString();
  38572. }
  38573. if (format === "hsv") {
  38574. formattedString = this.toHsvString();
  38575. }
  38576. return formattedString || this.toHexString();
  38577. },
  38578. clone: function() {
  38579. return tinycolor(this.toString());
  38580. },
  38581. _applyModification: function(fn, args) {
  38582. var color = fn.apply(null, [this].concat([].slice.call(args)));
  38583. this._r = color._r;
  38584. this._g = color._g;
  38585. this._b = color._b;
  38586. this.setAlpha(color._a);
  38587. return this;
  38588. },
  38589. lighten: function() {
  38590. return this._applyModification(lighten, arguments);
  38591. },
  38592. brighten: function() {
  38593. return this._applyModification(brighten, arguments);
  38594. },
  38595. darken: function() {
  38596. return this._applyModification(darken, arguments);
  38597. },
  38598. desaturate: function() {
  38599. return this._applyModification(desaturate, arguments);
  38600. },
  38601. saturate: function() {
  38602. return this._applyModification(saturate, arguments);
  38603. },
  38604. greyscale: function() {
  38605. return this._applyModification(greyscale, arguments);
  38606. },
  38607. spin: function() {
  38608. return this._applyModification(spin, arguments);
  38609. },
  38610. _applyCombination: function(fn, args) {
  38611. return fn.apply(null, [this].concat([].slice.call(args)));
  38612. },
  38613. analogous: function() {
  38614. return this._applyCombination(analogous, arguments);
  38615. },
  38616. complement: function() {
  38617. return this._applyCombination(complement, arguments);
  38618. },
  38619. monochromatic: function() {
  38620. return this._applyCombination(monochromatic, arguments);
  38621. },
  38622. splitcomplement: function() {
  38623. return this._applyCombination(splitcomplement, arguments);
  38624. },
  38625. triad: function() {
  38626. return this._applyCombination(triad, arguments);
  38627. },
  38628. tetrad: function() {
  38629. return this._applyCombination(tetrad, arguments);
  38630. }
  38631. };
  38632. // If input is an object, force 1 into "1.0" to handle ratios properly
  38633. // String input requires "1.0" as input, so 1 will be treated as 1
  38634. tinycolor.fromRatio = function(color, opts) {
  38635. if (typeof color == "object") {
  38636. var newColor = {};
  38637. for (var i in color) {
  38638. if (color.hasOwnProperty(i)) {
  38639. if (i === "a") {
  38640. newColor[i] = color[i];
  38641. }
  38642. else {
  38643. newColor[i] = convertToPercentage(color[i]);
  38644. }
  38645. }
  38646. }
  38647. color = newColor;
  38648. }
  38649. return tinycolor(color, opts);
  38650. };
  38651. // Given a string or object, convert that input to RGB
  38652. // Possible string inputs:
  38653. //
  38654. // "red"
  38655. // "#f00" or "f00"
  38656. // "#ff0000" or "ff0000"
  38657. // "#ff000000" or "ff000000"
  38658. // "rgb 255 0 0" or "rgb (255, 0, 0)"
  38659. // "rgb 1.0 0 0" or "rgb (1, 0, 0)"
  38660. // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
  38661. // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
  38662. // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
  38663. // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
  38664. // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
  38665. //
  38666. function inputToRGB(color) {
  38667. var rgb = { r: 0, g: 0, b: 0 };
  38668. var a = 1;
  38669. var s = null;
  38670. var v = null;
  38671. var l = null;
  38672. var ok = false;
  38673. var format = false;
  38674. if (typeof color == "string") {
  38675. color = stringInputToObject(color);
  38676. }
  38677. if (typeof color == "object") {
  38678. if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
  38679. rgb = rgbToRgb(color.r, color.g, color.b);
  38680. ok = true;
  38681. format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
  38682. }
  38683. else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
  38684. s = convertToPercentage(color.s);
  38685. v = convertToPercentage(color.v);
  38686. rgb = hsvToRgb(color.h, s, v);
  38687. ok = true;
  38688. format = "hsv";
  38689. }
  38690. else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
  38691. s = convertToPercentage(color.s);
  38692. l = convertToPercentage(color.l);
  38693. rgb = hslToRgb(color.h, s, l);
  38694. ok = true;
  38695. format = "hsl";
  38696. }
  38697. if (color.hasOwnProperty("a")) {
  38698. a = color.a;
  38699. }
  38700. }
  38701. a = boundAlpha(a);
  38702. return {
  38703. ok: ok,
  38704. format: color.format || format,
  38705. r: mathMin(255, mathMax(rgb.r, 0)),
  38706. g: mathMin(255, mathMax(rgb.g, 0)),
  38707. b: mathMin(255, mathMax(rgb.b, 0)),
  38708. a: a
  38709. };
  38710. }
  38711. // Conversion Functions
  38712. // --------------------
  38713. // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
  38714. // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
  38715. // `rgbToRgb`
  38716. // Handle bounds / percentage checking to conform to CSS color spec
  38717. // <http://www.w3.org/TR/css3-color/>
  38718. // *Assumes:* r, g, b in [0, 255] or [0, 1]
  38719. // *Returns:* { r, g, b } in [0, 255]
  38720. function rgbToRgb(r, g, b){
  38721. return {
  38722. r: bound01(r, 255) * 255,
  38723. g: bound01(g, 255) * 255,
  38724. b: bound01(b, 255) * 255
  38725. };
  38726. }
  38727. // `rgbToHsl`
  38728. // Converts an RGB color value to HSL.
  38729. // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
  38730. // *Returns:* { h, s, l } in [0,1]
  38731. function rgbToHsl(r, g, b) {
  38732. r = bound01(r, 255);
  38733. g = bound01(g, 255);
  38734. b = bound01(b, 255);
  38735. var max = mathMax(r, g, b), min = mathMin(r, g, b);
  38736. var h, s, l = (max + min) / 2;
  38737. if(max == min) {
  38738. h = s = 0; // achromatic
  38739. }
  38740. else {
  38741. var d = max - min;
  38742. s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
  38743. switch(max) {
  38744. case r: h = (g - b) / d + (g < b ? 6 : 0); break;
  38745. case g: h = (b - r) / d + 2; break;
  38746. case b: h = (r - g) / d + 4; break;
  38747. }
  38748. h /= 6;
  38749. }
  38750. return { h: h, s: s, l: l };
  38751. }
  38752. // `hslToRgb`
  38753. // Converts an HSL color value to RGB.
  38754. // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
  38755. // *Returns:* { r, g, b } in the set [0, 255]
  38756. function hslToRgb(h, s, l) {
  38757. var r, g, b;
  38758. h = bound01(h, 360);
  38759. s = bound01(s, 100);
  38760. l = bound01(l, 100);
  38761. function hue2rgb(p, q, t) {
  38762. if(t < 0) t += 1;
  38763. if(t > 1) t -= 1;
  38764. if(t < 1/6) return p + (q - p) * 6 * t;
  38765. if(t < 1/2) return q;
  38766. if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
  38767. return p;
  38768. }
  38769. if(s === 0) {
  38770. r = g = b = l; // achromatic
  38771. }
  38772. else {
  38773. var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
  38774. var p = 2 * l - q;
  38775. r = hue2rgb(p, q, h + 1/3);
  38776. g = hue2rgb(p, q, h);
  38777. b = hue2rgb(p, q, h - 1/3);
  38778. }
  38779. return { r: r * 255, g: g * 255, b: b * 255 };
  38780. }
  38781. // `rgbToHsv`
  38782. // Converts an RGB color value to HSV
  38783. // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
  38784. // *Returns:* { h, s, v } in [0,1]
  38785. function rgbToHsv(r, g, b) {
  38786. r = bound01(r, 255);
  38787. g = bound01(g, 255);
  38788. b = bound01(b, 255);
  38789. var max = mathMax(r, g, b), min = mathMin(r, g, b);
  38790. var h, s, v = max;
  38791. var d = max - min;
  38792. s = max === 0 ? 0 : d / max;
  38793. if(max == min) {
  38794. h = 0; // achromatic
  38795. }
  38796. else {
  38797. switch(max) {
  38798. case r: h = (g - b) / d + (g < b ? 6 : 0); break;
  38799. case g: h = (b - r) / d + 2; break;
  38800. case b: h = (r - g) / d + 4; break;
  38801. }
  38802. h /= 6;
  38803. }
  38804. return { h: h, s: s, v: v };
  38805. }
  38806. // `hsvToRgb`
  38807. // Converts an HSV color value to RGB.
  38808. // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
  38809. // *Returns:* { r, g, b } in the set [0, 255]
  38810. function hsvToRgb(h, s, v) {
  38811. h = bound01(h, 360) * 6;
  38812. s = bound01(s, 100);
  38813. v = bound01(v, 100);
  38814. var i = Math.floor(h),
  38815. f = h - i,
  38816. p = v * (1 - s),
  38817. q = v * (1 - f * s),
  38818. t = v * (1 - (1 - f) * s),
  38819. mod = i % 6,
  38820. r = [v, q, p, p, t, v][mod],
  38821. g = [t, v, v, q, p, p][mod],
  38822. b = [p, p, t, v, v, q][mod];
  38823. return { r: r * 255, g: g * 255, b: b * 255 };
  38824. }
  38825. // `rgbToHex`
  38826. // Converts an RGB color to hex
  38827. // Assumes r, g, and b are contained in the set [0, 255]
  38828. // Returns a 3 or 6 character hex
  38829. function rgbToHex(r, g, b, allow3Char) {
  38830. var hex = [
  38831. pad2(mathRound(r).toString(16)),
  38832. pad2(mathRound(g).toString(16)),
  38833. pad2(mathRound(b).toString(16))
  38834. ];
  38835. // Return a 3 character hex if possible
  38836. if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
  38837. return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
  38838. }
  38839. return hex.join("");
  38840. }
  38841. // `rgbaToHex`
  38842. // Converts an RGBA color plus alpha transparency to hex
  38843. // Assumes r, g, b are contained in the set [0, 255] and
  38844. // a in [0, 1]. Returns a 4 or 8 character rgba hex
  38845. function rgbaToHex(r, g, b, a, allow4Char) {
  38846. var hex = [
  38847. pad2(mathRound(r).toString(16)),
  38848. pad2(mathRound(g).toString(16)),
  38849. pad2(mathRound(b).toString(16)),
  38850. pad2(convertDecimalToHex(a))
  38851. ];
  38852. // Return a 4 character hex if possible
  38853. if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) {
  38854. return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
  38855. }
  38856. return hex.join("");
  38857. }
  38858. // `rgbaToArgbHex`
  38859. // Converts an RGBA color to an ARGB Hex8 string
  38860. // Rarely used, but required for "toFilter()"
  38861. function rgbaToArgbHex(r, g, b, a) {
  38862. var hex = [
  38863. pad2(convertDecimalToHex(a)),
  38864. pad2(mathRound(r).toString(16)),
  38865. pad2(mathRound(g).toString(16)),
  38866. pad2(mathRound(b).toString(16))
  38867. ];
  38868. return hex.join("");
  38869. }
  38870. // `equals`
  38871. // Can be called with any tinycolor input
  38872. tinycolor.equals = function (color1, color2) {
  38873. if (!color1 || !color2) { return false; }
  38874. return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
  38875. };
  38876. tinycolor.random = function() {
  38877. return tinycolor.fromRatio({
  38878. r: mathRandom(),
  38879. g: mathRandom(),
  38880. b: mathRandom()
  38881. });
  38882. };
  38883. // Modification Functions
  38884. // ----------------------
  38885. // Thanks to less.js for some of the basics here
  38886. // <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
  38887. function desaturate(color, amount) {
  38888. amount = (amount === 0) ? 0 : (amount || 10);
  38889. var hsl = tinycolor(color).toHsl();
  38890. hsl.s -= amount / 100;
  38891. hsl.s = clamp01(hsl.s);
  38892. return tinycolor(hsl);
  38893. }
  38894. function saturate(color, amount) {
  38895. amount = (amount === 0) ? 0 : (amount || 10);
  38896. var hsl = tinycolor(color).toHsl();
  38897. hsl.s += amount / 100;
  38898. hsl.s = clamp01(hsl.s);
  38899. return tinycolor(hsl);
  38900. }
  38901. function greyscale(color) {
  38902. return tinycolor(color).desaturate(100);
  38903. }
  38904. function lighten (color, amount) {
  38905. amount = (amount === 0) ? 0 : (amount || 10);
  38906. var hsl = tinycolor(color).toHsl();
  38907. hsl.l += amount / 100;
  38908. hsl.l = clamp01(hsl.l);
  38909. return tinycolor(hsl);
  38910. }
  38911. function brighten(color, amount) {
  38912. amount = (amount === 0) ? 0 : (amount || 10);
  38913. var rgb = tinycolor(color).toRgb();
  38914. rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100))));
  38915. rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100))));
  38916. rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100))));
  38917. return tinycolor(rgb);
  38918. }
  38919. function darken (color, amount) {
  38920. amount = (amount === 0) ? 0 : (amount || 10);
  38921. var hsl = tinycolor(color).toHsl();
  38922. hsl.l -= amount / 100;
  38923. hsl.l = clamp01(hsl.l);
  38924. return tinycolor(hsl);
  38925. }
  38926. // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
  38927. // Values outside of this range will be wrapped into this range.
  38928. function spin(color, amount) {
  38929. var hsl = tinycolor(color).toHsl();
  38930. var hue = (hsl.h + amount) % 360;
  38931. hsl.h = hue < 0 ? 360 + hue : hue;
  38932. return tinycolor(hsl);
  38933. }
  38934. // Combination Functions
  38935. // ---------------------
  38936. // Thanks to jQuery xColor for some of the ideas behind these
  38937. // <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
  38938. function complement(color) {
  38939. var hsl = tinycolor(color).toHsl();
  38940. hsl.h = (hsl.h + 180) % 360;
  38941. return tinycolor(hsl);
  38942. }
  38943. function triad(color) {
  38944. var hsl = tinycolor(color).toHsl();
  38945. var h = hsl.h;
  38946. return [
  38947. tinycolor(color),
  38948. tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }),
  38949. tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })
  38950. ];
  38951. }
  38952. function tetrad(color) {
  38953. var hsl = tinycolor(color).toHsl();
  38954. var h = hsl.h;
  38955. return [
  38956. tinycolor(color),
  38957. tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }),
  38958. tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }),
  38959. tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })
  38960. ];
  38961. }
  38962. function splitcomplement(color) {
  38963. var hsl = tinycolor(color).toHsl();
  38964. var h = hsl.h;
  38965. return [
  38966. tinycolor(color),
  38967. tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}),
  38968. tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l})
  38969. ];
  38970. }
  38971. function analogous(color, results, slices) {
  38972. results = results || 6;
  38973. slices = slices || 30;
  38974. var hsl = tinycolor(color).toHsl();
  38975. var part = 360 / slices;
  38976. var ret = [tinycolor(color)];
  38977. for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) {
  38978. hsl.h = (hsl.h + part) % 360;
  38979. ret.push(tinycolor(hsl));
  38980. }
  38981. return ret;
  38982. }
  38983. function monochromatic(color, results) {
  38984. results = results || 6;
  38985. var hsv = tinycolor(color).toHsv();
  38986. var h = hsv.h, s = hsv.s, v = hsv.v;
  38987. var ret = [];
  38988. var modification = 1 / results;
  38989. while (results--) {
  38990. ret.push(tinycolor({ h: h, s: s, v: v}));
  38991. v = (v + modification) % 1;
  38992. }
  38993. return ret;
  38994. }
  38995. // Utility Functions
  38996. // ---------------------
  38997. tinycolor.mix = function(color1, color2, amount) {
  38998. amount = (amount === 0) ? 0 : (amount || 50);
  38999. var rgb1 = tinycolor(color1).toRgb();
  39000. var rgb2 = tinycolor(color2).toRgb();
  39001. var p = amount / 100;
  39002. var rgba = {
  39003. r: ((rgb2.r - rgb1.r) * p) + rgb1.r,
  39004. g: ((rgb2.g - rgb1.g) * p) + rgb1.g,
  39005. b: ((rgb2.b - rgb1.b) * p) + rgb1.b,
  39006. a: ((rgb2.a - rgb1.a) * p) + rgb1.a
  39007. };
  39008. return tinycolor(rgba);
  39009. };
  39010. // Readability Functions
  39011. // ---------------------
  39012. // <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
  39013. // `contrast`
  39014. // Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
  39015. tinycolor.readability = function(color1, color2) {
  39016. var c1 = tinycolor(color1);
  39017. var c2 = tinycolor(color2);
  39018. return (Math.max(c1.getLuminance(),c2.getLuminance())+0.05) / (Math.min(c1.getLuminance(),c2.getLuminance())+0.05);
  39019. };
  39020. // `isReadable`
  39021. // Ensure that foreground and background color combinations meet WCAG2 guidelines.
  39022. // The third argument is an optional Object.
  39023. // the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
  39024. // the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
  39025. // If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
  39026. // *Example*
  39027. // tinycolor.isReadable("#000", "#111") => false
  39028. // tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false
  39029. tinycolor.isReadable = function(color1, color2, wcag2) {
  39030. var readability = tinycolor.readability(color1, color2);
  39031. var wcag2Parms, out;
  39032. out = false;
  39033. wcag2Parms = validateWCAG2Parms(wcag2);
  39034. switch (wcag2Parms.level + wcag2Parms.size) {
  39035. case "AAsmall":
  39036. case "AAAlarge":
  39037. out = readability >= 4.5;
  39038. break;
  39039. case "AAlarge":
  39040. out = readability >= 3;
  39041. break;
  39042. case "AAAsmall":
  39043. out = readability >= 7;
  39044. break;
  39045. }
  39046. return out;
  39047. };
  39048. // `mostReadable`
  39049. // Given a base color and a list of possible foreground or background
  39050. // colors for that base, returns the most readable color.
  39051. // Optionally returns Black or White if the most readable color is unreadable.
  39052. // *Example*
  39053. // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255"
  39054. // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff"
  39055. // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3"
  39056. // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff"
  39057. tinycolor.mostReadable = function(baseColor, colorList, args) {
  39058. var bestColor = null;
  39059. var bestScore = 0;
  39060. var readability;
  39061. var includeFallbackColors, level, size ;
  39062. args = args || {};
  39063. includeFallbackColors = args.includeFallbackColors ;
  39064. level = args.level;
  39065. size = args.size;
  39066. for (var i= 0; i < colorList.length ; i++) {
  39067. readability = tinycolor.readability(baseColor, colorList[i]);
  39068. if (readability > bestScore) {
  39069. bestScore = readability;
  39070. bestColor = tinycolor(colorList[i]);
  39071. }
  39072. }
  39073. if (tinycolor.isReadable(baseColor, bestColor, {"level":level,"size":size}) || !includeFallbackColors) {
  39074. return bestColor;
  39075. }
  39076. else {
  39077. args.includeFallbackColors=false;
  39078. return tinycolor.mostReadable(baseColor,["#fff", "#000"],args);
  39079. }
  39080. };
  39081. // Big List of Colors
  39082. // ------------------
  39083. // <http://www.w3.org/TR/css3-color/#svg-color>
  39084. var names = tinycolor.names = {
  39085. aliceblue: "f0f8ff",
  39086. antiquewhite: "faebd7",
  39087. aqua: "0ff",
  39088. aquamarine: "7fffd4",
  39089. azure: "f0ffff",
  39090. beige: "f5f5dc",
  39091. bisque: "ffe4c4",
  39092. black: "000",
  39093. blanchedalmond: "ffebcd",
  39094. blue: "00f",
  39095. blueviolet: "8a2be2",
  39096. brown: "a52a2a",
  39097. burlywood: "deb887",
  39098. burntsienna: "ea7e5d",
  39099. cadetblue: "5f9ea0",
  39100. chartreuse: "7fff00",
  39101. chocolate: "d2691e",
  39102. coral: "ff7f50",
  39103. cornflowerblue: "6495ed",
  39104. cornsilk: "fff8dc",
  39105. crimson: "dc143c",
  39106. cyan: "0ff",
  39107. darkblue: "00008b",
  39108. darkcyan: "008b8b",
  39109. darkgoldenrod: "b8860b",
  39110. darkgray: "a9a9a9",
  39111. darkgreen: "006400",
  39112. darkgrey: "a9a9a9",
  39113. darkkhaki: "bdb76b",
  39114. darkmagenta: "8b008b",
  39115. darkolivegreen: "556b2f",
  39116. darkorange: "ff8c00",
  39117. darkorchid: "9932cc",
  39118. darkred: "8b0000",
  39119. darksalmon: "e9967a",
  39120. darkseagreen: "8fbc8f",
  39121. darkslateblue: "483d8b",
  39122. darkslategray: "2f4f4f",
  39123. darkslategrey: "2f4f4f",
  39124. darkturquoise: "00ced1",
  39125. darkviolet: "9400d3",
  39126. deeppink: "ff1493",
  39127. deepskyblue: "00bfff",
  39128. dimgray: "696969",
  39129. dimgrey: "696969",
  39130. dodgerblue: "1e90ff",
  39131. firebrick: "b22222",
  39132. floralwhite: "fffaf0",
  39133. forestgreen: "228b22",
  39134. fuchsia: "f0f",
  39135. gainsboro: "dcdcdc",
  39136. ghostwhite: "f8f8ff",
  39137. gold: "ffd700",
  39138. goldenrod: "daa520",
  39139. gray: "808080",
  39140. green: "008000",
  39141. greenyellow: "adff2f",
  39142. grey: "808080",
  39143. honeydew: "f0fff0",
  39144. hotpink: "ff69b4",
  39145. indianred: "cd5c5c",
  39146. indigo: "4b0082",
  39147. ivory: "fffff0",
  39148. khaki: "f0e68c",
  39149. lavender: "e6e6fa",
  39150. lavenderblush: "fff0f5",
  39151. lawngreen: "7cfc00",
  39152. lemonchiffon: "fffacd",
  39153. lightblue: "add8e6",
  39154. lightcoral: "f08080",
  39155. lightcyan: "e0ffff",
  39156. lightgoldenrodyellow: "fafad2",
  39157. lightgray: "d3d3d3",
  39158. lightgreen: "90ee90",
  39159. lightgrey: "d3d3d3",
  39160. lightpink: "ffb6c1",
  39161. lightsalmon: "ffa07a",
  39162. lightseagreen: "20b2aa",
  39163. lightskyblue: "87cefa",
  39164. lightslategray: "789",
  39165. lightslategrey: "789",
  39166. lightsteelblue: "b0c4de",
  39167. lightyellow: "ffffe0",
  39168. lime: "0f0",
  39169. limegreen: "32cd32",
  39170. linen: "faf0e6",
  39171. magenta: "f0f",
  39172. maroon: "800000",
  39173. mediumaquamarine: "66cdaa",
  39174. mediumblue: "0000cd",
  39175. mediumorchid: "ba55d3",
  39176. mediumpurple: "9370db",
  39177. mediumseagreen: "3cb371",
  39178. mediumslateblue: "7b68ee",
  39179. mediumspringgreen: "00fa9a",
  39180. mediumturquoise: "48d1cc",
  39181. mediumvioletred: "c71585",
  39182. midnightblue: "191970",
  39183. mintcream: "f5fffa",
  39184. mistyrose: "ffe4e1",
  39185. moccasin: "ffe4b5",
  39186. navajowhite: "ffdead",
  39187. navy: "000080",
  39188. oldlace: "fdf5e6",
  39189. olive: "808000",
  39190. olivedrab: "6b8e23",
  39191. orange: "ffa500",
  39192. orangered: "ff4500",
  39193. orchid: "da70d6",
  39194. palegoldenrod: "eee8aa",
  39195. palegreen: "98fb98",
  39196. paleturquoise: "afeeee",
  39197. palevioletred: "db7093",
  39198. papayawhip: "ffefd5",
  39199. peachpuff: "ffdab9",
  39200. peru: "cd853f",
  39201. pink: "ffc0cb",
  39202. plum: "dda0dd",
  39203. powderblue: "b0e0e6",
  39204. purple: "800080",
  39205. rebeccapurple: "663399",
  39206. red: "f00",
  39207. rosybrown: "bc8f8f",
  39208. royalblue: "4169e1",
  39209. saddlebrown: "8b4513",
  39210. salmon: "fa8072",
  39211. sandybrown: "f4a460",
  39212. seagreen: "2e8b57",
  39213. seashell: "fff5ee",
  39214. sienna: "a0522d",
  39215. silver: "c0c0c0",
  39216. skyblue: "87ceeb",
  39217. slateblue: "6a5acd",
  39218. slategray: "708090",
  39219. slategrey: "708090",
  39220. snow: "fffafa",
  39221. springgreen: "00ff7f",
  39222. steelblue: "4682b4",
  39223. tan: "d2b48c",
  39224. teal: "008080",
  39225. thistle: "d8bfd8",
  39226. tomato: "ff6347",
  39227. turquoise: "40e0d0",
  39228. violet: "ee82ee",
  39229. wheat: "f5deb3",
  39230. white: "fff",
  39231. whitesmoke: "f5f5f5",
  39232. yellow: "ff0",
  39233. yellowgreen: "9acd32"
  39234. };
  39235. // Make it easy to access colors via `hexNames[hex]`
  39236. var hexNames = tinycolor.hexNames = flip(names);
  39237. // Utilities
  39238. // ---------
  39239. // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
  39240. function flip(o) {
  39241. var flipped = { };
  39242. for (var i in o) {
  39243. if (o.hasOwnProperty(i)) {
  39244. flipped[o[i]] = i;
  39245. }
  39246. }
  39247. return flipped;
  39248. }
  39249. // Return a valid alpha value [0,1] with all invalid values being set to 1
  39250. function boundAlpha(a) {
  39251. a = parseFloat(a);
  39252. if (isNaN(a) || a < 0 || a > 1) {
  39253. a = 1;
  39254. }
  39255. return a;
  39256. }
  39257. // Take input from [0, n] and return it as [0, 1]
  39258. function bound01(n, max) {
  39259. if (isOnePointZero(n)) { n = "100%"; }
  39260. var processPercent = isPercentage(n);
  39261. n = mathMin(max, mathMax(0, parseFloat(n)));
  39262. // Automatically convert percentage into number
  39263. if (processPercent) {
  39264. n = parseInt(n * max, 10) / 100;
  39265. }
  39266. // Handle floating point rounding errors
  39267. if ((Math.abs(n - max) < 0.000001)) {
  39268. return 1;
  39269. }
  39270. // Convert into [0, 1] range if it isn't already
  39271. return (n % max) / parseFloat(max);
  39272. }
  39273. // Force a number between 0 and 1
  39274. function clamp01(val) {
  39275. return mathMin(1, mathMax(0, val));
  39276. }
  39277. // Parse a base-16 hex value into a base-10 integer
  39278. function parseIntFromHex(val) {
  39279. return parseInt(val, 16);
  39280. }
  39281. // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
  39282. // <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
  39283. function isOnePointZero(n) {
  39284. return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1;
  39285. }
  39286. // Check to see if string passed in is a percentage
  39287. function isPercentage(n) {
  39288. return typeof n === "string" && n.indexOf('%') != -1;
  39289. }
  39290. // Force a hex value to have 2 characters
  39291. function pad2(c) {
  39292. return c.length == 1 ? '0' + c : '' + c;
  39293. }
  39294. // Replace a decimal with it's percentage value
  39295. function convertToPercentage(n) {
  39296. if (n <= 1) {
  39297. n = (n * 100) + "%";
  39298. }
  39299. return n;
  39300. }
  39301. // Converts a decimal to a hex value
  39302. function convertDecimalToHex(d) {
  39303. return Math.round(parseFloat(d) * 255).toString(16);
  39304. }
  39305. // Converts a hex value to a decimal
  39306. function convertHexToDecimal(h) {
  39307. return (parseIntFromHex(h) / 255);
  39308. }
  39309. var matchers = (function() {
  39310. // <http://www.w3.org/TR/css3-values/#integers>
  39311. var CSS_INTEGER = "[-\\+]?\\d+%?";
  39312. // <http://www.w3.org/TR/css3-values/#number-value>
  39313. var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
  39314. // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
  39315. var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
  39316. // Actual matching.
  39317. // Parentheses and commas are optional, but not required.
  39318. // Whitespace can take the place of commas or opening paren
  39319. var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
  39320. var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
  39321. return {
  39322. CSS_UNIT: new RegExp(CSS_UNIT),
  39323. rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
  39324. rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
  39325. hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
  39326. hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
  39327. hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
  39328. hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
  39329. hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
  39330. hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
  39331. hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
  39332. hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
  39333. };
  39334. })();
  39335. // `isValidCSSUnit`
  39336. // Take in a single string / number and check to see if it looks like a CSS unit
  39337. // (see `matchers` above for definition).
  39338. function isValidCSSUnit(color) {
  39339. return !!matchers.CSS_UNIT.exec(color);
  39340. }
  39341. // `stringInputToObject`
  39342. // Permissive string parsing. Take in a number of formats, and output an object
  39343. // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
  39344. function stringInputToObject(color) {
  39345. color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase();
  39346. var named = false;
  39347. if (names[color]) {
  39348. color = names[color];
  39349. named = true;
  39350. }
  39351. else if (color == 'transparent') {
  39352. return { r: 0, g: 0, b: 0, a: 0, format: "name" };
  39353. }
  39354. // Try to match string input using regular expressions.
  39355. // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
  39356. // Just return an object and let the conversion functions handle that.
  39357. // This way the result will be the same whether the tinycolor is initialized with string or object.
  39358. var match;
  39359. if ((match = matchers.rgb.exec(color))) {
  39360. return { r: match[1], g: match[2], b: match[3] };
  39361. }
  39362. if ((match = matchers.rgba.exec(color))) {
  39363. return { r: match[1], g: match[2], b: match[3], a: match[4] };
  39364. }
  39365. if ((match = matchers.hsl.exec(color))) {
  39366. return { h: match[1], s: match[2], l: match[3] };
  39367. }
  39368. if ((match = matchers.hsla.exec(color))) {
  39369. return { h: match[1], s: match[2], l: match[3], a: match[4] };
  39370. }
  39371. if ((match = matchers.hsv.exec(color))) {
  39372. return { h: match[1], s: match[2], v: match[3] };
  39373. }
  39374. if ((match = matchers.hsva.exec(color))) {
  39375. return { h: match[1], s: match[2], v: match[3], a: match[4] };
  39376. }
  39377. if ((match = matchers.hex8.exec(color))) {
  39378. return {
  39379. r: parseIntFromHex(match[1]),
  39380. g: parseIntFromHex(match[2]),
  39381. b: parseIntFromHex(match[3]),
  39382. a: convertHexToDecimal(match[4]),
  39383. format: named ? "name" : "hex8"
  39384. };
  39385. }
  39386. if ((match = matchers.hex6.exec(color))) {
  39387. return {
  39388. r: parseIntFromHex(match[1]),
  39389. g: parseIntFromHex(match[2]),
  39390. b: parseIntFromHex(match[3]),
  39391. format: named ? "name" : "hex"
  39392. };
  39393. }
  39394. if ((match = matchers.hex4.exec(color))) {
  39395. return {
  39396. r: parseIntFromHex(match[1] + '' + match[1]),
  39397. g: parseIntFromHex(match[2] + '' + match[2]),
  39398. b: parseIntFromHex(match[3] + '' + match[3]),
  39399. a: convertHexToDecimal(match[4] + '' + match[4]),
  39400. format: named ? "name" : "hex8"
  39401. };
  39402. }
  39403. if ((match = matchers.hex3.exec(color))) {
  39404. return {
  39405. r: parseIntFromHex(match[1] + '' + match[1]),
  39406. g: parseIntFromHex(match[2] + '' + match[2]),
  39407. b: parseIntFromHex(match[3] + '' + match[3]),
  39408. format: named ? "name" : "hex"
  39409. };
  39410. }
  39411. return false;
  39412. }
  39413. function validateWCAG2Parms(parms) {
  39414. // return valid WCAG2 parms for isReadable.
  39415. // If input parms are invalid, return {"level":"AA", "size":"small"}
  39416. var level, size;
  39417. parms = parms || {"level":"AA", "size":"small"};
  39418. level = (parms.level || "AA").toUpperCase();
  39419. size = (parms.size || "small").toLowerCase();
  39420. if (level !== "AA" && level !== "AAA") {
  39421. level = "AA";
  39422. }
  39423. if (size !== "small" && size !== "large") {
  39424. size = "small";
  39425. }
  39426. return {"level":level, "size":size};
  39427. }
  39428. // Node: Export function
  39429. if (typeof module !== "undefined" && module.exports) {
  39430. module.exports = tinycolor;
  39431. }
  39432. // AMD/requirejs: Define the module
  39433. else if (typeof define === 'function' && define.amd) {
  39434. define(function () {return tinycolor;});
  39435. }
  39436. // Browser: Expose to window
  39437. else {
  39438. window.tinycolor = tinycolor;
  39439. }
  39440. })(Math);